@webiny/api-aco 5.37.0-beta.0 → 5.37.0-beta.2
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 +16 -0
- package/apps/AcoApp.js +108 -0
- package/apps/AcoApp.js.map +1 -0
- package/apps/AcoApps.d.ts +10 -0
- package/apps/AcoApps.js +76 -0
- package/apps/AcoApps.js.map +1 -0
- package/apps/app.gql.d.ts +3 -0
- package/apps/app.gql.js +58 -0
- package/apps/app.gql.js.map +1 -0
- package/apps/index.d.ts +2 -0
- package/apps/index.js +27 -0
- package/apps/index.js.map +1 -0
- package/createAcoContext.js +50 -13
- package/createAcoContext.js.map +1 -1
- package/createAcoGraphQL.d.ts +2 -2
- package/createAcoGraphQL.js +34 -5
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoHooks.js.map +1 -1
- package/createAcoModels.js +0 -15
- package/createAcoModels.js.map +1 -1
- package/createAcoStorageOperations.js.map +1 -1
- package/{createAcoFields.d.ts → fields/index.d.ts} +1 -1
- package/fields/index.js +12 -0
- package/fields/index.js.map +1 -0
- package/fields/location.d.ts +2 -0
- package/fields/location.js +44 -0
- package/fields/location.js.map +1 -0
- package/folder/folder.crud.js +18 -0
- package/folder/folder.crud.js.map +1 -1
- package/folder/folder.gql.js +1 -1
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.model.js +0 -18
- package/folder/folder.model.js.map +1 -1
- package/folder/folder.so.js.map +1 -1
- package/folder/folder.types.d.ts +8 -2
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDelete.hook.js +21 -9
- package/folder/onFolderBeforeDelete.hook.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +31 -3
- package/index.js.map +1 -1
- package/package.json +29 -27
- package/plugins/AcoAppModifierPlugin.d.ts +43 -0
- package/plugins/AcoAppModifierPlugin.js +59 -0
- package/plugins/AcoAppModifierPlugin.js.map +1 -0
- package/plugins/AcoAppRegisterPlugin.d.ts +8 -0
- package/plugins/AcoAppRegisterPlugin.js +22 -0
- package/plugins/AcoAppRegisterPlugin.js.map +1 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +27 -0
- package/plugins/index.js.map +1 -0
- package/record/graphql/createAppResolvers.d.ts +14 -0
- package/record/graphql/createAppResolvers.js +108 -0
- package/record/graphql/createAppResolvers.js.map +1 -0
- package/record/graphql/createAppSchema.d.ts +9 -0
- package/record/graphql/createAppSchema.js +142 -0
- package/record/graphql/createAppSchema.js.map +1 -0
- package/record/record.crud.js +45 -14
- package/record/record.crud.js.map +1 -1
- package/record/record.gql.d.ts +8 -3
- package/record/record.gql.js +36 -182
- package/record/record.gql.js.map +1 -1
- package/record/record.model.d.ts +7 -1
- package/record/record.model.js +34 -10
- package/record/record.model.js.map +1 -1
- package/record/record.so.js +55 -44
- package/record/record.so.js.map +1 -1
- package/record/record.types.d.ts +49 -15
- package/record/record.types.js.map +1 -1
- package/types.d.ts +45 -3
- package/types.js +10 -4
- package/types.js.map +1 -1
- package/utils/acoRecordId.js.map +1 -1
- package/utils/checkPermissions.js.map +1 -1
- package/utils/createListSort.js.map +1 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/fieldResolver.js.map +1 -1
- package/utils/getFieldValues.d.ts +2 -2
- package/utils/getFieldValues.js +1 -1
- package/utils/getFieldValues.js.map +1 -1
- package/utils/getFolderAndItsAncestors.d.ts +7 -0
- package/utils/getFolderAndItsAncestors.js +48 -0
- package/utils/getFolderAndItsAncestors.js.map +1 -0
- package/utils/isInstallationPending.js.map +1 -1
- package/utils/modelFactory.js.map +1 -1
- package/utils/resolve.d.ts +2 -1
- package/utils/resolve.js +11 -2
- package/utils/resolve.js.map +1 -1
- package/createAcoCrud.d.ts +0 -2
- package/createAcoCrud.js +0 -17
- package/createAcoCrud.js.map +0 -1
- package/createAcoFields.js +0 -40
- package/createAcoFields.js.map +0 -1
package/apps/AcoApp.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AcoContext, AcoSearchRecordCrudBase, IAcoApp, IAcoAppModifyFieldCallableCallback, IAcoAppParams } from "../types";
|
|
2
|
+
import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export declare class AcoApp implements IAcoApp {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly context: AcoContext;
|
|
6
|
+
readonly model: CmsModel;
|
|
7
|
+
private readonly fields;
|
|
8
|
+
get search(): AcoSearchRecordCrudBase;
|
|
9
|
+
get folder(): import("../types").AcoFolderCrud;
|
|
10
|
+
private constructor();
|
|
11
|
+
static create(context: AcoContext, params: IAcoAppParams): AcoApp;
|
|
12
|
+
getFields(): CmsModelField[];
|
|
13
|
+
addField(field: CmsModelField): void;
|
|
14
|
+
removeField(id: string): void;
|
|
15
|
+
modifyField(id: string, cb: IAcoAppModifyFieldCallableCallback): void;
|
|
16
|
+
}
|
package/apps/AcoApp.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AcoApp = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
var _structuredClone = _interopRequireDefault(require("@ungap/structured-clone"));
|
|
11
|
+
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
12
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
13
|
+
var _record = require("../record/record.model");
|
|
14
|
+
const createApiName = name => {
|
|
15
|
+
return (0, _upperFirst.default)((0, _camelCase.default)(name));
|
|
16
|
+
};
|
|
17
|
+
class AcoApp {
|
|
18
|
+
get search() {
|
|
19
|
+
return {
|
|
20
|
+
create: async data => {
|
|
21
|
+
return this.context.aco.search.create(this.model, data);
|
|
22
|
+
},
|
|
23
|
+
update: async (id, data) => {
|
|
24
|
+
/**
|
|
25
|
+
* Required to have as any atm as TS is breaking on the return type.
|
|
26
|
+
*/
|
|
27
|
+
return await this.context.aco.search.update(this.model, id, data);
|
|
28
|
+
},
|
|
29
|
+
move: async (id, folderId) => {
|
|
30
|
+
return this.context.aco.search.move(this.model, id, folderId);
|
|
31
|
+
},
|
|
32
|
+
get: async id => {
|
|
33
|
+
return this.context.aco.search.get(this.model, id);
|
|
34
|
+
},
|
|
35
|
+
list: async params => {
|
|
36
|
+
return this.context.aco.search.list(this.model, params);
|
|
37
|
+
},
|
|
38
|
+
delete: async id => {
|
|
39
|
+
return this.context.aco.search.delete(this.model, id);
|
|
40
|
+
},
|
|
41
|
+
listTags: async params => {
|
|
42
|
+
return this.context.aco.search.listTags(this.model, params);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
get folder() {
|
|
47
|
+
return this.context.aco.folder;
|
|
48
|
+
}
|
|
49
|
+
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
|
+
this.context = context;
|
|
56
|
+
this.name = params.name;
|
|
57
|
+
this.model = (0, _structuredClone.default)(params.model);
|
|
58
|
+
/**
|
|
59
|
+
* We can safely define the api name of the model as we control everything here.
|
|
60
|
+
*/
|
|
61
|
+
this.model.name = `${this.model.name} ${this.name}`;
|
|
62
|
+
this.model.modelId = `${this.model.modelId}-${this.name.toLowerCase()}`;
|
|
63
|
+
const apiName = `AcoSearchRecord${createApiName(params.apiName)}`;
|
|
64
|
+
this.model.singularApiName = apiName;
|
|
65
|
+
this.model.pluralApiName = apiName;
|
|
66
|
+
const index = this.model.fields.findIndex(f => f.fieldId === "data");
|
|
67
|
+
if (index === -1) {
|
|
68
|
+
throw new _error.default(`The "data" field does not exist in model "${this.model.modelId}".`, "MODEL_DATA_FIELD_ERROR", {
|
|
69
|
+
modelId: this.model.modelId
|
|
70
|
+
});
|
|
71
|
+
} else if (!((_this$model$fields$in = this.model.fields[index].settings) !== null && _this$model$fields$in !== void 0 && _this$model$fields$in.fields)) {
|
|
72
|
+
this.model.fields[index].settings.fields = [];
|
|
73
|
+
}
|
|
74
|
+
this.fields = this.model.fields[index].settings.fields;
|
|
75
|
+
this.fields.push(...params.fields);
|
|
76
|
+
}
|
|
77
|
+
static create(context, params) {
|
|
78
|
+
return new AcoApp(context, params);
|
|
79
|
+
}
|
|
80
|
+
getFields() {
|
|
81
|
+
return this.fields;
|
|
82
|
+
}
|
|
83
|
+
addField(field) {
|
|
84
|
+
this.fields.push(field);
|
|
85
|
+
}
|
|
86
|
+
removeField(id) {
|
|
87
|
+
if (_record.DEFAULT_FIELDS.includes(id)) {
|
|
88
|
+
throw new _error.default(`Cannot remove the default field from the ACO App.`, "REMOVE_DEFAULT_FIELD_ERROR", {
|
|
89
|
+
fieldId: id
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const index = this.fields.findIndex(field => field.id === id);
|
|
93
|
+
if (index === -1) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this.fields.splice(index, 1);
|
|
97
|
+
}
|
|
98
|
+
modifyField(id, cb) {
|
|
99
|
+
const index = this.fields.findIndex(field => field.id === id);
|
|
100
|
+
if (index === -1) {
|
|
101
|
+
throw new _error.default(`There is no field "${id}" in app "${this.name}".`, "FIELD_NOT_FOUND_ERROR", {
|
|
102
|
+
id
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
this.fields[index] = cb((0, _structuredClone.default)(this.fields[index]));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.AcoApp = AcoApp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_structuredClone","_upperFirst","_camelCase","_record","createApiName","name","lodashUpperFirst","lodashCamelCase","AcoApp","search","create","data","context","aco","model","update","id","move","folderId","get","list","params","delete","listTags","folder","constructor","_this$model$fields$in","_defineProperty2","default","structuredClone","modelId","toLowerCase","apiName","singularApiName","pluralApiName","index","fields","findIndex","f","fieldId","WebinyError","settings","push","getFields","addField","field","removeField","DEFAULT_FIELDS","includes","splice","modifyField","cb","exports"],"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 {\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CAAC;EAC3B;EAEOC,WAAWA,CAAC9B,EAAU,EAAQ;IACjC,IAAI+B,sBAAc,CAACC,QAAQ,CAAChC,EAAE,CAAC,EAAE;MAC7B,MAAM,IAAIwB,cAAW,CAChB,mDAAkD,EACnD,4BAA4B,EAC5B;QACID,OAAO,EAAEvB;MACb,CACJ,CAAC;IACL;IACA,MAAMmB,KAAK,GAAG,IAAI,CAACC,MAAM,CAACC,SAAS,CAACQ,KAAK,IAAIA,KAAK,CAAC7B,EAAE,KAAKA,EAAE,CAAC;IAC7D,IAAImB,KAAK,KAAK,CAAC,CAAC,EAAE;MACd;IACJ;IACA,IAAI,CAACC,MAAM,CAACa,MAAM,CAACd,KAAK,EAAE,CAAC,CAAC;EAChC;EAEOe,WAAWA,CAAClC,EAAU,EAAEmC,EAAsC,EAAQ;IACzE,MAAMhB,KAAK,GAAG,IAAI,CAACC,MAAM,CAACC,SAAS,CAACQ,KAAK,IAAIA,KAAK,CAAC7B,EAAE,KAAKA,EAAE,CAAC;IAC7D,IAAImB,KAAK,KAAK,CAAC,CAAC,EAAE;MACd,MAAM,IAAIK,cAAW,CAChB,sBAAqBxB,EAAG,aAAY,IAAI,CAACX,IAAK,IAAG,EAClD,uBAAuB,EACvB;QACIW;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACoB,MAAM,CAACD,KAAK,CAAC,GAAGgB,EAAE,CAAC,IAAAtB,wBAAe,EAAC,IAAI,CAACO,MAAM,CAACD,KAAK,CAAC,CAAC,CAAC;EAChE;AACJ;AAACiB,OAAA,CAAA5C,MAAA,GAAAA,MAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AcoContext, IAcoApp, IAcoAppParams, IAcoApps, IAcoAppsOptions } from "../types";
|
|
2
|
+
export declare class AcoApps implements IAcoApps {
|
|
3
|
+
private readonly apps;
|
|
4
|
+
private readonly context;
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(context: AcoContext, options: IAcoAppsOptions);
|
|
7
|
+
get(name: string): IAcoApp;
|
|
8
|
+
list(): IAcoApp[];
|
|
9
|
+
register(options: IAcoAppParams): Promise<IAcoApp>;
|
|
10
|
+
}
|
package/apps/AcoApps.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AcoApps = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
var _AcoApp = require("./AcoApp");
|
|
12
|
+
var _plugins = require("../plugins");
|
|
13
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
14
|
+
var _record = require("../record/record.gql");
|
|
15
|
+
class AcoApps {
|
|
16
|
+
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
|
+
this.context = context;
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
23
|
+
get(name) {
|
|
24
|
+
const app = this.apps.get(name);
|
|
25
|
+
if (app) {
|
|
26
|
+
return app;
|
|
27
|
+
}
|
|
28
|
+
throw new _error.default(`App "${name}" is not registered.`, "APP_NOT_REGISTERED", {
|
|
29
|
+
name,
|
|
30
|
+
apps: Array.from(this.apps.keys())
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
list() {
|
|
34
|
+
return Array.from(this.apps.values());
|
|
35
|
+
}
|
|
36
|
+
async register(options) {
|
|
37
|
+
const exists = this.apps.has(options.name);
|
|
38
|
+
if (exists) {
|
|
39
|
+
throw new _error.default(`An app with the name "${options.name}" is already registered.`, "APP_EXISTS", {
|
|
40
|
+
name: options.name
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* We need to create the app and run the modifiers on it.
|
|
45
|
+
*/
|
|
46
|
+
const app = _AcoApp.AcoApp.create(this.context, options);
|
|
47
|
+
const modifiers = this.context.plugins.byType(_plugins.AcoAppModifierPlugin.type);
|
|
48
|
+
for (const modifier of modifiers) {
|
|
49
|
+
if (modifier.canUse(app) === false) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
await modifier.modify({
|
|
53
|
+
context: this.context,
|
|
54
|
+
app
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Also, we need to register the app model as the plugin one, so it can be used in the CMS.
|
|
59
|
+
* We do not need to validate model or show it in the API.
|
|
60
|
+
*/
|
|
61
|
+
this.context.plugins.register(new _apiHeadlessCms.CmsModelPlugin((0, _objectSpread2.default)((0, _objectSpread2.default)({}, app.model), {}, {
|
|
62
|
+
singularApiName: undefined,
|
|
63
|
+
pluralApiName: undefined,
|
|
64
|
+
isPrivate: true,
|
|
65
|
+
noValidate: true
|
|
66
|
+
})));
|
|
67
|
+
this.apps.set(app.name, app);
|
|
68
|
+
const searchRecordSchema = await (0, _record.createSchema)({
|
|
69
|
+
context: this.context,
|
|
70
|
+
app
|
|
71
|
+
});
|
|
72
|
+
this.context.plugins.register(searchRecordSchema);
|
|
73
|
+
return app;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.AcoApps = AcoApps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_AcoApp","_plugins","_apiHeadlessCms","_record","AcoApps","constructor","context","options","_defineProperty2","default","Map","get","name","app","apps","WebinyError","Array","from","keys","list","values","register","exists","has","AcoApp","create","modifiers","plugins","byType","AcoAppModifierPlugin","type","modifier","canUse","modify","CmsModelPlugin","_objectSpread2","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 });\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
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.appGql = void 0;
|
|
8
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
+
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
10
|
+
var _checkPermissions = require("../utils/checkPermissions");
|
|
11
|
+
var _resolve = require("../utils/resolve");
|
|
12
|
+
const cleanModel = model => {
|
|
13
|
+
return (0, _omit.default)(model, ["webinyVersion", "tags", "locale", "tenant", "layout", "group", "description", "isPrivate"]);
|
|
14
|
+
};
|
|
15
|
+
const appGql = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
16
|
+
typeDefs: /* GraphQL */`
|
|
17
|
+
type AcoApp {
|
|
18
|
+
id: ID!
|
|
19
|
+
name: String!
|
|
20
|
+
model: JSON!
|
|
21
|
+
}
|
|
22
|
+
type GetAppResponse {
|
|
23
|
+
data: AcoApp
|
|
24
|
+
error: AcoError
|
|
25
|
+
}
|
|
26
|
+
type GetAppModelResponse {
|
|
27
|
+
data: JSON
|
|
28
|
+
error: AcoError
|
|
29
|
+
}
|
|
30
|
+
extend type AcoQuery {
|
|
31
|
+
getApp(id: ID!): GetAppResponse!
|
|
32
|
+
getAppModel(id: ID!): GetAppModelResponse!
|
|
33
|
+
}
|
|
34
|
+
`,
|
|
35
|
+
resolvers: {
|
|
36
|
+
AcoQuery: {
|
|
37
|
+
getApp: async (_, args, context) => {
|
|
38
|
+
return (0, _resolve.resolve)(async () => {
|
|
39
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
40
|
+
const app = context.aco.getApp(args.id);
|
|
41
|
+
return {
|
|
42
|
+
id: args.id,
|
|
43
|
+
name: app.name,
|
|
44
|
+
model: cleanModel(app.model)
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
getAppModel: async (_, args, context) => {
|
|
49
|
+
return (0, _resolve.resolve)(async () => {
|
|
50
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
51
|
+
const app = context.aco.getApp(args.id);
|
|
52
|
+
return cleanModel(app.model);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
exports.appGql = appGql;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_omit","_interopRequireDefault","_checkPermissions","_resolve","cleanModel","model","lodashOmit","appGql","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getApp","_","args","context","resolve","checkPermissions","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 { checkPermissions } from \"~/utils/checkPermissions\";\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 checkPermissions(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 checkPermissions(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,iBAAA,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,kCAAgB,EAACF,OAAO,CAAC;UACzB,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,kCAAgB,EAACF,OAAO,CAAC;UACzB,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.d.ts
ADDED
package/apps/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _AcoApp = require("./AcoApp");
|
|
7
|
+
Object.keys(_AcoApp).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _AcoApp[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _AcoApp[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _AcoApps = require("./AcoApps");
|
|
18
|
+
Object.keys(_AcoApps).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _AcoApps[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _AcoApps[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
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.js
CHANGED
|
@@ -5,24 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createAcoContext = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
-
var
|
|
10
|
+
var _api = require("@webiny/api");
|
|
11
11
|
var _createAcoHooks = require("./createAcoHooks");
|
|
12
12
|
var _createAcoStorageOperations = require("./createAcoStorageOperations");
|
|
13
13
|
var _isInstallationPending = require("./utils/isInstallationPending");
|
|
14
|
-
|
|
14
|
+
var _folder = require("./folder/folder.crud");
|
|
15
|
+
var _record = require("./record/record.crud");
|
|
16
|
+
var _apps = require("./apps");
|
|
17
|
+
var _record2 = require("./record/record.model");
|
|
18
|
+
var _plugins = require("./plugins");
|
|
19
|
+
const setupAcoContext = async context => {
|
|
15
20
|
const {
|
|
16
21
|
tenancy,
|
|
17
22
|
security,
|
|
18
23
|
i18n
|
|
19
24
|
} = context;
|
|
20
|
-
if ((0, _isInstallationPending.isInstallationPending)({
|
|
21
|
-
tenancy,
|
|
22
|
-
i18n
|
|
23
|
-
})) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
25
|
const getLocale = () => {
|
|
27
26
|
const locale = i18n.getContentLocale();
|
|
28
27
|
if (!locale) {
|
|
@@ -34,7 +33,7 @@ const setupAcoContext = context => {
|
|
|
34
33
|
return tenancy.getCurrentTenant();
|
|
35
34
|
};
|
|
36
35
|
const getIdentity = () => security.getIdentity();
|
|
37
|
-
|
|
36
|
+
const params = {
|
|
38
37
|
getLocale,
|
|
39
38
|
getIdentity,
|
|
40
39
|
getTenant,
|
|
@@ -49,15 +48,53 @@ const setupAcoContext = context => {
|
|
|
49
48
|
getCmsContext: () => context,
|
|
50
49
|
security
|
|
51
50
|
})
|
|
51
|
+
};
|
|
52
|
+
const defaultRecordModel = await context.security.withoutAuthorization(async () => {
|
|
53
|
+
return context.cms.getModel(_record2.SEARCH_RECORD_MODEL_ID);
|
|
52
54
|
});
|
|
55
|
+
if (!defaultRecordModel) {
|
|
56
|
+
throw new _error.default(`There is no default record model in ${_record2.SEARCH_RECORD_MODEL_ID}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* First we need to create all the apps.
|
|
61
|
+
*/
|
|
62
|
+
const apps = new _apps.AcoApps(context, params);
|
|
63
|
+
const plugins = context.plugins.byType(_plugins.AcoAppRegisterPlugin.type);
|
|
64
|
+
for (const plugin of plugins) {
|
|
65
|
+
await apps.register((0, _objectSpread2.default)({
|
|
66
|
+
model: defaultRecordModel
|
|
67
|
+
}, plugin.app));
|
|
68
|
+
}
|
|
69
|
+
context.aco = {
|
|
70
|
+
folder: (0, _folder.createFolderCrudMethods)(params),
|
|
71
|
+
search: (0, _record.createSearchRecordCrudMethods)(params),
|
|
72
|
+
apps,
|
|
73
|
+
getApp: name => apps.get(name),
|
|
74
|
+
listApps: () => apps.list(),
|
|
75
|
+
registerApp: async params => {
|
|
76
|
+
return apps.register((0, _objectSpread2.default)({
|
|
77
|
+
model: defaultRecordModel
|
|
78
|
+
}, params));
|
|
79
|
+
}
|
|
80
|
+
};
|
|
53
81
|
};
|
|
54
82
|
const createAcoContext = () => {
|
|
55
|
-
|
|
83
|
+
const plugin = new _api.ContextPlugin(async context => {
|
|
84
|
+
/**
|
|
85
|
+
* We can skip the ACO initialization if the installation is pending.
|
|
86
|
+
*/
|
|
56
87
|
if ((0, _isInstallationPending.isInstallationPending)(context)) {
|
|
57
88
|
return;
|
|
58
89
|
}
|
|
59
|
-
await
|
|
60
|
-
|
|
90
|
+
await context.benchmark.measure("aco.context.setup", async () => {
|
|
91
|
+
await setupAcoContext(context);
|
|
92
|
+
});
|
|
93
|
+
await context.benchmark.measure("aco.context.hooks", async () => {
|
|
94
|
+
await (0, _createAcoHooks.createAcoHooks)(context);
|
|
95
|
+
});
|
|
61
96
|
});
|
|
97
|
+
plugin.name = "aco.createContext";
|
|
98
|
+
return plugin;
|
|
62
99
|
};
|
|
63
100
|
exports.createAcoContext = createAcoContext;
|
package/createAcoContext.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["setupAcoContext","context","tenancy","security","i18n","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_api","_createAcoHooks","_createAcoStorageOperations","_isInstallationPending","_folder","_record","_apps","_record2","_plugins","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","_objectSpread2","default","model","app","aco","folder","createFolderCrudMethods","search","createSearchRecordCrudMethods","getApp","name","get","listApps","list","registerApp","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, 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,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;AAEA,MAAMU,eAAe,GAAG,MAAOC,OAAmB,IAAoB;EAClE,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAK,CAAC,GAAGH,OAAO;EAE3C,MAAMI,SAAS,GAAGA,CAAA,KAAkB;IAChC,MAAMC,MAAM,GAAGF,IAAI,CAACG,gBAAgB,CAAC,CAAC;IACtC,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,sDAAsD,EACtD,cACJ,CAAC;IACL;IAEA,OAAOF,MAAM;EACjB,CAAC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,IAAI,CAACmB,GAAG,CAACD,IAAI,CAAC;IACxCE,QAAQ,EAAEA,CAAA,KAAMpB,IAAI,CAACqB,IAAI,CAAC,CAAC;IAC3BC,WAAW,EAAE,MAAO/B,MAA6B,IAAK;MAClD,OAAOS,IAAI,CAACO,QAAQ,KAAAC,cAAA,CAAAC,OAAA;QAChBC,KAAK,EAAEd;MAAkB,GACtBL,MAAM,CACZ,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAEM,MAAMgC,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMjB,MAAM,GAAG,IAAIkB,kBAAa,CAAa,MAAM5C,OAAO,IAAI;IAC1D;AACR;AACA;IACQ,IAAI,IAAA6C,4CAAqB,EAAC7C,OAAO,CAAC,EAAE;MAChC;IACJ;IACA,MAAMA,OAAO,CAAC8C,SAAS,CAACC,OAAO,CAAC,mBAAmB,EAAE,YAAY;MAC7D,MAAMhD,eAAe,CAACC,OAAO,CAAC;IAClC,CAAC,CAAC;IAEF,MAAMA,OAAO,CAAC8C,SAAS,CAACC,OAAO,CAAC,mBAAmB,EAAE,YAAY;MAC7D,MAAM,IAAAC,8BAAc,EAAChD,OAAO,CAAC;IACjC,CAAC,CAAC;EACN,CAAC,CAAC;EAEF0B,MAAM,CAACY,IAAI,GAAG,mBAAmB;EAEjC,OAAOZ,MAAM;AACjB,CAAC;AAACuB,OAAA,CAAAN,gBAAA,GAAAA,gBAAA"}
|
package/createAcoGraphQL.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
|
|
2
2
|
import { AcoContext } from "./types";
|
|
3
|
-
export declare const createAcoGraphQL: () =>
|
|
3
|
+
export declare const createAcoGraphQL: () => GraphQLSchemaPlugin<AcoContext>[];
|
package/createAcoGraphQL.js
CHANGED
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createAcoGraphQL = void 0;
|
|
7
|
-
var _api = require("@webiny/api");
|
|
8
7
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
8
|
var _folder = require("./folder/folder.gql");
|
|
10
|
-
var
|
|
9
|
+
var _app = require("./apps/app.gql");
|
|
11
10
|
const emptyResolver = () => ({});
|
|
12
11
|
const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
13
12
|
typeDefs: /* GraphQL */`
|
|
@@ -63,6 +62,38 @@ const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
63
62
|
title: AcoSortDirection
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
input AcoSearchRecordTagListWhereInput {
|
|
66
|
+
tags_in: [String!]
|
|
67
|
+
tags_startsWith: String
|
|
68
|
+
tags_not_startsWith: String
|
|
69
|
+
createdBy: ID
|
|
70
|
+
AND: [AcoSearchRecordTagListWhereInput!]
|
|
71
|
+
OR: [AcoSearchRecordTagListWhereInput!]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type AcoSearchRecordMoveResponse {
|
|
75
|
+
data: Boolean
|
|
76
|
+
error: AcoError
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type TagItem {
|
|
80
|
+
tag: String!
|
|
81
|
+
count: Int!
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type AcoSearchRecordTagListResponse {
|
|
85
|
+
data: [TagItem!]
|
|
86
|
+
error: AcoError
|
|
87
|
+
meta: AcoMeta
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type AcoSearchLocationType {
|
|
91
|
+
folderId: ID!
|
|
92
|
+
}
|
|
93
|
+
input AcoSearchLocationInput {
|
|
94
|
+
folderId: ID!
|
|
95
|
+
}
|
|
96
|
+
|
|
66
97
|
extend type Query {
|
|
67
98
|
aco: AcoQuery
|
|
68
99
|
search: SearchQuery
|
|
@@ -85,8 +116,6 @@ const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
85
116
|
}
|
|
86
117
|
});
|
|
87
118
|
const createAcoGraphQL = () => {
|
|
88
|
-
return
|
|
89
|
-
context.plugins.register([baseSchema, _folder.folderSchema, _record.searchRecordSchema]);
|
|
90
|
-
});
|
|
119
|
+
return [baseSchema, _app.appGql, _folder.folderSchema];
|
|
91
120
|
};
|
|
92
121
|
exports.createAcoGraphQL = createAcoGraphQL;
|
package/createAcoGraphQL.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","aco","search","Mutation","createAcoGraphQL","
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_folder","_app","emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","aco","search","Mutation","createAcoGraphQL","appGql","folderSchema","exports"],"sources":["createAcoGraphQL.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { folderSchema } from \"~/folder/folder.gql\";\nimport { appGql } from \"~/apps/app.gql\";\nimport { AcoContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type AcoQuery {\n _empty: String\n }\n\n type AcoMutation {\n _empty: String\n }\n\n type SearchQuery {\n _empty: String\n }\n\n type SearchMutation {\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 savedOn: AcoSortDirection\n title: AcoSortDirection\n }\n\n input AcoSearchRecordTagListWhereInput {\n tags_in: [String!]\n tags_startsWith: String\n tags_not_startsWith: String\n createdBy: ID\n AND: [AcoSearchRecordTagListWhereInput!]\n OR: [AcoSearchRecordTagListWhereInput!]\n }\n\n type AcoSearchRecordMoveResponse {\n data: Boolean\n error: AcoError\n }\n\n type TagItem {\n tag: String!\n count: Int!\n }\n\n type AcoSearchRecordTagListResponse {\n data: [TagItem!]\n error: AcoError\n meta: AcoMeta\n }\n\n type AcoSearchLocationType {\n folderId: ID!\n }\n input AcoSearchLocationInput {\n folderId: ID!\n }\n\n extend type Query {\n aco: AcoQuery\n search: SearchQuery\n }\n\n extend type Mutation {\n aco: AcoMutation\n search: SearchMutation\n }\n `,\n resolvers: {\n Query: {\n aco: emptyResolver,\n search: emptyResolver\n },\n Mutation: {\n aco: emptyResolver,\n search: emptyResolver\n }\n }\n});\n\nexport const createAcoGraphQL = (): GraphQLSchemaPlugin<AcoContext>[] => {\n return [baseSchema, appGql, folderSchema];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAGA,MAAMG,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ,CAAC;IACDQ,QAAQ,EAAE;MACNF,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ;EACJ;AACJ,CAAC,CAAC;AAEK,MAAMS,gBAAgB,GAAGA,CAAA,KAAyC;EACrE,OAAO,CAACR,UAAU,EAAES,WAAM,EAAEC,oBAAY,CAAC;AAC7C,CAAC;AAACC,OAAA,CAAAH,gBAAA,GAAAA,gBAAA"}
|
package/createAcoHooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAcoHooks","context","onFolderBeforeDeleteHook"],"sources":["createAcoHooks.ts"],"sourcesContent":["import { onFolderBeforeDeleteHook } from \"~/folder/onFolderBeforeDelete.hook\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const createAcoHooks = (context: AcoContext) => {\n onFolderBeforeDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA;AAIO,
|
|
1
|
+
{"version":3,"names":["_onFolderBeforeDelete","require","createAcoHooks","context","onFolderBeforeDeleteHook","exports"],"sources":["createAcoHooks.ts"],"sourcesContent":["import { onFolderBeforeDeleteHook } from \"~/folder/onFolderBeforeDelete.hook\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const createAcoHooks = (context: AcoContext) => {\n onFolderBeforeDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAIO,MAAMC,cAAc,GAAIC,OAAmB,IAAK;EACnD,IAAAC,8CAAwB,EAACD,OAAO,CAAC;AACrC,CAAC;AAACE,OAAA,CAAAH,cAAA,GAAAA,cAAA"}
|
package/createAcoModels.js
CHANGED
|
@@ -7,23 +7,8 @@ exports.createAcoModels = void 0;
|
|
|
7
7
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
8
8
|
var _folder = require("./folder/folder.model");
|
|
9
9
|
var _record = require("./record/record.model");
|
|
10
|
-
var _isInstallationPending = require("./utils/isInstallationPending");
|
|
11
10
|
var _modelFactory = require("./utils/modelFactory");
|
|
12
11
|
const createAcoModels = context => {
|
|
13
|
-
/**
|
|
14
|
-
* This should never happen in the actual project.
|
|
15
|
-
* It is to make sure that we load setup context before the CRUD init in our internal code.
|
|
16
|
-
*/
|
|
17
|
-
if (!context.cms) {
|
|
18
|
-
console.warn("Creating model before cms init.");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if ((0, _isInstallationPending.isInstallationPending)({
|
|
22
|
-
tenancy: context.tenancy,
|
|
23
|
-
i18n: context.i18n
|
|
24
|
-
})) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
12
|
const groupId = "contentModelGroup_aco";
|
|
28
13
|
|
|
29
14
|
/**
|
package/createAcoModels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_apiHeadlessCms","require","_folder","_record","_modelFactory","createAcoModels","context","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","modelDefinitions","createFolderModelDefinition","createSearchModelDefinition","cmsModelPlugins","map","modelDefinition","modelFactory","group","contentModelGroup","plugins","register","exports"],"sources":["createAcoModels.ts"],"sourcesContent":["import { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { createFolderModelDefinition } from \"~/folder/folder.model\";\nimport { createSearchModelDefinition } from \"~/record/record.model\";\nimport { modelFactory } from \"~/utils/modelFactory\";\n\nexport const createAcoModels = (context: CmsContext) => {\n const groupId = \"contentModelGroup_aco\";\n\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"aco\",\n name: \"ACO\",\n description: \"Group for Advanced Content Organisation and Search\",\n icon: \"fas/folder\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const modelDefinitions = [createFolderModelDefinition(), createSearchModelDefinition()];\n const cmsModelPlugins = modelDefinitions.map(modelDefinition => {\n return modelFactory({\n group: cmsGroupPlugin.contentModelGroup,\n modelDefinition\n });\n });\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEO,MAAMI,eAAe,GAAIC,OAAmB,IAAK;EACpD,MAAMC,OAAO,GAAG,uBAAuB;;EAEvC;AACJ;AACA;EACI,MAAMC,cAAc,GAAG,IAAIC,8BAAc,CAAC;IACtCC,EAAE,EAAEH,OAAO;IACXI,IAAI,EAAE,KAAK;IACXC,IAAI,EAAE,KAAK;IACXC,WAAW,EAAE,oDAAoD;IACjEC,IAAI,EAAE,YAAY;IAClBC,SAAS,EAAE;EACf,CAAC,CAAC;;EAEF;AACJ;AACA;EACI,MAAMC,gBAAgB,GAAG,CAAC,IAAAC,mCAA2B,EAAC,CAAC,EAAE,IAAAC,mCAA2B,EAAC,CAAC,CAAC;EACvF,MAAMC,eAAe,GAAGH,gBAAgB,CAACI,GAAG,CAACC,eAAe,IAAI;IAC5D,OAAO,IAAAC,0BAAY,EAAC;MAChBC,KAAK,EAAEf,cAAc,CAACgB,iBAAiB;MACvCH;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;EACIf,OAAO,CAACmB,OAAO,CAACC,QAAQ,CAAC,CAAClB,cAAc,EAAEW,eAAe,CAAC,CAAC;AAC/D,CAAC;AAACQ,OAAA,CAAAtB,eAAA,GAAAA,eAAA"}
|