@webiny/api-aco 0.0.0-unstable.cc58a6566b → 0.0.0-unstable.d7f521b032

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.
@@ -0,0 +1,2 @@
1
+ import { FoldersConfig, IFolders } from "../types";
2
+ export declare const createFoldersContext: ({ getTenantId, getLocaleCode, getIdentity, storageOperations }: FoldersConfig) => Promise<IFolders>;
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createFoldersContext = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _mdbid = _interopRequireDefault(require("mdbid"));
13
+
14
+ var _error = _interopRequireDefault(require("@webiny/error"));
15
+
16
+ var _handlerGraphql = require("@webiny/handler-graphql");
17
+
18
+ var _pubsub = require("@webiny/pubsub");
19
+
20
+ var _joi = _interopRequireDefault(require("joi"));
21
+
22
+ /**
23
+ * Package mdbid does not have types.
24
+ */
25
+ // @ts-ignore
26
+ const requiredString = _joi.default.string().required();
27
+
28
+ const createSchema = _joi.default.object({
29
+ name: requiredString.min(3),
30
+ slug: requiredString.min(3),
31
+ type: requiredString,
32
+ tenant: requiredString,
33
+ locale: requiredString
34
+ });
35
+
36
+ const updateSchema = _joi.default.object({
37
+ name: requiredString.min(3),
38
+ slug: requiredString.min(3)
39
+ });
40
+
41
+ const createFoldersContext = async ({
42
+ getTenantId,
43
+ getLocaleCode,
44
+ getIdentity,
45
+ storageOperations
46
+ }) => {
47
+ // create
48
+ const onFolderBeforeCreate = (0, _pubsub.createTopic)("folders.onFolderBeforeCreate");
49
+ const onFolderAfterCreate = (0, _pubsub.createTopic)("folders.onFolderAfterCreate"); // update
50
+
51
+ const onFolderBeforeUpdate = (0, _pubsub.createTopic)("folders.onFolderBeforeUpdate");
52
+ const onFolderAfterUpdate = (0, _pubsub.createTopic)("folders.onFolderAfterUpdate"); // delete
53
+
54
+ const onFolderBeforeDelete = (0, _pubsub.createTopic)("folders.onFolderBeforeDelete");
55
+ const onFolderAfterDelete = (0, _pubsub.createTopic)("folders.onFolderAfterDelete");
56
+ return {
57
+ onFolderBeforeCreate,
58
+ onFolderAfterCreate,
59
+ onFolderBeforeUpdate,
60
+ onFolderAfterUpdate,
61
+ onFolderBeforeDelete,
62
+ onFolderAfterDelete,
63
+
64
+ async getFolder({
65
+ id
66
+ }) {
67
+ const tenant = getTenantId();
68
+ const locale = getLocaleCode();
69
+ let folder;
70
+
71
+ try {
72
+ folder = await storageOperations.getFolder({
73
+ tenant,
74
+ locale,
75
+ id
76
+ });
77
+ } catch (error) {
78
+ throw _error.default.from(error, {
79
+ message: "Could not get folder.",
80
+ code: "GET_FOLDER_ERROR",
81
+ data: {
82
+ id
83
+ }
84
+ });
85
+ }
86
+
87
+ if (!folder) {
88
+ throw new _handlerGraphql.NotFoundError(`Unable to find folder with id: ${id}`);
89
+ }
90
+
91
+ return folder;
92
+ },
93
+
94
+ async listFolders({
95
+ where
96
+ }) {
97
+ const tenant = getTenantId();
98
+ const locale = getLocaleCode();
99
+
100
+ try {
101
+ return await storageOperations.listFolders({
102
+ where: (0, _objectSpread2.default)({
103
+ tenant,
104
+ locale
105
+ }, where),
106
+ sort: ["createdOn_ASC"]
107
+ });
108
+ } catch (error) {
109
+ throw _error.default.from(error, {
110
+ message: "Could not list folders.",
111
+ code: "LIST_FOLDERS_ERROR",
112
+ data: (0, _objectSpread2.default)({}, where)
113
+ });
114
+ }
115
+ },
116
+
117
+ async createFolder(input) {
118
+ await createSchema.validate(input);
119
+ const tenant = getTenantId();
120
+ const locale = getLocaleCode();
121
+ const {
122
+ type,
123
+ slug,
124
+ parentId
125
+ } = input;
126
+ const existing = await storageOperations.getFolder({
127
+ tenant,
128
+ locale,
129
+ type,
130
+ slug,
131
+ parentId
132
+ });
133
+
134
+ if (existing) {
135
+ throw new _error.default(`Folder with slug "${slug}" already exists at this level.`, "FOLDER_EXISTS");
136
+ }
137
+
138
+ const identity = getIdentity();
139
+ const folder = (0, _objectSpread2.default)((0, _objectSpread2.default)({
140
+ id: (0, _mdbid.default)(),
141
+ tenant,
142
+ locale
143
+ }, input), {}, {
144
+ webinyVersion: process.env.WEBINY_VERSION,
145
+ createdOn: new Date().toISOString(),
146
+ createdBy: {
147
+ id: identity.id,
148
+ displayName: identity.displayName,
149
+ type: identity.type
150
+ }
151
+ });
152
+
153
+ try {
154
+ await onFolderBeforeCreate.publish({
155
+ folder
156
+ });
157
+ const result = await storageOperations.createFolder({
158
+ folder
159
+ });
160
+ await onFolderAfterCreate.publish({
161
+ folder: result
162
+ });
163
+ return result;
164
+ } catch (error) {
165
+ throw _error.default.from(error, {
166
+ message: "Could not create folder.",
167
+ code: "CREATE_FOLDER_ERROR",
168
+ data: (0, _objectSpread2.default)({}, input)
169
+ });
170
+ }
171
+ },
172
+
173
+ async updateFolder(id, input) {
174
+ await updateSchema.validate(input);
175
+ const tenant = getTenantId();
176
+ const locale = getLocaleCode();
177
+ const {
178
+ slug,
179
+ parentId
180
+ } = input;
181
+ const original = await storageOperations.getFolder({
182
+ tenant,
183
+ locale,
184
+ id
185
+ });
186
+
187
+ if (!original) {
188
+ throw new _handlerGraphql.NotFoundError(`Folder "${id}" was not found!`);
189
+ }
190
+
191
+ const existing = await storageOperations.getFolder({
192
+ tenant,
193
+ locale,
194
+ type: original.type,
195
+ slug: slug || original.slug,
196
+ parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`
197
+
198
+ }); // Check if another folder exists already inside the target
199
+
200
+ if (existing && (existing === null || existing === void 0 ? void 0 : existing.id) !== id) {
201
+ throw new _error.default(`Folder with slug "${slug}" already exists at this level.`, "FOLDER_EXISTS");
202
+ }
203
+
204
+ const folder = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), input);
205
+
206
+ try {
207
+ await onFolderBeforeUpdate.publish({
208
+ folder,
209
+ original
210
+ });
211
+ const result = await storageOperations.updateFolder({
212
+ original,
213
+ folder
214
+ });
215
+ await onFolderAfterUpdate.publish({
216
+ folder: result,
217
+ original
218
+ });
219
+ return result;
220
+ } catch (error) {
221
+ throw new _error.default(error.message || "Could not update folder.", error.code || "UPDATE_FOLDER_ERROR", {
222
+ folder
223
+ });
224
+ }
225
+ },
226
+
227
+ async deleteFolder(id) {
228
+ const tenant = getTenantId();
229
+ const locale = getLocaleCode();
230
+ const folder = await storageOperations.getFolder({
231
+ tenant,
232
+ locale,
233
+ id
234
+ });
235
+
236
+ if (!folder) {
237
+ throw new _handlerGraphql.NotFoundError(`Folder "${id}" was not found!`);
238
+ }
239
+
240
+ try {
241
+ await onFolderBeforeDelete.publish({
242
+ folder
243
+ });
244
+ const result = storageOperations.deleteFolder({
245
+ folder
246
+ });
247
+ await onFolderAfterDelete.publish({
248
+ folder
249
+ });
250
+ return result;
251
+ } catch (error) {
252
+ throw new _error.default(error.message || "Could not delete folder.", error.code || "DELETE_FOLDER_ERROR", {
253
+ folder
254
+ });
255
+ }
256
+ }
257
+
258
+ };
259
+ };
260
+
261
+ exports.createFoldersContext = createFoldersContext;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["requiredString","joi","string","required","createSchema","object","name","min","slug","type","tenant","locale","updateSchema","createFoldersContext","getTenantId","getLocaleCode","getIdentity","storageOperations","onFolderBeforeCreate","createTopic","onFolderAfterCreate","onFolderBeforeUpdate","onFolderAfterUpdate","onFolderBeforeDelete","onFolderAfterDelete","getFolder","id","folder","error","WebinyError","from","message","code","data","NotFoundError","listFolders","where","sort","createFolder","input","validate","parentId","existing","identity","mdbid","webinyVersion","process","env","WEBINY_VERSION","createdOn","Date","toISOString","createdBy","displayName","publish","result","updateFolder","original","undefined","deleteFolder"],"sources":["folders.ts"],"sourcesContent":["/**\n * Package mdbid does not have types.\n */\n// @ts-ignore\nimport mdbid from \"mdbid\";\nimport WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport joi from \"joi\";\n\nimport {\n Folder,\n FolderInput,\n FoldersConfig,\n GetFolderParams,\n IFolders,\n ListFoldersParams,\n OnFolderAfterCreateTopicParams,\n OnFolderAfterDeleteTopicParams,\n OnFolderAfterUpdateTopicParams,\n OnFolderBeforeCreateTopicParams,\n OnFolderBeforeDeleteTopicParams,\n OnFolderBeforeUpdateTopicParams\n} from \"~/types\";\n\nconst requiredString = joi.string().required();\n\nconst createSchema = joi.object({\n name: requiredString.min(3),\n slug: requiredString.min(3),\n type: requiredString,\n tenant: requiredString,\n locale: requiredString\n});\n\nconst updateSchema = joi.object({\n name: requiredString.min(3),\n slug: requiredString.min(3)\n});\n\nexport const createFoldersContext = async ({\n getTenantId,\n getLocaleCode,\n getIdentity,\n storageOperations\n}: FoldersConfig): Promise<IFolders> => {\n // create\n const onFolderBeforeCreate = createTopic<OnFolderBeforeCreateTopicParams>(\n \"folders.onFolderBeforeCreate\"\n );\n const onFolderAfterCreate = createTopic<OnFolderAfterCreateTopicParams>(\n \"folders.onFolderAfterCreate\"\n );\n // update\n const onFolderBeforeUpdate = createTopic<OnFolderBeforeUpdateTopicParams>(\n \"folders.onFolderBeforeUpdate\"\n );\n const onFolderAfterUpdate = createTopic<OnFolderAfterUpdateTopicParams>(\n \"folders.onFolderAfterUpdate\"\n );\n // delete\n const onFolderBeforeDelete = createTopic<OnFolderBeforeDeleteTopicParams>(\n \"folders.onFolderBeforeDelete\"\n );\n const onFolderAfterDelete = createTopic<OnFolderAfterDeleteTopicParams>(\n \"folders.onFolderAfterDelete\"\n );\n\n return {\n onFolderBeforeCreate,\n onFolderAfterCreate,\n onFolderBeforeUpdate,\n onFolderAfterUpdate,\n onFolderBeforeDelete,\n onFolderAfterDelete,\n async getFolder({ id }: GetFolderParams): Promise<Folder> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n let folder: Folder | undefined;\n\n try {\n folder = await storageOperations.getFolder({ tenant, locale, id });\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Could not get folder.\",\n code: \"GET_FOLDER_ERROR\",\n data: { id }\n });\n }\n if (!folder) {\n throw new NotFoundError(`Unable to find folder with id: ${id}`);\n }\n return folder;\n },\n\n async listFolders({ where }: ListFoldersParams): Promise<Folder[]> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n try {\n return await storageOperations.listFolders({\n where: { tenant, locale, ...where },\n sort: [\"createdOn_ASC\"]\n });\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Could not list folders.\",\n code: \"LIST_FOLDERS_ERROR\",\n data: { ...where }\n });\n }\n },\n\n async createFolder(input: FolderInput): Promise<Folder> {\n await createSchema.validate(input);\n\n const tenant = getTenantId();\n const locale = getLocaleCode();\n const { type, slug, parentId } = input;\n\n const existing = await storageOperations.getFolder({\n tenant,\n locale,\n type,\n slug,\n parentId\n });\n\n if (existing) {\n throw new WebinyError(\n `Folder with slug \"${slug}\" already exists at this level.`,\n \"FOLDER_EXISTS\"\n );\n }\n\n const identity = getIdentity();\n\n const folder: Folder = {\n id: mdbid(),\n tenant,\n locale,\n ...input,\n webinyVersion: process.env.WEBINY_VERSION as string,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n }\n };\n\n try {\n await onFolderBeforeCreate.publish({\n folder\n });\n const result = await storageOperations.createFolder({ folder });\n await onFolderAfterCreate.publish({\n folder: result\n });\n return result;\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Could not create folder.\",\n code: \"CREATE_FOLDER_ERROR\",\n data: { ...input }\n });\n }\n },\n\n async updateFolder(id: string, input: Record<string, any>): Promise<Folder> {\n await updateSchema.validate(input);\n\n const tenant = getTenantId();\n const locale = getLocaleCode();\n const { slug, parentId } = input;\n\n const original = await storageOperations.getFolder({ tenant, locale, id });\n\n if (!original) {\n throw new NotFoundError(`Folder \"${id}\" was not found!`);\n }\n\n const existing = await storageOperations.getFolder({\n tenant,\n locale,\n type: original.type,\n slug: slug || original.slug,\n parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`\n });\n\n // Check if another folder exists already inside the target\n if (existing && existing?.id !== id) {\n throw new WebinyError(\n `Folder with slug \"${slug}\" already exists at this level.`,\n \"FOLDER_EXISTS\"\n );\n }\n\n const folder: Folder = {\n ...original,\n ...input\n };\n try {\n await onFolderBeforeUpdate.publish({\n folder,\n original\n });\n const result = await storageOperations.updateFolder({ original, folder });\n await onFolderAfterUpdate.publish({\n folder: result,\n original\n });\n return result;\n } catch (error) {\n throw new WebinyError(\n error.message || \"Could not update folder.\",\n error.code || \"UPDATE_FOLDER_ERROR\",\n {\n folder\n }\n );\n }\n },\n\n async deleteFolder(id: string): Promise<void> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const folder = await storageOperations.getFolder({ tenant, locale, id });\n\n if (!folder) {\n throw new NotFoundError(`Folder \"${id}\" was not found!`);\n }\n\n try {\n await onFolderBeforeDelete.publish({\n folder\n });\n const result = storageOperations.deleteFolder({ folder });\n await onFolderAfterDelete.publish({\n folder\n });\n return result;\n } catch (error) {\n throw new WebinyError(\n error.message || \"Could not delete folder.\",\n error.code || \"DELETE_FOLDER_ERROR\",\n {\n folder\n }\n );\n }\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AACA;;AARA;AACA;AACA;AACA;AAsBA,MAAMA,cAAc,GAAGC,YAAA,CAAIC,MAAJ,GAAaC,QAAb,EAAvB;;AAEA,MAAMC,YAAY,GAAGH,YAAA,CAAII,MAAJ,CAAW;EAC5BC,IAAI,EAAEN,cAAc,CAACO,GAAf,CAAmB,CAAnB,CADsB;EAE5BC,IAAI,EAAER,cAAc,CAACO,GAAf,CAAmB,CAAnB,CAFsB;EAG5BE,IAAI,EAAET,cAHsB;EAI5BU,MAAM,EAAEV,cAJoB;EAK5BW,MAAM,EAAEX;AALoB,CAAX,CAArB;;AAQA,MAAM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E;;IA6JH,MAAMgC,YAAN,CAAmBjC,EAAnB,EAA8C;MAC1C,MAAMhB,MAAM,GAAGI,WAAW,EAA1B;MACA,MAAMH,MAAM,GAAGI,aAAa,EAA5B;MAEA,MAAMY,MAAM,GAAG,MAAMV,iBAAiB,CAACQ,SAAlB,CAA4B;QAAEf,MAAF;QAAUC,MAAV;QAAkBe;MAAlB,CAA5B,CAArB;;MAEA,IAAI,CAACC,MAAL,EAAa;QACT,MAAM,IAAIO,6BAAJ,CAAmB,WAAUR,EAAG,kBAAhC,CAAN;MACH;;MAED,IAAI;QACA,MAAMH,oBAAoB,CAAC+B,OAArB,CAA6B;UAC/B3B;QAD+B,CAA7B,CAAN;QAGA,MAAM4B,MAAM,GAAGtC,iBAAiB,CAAC0C,YAAlB,CAA+B;UAAEhC;QAAF,CAA/B,CAAf;QACA,MAAMH,mBAAmB,CAAC8B,OAApB,CAA4B;UAC9B3B;QAD8B,CAA5B,CAAN;QAGA,OAAO4B,MAAP;MACH,CATD,CASE,OAAO3B,KAAP,EAAc;QACZ,MAAM,IAAIC,cAAJ,CACFD,KAAK,CAACG,OAAN,IAAiB,0BADf,EAEFH,KAAK,CAACI,IAAN,IAAc,qBAFZ,EAGF;UACIL;QADJ,CAHE,CAAN;MAOH;IACJ;;EAzLE,CAAP;AA2LH,CAvNM"}
@@ -0,0 +1,2 @@
1
+ import { Folders, FoldersConfig } from "../types";
2
+ export declare const createContext: (config: FoldersConfig) => Promise<Folders>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createContext = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _folders = require("./folders");
13
+
14
+ var _links = require("./links");
15
+
16
+ const createContext = async config => {
17
+ const linksContext = await (0, _links.createLinksContext)(config);
18
+ const folderContext = await (0, _folders.createFoldersContext)(config);
19
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, linksContext), folderContext);
20
+ };
21
+
22
+ exports.createContext = createContext;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","config","linksContext","createLinksContext","folderContext","createFoldersContext"],"sources":["index.ts"],"sourcesContent":["import { createFoldersContext } from \"./folders\";\nimport { createLinksContext } from \"./links\";\n\nimport { Folders, FoldersConfig } from \"~/types\";\n\nexport const createContext = async (config: FoldersConfig): Promise<Folders> => {\n const linksContext = await createLinksContext(config);\n const folderContext = await createFoldersContext(config);\n\n return {\n ...linksContext,\n ...folderContext\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAIO,MAAMA,aAAa,GAAG,MAAOC,MAAP,IAAmD;EAC5E,MAAMC,YAAY,GAAG,MAAM,IAAAC,yBAAA,EAAmBF,MAAnB,CAA3B;EACA,MAAMG,aAAa,GAAG,MAAM,IAAAC,6BAAA,EAAqBJ,MAArB,CAA5B;EAEA,mEACOC,YADP,GAEOE,aAFP;AAIH,CARM"}
@@ -0,0 +1,2 @@
1
+ import { FoldersConfig, ILinks } from "../types";
2
+ export declare const createLinksContext: ({ getTenantId, getLocaleCode, getIdentity, storageOperations }: FoldersConfig) => Promise<ILinks>;
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createLinksContext = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _mdbid = _interopRequireDefault(require("mdbid"));
13
+
14
+ var _error = _interopRequireDefault(require("@webiny/error"));
15
+
16
+ var _handlerGraphql = require("@webiny/handler-graphql");
17
+
18
+ var _pubsub = require("@webiny/pubsub");
19
+
20
+ var _joi = _interopRequireDefault(require("joi"));
21
+
22
+ /**
23
+ * Package mdbid does not have types.
24
+ */
25
+ // @ts-ignore
26
+ const requiredString = _joi.default.string().required();
27
+
28
+ const createSchema = _joi.default.object({
29
+ id: requiredString,
30
+ folderId: requiredString,
31
+ tenant: requiredString,
32
+ locale: requiredString
33
+ });
34
+
35
+ const updateSchema = _joi.default.object({
36
+ folderId: requiredString
37
+ });
38
+
39
+ const createLinksContext = async ({
40
+ getTenantId,
41
+ getLocaleCode,
42
+ getIdentity,
43
+ storageOperations
44
+ }) => {
45
+ // create
46
+ const onLinkBeforeCreate = (0, _pubsub.createTopic)("folders.onLinkBeforeCreate");
47
+ const onLinkAfterCreate = (0, _pubsub.createTopic)("folders.onLinkAfterCreate"); // update
48
+
49
+ const onLinkBeforeUpdate = (0, _pubsub.createTopic)("folders.onLinkBeforeUpdate");
50
+ const onLinkAfterUpdate = (0, _pubsub.createTopic)("folders.onLinkAfterUpdate"); // delete
51
+
52
+ const onLinkBeforeDelete = (0, _pubsub.createTopic)("folders.onLinkBeforeDelete");
53
+ const onLinkAfterDelete = (0, _pubsub.createTopic)("folders.onLinkAfterDelete"); // delete batch
54
+
55
+ const onLinkBeforeDeleteBatch = (0, _pubsub.createTopic)("folders.onLinkBeforeDeleteBatch");
56
+ const onLinkAfterDeleteBatch = (0, _pubsub.createTopic)("folders.onLinkAfterDeleteBatch");
57
+ return {
58
+ onLinkBeforeCreate,
59
+ onLinkAfterCreate,
60
+ onLinkBeforeUpdate,
61
+ onLinkAfterUpdate,
62
+ onLinkBeforeDelete,
63
+ onLinkAfterDelete,
64
+ onLinkBeforeDeleteBatch,
65
+ onLinkAfterDeleteBatch,
66
+
67
+ async getLink(id) {
68
+ const tenant = getTenantId();
69
+ const locale = getLocaleCode();
70
+ let link;
71
+
72
+ try {
73
+ link = await storageOperations.getLink({
74
+ tenant,
75
+ locale,
76
+ id
77
+ });
78
+ } catch (error) {
79
+ throw _error.default.from(error, {
80
+ message: "Could not get link.",
81
+ code: "GET_LINK_ERROR",
82
+ data: {
83
+ id
84
+ }
85
+ });
86
+ }
87
+
88
+ if (!link) {
89
+ throw new _handlerGraphql.NotFoundError(`Unable to find link with id: ${id}`);
90
+ }
91
+
92
+ return link;
93
+ },
94
+
95
+ async listLinks({
96
+ where,
97
+ limit,
98
+ after
99
+ }) {
100
+ const tenant = getTenantId();
101
+ const locale = getLocaleCode();
102
+
103
+ try {
104
+ return await storageOperations.listLinks({
105
+ where: (0, _objectSpread2.default)({
106
+ tenant,
107
+ locale
108
+ }, where),
109
+ sort: ["createdOn_ASC"],
110
+ limit,
111
+ after
112
+ });
113
+ } catch (error) {
114
+ throw _error.default.from(error, {
115
+ message: "Could not list links.",
116
+ code: "LIST_LINKS_ERROR",
117
+ data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
118
+ limit,
119
+ after
120
+ })
121
+ });
122
+ }
123
+ },
124
+
125
+ async createLink(input) {
126
+ await createSchema.validate(input);
127
+ const tenant = getTenantId();
128
+ const locale = getLocaleCode();
129
+ const existing = await storageOperations.getLink({
130
+ tenant,
131
+ locale,
132
+ folderId: input.folderId,
133
+ id: input.id
134
+ });
135
+
136
+ if (existing) {
137
+ throw new _error.default(`Link with id "${input.id}" already exists.`, "LINK_EXISTS");
138
+ }
139
+
140
+ const identity = getIdentity();
141
+ const link = (0, _objectSpread2.default)((0, _objectSpread2.default)({
142
+ linkId: (0, _mdbid.default)(),
143
+ tenant,
144
+ locale
145
+ }, input), {}, {
146
+ webinyVersion: process.env.WEBINY_VERSION,
147
+ createdOn: new Date().toISOString(),
148
+ createdBy: {
149
+ id: identity.id,
150
+ displayName: identity.displayName,
151
+ type: identity.type
152
+ }
153
+ });
154
+
155
+ try {
156
+ await onLinkBeforeCreate.publish({
157
+ link
158
+ });
159
+ const result = await storageOperations.createLink({
160
+ link
161
+ });
162
+ await onLinkAfterCreate.publish({
163
+ link: result
164
+ });
165
+ return result;
166
+ } catch (error) {
167
+ throw _error.default.from(error, {
168
+ message: "Could not create link.",
169
+ code: "CREATE_LINK_ERROR",
170
+ data: (0, _objectSpread2.default)({}, input)
171
+ });
172
+ }
173
+ },
174
+
175
+ async updateLink(id, input) {
176
+ const tenant = getTenantId();
177
+ const locale = getLocaleCode();
178
+ const original = await storageOperations.getLink({
179
+ tenant,
180
+ locale,
181
+ id
182
+ });
183
+
184
+ if (!original) {
185
+ throw new _handlerGraphql.NotFoundError(`Link "${id}" was not found!`);
186
+ }
187
+
188
+ await updateSchema.validate(input);
189
+ const link = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), input);
190
+
191
+ try {
192
+ await onLinkBeforeUpdate.publish({
193
+ link,
194
+ original
195
+ });
196
+ const result = await storageOperations.updateLink({
197
+ original,
198
+ link
199
+ });
200
+ await onLinkAfterUpdate.publish({
201
+ link: result,
202
+ original
203
+ });
204
+ return result;
205
+ } catch (error) {
206
+ throw new _error.default(error.message || "Could not update link.", error.code || "UPDATE_LINK_ERROR", {
207
+ link
208
+ });
209
+ }
210
+ },
211
+
212
+ async deleteLink(id) {
213
+ const tenant = getTenantId();
214
+ const locale = getLocaleCode();
215
+ const link = await storageOperations.getLink({
216
+ tenant,
217
+ locale,
218
+ id
219
+ });
220
+
221
+ if (!link) {
222
+ throw new _handlerGraphql.NotFoundError(`Link "${id}" was not found!`);
223
+ }
224
+
225
+ try {
226
+ await onLinkBeforeDelete.publish({
227
+ link
228
+ });
229
+ const result = await storageOperations.deleteLink({
230
+ link
231
+ });
232
+ await onLinkAfterDelete.publish({
233
+ link
234
+ });
235
+ return result;
236
+ } catch (error) {
237
+ throw new _error.default(error.message || "Could not delete link.", error.code || "DELETE_LINK_ERROR", {
238
+ link
239
+ });
240
+ }
241
+ },
242
+
243
+ async deleteLinks(folderIds) {
244
+ const tenant = getTenantId();
245
+ const locale = getLocaleCode();
246
+
247
+ try {
248
+ await onLinkBeforeDeleteBatch.publish({
249
+ folderIds
250
+ });
251
+ const result = await storageOperations.deleteLinks({
252
+ tenant,
253
+ locale,
254
+ folderIds
255
+ });
256
+ await onLinkAfterDeleteBatch.publish({
257
+ folderIds
258
+ });
259
+ return result;
260
+ } catch (error) {
261
+ throw new _error.default(error.message || "Could not batch delete links.", error.code || "DELETE_LINKS_ERROR", {
262
+ folderIds
263
+ });
264
+ }
265
+ }
266
+
267
+ };
268
+ };
269
+
270
+ exports.createLinksContext = createLinksContext;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["requiredString","joi","string","required","createSchema","object","id","folderId","tenant","locale","updateSchema","createLinksContext","getTenantId","getLocaleCode","getIdentity","storageOperations","onLinkBeforeCreate","createTopic","onLinkAfterCreate","onLinkBeforeUpdate","onLinkAfterUpdate","onLinkBeforeDelete","onLinkAfterDelete","onLinkBeforeDeleteBatch","onLinkAfterDeleteBatch","getLink","link","error","WebinyError","from","message","code","data","NotFoundError","listLinks","where","limit","after","sort","createLink","input","validate","existing","identity","linkId","mdbid","webinyVersion","process","env","WEBINY_VERSION","createdOn","Date","toISOString","createdBy","displayName","type","publish","result","updateLink","original","deleteLink","deleteLinks","folderIds"],"sources":["links.ts"],"sourcesContent":["/**\n * Package mdbid does not have types.\n */\n// @ts-ignore\nimport mdbid from \"mdbid\";\nimport WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport joi from \"joi\";\n\nimport {\n FoldersConfig,\n ILinks,\n Link,\n LinkInput,\n ListLinksParams,\n ListLinksResponse,\n OnLinkAfterCreateTopicParams,\n OnLinkAfterDeleteBatchTopicParams,\n OnLinkAfterDeleteTopicParams,\n OnLinkAfterUpdateTopicParams,\n OnLinkBeforeCreateTopicParams,\n OnLinkBeforeDeleteBatchTopicParams,\n OnLinkBeforeDeleteTopicParams,\n OnLinkBeforeUpdateTopicParams\n} from \"~/types\";\n\nconst requiredString = joi.string().required();\n\nconst createSchema = joi.object({\n id: requiredString,\n folderId: requiredString,\n tenant: requiredString,\n locale: requiredString\n});\n\nconst updateSchema = joi.object({\n folderId: requiredString\n});\n\nexport const createLinksContext = async ({\n getTenantId,\n getLocaleCode,\n getIdentity,\n storageOperations\n}: FoldersConfig): Promise<ILinks> => {\n // create\n const onLinkBeforeCreate = createTopic<OnLinkBeforeCreateTopicParams>(\n \"folders.onLinkBeforeCreate\"\n );\n const onLinkAfterCreate = createTopic<OnLinkAfterCreateTopicParams>(\n \"folders.onLinkAfterCreate\"\n );\n // update\n const onLinkBeforeUpdate = createTopic<OnLinkBeforeUpdateTopicParams>(\n \"folders.onLinkBeforeUpdate\"\n );\n const onLinkAfterUpdate = createTopic<OnLinkAfterUpdateTopicParams>(\n \"folders.onLinkAfterUpdate\"\n );\n // delete\n const onLinkBeforeDelete = createTopic<OnLinkBeforeDeleteTopicParams>(\n \"folders.onLinkBeforeDelete\"\n );\n const onLinkAfterDelete = createTopic<OnLinkAfterDeleteTopicParams>(\n \"folders.onLinkAfterDelete\"\n );\n // delete batch\n const onLinkBeforeDeleteBatch = createTopic<OnLinkBeforeDeleteBatchTopicParams>(\n \"folders.onLinkBeforeDeleteBatch\"\n );\n const onLinkAfterDeleteBatch = createTopic<OnLinkAfterDeleteBatchTopicParams>(\n \"folders.onLinkAfterDeleteBatch\"\n );\n\n return {\n onLinkBeforeCreate,\n onLinkAfterCreate,\n onLinkBeforeUpdate,\n onLinkAfterUpdate,\n onLinkBeforeDelete,\n onLinkAfterDelete,\n onLinkBeforeDeleteBatch,\n onLinkAfterDeleteBatch,\n async getLink(id: string): Promise<Link> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n let link: Link | undefined;\n try {\n link = await storageOperations.getLink({ tenant, locale, id });\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Could not get link.\",\n code: \"GET_LINK_ERROR\",\n data: { id }\n });\n }\n if (!link) {\n throw new NotFoundError(`Unable to find link with id: ${id}`);\n }\n return link;\n },\n\n async listLinks({ where, limit, after }: ListLinksParams): Promise<ListLinksResponse> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n try {\n return await storageOperations.listLinks({\n where: { tenant, locale, ...where },\n sort: [\"createdOn_ASC\"],\n limit,\n after\n });\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Could not list links.\",\n code: \"LIST_LINKS_ERROR\",\n data: { ...where, limit, after }\n });\n }\n },\n\n async createLink(input: LinkInput): Promise<Link> {\n await createSchema.validate(input);\n\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const existing = await storageOperations.getLink({\n tenant,\n locale,\n folderId: input.folderId,\n id: input.id\n });\n\n if (existing) {\n throw new WebinyError(`Link with id \"${input.id}\" already exists.`, \"LINK_EXISTS\");\n }\n\n const identity = getIdentity();\n\n const link: Link = {\n linkId: mdbid(),\n tenant,\n locale,\n ...input,\n webinyVersion: process.env.WEBINY_VERSION as string,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n }\n };\n\n try {\n await onLinkBeforeCreate.publish({\n link\n });\n const result = await storageOperations.createLink({ link });\n await onLinkAfterCreate.publish({\n link: result\n });\n return result;\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Could not create link.\",\n code: \"CREATE_LINK_ERROR\",\n data: { ...input }\n });\n }\n },\n\n async updateLink(id: string, input: Record<string, any>): Promise<Link> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const original = await storageOperations.getLink({ tenant, locale, id });\n\n if (!original) {\n throw new NotFoundError(`Link \"${id}\" was not found!`);\n }\n\n await updateSchema.validate(input);\n\n const link: Link = {\n ...original,\n ...input\n };\n\n try {\n await onLinkBeforeUpdate.publish({\n link,\n original\n });\n const result = await storageOperations.updateLink({ original, link });\n await onLinkAfterUpdate.publish({\n link: result,\n original\n });\n return result;\n } catch (error) {\n throw new WebinyError(\n error.message || \"Could not update link.\",\n error.code || \"UPDATE_LINK_ERROR\",\n {\n link\n }\n );\n }\n },\n\n async deleteLink(id: string): Promise<void> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const link = await storageOperations.getLink({ tenant, locale, id });\n\n if (!link) {\n throw new NotFoundError(`Link \"${id}\" was not found!`);\n }\n\n try {\n await onLinkBeforeDelete.publish({\n link\n });\n const result = await storageOperations.deleteLink({ link });\n await onLinkAfterDelete.publish({\n link\n });\n return result;\n } catch (error) {\n throw new WebinyError(\n error.message || \"Could not delete link.\",\n error.code || \"DELETE_LINK_ERROR\",\n {\n link\n }\n );\n }\n },\n\n async deleteLinks(folderIds: string[]): Promise<void> {\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n try {\n await onLinkBeforeDeleteBatch.publish({\n folderIds\n });\n const result = await storageOperations.deleteLinks({ tenant, locale, folderIds });\n await onLinkAfterDeleteBatch.publish({\n folderIds\n });\n return result;\n } catch (error) {\n throw new WebinyError(\n error.message || \"Could not batch delete links.\",\n error.code || \"DELETE_LINKS_ERROR\",\n {\n folderIds\n }\n );\n }\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AACA;;AARA;AACA;AACA;AACA;AAwBA,MAAMA,cAAc,GAAGC,YAAA,CAAIC,MAAJ,GAAaC,QAAb,EAAvB;;AAEA,MAAMC,YAAY,GAAGH,YAAA,CAAII,MAAJ,CAAW;EAC5BC,EAAE,EAAEN,cADwB;EAE5BO,QAAQ,EAAEP,cAFkB;EAG5BQ,MAAM,EAAER,cAHoB;EAI5BS,MAAM,EAAET;AAJoB,CAAX,CAArB;;AAOA,MAAMU,YAAY,GAAGT,YAAA,CAAII,MAAJ,CAAW;EAC5BE,QAAQ,EAAEP;AADkB,CAAX,CAArB;;AAIO,MAAMW,kBAAkB,GAAG,OAAO;EACrCC,WADqC;EAErCC,aAFqC;EAGrCC,WAHqC;EAIrCC;AAJqC,CAAP,KAKI;EAClC;EACA,MAAMC,kBAAkB,GAAG,IAAAC,mBAAA,EACvB,4BADuB,CAA3B;EAGA,MAAMC,iBAAiB,GAAG,IAAAD,mBAAA,EACtB,2BADsB,CAA1B,CALkC,CAQlC;;EACA,MAAME,kBAAkB,GAAG,IAAAF,mBAAA,EACvB,4BADuB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CAAkBC,SAAlB,EAAsD;MAClD,MAAMtD,MAAM,GAAGI,WAAW,EAA1B;MACA,MAAMH,MAAM,GAAGI,aAAa,EAA5B;;MAEA,IAAI;QACA,MAAMU,uBAAuB,CAACiC,OAAxB,CAAgC;UAClCM;QADkC,CAAhC,CAAN;QAGA,MAAML,MAAM,GAAG,MAAM1C,iBAAiB,CAAC8C,WAAlB,CAA8B;UAAErD,MAAF;UAAUC,MAAV;UAAkBqD;QAAlB,CAA9B,CAArB;QACA,MAAMtC,sBAAsB,CAACgC,OAAvB,CAA+B;UACjCM;QADiC,CAA/B,CAAN;QAGA,OAAOL,MAAP;MACH,CATD,CASE,OAAO9B,KAAP,EAAc;QACZ,MAAM,IAAIC,cAAJ,CACFD,KAAK,CAACG,OAAN,IAAiB,+BADf,EAEFH,KAAK,CAACI,IAAN,IAAc,oBAFZ,EAGF;UACI+B;QADJ,CAHE,CAAN;MAOH;IACJ;;EA/LE,CAAP;AAiMH,CApOM"}
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins";
2
+ import { ACOContext } from "../types";
3
+ export declare const baseSchema: GraphQLSchemaPlugin<ACOContext>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.baseSchema = void 0;
7
+
8
+ var _plugins = require("@webiny/handler-graphql/plugins");
9
+
10
+ const emptyResolver = () => ({});
11
+
12
+ const baseSchema = new _plugins.GraphQLSchemaPlugin({
13
+ typeDefs:
14
+ /* GraphQL */
15
+ `
16
+ type FoldersQuery {
17
+ _empty: String
18
+ }
19
+
20
+ type FoldersMutation {
21
+ _empty: String
22
+ }
23
+
24
+ extend type Query {
25
+ folders: FoldersQuery
26
+ }
27
+
28
+ extend type Mutation {
29
+ folders: FoldersMutation
30
+ }
31
+
32
+ type FolderCreatedBy {
33
+ id: ID
34
+ displayName: String
35
+ }
36
+
37
+ type FolderError {
38
+ code: String
39
+ message: String
40
+ data: JSON
41
+ }
42
+
43
+ type FolderBooleanResponse {
44
+ data: Boolean
45
+ error: FolderError
46
+ }
47
+
48
+ type ListMeta {
49
+ cursor: String
50
+ totalCount: Int
51
+ hasMoreItems: Boolean
52
+ }
53
+ `,
54
+ resolvers: {
55
+ Query: {
56
+ folders: emptyResolver
57
+ },
58
+ Mutation: {
59
+ folders: emptyResolver
60
+ }
61
+ }
62
+ });
63
+ exports.baseSchema = baseSchema;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","folders","Mutation"],"sources":["base.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ACOContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nexport const baseSchema = new GraphQLSchemaPlugin<ACOContext>({\n typeDefs: /* GraphQL */ `\n type FoldersQuery {\n _empty: String\n }\n\n type FoldersMutation {\n _empty: String\n }\n\n extend type Query {\n folders: FoldersQuery\n }\n\n extend type Mutation {\n folders: FoldersMutation\n }\n\n type FolderCreatedBy {\n id: ID\n displayName: String\n }\n\n type FolderError {\n code: String\n message: String\n data: JSON\n }\n\n type FolderBooleanResponse {\n data: Boolean\n error: FolderError\n }\n\n type ListMeta {\n cursor: String\n totalCount: Int\n hasMoreItems: Boolean\n }\n `,\n resolvers: {\n Query: {\n folders: emptyResolver\n },\n Mutation: {\n folders: emptyResolver\n }\n }\n});\n"],"mappings":";;;;;;;AAAA;;AAGA,MAAMA,aAAa,GAAG,OAAO,EAAP,CAAtB;;AAEO,MAAMC,UAAU,GAAG,IAAIC,4BAAJ,CAAoC;EAC1DC,QAAQ;EAAE;EAAe;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,KAvC8D;EAwC1DC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,OAAO,EAAEN;IADN,CADA;IAIPO,QAAQ,EAAE;MACND,OAAO,EAAEN;IADH;EAJH;AAxC+C,CAApC,CAAnB"}
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin";
2
+ import { ACOContext } from "../types";
3
+ export declare const foldersSchema: GraphQLSchemaPlugin<ACOContext>;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.foldersSchema = void 0;
7
+
8
+ var _responses = require("@webiny/handler-graphql/responses");
9
+
10
+ var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
11
+
12
+ const foldersSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
13
+ typeDefs:
14
+ /* GraphQL */
15
+ `
16
+ type Folder {
17
+ id: ID!
18
+ name: String!
19
+ slug: String!
20
+ type: String!
21
+ parentId: ID
22
+ createdOn: DateTime
23
+ createdBy: FolderCreatedBy
24
+ }
25
+
26
+ input FolderCreateInput {
27
+ name: String!
28
+ slug: String!
29
+ type: String!
30
+ parentId: ID
31
+ }
32
+
33
+ input FolderUpdateInput {
34
+ name: String
35
+ slug: String
36
+ parentId: ID
37
+ }
38
+
39
+ input FoldersListWhereInput {
40
+ type: String!
41
+ }
42
+
43
+ type FolderResponse {
44
+ data: Folder
45
+ error: FolderError
46
+ }
47
+
48
+ type FoldersListResponse {
49
+ data: [Folder]
50
+ error: FolderError
51
+ }
52
+
53
+ extend type FoldersQuery {
54
+ getFolder(id: ID!): FolderResponse
55
+ listFolders(where: FoldersListWhereInput!): FoldersListResponse
56
+ }
57
+
58
+ extend type FoldersMutation {
59
+ createFolder(data: FolderCreateInput!): FolderResponse
60
+ updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse
61
+ deleteFolder(id: ID!): FolderBooleanResponse
62
+ }
63
+ `,
64
+ resolvers: {
65
+ FoldersQuery: {
66
+ getFolder: async (_, {
67
+ id
68
+ }, context) => {
69
+ try {
70
+ const folder = await context.folders.getFolder({
71
+ id
72
+ });
73
+ return new _responses.Response(folder);
74
+ } catch (error) {
75
+ return new _responses.ErrorResponse(error);
76
+ }
77
+ },
78
+ listFolders: async (_, {
79
+ where
80
+ }, context) => {
81
+ try {
82
+ const folders = await context.folders.listFolders({
83
+ where
84
+ });
85
+ return new _responses.Response(folders);
86
+ } catch (error) {
87
+ return new _responses.ErrorResponse(error);
88
+ }
89
+ }
90
+ },
91
+ FoldersMutation: {
92
+ createFolder: async (_, {
93
+ data
94
+ }, context) => {
95
+ try {
96
+ const folder = await context.folders.createFolder(data);
97
+ return new _responses.Response(folder);
98
+ } catch (error) {
99
+ return new _responses.ErrorResponse(error);
100
+ }
101
+ },
102
+ updateFolder: async (_, {
103
+ id,
104
+ data
105
+ }, context) => {
106
+ try {
107
+ const folder = await context.folders.updateFolder(id, data);
108
+ return new _responses.Response(folder);
109
+ } catch (error) {
110
+ return new _responses.ErrorResponse(error);
111
+ }
112
+ },
113
+ deleteFolder: async (_, {
114
+ id
115
+ }, context) => {
116
+ try {
117
+ await context.folders.deleteFolder(id);
118
+ return new _responses.Response(true);
119
+ } catch (error) {
120
+ return new _responses.ErrorResponse(error);
121
+ }
122
+ }
123
+ }
124
+ }
125
+ });
126
+ exports.foldersSchema = foldersSchema;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["foldersSchema","GraphQLSchemaPlugin","typeDefs","resolvers","FoldersQuery","getFolder","_","id","context","folder","folders","Response","error","ErrorResponse","listFolders","where","FoldersMutation","createFolder","data","updateFolder","deleteFolder"],"sources":["folders.gql.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { ACOContext } from \"~/types\";\n\nexport const foldersSchema = new GraphQLSchemaPlugin<ACOContext>({\n typeDefs: /* GraphQL */ `\n type Folder {\n id: ID!\n name: String!\n slug: String!\n type: String!\n parentId: ID\n createdOn: DateTime\n createdBy: FolderCreatedBy\n }\n\n input FolderCreateInput {\n name: String!\n slug: String!\n type: String!\n parentId: ID\n }\n\n input FolderUpdateInput {\n name: String\n slug: String\n parentId: ID\n }\n\n input FoldersListWhereInput {\n type: String!\n }\n\n type FolderResponse {\n data: Folder\n error: FolderError\n }\n\n type FoldersListResponse {\n data: [Folder]\n error: FolderError\n }\n\n extend type FoldersQuery {\n getFolder(id: ID!): FolderResponse\n listFolders(where: FoldersListWhereInput!): FoldersListResponse\n }\n\n extend type FoldersMutation {\n createFolder(data: FolderCreateInput!): FolderResponse\n updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse\n deleteFolder(id: ID!): FolderBooleanResponse\n }\n `,\n resolvers: {\n FoldersQuery: {\n getFolder: async (_, { id }, context) => {\n try {\n const folder = await context.folders.getFolder({ id });\n return new Response(folder);\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n listFolders: async (_, { where }, context) => {\n try {\n const folders = await context.folders.listFolders({ where });\n return new Response(folders);\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n },\n\n FoldersMutation: {\n createFolder: async (_, { data }, context) => {\n try {\n const folder = await context.folders.createFolder(data);\n return new Response(folder);\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n updateFolder: async (_, { id, data }, context) => {\n try {\n const folder = await context.folders.updateFolder(id, data);\n return new Response(folder);\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n deleteFolder: async (_, { id }, context) => {\n try {\n await context.folders.deleteFolder(id);\n return new Response(true);\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n }\n }\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAGO,MAAMA,aAAa,GAAG,IAAIC,wCAAJ,CAAoC;EAC7DC,QAAQ;EAAE;EA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,KAAP,EAAc;UACZ,OAAO,IAAIC,wBAAJ,CAAkBD,KAAlB,CAAP;QACH;MACJ,CARY;MASbO,YAAY,EAAE,OAAOb,CAAP,EAAU;QAAEC,EAAF;QAAMW;MAAN,CAAV,EAAwBV,OAAxB,KAAoC;QAC9C,IAAI;UACA,MAAMC,MAAM,GAAG,MAAMD,OAAO,CAACE,OAAR,CAAgBS,YAAhB,CAA6BZ,EAA7B,EAAiCW,IAAjC,CAArB;UACA,OAAO,IAAIP,mBAAJ,CAAaF,MAAb,CAAP;QACH,CAHD,CAGE,OAAOG,KAAP,EAAc;UACZ,OAAO,IAAIC,wBAAJ,CAAkBD,KAAlB,CAAP;QACH;MACJ,CAhBY;MAiBbQ,YAAY,EAAE,OAAOd,CAAP,EAAU;QAAEC;MAAF,CAAV,EAAkBC,OAAlB,KAA8B;QACxC,IAAI;UACA,MAAMA,OAAO,CAACE,OAAR,CAAgBU,YAAhB,CAA6Bb,EAA7B,CAAN;UACA,OAAO,IAAII,mBAAJ,CAAa,IAAb,CAAP;QACH,CAHD,CAGE,OAAOC,KAAP,EAAc;UACZ,OAAO,IAAIC,wBAAJ,CAAkBD,KAAlB,CAAP;QACH;MACJ;IAxBY;EApBV;AAlDkD,CAApC,CAAtB"}
@@ -0,0 +1 @@
1
+ export declare const graphqlPlugins: import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("../types").ACOContext>[];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.graphqlPlugins = void 0;
7
+
8
+ var _base = require("./base.gql");
9
+
10
+ var _links = require("./links.gql");
11
+
12
+ var _folders = require("./folders.gql");
13
+
14
+ const graphqlPlugins = [_base.baseSchema, _links.linksSchema, _folders.foldersSchema];
15
+ exports.graphqlPlugins = graphqlPlugins;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["graphqlPlugins","baseSchema","linksSchema","foldersSchema"],"sources":["index.ts"],"sourcesContent":["import { baseSchema } from \"./base.gql\";\nimport { linksSchema } from \"./links.gql\";\nimport { foldersSchema } from \"./folders.gql\";\n\nexport const graphqlPlugins = [baseSchema, linksSchema, foldersSchema];\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,cAAc,GAAG,CAACC,gBAAD,EAAaC,kBAAb,EAA0BC,sBAA1B,CAAvB"}
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin";
2
+ import { ACOContext } from "../types";
3
+ export declare const linksSchema: GraphQLSchemaPlugin<ACOContext>;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.linksSchema = void 0;
7
+
8
+ var _responses = require("@webiny/handler-graphql/responses");
9
+
10
+ var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
11
+
12
+ const linksSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
13
+ typeDefs:
14
+ /* GraphQL */
15
+ `
16
+ type Link {
17
+ id: ID!
18
+ linkId: ID!
19
+ folderId: ID!
20
+ createdOn: DateTime
21
+ createdBy: FolderCreatedBy
22
+ }
23
+
24
+ input LinkCreateInput {
25
+ id: ID!
26
+ folderId: ID!
27
+ }
28
+
29
+ input LinkUpdateInput {
30
+ folderId: ID!
31
+ }
32
+
33
+ input LinksListWhereInput {
34
+ folderId: ID!
35
+ }
36
+
37
+ type LinkResponse {
38
+ data: Link
39
+ error: FolderError
40
+ }
41
+
42
+ type LinksListResponse {
43
+ data: [Link]
44
+ meta: ListMeta
45
+ error: FolderError
46
+ }
47
+
48
+ extend type FoldersQuery {
49
+ getLink(id: ID!): LinkResponse
50
+ listLinks(where: LinksListWhereInput!, limit: Int, after: String): LinksListResponse
51
+ }
52
+
53
+ extend type FoldersMutation {
54
+ createLink(data: LinkCreateInput!): LinkResponse
55
+ updateLink(id: ID!, data: LinkUpdateInput!): LinkResponse
56
+ deleteLink(id: ID!): FolderBooleanResponse
57
+ }
58
+ `,
59
+ resolvers: {
60
+ FoldersQuery: {
61
+ getLink: async (_, {
62
+ id
63
+ }, context) => {
64
+ try {
65
+ const link = await context.folders.getLink(id);
66
+ return new _responses.Response(link);
67
+ } catch (error) {
68
+ return new _responses.ErrorResponse(error);
69
+ }
70
+ },
71
+ listLinks: async (_, {
72
+ where,
73
+ limit,
74
+ after
75
+ }, context) => {
76
+ try {
77
+ const [data, meta] = await context.folders.listLinks({
78
+ where,
79
+ limit,
80
+ after
81
+ });
82
+ return new _responses.ListResponse(data, meta);
83
+ } catch (error) {
84
+ return new _responses.ErrorResponse(error);
85
+ }
86
+ }
87
+ },
88
+ FoldersMutation: {
89
+ createLink: async (_, {
90
+ data
91
+ }, context) => {
92
+ try {
93
+ const link = await context.folders.createLink(data);
94
+ return new _responses.Response(link);
95
+ } catch (error) {
96
+ return new _responses.ErrorResponse(error);
97
+ }
98
+ },
99
+ updateLink: async (_, {
100
+ id,
101
+ data
102
+ }, context) => {
103
+ try {
104
+ const link = await context.folders.updateLink(id, data);
105
+ return new _responses.Response(link);
106
+ } catch (error) {
107
+ return new _responses.ErrorResponse(error);
108
+ }
109
+ },
110
+ deleteLink: async (_, {
111
+ id
112
+ }, context) => {
113
+ try {
114
+ await context.folders.deleteLink(id);
115
+ return new _responses.Response(true);
116
+ } catch (error) {
117
+ return new _responses.ErrorResponse(error);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ });
123
+ exports.linksSchema = linksSchema;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["linksSchema","GraphQLSchemaPlugin","typeDefs","resolvers","FoldersQuery","getLink","_","id","context","link","folders","Response","error","ErrorResponse","listLinks","where","limit","after","data","meta","ListResponse","FoldersMutation","createLink","updateLink","deleteLink"],"sources":["links.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse, Response } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { ACOContext } from \"~/types\";\n\nexport const linksSchema = new GraphQLSchemaPlugin<ACOContext>({\n typeDefs: /* GraphQL */ `\n type Link {\n id: ID!\n linkId: ID!\n folderId: ID!\n createdOn: DateTime\n createdBy: FolderCreatedBy\n }\n\n input LinkCreateInput {\n id: ID!\n folderId: ID!\n }\n\n input LinkUpdateInput {\n folderId: ID!\n }\n\n input LinksListWhereInput {\n folderId: ID!\n }\n\n type LinkResponse {\n data: Link\n error: FolderError\n }\n\n type LinksListResponse {\n data: [Link]\n meta: ListMeta\n error: FolderError\n }\n\n extend type FoldersQuery {\n getLink(id: ID!): LinkResponse\n listLinks(where: LinksListWhereInput!, limit: Int, after: String): LinksListResponse\n }\n\n extend type FoldersMutation {\n createLink(data: LinkCreateInput!): LinkResponse\n updateLink(id: ID!, data: LinkUpdateInput!): LinkResponse\n deleteLink(id: ID!): FolderBooleanResponse\n }\n `,\n resolvers: {\n FoldersQuery: {\n getLink: async (_, { id }, context) => {\n try {\n const link = await context.folders.getLink(id);\n return new Response(link);\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n listLinks: async (_, { where, limit, after }, context) => {\n try {\n const [data, meta] = await context.folders.listLinks({ where, limit, after });\n return new ListResponse(data, meta);\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n },\n\n FoldersMutation: {\n createLink: async (_, { data }, context) => {\n try {\n const link = await context.folders.createLink(data);\n return new Response(link);\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n updateLink: async (_, { id, data }, context) => {\n try {\n const link = await context.folders.updateLink(id, data);\n return new Response(link);\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n deleteLink: async (_, { id }, context) => {\n try {\n await context.folders.deleteLink(id);\n return new Response(true);\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n }\n }\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAGO,MAAMA,WAAW,GAAG,IAAIC,wCAAJ,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A2BJ,IAA3B,CAAnB;UACA,OAAO,IAAIP,mBAAJ,CAAaF,IAAb,CAAP;QACH,CAHD,CAGE,OAAOG,KAAP,EAAc;UACZ,OAAO,IAAIC,wBAAJ,CAAkBD,KAAlB,CAAP;QACH;MACJ,CARY;MASbW,UAAU,EAAE,OAAOjB,CAAP,EAAU;QAAEC,EAAF;QAAMW;MAAN,CAAV,EAAwBV,OAAxB,KAAoC;QAC5C,IAAI;UACA,MAAMC,IAAI,GAAG,MAAMD,OAAO,CAACE,OAAR,CAAgBa,UAAhB,CAA2BhB,EAA3B,EAA+BW,IAA/B,CAAnB;UACA,OAAO,IAAIP,mBAAJ,CAAaF,IAAb,CAAP;QACH,CAHD,CAGE,OAAOG,KAAP,EAAc;UACZ,OAAO,IAAIC,wBAAJ,CAAkBD,KAAlB,CAAP;QACH;MACJ,CAhBY;MAiBbY,UAAU,EAAE,OAAOlB,CAAP,EAAU;QAAEC;MAAF,CAAV,EAAkBC,OAAlB,KAA8B;QACtC,IAAI;UACA,MAAMA,OAAO,CAACE,OAAR,CAAgBc,UAAhB,CAA2BjB,EAA3B,CAAN;UACA,OAAO,IAAII,mBAAJ,CAAa,IAAb,CAAP;QACH,CAHD,CAGE,OAAOC,KAAP,EAAc;UACZ,OAAO,IAAIC,wBAAJ,CAAkBD,KAAlB,CAAP;QACH;MACJ;IAxBY;EApBV;AA7CgD,CAApC,CAApB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco",
3
- "version": "0.0.0-unstable.cc58a6566b",
3
+ "version": "0.0.0-unstable.d7f521b032",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "aco:base"
@@ -27,31 +27,31 @@
27
27
  "@babel/preset-env": "^7.19.4",
28
28
  "@babel/preset-typescript": "^7.18.6",
29
29
  "@babel/runtime": "^7.19.0",
30
- "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.cc58a6566b",
31
- "@webiny/api-i18n-ddb": "^0.0.0-unstable.cc58a6566b",
32
- "@webiny/api-security-so-ddb": "^0.0.0-unstable.cc58a6566b",
33
- "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.cc58a6566b",
34
- "@webiny/api-wcp": "^0.0.0-unstable.cc58a6566b",
35
- "@webiny/cli": "^0.0.0-unstable.cc58a6566b",
36
- "@webiny/handler-aws": "^0.0.0-unstable.cc58a6566b",
37
- "@webiny/plugins": "^0.0.0-unstable.cc58a6566b",
38
- "@webiny/project-utils": "^0.0.0-unstable.cc58a6566b",
30
+ "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.d7f521b032",
31
+ "@webiny/api-i18n-ddb": "^0.0.0-unstable.d7f521b032",
32
+ "@webiny/api-security-so-ddb": "^0.0.0-unstable.d7f521b032",
33
+ "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.d7f521b032",
34
+ "@webiny/api-wcp": "^0.0.0-unstable.d7f521b032",
35
+ "@webiny/cli": "^0.0.0-unstable.d7f521b032",
36
+ "@webiny/handler-aws": "^0.0.0-unstable.d7f521b032",
37
+ "@webiny/plugins": "^0.0.0-unstable.d7f521b032",
38
+ "@webiny/project-utils": "^0.0.0-unstable.d7f521b032",
39
39
  "rimraf": "^3.0.2",
40
40
  "ttypescript": "^1.5.13",
41
41
  "typescript": "^4.7.4"
42
42
  },
43
43
  "dependencies": {
44
- "@webiny/api": "0.0.0-unstable.cc58a6566b",
45
- "@webiny/api-admin-settings": "0.0.0-unstable.cc58a6566b",
46
- "@webiny/api-headless-cms": "0.0.0-unstable.cc58a6566b",
47
- "@webiny/api-i18n": "0.0.0-unstable.cc58a6566b",
48
- "@webiny/api-security": "0.0.0-unstable.cc58a6566b",
49
- "@webiny/api-tenancy": "0.0.0-unstable.cc58a6566b",
50
- "@webiny/error": "0.0.0-unstable.cc58a6566b",
51
- "@webiny/handler": "0.0.0-unstable.cc58a6566b",
52
- "@webiny/handler-graphql": "0.0.0-unstable.cc58a6566b",
53
- "@webiny/pubsub": "0.0.0-unstable.cc58a6566b",
44
+ "@webiny/api": "0.0.0-unstable.d7f521b032",
45
+ "@webiny/api-admin-settings": "0.0.0-unstable.d7f521b032",
46
+ "@webiny/api-headless-cms": "0.0.0-unstable.d7f521b032",
47
+ "@webiny/api-i18n": "0.0.0-unstable.d7f521b032",
48
+ "@webiny/api-security": "0.0.0-unstable.d7f521b032",
49
+ "@webiny/api-tenancy": "0.0.0-unstable.d7f521b032",
50
+ "@webiny/error": "0.0.0-unstable.d7f521b032",
51
+ "@webiny/handler": "0.0.0-unstable.d7f521b032",
52
+ "@webiny/handler-graphql": "0.0.0-unstable.d7f521b032",
53
+ "@webiny/pubsub": "0.0.0-unstable.d7f521b032",
54
54
  "lodash": "4.17.21"
55
55
  },
56
- "gitHead": "cc58a6566be0baabe335f20bd22137818565241a"
56
+ "gitHead": "d7f521b0325964664dbeb6d2d07e2b6518e53841"
57
57
  }
@@ -0,0 +1,3 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { ACOContext } from "../types";
3
+ export declare const afterFolderDelete: () => ContextPlugin<ACOContext>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.afterFolderDelete = void 0;
9
+
10
+ var _api = require("@webiny/api");
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ const filterFolderTreeIds = (folders, folderId) => {
15
+ function findChildrenIds(acc, curr, index, arr) {
16
+ if (curr.parentId && acc.some(el => el === (curr === null || curr === void 0 ? void 0 : curr.parentId))) {
17
+ acc.push(curr.id);
18
+ arr.splice(index, 1);
19
+ return arr.reduce(findChildrenIds, acc);
20
+ }
21
+
22
+ return acc;
23
+ }
24
+
25
+ const result = folders.reduce(findChildrenIds, [folderId]);
26
+ return [...new Set([...result])];
27
+ };
28
+
29
+ const afterFolderDelete = () => {
30
+ return new _api.ContextPlugin(async ({
31
+ folders: foldersContext
32
+ }) => {
33
+ try {
34
+ // After a folder has been deleted, delete all related links.
35
+ foldersContext.onFolderAfterDelete.subscribe(async ({
36
+ folder
37
+ }) => {
38
+ const {
39
+ id,
40
+ type
41
+ } = folder; // Fetching all folders by `type`
42
+
43
+ const folders = await foldersContext.listFolders({
44
+ where: {
45
+ type
46
+ }
47
+ }); // Filter folders tree under the given folder `id`
48
+
49
+ const folderTreeIds = filterFolderTreeIds(folders, id); // Delete all links related to a list of folders ids
50
+
51
+ await foldersContext.deleteLinks(folderTreeIds);
52
+ });
53
+ } catch (error) {
54
+ throw _error.default.from(error, {
55
+ message: "Error while deleting folder-related links.",
56
+ code: "AFTER_FORM_DELETE"
57
+ });
58
+ }
59
+ });
60
+ };
61
+
62
+ exports.afterFolderDelete = afterFolderDelete;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["filterFolderTreeIds","folders","folderId","findChildrenIds","acc","curr","index","arr","parentId","some","el","push","id","splice","reduce","result","Set","afterFolderDelete","ContextPlugin","foldersContext","onFolderAfterDelete","subscribe","folder","type","listFolders","where","folderTreeIds","deleteLinks","error","WebinyError","from","message","code"],"sources":["afterFolderDelete.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport WebinyError from \"@webiny/error\";\nimport { Folder, ACOContext } from \"~/types\";\n\nconst filterFolderTreeIds = (folders: Folder[], folderId: string): string[] => {\n function findChildrenIds(acc: string[], curr: Folder, index: number, arr: Folder[]): string[] {\n if (curr.parentId && acc.some(el => el === curr?.parentId)) {\n acc.push(curr.id);\n arr.splice(index, 1);\n return arr.reduce(findChildrenIds, acc);\n }\n\n return acc;\n }\n\n const result = folders.reduce(findChildrenIds, [folderId]);\n\n return [...new Set([...result])];\n};\n\nexport const afterFolderDelete = () => {\n return new ContextPlugin<ACOContext>(async ({ folders: foldersContext }) => {\n try {\n // After a folder has been deleted, delete all related links.\n foldersContext.onFolderAfterDelete.subscribe(async ({ folder }) => {\n const { id, type } = folder;\n\n // Fetching all folders by `type`\n const folders = await foldersContext.listFolders({\n where: { type }\n });\n\n // Filter folders tree under the given folder `id`\n const folderTreeIds = filterFolderTreeIds(folders, id);\n\n // Delete all links related to a list of folders ids\n await foldersContext.deleteLinks(folderTreeIds);\n });\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while deleting folder-related links.\",\n code: \"AFTER_FORM_DELETE\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGA,MAAMA,mBAAmB,GAAG,CAACC,OAAD,EAAoBC,QAApB,KAAmD;EAC3E,SAASC,eAAT,CAAyBC,GAAzB,EAAwCC,IAAxC,EAAsDC,KAAtD,EAAqEC,GAArE,EAA8F;IAC1F,IAAIF,IAAI,CAACG,QAAL,IAAiBJ,GAAG,CAACK,IAAJ,CAASC,EAAE,IAAIA,EAAE,MAAKL,IAAL,aAAKA,IAAL,uBAAKA,IAAI,CAAEG,QAAX,CAAjB,CAArB,EAA4D;MACxDJ,GAAG,CAACO,IAAJ,CAASN,IAAI,CAACO,EAAd;MACAL,GAAG,CAACM,MAAJ,CAAWP,KAAX,EAAkB,CAAlB;MACA,OAAOC,GAAG,CAACO,MAAJ,CAAWX,eAAX,EAA4BC,GAA5B,CAAP;IACH;;IAED,OAAOA,GAAP;EACH;;EAED,MAAMW,MAAM,GAAGd,OAAO,CAACa,MAAR,CAAeX,eAAf,EAAgC,CAACD,QAAD,CAAhC,CAAf;EAEA,OAAO,CAAC,GAAG,IAAIc,GAAJ,CAAQ,CAAC,GAAGD,MAAJ,CAAR,CAAJ,CAAP;AACH,CAdD;;AAgBO,MAAME,iBAAiB,GAAG,MAAM;EACnC,OAAO,IAAIC,kBAAJ,CAA8B,OAAO;IAAEjB,OAAO,EAAEkB;EAAX,CAAP,KAAuC;IACxE,IAAI;MACA;MACAA,cAAc,CAACC,mBAAf,CAAmCC,SAAnC,CAA6C,OAAO;QAAEC;MAAF,CAAP,KAAsB;QAC/D,MAAM;UAAEV,EAAF;UAAMW;QAAN,IAAeD,MAArB,CAD+D,CAG/D;;QACA,MAAMrB,OAAO,GAAG,MAAMkB,cAAc,CAACK,WAAf,CAA2B;UAC7CC,KAAK,EAAE;YAAEF;UAAF;QADsC,CAA3B,CAAtB,CAJ+D,CAQ/D;;QACA,MAAMG,aAAa,GAAG1B,mBAAmB,CAACC,OAAD,EAAUW,EAAV,CAAzC,CAT+D,CAW/D;;QACA,MAAMO,cAAc,CAACQ,WAAf,CAA2BD,aAA3B,CAAN;MACH,CAbD;IAcH,CAhBD,CAgBE,OAAOE,KAAP,EAAc;MACZ,MAAMC,cAAA,CAAYC,IAAZ,CAAiBF,KAAjB,EAAwB;QAC1BG,OAAO,EAAE,4CADiB;QAE1BC,IAAI,EAAE;MAFoB,CAAxB,CAAN;IAIH;EACJ,CAvBM,CAAP;AAwBH,CAzBM"}
@@ -0,0 +1,3 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { ACOContext } from "../types";
3
+ export declare const subscriptions: () => ContextPlugin<ACOContext>[];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.subscriptions = void 0;
7
+
8
+ var _afterFolderDelete = require("./afterFolderDelete");
9
+
10
+ const subscriptions = () => {
11
+ return [(0, _afterFolderDelete.afterFolderDelete)()];
12
+ };
13
+
14
+ exports.subscriptions = subscriptions;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["subscriptions","afterFolderDelete"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { afterFolderDelete } from \"./afterFolderDelete\";\nimport { ACOContext } from \"~/types\";\n\nexport const subscriptions = (): ContextPlugin<ACOContext>[] => {\n return [afterFolderDelete()];\n};\n"],"mappings":";;;;;;;AACA;;AAGO,MAAMA,aAAa,GAAG,MAAmC;EAC5D,OAAO,CAAC,IAAAC,oCAAA,GAAD,CAAP;AACH,CAFM"}
@@ -1,2 +1,2 @@
1
1
  import { Response, ErrorResponse } from "@webiny/handler-graphql";
2
- export declare const resolve: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
2
+ export declare const resolve: (fn: () => Promise<any>) => Promise<Response<any> | ErrorResponse>;