@webiny/api-aco 5.34.8 → 5.35.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/createAcoContext.d.ts +3 -0
- package/createAcoContext.js +63 -0
- package/createAcoContext.js.map +1 -0
- package/createAcoCrud.d.ts +2 -0
- package/createAcoCrud.js +17 -0
- package/createAcoCrud.js.map +1 -0
- package/createAcoFields.d.ts +2 -0
- package/createAcoFields.js +40 -0
- package/createAcoFields.js.map +1 -0
- package/createAcoGraphQL.d.ts +3 -0
- package/createAcoGraphQL.js +92 -0
- package/createAcoGraphQL.js.map +1 -0
- package/createAcoHooks.d.ts +2 -0
- package/createAcoHooks.js +11 -0
- package/createAcoHooks.js.map +1 -0
- package/createAcoModels.d.ts +2 -0
- package/createAcoModels.js +65 -0
- package/createAcoModels.js.map +1 -0
- package/createAcoStorageOperations.d.ts +10 -0
- package/createAcoStorageOperations.js +19 -0
- package/createAcoStorageOperations.js.map +1 -0
- package/folder/folder.crud.d.ts +3 -0
- package/folder/folder.crud.js +92 -0
- package/folder/folder.crud.js.map +1 -0
- package/folder/folder.gql.d.ts +3 -0
- package/folder/folder.gql.js +103 -0
- package/folder/folder.gql.js.map +1 -0
- package/folder/folder.model.d.ts +4 -0
- package/folder/folder.model.js +75 -0
- package/folder/folder.model.js.map +1 -0
- package/folder/folder.so.d.ts +3 -0
- package/folder/folder.so.js +151 -0
- package/folder/folder.so.js.map +1 -0
- package/folder/folder.types.d.ts +83 -0
- package/folder/folder.types.js +5 -0
- package/folder/folder.types.js.map +1 -0
- package/folder/onFolderBeforeDelete.hook.d.ts +2 -0
- package/folder/onFolderBeforeDelete.hook.js +53 -0
- package/folder/onFolderBeforeDelete.hook.js.map +1 -0
- package/index.d.ts +3 -9
- package/index.js +22 -65
- package/index.js.map +1 -1
- package/package.json +23 -20
- package/record/record.crud.d.ts +3 -0
- package/record/record.crud.js +92 -0
- package/record/record.crud.js.map +1 -0
- package/record/record.gql.d.ts +3 -0
- package/record/record.gql.js +133 -0
- package/record/record.gql.js.map +1 -0
- package/record/record.model.d.ts +4 -0
- package/record/record.model.js +62 -0
- package/record/record.model.js.map +1 -0
- package/record/record.so.d.ts +3 -0
- package/record/record.so.js +105 -0
- package/record/record.so.js.map +1 -0
- package/record/record.types.d.ts +96 -0
- package/record/record.types.js +5 -0
- package/record/record.types.js.map +1 -0
- package/types.d.ts +32 -202
- package/types.js +35 -1
- package/types.js.map +1 -1
- package/utils/acoRecordId.d.ts +6 -0
- package/utils/acoRecordId.js +33 -0
- package/utils/acoRecordId.js.map +1 -0
- package/utils/createListSort.d.ts +2 -0
- package/utils/createListSort.js +13 -0
- package/utils/createListSort.js.map +1 -0
- package/utils/createModelField.d.ts +5 -0
- package/utils/createModelField.js +37 -0
- package/utils/createModelField.js.map +1 -0
- package/utils/createOperationsWrapper.d.ts +9 -0
- package/utils/createOperationsWrapper.js +29 -0
- package/utils/createOperationsWrapper.js.map +1 -0
- package/utils/fieldResolver.d.ts +16 -0
- package/utils/fieldResolver.js +44 -0
- package/utils/fieldResolver.js.map +1 -0
- package/utils/getFieldValues.d.ts +5 -0
- package/utils/getFieldValues.js +16 -0
- package/utils/getFieldValues.js.map +1 -0
- package/utils/isInstallationPending.d.ts +4 -0
- package/utils/isInstallationPending.js +21 -0
- package/utils/isInstallationPending.js.map +1 -0
- package/utils/modelFactory.d.ts +15 -0
- package/utils/modelFactory.js +25 -0
- package/utils/modelFactory.js.map +1 -0
- package/utils/resolve.d.ts +2 -0
- package/utils/resolve.js +15 -0
- package/utils/resolve.js.map +1 -0
package/README.md
CHANGED
|
@@ -16,3 +16,18 @@ Or if you prefer yarn:
|
|
|
16
16
|
```
|
|
17
17
|
yarn add @webiny/api-aco
|
|
18
18
|
```
|
|
19
|
+
## Testing
|
|
20
|
+
|
|
21
|
+
To run tests api-aco tests with targeted storage operations loaded use:
|
|
22
|
+
|
|
23
|
+
### DynamoDB
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
yarn test packages/api-aco/* --keyword=cms:ddb --keyword=aco:base
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### DynamoDB + ElasticSearch
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
yarn test packages/api-aco/* --keyword=cms:ddb-es --keyword=aco:base
|
|
33
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createAcoContext = void 0;
|
|
8
|
+
var _api = require("@webiny/api");
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
var _createAcoCrud = require("./createAcoCrud");
|
|
11
|
+
var _createAcoHooks = require("./createAcoHooks");
|
|
12
|
+
var _createAcoStorageOperations = require("./createAcoStorageOperations");
|
|
13
|
+
var _isInstallationPending = require("./utils/isInstallationPending");
|
|
14
|
+
const setupAcoContext = context => {
|
|
15
|
+
const {
|
|
16
|
+
tenancy,
|
|
17
|
+
security,
|
|
18
|
+
i18n
|
|
19
|
+
} = context;
|
|
20
|
+
if ((0, _isInstallationPending.isInstallationPending)({
|
|
21
|
+
tenancy,
|
|
22
|
+
i18n
|
|
23
|
+
})) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const getLocale = () => {
|
|
27
|
+
const locale = i18n.getContentLocale();
|
|
28
|
+
if (!locale) {
|
|
29
|
+
throw new _error.default("Missing content locale in api-aco/plugins/context.ts", "LOCALE_ERROR");
|
|
30
|
+
}
|
|
31
|
+
return locale;
|
|
32
|
+
};
|
|
33
|
+
const getTenant = () => {
|
|
34
|
+
return tenancy.getCurrentTenant();
|
|
35
|
+
};
|
|
36
|
+
const getIdentity = () => security.getIdentity();
|
|
37
|
+
context.aco = (0, _createAcoCrud.createAcoCrud)({
|
|
38
|
+
getLocale,
|
|
39
|
+
getIdentity,
|
|
40
|
+
getTenant,
|
|
41
|
+
storageOperations: (0, _createAcoStorageOperations.createAcoStorageOperations)({
|
|
42
|
+
/**
|
|
43
|
+
* TODO: We need to figure out a way to pass "cms" from outside (e.g. apps/api/graphql)
|
|
44
|
+
*/
|
|
45
|
+
cms: context.cms,
|
|
46
|
+
/**
|
|
47
|
+
* TODO: This is required for "entryFieldFromStorageTransform" which access plugins from context.
|
|
48
|
+
*/
|
|
49
|
+
getCmsContext: () => context,
|
|
50
|
+
security
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const createAcoContext = () => {
|
|
55
|
+
return new _api.ContextPlugin(async context => {
|
|
56
|
+
if ((0, _isInstallationPending.isInstallationPending)(context)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
await setupAcoContext(context);
|
|
60
|
+
await (0, _createAcoHooks.createAcoHooks)(context);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
exports.createAcoContext = createAcoContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["setupAcoContext","context","tenancy","security","i18n","isInstallationPending","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","getIdentity","aco","createAcoCrud","storageOperations","createAcoStorageOperations","cms","getCmsContext","createAcoContext","ContextPlugin","createAcoHooks"],"sources":["createAcoContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createAcoCrud } from \"~/createAcoCrud\";\nimport { createAcoHooks } from \"~/createAcoHooks\";\nimport { createAcoStorageOperations } from \"~/createAcoStorageOperations\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\n\nimport { AcoContext } from \"~/types\";\n\nconst setupAcoContext = (context: AcoContext) => {\n const { tenancy, security, i18n } = context;\n\n if (isInstallationPending({ tenancy, i18n })) {\n return;\n }\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const getIdentity = () => security.getIdentity();\n\n context.aco = createAcoCrud({\n getLocale,\n getIdentity,\n getTenant,\n storageOperations: createAcoStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context,\n security\n })\n });\n};\n\nexport const createAcoContext = () => {\n return new ContextPlugin<AcoContext>(async context => {\n if (isInstallationPending(context)) {\n return;\n }\n\n await setupAcoContext(context);\n await createAcoHooks(context);\n });\n};\n"],"mappings":";;;;;;;AAAA;AAGA;AAEA;AACA;AACA;AACA;AAIA,MAAMA,eAAe,GAAIC,OAAmB,IAAK;EAC7C,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAK,CAAC,GAAGH,OAAO;EAE3C,IAAI,IAAAI,4CAAqB,EAAC;IAAEH,OAAO;IAAEE;EAAK,CAAC,CAAC,EAAE;IAC1C;EACJ;EAEA,MAAME,SAAS,GAAG,MAAkB;IAChC,MAAMC,MAAM,GAAGH,IAAI,CAACI,gBAAgB,EAAE;IACtC,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,sDAAsD,EACtD,cAAc,CACjB;IACL;IAEA,OAAOF,MAAM;EACjB,CAAC;EAED,MAAMG,SAAS,GAAG,MAAc;IAC5B,OAAOR,OAAO,CAACS,gBAAgB,EAAE;EACrC,CAAC;EAED,MAAMC,WAAW,GAAG,MAAMT,QAAQ,CAACS,WAAW,EAAE;EAEhDX,OAAO,CAACY,GAAG,GAAG,IAAAC,4BAAa,EAAC;IACxBR,SAAS;IACTM,WAAW;IACXF,SAAS;IACTK,iBAAiB,EAAE,IAAAC,sDAA0B,EAAC;MAC1C;AACZ;AACA;MACYC,GAAG,EAAEhB,OAAO,CAACgB,GAAG;MAChB;AACZ;AACA;MACYC,aAAa,EAAE,MAAMjB,OAAO;MAC5BE;IACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAEM,MAAMgB,gBAAgB,GAAG,MAAM;EAClC,OAAO,IAAIC,kBAAa,CAAa,MAAMnB,OAAO,IAAI;IAClD,IAAI,IAAAI,4CAAqB,EAACJ,OAAO,CAAC,EAAE;MAChC;IACJ;IAEA,MAAMD,eAAe,CAACC,OAAO,CAAC;IAC9B,MAAM,IAAAoB,8BAAc,EAACpB,OAAO,CAAC;EACjC,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/createAcoCrud.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAcoCrud = void 0;
|
|
7
|
+
var _folder = require("./folder/folder.crud");
|
|
8
|
+
var _record = require("./record/record.crud");
|
|
9
|
+
const createAcoCrud = params => {
|
|
10
|
+
const folderMethods = (0, _folder.createFolderCrudMethods)(params);
|
|
11
|
+
const searchRecordMethods = (0, _record.createSearchRecordCrudMethods)(params);
|
|
12
|
+
return {
|
|
13
|
+
folder: folderMethods,
|
|
14
|
+
search: searchRecordMethods
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.createAcoCrud = createAcoCrud;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAcoCrud","params","folderMethods","createFolderCrudMethods","searchRecordMethods","createSearchRecordCrudMethods","folder","search"],"sources":["createAcoCrud.ts"],"sourcesContent":["import { createFolderCrudMethods } from \"~/folder/folder.crud\";\nimport { createSearchRecordCrudMethods } from \"~/record/record.crud\";\n\nimport { AdvancedContentOrganisation, CreateAcoParams } from \"~/types\";\n\nexport const createAcoCrud = (params: CreateAcoParams): AdvancedContentOrganisation => {\n const folderMethods = createFolderCrudMethods(params);\n const searchRecordMethods = createSearchRecordCrudMethods(params);\n\n return {\n folder: folderMethods,\n search: searchRecordMethods\n };\n};\n"],"mappings":";;;;;;AAAA;AACA;AAIO,MAAMA,aAAa,GAAIC,MAAuB,IAAkC;EACnF,MAAMC,aAAa,GAAG,IAAAC,+BAAuB,EAACF,MAAM,CAAC;EACrD,MAAMG,mBAAmB,GAAG,IAAAC,qCAA6B,EAACJ,MAAM,CAAC;EAEjE,OAAO;IACHK,MAAM,EAAEJ,aAAa;IACrBK,MAAM,EAAEH;EACZ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAcoFields = void 0;
|
|
7
|
+
// Creating an internal JSON field, we are using it inside the `record` type
|
|
8
|
+
const jsonField = {
|
|
9
|
+
name: "cms-model-field-to-graphql-json",
|
|
10
|
+
type: "cms-model-field-to-graphql",
|
|
11
|
+
fieldType: "wby-aco-json",
|
|
12
|
+
isSortable: true,
|
|
13
|
+
isSearchable: true,
|
|
14
|
+
read: {
|
|
15
|
+
createTypeField({
|
|
16
|
+
field
|
|
17
|
+
}) {
|
|
18
|
+
return `${field.fieldId}: JSON`;
|
|
19
|
+
},
|
|
20
|
+
createGetFilters({
|
|
21
|
+
field
|
|
22
|
+
}) {
|
|
23
|
+
return `${field.fieldId}: JSON`;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
manage: {
|
|
27
|
+
createTypeField({
|
|
28
|
+
field
|
|
29
|
+
}) {
|
|
30
|
+
return `${field.fieldId}: JSON`;
|
|
31
|
+
},
|
|
32
|
+
createInputField({
|
|
33
|
+
field
|
|
34
|
+
}) {
|
|
35
|
+
return field.fieldId + ": JSON";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const createAcoFields = () => [jsonField];
|
|
40
|
+
exports.createAcoFields = createAcoFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsonField","name","type","fieldType","isSortable","isSearchable","read","createTypeField","field","fieldId","createGetFilters","manage","createInputField","createAcoFields"],"sources":["createAcoFields.ts"],"sourcesContent":["import { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\n\n// Creating an internal JSON field, we are using it inside the `record` type\nconst jsonField: CmsModelFieldToGraphQLPlugin = {\n name: \"cms-model-field-to-graphql-json\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"wby-aco-json\",\n isSortable: true,\n isSearchable: true,\n read: {\n createTypeField({ field }) {\n return `${field.fieldId}: JSON`;\n },\n createGetFilters({ field }) {\n return `${field.fieldId}: JSON`;\n }\n },\n manage: {\n createTypeField({ field }) {\n return `${field.fieldId}: JSON`;\n },\n createInputField({ field }) {\n return field.fieldId + \": JSON\";\n }\n }\n};\n\nexport const createAcoFields = (): CmsModelFieldToGraphQLPlugin[] => [jsonField];\n"],"mappings":";;;;;;AAEA;AACA,MAAMA,SAAuC,GAAG;EAC5CC,IAAI,EAAE,iCAAiC;EACvCC,IAAI,EAAE,4BAA4B;EAClCC,SAAS,EAAE,cAAc;EACzBC,UAAU,EAAE,IAAI;EAChBC,YAAY,EAAE,IAAI;EAClBC,IAAI,EAAE;IACFC,eAAe,CAAC;MAAEC;IAAM,CAAC,EAAE;MACvB,OAAQ,GAAEA,KAAK,CAACC,OAAQ,QAAO;IACnC,CAAC;IACDC,gBAAgB,CAAC;MAAEF;IAAM,CAAC,EAAE;MACxB,OAAQ,GAAEA,KAAK,CAACC,OAAQ,QAAO;IACnC;EACJ,CAAC;EACDE,MAAM,EAAE;IACJJ,eAAe,CAAC;MAAEC;IAAM,CAAC,EAAE;MACvB,OAAQ,GAAEA,KAAK,CAACC,OAAQ,QAAO;IACnC,CAAC;IACDG,gBAAgB,CAAC;MAAEJ;IAAM,CAAC,EAAE;MACxB,OAAOA,KAAK,CAACC,OAAO,GAAG,QAAQ;IACnC;EACJ;AACJ,CAAC;AAEM,MAAMI,eAAe,GAAG,MAAsC,CAACb,SAAS,CAAC;AAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAcoGraphQL = void 0;
|
|
7
|
+
var _api = require("@webiny/api");
|
|
8
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
+
var _folder = require("./folder/folder.gql");
|
|
10
|
+
var _record = require("./record/record.gql");
|
|
11
|
+
const emptyResolver = () => ({});
|
|
12
|
+
const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
13
|
+
typeDefs: /* GraphQL */`
|
|
14
|
+
type AcoQuery {
|
|
15
|
+
_empty: String
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type AcoMutation {
|
|
19
|
+
_empty: String
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type SearchQuery {
|
|
23
|
+
_empty: String
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type SearchMutation {
|
|
27
|
+
_empty: String
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type AcoMeta {
|
|
31
|
+
hasMoreItems: Boolean
|
|
32
|
+
totalCount: Int
|
|
33
|
+
cursor: String
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type AcoUser {
|
|
37
|
+
id: ID
|
|
38
|
+
displayName: String
|
|
39
|
+
type: String
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type AcoError {
|
|
43
|
+
code: String
|
|
44
|
+
message: String
|
|
45
|
+
data: JSON
|
|
46
|
+
stack: String
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type AcoBooleanResponse {
|
|
50
|
+
data: Boolean
|
|
51
|
+
error: AcoError
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
enum AcoSortDirection {
|
|
55
|
+
ASC
|
|
56
|
+
DESC
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input AcoSort {
|
|
60
|
+
id: AcoSortDirection
|
|
61
|
+
createdOn: AcoSortDirection
|
|
62
|
+
savedOn: AcoSortDirection
|
|
63
|
+
title: AcoSortDirection
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
extend type Query {
|
|
67
|
+
aco: AcoQuery
|
|
68
|
+
search: SearchQuery
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
extend type Mutation {
|
|
72
|
+
aco: AcoMutation
|
|
73
|
+
search: SearchMutation
|
|
74
|
+
}
|
|
75
|
+
`,
|
|
76
|
+
resolvers: {
|
|
77
|
+
Query: {
|
|
78
|
+
aco: emptyResolver,
|
|
79
|
+
search: emptyResolver
|
|
80
|
+
},
|
|
81
|
+
Mutation: {
|
|
82
|
+
aco: emptyResolver,
|
|
83
|
+
search: emptyResolver
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const createAcoGraphQL = () => {
|
|
88
|
+
return new _api.ContextPlugin(context => {
|
|
89
|
+
context.plugins.register([baseSchema, _folder.folderSchema, _record.searchRecordSchema]);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
exports.createAcoGraphQL = createAcoGraphQL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","aco","search","Mutation","createAcoGraphQL","ContextPlugin","context","plugins","register","folderSchema","searchRecordSchema"],"sources":["createAcoGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nimport { folderSchema } from \"~/folder/folder.gql\";\nimport { searchRecordSchema } from \"~/record/record.gql\";\n\nimport { AcoContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type AcoQuery {\n _empty: String\n }\n\n type AcoMutation {\n _empty: String\n }\n\n type SearchQuery {\n _empty: String\n }\n\n type SearchMutation {\n _empty: String\n }\n\n type AcoMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n\n type AcoUser {\n id: ID\n displayName: String\n type: String\n }\n\n type AcoError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AcoBooleanResponse {\n data: Boolean\n error: AcoError\n }\n\n enum AcoSortDirection {\n ASC\n DESC\n }\n\n input AcoSort {\n id: AcoSortDirection\n createdOn: AcoSortDirection\n savedOn: AcoSortDirection\n title: AcoSortDirection\n }\n\n extend type Query {\n aco: AcoQuery\n search: SearchQuery\n }\n\n extend type Mutation {\n aco: AcoMutation\n search: SearchMutation\n }\n `,\n resolvers: {\n Query: {\n aco: emptyResolver,\n search: emptyResolver\n },\n Mutation: {\n aco: emptyResolver,\n search: emptyResolver\n }\n }\n});\n\nexport const createAcoGraphQL = () => {\n return new ContextPlugin<AcoContext>(context => {\n context.plugins.register([baseSchema, folderSchema, searchRecordSchema]);\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AACA;AAIA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ,CAAC;IACDQ,QAAQ,EAAE;MACNF,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ;EACJ;AACJ,CAAC,CAAC;AAEK,MAAMS,gBAAgB,GAAG,MAAM;EAClC,OAAO,IAAIC,kBAAa,CAAaC,OAAO,IAAI;IAC5CA,OAAO,CAACC,OAAO,CAACC,QAAQ,CAAC,CAACZ,UAAU,EAAEa,oBAAY,EAAEC,0BAAkB,CAAC,CAAC;EAC5E,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAcoHooks = void 0;
|
|
7
|
+
var _onFolderBeforeDelete = require("./folder/onFolderBeforeDelete.hook");
|
|
8
|
+
const createAcoHooks = context => {
|
|
9
|
+
(0, _onFolderBeforeDelete.onFolderBeforeDeleteHook)(context);
|
|
10
|
+
};
|
|
11
|
+
exports.createAcoHooks = createAcoHooks;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAcoHooks","context","onFolderBeforeDeleteHook"],"sources":["createAcoHooks.ts"],"sourcesContent":["import { onFolderBeforeDeleteHook } from \"~/folder/onFolderBeforeDelete.hook\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const createAcoHooks = (context: AcoContext) => {\n onFolderBeforeDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA;AAIO,MAAMA,cAAc,GAAIC,OAAmB,IAAK;EACnD,IAAAC,8CAAwB,EAACD,OAAO,CAAC;AACrC,CAAC;AAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createAcoModels = void 0;
|
|
8
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
var _folder = require("./folder/folder.model");
|
|
11
|
+
var _record = require("./record/record.model");
|
|
12
|
+
var _modelFactory = require("./utils/modelFactory");
|
|
13
|
+
var _isInstallationPending = require("./utils/isInstallationPending");
|
|
14
|
+
const createAcoModels = context => {
|
|
15
|
+
/**
|
|
16
|
+
* This should never happen in the actual project.
|
|
17
|
+
* It is to make sure that we load setup context before the CRUD init in our internal code.
|
|
18
|
+
*/
|
|
19
|
+
if (!context.cms) {
|
|
20
|
+
console.warn("Creating model before cms init.");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if ((0, _isInstallationPending.isInstallationPending)({
|
|
24
|
+
tenancy: context.tenancy,
|
|
25
|
+
i18n: context.i18n
|
|
26
|
+
})) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const locale = context.i18n.getContentLocale();
|
|
30
|
+
if (!locale) {
|
|
31
|
+
throw new _error.default("Missing content locale in api-aco/storageOperations/index.ts", "LOCALE_ERROR");
|
|
32
|
+
}
|
|
33
|
+
const groupId = "contentModelGroup_aco";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Create a CmsGroup.
|
|
37
|
+
*/
|
|
38
|
+
const cmsGroupPlugin = new _apiHeadlessCms.CmsGroupPlugin({
|
|
39
|
+
id: groupId,
|
|
40
|
+
slug: "aco",
|
|
41
|
+
name: "ACO",
|
|
42
|
+
description: "Group for Advanced Content Organisation and Search",
|
|
43
|
+
icon: "fas/folder",
|
|
44
|
+
isPrivate: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create CmsModel plugins.
|
|
49
|
+
*/
|
|
50
|
+
const modelDefinitions = [(0, _folder.createFolderModelDefinition)(), (0, _record.createSearchModelDefinition)()];
|
|
51
|
+
const cmsModelPlugins = modelDefinitions.map(modelDefinition => {
|
|
52
|
+
return (0, _modelFactory.modelFactory)({
|
|
53
|
+
group: cmsGroupPlugin.contentModelGroup,
|
|
54
|
+
tenant: context.tenancy.getCurrentTenant().id,
|
|
55
|
+
locale: locale.code,
|
|
56
|
+
modelDefinition
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Register them so that they are accessible in cms context
|
|
62
|
+
*/
|
|
63
|
+
context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);
|
|
64
|
+
};
|
|
65
|
+
exports.createAcoModels = createAcoModels;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAcoModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","modelDefinitions","createFolderModelDefinition","createSearchModelDefinition","cmsModelPlugins","map","modelDefinition","modelFactory","group","contentModelGroup","tenant","getCurrentTenant","code","plugins","register"],"sources":["createAcoModels.ts"],"sourcesContent":["import { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createFolderModelDefinition } from \"~/folder/folder.model\";\nimport { createSearchModelDefinition } from \"~/record/record.model\";\nimport { modelFactory } from \"~/utils/modelFactory\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\n\nexport const createAcoModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n const groupId = \"contentModelGroup_aco\";\n\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"aco\",\n name: \"ACO\",\n description: \"Group for Advanced Content Organisation and Search\",\n icon: \"fas/folder\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const modelDefinitions = [createFolderModelDefinition(), createSearchModelDefinition()];\n const cmsModelPlugins = modelDefinitions.map(modelDefinition => {\n return modelFactory({\n group: cmsGroupPlugin.contentModelGroup,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: locale.code,\n modelDefinition\n });\n });\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AAEO,MAAMA,eAAe,GAAIC,OAAmB,IAAK;EACpD;AACJ;AACA;AACA;EACI,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,iCAAiC,CAAC;IAC/C;EACJ;EAEA,IAAI,IAAAC,4CAAqB,EAAC;IAAEC,OAAO,EAAEL,OAAO,CAACK,OAAO;IAAEC,IAAI,EAAEN,OAAO,CAACM;EAAK,CAAC,CAAC,EAAE;IACzE;EACJ;EAEA,MAAMC,MAAM,GAAGP,OAAO,CAACM,IAAI,CAACE,gBAAgB,EAAE;EAC9C,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CACjB,8DAA8D,EAC9D,cAAc,CACjB;EACL;EAEA,MAAMC,OAAO,GAAG,uBAAuB;;EAEvC;AACJ;AACA;EACI,MAAMC,cAAc,GAAG,IAAIC,8BAAc,CAAC;IACtCC,EAAE,EAAEH,OAAO;IACXI,IAAI,EAAE,KAAK;IACXC,IAAI,EAAE,KAAK;IACXC,WAAW,EAAE,oDAAoD;IACjEC,IAAI,EAAE,YAAY;IAClBC,SAAS,EAAE;EACf,CAAC,CAAC;;EAEF;AACJ;AACA;EACI,MAAMC,gBAAgB,GAAG,CAAC,IAAAC,mCAA2B,GAAE,EAAE,IAAAC,mCAA2B,GAAE,CAAC;EACvF,MAAMC,eAAe,GAAGH,gBAAgB,CAACI,GAAG,CAACC,eAAe,IAAI;IAC5D,OAAO,IAAAC,0BAAY,EAAC;MAChBC,KAAK,EAAEf,cAAc,CAACgB,iBAAiB;MACvCC,MAAM,EAAE5B,OAAO,CAACK,OAAO,CAACwB,gBAAgB,EAAE,CAAChB,EAAE;MAC7CN,MAAM,EAAEA,MAAM,CAACuB,IAAI;MACnBN;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;EACIxB,OAAO,CAAC+B,OAAO,CAACC,QAAQ,CAAC,CAACrB,cAAc,EAAEW,eAAe,CAAC,CAAC;AAC/D,CAAC;AAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CmsContext, HeadlessCms } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { Security } from "@webiny/api-security/types";
|
|
3
|
+
import { AcoStorageOperations } from "./types";
|
|
4
|
+
export interface CreateAcoStorageOperationsParams {
|
|
5
|
+
cms: HeadlessCms;
|
|
6
|
+
security: Security;
|
|
7
|
+
getCmsContext: () => CmsContext;
|
|
8
|
+
}
|
|
9
|
+
export declare const baseFields: string[];
|
|
10
|
+
export declare const createAcoStorageOperations: (params: CreateAcoStorageOperationsParams) => AcoStorageOperations;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createAcoStorageOperations = exports.baseFields = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _folder = require("./folder/folder.so");
|
|
10
|
+
var _record = require("./record/record.so");
|
|
11
|
+
var _createAcoModels = require("./createAcoModels");
|
|
12
|
+
const baseFields = ["id", "entryId", "createdBy", "createdOn", "savedOn"];
|
|
13
|
+
exports.baseFields = baseFields;
|
|
14
|
+
const createAcoStorageOperations = params => {
|
|
15
|
+
const context = params.getCmsContext();
|
|
16
|
+
(0, _createAcoModels.createAcoModels)(context);
|
|
17
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _folder.createFolderOperations)(params)), (0, _record.createSearchRecordOperations)(params));
|
|
18
|
+
};
|
|
19
|
+
exports.createAcoStorageOperations = createAcoStorageOperations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["baseFields","createAcoStorageOperations","params","context","getCmsContext","createAcoModels","createFolderOperations","createSearchRecordOperations"],"sources":["createAcoStorageOperations.ts"],"sourcesContent":["import { CmsContext, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\nimport { createFolderOperations } from \"~/folder/folder.so\";\nimport { createSearchRecordOperations } from \"~/record/record.so\";\nimport { createAcoModels } from \"~/createAcoModels\";\n\nimport { AcoStorageOperations } from \"~/types\";\n\nexport interface CreateAcoStorageOperationsParams {\n cms: HeadlessCms;\n security: Security;\n getCmsContext: () => CmsContext;\n}\n\nexport const baseFields = [\"id\", \"entryId\", \"createdBy\", \"createdOn\", \"savedOn\"];\n\nexport const createAcoStorageOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoStorageOperations => {\n const context = params.getCmsContext();\n\n createAcoModels(context);\n\n return {\n ...createFolderOperations(params),\n ...createSearchRecordOperations(params)\n };\n};\n"],"mappings":";;;;;;;;AAGA;AACA;AACA;AAUO,MAAMA,UAAU,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,CAAC;AAAC;AAE1E,MAAMC,0BAA0B,GACnCC,MAAwC,IACjB;EACvB,MAAMC,OAAO,GAAGD,MAAM,CAACE,aAAa,EAAE;EAEtC,IAAAC,gCAAe,EAACF,OAAO,CAAC;EAExB,mEACO,IAAAG,8BAAsB,EAACJ,MAAM,CAAC,GAC9B,IAAAK,oCAA4B,EAACL,MAAM,CAAC;AAE/C,CAAC;AAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFolderCrudMethods = void 0;
|
|
7
|
+
var _pubsub = require("@webiny/pubsub");
|
|
8
|
+
const createFolderCrudMethods = ({
|
|
9
|
+
storageOperations
|
|
10
|
+
}) => {
|
|
11
|
+
// create
|
|
12
|
+
const onFolderBeforeCreate = (0, _pubsub.createTopic)("aco.onFolderBeforeCreate");
|
|
13
|
+
const onFolderAfterCreate = (0, _pubsub.createTopic)("aco.onFolderAfterCreate");
|
|
14
|
+
// update
|
|
15
|
+
const onFolderBeforeUpdate = (0, _pubsub.createTopic)("aco.onFolderBeforeUpdate");
|
|
16
|
+
const onFolderAfterUpdate = (0, _pubsub.createTopic)("aco.onFolderAfterUpdate");
|
|
17
|
+
// delete
|
|
18
|
+
const onFolderBeforeDelete = (0, _pubsub.createTopic)("aco.onFolderBeforeDelete");
|
|
19
|
+
const onFolderAfterDelete = (0, _pubsub.createTopic)("aco.onFolderAfterDelete");
|
|
20
|
+
return {
|
|
21
|
+
/**
|
|
22
|
+
* Lifecycle events
|
|
23
|
+
*/
|
|
24
|
+
onFolderBeforeCreate,
|
|
25
|
+
onFolderAfterCreate,
|
|
26
|
+
onFolderBeforeUpdate,
|
|
27
|
+
onFolderAfterUpdate,
|
|
28
|
+
onFolderBeforeDelete,
|
|
29
|
+
onFolderAfterDelete,
|
|
30
|
+
async get(id) {
|
|
31
|
+
return storageOperations.getFolder({
|
|
32
|
+
id
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
async list(params) {
|
|
36
|
+
return storageOperations.listFolders(params);
|
|
37
|
+
},
|
|
38
|
+
async create(data) {
|
|
39
|
+
await onFolderBeforeCreate.publish({
|
|
40
|
+
input: data
|
|
41
|
+
});
|
|
42
|
+
const folder = await storageOperations.createFolder({
|
|
43
|
+
data
|
|
44
|
+
});
|
|
45
|
+
await onFolderAfterCreate.publish({
|
|
46
|
+
folder
|
|
47
|
+
});
|
|
48
|
+
return folder;
|
|
49
|
+
},
|
|
50
|
+
async update(id, data) {
|
|
51
|
+
const original = await storageOperations.getFolder({
|
|
52
|
+
id
|
|
53
|
+
});
|
|
54
|
+
await onFolderBeforeUpdate.publish({
|
|
55
|
+
original,
|
|
56
|
+
input: {
|
|
57
|
+
id,
|
|
58
|
+
data
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const folder = await storageOperations.updateFolder({
|
|
62
|
+
id,
|
|
63
|
+
data
|
|
64
|
+
});
|
|
65
|
+
await onFolderAfterUpdate.publish({
|
|
66
|
+
original,
|
|
67
|
+
input: {
|
|
68
|
+
id,
|
|
69
|
+
data
|
|
70
|
+
},
|
|
71
|
+
folder
|
|
72
|
+
});
|
|
73
|
+
return folder;
|
|
74
|
+
},
|
|
75
|
+
async delete(id) {
|
|
76
|
+
const folder = await storageOperations.getFolder({
|
|
77
|
+
id
|
|
78
|
+
});
|
|
79
|
+
await onFolderBeforeDelete.publish({
|
|
80
|
+
folder
|
|
81
|
+
});
|
|
82
|
+
await storageOperations.deleteFolder({
|
|
83
|
+
id
|
|
84
|
+
});
|
|
85
|
+
await onFolderAfterDelete.publish({
|
|
86
|
+
folder
|
|
87
|
+
});
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
exports.createFolderCrudMethods = createFolderCrudMethods;
|
|
@@ -0,0 +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;AAaO,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,CAAC;QAAEE;MAAO,CAAC,CAAC;MAC7C,OAAOA,MAAM;IACjB,CAAC;IACD,MAAME,MAAM,CAACX,EAAE,EAAEM,IAAI,EAAE;MACnB,MAAMM,QAAQ,GAAG,MAAMrB,iBAAiB,CAACU,SAAS,CAAC;QAAED;MAAG,CAAC,CAAC;MAC1D,MAAML,oBAAoB,CAACY,OAAO,CAAC;QAAEK,QAAQ;QAAEJ,KAAK,EAAE;UAAER,EAAE;UAAEM;QAAK;MAAE,CAAC,CAAC;MACrE,MAAMG,MAAM,GAAG,MAAMlB,iBAAiB,CAACsB,YAAY,CAAC;QAAEb,EAAE;QAAEM;MAAK,CAAC,CAAC;MACjE,MAAMV,mBAAmB,CAACW,OAAO,CAAC;QAAEK,QAAQ;QAAEJ,KAAK,EAAE;UAAER,EAAE;UAAEM;QAAK,CAAC;QAAEG;MAAO,CAAC,CAAC;MAC5E,OAAOA,MAAM;IACjB,CAAC;IACD,MAAMK,MAAM,CAACd,EAAU,EAAE;MACrB,MAAMS,MAAM,GAAG,MAAMlB,iBAAiB,CAACU,SAAS,CAAC;QAAED;MAAG,CAAC,CAAC;MACxD,MAAMH,oBAAoB,CAACU,OAAO,CAAC;QAAEE;MAAO,CAAC,CAAC;MAC9C,MAAMlB,iBAAiB,CAACwB,YAAY,CAAC;QAAEf;MAAG,CAAC,CAAC;MAC5C,MAAMF,mBAAmB,CAACS,OAAO,CAAC;QAAEE;MAAO,CAAC,CAAC;MAC7C,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.folderSchema = void 0;
|
|
7
|
+
var _responses = require("@webiny/handler-graphql/responses");
|
|
8
|
+
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
9
|
+
var _resolve = require("../utils/resolve");
|
|
10
|
+
const folderSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
11
|
+
typeDefs: /* GraphQL */`
|
|
12
|
+
type Folder {
|
|
13
|
+
id: ID!
|
|
14
|
+
title: String!
|
|
15
|
+
slug: String!
|
|
16
|
+
type: String!
|
|
17
|
+
parentId: ID
|
|
18
|
+
savedOn: DateTime
|
|
19
|
+
createdOn: DateTime
|
|
20
|
+
createdBy: AcoUser
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
input FolderCreateInput {
|
|
24
|
+
title: String!
|
|
25
|
+
slug: String!
|
|
26
|
+
type: String!
|
|
27
|
+
parentId: ID
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
input FolderUpdateInput {
|
|
31
|
+
title: String
|
|
32
|
+
slug: String
|
|
33
|
+
parentId: ID
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
input FoldersListWhereInput {
|
|
37
|
+
type: String!
|
|
38
|
+
parentId: String
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type FolderResponse {
|
|
42
|
+
data: Folder
|
|
43
|
+
error: AcoError
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type FoldersListResponse {
|
|
47
|
+
data: [Folder]
|
|
48
|
+
error: AcoError
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
extend type AcoQuery {
|
|
52
|
+
getFolder(id: ID!): FolderResponse
|
|
53
|
+
listFolders(
|
|
54
|
+
where: FoldersListWhereInput!
|
|
55
|
+
limit: Int
|
|
56
|
+
after: String
|
|
57
|
+
sort: AcoSort
|
|
58
|
+
): FoldersListResponse
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
extend type AcoMutation {
|
|
62
|
+
createFolder(data: FolderCreateInput!): FolderResponse
|
|
63
|
+
updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse
|
|
64
|
+
deleteFolder(id: ID!): AcoBooleanResponse
|
|
65
|
+
}
|
|
66
|
+
`,
|
|
67
|
+
resolvers: {
|
|
68
|
+
AcoQuery: {
|
|
69
|
+
getFolder: async (_, {
|
|
70
|
+
id
|
|
71
|
+
}, context) => {
|
|
72
|
+
return (0, _resolve.resolve)(() => context.aco.folder.get(id));
|
|
73
|
+
},
|
|
74
|
+
listFolders: async (_, args, context) => {
|
|
75
|
+
try {
|
|
76
|
+
const [entries, meta] = await context.aco.folder.list(args);
|
|
77
|
+
return new _responses.ListResponse(entries, meta);
|
|
78
|
+
} catch (e) {
|
|
79
|
+
return new _responses.ErrorResponse(e);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
AcoMutation: {
|
|
84
|
+
createFolder: async (_, {
|
|
85
|
+
data
|
|
86
|
+
}, context) => {
|
|
87
|
+
return (0, _resolve.resolve)(() => context.aco.folder.create(data));
|
|
88
|
+
},
|
|
89
|
+
updateFolder: async (_, {
|
|
90
|
+
id,
|
|
91
|
+
data
|
|
92
|
+
}, context) => {
|
|
93
|
+
return (0, _resolve.resolve)(() => context.aco.folder.update(id, data));
|
|
94
|
+
},
|
|
95
|
+
deleteFolder: async (_, {
|
|
96
|
+
id
|
|
97
|
+
}, context) => {
|
|
98
|
+
return (0, _resolve.resolve)(() => context.aco.folder.delete(id));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
exports.folderSchema = folderSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["folderSchema","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getFolder","_","id","context","resolve","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 { 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 }\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(() => context.aco.folder.get(id));\n },\n listFolders: async (_, args: any, context) => {\n try {\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(() => context.aco.folder.create(data));\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(() => context.aco.folder.update(id, data));\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(() => context.aco.folder.delete(id));\n }\n }\n }\n});\n"],"mappings":";;;;;;AAAA;AACA;AAEA;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,KAAK;EACDC,SAAS,EAAE;IACPC,QAAQ,EAAE;MACNC,SAAS,EAAE,OAAOC,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACrC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACC,GAAG,CAACL,EAAE,CAAC,CAAC;MACpD,CAAC;MACDM,WAAW,EAAE,OAAOP,CAAC,EAAEQ,IAAS,EAAEN,OAAO,KAAK;QAC1C,IAAI;UACA,MAAM,CAACO,OAAO,EAAEC,IAAI,CAAC,GAAG,MAAMR,OAAO,CAACE,GAAG,CAACC,MAAM,CAACM,IAAI,CAACH,IAAI,CAAC;UAC3D,OAAO,IAAII,uBAAY,CAACH,OAAO,EAAEC,IAAI,CAAC;QAC1C,CAAC,CAAC,OAAOG,CAAC,EAAE;UACR,OAAO,IAAIC,wBAAa,CAACD,CAAC,CAAC;QAC/B;MACJ;IACJ,CAAC;IACDE,WAAW,EAAE;MACTC,YAAY,EAAE,OAAOhB,CAAC,EAAE;QAAEiB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACa,MAAM,CAACD,IAAI,CAAC,CAAC;MACzD,CAAC;MACDE,YAAY,EAAE,OAAOnB,CAAC,EAAE;QAAEC,EAAE;QAAEgB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC9C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACe,MAAM,CAACnB,EAAE,EAAEgB,IAAI,CAAC,CAAC;MAC7D,CAAC;MACDI,YAAY,EAAE,OAAOrB,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACxC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACiB,MAAM,CAACrB,EAAE,CAAC,CAAC;MACvD;IACJ;EACJ;AACJ,CAAC,CAAC;AAAC"}
|