@webiny/api-aco 0.0.0-unstable.99666aeb00 → 0.0.0-unstable.a9593f74dd
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/apps/AcoApp.d.ts +5 -0
- package/apps/AcoApp.js +56 -21
- package/apps/AcoApp.js.map +1 -1
- package/apps/AcoApps.js +7 -8
- package/apps/AcoApps.js.map +1 -1
- package/apps/app.gql.js +6 -4
- package/apps/app.gql.js.map +1 -1
- package/apps/index.js +3 -1
- package/apps/index.js.map +1 -1
- package/createAcoContext.d.ts +5 -1
- package/createAcoContext.js +119 -25
- package/createAcoContext.js.map +1 -1
- package/createAcoGraphQL.js +6 -2
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoHooks.js +9 -3
- package/createAcoHooks.js.map +1 -1
- package/createAcoModels.js +6 -19
- package/createAcoModels.js.map +1 -1
- package/createAcoStorageOperations.d.ts +0 -1
- package/createAcoStorageOperations.js +10 -7
- package/createAcoStorageOperations.js.map +1 -1
- package/fields/index.js +3 -1
- package/fields/index.js.map +1 -1
- package/fields/location.js +3 -1
- package/fields/location.js.map +1 -1
- package/filter/filter.crud.d.ts +3 -0
- package/filter/filter.crud.js +94 -0
- package/filter/filter.crud.js.map +1 -0
- package/filter/filter.gql.d.ts +3 -0
- package/filter/filter.gql.js +153 -0
- package/filter/filter.gql.js.map +1 -0
- package/filter/filter.model.d.ts +2 -0
- package/filter/filter.model.js +125 -0
- package/filter/filter.model.js.map +1 -0
- package/filter/filter.so.d.ts +3 -0
- package/filter/filter.so.js +98 -0
- package/filter/filter.so.js.map +1 -0
- package/filter/filter.types.d.ts +95 -0
- package/filter/filter.types.js +14 -0
- package/filter/filter.types.js.map +1 -0
- package/folder/folder.crud.d.ts +8 -1
- package/folder/folder.crud.js +194 -15
- package/folder/folder.crud.js.map +1 -1
- package/folder/folder.gql.js +85 -8
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.model.d.ts +1 -3
- package/folder/folder.model.js +54 -7
- package/folder/folder.model.js.map +1 -1
- package/folder/folder.so.js +38 -18
- package/folder/folder.so.js.map +1 -1
- package/folder/folder.types.d.ts +28 -2
- package/folder/folder.types.js +3 -1
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDeleteAco.hook.d.ts +2 -0
- package/folder/onFolderBeforeDeleteAco.hook.js +67 -0
- package/folder/onFolderBeforeDeleteAco.hook.js.map +1 -0
- package/folder/onFolderBeforeDeleteFm.hook.d.ts +2 -0
- package/folder/onFolderBeforeDeleteFm.hook.js +49 -0
- package/folder/onFolderBeforeDeleteFm.hook.js.map +1 -0
- package/folder/onFolderBeforeDeleteHcms.hook.d.ts +2 -0
- package/folder/onFolderBeforeDeleteHcms.hook.js +56 -0
- package/folder/onFolderBeforeDeleteHcms.hook.js.map +1 -0
- package/index.d.ts +5 -1
- package/index.js +14 -4
- package/index.js.map +1 -1
- package/package.json +31 -27
- package/plugins/AcoAppModifierPlugin.js +4 -5
- package/plugins/AcoAppModifierPlugin.js.map +1 -1
- package/plugins/AcoAppRegisterPlugin.js +4 -5
- package/plugins/AcoAppRegisterPlugin.js.map +1 -1
- package/plugins/index.js +3 -1
- package/plugins/index.js.map +1 -1
- package/record/graphql/createAppResolvers.js +26 -19
- package/record/graphql/createAppResolvers.js.map +1 -1
- package/record/graphql/createAppSchema.js +10 -5
- package/record/graphql/createAppSchema.js.map +1 -1
- package/record/record.crud.js +3 -1
- package/record/record.crud.js.map +1 -1
- package/record/record.gql.js +3 -1
- package/record/record.gql.js.map +1 -1
- package/record/record.model.d.ts +1 -3
- package/record/record.model.js +7 -7
- package/record/record.model.js.map +1 -1
- package/record/record.so.js +35 -23
- package/record/record.so.js.map +1 -1
- package/record/record.types.d.ts +4 -3
- package/record/record.types.js +3 -1
- package/record/record.types.js.map +1 -1
- package/types.d.ts +23 -6
- package/types.js +25 -4
- package/types.js.map +1 -1
- package/utils/FolderLevelPermissions.d.ts +71 -0
- package/utils/FolderLevelPermissions.js +353 -0
- package/utils/FolderLevelPermissions.js.map +1 -0
- package/utils/acoRecordId.js +3 -1
- package/utils/acoRecordId.js.map +1 -1
- package/utils/createListSort.js +3 -1
- package/utils/createListSort.js.map +1 -1
- package/utils/createModelField.js +3 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/createOperationsWrapper.js +3 -1
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.d.ts +11 -0
- package/utils/decorators/CmsEntriesCrudDecorators.js +232 -0
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -0
- package/utils/decorators/constants.d.ts +1 -0
- package/utils/decorators/constants.js +10 -0
- package/utils/decorators/constants.js.map +1 -0
- package/utils/decorators/where.d.ts +14 -0
- package/utils/decorators/where.js +52 -0
- package/utils/decorators/where.js.map +1 -0
- package/utils/ensureAuthentication.d.ts +2 -0
- package/utils/{checkPermissions.js → ensureAuthentication.js} +5 -3
- package/utils/ensureAuthentication.js.map +1 -0
- package/utils/getFolderAndItsAncestors.d.ts +2 -2
- package/utils/getFolderAndItsAncestors.js +16 -11
- package/utils/getFolderAndItsAncestors.js.map +1 -1
- package/utils/isInstallationPending.js +3 -1
- package/utils/isInstallationPending.js.map +1 -1
- package/utils/modelFactory.d.ts +1 -3
- package/utils/modelFactory.js +7 -10
- package/utils/modelFactory.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +3 -0
- package/utils/pickEntryFieldValues.js +31 -0
- package/utils/pickEntryFieldValues.js.map +1 -0
- package/utils/resolve.js +3 -1
- package/utils/resolve.js.map +1 -1
- package/folder/onFolderBeforeDelete.hook.d.ts +0 -2
- package/folder/onFolderBeforeDelete.hook.js +0 -66
- package/folder/onFolderBeforeDelete.hook.js.map +0 -1
- package/utils/checkPermissions.d.ts +0 -2
- package/utils/checkPermissions.js.map +0 -1
- package/utils/fieldResolver.d.ts +0 -16
- package/utils/fieldResolver.js +0 -44
- package/utils/fieldResolver.js.map +0 -1
- package/utils/getFieldValues.d.ts +0 -5
- package/utils/getFieldValues.js +0 -16
- package/utils/getFieldValues.js.map +0 -1
package/apps/AcoApp.d.ts
CHANGED
|
@@ -5,12 +5,17 @@ export declare class AcoApp implements IAcoApp {
|
|
|
5
5
|
readonly context: AcoContext;
|
|
6
6
|
readonly model: CmsModel;
|
|
7
7
|
private readonly fields;
|
|
8
|
+
private readonly onEntry?;
|
|
9
|
+
private readonly onEntryList?;
|
|
10
|
+
private readonly onAnyRequest?;
|
|
8
11
|
get search(): AcoSearchRecordCrudBase;
|
|
9
12
|
get folder(): import("../types").AcoFolderCrud;
|
|
13
|
+
private getModel;
|
|
10
14
|
private constructor();
|
|
11
15
|
static create(context: AcoContext, params: IAcoAppParams): AcoApp;
|
|
12
16
|
getFields(): CmsModelField[];
|
|
13
17
|
addField(field: CmsModelField): void;
|
|
14
18
|
removeField(id: string): void;
|
|
15
19
|
modifyField(id: string, cb: IAcoAppModifyFieldCallableCallback): void;
|
|
20
|
+
private execOnAnyRequest;
|
|
16
21
|
}
|
package/apps/AcoApp.js
CHANGED
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.AcoApp = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
-
var _structuredClone = _interopRequireDefault(require("@ungap/structured-clone"));
|
|
11
9
|
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
12
10
|
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
13
11
|
var _record = require("../record/record.model");
|
|
@@ -18,43 +16,72 @@ class AcoApp {
|
|
|
18
16
|
get search() {
|
|
19
17
|
return {
|
|
20
18
|
create: async data => {
|
|
21
|
-
|
|
19
|
+
await this.execOnAnyRequest("create");
|
|
20
|
+
const result = await this.context.aco.search.create(this.getModel(), data);
|
|
21
|
+
if (!this.onEntry) {
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
return this.onEntry(result);
|
|
22
25
|
},
|
|
23
26
|
update: async (id, data) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
await this.execOnAnyRequest("update");
|
|
28
|
+
const result = await this.context.aco.search.update(this.getModel(), id, data);
|
|
29
|
+
if (!this.onEntry) {
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
return this.onEntry(result);
|
|
28
33
|
},
|
|
29
34
|
move: async (id, folderId) => {
|
|
30
|
-
|
|
35
|
+
await this.execOnAnyRequest("move");
|
|
36
|
+
return this.context.aco.search.move(this.getModel(), id, folderId);
|
|
31
37
|
},
|
|
32
38
|
get: async id => {
|
|
33
|
-
|
|
39
|
+
await this.execOnAnyRequest("fetch");
|
|
40
|
+
const result = await this.context.aco.search.get(this.getModel(), id);
|
|
41
|
+
if (!result || !this.onEntry) {
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
return this.onEntry(result);
|
|
34
45
|
},
|
|
35
46
|
list: async params => {
|
|
36
|
-
|
|
47
|
+
await this.execOnAnyRequest("fetch");
|
|
48
|
+
const result = await this.context.aco.search.list(this.getModel(), params);
|
|
49
|
+
const onEntryList = this.onEntryList;
|
|
50
|
+
if (!onEntryList) {
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
const [entries, meta] = result;
|
|
54
|
+
const items = await onEntryList(entries);
|
|
55
|
+
return [items, meta];
|
|
37
56
|
},
|
|
38
57
|
delete: async id => {
|
|
39
|
-
|
|
58
|
+
await this.execOnAnyRequest("delete");
|
|
59
|
+
return this.context.aco.search.delete(this.getModel(), id);
|
|
40
60
|
},
|
|
41
61
|
listTags: async params => {
|
|
42
|
-
|
|
62
|
+
await this.execOnAnyRequest("fetch");
|
|
63
|
+
return this.context.aco.search.listTags(this.getModel(), params);
|
|
43
64
|
}
|
|
44
65
|
};
|
|
45
66
|
}
|
|
46
67
|
get folder() {
|
|
47
68
|
return this.context.aco.folder;
|
|
48
69
|
}
|
|
70
|
+
getModel() {
|
|
71
|
+
const tenant = this.context.tenancy.getCurrentTenant().id;
|
|
72
|
+
const locale = this.context.i18n.getContentLocale().code;
|
|
73
|
+
return {
|
|
74
|
+
...this.model,
|
|
75
|
+
tenant,
|
|
76
|
+
locale
|
|
77
|
+
};
|
|
78
|
+
}
|
|
49
79
|
constructor(context, params) {
|
|
50
|
-
var _this$model$fields$in;
|
|
51
|
-
(0, _defineProperty2.default)(this, "name", void 0);
|
|
52
|
-
(0, _defineProperty2.default)(this, "context", void 0);
|
|
53
|
-
(0, _defineProperty2.default)(this, "model", void 0);
|
|
54
|
-
(0, _defineProperty2.default)(this, "fields", void 0);
|
|
55
80
|
this.context = context;
|
|
56
81
|
this.name = params.name;
|
|
57
|
-
this.
|
|
82
|
+
this.onEntry = params.onEntry;
|
|
83
|
+
this.onEntryList = params.onEntryList;
|
|
84
|
+
this.model = structuredClone(params.model);
|
|
58
85
|
/**
|
|
59
86
|
* We can safely define the api name of the model as we control everything here.
|
|
60
87
|
*/
|
|
@@ -68,7 +95,7 @@ class AcoApp {
|
|
|
68
95
|
throw new _error.default(`The "data" field does not exist in model "${this.model.modelId}".`, "MODEL_DATA_FIELD_ERROR", {
|
|
69
96
|
modelId: this.model.modelId
|
|
70
97
|
});
|
|
71
|
-
} else if (!
|
|
98
|
+
} else if (!this.model.fields[index].settings?.fields) {
|
|
72
99
|
this.model.fields[index].settings.fields = [];
|
|
73
100
|
}
|
|
74
101
|
this.fields = this.model.fields[index].settings.fields;
|
|
@@ -102,7 +129,15 @@ class AcoApp {
|
|
|
102
129
|
id
|
|
103
130
|
});
|
|
104
131
|
}
|
|
105
|
-
this.fields[index] = cb((
|
|
132
|
+
this.fields[index] = cb(structuredClone(this.fields[index]));
|
|
133
|
+
}
|
|
134
|
+
async execOnAnyRequest(action) {
|
|
135
|
+
if (!this.onAnyRequest) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
await this.onAnyRequest(this.context, action);
|
|
106
139
|
}
|
|
107
140
|
}
|
|
108
|
-
exports.AcoApp = AcoApp;
|
|
141
|
+
exports.AcoApp = AcoApp;
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=AcoApp.js.map
|
package/apps/AcoApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createApiName","name","lodashUpperFirst","lodashCamelCase","AcoApp","search","create","data","context","aco","model","update","id","move","folderId","get","list","params","delete","listTags","folder","constructor","structuredClone","modelId","toLowerCase","apiName","singularApiName","pluralApiName","index","fields","findIndex","f","fieldId","WebinyError","settings","push","getFields","addField","field","removeField","DEFAULT_FIELDS","includes","splice","modifyField","cb"],"sources":["AcoApp.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport structuredClone from \"@ungap/structured-clone\";\nimport {\n AcoContext,\n AcoSearchRecordCrudBase,\n CreateSearchRecordParams,\n IAcoApp,\n IAcoAppModifyFieldCallableCallback,\n IAcoAppParams,\n ListSearchRecordsParams,\n ListSearchRecordTagsParams,\n SearchRecord\n} from \"~/types\";\nimport { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport lodashUpperFirst from \"lodash/upperFirst\";\nimport lodashCamelCase from \"lodash/camelCase\";\nimport { DEFAULT_FIELDS } from \"~/record/record.model\";\n\nconst createApiName = (name: string) => {\n return lodashUpperFirst(lodashCamelCase(name));\n};\n\nexport class AcoApp implements IAcoApp {\n public readonly name: string;\n public readonly context: AcoContext;\n public readonly model: CmsModel;\n private readonly fields: CmsModelField[];\n\n public get search(): AcoSearchRecordCrudBase {\n return {\n create: async <TData>(data: CreateSearchRecordParams<TData>) => {\n return this.context.aco.search.create<TData>(this.model, data);\n },\n update: async <TData>(id: string, data: SearchRecord<TData>) => {\n /**\n * Required to have as any atm as TS is breaking on the return type.\n */\n return (await this.context.aco.search.update<TData>(this.model, id, data)) as any;\n },\n move: async (id: string, folderId?: string) => {\n return this.context.aco.search.move(this.model, id, folderId);\n },\n get: async <TData>(id: string) => {\n return this.context.aco.search.get<TData>(this.model, id);\n },\n list: async <TData>(params: ListSearchRecordsParams) => {\n return this.context.aco.search.list<TData>(this.model, params);\n },\n delete: async (id: string): Promise<Boolean> => {\n return this.context.aco.search.delete(this.model, id);\n },\n listTags: async (params: ListSearchRecordTagsParams) => {\n return this.context.aco.search.listTags(this.model, params);\n }\n };\n }\n\n public get folder() {\n return this.context.aco.folder;\n }\n\n private constructor(context: AcoContext, params: IAcoAppParams) {\n this.context = context;\n this.name = params.name;\n this.model = structuredClone(params.model);\n /**\n * We can safely define the api name of the model as we control everything here.\n */\n this.model.name = `${this.model.name} ${this.name}`;\n this.model.modelId = `${this.model.modelId}-${this.name.toLowerCase()}`;\n const apiName = `AcoSearchRecord${createApiName(params.apiName)}`;\n this.model.singularApiName = apiName;\n this.model.pluralApiName = apiName;\n\n const index = this.model.fields.findIndex(f => f.fieldId === \"data\");\n if (index === -1) {\n throw new WebinyError(\n `The \"data\" field does not exist in model \"${this.model.modelId}\".`,\n \"MODEL_DATA_FIELD_ERROR\",\n {\n modelId: this.model.modelId\n }\n );\n } else if (!this.model.fields[index].settings?.fields) {\n this.model.fields[index].settings!.fields = [];\n }\n this.fields = this.model.fields[index].settings!.fields as CmsModelField[];\n this.fields.push(...params.fields);\n }\n\n public static create(context: AcoContext, params: IAcoAppParams) {\n return new AcoApp(context, params);\n }\n\n public getFields(): CmsModelField[] {\n return this.fields;\n }\n\n public addField(field: CmsModelField): void {\n this.fields.push(field);\n }\n\n public removeField(id: string): void {\n if (DEFAULT_FIELDS.includes(id)) {\n throw new WebinyError(\n `Cannot remove the default field from the ACO App.`,\n \"REMOVE_DEFAULT_FIELD_ERROR\",\n {\n fieldId: id\n }\n );\n }\n const index = this.fields.findIndex(field => field.id === id);\n if (index === -1) {\n return;\n }\n this.fields.splice(index, 1);\n }\n\n public modifyField(id: string, cb: IAcoAppModifyFieldCallableCallback): void {\n const index = this.fields.findIndex(field => field.id === id);\n if (index === -1) {\n throw new WebinyError(\n `There is no field \"${id}\" in app \"${this.name}\".`,\n \"FIELD_NOT_FOUND_ERROR\",\n {\n id\n }\n );\n }\n this.fields[index] = cb(structuredClone(this.fields[index]));\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAaA;AACA;AACA;AAEA,MAAMA,aAAa,GAAIC,IAAY,IAAK;EACpC,OAAO,IAAAC,mBAAgB,EAAC,IAAAC,kBAAe,EAACF,IAAI,CAAC,CAAC;AAClD,CAAC;AAEM,MAAMG,MAAM,CAAoB;EAMnC,IAAWC,MAAM,GAA4B;IACzC,OAAO;MACHC,MAAM,EAAE,MAAcC,IAAqC,IAAK;QAC5D,OAAO,IAAI,CAACC,OAAO,CAACC,GAAG,CAACJ,MAAM,CAACC,MAAM,CAAQ,IAAI,CAACI,KAAK,EAAEH,IAAI,CAAC;MAClE,CAAC;MACDI,MAAM,EAAE,OAAcC,EAAU,EAAEL,IAAyB,KAAK;QAC5D;AAChB;AACA;QACgB,OAAQ,MAAM,IAAI,CAACC,OAAO,CAACC,GAAG,CAACJ,MAAM,CAACM,MAAM,CAAQ,IAAI,CAACD,KAAK,EAAEE,EAAE,EAAEL,IAAI,CAAC;MAC7E,CAAC;MACDM,IAAI,EAAE,OAAOD,EAAU,EAAEE,QAAiB,KAAK;QAC3C,OAAO,IAAI,CAACN,OAAO,CAACC,GAAG,CAACJ,MAAM,CAACQ,IAAI,CAAC,IAAI,CAACH,KAAK,EAAEE,EAAE,EAAEE,QAAQ,CAAC;MACjE,CAAC;MACDC,GAAG,EAAE,MAAcH,EAAU,IAAK;QAC9B,OAAO,IAAI,CAACJ,OAAO,CAACC,GAAG,CAACJ,MAAM,CAACU,GAAG,CAAQ,IAAI,CAACL,KAAK,EAAEE,EAAE,CAAC;MAC7D,CAAC;MACDI,IAAI,EAAE,MAAcC,MAA+B,IAAK;QACpD,OAAO,IAAI,CAACT,OAAO,CAACC,GAAG,CAACJ,MAAM,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CAAC1B,EAAE,KAAKA,EAAE,CAAC;IAC7D,IAAIgB,KAAK,KAAK,CAAC,CAAC,EAAE;MACd;IACJ;IACA,IAAI,CAACC,MAAM,CAACa,MAAM,CAACd,KAAK,EAAE,CAAC,CAAC;EAChC;EAEOe,WAAW,CAAC/B,EAAU,EAAEgC,EAAsC,EAAQ;IACzE,MAAMhB,KAAK,GAAG,IAAI,CAACC,MAAM,CAACC,SAAS,CAACQ,KAAK,IAAIA,KAAK,CAAC1B,EAAE,KAAKA,EAAE,CAAC;IAC7D,IAAIgB,KAAK,KAAK,CAAC,CAAC,EAAE;MACd,MAAM,IAAIK,cAAW,CAChB,sBAAqBrB,EAAG,aAAY,IAAI,CAACX,IAAK,IAAG,EAClD,uBAAuB,EACvB;QACIW;MACJ,CAAC,CACJ;IACL;IACA,IAAI,CAACiB,MAAM,CAACD,KAAK,CAAC,GAAGgB,EAAE,CAAC,IAAAtB,wBAAe,EAAC,IAAI,CAACO,MAAM,CAACD,KAAK,CAAC,CAAC,CAAC;EAChE;AACJ;AAAC"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_upperFirst","_camelCase","_record","createApiName","name","lodashUpperFirst","lodashCamelCase","AcoApp","search","create","data","execOnAnyRequest","result","context","aco","getModel","onEntry","update","id","move","folderId","get","list","params","onEntryList","entries","meta","items","delete","listTags","folder","tenant","tenancy","getCurrentTenant","locale","i18n","getContentLocale","code","model","constructor","structuredClone","modelId","toLowerCase","apiName","singularApiName","pluralApiName","index","fields","findIndex","f","fieldId","WebinyError","settings","push","getFields","addField","field","removeField","DEFAULT_FIELDS","includes","splice","modifyField","cb","action","onAnyRequest","exports"],"sources":["AcoApp.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n AcoContext,\n AcoRequestAction,\n AcoSearchRecordCrudBase,\n CreateSearchRecordParams,\n IAcoApp,\n IAcoAppModifyFieldCallableCallback,\n IAcoAppOnAnyRequest,\n IAcoAppOnEntry,\n IAcoAppOnEntryList,\n IAcoAppParams,\n ListSearchRecordsParams,\n ListSearchRecordTagsParams,\n SearchRecord\n} from \"~/types\";\nimport { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport lodashUpperFirst from \"lodash/upperFirst\";\nimport lodashCamelCase from \"lodash/camelCase\";\nimport { DEFAULT_FIELDS } from \"~/record/record.model\";\n\nconst createApiName = (name: string) => {\n return lodashUpperFirst(lodashCamelCase(name));\n};\n\nexport class AcoApp implements IAcoApp {\n public readonly name: string;\n public readonly context: AcoContext;\n public readonly model: CmsModel;\n private readonly fields: CmsModelField[];\n private readonly onEntry?: IAcoAppOnEntry;\n private readonly onEntryList?: IAcoAppOnEntryList;\n private readonly onAnyRequest?: IAcoAppOnAnyRequest;\n\n public get search(): AcoSearchRecordCrudBase {\n return {\n create: async <TData>(data: CreateSearchRecordParams<TData>) => {\n await this.execOnAnyRequest(\"create\");\n const result = await this.context.aco.search.create<TData>(this.getModel(), data);\n if (!this.onEntry) {\n return result;\n }\n return this.onEntry(result);\n },\n update: async <TData>(id: string, data: SearchRecord<TData>) => {\n await this.execOnAnyRequest(\"update\");\n const result = await this.context.aco.search.update<TData>(\n this.getModel(),\n id,\n data\n );\n if (!this.onEntry) {\n return result;\n }\n return this.onEntry(result);\n },\n move: async (id: string, folderId?: string) => {\n await this.execOnAnyRequest(\"move\");\n return this.context.aco.search.move(this.getModel(), id, folderId);\n },\n get: async <TData>(id: string) => {\n await this.execOnAnyRequest(\"fetch\");\n const result = await this.context.aco.search.get<TData>(this.getModel(), id);\n if (!result || !this.onEntry) {\n return result;\n }\n return this.onEntry(result);\n },\n list: async <TData>(params: ListSearchRecordsParams) => {\n await this.execOnAnyRequest(\"fetch\");\n const result = await this.context.aco.search.list<TData>(this.getModel(), params);\n const onEntryList = this.onEntryList;\n if (!onEntryList) {\n return result;\n }\n const [entries, meta] = result;\n const items = await onEntryList(entries);\n return [items, meta];\n },\n delete: async (id: string): Promise<boolean> => {\n await this.execOnAnyRequest(\"delete\");\n return this.context.aco.search.delete(this.getModel(), id);\n },\n listTags: async (params: ListSearchRecordTagsParams) => {\n await this.execOnAnyRequest(\"fetch\");\n return this.context.aco.search.listTags(this.getModel(), params);\n }\n };\n }\n\n public get folder() {\n return this.context.aco.folder;\n }\n\n private getModel() {\n const tenant = this.context.tenancy.getCurrentTenant().id;\n const locale = this.context.i18n.getContentLocale()!.code;\n\n return { ...this.model, tenant, locale };\n }\n\n private constructor(context: AcoContext, params: IAcoAppParams) {\n this.context = context;\n this.name = params.name;\n this.onEntry = params.onEntry;\n this.onEntryList = params.onEntryList;\n this.model = structuredClone(params.model);\n /**\n * We can safely define the api name of the model as we control everything here.\n */\n this.model.name = `${this.model.name} ${this.name}`;\n this.model.modelId = `${this.model.modelId}-${this.name.toLowerCase()}`;\n const apiName = `AcoSearchRecord${createApiName(params.apiName)}`;\n this.model.singularApiName = apiName;\n this.model.pluralApiName = apiName;\n\n const index = this.model.fields.findIndex(f => f.fieldId === \"data\");\n if (index === -1) {\n throw new WebinyError(\n `The \"data\" field does not exist in model \"${this.model.modelId}\".`,\n \"MODEL_DATA_FIELD_ERROR\",\n {\n modelId: this.model.modelId\n }\n );\n } else if (!this.model.fields[index].settings?.fields) {\n this.model.fields[index].settings!.fields = [];\n }\n this.fields = this.model.fields[index].settings!.fields as CmsModelField[];\n this.fields.push(...params.fields);\n }\n\n public static create(context: AcoContext, params: IAcoAppParams) {\n return new AcoApp(context, params);\n }\n\n public getFields(): CmsModelField[] {\n return this.fields;\n }\n\n public addField(field: CmsModelField): void {\n this.fields.push(field);\n }\n\n public removeField(id: string): void {\n if (DEFAULT_FIELDS.includes(id)) {\n throw new WebinyError(\n `Cannot remove the default field from the ACO App.`,\n \"REMOVE_DEFAULT_FIELD_ERROR\",\n {\n fieldId: id\n }\n );\n }\n const index = this.fields.findIndex(field => field.id === id);\n if (index === -1) {\n return;\n }\n this.fields.splice(index, 1);\n }\n\n public modifyField(id: string, cb: IAcoAppModifyFieldCallableCallback): void {\n const index = this.fields.findIndex(field => field.id === id);\n if (index === -1) {\n throw new WebinyError(\n `There is no field \"${id}\" in app \"${this.name}\".`,\n \"FIELD_NOT_FOUND_ERROR\",\n {\n id\n }\n );\n }\n this.fields[index] = cb(structuredClone(this.fields[index]));\n }\n\n private async execOnAnyRequest(action: AcoRequestAction): Promise<void> {\n if (!this.onAnyRequest) {\n return;\n }\n await this.onAnyRequest(this.context, action);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAiBA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,MAAMI,aAAa,GAAIC,IAAY,IAAK;EACpC,OAAO,IAAAC,mBAAgB,EAAC,IAAAC,kBAAe,EAACF,IAAI,CAAC,CAAC;AAClD,CAAC;AAEM,MAAMG,MAAM,CAAoB;EASnC,IAAWC,MAAMA,CAAA,EAA4B;IACzC,OAAO;MACHC,MAAM,EAAE,MAAcC,IAAqC,IAAK;QAC5D,MAAM,IAAI,CAACC,gBAAgB,CAAC,QAAQ,CAAC;QACrC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACC,OAAO,CAACC,GAAG,CAACN,MAAM,CAACC,MAAM,CAAQ,IAAI,CAACM,QAAQ,CAAC,CAAC,EAAEL,IAAI,CAAC;QACjF,IAAI,CAAC,IAAI,CAACM,OAAO,EAAE;UACf,OAAOJ,MAAM;QACjB;QACA,OAAO,IAAI,CAACI,OAAO,CAACJ,MAAM,CAAC;MAC/B,CAAC;MACDK,MAAM,EAAE,MAAAA,CAAcC,EAAU,EAAER,IAAyB,KAAK;QAC5D,MAAM,IAAI,CAACC,gBAAgB,CAAC,QAAQ,CAAC;QACrC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACC,OAAO,CAACC,GAAG,CAACN,MAAM,CAACS,MAAM,CAC/C,IAAI,CAACF,QAAQ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Y,EAAE;MACpB;IACJ;IACA,MAAM,IAAI,CAACA,YAAY,CAAC,IAAI,CAACnD,OAAO,EAAEkD,MAAM,CAAC;EACjD;AACJ;AAACE,OAAA,CAAA1D,MAAA,GAAAA,MAAA"}
|
package/apps/AcoApps.js
CHANGED
|
@@ -5,18 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.AcoApps = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
9
|
var _AcoApp = require("./AcoApp");
|
|
12
10
|
var _plugins = require("../plugins");
|
|
13
11
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
14
12
|
var _record = require("../record/record.gql");
|
|
15
13
|
class AcoApps {
|
|
14
|
+
apps = new Map();
|
|
16
15
|
constructor(context, options) {
|
|
17
|
-
(0, _defineProperty2.default)(this, "apps", new Map());
|
|
18
|
-
(0, _defineProperty2.default)(this, "context", void 0);
|
|
19
|
-
(0, _defineProperty2.default)(this, "options", void 0);
|
|
20
16
|
this.context = context;
|
|
21
17
|
this.options = options;
|
|
22
18
|
}
|
|
@@ -58,12 +54,13 @@ class AcoApps {
|
|
|
58
54
|
* Also, we need to register the app model as the plugin one, so it can be used in the CMS.
|
|
59
55
|
* We do not need to validate model or show it in the API.
|
|
60
56
|
*/
|
|
61
|
-
this.context.plugins.register(new _apiHeadlessCms.CmsModelPlugin(
|
|
57
|
+
this.context.plugins.register(new _apiHeadlessCms.CmsModelPlugin({
|
|
58
|
+
...app.model,
|
|
62
59
|
singularApiName: undefined,
|
|
63
60
|
pluralApiName: undefined,
|
|
64
61
|
isPrivate: true,
|
|
65
62
|
noValidate: true
|
|
66
|
-
}))
|
|
63
|
+
}));
|
|
67
64
|
this.apps.set(app.name, app);
|
|
68
65
|
const searchRecordSchema = await (0, _record.createSchema)({
|
|
69
66
|
context: this.context,
|
|
@@ -73,4 +70,6 @@ class AcoApps {
|
|
|
73
70
|
return app;
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
|
-
exports.AcoApps = AcoApps;
|
|
73
|
+
exports.AcoApps = AcoApps;
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=AcoApps.js.map
|
package/apps/AcoApps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AcoApps","constructor","context","options","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_AcoApp","_plugins","_apiHeadlessCms","_record","AcoApps","apps","Map","constructor","context","options","get","name","app","WebinyError","Array","from","keys","list","values","register","exists","has","AcoApp","create","modifiers","plugins","byType","AcoAppModifierPlugin","type","modifier","canUse","modify","CmsModelPlugin","model","singularApiName","undefined","pluralApiName","isPrivate","noValidate","set","searchRecordSchema","createSchema","exports"],"sources":["AcoApps.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoApp } from \"./AcoApp\";\nimport { AcoAppModifierPlugin } from \"~/plugins\";\nimport { AcoContext, IAcoApp, IAcoAppParams, IAcoApps, IAcoAppsOptions } from \"~/types\";\nimport { CmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { createSchema } from \"~/record/record.gql\";\n\nexport class AcoApps implements IAcoApps {\n private readonly apps: Map<string, IAcoApp> = new Map();\n private readonly context: AcoContext;\n private readonly options: IAcoAppsOptions;\n\n public constructor(context: AcoContext, options: IAcoAppsOptions) {\n this.context = context;\n this.options = options;\n }\n\n public get(name: string): IAcoApp {\n const app = this.apps.get(name);\n if (app) {\n return app;\n }\n throw new WebinyError(`App \"${name}\" is not registered.`, \"APP_NOT_REGISTERED\", {\n name,\n apps: Array.from(this.apps.keys())\n });\n }\n\n public list(): IAcoApp[] {\n return Array.from(this.apps.values());\n }\n\n public async register(options: IAcoAppParams): Promise<IAcoApp> {\n const exists = this.apps.has(options.name);\n if (exists) {\n throw new WebinyError(\n `An app with the name \"${options.name}\" is already registered.`,\n \"APP_EXISTS\",\n {\n name: options.name\n }\n );\n }\n /**\n * We need to create the app and run the modifiers on it.\n */\n const app = AcoApp.create(this.context, options);\n const modifiers = this.context.plugins.byType<AcoAppModifierPlugin>(\n AcoAppModifierPlugin.type\n );\n for (const modifier of modifiers) {\n if (modifier.canUse(app) === false) {\n continue;\n }\n await modifier.modify({\n context: this.context,\n app\n });\n }\n /**\n * Also, we need to register the app model as the plugin one, so it can be used in the CMS.\n * We do not need to validate model or show it in the API.\n */\n this.context.plugins.register(\n new CmsModelPlugin({\n ...app.model,\n singularApiName: undefined,\n pluralApiName: undefined,\n isPrivate: true,\n noValidate: true\n })\n );\n this.apps.set(app.name, app);\n\n const searchRecordSchema = await createSchema({\n context: this.context,\n app\n });\n this.context.plugins.register(searchRecordSchema);\n\n return app;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEO,MAAMK,OAAO,CAAqB;EACpBC,IAAI,GAAyB,IAAIC,GAAG,CAAC,CAAC;EAIhDC,WAAWA,CAACC,OAAmB,EAAEC,OAAwB,EAAE;IAC9D,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;EAEOC,GAAGA,CAACC,IAAY,EAAW;IAC9B,MAAMC,GAAG,GAAG,IAAI,CAACP,IAAI,CAACK,GAAG,CAACC,IAAI,CAAC;IAC/B,IAAIC,GAAG,EAAE;MACL,OAAOA,GAAG;IACd;IACA,MAAM,IAAIC,cAAW,CAAE,QAAOF,IAAK,sBAAqB,EAAE,oBAAoB,EAAE;MAC5EA,IAAI;MACJN,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kC,GAAG,CAAC3B,GAAG,CAACD,IAAI,EAAEC,GAAG,CAAC;IAE5B,MAAM4B,kBAAkB,GAAG,MAAM,IAAAC,oBAAY,EAAC;MAC1CjC,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBI;IACJ,CAAC,CAAC;IACF,IAAI,CAACJ,OAAO,CAACiB,OAAO,CAACN,QAAQ,CAACqB,kBAAkB,CAAC;IAEjD,OAAO5B,GAAG;EACd;AACJ;AAAC8B,OAAA,CAAAtC,OAAA,GAAAA,OAAA"}
|
package/apps/app.gql.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.appGql = void 0;
|
|
8
8
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
9
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
10
|
-
var
|
|
10
|
+
var _ensureAuthentication = require("../utils/ensureAuthentication");
|
|
11
11
|
var _resolve = require("../utils/resolve");
|
|
12
12
|
const cleanModel = model => {
|
|
13
13
|
return (0, _omit.default)(model, ["webinyVersion", "tags", "locale", "tenant", "layout", "group", "description", "isPrivate"]);
|
|
@@ -36,7 +36,7 @@ const appGql = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
36
36
|
AcoQuery: {
|
|
37
37
|
getApp: async (_, args, context) => {
|
|
38
38
|
return (0, _resolve.resolve)(async () => {
|
|
39
|
-
(0,
|
|
39
|
+
(0, _ensureAuthentication.ensureAuthentication)(context);
|
|
40
40
|
const app = context.aco.getApp(args.id);
|
|
41
41
|
return {
|
|
42
42
|
id: args.id,
|
|
@@ -47,7 +47,7 @@ const appGql = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
47
47
|
},
|
|
48
48
|
getAppModel: async (_, args, context) => {
|
|
49
49
|
return (0, _resolve.resolve)(async () => {
|
|
50
|
-
(0,
|
|
50
|
+
(0, _ensureAuthentication.ensureAuthentication)(context);
|
|
51
51
|
const app = context.aco.getApp(args.id);
|
|
52
52
|
return cleanModel(app.model);
|
|
53
53
|
});
|
|
@@ -55,4 +55,6 @@ const appGql = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
exports.appGql = appGql;
|
|
58
|
+
exports.appGql = appGql;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=app.gql.js.map
|
package/apps/app.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cleanModel","model","lodashOmit","appGql","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getApp","_","args","context","resolve","
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_omit","_interopRequireDefault","_ensureAuthentication","_resolve","cleanModel","model","lodashOmit","appGql","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getApp","_","args","context","resolve","ensureAuthentication","app","aco","id","name","getAppModel","exports"],"sources":["app.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { AcoContext } from \"~/types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport lodashOmit from \"lodash/omit\";\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication\";\nimport { resolve } from \"~/utils/resolve\";\n\nconst cleanModel = (model: CmsModel): Partial<CmsModel> => {\n return lodashOmit(model, [\n \"webinyVersion\",\n \"tags\",\n \"locale\",\n \"tenant\",\n \"layout\",\n \"group\",\n \"description\",\n \"isPrivate\"\n ]);\n};\n\nexport const appGql = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type AcoApp {\n id: ID!\n name: String!\n model: JSON!\n }\n type GetAppResponse {\n data: AcoApp\n error: AcoError\n }\n type GetAppModelResponse {\n data: JSON\n error: AcoError\n }\n extend type AcoQuery {\n getApp(id: ID!): GetAppResponse!\n getAppModel(id: ID!): GetAppModelResponse!\n }\n `,\n resolvers: {\n AcoQuery: {\n getApp: async (_, args, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const app = context.aco.getApp(args.id);\n return {\n id: args.id,\n name: app.name,\n model: cleanModel(app.model)\n };\n });\n },\n getAppModel: async (_, args, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const app = context.aco.getApp(args.id);\n return cleanModel(app.model);\n });\n }\n }\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,MAAMK,UAAU,GAAIC,KAAe,IAAwB;EACvD,OAAO,IAAAC,aAAU,EAACD,KAAK,EAAE,CACrB,eAAe,EACf,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,aAAa,EACb,WAAW,CACd,CAAC;AACN,CAAC;AAEM,MAAME,MAAM,GAAG,IAAIC,mCAAmB,CAAa;EACtDC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,QAAQ,EAAE;MACNC,MAAM,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAI,EAAEC,OAAO,KAAK;QAChC,OAAO,IAAAC,gBAAO,EAAC,YAAY;UACvB,IAAAC,0CAAoB,EAACF,OAAO,CAAC;UAC7B,MAAMG,GAAG,GAAGH,OAAO,CAACI,GAAG,CAACP,MAAM,CAACE,IAAI,CAACM,EAAE,CAAC;UACvC,OAAO;YACHA,EAAE,EAAEN,IAAI,CAACM,EAAE;YACXC,IAAI,EAAEH,GAAG,CAACG,IAAI;YACdhB,KAAK,EAAED,UAAU,CAACc,GAAG,CAACb,KAAK;UAC/B,CAAC;QACL,CAAC,CAAC;MACN,CAAC;MACDiB,WAAW,EAAE,MAAAA,CAAOT,CAAC,EAAEC,IAAI,EAAEC,OAAO,KAAK;QACrC,OAAO,IAAAC,gBAAO,EAAC,YAAY;UACvB,IAAAC,0CAAoB,EAACF,OAAO,CAAC;UAC7B,MAAMG,GAAG,GAAGH,OAAO,CAACI,GAAG,CAACP,MAAM,CAACE,IAAI,CAACM,EAAE,CAAC;UACvC,OAAOhB,UAAU,CAACc,GAAG,CAACb,KAAK,CAAC;QAChC,CAAC,CAAC;MACN;IACJ;EACJ;AACJ,CAAC,CAAC;AAACkB,OAAA,CAAAhB,MAAA,GAAAA,MAAA"}
|
package/apps/index.js
CHANGED
package/apps/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./AcoApp\";\nexport * from \"./AcoApps\";\n"],"mappings":";;;;;AAAA;
|
|
1
|
+
{"version":3,"names":["_AcoApp","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_AcoApps"],"sources":["index.ts"],"sourcesContent":["export * from \"./AcoApp\";\nexport * from \"./AcoApps\";\n"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|
package/createAcoContext.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { ContextPlugin } from "@webiny/api";
|
|
2
2
|
import { AcoContext } from "./types";
|
|
3
|
-
|
|
3
|
+
interface CreateAcoContextParams {
|
|
4
|
+
useFolderLevelPermissions?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const createAcoContext: (params?: CreateAcoContextParams) => ContextPlugin<AcoContext>;
|
|
7
|
+
export {};
|
package/createAcoContext.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createAcoContext = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
9
|
var _api = require("@webiny/api");
|
|
11
10
|
var _createAcoHooks = require("./createAcoHooks");
|
|
@@ -16,7 +15,13 @@ var _record = require("./record/record.crud");
|
|
|
16
15
|
var _apps = require("./apps");
|
|
17
16
|
var _record2 = require("./record/record.model");
|
|
18
17
|
var _plugins = require("./plugins");
|
|
19
|
-
|
|
18
|
+
var _FolderLevelPermissions = require("./utils/FolderLevelPermissions");
|
|
19
|
+
var _CmsEntriesCrudDecorators = require("./utils/decorators/CmsEntriesCrudDecorators");
|
|
20
|
+
var _folder2 = require("./folder/folder.model");
|
|
21
|
+
var _createOperationsWrapper = require("./utils/createOperationsWrapper");
|
|
22
|
+
var _pickEntryFieldValues = require("./utils/pickEntryFieldValues");
|
|
23
|
+
var _filter = require("./filter/filter.crud");
|
|
24
|
+
const setupAcoContext = async (context, setupAcoContextParams) => {
|
|
20
25
|
const {
|
|
21
26
|
tenancy,
|
|
22
27
|
security,
|
|
@@ -32,22 +37,82 @@ const setupAcoContext = async context => {
|
|
|
32
37
|
const getTenant = () => {
|
|
33
38
|
return tenancy.getCurrentTenant();
|
|
34
39
|
};
|
|
35
|
-
const
|
|
40
|
+
const storageOperations = (0, _createAcoStorageOperations.createAcoStorageOperations)({
|
|
41
|
+
/**
|
|
42
|
+
* TODO: We need to figure out a way to pass "cms" from outside (e.g. apps/api/graphql)
|
|
43
|
+
*/
|
|
44
|
+
cms: context.cms,
|
|
45
|
+
/**
|
|
46
|
+
* TODO: This is required for "entryFieldFromStorageTransform" which access plugins from context.
|
|
47
|
+
*/
|
|
48
|
+
getCmsContext: () => context,
|
|
49
|
+
security
|
|
50
|
+
});
|
|
51
|
+
const folderLevelPermissions = new _FolderLevelPermissions.FolderLevelPermissions({
|
|
52
|
+
getIdentity: () => security.getIdentity(),
|
|
53
|
+
getIdentityTeam: async () => {
|
|
54
|
+
return security.withoutAuthorization(async () => {
|
|
55
|
+
const identity = security.getIdentity();
|
|
56
|
+
if (!identity) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const adminUser = await context.adminUsers.getUser({
|
|
60
|
+
where: {
|
|
61
|
+
id: identity.id
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (!adminUser) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (!adminUser.team) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return context.security.getTeam({
|
|
71
|
+
where: {
|
|
72
|
+
id: adminUser.team
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
listPermissions: () => security.listPermissions(),
|
|
78
|
+
listAllFolders: type => {
|
|
79
|
+
// When retrieving a list of all folders, we want to do it in the
|
|
80
|
+
// fastest way and that is by directly using CMS's storage operations.
|
|
81
|
+
const {
|
|
82
|
+
withModel
|
|
83
|
+
} = (0, _createOperationsWrapper.createOperationsWrapper)({
|
|
84
|
+
modelName: _folder2.FOLDER_MODEL_ID,
|
|
85
|
+
cms: context.cms,
|
|
86
|
+
getCmsContext: () => context,
|
|
87
|
+
security
|
|
88
|
+
});
|
|
89
|
+
return withModel(async model => {
|
|
90
|
+
const results = await context.cms.storageOperations.entries.list(model, {
|
|
91
|
+
limit: 100_000,
|
|
92
|
+
where: {
|
|
93
|
+
type,
|
|
94
|
+
// Folders always work with latest entries. We never publish them.
|
|
95
|
+
latest: true
|
|
96
|
+
},
|
|
97
|
+
sort: ["title_ASC"]
|
|
98
|
+
});
|
|
99
|
+
return results.items.map(_pickEntryFieldValues.pickEntryFieldValues);
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
canUseTeams: () => context.wcp.canUseTeams(),
|
|
103
|
+
canUseFolderLevelPermissions: () => {
|
|
104
|
+
if (setupAcoContextParams.useFolderLevelPermissions === false) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return context.wcp.canUseFolderLevelPermissions();
|
|
108
|
+
},
|
|
109
|
+
isAuthorizationEnabled: () => context.security.isAuthorizationEnabled()
|
|
110
|
+
});
|
|
36
111
|
const params = {
|
|
37
112
|
getLocale,
|
|
38
|
-
getIdentity,
|
|
39
113
|
getTenant,
|
|
40
|
-
storageOperations
|
|
41
|
-
|
|
42
|
-
* TODO: We need to figure out a way to pass "cms" from outside (e.g. apps/api/graphql)
|
|
43
|
-
*/
|
|
44
|
-
cms: context.cms,
|
|
45
|
-
/**
|
|
46
|
-
* TODO: This is required for "entryFieldFromStorageTransform" which access plugins from context.
|
|
47
|
-
*/
|
|
48
|
-
getCmsContext: () => context,
|
|
49
|
-
security
|
|
50
|
-
})
|
|
114
|
+
storageOperations,
|
|
115
|
+
folderLevelPermissions
|
|
51
116
|
};
|
|
52
117
|
const defaultRecordModel = await context.security.withoutAuthorization(async () => {
|
|
53
118
|
return context.cms.getModel(_record2.SEARCH_RECORD_MODEL_ID);
|
|
@@ -62,24 +127,51 @@ const setupAcoContext = async context => {
|
|
|
62
127
|
const apps = new _apps.AcoApps(context, params);
|
|
63
128
|
const plugins = context.plugins.byType(_plugins.AcoAppRegisterPlugin.type);
|
|
64
129
|
for (const plugin of plugins) {
|
|
65
|
-
await apps.register(
|
|
66
|
-
model: defaultRecordModel
|
|
67
|
-
|
|
130
|
+
await apps.register({
|
|
131
|
+
model: defaultRecordModel,
|
|
132
|
+
...plugin.app
|
|
133
|
+
});
|
|
68
134
|
}
|
|
135
|
+
const listAdminUsers = () => {
|
|
136
|
+
return security.withoutAuthorization(async () => {
|
|
137
|
+
return context.adminUsers.listUsers();
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const listTeams = () => {
|
|
141
|
+
return security.withoutAuthorization(async () => {
|
|
142
|
+
return context.security.listTeams();
|
|
143
|
+
});
|
|
144
|
+
};
|
|
69
145
|
context.aco = {
|
|
70
|
-
folder: (0, _folder.createFolderCrudMethods)(
|
|
146
|
+
folder: (0, _folder.createFolderCrudMethods)({
|
|
147
|
+
...params,
|
|
148
|
+
listAdminUsers,
|
|
149
|
+
listTeams
|
|
150
|
+
}),
|
|
71
151
|
search: (0, _record.createSearchRecordCrudMethods)(params),
|
|
152
|
+
folderLevelPermissions,
|
|
153
|
+
filter: (0, _filter.createFilterCrudMethods)(params),
|
|
72
154
|
apps,
|
|
73
155
|
getApp: name => apps.get(name),
|
|
74
156
|
listApps: () => apps.list(),
|
|
75
157
|
registerApp: async params => {
|
|
76
|
-
return apps.register(
|
|
77
|
-
model: defaultRecordModel
|
|
78
|
-
|
|
158
|
+
return apps.register({
|
|
159
|
+
model: defaultRecordModel,
|
|
160
|
+
...params
|
|
161
|
+
});
|
|
79
162
|
}
|
|
80
163
|
};
|
|
164
|
+
if (context.wcp.canUseFolderLevelPermissions()) {
|
|
165
|
+
new _CmsEntriesCrudDecorators.CmsEntriesCrudDecorators({
|
|
166
|
+
context
|
|
167
|
+
}).decorate();
|
|
168
|
+
|
|
169
|
+
// PB decorators registered here: packages/api-page-builder-aco/src/index.ts
|
|
170
|
+
// new PageBuilderCrudDecorators({ context }).decorate();
|
|
171
|
+
}
|
|
81
172
|
};
|
|
82
|
-
|
|
173
|
+
|
|
174
|
+
const createAcoContext = (params = {}) => {
|
|
83
175
|
const plugin = new _api.ContextPlugin(async context => {
|
|
84
176
|
/**
|
|
85
177
|
* We can skip the ACO initialization if the installation is pending.
|
|
@@ -88,7 +180,7 @@ const createAcoContext = () => {
|
|
|
88
180
|
return;
|
|
89
181
|
}
|
|
90
182
|
await context.benchmark.measure("aco.context.setup", async () => {
|
|
91
|
-
await setupAcoContext(context);
|
|
183
|
+
await setupAcoContext(context, params);
|
|
92
184
|
});
|
|
93
185
|
await context.benchmark.measure("aco.context.hooks", async () => {
|
|
94
186
|
await (0, _createAcoHooks.createAcoHooks)(context);
|
|
@@ -97,4 +189,6 @@ const createAcoContext = () => {
|
|
|
97
189
|
plugin.name = "aco.createContext";
|
|
98
190
|
return plugin;
|
|
99
191
|
};
|
|
100
|
-
exports.createAcoContext = createAcoContext;
|
|
192
|
+
exports.createAcoContext = createAcoContext;
|
|
193
|
+
|
|
194
|
+
//# sourceMappingURL=createAcoContext.js.map
|
package/createAcoContext.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["setupAcoContext","context","tenancy","security","i18n","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","getIdentity","params","storageOperations","createAcoStorageOperations","cms","getCmsContext","defaultRecordModel","withoutAuthorization","getModel","SEARCH_RECORD_MODEL_ID","apps","AcoApps","plugins","byType","AcoAppRegisterPlugin","type","plugin","register","model","app","aco","folder","createFolderCrudMethods","search","createSearchRecordCrudMethods","getApp","name","get","listApps","list","registerApp","createAcoContext","ContextPlugin","isInstallationPending","benchmark","measure","createAcoHooks"],"sources":["createAcoContext.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { createAcoHooks } from \"~/createAcoHooks\";\nimport { createAcoStorageOperations } from \"~/createAcoStorageOperations\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\nimport { AcoContext, CreateAcoParams, IAcoAppRegisterParams } from \"~/types\";\nimport { createFolderCrudMethods } from \"~/folder/folder.crud\";\nimport { createSearchRecordCrudMethods } from \"~/record/record.crud\";\nimport { AcoApps } from \"./apps\";\nimport { SEARCH_RECORD_MODEL_ID } from \"~/record/record.model\";\nimport { AcoAppRegisterPlugin } from \"~/plugins\";\n\nconst setupAcoContext = async (context: AcoContext): Promise<void> => {\n const { tenancy, security, i18n } = context;\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const getIdentity = () => security.getIdentity();\n\n const params: CreateAcoParams = {\n getLocale,\n getIdentity,\n getTenant,\n storageOperations: createAcoStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context,\n security\n })\n };\n\n const defaultRecordModel = await context.security.withoutAuthorization(async () => {\n return context.cms.getModel(SEARCH_RECORD_MODEL_ID);\n });\n if (!defaultRecordModel) {\n throw new WebinyError(`There is no default record model in ${SEARCH_RECORD_MODEL_ID}`);\n }\n\n /**\n * First we need to create all the apps.\n */\n const apps = new AcoApps(context, params);\n const plugins = context.plugins.byType<AcoAppRegisterPlugin>(AcoAppRegisterPlugin.type);\n for (const plugin of plugins) {\n await apps.register({\n model: defaultRecordModel,\n ...plugin.app\n });\n }\n\n context.aco = {\n folder: createFolderCrudMethods(params),\n search: createSearchRecordCrudMethods(params),\n apps,\n getApp: (name: string) => apps.get(name),\n listApps: () => apps.list(),\n registerApp: async (params: IAcoAppRegisterParams) => {\n return apps.register({\n model: defaultRecordModel,\n ...params\n });\n }\n };\n};\n\nexport const createAcoContext = () => {\n const plugin = new ContextPlugin<AcoContext>(async context => {\n /**\n * We can skip the ACO initialization if the installation is pending.\n */\n if (isInstallationPending(context)) {\n return;\n }\n await context.benchmark.measure(\"aco.context.setup\", async () => {\n await setupAcoContext(context);\n });\n\n await context.benchmark.measure(\"aco.context.hooks\", async () => {\n await createAcoHooks(context);\n });\n });\n\n plugin.name = \"aco.createContext\";\n\n return plugin;\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA,MAAMA,eAAe,GAAG,MAAOC,OAAmB,IAAoB;EAClE,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAK,CAAC,GAAGH,OAAO;EAE3C,MAAMI,SAAS,GAAG,MAAkB;IAChC,MAAMC,MAAM,GAAGF,IAAI,CAACG,gBAAgB,EAAE;IACtC,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,sDAAsD,EACtD,cAAc,CACjB;IACL;IAEA,OAAOF,MAAM;EACjB,CAAC;EAED,MAAMG,SAAS,GAAG,MAAc;IAC5B,OAAOP,OAAO,CAACQ,gBAAgB,EAAE;EACrC,CAAC;EAED,MAAMC,WAAW,GAAG,MAAMR,QAAQ,CAACQ,WAAW,EAAE;EAEhD,MAAMC,MAAuB,GAAG;IAC5BP,SAAS;IACTM,WAAW;IACXF,SAAS;IACTI,iBAAiB,EAAE,IAAAC,sDAA0B,EAAC;MAC1C;AACZ;AACA;MACYC,GAAG,EAAEd,OAAO,CAACc,GAAG;MAChB;AACZ;AACA;MACYC,aAAa,EAAE,MAAMf,OAAO;MAC5BE;IACJ,CAAC;EACL,CAAC;EAED,MAAMc,kBAAkB,GAAG,MAAMhB,OAAO,CAACE,QAAQ,CAACe,oBA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AAe,CAACC,OAAO,CAAC;IAClC,CAAC,CAAC;IAEF,MAAMA,OAAO,CAAC4C,SAAS,CAACC,OAAO,CAAC,mBAAmB,EAAE,YAAY;MAC7D,MAAM,IAAAC,8BAAc,EAAC9C,OAAO,CAAC;IACjC,CAAC,CAAC;EACN,CAAC,CAAC;EAEF0B,MAAM,CAACU,IAAI,GAAG,mBAAmB;EAEjC,OAAOV,MAAM;AACjB,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_api","_createAcoHooks","_createAcoStorageOperations","_isInstallationPending","_folder","_record","_apps","_record2","_plugins","_FolderLevelPermissions","_CmsEntriesCrudDecorators","_folder2","_createOperationsWrapper","_pickEntryFieldValues","_filter","setupAcoContext","context","setupAcoContextParams","tenancy","security","i18n","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","storageOperations","createAcoStorageOperations","cms","getCmsContext","folderLevelPermissions","FolderLevelPermissions","getIdentity","getIdentityTeam","withoutAuthorization","identity","adminUser","adminUsers","getUser","where","id","team","getTeam","listPermissions","listAllFolders","type","withModel","createOperationsWrapper","modelName","FOLDER_MODEL_ID","model","results","entries","list","limit","latest","sort","items","map","pickEntryFieldValues","canUseTeams","wcp","canUseFolderLevelPermissions","useFolderLevelPermissions","isAuthorizationEnabled","params","defaultRecordModel","getModel","SEARCH_RECORD_MODEL_ID","apps","AcoApps","plugins","byType","AcoAppRegisterPlugin","plugin","register","app","listAdminUsers","listUsers","listTeams","aco","folder","createFolderCrudMethods","search","createSearchRecordCrudMethods","filter","createFilterCrudMethods","getApp","name","get","listApps","registerApp","CmsEntriesCrudDecorators","decorate","createAcoContext","ContextPlugin","isInstallationPending","benchmark","measure","createAcoHooks","exports"],"sources":["createAcoContext.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { createAcoHooks } from \"~/createAcoHooks\";\nimport { createAcoStorageOperations } from \"~/createAcoStorageOperations\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\nimport { AcoContext, CreateAcoParams, Folder, IAcoAppRegisterParams } from \"~/types\";\nimport { createFolderCrudMethods } from \"~/folder/folder.crud\";\nimport { createSearchRecordCrudMethods } from \"~/record/record.crud\";\nimport { AcoApps } from \"./apps\";\nimport { SEARCH_RECORD_MODEL_ID } from \"~/record/record.model\";\nimport { AcoAppRegisterPlugin } from \"~/plugins\";\nimport { FolderLevelPermissions } from \"~/utils/FolderLevelPermissions\";\nimport { CmsEntriesCrudDecorators } from \"~/utils/decorators/CmsEntriesCrudDecorators\";\nimport { FOLDER_MODEL_ID } from \"~/folder/folder.model\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { pickEntryFieldValues } from \"~/utils/pickEntryFieldValues\";\nimport { createFilterCrudMethods } from \"~/filter/filter.crud\";\n\ninterface CreateAcoContextParams {\n useFolderLevelPermissions?: boolean;\n}\n\nconst setupAcoContext = async (\n context: AcoContext,\n setupAcoContextParams: CreateAcoContextParams\n): Promise<void> => {\n const { tenancy, security, i18n } = context;\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const storageOperations = createAcoStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context,\n security\n });\n\n const folderLevelPermissions = new FolderLevelPermissions({\n getIdentity: () => security.getIdentity(),\n getIdentityTeam: async () => {\n return security.withoutAuthorization(async () => {\n const identity = security.getIdentity();\n if (!identity) {\n return null;\n }\n\n const adminUser = await context.adminUsers.getUser({ where: { id: identity.id } });\n if (!adminUser) {\n return null;\n }\n\n if (!adminUser.team) {\n return null;\n }\n\n return context.security.getTeam({ where: { id: adminUser.team } });\n });\n },\n listPermissions: () => security.listPermissions(),\n listAllFolders: type => {\n // When retrieving a list of all folders, we want to do it in the\n // fastest way and that is by directly using CMS's storage operations.\n const { withModel } = createOperationsWrapper({\n modelName: FOLDER_MODEL_ID,\n cms: context.cms,\n getCmsContext: () => context,\n security\n });\n\n return withModel(async model => {\n const results = await context.cms.storageOperations.entries.list(model, {\n limit: 100_000,\n where: {\n type,\n\n // Folders always work with latest entries. We never publish them.\n latest: true\n },\n sort: [\"title_ASC\"]\n });\n\n return results.items.map(pickEntryFieldValues<Folder>);\n });\n },\n canUseTeams: () => context.wcp.canUseTeams(),\n canUseFolderLevelPermissions: () => {\n if (setupAcoContextParams.useFolderLevelPermissions === false) {\n return false;\n }\n\n return context.wcp.canUseFolderLevelPermissions();\n },\n isAuthorizationEnabled: () => context.security.isAuthorizationEnabled()\n });\n\n const params: CreateAcoParams = {\n getLocale,\n getTenant,\n storageOperations,\n folderLevelPermissions\n };\n\n const defaultRecordModel = await context.security.withoutAuthorization(async () => {\n return context.cms.getModel(SEARCH_RECORD_MODEL_ID);\n });\n\n if (!defaultRecordModel) {\n throw new WebinyError(`There is no default record model in ${SEARCH_RECORD_MODEL_ID}`);\n }\n\n /**\n * First we need to create all the apps.\n */\n const apps = new AcoApps(context, params);\n const plugins = context.plugins.byType<AcoAppRegisterPlugin>(AcoAppRegisterPlugin.type);\n for (const plugin of plugins) {\n await apps.register({\n model: defaultRecordModel,\n ...plugin.app\n });\n }\n\n const listAdminUsers = () => {\n return security.withoutAuthorization(async () => {\n return context.adminUsers.listUsers();\n });\n };\n const listTeams = () => {\n return security.withoutAuthorization(async () => {\n return context.security.listTeams();\n });\n };\n\n context.aco = {\n folder: createFolderCrudMethods({\n ...params,\n listAdminUsers,\n listTeams\n }),\n search: createSearchRecordCrudMethods(params),\n folderLevelPermissions,\n filter: createFilterCrudMethods(params),\n apps,\n getApp: (name: string) => apps.get(name),\n listApps: () => apps.list(),\n registerApp: async (params: IAcoAppRegisterParams) => {\n return apps.register({\n model: defaultRecordModel,\n ...params\n });\n }\n };\n\n if (context.wcp.canUseFolderLevelPermissions()) {\n new CmsEntriesCrudDecorators({ context }).decorate();\n\n // PB decorators registered here: packages/api-page-builder-aco/src/index.ts\n // new PageBuilderCrudDecorators({ context }).decorate();\n }\n};\n\nexport const createAcoContext = (params: CreateAcoContextParams = {}) => {\n const plugin = new ContextPlugin<AcoContext>(async context => {\n /**\n * We can skip the ACO initialization if the installation is pending.\n */\n if (isInstallationPending(context)) {\n return;\n }\n await context.benchmark.measure(\"aco.context.setup\", async () => {\n await setupAcoContext(context, params);\n });\n\n await context.benchmark.measure(\"aco.context.hooks\", async () => {\n await createAcoHooks(context);\n });\n });\n\n plugin.name = \"aco.createContext\";\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAGA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,uBAAA,GAAAV,OAAA;AACA,IAAAW,yBAAA,GAAAX,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AACA,IAAAa,wBAAA,GAAAb,OAAA;AACA,IAAAc,qBAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AAMA,MAAMgB,eAAe,GAAG,MAAAA,CACpBC,OAAmB,EACnBC,qBAA6C,KAC7B;EAChB,MAAM;IAAEC,OAAO;IAAE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
|
7
7
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
8
|
+
var _filter = require("./filter/filter.gql");
|
|
8
9
|
var _folder = require("./folder/folder.gql");
|
|
9
10
|
var _app = require("./apps/app.gql");
|
|
10
11
|
const emptyResolver = () => ({});
|
|
@@ -58,6 +59,7 @@ const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
58
59
|
input AcoSort {
|
|
59
60
|
id: AcoSortDirection
|
|
60
61
|
createdOn: AcoSortDirection
|
|
62
|
+
modifiedOn: AcoSortDirection
|
|
61
63
|
savedOn: AcoSortDirection
|
|
62
64
|
title: AcoSortDirection
|
|
63
65
|
}
|
|
@@ -116,6 +118,8 @@ const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
116
118
|
}
|
|
117
119
|
});
|
|
118
120
|
const createAcoGraphQL = () => {
|
|
119
|
-
return [baseSchema, _app.appGql, _folder.folderSchema];
|
|
121
|
+
return [baseSchema, _app.appGql, _folder.folderSchema, _filter.filterSchema];
|
|
120
122
|
};
|
|
121
|
-
exports.createAcoGraphQL = createAcoGraphQL;
|
|
123
|
+
exports.createAcoGraphQL = createAcoGraphQL;
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=createAcoGraphQL.js.map
|