Skip to content

Commit

Permalink
commenting out wip changes
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-rodgers committed Feb 27, 2024
1 parent 65f1cca commit 5f03203
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
29 changes: 15 additions & 14 deletions packages/queryable/queryable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export interface Queryable<R = any> extends IInvokable<R> { }
// this interface is required to stop the class from recursively referencing itself through the DefaultBehaviors type
export interface IQueryableInternal<R = any> extends Timeline<any>, IInvokable {
readonly query: URLSearchParams;
new(...params: any[]);
// new(...params: any[]);
<T = R>(this: IQueryableInternal, init?: RequestInit): Promise<T>;
using(...behaviors: TimelinePipe[]): this;
toRequestUrl(): string;
Expand Down Expand Up @@ -269,7 +269,7 @@ export function op<T>(q: IQueryableInternal, operation: Operation, init?: Reques
return Reflect.apply(operation, q, [init]);
}

export function queryableFactory<InstanceType extends IQueryableInternal>(
export function queryableFactory<InstanceType>(
constructor: { new(init: QueryableInit, path?: string): InstanceType },
): (init: QueryableInit, path?: string) => InstanceType {

Expand All @@ -287,22 +287,23 @@ export function queryableFactory<InstanceType extends IQueryableInternal>(
};
}

// extends IQueryableInternal
export function queryableFactory2<InstanceType extends IQueryableInternal>(constructor: InstanceType): (...args: ConstructorParameters<InstanceType>) => InstanceType & IInvokable {
// // extends IQueryableInternal
// export function queryableFactory2<InstanceType extends IQueryableInternal>(constructor: InstanceType):
// (...args: ConstructorParameters<InstanceType>) => InstanceType & IInvokable {

return (...args: ConstructorParameters<InstanceType>) => {
// return (...args: ConstructorParameters<InstanceType>) => {

// construct the concrete instance
const instance: InstanceType = new constructor(...args);
// // construct the concrete instance
// const instance: InstanceType = new constructor(...args);

// we emit the construct event from the factory because we need all of the decorators and constructors
// to have fully finished before we emit, which is now true. We type the instance to any to get around
// the protected nature of emit
(<any>instance).emit.construct(...args);
// // we emit the construct event from the factory because we need all of the decorators and constructors
// // to have fully finished before we emit, which is now true. We type the instance to any to get around
// // the protected nature of emit
// (<any>instance).emit.construct(...args);

return instance;
};
}
// return instance;
// };
// }

/**
* Allows a decorated object to be invoked as a function, optionally providing an implementation for that action
Expand Down
10 changes: 5 additions & 5 deletions packages/sp/spqueryable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { combine, isUrlAbsolute, isArray, objectDefinedNotNull, stringIsNullOrEmpty } from "@pnp/core";
import { Queryable, queryableFactory, queryableFactory2, op, get, post, patch, del, IInvokable } from "@pnp/queryable";
import { Queryable, queryableFactory, op, get, post, patch, del, IInvokable } from "@pnp/queryable";

export type SPInit = string | ISPQueryable | [ISPQueryable, string];

Expand All @@ -15,16 +15,16 @@ export const spInvokableFactory = <R extends ISPQueryable>(f: any): ISPInvokable



export type ISPInvokableFactory2<R extends ISPQueryable> = (...args: any[]) => R & IInvokable;
// export type ISPInvokableFactory2<R extends ISPQueryable> = (...args: any[]) => R & IInvokable;

export const spInvokableFactory2 = <R extends ISPQueryable<T>, T extends ISPQueryable>(f: T): ISPInvokableFactory2<R> => {
// export const spInvokableFactory2 = <R extends ISPQueryable<T>, T extends ISPQueryable>(f: T): ISPInvokableFactory2<R> => {





return queryableFactory2<R>(f);
};
// return queryableFactory2<R>(f);
// };


/**
Expand Down

0 comments on commit 5f03203

Please sign in to comment.