@webiny/api-aco 6.4.5-beta.0 → 6.6.0-alpha.0
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.d.ts +5 -0
- package/AcoFeature.js +122 -0
- package/AcoFeature.js.map +1 -0
- package/AcoInitializer.d.ts +25 -0
- package/AcoInitializer.js +79 -0
- package/AcoInitializer.js.map +1 -0
- package/createAcoGraphQL.d.ts +7 -4
- package/createAcoGraphQL.js +56 -96
- package/createAcoGraphQL.js.map +1 -1
- package/exports/api/aco/folder.d.ts +1 -1
- package/exports/api/aco/folder.js +1 -1
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/MoveEntryWithFlpDecorator.d.ts +1 -1
- package/features/flp/CreateFlp/CreateFlpUseCase.d.ts +3 -3
- package/features/flp/CreateFlp/CreateFlpUseCase.js +4 -4
- package/features/flp/CreateFlp/CreateFlpUseCase.js.map +1 -1
- package/features/flp/CreateFlp/feature.d.ts +1 -6
- package/features/flp/CreateFlp/feature.js +3 -2
- package/features/flp/CreateFlp/feature.js.map +1 -1
- package/features/flp/DeleteFlp/DeleteFlpUseCase.d.ts +3 -3
- package/features/flp/DeleteFlp/DeleteFlpUseCase.js +3 -3
- package/features/flp/DeleteFlp/DeleteFlpUseCase.js.map +1 -1
- package/features/flp/DeleteFlp/feature.d.ts +1 -6
- package/features/flp/DeleteFlp/feature.js +3 -2
- package/features/flp/DeleteFlp/feature.js.map +1 -1
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.d.ts +25 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js +48 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js.map +1 -0
- package/features/flp/FolderLevelPermissions/index.d.ts +1 -0
- package/features/flp/FolderLevelPermissions/index.js +1 -0
- package/features/flp/GetFlp/feature.d.ts +1 -1
- package/features/flp/GetFlp/feature.js +3 -2
- package/features/flp/GetFlp/feature.js.map +1 -1
- package/features/flp/ListFlps/feature.d.ts +1 -1
- package/features/flp/ListFlps/feature.js +3 -2
- package/features/flp/ListFlps/feature.js.map +1 -1
- package/features/flp/UpdateFlp/UpdateFlpUseCase.d.ts +11 -3
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js +14 -13
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
- package/features/flp/UpdateFlp/feature.d.ts +1 -6
- package/features/flp/UpdateFlp/feature.js +7 -2
- package/features/flp/UpdateFlp/feature.js.map +1 -1
- package/features/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.d.ts +1 -1
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +4 -0
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js +4 -0
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js.map +1 -1
- package/features/folder/GetFolder/decorators/GetFolderWithFolderLevelPermissions.d.ts +8 -8
- package/features/folder/shared/abstractions.d.ts +14 -0
- package/features/folder/shared/abstractions.js +4 -1
- package/features/folder/shared/abstractions.js.map +1 -1
- package/filter/filter.gql.d.ts +2 -3
- package/filter/filter.gql.js +61 -27
- package/filter/filter.gql.js.map +1 -1
- package/filter/filter.so.d.ts +10 -2
- package/filter/filter.so.js +2 -2
- package/filter/filter.so.js.map +1 -1
- package/flp/index.d.ts +0 -1
- package/flp/index.js +0 -1
- package/flp/tasks/createFlp.task.d.ts +2 -2
- package/flp/tasks/deleteFlp.task.d.ts +2 -2
- package/flp/tasks/index.d.ts +0 -1
- package/flp/tasks/index.js +1 -14
- package/flp/tasks/index.js.map +1 -1
- package/flp/tasks/syncFlp.task.d.ts +2 -2
- package/flp/tasks/syncFlp.task.js +12 -0
- package/flp/tasks/syncFlp.task.js.map +1 -1
- package/flp/tasks/updateFlp.task.d.ts +2 -2
- package/folder/folder.gql.d.ts +1 -1
- package/folder/folder.gql.js +9 -3
- package/folder/folder.gql.js.map +1 -1
- package/index.d.ts +1 -6
- package/index.js +1 -11
- package/package.json +20 -22
- package/utils/createOperationsWrapper.d.ts +5 -2
- package/utils/createOperationsWrapper.js +2 -2
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.js +9 -5
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
- package/utils/resolve.d.ts +2 -2
- package/utils/resolve.js +1 -1
- package/utils/resolve.js.map +1 -1
- package/createAcoContext.d.ts +0 -9
- package/createAcoContext.js +0 -109
- package/createAcoContext.js.map +0 -1
- package/createAcoStorageOperations.d.ts +0 -12
- package/createAcoStorageOperations.js +0 -9
- package/createAcoStorageOperations.js.map +0 -1
- package/createAcoTasks.d.ts +0 -1
- package/createAcoTasks.js +0 -14
- package/createAcoTasks.js.map +0 -1
- package/flp/flp.so.d.ts +0 -20
- package/flp/flp.so.js +0 -183
- package/flp/flp.so.js.map +0 -1
- package/index.js.map +0 -1
package/AcoFeature.d.ts
ADDED
package/AcoFeature.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
3
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
4
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
5
|
+
import { HeadlessCms } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
import { addAcoBaseSchema } from "./createAcoGraphQL.js";
|
|
7
|
+
import { addFilterSchema } from "./filter/filter.gql.js";
|
|
8
|
+
import { AcoInitializer } from "./AcoInitializer.js";
|
|
9
|
+
import { CreateFlpTask } from "./flp/tasks/createFlp.task.js";
|
|
10
|
+
import { UpdateFlpTask } from "./flp/tasks/updateFlp.task.js";
|
|
11
|
+
import { DeleteFlpTask } from "./flp/tasks/deleteFlp.task.js";
|
|
12
|
+
import { SyncFlpTask } from "./flp/tasks/syncFlp.task.js";
|
|
13
|
+
import { FolderModel } from "./domain/folder/folder.model.js";
|
|
14
|
+
import { FilterPrivateModel } from "./filter/filter.model.js";
|
|
15
|
+
import { createFilterOperations } from "./filter/filter.so.js";
|
|
16
|
+
import { createFilterCrudMethods } from "./filter/filter.crud.js";
|
|
17
|
+
import { createFlpCrudMethods } from "./flp/index.js";
|
|
18
|
+
import { FolderLevelPermissions, FolderLevelPermissionsFeature } from "./features/flp/FolderLevelPermissions/index.js";
|
|
19
|
+
import { UpdateFolderFeature } from "./features/folder/UpdateFolder/index.js";
|
|
20
|
+
import { DeleteFolderFeature } from "./features/folder/DeleteFolder/index.js";
|
|
21
|
+
import { CreateFolderFeature } from "./features/folder/CreateFolder/index.js";
|
|
22
|
+
import { GetFolderFeature } from "./features/folder/GetFolder/index.js";
|
|
23
|
+
import { ListFoldersFeature } from "./features/folder/ListFolders/index.js";
|
|
24
|
+
import { GetFolderHierarchyFeature } from "./features/folder/GetFolderHierarchy/index.js";
|
|
25
|
+
import { GetAncestorsFeature } from "./features/folder/GetAncestors/index.js";
|
|
26
|
+
import { UpdateFlpOnFolderUpdatedFeature } from "./features/flp/UpdateFlpOnFolderUpdated/index.js";
|
|
27
|
+
import { DeleteFlpOnFolderDeletedFeature } from "./features/flp/DeleteFlpOnFolderDeleted/index.js";
|
|
28
|
+
import { EnsureHcmsFolderIsEmptyOnDeleteFeature } from "./features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js";
|
|
29
|
+
import { CreateFlpFeature } from "./features/flp/CreateFlp/index.js";
|
|
30
|
+
import { DeleteFlpFeature } from "./features/flp/DeleteFlp/index.js";
|
|
31
|
+
import { UpdateFlpFeature } from "./features/flp/UpdateFlp/index.js";
|
|
32
|
+
import { EnsureFolderIsEmptyOnDeleteFeature } from "./features/folder/EnsureFolderIsEmptyOnDelete/index.js";
|
|
33
|
+
import { AcoFilterCrud, AcoFlpCrud, FilterStorageOperations, FlpStorageOperations } from "./features/folder/shared/abstractions.js";
|
|
34
|
+
import { ListFlpsFeature } from "./features/flp/ListFlps/feature.js";
|
|
35
|
+
import { GetFlpFeature } from "./features/flp/GetFlp/feature.js";
|
|
36
|
+
import { ListFolderLevelPermissionsTargetsFeature } from "./features/folder/ListFolderLevelPermissionsTargets/feature.js";
|
|
37
|
+
import { CreateFlpOnFolderCreatedFeature } from "./features/flp/CreateFlpOnFolderCreated/index.js";
|
|
38
|
+
import { EnsureFolderIsEmptyFeature } from "./features/folder/EnsureFolderIsEmpty/feature.js";
|
|
39
|
+
class AcoSchemaFactoryImpl {
|
|
40
|
+
async execute(builder) {
|
|
41
|
+
addAcoBaseSchema(builder);
|
|
42
|
+
addFilterSchema(builder);
|
|
43
|
+
return builder;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const AcoSchemaFactory = GraphQLSchemaFactory.createImplementation({
|
|
47
|
+
implementation: AcoSchemaFactoryImpl,
|
|
48
|
+
dependencies: []
|
|
49
|
+
});
|
|
50
|
+
const AcoFeature = createFeature({
|
|
51
|
+
name: "Aco",
|
|
52
|
+
register (container) {
|
|
53
|
+
container.register(FolderModel);
|
|
54
|
+
container.register(FilterPrivateModel);
|
|
55
|
+
container.register(CreateFlpTask);
|
|
56
|
+
container.register(UpdateFlpTask);
|
|
57
|
+
container.register(DeleteFlpTask);
|
|
58
|
+
container.register(SyncFlpTask);
|
|
59
|
+
FolderLevelPermissionsFeature.register(container);
|
|
60
|
+
CreateFolderFeature.register(container);
|
|
61
|
+
UpdateFolderFeature.register(container);
|
|
62
|
+
DeleteFolderFeature.register(container);
|
|
63
|
+
GetFolderFeature.register(container);
|
|
64
|
+
ListFoldersFeature.register(container);
|
|
65
|
+
ListFolderLevelPermissionsTargetsFeature.register(container);
|
|
66
|
+
GetFolderHierarchyFeature.register(container);
|
|
67
|
+
GetAncestorsFeature.register(container);
|
|
68
|
+
EnsureFolderIsEmptyFeature.register(container);
|
|
69
|
+
CreateFlpFeature.register(container);
|
|
70
|
+
UpdateFlpFeature.register(container);
|
|
71
|
+
DeleteFlpFeature.register(container);
|
|
72
|
+
ListFlpsFeature.register(container);
|
|
73
|
+
GetFlpFeature.register(container);
|
|
74
|
+
CreateFlpOnFolderCreatedFeature.register(container);
|
|
75
|
+
UpdateFlpOnFolderUpdatedFeature.register(container);
|
|
76
|
+
DeleteFlpOnFolderDeletedFeature.register(container);
|
|
77
|
+
EnsureFolderIsEmptyOnDeleteFeature.register(container);
|
|
78
|
+
EnsureHcmsFolderIsEmptyOnDeleteFeature.register(container);
|
|
79
|
+
const getTenant = ()=>container.resolve(TenantContext).getTenant();
|
|
80
|
+
let storageOperations;
|
|
81
|
+
const getStorageOperations = ()=>{
|
|
82
|
+
if (!storageOperations) {
|
|
83
|
+
const cms = container.resolve(HeadlessCms);
|
|
84
|
+
const identityContext = container.resolve(IdentityContext);
|
|
85
|
+
storageOperations = {
|
|
86
|
+
filter: createFilterOperations({
|
|
87
|
+
cms,
|
|
88
|
+
identityContext,
|
|
89
|
+
container
|
|
90
|
+
}),
|
|
91
|
+
flp: container.resolve(FlpStorageOperations)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return storageOperations;
|
|
95
|
+
};
|
|
96
|
+
let flpCrudMethods;
|
|
97
|
+
const getFlpCrudMethods = ()=>{
|
|
98
|
+
if (!flpCrudMethods) flpCrudMethods = createFlpCrudMethods({
|
|
99
|
+
getTenant,
|
|
100
|
+
storageOperations: getStorageOperations()
|
|
101
|
+
});
|
|
102
|
+
return flpCrudMethods;
|
|
103
|
+
};
|
|
104
|
+
container.registerFactory(AcoFlpCrud, ()=>getFlpCrudMethods());
|
|
105
|
+
container.registerFactory(FilterStorageOperations, ()=>getStorageOperations().filter);
|
|
106
|
+
let filterCrudMethods;
|
|
107
|
+
container.registerFactory(AcoFilterCrud, ()=>{
|
|
108
|
+
if (!filterCrudMethods) filterCrudMethods = createFilterCrudMethods({
|
|
109
|
+
container,
|
|
110
|
+
getTenant,
|
|
111
|
+
storageOperations: getStorageOperations(),
|
|
112
|
+
folderLevelPermissions: container.resolve(FolderLevelPermissions)
|
|
113
|
+
});
|
|
114
|
+
return filterCrudMethods;
|
|
115
|
+
});
|
|
116
|
+
container.register(AcoInitializer);
|
|
117
|
+
container.register(AcoSchemaFactory);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
export { AcoFeature };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=AcoFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcoFeature.js","sources":["../src/AcoFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { Container } from \"@webiny/di\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { addAcoBaseSchema } from \"./createAcoGraphQL.js\";\nimport { addFilterSchema } from \"~/filter/filter.gql.js\";\nimport { AcoInitializer } from \"./AcoInitializer.js\";\nimport { CreateFlpTask } from \"~/flp/tasks/createFlp.task.js\";\nimport { UpdateFlpTask } from \"~/flp/tasks/updateFlp.task.js\";\nimport { DeleteFlpTask } from \"~/flp/tasks/deleteFlp.task.js\";\nimport { SyncFlpTask } from \"~/flp/tasks/syncFlp.task.js\";\nimport type { AcoStorageOperations } from \"~/types.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\nimport { FolderModel } from \"~/domain/folder/folder.model.js\";\nimport { FilterPrivateModel } from \"~/filter/filter.model.js\";\n// Facade wiring (moved here from createAcoContext so the ACO facade can be a lazy DI factory).\nimport { createFilterOperations } from \"~/filter/filter.so.js\";\nimport { createFilterCrudMethods } from \"~/filter/filter.crud.js\";\nimport { createFlpCrudMethods } from \"~/flp/index.js\";\nimport {\n FolderLevelPermissions,\n FolderLevelPermissionsFeature\n} from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { UpdateFolderFeature } from \"~/features/folder/UpdateFolder/index.js\";\nimport { DeleteFolderFeature } from \"~/features/folder/DeleteFolder/index.js\";\nimport { CreateFolderFeature } from \"~/features/folder/CreateFolder/index.js\";\nimport { GetFolderFeature } from \"~/features/folder/GetFolder/index.js\";\nimport { ListFoldersFeature } from \"~/features/folder/ListFolders/index.js\";\nimport { GetFolderHierarchyFeature } from \"~/features/folder/GetFolderHierarchy/index.js\";\nimport { GetAncestorsFeature } from \"~/features/folder/GetAncestors/index.js\";\nimport { UpdateFlpOnFolderUpdatedFeature } from \"~/features/flp/UpdateFlpOnFolderUpdated/index.js\";\nimport { DeleteFlpOnFolderDeletedFeature } from \"~/features/flp/DeleteFlpOnFolderDeleted/index.js\";\nimport { EnsureHcmsFolderIsEmptyOnDeleteFeature } from \"~/features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js\";\nimport { CreateFlpFeature } from \"~/features/flp/CreateFlp/index.js\";\nimport { DeleteFlpFeature } from \"~/features/flp/DeleteFlp/index.js\";\nimport { UpdateFlpFeature } from \"~/features/flp/UpdateFlp/index.js\";\nimport { EnsureFolderIsEmptyOnDeleteFeature } from \"~/features/folder/EnsureFolderIsEmptyOnDelete/index.js\";\nimport {\n AcoFilterCrud,\n AcoFlpCrud,\n FilterStorageOperations,\n FlpStorageOperations\n} from \"~/features/folder/shared/abstractions.js\";\nimport { ListFlpsFeature } from \"~/features/flp/ListFlps/feature.js\";\nimport { GetFlpFeature } from \"~/features/flp/GetFlp/feature.js\";\nimport { ListFolderLevelPermissionsTargetsFeature } from \"~/features/folder/ListFolderLevelPermissionsTargets/feature.js\";\nimport { CreateFlpOnFolderCreatedFeature } from \"~/features/flp/CreateFlpOnFolderCreated/index.js\";\nimport { EnsureFolderIsEmptyFeature } from \"~/features/folder/EnsureFolderIsEmpty/feature.js\";\n\nclass AcoSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n // Static ACO base + filter schema (DI-native contributors declaring their deps). The dynamic\n // folder schema (needs the per-tenant folder model) is still built by AcoInitializer.\n addAcoBaseSchema(builder);\n addFilterSchema(builder);\n return builder;\n }\n}\n\nconst AcoSchemaFactory = GraphQLSchemaFactory.createImplementation({\n implementation: AcoSchemaFactoryImpl,\n dependencies: []\n});\n\nexport const AcoFeature = createFeature({\n name: \"Aco\",\n register(container: Container) {\n container.register(FolderModel);\n container.register(FilterPrivateModel);\n\n // Background task definitions — pure wiring, no tenant/identity needed.\n container.register(CreateFlpTask);\n container.register(UpdateFlpTask);\n container.register(DeleteFlpTask);\n container.register(SyncFlpTask);\n\n // Folder + FLP use-case features — pure DI wiring (all lazy). Moved out of the per-request\n // initializer so they're registered for every event, not only GraphQL requests.\n FolderLevelPermissionsFeature.register(container);\n CreateFolderFeature.register(container);\n UpdateFolderFeature.register(container);\n DeleteFolderFeature.register(container);\n GetFolderFeature.register(container);\n ListFoldersFeature.register(container);\n ListFolderLevelPermissionsTargetsFeature.register(container);\n GetFolderHierarchyFeature.register(container);\n GetAncestorsFeature.register(container);\n EnsureFolderIsEmptyFeature.register(container);\n CreateFlpFeature.register(container);\n UpdateFlpFeature.register(container);\n DeleteFlpFeature.register(container);\n ListFlpsFeature.register(container);\n GetFlpFeature.register(container);\n CreateFlpOnFolderCreatedFeature.register(container);\n UpdateFlpOnFolderUpdatedFeature.register(container);\n DeleteFlpOnFolderDeletedFeature.register(container);\n EnsureFolderIsEmptyOnDeleteFeature.register(container);\n EnsureHcmsFolderIsEmptyOnDeleteFeature.register(container);\n\n // ===== Lazy ACO facade =====\n // Built on first resolve (post-auth) so the HeadlessCms facade (also lazy) is resolved on\n // demand. Memoised per request container. Consumers resolve AcoFlpCrud / AcoFilterCrud /\n // FilterStorageOperations via DI.\n const getTenant = (): Tenant => container.resolve(TenantContext).getTenant();\n\n let storageOperations: AcoStorageOperations | undefined;\n const getStorageOperations = (): AcoStorageOperations => {\n if (!storageOperations) {\n const cms = container.resolve(HeadlessCms);\n const identityContext = container.resolve(IdentityContext);\n storageOperations = {\n filter: createFilterOperations({ cms, identityContext, container }),\n flp: container.resolve(FlpStorageOperations)\n };\n }\n return storageOperations;\n };\n\n let flpCrudMethods: ReturnType<typeof createFlpCrudMethods> | undefined;\n const getFlpCrudMethods = () => {\n if (!flpCrudMethods) {\n flpCrudMethods = createFlpCrudMethods({\n getTenant,\n storageOperations: getStorageOperations()\n });\n }\n return flpCrudMethods;\n };\n container.registerFactory(AcoFlpCrud, () => getFlpCrudMethods());\n container.registerFactory(FilterStorageOperations, () => getStorageOperations().filter);\n\n let filterCrudMethods: ReturnType<typeof createFilterCrudMethods> | undefined;\n container.registerFactory(AcoFilterCrud, () => {\n if (!filterCrudMethods) {\n filterCrudMethods = createFilterCrudMethods({\n container,\n getTenant,\n storageOperations: getStorageOperations(),\n folderLevelPermissions: container.resolve(FolderLevelPermissions)\n });\n }\n return filterCrudMethods;\n });\n\n container.register(AcoInitializer);\n container.register(AcoSchemaFactory);\n }\n});\n"],"names":["AcoSchemaFactoryImpl","builder","addAcoBaseSchema","addFilterSchema","AcoSchemaFactory","GraphQLSchemaFactory","AcoFeature","createFeature","container","FolderModel","FilterPrivateModel","CreateFlpTask","UpdateFlpTask","DeleteFlpTask","SyncFlpTask","FolderLevelPermissionsFeature","CreateFolderFeature","UpdateFolderFeature","DeleteFolderFeature","GetFolderFeature","ListFoldersFeature","ListFolderLevelPermissionsTargetsFeature","GetFolderHierarchyFeature","GetAncestorsFeature","EnsureFolderIsEmptyFeature","CreateFlpFeature","UpdateFlpFeature","DeleteFlpFeature","ListFlpsFeature","GetFlpFeature","CreateFlpOnFolderCreatedFeature","UpdateFlpOnFolderUpdatedFeature","DeleteFlpOnFolderDeletedFeature","EnsureFolderIsEmptyOnDeleteFeature","EnsureHcmsFolderIsEmptyOnDeleteFeature","getTenant","TenantContext","storageOperations","getStorageOperations","cms","HeadlessCms","identityContext","IdentityContext","createFilterOperations","FlpStorageOperations","flpCrudMethods","getFlpCrudMethods","createFlpCrudMethods","AcoFlpCrud","FilterStorageOperations","filterCrudMethods","AcoFilterCrud","createFilterCrudMethods","FolderLevelPermissions","AcoInitializer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAG1EC,iBAAiBD;QACjBE,gBAAgBF;QAChB,OAAOA;IACX;AACJ;AAEA,MAAMG,mBAAmBC,qBAAqB,oBAAoB,CAAC;IAC/D,gBAAgBL;IAChB,cAAc,EAAE;AACpB;AAEO,MAAMM,aAAaC,cAAc;IACpC,MAAM;IACN,UAASC,SAAoB;QACzBA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QAGnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QAInBC,8BAA8B,QAAQ,CAACP;QACvCQ,oBAAoB,QAAQ,CAACR;QAC7BS,oBAAoB,QAAQ,CAACT;QAC7BU,oBAAoB,QAAQ,CAACV;QAC7BW,iBAAiB,QAAQ,CAACX;QAC1BY,mBAAmB,QAAQ,CAACZ;QAC5Ba,yCAAyC,QAAQ,CAACb;QAClDc,0BAA0B,QAAQ,CAACd;QACnCe,oBAAoB,QAAQ,CAACf;QAC7BgB,2BAA2B,QAAQ,CAAChB;QACpCiB,iBAAiB,QAAQ,CAACjB;QAC1BkB,iBAAiB,QAAQ,CAAClB;QAC1BmB,iBAAiB,QAAQ,CAACnB;QAC1BoB,gBAAgB,QAAQ,CAACpB;QACzBqB,cAAc,QAAQ,CAACrB;QACvBsB,gCAAgC,QAAQ,CAACtB;QACzCuB,gCAAgC,QAAQ,CAACvB;QACzCwB,gCAAgC,QAAQ,CAACxB;QACzCyB,mCAAmC,QAAQ,CAACzB;QAC5C0B,uCAAuC,QAAQ,CAAC1B;QAMhD,MAAM2B,YAAY,IAAc3B,UAAU,OAAO,CAAC4B,eAAe,SAAS;QAE1E,IAAIC;QACJ,MAAMC,uBAAuB;YACzB,IAAI,CAACD,mBAAmB;gBACpB,MAAME,MAAM/B,UAAU,OAAO,CAACgC;gBAC9B,MAAMC,kBAAkBjC,UAAU,OAAO,CAACkC;gBAC1CL,oBAAoB;oBAChB,QAAQM,uBAAuB;wBAAEJ;wBAAKE;wBAAiBjC;oBAAU;oBACjE,KAAKA,UAAU,OAAO,CAACoC;gBAC3B;YACJ;YACA,OAAOP;QACX;QAEA,IAAIQ;QACJ,MAAMC,oBAAoB;YACtB,IAAI,CAACD,gBACDA,iBAAiBE,qBAAqB;gBAClCZ;gBACA,mBAAmBG;YACvB;YAEJ,OAAOO;QACX;QACArC,UAAU,eAAe,CAACwC,YAAY,IAAMF;QAC5CtC,UAAU,eAAe,CAACyC,yBAAyB,IAAMX,uBAAuB,MAAM;QAEtF,IAAIY;QACJ1C,UAAU,eAAe,CAAC2C,eAAe;YACrC,IAAI,CAACD,mBACDA,oBAAoBE,wBAAwB;gBACxC5C;gBACA2B;gBACA,mBAAmBG;gBACnB,wBAAwB9B,UAAU,OAAO,CAAC6C;YAC9C;YAEJ,OAAOH;QACX;QAEA1C,UAAU,QAAQ,CAAC8C;QACnB9C,UAAU,QAAQ,CAACJ;IACvB;AACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/createAcoGraphQL.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
2
|
+
/**
|
|
3
|
+
* The static ACO base schema (root Query.aco / Mutation.aco wrappers + shared types). The dynamic
|
|
4
|
+
* folder schema (field plugins + folders schema) is built per-request by AcoInitializer, which needs
|
|
5
|
+
* the resolved per-tenant folder model. The filter schema is contributed by addFilterSchema.
|
|
6
|
+
*/
|
|
7
|
+
export declare const addAcoBaseSchema: (builder: IGraphQLSchemaBuilder) => void;
|
package/createAcoGraphQL.js
CHANGED
|
@@ -1,110 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { isHeadlessCmsReady } from "@webiny/api-headless-cms";
|
|
6
|
-
import { createGraphQLSchemaPluginFromFieldPlugins } from "@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js";
|
|
7
|
-
import { FOLDER_MODEL_ID } from "./domain/folder/folder.model.js";
|
|
8
|
-
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
9
|
-
const emptyResolver = ()=>({});
|
|
10
|
-
const baseSchema = new GraphQLSchemaPlugin({
|
|
11
|
-
typeDefs: `
|
|
12
|
-
type AcoQuery {
|
|
13
|
-
_empty: String
|
|
14
|
-
}
|
|
1
|
+
const BASE_TYPE_DEFS = `
|
|
2
|
+
type AcoQuery {
|
|
3
|
+
_empty: String
|
|
4
|
+
}
|
|
15
5
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
type AcoMutation {
|
|
7
|
+
_empty: String
|
|
8
|
+
}
|
|
19
9
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
type AcoMeta {
|
|
11
|
+
hasMoreItems: Boolean
|
|
12
|
+
totalCount: Int
|
|
13
|
+
cursor: String
|
|
14
|
+
}
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
type AcoUser {
|
|
17
|
+
id: ID
|
|
18
|
+
displayName: String
|
|
19
|
+
type: String
|
|
20
|
+
}
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
type AcoError {
|
|
23
|
+
code: String
|
|
24
|
+
message: String
|
|
25
|
+
data: JSON
|
|
26
|
+
stack: String
|
|
27
|
+
}
|
|
38
28
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
type AcoBooleanResponse {
|
|
30
|
+
data: Boolean
|
|
31
|
+
error: AcoError
|
|
32
|
+
}
|
|
43
33
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
enum AcoSortDirection {
|
|
35
|
+
ASC
|
|
36
|
+
DESC
|
|
37
|
+
}
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
input AcoSort {
|
|
40
|
+
id: AcoSortDirection
|
|
41
|
+
createdOn: AcoSortDirection
|
|
42
|
+
modifiedOn: AcoSortDirection
|
|
43
|
+
savedOn: AcoSortDirection
|
|
44
|
+
title: AcoSortDirection
|
|
45
|
+
}
|
|
56
46
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
extend type Query {
|
|
48
|
+
aco: AcoQuery
|
|
49
|
+
}
|
|
60
50
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
`,
|
|
65
|
-
resolvers: {
|
|
66
|
-
Query: {
|
|
67
|
-
aco: emptyResolver
|
|
68
|
-
},
|
|
69
|
-
Mutation: {
|
|
70
|
-
aco: emptyResolver
|
|
71
|
-
}
|
|
51
|
+
extend type Mutation {
|
|
52
|
+
aco: AcoMutation
|
|
72
53
|
}
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
createPlugin: ({ schema, type, fieldType })=>{
|
|
86
|
-
const plugin = new GraphQLSchemaPlugin(schema);
|
|
87
|
-
plugin.name = `aco.graphql.folder.schema.${type}.field.${fieldType}`;
|
|
88
|
-
return plugin;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
const graphQlPlugin = createFoldersSchema({
|
|
92
|
-
model,
|
|
93
|
-
models,
|
|
94
|
-
fieldRegistry
|
|
95
|
-
});
|
|
96
|
-
context.plugins.register([
|
|
97
|
-
...plugins,
|
|
98
|
-
graphQlPlugin
|
|
99
|
-
]);
|
|
100
|
-
});
|
|
54
|
+
`;
|
|
55
|
+
const addAcoBaseSchema = (builder)=>{
|
|
56
|
+
builder.addTypeDefs(BASE_TYPE_DEFS);
|
|
57
|
+
builder.addResolver({
|
|
58
|
+
path: "Query.aco",
|
|
59
|
+
dependencies: [],
|
|
60
|
+
resolver: ()=>()=>({})
|
|
61
|
+
});
|
|
62
|
+
builder.addResolver({
|
|
63
|
+
path: "Mutation.aco",
|
|
64
|
+
dependencies: [],
|
|
65
|
+
resolver: ()=>()=>({})
|
|
101
66
|
});
|
|
102
|
-
return [
|
|
103
|
-
baseSchema,
|
|
104
|
-
folderSchema,
|
|
105
|
-
filterSchema
|
|
106
|
-
];
|
|
107
67
|
};
|
|
108
|
-
export {
|
|
68
|
+
export { addAcoBaseSchema };
|
|
109
69
|
|
|
110
70
|
//# sourceMappingURL=createAcoGraphQL.js.map
|
package/createAcoGraphQL.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAcoGraphQL.js","sources":["../src/createAcoGraphQL.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"createAcoGraphQL.js","sources":["../src/createAcoGraphQL.ts"],"sourcesContent":["import type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\n\nconst BASE_TYPE_DEFS = /* GraphQL */ `\n type AcoQuery {\n _empty: String\n }\n\n type AcoMutation {\n _empty: String\n }\n\n type AcoMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n\n type AcoUser {\n id: ID\n displayName: String\n type: String\n }\n\n type AcoError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AcoBooleanResponse {\n data: Boolean\n error: AcoError\n }\n\n enum AcoSortDirection {\n ASC\n DESC\n }\n\n input AcoSort {\n id: AcoSortDirection\n createdOn: AcoSortDirection\n modifiedOn: AcoSortDirection\n savedOn: AcoSortDirection\n title: AcoSortDirection\n }\n\n extend type Query {\n aco: AcoQuery\n }\n\n extend type Mutation {\n aco: AcoMutation\n }\n`;\n\n/**\n * The static ACO base schema (root Query.aco / Mutation.aco wrappers + shared types). The dynamic\n * folder schema (field plugins + folders schema) is built per-request by AcoInitializer, which needs\n * the resolved per-tenant folder model. The filter schema is contributed by addFilterSchema.\n */\nexport const addAcoBaseSchema = (builder: IGraphQLSchemaBuilder): void => {\n builder.addTypeDefs(BASE_TYPE_DEFS);\n builder.addResolver({ path: \"Query.aco\", dependencies: [], resolver: () => () => ({}) });\n builder.addResolver({ path: \"Mutation.aco\", dependencies: [], resolver: () => () => ({}) });\n};\n"],"names":["BASE_TYPE_DEFS","addAcoBaseSchema","builder"],"mappings":"AAEA,MAAMA,iBAA+B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDtC,CAAC;AAOM,MAAMC,mBAAmB,CAACC;IAC7BA,QAAQ,WAAW,CAACF;IACpBE,QAAQ,WAAW,CAAC;QAAE,MAAM;QAAa,cAAc,EAAE;QAAE,UAAU,IAAM,IAAO,EAAC;IAAG;IACtFA,QAAQ,WAAW,CAAC;QAAE,MAAM;QAAgB,cAAc,EAAE;QAAE,UAAU,IAAM,IAAO,EAAC;IAAG;AAC7F"}
|
|
@@ -7,5 +7,5 @@ export { FolderAfterDeleteEventHandler, FolderBeforeDeleteEventHandler, DeleteFo
|
|
|
7
7
|
export { FolderAfterUpdateEventHandler, FolderBeforeUpdateEventHandler, UpdateFolderRepository, UpdateFolderUseCase } from "../../../features/folder/UpdateFolder/abstractions.js";
|
|
8
8
|
export { EnsureFolderIsEmpty } from "../../../features/folder/EnsureFolderIsEmpty/abstractions.js";
|
|
9
9
|
export { ListFoldersUseCase, ListFoldersRepository } from "../../../features/folder/ListFolders/abstractions.js";
|
|
10
|
-
export { FilterStorageOperations } from "../../../features/folder/shared/abstractions.js";
|
|
10
|
+
export { FilterStorageOperations, FlpStorageOperations } from "../../../features/folder/shared/abstractions.js";
|
|
11
11
|
export type { Folder } from "../../../folder/folder.types.js";
|
|
@@ -7,4 +7,4 @@ export { DeleteFolderRepository, DeleteFolderUseCase, FolderAfterDeleteEventHand
|
|
|
7
7
|
export { FolderAfterUpdateEventHandler, FolderBeforeUpdateEventHandler, UpdateFolderRepository, UpdateFolderUseCase } from "../../../features/folder/UpdateFolder/abstractions.js";
|
|
8
8
|
export { EnsureFolderIsEmpty } from "../../../features/folder/EnsureFolderIsEmpty/abstractions.js";
|
|
9
9
|
export { ListFoldersRepository, ListFoldersUseCase } from "../../../features/folder/ListFolders/abstractions.js";
|
|
10
|
-
export { FilterStorageOperations } from "../../../features/folder/shared/abstractions.js";
|
|
10
|
+
export { FilterStorageOperations, FlpStorageOperations } from "../../../features/folder/shared/abstractions.js";
|
|
@@ -10,6 +10,7 @@ class ListDeletedEntriesWithFlpDecoratorImpl {
|
|
|
10
10
|
async execute(model, params) {
|
|
11
11
|
const loader = async (params)=>{
|
|
12
12
|
const result = await this.decoratee.execute(model, params);
|
|
13
|
+
if (result.isFail()) throw result.error;
|
|
13
14
|
return result.value;
|
|
14
15
|
};
|
|
15
16
|
const { entries, meta } = await this.listEntriesHandler.execute({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListDeletedEntriesWithFlpDecoratorImpl implements ListDeletedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListDeletedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListDeletedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListDeletedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListDeletedEntriesUseCase,\n decorator: ListDeletedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListDeletedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListDeletedEntriesWithFlpDecorator","createDecorator","ListDeletedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA8C,CACxD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACQ;QACnC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,
|
|
1
|
+
{"version":3,"file":"features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListDeletedEntriesWithFlpDecoratorImpl implements ListDeletedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListDeletedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListDeletedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListDeletedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListDeletedEntriesUseCase,\n decorator: ListDeletedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListDeletedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListDeletedEntriesWithFlpDecorator","createDecorator","ListDeletedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA8C,CACxD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACQ;QACnC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,qCAAqCC,gBAAgB;IAC9D,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
|
|
@@ -10,6 +10,7 @@ class ListEntriesWithFlpDecoratorImpl {
|
|
|
10
10
|
async execute(model, params) {
|
|
11
11
|
const loader = async (params)=>{
|
|
12
12
|
const result = await this.decoratee.execute(model, params);
|
|
13
|
+
if (result.isFail()) throw result.error;
|
|
13
14
|
return result.value;
|
|
14
15
|
};
|
|
15
16
|
const { entries, meta } = await this.listEntriesHandler.execute({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/cms/decorators/ListEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator, Result } from \"@webiny/feature/api\";\nimport { ListEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsEntryListParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListEntriesWithFlpDecoratorImpl implements ListEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListEntriesWithFlpDecorator = createDecorator({\n abstraction: ListEntriesUseCase,\n decorator: ListEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListEntriesWithFlpDecorator","createDecorator","ListEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAUA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAuC,CACjD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACC;QAC5B,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,
|
|
1
|
+
{"version":3,"file":"features/cms/decorators/ListEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator, Result } from \"@webiny/feature/api\";\nimport { ListEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsEntryListParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListEntriesWithFlpDecoratorImpl implements ListEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListEntriesWithFlpDecorator = createDecorator({\n abstraction: ListEntriesUseCase,\n decorator: ListEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListEntriesWithFlpDecorator","createDecorator","ListEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAUA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAuC,CACjD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACC;QAC5B,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,8BAA8BC,gBAAgB;IACvD,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
|
|
@@ -10,6 +10,7 @@ class ListLatestEntriesWithFlpDecoratorImpl {
|
|
|
10
10
|
async execute(model, params) {
|
|
11
11
|
const loader = async (params)=>{
|
|
12
12
|
const result = await this.decoratee.execute(model, params);
|
|
13
|
+
if (result.isFail()) throw result.error;
|
|
13
14
|
return result.value;
|
|
14
15
|
};
|
|
15
16
|
const { entries, meta } = await this.listEntriesHandler.execute({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/cms/decorators/ListLatestEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListLatestEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListLatestEntriesWithFlpDecoratorImpl implements ListLatestEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListLatestEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListLatestEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListLatestEntriesWithFlpDecorator = createDecorator({\n abstraction: ListLatestEntriesUseCase,\n decorator: ListLatestEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListLatestEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListLatestEntriesWithFlpDecorator","createDecorator","ListLatestEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA6C,CACvD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACO;QAClC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,
|
|
1
|
+
{"version":3,"file":"features/cms/decorators/ListLatestEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListLatestEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListLatestEntriesWithFlpDecoratorImpl implements ListLatestEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListLatestEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListLatestEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListLatestEntriesWithFlpDecorator = createDecorator({\n abstraction: ListLatestEntriesUseCase,\n decorator: ListLatestEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListLatestEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListLatestEntriesWithFlpDecorator","createDecorator","ListLatestEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA6C,CACvD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACO;QAClC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,oCAAoCC,gBAAgB;IAC7D,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
|
|
@@ -10,6 +10,7 @@ class ListPublishedEntriesWithFlpDecoratorImpl {
|
|
|
10
10
|
async execute(model, params) {
|
|
11
11
|
const loader = async (params)=>{
|
|
12
12
|
const result = await this.decoratee.execute(model, params);
|
|
13
|
+
if (result.isFail()) throw result.error;
|
|
13
14
|
return result.value;
|
|
14
15
|
};
|
|
15
16
|
const { entries, meta } = await this.listEntriesHandler.execute({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListPublishedEntriesWithFlpDecoratorImpl implements ListPublishedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListPublishedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListPublishedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListPublishedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListPublishedEntriesUseCase,\n decorator: ListPublishedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListPublishedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListPublishedEntriesWithFlpDecorator","createDecorator","ListPublishedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAgD,CAC1D;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACU;QACrC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,
|
|
1
|
+
{"version":3,"file":"features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListPublishedEntriesWithFlpDecoratorImpl implements ListPublishedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListPublishedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListPublishedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListPublishedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListPublishedEntriesUseCase,\n decorator: ListPublishedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListPublishedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListPublishedEntriesWithFlpDecorator","createDecorator","ListPublishedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAgD,CAC1D;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACU;QACrC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,uCAAuCC,gBAAgB;IAChE,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
|