@webiny/api-aco 0.0.0-unstable.c59b9cc5b9 → 0.0.0-unstable.c7dec08bb0
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/createAcoModels.js +0 -15
- package/createAcoModels.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.types.d.ts +8 -2
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDelete.hook.js +29 -16
- 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 +24 -22
- 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.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/resolve.d.ts +3 -2
- 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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createLocationField = void 0;
|
|
7
|
+
const createFilters = field => {
|
|
8
|
+
return [`${field.fieldId}: AcoLocationInput`, `${field.fieldId}_in: [AcoLocationInput!]`, `${field.fieldId}_not_in: [AcoLocationInput!]`].join("\n");
|
|
9
|
+
};
|
|
10
|
+
const createLocationField = () => {
|
|
11
|
+
return {
|
|
12
|
+
type: "cms-model-field-to-graphql",
|
|
13
|
+
name: "cms-model-field-to-graphql-location",
|
|
14
|
+
fieldType: "location",
|
|
15
|
+
isSortable: false,
|
|
16
|
+
isSearchable: true,
|
|
17
|
+
read: {
|
|
18
|
+
createGetFilters({
|
|
19
|
+
field
|
|
20
|
+
}) {
|
|
21
|
+
return createFilters(field);
|
|
22
|
+
},
|
|
23
|
+
createListFilters({
|
|
24
|
+
field
|
|
25
|
+
}) {
|
|
26
|
+
return createFilters(field);
|
|
27
|
+
},
|
|
28
|
+
createTypeField() {
|
|
29
|
+
return ``;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
manage: {
|
|
33
|
+
createTypeField() {
|
|
34
|
+
return ``;
|
|
35
|
+
},
|
|
36
|
+
createInputField({
|
|
37
|
+
field
|
|
38
|
+
}) {
|
|
39
|
+
return `${field.fieldId}: AcoLocationInput`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.createLocationField = createLocationField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFilters","field","fieldId","join","createLocationField","type","name","fieldType","isSortable","isSearchable","read","createGetFilters","createListFilters","createTypeField","manage","createInputField"],"sources":["location.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\n\nconst createFilters = (field: CmsModelField) => {\n return [\n `${field.fieldId}: AcoLocationInput`,\n `${field.fieldId}_in: [AcoLocationInput!]`,\n `${field.fieldId}_not_in: [AcoLocationInput!]`\n ].join(\"\\n\");\n};\nexport const createLocationField = (): CmsModelFieldToGraphQLPlugin => {\n return {\n type: \"cms-model-field-to-graphql\",\n name: \"cms-model-field-to-graphql-location\",\n fieldType: \"location\",\n isSortable: false,\n isSearchable: true,\n read: {\n createGetFilters({ field }): string {\n return createFilters(field);\n },\n createListFilters({ field }): string {\n return createFilters(field);\n },\n createTypeField(): string {\n return ``;\n }\n },\n manage: {\n createTypeField(): string {\n return ``;\n },\n createInputField({ field }): string {\n return `${field.fieldId}: AcoLocationInput`;\n }\n }\n };\n};\n"],"mappings":";;;;;;AAEA,MAAMA,aAAa,GAAIC,KAAoB,IAAK;EAC5C,OAAO,CACF,GAAEA,KAAK,CAACC,OAAQ,oBAAmB,EACnC,GAAED,KAAK,CAACC,OAAQ,0BAAyB,EACzC,GAAED,KAAK,CAACC,OAAQ,8BAA6B,CACjD,CAACC,IAAI,CAAC,IAAI,CAAC;AAChB,CAAC;AACM,MAAMC,mBAAmB,GAAG,MAAoC;EACnE,OAAO;IACHC,IAAI,EAAE,4BAA4B;IAClCC,IAAI,EAAE,qCAAqC;IAC3CC,SAAS,EAAE,UAAU;IACrBC,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE,IAAI;IAClBC,IAAI,EAAE;MACFC,gBAAgB,CAAC;QAAEV;MAAM,CAAC,EAAU;QAChC,OAAOD,aAAa,CAACC,KAAK,CAAC;MAC/B,CAAC;MACDW,iBAAiB,CAAC;QAAEX;MAAM,CAAC,EAAU;QACjC,OAAOD,aAAa,CAACC,KAAK,CAAC;MAC/B,CAAC;MACDY,eAAe,GAAW;QACtB,OAAQ,EAAC;MACb;IACJ,CAAC;IACDC,MAAM,EAAE;MACJD,eAAe,GAAW;QACtB,OAAQ,EAAC;MACb,CAAC;MACDE,gBAAgB,CAAC;QAAEd;MAAM,CAAC,EAAU;QAChC,OAAQ,GAAEA,KAAK,CAACC,OAAQ,oBAAmB;MAC/C;IACJ;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/folder/folder.crud.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createFolderCrudMethods = void 0;
|
|
7
7
|
var _pubsub = require("@webiny/pubsub");
|
|
8
|
+
var _getFolderAndItsAncestors = require("../utils/getFolderAndItsAncestors");
|
|
8
9
|
const createFolderCrudMethods = ({
|
|
9
10
|
storageOperations
|
|
10
11
|
}) => {
|
|
@@ -86,6 +87,23 @@ const createFolderCrudMethods = ({
|
|
|
86
87
|
folder
|
|
87
88
|
});
|
|
88
89
|
return true;
|
|
90
|
+
},
|
|
91
|
+
async getFolderWithAncestors(id) {
|
|
92
|
+
const {
|
|
93
|
+
type
|
|
94
|
+
} = await storageOperations.getFolder({
|
|
95
|
+
id
|
|
96
|
+
});
|
|
97
|
+
const [folders] = await storageOperations.listFolders({
|
|
98
|
+
where: {
|
|
99
|
+
type
|
|
100
|
+
},
|
|
101
|
+
limit: 10000
|
|
102
|
+
});
|
|
103
|
+
return (0, _getFolderAndItsAncestors.getFolderAndItsAncestors)({
|
|
104
|
+
id,
|
|
105
|
+
folders
|
|
106
|
+
});
|
|
89
107
|
}
|
|
90
108
|
};
|
|
91
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFolderCrudMethods","storageOperations","onFolderBeforeCreate","createTopic","onFolderAfterCreate","onFolderBeforeUpdate","onFolderAfterUpdate","onFolderBeforeDelete","onFolderAfterDelete","get","id","getFolder","list","params","listFolders","create","data","publish","input","folder","createFolder","update","original","updateFolder","delete","deleteFolder"],"sources":["folder.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\n\nimport { CreateAcoParams } from \"~/types\";\nimport {\n AcoFolderCrud,\n OnFolderAfterCreateTopicParams,\n OnFolderAfterDeleteTopicParams,\n OnFolderAfterUpdateTopicParams,\n OnFolderBeforeCreateTopicParams,\n OnFolderBeforeDeleteTopicParams,\n OnFolderBeforeUpdateTopicParams\n} from \"./folder.types\";\n\nexport const createFolderCrudMethods = ({ storageOperations }: CreateAcoParams): AcoFolderCrud => {\n // create\n const onFolderBeforeCreate = createTopic<OnFolderBeforeCreateTopicParams>(\n \"aco.onFolderBeforeCreate\"\n );\n const onFolderAfterCreate =\n createTopic<OnFolderAfterCreateTopicParams>(\"aco.onFolderAfterCreate\");\n // update\n const onFolderBeforeUpdate = createTopic<OnFolderBeforeUpdateTopicParams>(\n \"aco.onFolderBeforeUpdate\"\n );\n const onFolderAfterUpdate =\n createTopic<OnFolderAfterUpdateTopicParams>(\"aco.onFolderAfterUpdate\");\n // delete\n const onFolderBeforeDelete = createTopic<OnFolderBeforeDeleteTopicParams>(\n \"aco.onFolderBeforeDelete\"\n );\n const onFolderAfterDelete =\n createTopic<OnFolderAfterDeleteTopicParams>(\"aco.onFolderAfterDelete\");\n\n return {\n /**\n * Lifecycle events\n */\n onFolderBeforeCreate,\n onFolderAfterCreate,\n onFolderBeforeUpdate,\n onFolderAfterUpdate,\n onFolderBeforeDelete,\n onFolderAfterDelete,\n async get(id) {\n return storageOperations.getFolder({ id });\n },\n async list(params) {\n return storageOperations.listFolders(params);\n },\n async create(data) {\n await onFolderBeforeCreate.publish({ input: data });\n const folder = await storageOperations.createFolder({ data });\n await onFolderAfterCreate.publish({ folder });\n return folder;\n },\n async update(id, data) {\n const original = await storageOperations.getFolder({ id });\n await onFolderBeforeUpdate.publish({ original, input: { id, data } });\n const folder = await storageOperations.updateFolder({ id, data });\n await onFolderAfterUpdate.publish({ original, input: { id, data }, folder });\n return folder;\n },\n async delete(id: string) {\n const folder = await storageOperations.getFolder({ id });\n await onFolderBeforeDelete.publish({ folder });\n await storageOperations.deleteFolder({ id });\n await onFolderAfterDelete.publish({ folder });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;AAAA;
|
|
1
|
+
{"version":3,"names":["createFolderCrudMethods","storageOperations","onFolderBeforeCreate","createTopic","onFolderAfterCreate","onFolderBeforeUpdate","onFolderAfterUpdate","onFolderBeforeDelete","onFolderAfterDelete","get","id","getFolder","list","params","listFolders","create","data","publish","input","folder","createFolder","update","original","updateFolder","delete","deleteFolder","getFolderWithAncestors","type","folders","where","limit","getFolderAndItsAncestors"],"sources":["folder.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\n\nimport { CreateAcoParams } from \"~/types\";\nimport {\n AcoFolderCrud,\n OnFolderAfterCreateTopicParams,\n OnFolderAfterDeleteTopicParams,\n OnFolderAfterUpdateTopicParams,\n OnFolderBeforeCreateTopicParams,\n OnFolderBeforeDeleteTopicParams,\n OnFolderBeforeUpdateTopicParams\n} from \"./folder.types\";\n\nimport { getFolderAndItsAncestors } from \"~/utils/getFolderAndItsAncestors\";\n\nexport const createFolderCrudMethods = ({ storageOperations }: CreateAcoParams): AcoFolderCrud => {\n // create\n const onFolderBeforeCreate = createTopic<OnFolderBeforeCreateTopicParams>(\n \"aco.onFolderBeforeCreate\"\n );\n const onFolderAfterCreate =\n createTopic<OnFolderAfterCreateTopicParams>(\"aco.onFolderAfterCreate\");\n // update\n const onFolderBeforeUpdate = createTopic<OnFolderBeforeUpdateTopicParams>(\n \"aco.onFolderBeforeUpdate\"\n );\n const onFolderAfterUpdate =\n createTopic<OnFolderAfterUpdateTopicParams>(\"aco.onFolderAfterUpdate\");\n // delete\n const onFolderBeforeDelete = createTopic<OnFolderBeforeDeleteTopicParams>(\n \"aco.onFolderBeforeDelete\"\n );\n const onFolderAfterDelete =\n createTopic<OnFolderAfterDeleteTopicParams>(\"aco.onFolderAfterDelete\");\n\n return {\n /**\n * Lifecycle events\n */\n onFolderBeforeCreate,\n onFolderAfterCreate,\n onFolderBeforeUpdate,\n onFolderAfterUpdate,\n onFolderBeforeDelete,\n onFolderAfterDelete,\n async get(id) {\n return storageOperations.getFolder({ id });\n },\n async list(params) {\n return storageOperations.listFolders(params);\n },\n async create(data) {\n await onFolderBeforeCreate.publish({ input: data });\n const folder = await storageOperations.createFolder({ data });\n await onFolderAfterCreate.publish({ folder });\n return folder;\n },\n async update(id, data) {\n const original = await storageOperations.getFolder({ id });\n await onFolderBeforeUpdate.publish({ original, input: { id, data } });\n const folder = await storageOperations.updateFolder({ id, data });\n await onFolderAfterUpdate.publish({ original, input: { id, data }, folder });\n return folder;\n },\n async delete(id: string) {\n const folder = await storageOperations.getFolder({ id });\n await onFolderBeforeDelete.publish({ folder });\n await storageOperations.deleteFolder({ id });\n await onFolderAfterDelete.publish({ folder });\n return true;\n },\n async getFolderWithAncestors(id: string) {\n const { type } = await storageOperations.getFolder({ id });\n const [folders] = await storageOperations.listFolders({\n where: {\n type\n },\n limit: 10000\n });\n return getFolderAndItsAncestors({ id, folders });\n }\n };\n};\n"],"mappings":";;;;;;AAAA;AAaA;AAEO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC;AAAmC,CAAC,KAAoB;EAC9F;EACA,MAAMC,oBAAoB,GAAG,IAAAC,mBAAW,EACpC,0BAA0B,CAC7B;EACD,MAAMC,mBAAmB,GACrB,IAAAD,mBAAW,EAAiC,yBAAyB,CAAC;EAC1E;EACA,MAAME,oBAAoB,GAAG,IAAAF,mBAAW,EACpC,0BAA0B,CAC7B;EACD,MAAMG,mBAAmB,GACrB,IAAAH,mBAAW,EAAiC,yBAAyB,CAAC;EAC1E;EACA,MAAMI,oBAAoB,GAAG,IAAAJ,mBAAW,EACpC,0BAA0B,CAC7B;EACD,MAAMK,mBAAmB,GACrB,IAAAL,mBAAW,EAAiC,yBAAyB,CAAC;EAE1E,OAAO;IACH;AACR;AACA;IACQD,oBAAoB;IACpBE,mBAAmB;IACnBC,oBAAoB;IACpBC,mBAAmB;IACnBC,oBAAoB;IACpBC,mBAAmB;IACnB,MAAMC,GAAG,CAACC,EAAE,EAAE;MACV,OAAOT,iBAAiB,CAACU,SAAS,CAAC;QAAED;MAAG,CAAC,CAAC;IAC9C,CAAC;IACD,MAAME,IAAI,CAACC,MAAM,EAAE;MACf,OAAOZ,iBAAiB,CAACa,WAAW,CAACD,MAAM,CAAC;IAChD,CAAC;IACD,MAAME,MAAM,CAACC,IAAI,EAAE;MACf,MAAMd,oBAAoB,CAACe,OAAO,CAAC;QAAEC,KAAK,EAAEF;MAAK,CAAC,CAAC;MACnD,MAAMG,MAAM,GAAG,MAAMlB,iBAAiB,CAACmB,YAAY,CAAC;QAAEJ;MAAK,CAAC,CAAC;MAC7D,MAAMZ,mBAAmB,CAACa,OAAO,CA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wB,EAAC;QAAErB,EAAE;QAAEkB;MAAQ,CAAC,CAAC;IACpD;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/folder/folder.gql.js
CHANGED
|
@@ -78,7 +78,7 @@ const folderSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
78
78
|
},
|
|
79
79
|
listFolders: async (_, args, context) => {
|
|
80
80
|
try {
|
|
81
|
-
|
|
81
|
+
(0, _checkPermissions.checkPermissions)(context);
|
|
82
82
|
const [entries, meta] = await context.aco.folder.list(args);
|
|
83
83
|
return new _responses.ListResponse(entries, meta);
|
|
84
84
|
} catch (e) {
|
package/folder/folder.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["folderSchema","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getFolder","_","id","context","resolve","checkPermissions","aco","folder","get","listFolders","args","entries","meta","list","ListResponse","e","ErrorResponse","AcoMutation","createFolder","data","create","updateFolder","update","deleteFolder","delete"],"sources":["folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\n\nimport { checkPermissions } from \"~/utils/checkPermissions\";\nimport { resolve } from \"~/utils/resolve\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const folderSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type Folder {\n id: ID!\n title: String!\n slug: String!\n type: String!\n parentId: ID\n savedOn: DateTime\n createdOn: DateTime\n createdBy: AcoUser\n }\n\n input FolderCreateInput {\n title: String!\n slug: String!\n type: String!\n parentId: ID\n }\n\n input FolderUpdateInput {\n title: String\n slug: String\n parentId: ID\n }\n\n input FoldersListWhereInput {\n type: String!\n parentId: String\n createdBy: ID\n }\n\n type FolderResponse {\n data: Folder\n error: AcoError\n }\n\n type FoldersListResponse {\n data: [Folder]\n error: AcoError\n }\n\n extend type AcoQuery {\n getFolder(id: ID!): FolderResponse\n listFolders(\n where: FoldersListWhereInput!\n limit: Int\n after: String\n sort: AcoSort\n ): FoldersListResponse\n }\n\n extend type AcoMutation {\n createFolder(data: FolderCreateInput!): FolderResponse\n updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse\n deleteFolder(id: ID!): AcoBooleanResponse\n }\n `,\n resolvers: {\n AcoQuery: {\n getFolder: async (_, { id }, context) => {\n return resolve(() => {\n checkPermissions(context);\n return context.aco.folder.get(id);\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n
|
|
1
|
+
{"version":3,"names":["folderSchema","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getFolder","_","id","context","resolve","checkPermissions","aco","folder","get","listFolders","args","entries","meta","list","ListResponse","e","ErrorResponse","AcoMutation","createFolder","data","create","updateFolder","update","deleteFolder","delete"],"sources":["folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\n\nimport { checkPermissions } from \"~/utils/checkPermissions\";\nimport { resolve } from \"~/utils/resolve\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const folderSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type Folder {\n id: ID!\n title: String!\n slug: String!\n type: String!\n parentId: ID\n savedOn: DateTime\n createdOn: DateTime\n createdBy: AcoUser\n }\n\n input FolderCreateInput {\n title: String!\n slug: String!\n type: String!\n parentId: ID\n }\n\n input FolderUpdateInput {\n title: String\n slug: String\n parentId: ID\n }\n\n input FoldersListWhereInput {\n type: String!\n parentId: String\n createdBy: ID\n }\n\n type FolderResponse {\n data: Folder\n error: AcoError\n }\n\n type FoldersListResponse {\n data: [Folder]\n error: AcoError\n }\n\n extend type AcoQuery {\n getFolder(id: ID!): FolderResponse\n listFolders(\n where: FoldersListWhereInput!\n limit: Int\n after: String\n sort: AcoSort\n ): FoldersListResponse\n }\n\n extend type AcoMutation {\n createFolder(data: FolderCreateInput!): FolderResponse\n updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse\n deleteFolder(id: ID!): AcoBooleanResponse\n }\n `,\n resolvers: {\n AcoQuery: {\n getFolder: async (_, { id }, context) => {\n return resolve(() => {\n checkPermissions(context);\n return context.aco.folder.get(id);\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n checkPermissions(context);\n const [entries, meta] = await context.aco.folder.list(args);\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(() => {\n checkPermissions(context);\n return context.aco.folder.create(data);\n });\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(() => {\n checkPermissions(context);\n return context.aco.folder.update(id, data);\n });\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(() => {\n checkPermissions(context);\n return context.aco.folder.delete(id);\n });\n }\n }\n }\n});\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AACA;AAIO,MAAMA,YAAY,GAAG,IAAIC,wCAAmB,CAAa;EAC5DC,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,KAAK;EACDC,SAAS,EAAE;IACPC,QAAQ,EAAE;MACNC,SAAS,EAAE,OAAOC,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACrC,OAAO,IAAAC,gBAAO,EAAC,MAAM;UACjB,IAAAC,kCAAgB,EAACF,OAAO,CAAC;UACzB,OAAOA,OAAO,CAAC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G,CAACC,MAAM,CAACiB,MAAM,CAACtB,EAAE,CAAC;QACxC,CAAC,CAAC;MACN;IACJ;EACJ;AACJ,CAAC,CAAC;AAAC"}
|
package/folder/folder.types.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListMeta, ListSort, User } from "../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
|
-
export interface Folder
|
|
3
|
+
export interface Folder {
|
|
4
|
+
id: string;
|
|
5
|
+
entryId: string;
|
|
6
|
+
createdOn: string;
|
|
7
|
+
createdBy: User;
|
|
8
|
+
savedOn: string;
|
|
4
9
|
title: string;
|
|
5
10
|
slug: string;
|
|
6
11
|
type: string;
|
|
@@ -67,6 +72,7 @@ export interface AcoFolderCrud {
|
|
|
67
72
|
create(data: CreateFolderParams): Promise<Folder>;
|
|
68
73
|
update(id: string, data: UpdateFolderParams): Promise<Folder>;
|
|
69
74
|
delete(id: string): Promise<Boolean>;
|
|
75
|
+
getFolderWithAncestors(id: string): Promise<Folder[]>;
|
|
70
76
|
onFolderBeforeCreate: Topic<OnFolderBeforeCreateTopicParams>;
|
|
71
77
|
onFolderAfterCreate: Topic<OnFolderAfterCreateTopicParams>;
|
|
72
78
|
onFolderBeforeUpdate: Topic<OnFolderBeforeUpdateTopicParams>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["folder.types.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":[],"sources":["folder.types.ts"],"sourcesContent":["import { ListMeta, ListSort, User } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport interface Folder {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n title: string;\n slug: string;\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersWhere {\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersParams {\n where: ListFoldersWhere;\n sort?: ListSort;\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateFolderParams = Pick<Folder, \"title\" | \"slug\" | \"type\" | \"parentId\">;\n\nexport interface UpdateFolderParams {\n title?: string;\n slug?: string;\n parentId?: string;\n}\n\nexport interface DeleteFolderParams {\n id: string;\n}\n\nexport interface StorageOperationsGetFolderParams {\n id?: string;\n slug?: string;\n type?: string;\n parentId?: string | null;\n}\n\nexport type StorageOperationsListFoldersParams = ListFoldersParams;\n\nexport interface StorageOperationsCreateFolderParams {\n data: CreateFolderParams;\n}\n\nexport interface StorageOperationsUpdateFolderParams {\n id: string;\n data: UpdateFolderParams;\n}\n\nexport type StorageOperationsDeleteFolderParams = DeleteFolderParams;\n\nexport interface OnFolderBeforeCreateTopicParams {\n input: CreateFolderParams;\n}\n\nexport interface OnFolderAfterCreateTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderBeforeUpdateTopicParams {\n original: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderAfterUpdateTopicParams {\n original: Folder;\n folder: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderBeforeDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderAfterDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface AcoFolderCrud {\n get(id: string): Promise<Folder>;\n list(params: ListFoldersParams): Promise<[Folder[], ListMeta]>;\n create(data: CreateFolderParams): Promise<Folder>;\n update(id: string, data: UpdateFolderParams): Promise<Folder>;\n delete(id: string): Promise<Boolean>;\n getFolderWithAncestors(id: string): Promise<Folder[]>;\n onFolderBeforeCreate: Topic<OnFolderBeforeCreateTopicParams>;\n onFolderAfterCreate: Topic<OnFolderAfterCreateTopicParams>;\n onFolderBeforeUpdate: Topic<OnFolderBeforeUpdateTopicParams>;\n onFolderAfterUpdate: Topic<OnFolderAfterUpdateTopicParams>;\n onFolderBeforeDelete: Topic<OnFolderBeforeDeleteTopicParams>;\n onFolderAfterDelete: Topic<OnFolderAfterDeleteTopicParams>;\n}\n\nexport interface AcoFolderStorageOperations {\n getFolder(params: StorageOperationsGetFolderParams): Promise<Folder>;\n listFolders(params: StorageOperationsListFoldersParams): Promise<[Folder[], ListMeta]>;\n createFolder(params: StorageOperationsCreateFolderParams): Promise<Folder>;\n updateFolder(params: StorageOperationsUpdateFolderParams): Promise<Folder>;\n deleteFolder(params: StorageOperationsDeleteFolderParams): Promise<boolean>;\n}\n"],"mappings":""}
|
|
@@ -6,6 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.onFolderBeforeDeleteHook = void 0;
|
|
8
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
const throwDeleteError = folder => {
|
|
10
|
+
throw new _error.default("Error: delete all child folders and entries before proceeding.", "DELETE_FOLDER_WITH_CHILDREN", {
|
|
11
|
+
folder
|
|
12
|
+
});
|
|
13
|
+
};
|
|
9
14
|
const onFolderBeforeDeleteHook = ({
|
|
10
15
|
aco
|
|
11
16
|
}) => {
|
|
@@ -17,8 +22,9 @@ const onFolderBeforeDeleteHook = ({
|
|
|
17
22
|
id,
|
|
18
23
|
type
|
|
19
24
|
} = folder;
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
/**
|
|
26
|
+
* First we check for the child folders.
|
|
27
|
+
*/
|
|
22
28
|
const [children] = await aco.folder.list({
|
|
23
29
|
where: {
|
|
24
30
|
type,
|
|
@@ -26,21 +32,28 @@ const onFolderBeforeDeleteHook = ({
|
|
|
26
32
|
},
|
|
27
33
|
limit: 1
|
|
28
34
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
if (children.length > 0) {
|
|
36
|
+
throwDeleteError(folder);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Then for entries in each of the apps.
|
|
40
|
+
* Because we split the apps we must do it like this.
|
|
41
|
+
*/
|
|
42
|
+
const apps = aco.listApps();
|
|
43
|
+
for (const app of apps) {
|
|
44
|
+
const [records] = await app.search.list({
|
|
45
|
+
where: {
|
|
46
|
+
type,
|
|
47
|
+
location: {
|
|
48
|
+
folderId: id
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
limit: 1
|
|
43
52
|
});
|
|
53
|
+
if (records.length === 0) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
throwDeleteError(folder);
|
|
44
57
|
}
|
|
45
58
|
} catch (error) {
|
|
46
59
|
throw _error.default.from(error, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["throwDeleteError","folder","WebinyError","onFolderBeforeDeleteHook","aco","onFolderBeforeDelete","subscribe","id","type","children","list","where","parentId","limit","length","apps","listApps","app","records","search","location","folderId","error","from","message","code"],"sources":["onFolderBeforeDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoContext, Folder } from \"~/types\";\n\nconst throwDeleteError = (folder: Folder) => {\n throw new WebinyError(\n \"Error: delete all child folders and entries before proceeding.\",\n \"DELETE_FOLDER_WITH_CHILDREN\",\n {\n folder\n }\n );\n};\n\nexport const onFolderBeforeDeleteHook = ({ aco }: AcoContext) => {\n aco.folder.onFolderBeforeDelete.subscribe(async ({ folder }) => {\n try {\n const { id, type } = folder;\n /**\n * First we check for the child folders.\n */\n const [children] = await aco.folder.list({\n where: {\n type,\n parentId: id\n },\n limit: 1\n });\n if (children.length > 0) {\n throwDeleteError(folder);\n }\n /**\n * Then for entries in each of the apps.\n * Because we split the apps we must do it like this.\n */\n const apps = aco.listApps();\n for (const app of apps) {\n const [records] = await app.search.list({\n where: {\n type,\n location: {\n folderId: id\n }\n },\n limit: 1\n });\n if (records.length === 0) {\n continue;\n }\n throwDeleteError(folder);\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFolderBeforeD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EAAE;QAC1BE,OAAO,EAAE,iDAAiD;QAC1DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { SEARCH_RECORD_MODEL_ID } from "./record/record.model";
|
|
2
2
|
export { FOLDER_MODEL_ID } from "./folder/folder.model";
|
|
3
|
-
export
|
|
3
|
+
export * from "./apps";
|
|
4
|
+
export * from "./plugins";
|
|
5
|
+
export declare const createAco: () => (import("@webiny/api-headless-cms/types").CmsModelFieldToGraphQLPlugin<import("@webiny/api-headless-cms/types").CmsModelField> | import("@webiny/api").ContextPlugin<import("./types").AcoContext> | import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("./types").AcoContext>)[];
|
package/index.js
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
createAco: true,
|
|
8
|
+
SEARCH_RECORD_MODEL_ID: true,
|
|
9
|
+
FOLDER_MODEL_ID: true
|
|
10
|
+
};
|
|
6
11
|
Object.defineProperty(exports, "FOLDER_MODEL_ID", {
|
|
7
12
|
enumerable: true,
|
|
8
13
|
get: function () {
|
|
@@ -16,13 +21,36 @@ Object.defineProperty(exports, "SEARCH_RECORD_MODEL_ID", {
|
|
|
16
21
|
}
|
|
17
22
|
});
|
|
18
23
|
exports.createAco = void 0;
|
|
19
|
-
var _apiAdminSettings = require("@webiny/api-admin-settings");
|
|
20
24
|
var _createAcoContext = require("./createAcoContext");
|
|
21
|
-
var _createAcoFields = require("./createAcoFields");
|
|
22
25
|
var _createAcoGraphQL = require("./createAcoGraphQL");
|
|
26
|
+
var _fields = require("./fields");
|
|
23
27
|
var _record = require("./record/record.model");
|
|
24
28
|
var _folder = require("./folder/folder.model");
|
|
29
|
+
var _apps = require("./apps");
|
|
30
|
+
Object.keys(_apps).forEach(function (key) {
|
|
31
|
+
if (key === "default" || key === "__esModule") return;
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
33
|
+
if (key in exports && exports[key] === _apps[key]) return;
|
|
34
|
+
Object.defineProperty(exports, key, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return _apps[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
var _plugins = require("./plugins");
|
|
42
|
+
Object.keys(_plugins).forEach(function (key) {
|
|
43
|
+
if (key === "default" || key === "__esModule") return;
|
|
44
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
45
|
+
if (key in exports && exports[key] === _plugins[key]) return;
|
|
46
|
+
Object.defineProperty(exports, key, {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return _plugins[key];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
25
53
|
const createAco = () => {
|
|
26
|
-
return [...(0,
|
|
54
|
+
return [...(0, _fields.createFields)(), (0, _createAcoContext.createAcoContext)(), ...(0, _createAcoGraphQL.createAcoGraphQL)()];
|
|
27
55
|
};
|
|
28
56
|
exports.createAco = createAco;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAco","
|
|
1
|
+
{"version":3,"names":["createAco","createFields","createAcoContext","createAcoGraphQL"],"sources":["index.ts"],"sourcesContent":["import { createAcoContext } from \"~/createAcoContext\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL\";\nimport { createFields } from \"~/fields\";\n\nexport { SEARCH_RECORD_MODEL_ID } from \"./record/record.model\";\nexport { FOLDER_MODEL_ID } from \"./folder/folder.model\";\nexport * from \"./apps\";\nexport * from \"./plugins\";\n\nexport const createAco = () => {\n return [...createFields(), createAcoContext(), ...createAcoGraphQL()];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,CAAC,GAAG,IAAAC,oBAAY,GAAE,EAAE,IAAAC,kCAAgB,GAAE,EAAE,GAAG,IAAAC,kCAAgB,GAAE,CAAC;AACzE,CAAC;AAAC"}
|
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.c7dec08bb0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"directory": "dist"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@webiny/api
|
|
27
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
28
|
-
"@webiny/api-i18n": "0.0.0-unstable.
|
|
29
|
-
"@webiny/api-security": "0.0.0-unstable.
|
|
30
|
-
"@webiny/api-tenancy": "0.0.0-unstable.
|
|
31
|
-
"@webiny/error": "0.0.0-unstable.
|
|
32
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
33
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
34
|
-
"@webiny/pubsub": "0.0.0-unstable.
|
|
35
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
25
|
+
"@ungap/structured-clone": "1.2.0",
|
|
26
|
+
"@webiny/api": "0.0.0-unstable.c7dec08bb0",
|
|
27
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.c7dec08bb0",
|
|
28
|
+
"@webiny/api-i18n": "0.0.0-unstable.c7dec08bb0",
|
|
29
|
+
"@webiny/api-security": "0.0.0-unstable.c7dec08bb0",
|
|
30
|
+
"@webiny/api-tenancy": "0.0.0-unstable.c7dec08bb0",
|
|
31
|
+
"@webiny/error": "0.0.0-unstable.c7dec08bb0",
|
|
32
|
+
"@webiny/handler": "0.0.0-unstable.c7dec08bb0",
|
|
33
|
+
"@webiny/handler-graphql": "0.0.0-unstable.c7dec08bb0",
|
|
34
|
+
"@webiny/pubsub": "0.0.0-unstable.c7dec08bb0",
|
|
35
|
+
"@webiny/utils": "0.0.0-unstable.c7dec08bb0",
|
|
36
36
|
"lodash": "4.17.21"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -41,18 +41,20 @@
|
|
|
41
41
|
"@babel/preset-env": "7.20.2",
|
|
42
42
|
"@babel/preset-typescript": "7.18.6",
|
|
43
43
|
"@babel/runtime": "7.20.13",
|
|
44
|
-
"@
|
|
45
|
-
"@webiny/api-i18n-ddb": "0.0.0-unstable.
|
|
46
|
-
"@webiny/api-security-so-ddb": "0.0.0-unstable.
|
|
47
|
-
"@webiny/api-tenancy-so-ddb": "0.0.0-unstable.
|
|
48
|
-
"@webiny/api-wcp": "0.0.0-unstable.
|
|
49
|
-
"@webiny/cli": "0.0.0-unstable.
|
|
50
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
51
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
52
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
44
|
+
"@types/ungap__structured-clone": "0.3.0",
|
|
45
|
+
"@webiny/api-i18n-ddb": "0.0.0-unstable.c7dec08bb0",
|
|
46
|
+
"@webiny/api-security-so-ddb": "0.0.0-unstable.c7dec08bb0",
|
|
47
|
+
"@webiny/api-tenancy-so-ddb": "0.0.0-unstable.c7dec08bb0",
|
|
48
|
+
"@webiny/api-wcp": "0.0.0-unstable.c7dec08bb0",
|
|
49
|
+
"@webiny/cli": "0.0.0-unstable.c7dec08bb0",
|
|
50
|
+
"@webiny/handler-aws": "0.0.0-unstable.c7dec08bb0",
|
|
51
|
+
"@webiny/plugins": "0.0.0-unstable.c7dec08bb0",
|
|
52
|
+
"@webiny/project-utils": "0.0.0-unstable.c7dec08bb0",
|
|
53
|
+
"graphql": "16.6.0",
|
|
54
|
+
"prettier": "2.8.8",
|
|
53
55
|
"rimraf": "3.0.2",
|
|
54
56
|
"ttypescript": "1.5.15",
|
|
55
57
|
"typescript": "4.7.4"
|
|
56
58
|
},
|
|
57
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "c7dec08bb095467cca6a61381bd399d66b7bb147"
|
|
58
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":["createModifier","app","context","addField","field","removeField","id","modifyField","cb","AcoAppModifierPlugin","Plugin","constructor","params","create","canUse","name","modify","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;AA6CA,MAAMA,cAAc,GAAG,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,EAAE,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,WAAW,CAACC,MAAqC,EAAE;IACvD,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,OAAcC,MAAM,CAAiCD,MAAqC,EAAE;IACxF,OAAO,IAAIH,oBAAoB,CAAIG,MAAM,CAAC;EAC9C;EAEOE,MAAM,CAACb,GAAY,EAAW;IACjC,OAAOA,GAAG,CAACc,IAAI,KAAK,IAAI,CAACH,MAAM,CAACG,IAAI;EACxC;EAEA,MAAaC,MAAM,CAACJ,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,CAAC,CACL;EACL;AACJ;AAAC;AAAA,8BA3BYO,oBAAoB,UACkB,kBAAkB;AA+B9D,MAAMQ,oBAAoB,GAAG,CAChCF,IAAY,EACZP,EAAmC,KAClC;EACD,OAAOC,oBAAoB,CAACI,MAAM,CAAI;IAClCE,IAAI;IACJP;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -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":["AcoAppRegisterPlugin","Plugin","constructor","app","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;AAGO,MAAMA,oBAAoB,SAASC,eAAM,CAAC;EAItCC,WAAW,CAACC,GAA0B,EAAE;IAC3C,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,GAAG,GAAGA,GAAG;EAClB;AACJ;AAAC;AAAA,8BARYH,oBAAoB,UACC,qBAAqB;AAShD,MAAMI,cAAc,GAAID,GAA0B,IAAK;EAC1D,OAAO,IAAIH,oBAAoB,CAACG,GAAG,CAAC;AACxC,CAAC;AAAC"}
|
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":[],"sources":["index.ts"],"sourcesContent":["export * from \"./AcoAppRegisterPlugin\";\nexport * from \"./AcoAppModifierPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;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 {};
|