@webiny/api-aco 0.0.0-ee-vpcs.549378cf03

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,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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAjDiE;EAkD7DC,SAAS,EAAE;IACPC,YAAY,EAAE;MACVC,SAAS,EAAE,OAAOC,CAAP,EAAU;QAAEC;MAAF,CAAV,EAAkBC,OAAlB,KAA8B;QACrC,IAAI;UACA,MAAMC,MAAM,GAAG,MAAMD,OAAO,CAACE,OAAR,CAAgBL,SAAhB,CAA0B;YAAEE;UAAF,CAA1B,CAArB;UACA,OAAO,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AAF,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,CAAoC;EAC3DC,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;AACA;AACA;AACA;AACA;AACA,KA5C+D;EA6C3DC,SAAS,EAAE;IACPC,YAAY,EAAE;MACVC,OAAO,EAAE,OAAOC,CAAP,EAAU;QAAEC;MAAF,CAAV,EAAkBC,OAAlB,KAA8B;QACnC,IAAI;UACA,MAAMC,IAAI,GAAG,MAAMD,OAAO,CAACE,OAAR,CAAgBL,OAAhB,CAAwBE,EAAxB,CAAnB;UACA,OAAO,IAA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J,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/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { ACOContext, StorageOperations } from "./types";
3
+ export interface FoldersConfig {
4
+ storageOperations: StorageOperations;
5
+ }
6
+ export declare const createACO: () => never[];
7
+ export declare const createFoldersContext: ({ storageOperations }: FoldersConfig) => ContextPlugin<ACOContext>;
8
+ export declare const createFoldersGraphQL: () => import("@webiny/handler-graphql").GraphQLSchemaPlugin<ACOContext>[];
9
+ export declare const createFoldersSubscriptions: () => ContextPlugin<ACOContext>[];
package/index.js ADDED
@@ -0,0 +1,71 @@
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.createFoldersSubscriptions = exports.createFoldersGraphQL = exports.createFoldersContext = exports.createACO = void 0;
9
+
10
+ var _api = require("@webiny/api");
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _context = require("./context");
15
+
16
+ var _subscriptions = require("./subscriptions");
17
+
18
+ var _graphql = require("./graphql");
19
+
20
+ const createACO = () => {
21
+ return [];
22
+ };
23
+
24
+ exports.createACO = createACO;
25
+
26
+ const createFoldersContext = ({
27
+ storageOperations
28
+ }) => {
29
+ return new _api.ContextPlugin(async context => {
30
+ const getTenantId = () => {
31
+ const tenant = context.tenancy.getCurrentTenant();
32
+
33
+ if (!tenant) {
34
+ throw new _error.default("Missing tenant in API Folders.");
35
+ }
36
+
37
+ return tenant.id;
38
+ };
39
+
40
+ const getLocaleCode = () => {
41
+ const locale = context.i18n.getContentLocale();
42
+
43
+ if (!locale) {
44
+ throw new _error.default("Missing content locale in API Folders.");
45
+ }
46
+
47
+ return locale.code;
48
+ };
49
+
50
+ const getIdentity = () => {
51
+ return context.security.getIdentity();
52
+ };
53
+
54
+ context.folders = await (0, _context.createContext)({
55
+ storageOperations,
56
+ getTenantId,
57
+ getLocaleCode,
58
+ getIdentity
59
+ });
60
+ });
61
+ };
62
+
63
+ exports.createFoldersContext = createFoldersContext;
64
+
65
+ const createFoldersGraphQL = () => _graphql.graphqlPlugins;
66
+
67
+ exports.createFoldersGraphQL = createFoldersGraphQL;
68
+
69
+ const createFoldersSubscriptions = () => (0, _subscriptions.subscriptions)();
70
+
71
+ exports.createFoldersSubscriptions = createFoldersSubscriptions;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createACO","createFoldersContext","storageOperations","ContextPlugin","context","getTenantId","tenant","tenancy","getCurrentTenant","WebinyError","id","getLocaleCode","locale","i18n","getContentLocale","code","getIdentity","security","folders","createContext","createFoldersGraphQL","graphqlPlugins","createFoldersSubscriptions","subscriptions"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createContext } from \"./context\";\nimport { subscriptions } from \"./subscriptions\";\nimport { graphqlPlugins } from \"./graphql\";\n\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { ACOContext, StorageOperations } from \"~/types\";\n\nexport interface FoldersConfig {\n storageOperations: StorageOperations;\n}\n\nexport const createACO = () => {\n return [];\n};\n\nexport const createFoldersContext = ({ storageOperations }: FoldersConfig) => {\n return new ContextPlugin<ACOContext>(async context => {\n const getTenantId = (): string => {\n const tenant = context.tenancy.getCurrentTenant();\n if (!tenant) {\n throw new WebinyError(\"Missing tenant in API Folders.\");\n }\n return tenant.id;\n };\n\n const getLocaleCode = (): string => {\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\"Missing content locale in API Folders.\");\n }\n return locale.code;\n };\n\n const getIdentity = (): SecurityIdentity => {\n return context.security.getIdentity();\n };\n\n context.folders = await createContext({\n storageOperations,\n getTenantId,\n getLocaleCode,\n getIdentity\n });\n });\n};\n\nexport const createFoldersGraphQL = () => graphqlPlugins;\n\nexport const createFoldersSubscriptions = () => subscriptions();\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AASO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,EAAP;AACH,CAFM;;;;AAIA,MAAMC,oBAAoB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA0C;EAC1E,OAAO,IAAIC,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;IAClD,MAAMC,WAAW,GAAG,MAAc;MAC9B,MAAMC,MAAM,GAAGF,OAAO,CAACG,OAAR,CAAgBC,gBAAhB,EAAf;;MACA,IAAI,CAACF,MAAL,EAAa;QACT,MAAM,IAAIG,cAAJ,CAAgB,gCAAhB,CAAN;MACH;;MACD,OAAOH,MAAM,CAACI,EAAd;IACH,CAND;;IAQA,MAAMC,aAAa,GAAG,MAAc;MAChC,MAAMC,MAAM,GAAGR,OAAO,CAACS,IAAR,CAAaC,gBAAb,EAAf;;MACA,IAAI,CAACF,MAAL,EAAa;QACT,MAAM,IAAIH,cAAJ,CAAgB,wCAAhB,CAAN;MACH;;MACD,OAAOG,MAAM,CAACG,IAAd;IACH,CAND;;IAQA,MAAMC,WAAW,GAAG,MAAwB;MACxC,OAAOZ,OAAO,CAACa,QAAR,CAAiBD,WAAjB,EAAP;IACH,CAFD;;IAIAZ,OAAO,CAACc,OAAR,GAAkB,MAAM,IAAAC,sBAAA,EAAc;MAClCjB,iBADkC;MAElCG,WAFkC;MAGlCM,aAHkC;MAIlCK;IAJkC,CAAd,CAAxB;EAMH,CA3BM,CAAP;AA4BH,CA7BM;;;;AA+BA,MAAMI,oBAAoB,GAAG,MAAMC,uBAAnC;;;;AAEA,MAAMC,0BAA0B,GAAG,MAAM,IAAAC,4BAAA,GAAzC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@webiny/api-aco",
3
+ "version": "0.0.0-ee-vpcs.549378cf03",
4
+ "main": "index.js",
5
+ "keywords": [
6
+ "aco:base"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/webiny/webiny-js.git",
11
+ "directory": "packages/api-aco"
12
+ },
13
+ "description": "A set of backend aco-related features.",
14
+ "author": "Webiny Ltd.",
15
+ "license": "MIT",
16
+ "scripts": {
17
+ "build": "yarn webiny run build",
18
+ "watch": "yarn webiny run watch"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "directory": "dist"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/cli": "^7.19.3",
26
+ "@babel/core": "^7.19.3",
27
+ "@babel/preset-env": "^7.19.4",
28
+ "@babel/preset-typescript": "^7.18.6",
29
+ "@babel/runtime": "^7.19.0",
30
+ "@webiny/api-i18n-ddb": "^0.0.0-ee-vpcs.549378cf03",
31
+ "@webiny/api-security-so-ddb": "^0.0.0-ee-vpcs.549378cf03",
32
+ "@webiny/api-tenancy-so-ddb": "^0.0.0-ee-vpcs.549378cf03",
33
+ "@webiny/api-wcp": "^0.0.0-ee-vpcs.549378cf03",
34
+ "@webiny/cli": "^0.0.0-ee-vpcs.549378cf03",
35
+ "@webiny/handler-aws": "^0.0.0-ee-vpcs.549378cf03",
36
+ "@webiny/plugins": "^0.0.0-ee-vpcs.549378cf03",
37
+ "@webiny/project-utils": "^0.0.0-ee-vpcs.549378cf03",
38
+ "rimraf": "^3.0.2",
39
+ "ttypescript": "^1.5.13",
40
+ "typescript": "^4.7.4"
41
+ },
42
+ "dependencies": {
43
+ "@webiny/api": "0.0.0-ee-vpcs.549378cf03",
44
+ "@webiny/api-i18n": "0.0.0-ee-vpcs.549378cf03",
45
+ "@webiny/api-security": "0.0.0-ee-vpcs.549378cf03",
46
+ "@webiny/api-tenancy": "0.0.0-ee-vpcs.549378cf03",
47
+ "@webiny/error": "0.0.0-ee-vpcs.549378cf03",
48
+ "@webiny/handler": "0.0.0-ee-vpcs.549378cf03",
49
+ "@webiny/handler-graphql": "0.0.0-ee-vpcs.549378cf03",
50
+ "@webiny/pubsub": "0.0.0-ee-vpcs.549378cf03",
51
+ "joi": "17.6.2",
52
+ "mdbid": "1.0.0"
53
+ },
54
+ "gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
55
+ }
@@ -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"}