@webiny/api-aco 6.6.0-alpha.0 → 6.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AcoFeature.js +9 -2
- package/AcoFeature.js.map +1 -1
- package/AcoFolderSchemaFactory.d.ts +30 -0
- package/AcoFolderSchemaFactory.js +64 -0
- package/AcoFolderSchemaFactory.js.map +1 -0
- package/createAcoGraphQL.d.ts +3 -2
- package/createAcoGraphQL.js.map +1 -1
- package/domain/folder/abstractions.d.ts +12 -5
- package/domain/folder/abstractions.js +2 -2
- package/domain/folder/abstractions.js.map +1 -1
- package/features/ai/CreateFolderTool.d.ts +44 -0
- package/features/ai/CreateFolderTool.js +49 -0
- package/features/ai/CreateFolderTool.js.map +1 -0
- package/features/ai/CreateTeamTool.d.ts +43 -0
- package/features/ai/CreateTeamTool.js +47 -0
- package/features/ai/CreateTeamTool.js.map +1 -0
- package/features/ai/GrantFolderAccessTool.d.ts +72 -0
- package/features/ai/GrantFolderAccessTool.js +71 -0
- package/features/ai/GrantFolderAccessTool.js.map +1 -0
- package/features/ai/ListFoldersTool.d.ts +42 -0
- package/features/ai/ListFoldersTool.js +48 -0
- package/features/ai/ListFoldersTool.js.map +1 -0
- package/features/ai/ListRolesTool.d.ts +34 -0
- package/features/ai/ListRolesTool.js +39 -0
- package/features/ai/ListRolesTool.js.map +1 -0
- package/features/ai/ListTeamsTool.d.ts +34 -0
- package/features/ai/ListTeamsTool.js +39 -0
- package/features/ai/ListTeamsTool.js.map +1 -0
- package/features/ai/RevokeFolderAccessTool.d.ts +58 -0
- package/features/ai/RevokeFolderAccessTool.js +60 -0
- package/features/ai/RevokeFolderAccessTool.js.map +1 -0
- package/features/ai/assertTargetIsUsable.d.ts +10 -0
- package/features/ai/assertTargetIsUsable.js +14 -0
- package/features/ai/assertTargetIsUsable.js.map +1 -0
- package/features/ai/feature.d.ts +12 -0
- package/features/ai/feature.js +23 -0
- package/features/ai/feature.js.map +1 -0
- package/features/ai/index.d.ts +8 -0
- package/features/ai/index.js +8 -0
- package/features/ai/loadFolderPermissions.d.ts +16 -0
- package/features/ai/loadFolderPermissions.js +14 -0
- package/features/ai/loadFolderPermissions.js.map +1 -0
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.d.ts +3 -3
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +6 -6
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
- package/features/flp/UpdateFlp/UpdateFlpUseCase.d.ts +3 -3
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js +4 -3
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
- package/features/flp/UpdateFlp/feature.js +2 -2
- package/features/flp/UpdateFlp/feature.js.map +1 -1
- package/features/folder/CreateFolder/CreateFolderRepository.d.ts +3 -3
- package/features/folder/CreateFolder/CreateFolderRepository.js +10 -7
- package/features/folder/CreateFolder/CreateFolderRepository.js.map +1 -1
- package/features/folder/DeleteFolder/DeleteFolderRepository.d.ts +3 -3
- package/features/folder/DeleteFolder/DeleteFolderRepository.js +6 -5
- package/features/folder/DeleteFolder/DeleteFolderRepository.js.map +1 -1
- package/features/folder/FolderModelProvider.d.ts +26 -0
- package/features/folder/FolderModelProvider.js +22 -0
- package/features/folder/FolderModelProvider.js.map +1 -0
- package/features/folder/GetAncestors/GetAncestorsRepository.d.ts +3 -3
- package/features/folder/GetAncestors/GetAncestorsRepository.js +6 -5
- package/features/folder/GetAncestors/GetAncestorsRepository.js.map +1 -1
- package/features/folder/GetFolder/GetFolderRepository.d.ts +3 -3
- package/features/folder/GetFolder/GetFolderRepository.js +6 -5
- package/features/folder/GetFolder/GetFolderRepository.js.map +1 -1
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.d.ts +3 -3
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js +10 -8
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js.map +1 -1
- package/features/folder/ListFolders/ListFoldersRepository.d.ts +3 -3
- package/features/folder/ListFolders/ListFoldersRepository.js +8 -7
- package/features/folder/ListFolders/ListFoldersRepository.js.map +1 -1
- package/features/folder/UpdateFolder/UpdateFolderRepository.d.ts +3 -3
- package/features/folder/UpdateFolder/UpdateFolderRepository.js +11 -8
- package/features/folder/UpdateFolder/UpdateFolderRepository.js.map +1 -1
- package/folder/folder.gql.js +2 -2
- package/folder/folder.gql.js.map +1 -1
- package/package.json +23 -22
- package/AcoInitializer.d.ts +0 -25
- package/AcoInitializer.js +0 -79
- package/AcoInitializer.js.map +0 -1
package/AcoInitializer.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Container } from "@webiny/di";
|
|
2
|
-
import type { IRequestContextInitializer } from "@webiny/event-handler-core";
|
|
3
|
-
/**
|
|
4
|
-
* Per-request setup that cannot be a synchronous DI factory.
|
|
5
|
-
*
|
|
6
|
-
* The ACO facade (filter/flp CRUD, AcoFilterCrud / AcoFlpCrud / FilterStorageOperations) is a LAZY
|
|
7
|
-
* factory now — see AcoFeature.register. The only work that must stay eager, per request, before
|
|
8
|
-
* resolvers is:
|
|
9
|
-
*
|
|
10
|
-
* 1. Resolving the per-tenant folder model (async) and exposing it as FolderModelAbstraction.
|
|
11
|
-
* 2. Registering the WCP-gated CMS-entry FLP decorators (CmsFlpFeature) — they must be in place
|
|
12
|
-
* before any CMS-entry resolver runs, and the WCP license is only known post-RequestInitializer.
|
|
13
|
-
* 3. Building the dynamic folder GraphQL schema (needs the resolved folder model).
|
|
14
|
-
*/
|
|
15
|
-
declare class AcoInitializerImpl implements IRequestContextInitializer {
|
|
16
|
-
private container;
|
|
17
|
-
private initialized;
|
|
18
|
-
constructor(container: Container);
|
|
19
|
-
init(ctx: Record<string, any>): Promise<void>;
|
|
20
|
-
private _initialize;
|
|
21
|
-
}
|
|
22
|
-
export declare const AcoInitializer: typeof AcoInitializerImpl & {
|
|
23
|
-
__abstraction: import("@webiny/di").Abstraction<IRequestContextInitializer>;
|
|
24
|
-
};
|
|
25
|
-
export {};
|
package/AcoInitializer.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchemaPlugin } from "@webiny/api-graphql";
|
|
2
|
-
import { RequestContainer, RequestContextInitializer } from "@webiny/event-handler-core";
|
|
3
|
-
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
4
|
-
import { isHeadlessCmsReady } from "@webiny/api-headless-cms";
|
|
5
|
-
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
6
|
-
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
7
|
-
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/abstractions.js";
|
|
8
|
-
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
9
|
-
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
10
|
-
import { createGraphQLSchemaPluginFromFieldPlugins } from "@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js";
|
|
11
|
-
import { createFoldersSchema } from "./folder/folder.gql.js";
|
|
12
|
-
import { FOLDER_MODEL_ID } from "./domain/folder/folder.model.js";
|
|
13
|
-
import { FolderModel } from "./domain/folder/abstractions.js";
|
|
14
|
-
import { CmsFlpFeature } from "./features/cms/index.js";
|
|
15
|
-
class AcoInitializerImpl {
|
|
16
|
-
constructor(container){
|
|
17
|
-
this.container = container;
|
|
18
|
-
this.initialized = false;
|
|
19
|
-
}
|
|
20
|
-
async init(ctx) {
|
|
21
|
-
if (!this.initialized) {
|
|
22
|
-
this.initialized = true;
|
|
23
|
-
await this._initialize(ctx);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async _initialize(ctx) {
|
|
27
|
-
if (!await isHeadlessCmsReady(ctx)) return;
|
|
28
|
-
const identityContext = this.container.resolve(IdentityContext);
|
|
29
|
-
await identityContext.withoutAuthorization(async ()=>{
|
|
30
|
-
const folderModel = await this.container.resolve(GetModelUseCase).execute(FOLDER_MODEL_ID);
|
|
31
|
-
this.container.registerInstance(FolderModel, folderModel.value);
|
|
32
|
-
});
|
|
33
|
-
if (this.container.resolve(WcpContext).canUseFolderLevelPermissions()) CmsFlpFeature.register(this.container);
|
|
34
|
-
const fieldRegistry = this.container.resolve(CmsModelFieldToGraphQLRegistry);
|
|
35
|
-
await identityContext.withoutAuthorization(async ()=>{
|
|
36
|
-
const modelResult = await this.container.resolve(GetModelUseCase).execute(FOLDER_MODEL_ID);
|
|
37
|
-
if (modelResult.isFail()) throw modelResult.error;
|
|
38
|
-
const model = modelResult.value;
|
|
39
|
-
const modelsResult = await this.container.resolve(ListModelsUseCase).execute();
|
|
40
|
-
if (modelsResult.isFail()) throw modelsResult.error;
|
|
41
|
-
const models = modelsResult.value;
|
|
42
|
-
const fieldPlugins = createGraphQLSchemaPluginFromFieldPlugins({
|
|
43
|
-
models,
|
|
44
|
-
type: "manage",
|
|
45
|
-
fieldRegistry,
|
|
46
|
-
createPlugin: ({ schema, type, fieldType })=>{
|
|
47
|
-
const plugin = new GraphQLSchemaPlugin(schema);
|
|
48
|
-
plugin.name = `aco.graphql.folder.schema.${type}.field.${fieldType}`;
|
|
49
|
-
return plugin;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const graphQlPlugin = createFoldersSchema({
|
|
53
|
-
model,
|
|
54
|
-
models,
|
|
55
|
-
fieldRegistry
|
|
56
|
-
});
|
|
57
|
-
for (const p of [
|
|
58
|
-
...fieldPlugins,
|
|
59
|
-
graphQlPlugin
|
|
60
|
-
])this.container.registerInstance(CoreGraphQLSchemaFactory, {
|
|
61
|
-
async execute (builder) {
|
|
62
|
-
if (p.schema.typeDefs) builder.addTypeDefs(p.schema.typeDefs);
|
|
63
|
-
if (p.schema.resolvers) builder.addLegacyResolvers(p.schema.resolvers);
|
|
64
|
-
if (p.schema.resolverDecorators) for (const [path, decorators] of Object.entries(p.schema.resolverDecorators))for (const decorator of decorators)builder.addResolverDecorator(path, decorator);
|
|
65
|
-
return builder;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const AcoInitializer = RequestContextInitializer.createImplementation({
|
|
72
|
-
implementation: AcoInitializerImpl,
|
|
73
|
-
dependencies: [
|
|
74
|
-
RequestContainer
|
|
75
|
-
]
|
|
76
|
-
});
|
|
77
|
-
export { AcoInitializer };
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=AcoInitializer.js.map
|
package/AcoInitializer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AcoInitializer.js","sources":["../src/AcoInitializer.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { GraphQLSchemaPlugin } from \"@webiny/api-graphql\";\nimport { RequestContextInitializer } from \"@webiny/event-handler-core\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IRequestContextInitializer } from \"@webiny/event-handler-core\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/api-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport { RequestContainer } from \"@webiny/event-handler-core\";\nimport { isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { createGraphQLSchemaPluginFromFieldPlugins } from \"@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createFoldersSchema } from \"~/folder/folder.gql.js\";\nimport { FOLDER_MODEL_ID } from \"~/domain/folder/folder.model.js\";\nimport { FolderModel as FolderModelAbstraction } from \"~/domain/folder/abstractions.js\";\nimport { CmsFlpFeature } from \"~/features/cms/index.js\";\nimport type { AcoContext } from \"~/types.js\";\n\n/**\n * Per-request setup that cannot be a synchronous DI factory.\n *\n * The ACO facade (filter/flp CRUD, AcoFilterCrud / AcoFlpCrud / FilterStorageOperations) is a LAZY\n * factory now — see AcoFeature.register. The only work that must stay eager, per request, before\n * resolvers is:\n *\n * 1. Resolving the per-tenant folder model (async) and exposing it as FolderModelAbstraction.\n * 2. Registering the WCP-gated CMS-entry FLP decorators (CmsFlpFeature) — they must be in place\n * before any CMS-entry resolver runs, and the WCP license is only known post-RequestInitializer.\n * 3. Building the dynamic folder GraphQL schema (needs the resolved folder model).\n */\nclass AcoInitializerImpl implements IRequestContextInitializer {\n private initialized = false;\n\n constructor(private container: Container) {}\n\n async init(ctx: Record<string, any>): Promise<void> {\n if (!this.initialized) {\n this.initialized = true;\n await this._initialize(ctx);\n }\n }\n\n private async _initialize(ctx: Record<string, any>): Promise<void> {\n if (!(await isHeadlessCmsReady(ctx as AcoContext))) {\n return;\n }\n\n const identityContext = this.container.resolve(IdentityContext);\n\n // Expose the per-tenant folder model.\n await identityContext.withoutAuthorization(async () => {\n const folderModel = await this.container\n .resolve(GetModelUseCase)\n .execute(FOLDER_MODEL_ID);\n this.container.registerInstance(FolderModelAbstraction, folderModel.value);\n });\n\n // CMS-entry folder-level-permission decorators (WCP-gated). Must be registered before any\n // CMS-entry resolver runs, so this stays in the (pre-resolver) initializer rather than a\n // lazy factory.\n if (this.container.resolve(WcpContext).canUseFolderLevelPermissions()) {\n CmsFlpFeature.register(this.container);\n }\n\n // Dynamic folder schema: register each field/folder schema plugin as a CoreGraphQLSchemaFactory.\n const fieldRegistry = this.container.resolve(CmsModelFieldToGraphQLRegistry);\n await identityContext.withoutAuthorization(async () => {\n const modelResult = await this.container\n .resolve(GetModelUseCase)\n .execute(FOLDER_MODEL_ID);\n if (modelResult.isFail()) {\n throw modelResult.error;\n }\n const model = modelResult.value as CmsModel;\n\n const modelsResult = await this.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const models = modelsResult.value;\n\n const fieldPlugins = createGraphQLSchemaPluginFromFieldPlugins({\n models,\n type: \"manage\",\n fieldRegistry,\n createPlugin: ({ schema, type, fieldType }) => {\n const plugin = new GraphQLSchemaPlugin(schema);\n plugin.name = `aco.graphql.folder.schema.${type}.field.${fieldType}`;\n return plugin;\n }\n });\n\n const graphQlPlugin = createFoldersSchema({ model, models, fieldRegistry });\n\n for (const p of [...fieldPlugins, graphQlPlugin] as IGraphQLSchemaPlugin[]) {\n this.container.registerInstance(CoreGraphQLSchemaFactory, {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n if (p.schema.typeDefs) {\n builder.addTypeDefs(p.schema.typeDefs);\n }\n if (p.schema.resolvers) {\n builder.addLegacyResolvers(p.schema.resolvers as Record<string, any>);\n }\n if (p.schema.resolverDecorators) {\n for (const [path, decorators] of Object.entries(\n p.schema.resolverDecorators\n )) {\n for (const decorator of decorators as any[]) {\n builder.addResolverDecorator(path, decorator);\n }\n }\n }\n return builder;\n }\n });\n }\n });\n }\n}\n\nexport const AcoInitializer = RequestContextInitializer.createImplementation({\n implementation: AcoInitializerImpl,\n dependencies: [RequestContainer]\n});\n"],"names":["AcoInitializerImpl","container","ctx","isHeadlessCmsReady","identityContext","IdentityContext","folderModel","GetModelUseCase","FOLDER_MODEL_ID","FolderModelAbstraction","WcpContext","CmsFlpFeature","fieldRegistry","CmsModelFieldToGraphQLRegistry","modelResult","model","modelsResult","ListModelsUseCase","models","fieldPlugins","createGraphQLSchemaPluginFromFieldPlugins","schema","type","fieldType","plugin","GraphQLSchemaPlugin","graphQlPlugin","createFoldersSchema","p","CoreGraphQLSchemaFactory","builder","path","decorators","Object","decorator","AcoInitializer","RequestContextInitializer","RequestContainer"],"mappings":";;;;;;;;;;;;;;AAkCA,MAAMA;IAGF,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;aAFZ,WAAW,GAAG;IAEqB;IAE3C,MAAM,KAAKC,GAAwB,EAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG;YACnB,MAAM,IAAI,CAAC,WAAW,CAACA;QAC3B;IACJ;IAEA,MAAc,YAAYA,GAAwB,EAAiB;QAC/D,IAAI,CAAE,MAAMC,mBAAmBD,MAC3B;QAGJ,MAAME,kBAAkB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAG/C,MAAMD,gBAAgB,oBAAoB,CAAC;YACvC,MAAME,cAAc,MAAM,IAAI,CAAC,SAAS,CACnC,OAAO,CAACC,iBACR,OAAO,CAACC;YACb,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAACC,aAAwBH,YAAY,KAAK;QAC7E;QAKA,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAACI,YAAY,4BAA4B,IAC/DC,cAAc,QAAQ,CAAC,IAAI,CAAC,SAAS;QAIzC,MAAMC,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7C,MAAMT,gBAAgB,oBAAoB,CAAC;YACvC,MAAMU,cAAc,MAAM,IAAI,CAAC,SAAS,CACnC,OAAO,CAACP,iBACR,OAAO,CAACC;YACb,IAAIM,YAAY,MAAM,IAClB,MAAMA,YAAY,KAAK;YAE3B,MAAMC,QAAQD,YAAY,KAAK;YAE/B,MAAME,eAAe,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC,mBAAmB,OAAO;YAC5E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;YAE5B,MAAME,SAASF,aAAa,KAAK;YAEjC,MAAMG,eAAeC,0CAA0C;gBAC3DF;gBACA,MAAM;gBACNN;gBACA,cAAc,CAAC,EAAES,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAE;oBACtC,MAAMC,SAAS,IAAIC,oBAAoBJ;oBACvCG,OAAO,IAAI,GAAG,CAAC,0BAA0B,EAAEF,KAAK,OAAO,EAAEC,WAAW;oBACpE,OAAOC;gBACX;YACJ;YAEA,MAAME,gBAAgBC,oBAAoB;gBAAEZ;gBAAOG;gBAAQN;YAAc;YAEzE,KAAK,MAAMgB,KAAK;mBAAIT;gBAAcO;aAAc,CAC5C,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAACG,0BAA0B;gBACtD,MAAM,SAAQC,OAA8B;oBACxC,IAAIF,EAAE,MAAM,CAAC,QAAQ,EACjBE,QAAQ,WAAW,CAACF,EAAE,MAAM,CAAC,QAAQ;oBAEzC,IAAIA,EAAE,MAAM,CAAC,SAAS,EAClBE,QAAQ,kBAAkB,CAACF,EAAE,MAAM,CAAC,SAAS;oBAEjD,IAAIA,EAAE,MAAM,CAAC,kBAAkB,EAC3B,KAAK,MAAM,CAACG,MAAMC,WAAW,IAAIC,OAAO,OAAO,CAC3CL,EAAE,MAAM,CAAC,kBAAkB,EAE3B,KAAK,MAAMM,aAAaF,WACpBF,QAAQ,oBAAoB,CAACC,MAAMG;oBAI/C,OAAOJ;gBACX;YACJ;QAER;IACJ;AACJ;AAEO,MAAMK,iBAAiBC,0BAA0B,oBAAoB,CAAC;IACzE,gBAAgBpC;IAChB,cAAc;QAACqC;KAAiB;AACpC"}
|