@webiny/api-aco 0.0.0-unstable.7f63ea0744 → 0.0.0-unstable.8feaff8c32
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/README.md +6 -6
- 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 +44 -14
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoHooks.js.map +1 -1
- package/createAcoModels.js +0 -25
- 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 +20 -5
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.model.d.ts +3 -3
- package/folder/folder.model.js +3 -25
- package/folder/folder.model.js.map +1 -1
- package/folder/folder.so.d.ts +1 -6
- package/folder/folder.so.js +103 -108
- package/folder/folder.so.js.map +1 -1
- package/folder/folder.types.d.ts +9 -3
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDelete.hook.js +40 -27
- package/folder/onFolderBeforeDelete.hook.js.map +1 -1
- package/index.d.ts +5 -1
- package/index.js +48 -6
- package/index.js.map +1 -1
- package/package.json +34 -31
- 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 +46 -12
- package/record/record.crud.js.map +1 -1
- package/record/record.gql.d.ts +8 -3
- package/record/record.gql.js +36 -113
- package/record/record.gql.js.map +1 -1
- package/record/record.model.d.ts +10 -4
- package/record/record.model.js +39 -28
- package/record/record.model.js.map +1 -1
- package/record/record.so.d.ts +1 -6
- package/record/record.so.js +112 -62
- package/record/record.so.js.map +1 -1
- package/record/record.types.d.ts +66 -15
- package/record/record.types.js.map +1 -1
- package/types.d.ts +56 -3
- package/types.js +41 -1
- package/types.js.map +1 -1
- package/utils/acoRecordId.d.ts +6 -0
- package/utils/acoRecordId.js +33 -0
- package/utils/acoRecordId.js.map +1 -0
- package/utils/checkPermissions.d.ts +2 -0
- package/utils/checkPermissions.js +14 -0
- package/utils/checkPermissions.js.map +1 -0
- package/utils/createListSort.d.ts +2 -0
- package/utils/createListSort.js +13 -0
- package/utils/createListSort.js.map +1 -0
- package/utils/createModelField.d.ts +0 -1
- package/utils/createModelField.js +2 -4
- package/utils/createModelField.js.map +1 -1
- package/utils/createOperationsWrapper.d.ts +9 -0
- package/utils/createOperationsWrapper.js +29 -0
- package/utils/createOperationsWrapper.js.map +1 -0
- package/utils/fieldResolver.js.map +1 -1
- package/utils/getFieldValues.d.ts +4 -1
- package/utils/getFieldValues.js +6 -2
- 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.d.ts +3 -3
- package/utils/modelFactory.js +4 -2
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.8feaff8c32",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -21,37 +21,40 @@
|
|
|
21
21
|
"access": "public",
|
|
22
22
|
"directory": "dist"
|
|
23
23
|
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@babel/cli": "^7.19.3",
|
|
26
|
-
"@babel/core": "^7.19.3",
|
|
27
|
-
"@babel/preset-env": "^7.19.4",
|
|
28
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
29
|
-
"@babel/runtime": "^7.19.0",
|
|
30
|
-
"@webiny/api-headless-cms-ddb": "^0.0.0-unstable.7f63ea0744",
|
|
31
|
-
"@webiny/api-i18n-ddb": "^0.0.0-unstable.7f63ea0744",
|
|
32
|
-
"@webiny/api-security-so-ddb": "^0.0.0-unstable.7f63ea0744",
|
|
33
|
-
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.7f63ea0744",
|
|
34
|
-
"@webiny/api-wcp": "^0.0.0-unstable.7f63ea0744",
|
|
35
|
-
"@webiny/cli": "^0.0.0-unstable.7f63ea0744",
|
|
36
|
-
"@webiny/handler-aws": "^0.0.0-unstable.7f63ea0744",
|
|
37
|
-
"@webiny/plugins": "^0.0.0-unstable.7f63ea0744",
|
|
38
|
-
"@webiny/project-utils": "^0.0.0-unstable.7f63ea0744",
|
|
39
|
-
"rimraf": "^3.0.2",
|
|
40
|
-
"ttypescript": "^1.5.13",
|
|
41
|
-
"typescript": "^4.7.4"
|
|
42
|
-
},
|
|
43
24
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@webiny/api
|
|
46
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
47
|
-
"@webiny/api-i18n": "0.0.0-unstable.
|
|
48
|
-
"@webiny/api-security": "0.0.0-unstable.
|
|
49
|
-
"@webiny/api-tenancy": "0.0.0-unstable.
|
|
50
|
-
"@webiny/error": "0.0.0-unstable.
|
|
51
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
52
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
53
|
-
"@webiny/pubsub": "0.0.0-unstable.
|
|
25
|
+
"@ungap/structured-clone": "1.2.0",
|
|
26
|
+
"@webiny/api": "0.0.0-unstable.8feaff8c32",
|
|
27
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.8feaff8c32",
|
|
28
|
+
"@webiny/api-i18n": "0.0.0-unstable.8feaff8c32",
|
|
29
|
+
"@webiny/api-security": "0.0.0-unstable.8feaff8c32",
|
|
30
|
+
"@webiny/api-tenancy": "0.0.0-unstable.8feaff8c32",
|
|
31
|
+
"@webiny/error": "0.0.0-unstable.8feaff8c32",
|
|
32
|
+
"@webiny/handler": "0.0.0-unstable.8feaff8c32",
|
|
33
|
+
"@webiny/handler-graphql": "0.0.0-unstable.8feaff8c32",
|
|
34
|
+
"@webiny/pubsub": "0.0.0-unstable.8feaff8c32",
|
|
35
|
+
"@webiny/utils": "0.0.0-unstable.8feaff8c32",
|
|
54
36
|
"lodash": "4.17.21"
|
|
55
37
|
},
|
|
56
|
-
"
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/cli": "7.22.6",
|
|
40
|
+
"@babel/core": "7.22.8",
|
|
41
|
+
"@babel/preset-env": "7.22.7",
|
|
42
|
+
"@babel/preset-typescript": "7.22.5",
|
|
43
|
+
"@babel/runtime": "7.22.6",
|
|
44
|
+
"@types/ungap__structured-clone": "0.3.0",
|
|
45
|
+
"@webiny/api-i18n-ddb": "0.0.0-unstable.8feaff8c32",
|
|
46
|
+
"@webiny/api-security-so-ddb": "0.0.0-unstable.8feaff8c32",
|
|
47
|
+
"@webiny/api-tenancy-so-ddb": "0.0.0-unstable.8feaff8c32",
|
|
48
|
+
"@webiny/api-wcp": "0.0.0-unstable.8feaff8c32",
|
|
49
|
+
"@webiny/cli": "0.0.0-unstable.8feaff8c32",
|
|
50
|
+
"@webiny/handler-aws": "0.0.0-unstable.8feaff8c32",
|
|
51
|
+
"@webiny/plugins": "0.0.0-unstable.8feaff8c32",
|
|
52
|
+
"@webiny/project-utils": "0.0.0-unstable.8feaff8c32",
|
|
53
|
+
"graphql": "15.8.0",
|
|
54
|
+
"prettier": "2.8.8",
|
|
55
|
+
"rimraf": "3.0.2",
|
|
56
|
+
"ttypescript": "1.5.15",
|
|
57
|
+
"typescript": "4.7.4"
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "8feaff8c32ad81701938e9e3eadd836c8eb2fcb1"
|
|
57
60
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { AcoContext, IAcoApp, IAcoAppAddFieldCallable, IAcoAppModifyFieldCallable, IAcoAppRemoveFieldCallable } from "../types";
|
|
3
|
+
import { Context } from "@webiny/handler/types";
|
|
4
|
+
export interface AcoAppModifierPluginModifyParams<T extends Context = AcoContext> {
|
|
5
|
+
app: IAcoApp;
|
|
6
|
+
context: T;
|
|
7
|
+
}
|
|
8
|
+
export interface AcoAppModifierPluginParamsCallable<T extends Context = AcoContext> {
|
|
9
|
+
(params: AppModifier<T>): Promise<void> | void;
|
|
10
|
+
}
|
|
11
|
+
export interface AcoAppModifierPluginParams<T extends Context = AcoContext> {
|
|
12
|
+
name: string;
|
|
13
|
+
cb: AcoAppModifierPluginParamsCallable<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface AppModifier<T extends Context = AcoContext> {
|
|
16
|
+
/**
|
|
17
|
+
* We can access the app if really required.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
app: IAcoApp;
|
|
21
|
+
/**
|
|
22
|
+
* We can access the context if really required.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
context: T;
|
|
26
|
+
addField: IAcoAppAddFieldCallable;
|
|
27
|
+
removeField: IAcoAppRemoveFieldCallable;
|
|
28
|
+
modifyField: IAcoAppModifyFieldCallable;
|
|
29
|
+
}
|
|
30
|
+
export interface AppModifierParams<T extends Context = AcoContext> {
|
|
31
|
+
app: IAcoApp;
|
|
32
|
+
context: T;
|
|
33
|
+
}
|
|
34
|
+
export declare class AcoAppModifierPlugin<T extends Context = Context> extends Plugin {
|
|
35
|
+
static readonly type: string;
|
|
36
|
+
private readonly params;
|
|
37
|
+
private constructor();
|
|
38
|
+
static create<C extends Context = AcoContext>(params: AcoAppModifierPluginParams<C>): AcoAppModifierPlugin<C>;
|
|
39
|
+
canUse(app: IAcoApp): boolean;
|
|
40
|
+
modify(params: AcoAppModifierPluginModifyParams<T>): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export declare type CreateAcoAppModifierCallable<T extends Context = AcoContext> = AcoAppModifierPluginParamsCallable<T>;
|
|
43
|
+
export declare const createAcoAppModifier: <T extends Context = AcoContext>(name: string, cb: CreateAcoAppModifierCallable<T>) => AcoAppModifierPlugin<T>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createAcoAppModifier = exports.AcoAppModifierPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
const createModifier = ({
|
|
11
|
+
app,
|
|
12
|
+
context
|
|
13
|
+
}) => {
|
|
14
|
+
return {
|
|
15
|
+
app,
|
|
16
|
+
context,
|
|
17
|
+
addField: field => {
|
|
18
|
+
app.addField(field);
|
|
19
|
+
},
|
|
20
|
+
removeField: id => {
|
|
21
|
+
app.removeField(id);
|
|
22
|
+
},
|
|
23
|
+
modifyField: (id, cb) => {
|
|
24
|
+
app.modifyField(id, cb);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
class AcoAppModifierPlugin extends _plugins.Plugin {
|
|
29
|
+
constructor(params) {
|
|
30
|
+
super();
|
|
31
|
+
(0, _defineProperty2.default)(this, "params", void 0);
|
|
32
|
+
this.params = params;
|
|
33
|
+
}
|
|
34
|
+
static create(params) {
|
|
35
|
+
return new AcoAppModifierPlugin(params);
|
|
36
|
+
}
|
|
37
|
+
canUse(app) {
|
|
38
|
+
return app.name === this.params.name;
|
|
39
|
+
}
|
|
40
|
+
async modify(params) {
|
|
41
|
+
const {
|
|
42
|
+
app,
|
|
43
|
+
context
|
|
44
|
+
} = params;
|
|
45
|
+
return this.params.cb(createModifier({
|
|
46
|
+
app,
|
|
47
|
+
context
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.AcoAppModifierPlugin = AcoAppModifierPlugin;
|
|
52
|
+
(0, _defineProperty2.default)(AcoAppModifierPlugin, "type", "aco.app.modifier");
|
|
53
|
+
const createAcoAppModifier = (name, cb) => {
|
|
54
|
+
return AcoAppModifierPlugin.create({
|
|
55
|
+
name,
|
|
56
|
+
cb
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
exports.createAcoAppModifier = createAcoAppModifier;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","createModifier","app","context","addField","field","removeField","id","modifyField","cb","AcoAppModifierPlugin","Plugin","constructor","params","_defineProperty2","default","create","canUse","name","modify","exports","createAcoAppModifier"],"sources":["AcoAppModifierPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n AcoContext,\n IAcoApp,\n IAcoAppAddFieldCallable,\n IAcoAppModifyFieldCallable,\n IAcoAppRemoveFieldCallable\n} from \"~/types\";\nimport { Context } from \"@webiny/handler/types\";\n\nexport interface AcoAppModifierPluginModifyParams<T extends Context = AcoContext> {\n app: IAcoApp;\n context: T;\n}\n\nexport interface AcoAppModifierPluginParamsCallable<T extends Context = AcoContext> {\n (params: AppModifier<T>): Promise<void> | void;\n}\n\nexport interface AcoAppModifierPluginParams<T extends Context = AcoContext> {\n name: string;\n cb: AcoAppModifierPluginParamsCallable<T>;\n}\n\nexport interface AppModifier<T extends Context = AcoContext> {\n /**\n * We can access the app if really required.\n * @internal\n */\n app: IAcoApp;\n /**\n * We can access the context if really required.\n * @internal\n */\n context: T;\n addField: IAcoAppAddFieldCallable;\n removeField: IAcoAppRemoveFieldCallable;\n modifyField: IAcoAppModifyFieldCallable;\n}\n\nexport interface AppModifierParams<T extends Context = AcoContext> {\n app: IAcoApp;\n context: T;\n}\n\nconst createModifier = <T extends Context>({\n app,\n context\n}: AppModifierParams<T>): AppModifier<T> => {\n return {\n app,\n context,\n addField: field => {\n app.addField(field);\n },\n removeField: id => {\n app.removeField(id);\n },\n modifyField: (id, cb) => {\n app.modifyField(id, cb);\n }\n };\n};\n\nexport class AcoAppModifierPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"aco.app.modifier\";\n\n private readonly params: AcoAppModifierPluginParams<T>;\n\n private constructor(params: AcoAppModifierPluginParams<T>) {\n super();\n this.params = params;\n }\n\n public static create<C extends Context = AcoContext>(params: AcoAppModifierPluginParams<C>) {\n return new AcoAppModifierPlugin<C>(params);\n }\n\n public canUse(app: IAcoApp): boolean {\n return app.name === this.params.name;\n }\n\n public async modify(params: AcoAppModifierPluginModifyParams<T>): Promise<void> {\n const { app, context } = params;\n return this.params.cb(\n createModifier<T>({\n app,\n context\n })\n );\n }\n}\n\nexport type CreateAcoAppModifierCallable<T extends Context = AcoContext> =\n AcoAppModifierPluginParamsCallable<T>;\n\nexport const createAcoAppModifier = <T extends Context = AcoContext>(\n name: string,\n cb: CreateAcoAppModifierCallable<T>\n) => {\n return AcoAppModifierPlugin.create<T>({\n name,\n cb\n });\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AA6CA,MAAMC,cAAc,GAAGA,CAAoB;EACvCC,GAAG;EACHC;AACkB,CAAC,KAAqB;EACxC,OAAO;IACHD,GAAG;IACHC,OAAO;IACPC,QAAQ,EAAEC,KAAK,IAAI;MACfH,GAAG,CAACE,QAAQ,CAACC,KAAK,CAAC;IACvB,CAAC;IACDC,WAAW,EAAEC,EAAE,IAAI;MACfL,GAAG,CAACI,WAAW,CAACC,EAAE,CAAC;IACvB,CAAC;IACDC,WAAW,EAAEA,CAACD,EAAE,EAAEE,EAAE,KAAK;MACrBP,GAAG,CAACM,WAAW,CAACD,EAAE,EAAEE,EAAE,CAAC;IAC3B;EACJ,CAAC;AACL,CAAC;AAEM,MAAMC,oBAAoB,SAAsCC,eAAM,CAAC;EAKlEC,WAAWA,CAACC,MAAqC,EAAE;IACvD,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACF,MAAM,GAAGA,MAAM;EACxB;EAEA,OAAcG,MAAMA,CAAiCH,MAAqC,EAAE;IACxF,OAAO,IAAIH,oBAAoB,CAAIG,MAAM,CAAC;EAC9C;EAEOI,MAAMA,CAACf,GAAY,EAAW;IACjC,OAAOA,GAAG,CAACgB,IAAI,KAAK,IAAI,CAACL,MAAM,CAACK,IAAI;EACxC;EAEA,MAAaC,MAAMA,CAACN,MAA2C,EAAiB;IAC5E,MAAM;MAAEX,GAAG;MAAEC;IAAQ,CAAC,GAAGU,MAAM;IAC/B,OAAO,IAAI,CAACA,MAAM,CAACJ,EAAE,CACjBR,cAAc,CAAI;MACdC,GAAG;MACHC;IACJ,CAAC,CACL,CAAC;EACL;AACJ;AAACiB,OAAA,CAAAV,oBAAA,GAAAA,oBAAA;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EA3BYL,oBAAoB,UACkB,kBAAkB;AA+B9D,MAAMW,oBAAoB,GAAGA,CAChCH,IAAY,EACZT,EAAmC,KAClC;EACD,OAAOC,oBAAoB,CAACM,MAAM,CAAI;IAClCE,IAAI;IACJT;EACJ,CAAC,CAAC;AACN,CAAC;AAACW,OAAA,CAAAC,oBAAA,GAAAA,oBAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { IAcoAppRegisterParams } from "../types";
|
|
3
|
+
export declare class AcoAppRegisterPlugin extends Plugin {
|
|
4
|
+
static type: string;
|
|
5
|
+
readonly app: IAcoAppRegisterParams;
|
|
6
|
+
constructor(app: IAcoAppRegisterParams);
|
|
7
|
+
}
|
|
8
|
+
export declare const registerAcoApp: (app: IAcoAppRegisterParams) => AcoAppRegisterPlugin;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.registerAcoApp = exports.AcoAppRegisterPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
class AcoAppRegisterPlugin extends _plugins.Plugin {
|
|
11
|
+
constructor(app) {
|
|
12
|
+
super();
|
|
13
|
+
(0, _defineProperty2.default)(this, "app", void 0);
|
|
14
|
+
this.app = app;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.AcoAppRegisterPlugin = AcoAppRegisterPlugin;
|
|
18
|
+
(0, _defineProperty2.default)(AcoAppRegisterPlugin, "type", "aco.apps.create.app");
|
|
19
|
+
const registerAcoApp = app => {
|
|
20
|
+
return new AcoAppRegisterPlugin(app);
|
|
21
|
+
};
|
|
22
|
+
exports.registerAcoApp = registerAcoApp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","AcoAppRegisterPlugin","Plugin","constructor","app","_defineProperty2","default","exports","registerAcoApp"],"sources":["AcoAppRegisterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { IAcoAppRegisterParams } from \"~/types\";\n\nexport class AcoAppRegisterPlugin extends Plugin {\n public static override type = \"aco.apps.create.app\";\n public readonly app: IAcoAppRegisterParams;\n\n public constructor(app: IAcoAppRegisterParams) {\n super();\n this.app = app;\n }\n}\n\nexport const registerAcoApp = (app: IAcoAppRegisterParams) => {\n return new AcoAppRegisterPlugin(app);\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGO,MAAMC,oBAAoB,SAASC,eAAM,CAAC;EAItCC,WAAWA,CAACC,GAA0B,EAAE;IAC3C,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACF,GAAG,GAAGA,GAAG;EAClB;AACJ;AAACG,OAAA,CAAAN,oBAAA,GAAAA,oBAAA;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EARYL,oBAAoB,UACC,qBAAqB;AAShD,MAAMO,cAAc,GAAIJ,GAA0B,IAAK;EAC1D,OAAO,IAAIH,oBAAoB,CAACG,GAAG,CAAC;AACxC,CAAC;AAACG,OAAA,CAAAC,cAAA,GAAAA,cAAA"}
|
package/plugins/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _AcoAppRegisterPlugin = require("./AcoAppRegisterPlugin");
|
|
7
|
+
Object.keys(_AcoAppRegisterPlugin).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _AcoAppRegisterPlugin[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _AcoAppRegisterPlugin[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _AcoAppModifierPlugin = require("./AcoAppModifierPlugin");
|
|
18
|
+
Object.keys(_AcoAppModifierPlugin).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _AcoAppModifierPlugin[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _AcoAppModifierPlugin[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_AcoAppRegisterPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_AcoAppModifierPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"./AcoAppRegisterPlugin\";\nexport * from \"./AcoAppModifierPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,qBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,qBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,qBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,qBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,qBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,qBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,qBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CmsFieldTypePlugins, CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { IAcoApp } from "../../types";
|
|
3
|
+
interface Params {
|
|
4
|
+
app: IAcoApp;
|
|
5
|
+
models: CmsModel[];
|
|
6
|
+
plugins: CmsFieldTypePlugins;
|
|
7
|
+
}
|
|
8
|
+
interface Resolvers {
|
|
9
|
+
SearchQuery: Record<string, any>;
|
|
10
|
+
SearchMutation: Record<string, any>;
|
|
11
|
+
[key: string]: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
export declare const createAppResolvers: (params: Params) => Resolvers;
|
|
14
|
+
export {};
|
|
@@ -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.createAppResolvers = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _createFieldResolvers = require("@webiny/api-headless-cms/graphql/schema/createFieldResolvers");
|
|
10
|
+
var _resolve = require("../../utils/resolve");
|
|
11
|
+
var _utils = require("@webiny/utils");
|
|
12
|
+
var _acoRecordId = require("../../utils/acoRecordId");
|
|
13
|
+
var _checkPermissions = require("../../utils/checkPermissions");
|
|
14
|
+
const createAppResolvers = params => {
|
|
15
|
+
const {
|
|
16
|
+
app,
|
|
17
|
+
models,
|
|
18
|
+
plugins
|
|
19
|
+
} = params;
|
|
20
|
+
const model = app.model;
|
|
21
|
+
const apiName = model.singularApiName;
|
|
22
|
+
const createFieldResolvers = (0, _createFieldResolvers.createFieldResolversFactory)({
|
|
23
|
+
endpointType: "manage",
|
|
24
|
+
models,
|
|
25
|
+
model,
|
|
26
|
+
fieldTypePlugins: plugins
|
|
27
|
+
});
|
|
28
|
+
const fieldResolvers = createFieldResolvers({
|
|
29
|
+
graphQLType: apiName,
|
|
30
|
+
fields: app.model.fields,
|
|
31
|
+
isRoot: true,
|
|
32
|
+
extraResolvers: {
|
|
33
|
+
id: entry => {
|
|
34
|
+
const {
|
|
35
|
+
id
|
|
36
|
+
} = (0, _utils.parseIdentifier)(entry.id);
|
|
37
|
+
return (0, _acoRecordId.removeAcoRecordPrefix)(id);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const resolvers = {
|
|
42
|
+
SearchQuery: {
|
|
43
|
+
[`get${apiName}`]: async (_, args, context) => {
|
|
44
|
+
return (0, _resolve.resolve)(() => {
|
|
45
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
46
|
+
return app.search.get(args.id);
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
[`list${apiName}`]: async (_, args, context) => {
|
|
50
|
+
return (0, _resolve.resolveList)(() => {
|
|
51
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
52
|
+
return app.search.list(args);
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
[`list${apiName}Tags`]: async (_, args, context) => {
|
|
56
|
+
return (0, _resolve.resolveList)(() => {
|
|
57
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
58
|
+
return app.search.listTags(args);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
SearchMutation: {
|
|
63
|
+
[`create${apiName}`]: async (_, args, context) => {
|
|
64
|
+
return (0, _resolve.resolve)(() => {
|
|
65
|
+
var _args$data;
|
|
66
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
67
|
+
const {
|
|
68
|
+
id
|
|
69
|
+
} = (0, _utils.parseIdentifier)((_args$data = args.data) === null || _args$data === void 0 ? void 0 : _args$data.id);
|
|
70
|
+
return app.search.create((0, _objectSpread2.default)((0, _objectSpread2.default)({}, args.data), {}, {
|
|
71
|
+
id
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
[`update${apiName}`]: async (_, args, context) => {
|
|
76
|
+
return (0, _resolve.resolve)(() => {
|
|
77
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
78
|
+
const {
|
|
79
|
+
id
|
|
80
|
+
} = (0, _utils.parseIdentifier)(args.id);
|
|
81
|
+
return app.search.update(id, args.data || {});
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
[`move${apiName}`]: async (_, args, context) => {
|
|
85
|
+
return (0, _resolve.resolve)(() => {
|
|
86
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
87
|
+
const {
|
|
88
|
+
id
|
|
89
|
+
} = (0, _utils.parseIdentifier)(args.id);
|
|
90
|
+
return app.search.move(id, args.folderId);
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
[`delete${apiName}`]: async (_, args, context) => {
|
|
94
|
+
return (0, _resolve.resolve)(() => {
|
|
95
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
96
|
+
const {
|
|
97
|
+
id
|
|
98
|
+
} = (0, _utils.parseIdentifier)(args.id);
|
|
99
|
+
return app.search.delete(id);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
Object.assign(resolvers, fieldResolvers);
|
|
105
|
+
delete resolvers[apiName].entryId;
|
|
106
|
+
return resolvers;
|
|
107
|
+
};
|
|
108
|
+
exports.createAppResolvers = createAppResolvers;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_createFieldResolvers","require","_resolve","_utils","_acoRecordId","_checkPermissions","createAppResolvers","params","app","models","plugins","model","apiName","singularApiName","createFieldResolvers","createFieldResolversFactory","endpointType","fieldTypePlugins","fieldResolvers","graphQLType","fields","isRoot","extraResolvers","id","entry","parseIdentifier","removeAcoRecordPrefix","resolvers","SearchQuery","_","args","context","resolve","checkPermissions","search","get","resolveList","list","listTags","SearchMutation","_args$data","data","create","_objectSpread2","default","update","move","folderId","delete","Object","assign","entryId","exports"],"sources":["createAppResolvers.ts"],"sourcesContent":["import { CmsEntry, CmsFieldTypePlugins, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { createFieldResolversFactory } from \"@webiny/api-headless-cms/graphql/schema/createFieldResolvers\";\nimport { AcoContext, IAcoApp } from \"~/types\";\nimport { resolve, resolveList } from \"~/utils/resolve\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { removeAcoRecordPrefix } from \"~/utils/acoRecordId\";\nimport { checkPermissions } from \"~/utils/checkPermissions\";\n\ninterface Params {\n app: IAcoApp;\n models: CmsModel[];\n plugins: CmsFieldTypePlugins;\n}\n\ninterface Resolvers {\n SearchQuery: Record<string, any>;\n SearchMutation: Record<string, any>;\n [key: string]: Record<string, any>;\n}\n\nexport const createAppResolvers = (params: Params): Resolvers => {\n const { app, models, plugins } = params;\n\n const model = app.model;\n const apiName = model.singularApiName;\n\n const createFieldResolvers = createFieldResolversFactory({\n endpointType: \"manage\",\n models,\n model,\n fieldTypePlugins: plugins\n });\n\n const fieldResolvers = createFieldResolvers({\n graphQLType: apiName,\n fields: app.model.fields,\n isRoot: true,\n extraResolvers: {\n id: (entry: CmsEntry) => {\n const { id } = parseIdentifier(entry.id);\n return removeAcoRecordPrefix(id);\n }\n }\n });\n\n const resolvers: Resolvers = {\n SearchQuery: {\n [`get${apiName}`]: async (_: unknown, args: any, context: AcoContext) => {\n return resolve(() => {\n checkPermissions(context);\n return app.search.get(args.id);\n });\n },\n [`list${apiName}`]: async (_: unknown, args: any, context: AcoContext) => {\n return resolveList(() => {\n checkPermissions(context);\n return app.search.list(args);\n });\n },\n [`list${apiName}Tags`]: async (_: unknown, args: any, context: AcoContext) => {\n return resolveList(() => {\n checkPermissions(context);\n return app.search.listTags(args);\n });\n }\n },\n SearchMutation: {\n [`create${apiName}`]: async (_: unknown, args: any, context: AcoContext) => {\n return resolve(() => {\n checkPermissions(context);\n const { id } = parseIdentifier(args.data?.id);\n return app.search.create({\n ...args.data,\n id\n });\n });\n },\n [`update${apiName}`]: async (_: unknown, args: any, context: AcoContext) => {\n return resolve(() => {\n checkPermissions(context);\n const { id } = parseIdentifier(args.id);\n return app.search.update(id, args.data || {});\n });\n },\n [`move${apiName}`]: async (_: unknown, args: any, context: AcoContext) => {\n return resolve(() => {\n checkPermissions(context);\n const { id } = parseIdentifier(args.id);\n return app.search.move(id, args.folderId);\n });\n },\n [`delete${apiName}`]: async (_: unknown, args: any, context: AcoContext) => {\n return resolve(() => {\n checkPermissions(context);\n const { id } = parseIdentifier(args.id);\n return app.search.delete(id);\n });\n }\n }\n };\n\n Object.assign(resolvers, fieldResolvers);\n delete resolvers[apiName].entryId;\n\n return resolvers;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,qBAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAcO,MAAMK,kBAAkB,GAAIC,MAAc,IAAgB;EAC7D,MAAM;IAAEC,GAAG;IAAEC,MAAM;IAAEC;EAAQ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,MAAM;UACjB,IAAAC,kCAAgB,EAACF,OAAO,CAAC;UACzB,MAAM;YAAER;UAAG,CAAC,GAAG,IAAAE,sBAAe,EAACK,IAAI,CAACP,EAAE,CAAC;UACvC,OAAOf,GAAG,CAAC0B,MAAM,CAACY,IAAI,CAACvB,EAAE,EAAEO,IAAI,CAACiB,QAAQ,CAAC;QAC7C,CAAC,CAAC;MACN,CAAC;MACD,CAAE,SAAQnC,OAAQ,EAAC,GAAG,OAAOiB,CAAU,EAAEC,IAAS,EAAEC,OAAmB,KAAK;QACxE,OAAO,IAAAC,gBAAO,EAAC,MAAM;UACjB,IAAAC,kCAAgB,EAACF,OAAO,CAAC;UACzB,MAAM;YAAER;UAAG,CAAC,GAAG,IAAAE,sBAAe,EAACK,IAAI,CAACP,EAAE,CAAC;UACvC,OAAOf,GAAG,CAAC0B,MAAM,CAACc,MAAM,CAACzB,EAAE,CAAC;QAChC,CAAC,CAAC;MACN;IACJ;EACJ,CAAC;EAED0B,MAAM,CAACC,MAAM,CAACvB,SAAS,EAAET,cAAc,CAAC;EACxC,OAAOS,SAAS,CAACf,OAAO,CAAC,CAACuC,OAAO;EAEjC,OAAOxB,SAAS;AACpB,CAAC;AAACyB,OAAA,CAAA9C,kBAAA,GAAAA,kBAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CmsFieldTypePlugins, CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { IAcoApp } from "../../types";
|
|
3
|
+
interface Params {
|
|
4
|
+
app: IAcoApp;
|
|
5
|
+
models: CmsModel[];
|
|
6
|
+
plugins: CmsFieldTypePlugins;
|
|
7
|
+
}
|
|
8
|
+
export declare const createAppSchema: (params: Params) => string;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createAppSchema = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _renderFields = require("@webiny/api-headless-cms/utils/renderFields");
|
|
10
|
+
var _renderInputFields = require("@webiny/api-headless-cms/utils/renderInputFields");
|
|
11
|
+
var _renderListFilterFields = require("@webiny/api-headless-cms/utils/renderListFilterFields");
|
|
12
|
+
var _renderSortEnum = require("@webiny/api-headless-cms/utils/renderSortEnum");
|
|
13
|
+
const removeFieldRequiredValidation = field => {
|
|
14
|
+
if (field.validation) {
|
|
15
|
+
field.validation = field.validation.filter(validation => validation.name !== "required");
|
|
16
|
+
}
|
|
17
|
+
if (field.listValidation) {
|
|
18
|
+
field.listValidation = field.listValidation.filter(v => v.name !== "required");
|
|
19
|
+
}
|
|
20
|
+
return field;
|
|
21
|
+
};
|
|
22
|
+
const createUpdateFields = fields => {
|
|
23
|
+
return fields.reduce((collection, field) => {
|
|
24
|
+
if (["type"].includes(field.fieldId)) {
|
|
25
|
+
return collection;
|
|
26
|
+
} else if (field.fieldId === "tags") {
|
|
27
|
+
collection.push(field);
|
|
28
|
+
return collection;
|
|
29
|
+
}
|
|
30
|
+
collection.push(removeFieldRequiredValidation((0, _objectSpread2.default)({}, field)));
|
|
31
|
+
return collection;
|
|
32
|
+
}, []);
|
|
33
|
+
};
|
|
34
|
+
const createAppSchema = params => {
|
|
35
|
+
const {
|
|
36
|
+
app,
|
|
37
|
+
models,
|
|
38
|
+
plugins: fieldTypePlugins
|
|
39
|
+
} = params;
|
|
40
|
+
const {
|
|
41
|
+
model
|
|
42
|
+
} = app;
|
|
43
|
+
const {
|
|
44
|
+
singularApiName: apiName,
|
|
45
|
+
fields
|
|
46
|
+
} = model;
|
|
47
|
+
const fieldTypes = (0, _renderFields.renderFields)({
|
|
48
|
+
models,
|
|
49
|
+
model,
|
|
50
|
+
fields,
|
|
51
|
+
type: "manage",
|
|
52
|
+
fieldTypePlugins
|
|
53
|
+
});
|
|
54
|
+
const inputCreateFields = (0, _renderInputFields.renderInputFields)({
|
|
55
|
+
models,
|
|
56
|
+
model,
|
|
57
|
+
fields,
|
|
58
|
+
fieldTypePlugins
|
|
59
|
+
});
|
|
60
|
+
const inputUpdateFields = (0, _renderInputFields.renderInputFields)({
|
|
61
|
+
models,
|
|
62
|
+
model,
|
|
63
|
+
fields: createUpdateFields(fields),
|
|
64
|
+
fieldTypePlugins
|
|
65
|
+
});
|
|
66
|
+
const listFilterFieldsRender = (0, _renderListFilterFields.renderListFilterFields)({
|
|
67
|
+
model,
|
|
68
|
+
fields: model.fields,
|
|
69
|
+
type: "manage",
|
|
70
|
+
fieldTypePlugins
|
|
71
|
+
});
|
|
72
|
+
const sortEnumRender = (0, _renderSortEnum.renderSortEnum)({
|
|
73
|
+
model,
|
|
74
|
+
fields: model.fields,
|
|
75
|
+
fieldTypePlugins
|
|
76
|
+
});
|
|
77
|
+
return (/* GraphQL */`
|
|
78
|
+
${fieldTypes.map(f => f.typeDefs).join("\n")}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
type ${apiName} {
|
|
82
|
+
id: ID!
|
|
83
|
+
savedOn: DateTime!
|
|
84
|
+
createdOn: DateTime!
|
|
85
|
+
createdBy: AcoUser!
|
|
86
|
+
${fieldTypes.map(f => f.fields).join("\n")}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
${inputCreateFields.map(f => f.typeDefs).join("\n")}
|
|
90
|
+
|
|
91
|
+
input ${apiName}CreateInput {
|
|
92
|
+
id: ID
|
|
93
|
+
${inputCreateFields.map(f => f.fields).join("\n")}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
input ${apiName}UpdateInput {
|
|
97
|
+
${inputUpdateFields.map(f => f.fields).join("\n")}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type ${apiName}Response {
|
|
101
|
+
data: ${apiName}
|
|
102
|
+
error: AcoError
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
input ${apiName}ListWhereInput {
|
|
106
|
+
${listFilterFieldsRender}
|
|
107
|
+
AND: [${apiName}ListWhereInput!]
|
|
108
|
+
OR: [${apiName}ListWhereInput!]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type ${apiName}ListResponse {
|
|
112
|
+
data: [${apiName}!]
|
|
113
|
+
error: AcoError
|
|
114
|
+
meta: AcoMeta
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
enum ${apiName}ListSorter {
|
|
118
|
+
${sortEnumRender}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
extend type SearchQuery {
|
|
122
|
+
get${apiName}(id: ID!): ${apiName}Response!
|
|
123
|
+
list${apiName}(
|
|
124
|
+
where: ${apiName}ListWhereInput
|
|
125
|
+
search: String
|
|
126
|
+
limit: Int
|
|
127
|
+
after: String
|
|
128
|
+
sort: [${apiName}ListSorter!]
|
|
129
|
+
): ${apiName}ListResponse!
|
|
130
|
+
list${apiName}Tags(where: AcoSearchRecordTagListWhereInput): AcoSearchRecordTagListResponse!
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
extend type SearchMutation {
|
|
134
|
+
create${apiName}(data: ${apiName}CreateInput!): ${apiName}Response!
|
|
135
|
+
update${apiName}(id: ID!, data: ${apiName}UpdateInput!): ${apiName}Response!
|
|
136
|
+
move${apiName}(id: ID!, folderId: ID!): AcoSearchRecordMoveResponse!
|
|
137
|
+
delete${apiName}(id: ID!): AcoBooleanResponse!
|
|
138
|
+
}
|
|
139
|
+
`
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
exports.createAppSchema = createAppSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_renderFields","require","_renderInputFields","_renderListFilterFields","_renderSortEnum","removeFieldRequiredValidation","field","validation","filter","name","listValidation","v","createUpdateFields","fields","reduce","collection","includes","fieldId","push","_objectSpread2","default","createAppSchema","params","app","models","plugins","fieldTypePlugins","model","singularApiName","apiName","fieldTypes","renderFields","type","inputCreateFields","renderInputFields","inputUpdateFields","listFilterFieldsRender","renderListFilterFields","sortEnumRender","renderSortEnum","map","f","typeDefs","join","exports"],"sources":["createAppSchema.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields\";\nimport { IAcoApp } from \"~/types\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum\";\n\ninterface Params {\n app: IAcoApp;\n models: CmsModel[];\n plugins: CmsFieldTypePlugins;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n if ([\"type\"].includes(field.fieldId)) {\n return collection;\n } else if (field.fieldId === \"tags\") {\n collection.push(field);\n return collection;\n }\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createAppSchema = (params: Params): string => {\n const { app, models, plugins: fieldTypePlugins } = params;\n const { model } = app;\n const { singularApiName: apiName, fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldTypePlugins\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldTypePlugins\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldTypePlugins\n });\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins\n });\n\n return /* GraphQL */ `\n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n\n\n type ${apiName} {\n id: ID!\n savedOn: DateTime!\n createdOn: DateTime!\n createdBy: AcoUser!\n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n\n input ${apiName}CreateInput {\n id: ID\n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n input ${apiName}UpdateInput {\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type ${apiName}Response {\n data: ${apiName}\n error: AcoError\n }\n\n input ${apiName}ListWhereInput {\n ${listFilterFieldsRender}\n AND: [${apiName}ListWhereInput!]\n OR: [${apiName}ListWhereInput!]\n }\n\n type ${apiName}ListResponse {\n data: [${apiName}!]\n error: AcoError\n meta: AcoMeta\n }\n\n enum ${apiName}ListSorter {\n ${sortEnumRender}\n }\n\n extend type SearchQuery {\n get${apiName}(id: ID!): ${apiName}Response!\n list${apiName}(\n where: ${apiName}ListWhereInput\n search: String\n limit: Int\n after: String\n sort: [${apiName}ListSorter!]\n ): ${apiName}ListResponse!\n list${apiName}Tags(where: AcoSearchRecordTagListWhereInput): AcoSearchRecordTagListResponse!\n }\n\n extend type SearchMutation {\n create${apiName}(data: ${apiName}CreateInput!): ${apiName}Response!\n update${apiName}(id: ID!, data: ${apiName}UpdateInput!): ${apiName}Response!\n move${apiName}(id: ID!, folderId: ID!): AcoSearchRecordMoveResponse!\n delete${apiName}(id: ID!): AcoBooleanResponse!\n }\n `;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAQA,MAAMI,6BAA6B,GAAIC,KAAoB,IAAK;EAC5D,IAAIA,KAAK,CAACC,UAAU,EAAE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