Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some updates #2908

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ site

# Optional npm cache directory
.npm

.idea

# allow folks to add things to the debug /launch and /serve folder, but don't include them in git
Expand All @@ -55,3 +54,6 @@ settings.js

# don't save the locally produced .js of the buildsystem config
buildsystem-config.js

# never accidentally include any .js files that are generated in the main package source tree
packages/**/*.js
4 changes: 2 additions & 2 deletions packages/azidjsclient/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PnPClientStorage, getHashCode } from "@pnp/core/index.js";
import { Queryable } from "@pnp/queryable/index.js";
import { PnPClientStorage, getHashCode } from "@pnp/core";
import { Queryable } from "@pnp/queryable";
import {
AccessToken,
AuthorizationCodeCredential,
Expand Down
2 changes: 1 addition & 1 deletion packages/graph/appCatalog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TeamworkBot as ITeamworkBot } from "@microsoft/microsoft-graph-types";
import { _GraphCollection, graphInvokableFactory, _GraphInstance, graphPost, graphDelete, graphGet } from "../graphqueryable.js";
import { IGetById, defaultPath, getById } from "../decorators.js";
import { InjectHeaders } from "@pnp/queryable/index.js";
import { InjectHeaders } from "@pnp/queryable";

/**
* AppCatalogs
Expand Down
24 changes: 0 additions & 24 deletions packages/queryable/behaviors/diagnostics-jwt-decode.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/queryable/behaviors/resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TimelinePipe } from "../../core/timeline.js";
import { TimelinePipe } from "@pnp/core";
import { Queryable } from "../queryable.js";

export function ResolveOnData(): TimelinePipe {
Expand Down
5 changes: 0 additions & 5 deletions packages/queryable/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { jsS } from "@pnp/core";

export * from "./invokable.js";
export * from "./queryable.js";

/**
Expand All @@ -16,10 +15,6 @@ export * from "./behaviors/parsers.js";
export * from "./behaviors/timeout.js";
export * from "./behaviors/resolvers.js";


// testing
export * from "./behaviors/diagnostics-jwt-decode.js";

/**
* Adds a property to a target instance
*
Expand Down
40 changes: 0 additions & 40 deletions packages/queryable/invokable.ts

This file was deleted.

43 changes: 40 additions & 3 deletions packages/queryable/queryable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
import { combine, getGUID, Timeline, asyncReduce, reduce, broadcast, request, isArray, TimelinePipe, lifecycle, stringIsNullOrEmpty } from "@pnp/core";
import { IInvokable, invokable } from "./invokable.js";
import { combine, getGUID, Timeline, asyncReduce, reduce, broadcast, request, isArray, TimelinePipe, lifecycle, stringIsNullOrEmpty, isFunc } from "@pnp/core";

export type QueryableConstructObserver = (this: IQueryableInternal, init: QueryableInit, path?: string) => void;

Expand Down Expand Up @@ -32,6 +30,7 @@ const DefaultMoments = {
export type QueryableInit = Queryable<any> | string | [Queryable<any>, string];

@invokable()
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class Queryable<R> extends Timeline<typeof DefaultMoments> implements IQueryableInternal<R> {

// tracks any query parameters which will be appended to the request url
Expand Down Expand Up @@ -291,3 +290,41 @@ export function queryableFactory<InstanceType extends IQueryableInternal>(
return instance;
};
}

/**
* Allows a decorated object to be invoked as a function, optionally providing an implementation for that action
*
* @param invokeableAction Optional. The logic to execute upon invoking the object as a function.
* @returns Decorator which applies the invokable logic to the tagged class
*/
export function invokable(invokeableAction?: (this: any, init?: RequestInit) => Promise<any>) {

return (target: any) => {

return new Proxy(target, {

construct(clz, args, newTarget: any) {

const invokableInstance = Object.assign(function (init?: RequestInit) {

if (!isFunc(invokeableAction)) {
invokeableAction = function (this: any, init?: RequestInit) {
return op(this, get, init);
};
}

return Reflect.apply(invokeableAction, invokableInstance, [init]);

}, Reflect.construct(clz, args, newTarget));

Reflect.setPrototypeOf(invokableInstance, newTarget.prototype);

return invokableInstance;
},
});
};
}

export interface IInvokable<R = any> {
<T = R>(init?: RequestInit): Promise<T>;
}
5 changes: 2 additions & 3 deletions packages/sp-admin/tenant.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// import { body } from "@pnp/queryable";
import { body, BufferParse } from "@pnp/queryable";
import { _SPInstance, defaultPath, spInvokableFactory, spPost } from "@pnp/sp";
import { IRenderListDataParameters } from "@pnp/sp/lists/index.js";
import { IHubSiteInfo } from "@pnp/sp/hubsites/index.js";
import { IRenderListDataParameters } from "@pnp/sp/lists";
import { IHubSiteInfo } from "@pnp/sp/hubsites";
import {
IHomeSitesDetails,
IPortalHealthStatus,
Expand Down
Loading