@webiny/api-aco 0.0.0-unstable.aad28a72ae → 0.0.0-unstable.bca7b3e350

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.
Files changed (79) hide show
  1. package/README.md +15 -0
  2. package/createAcoContext.d.ts +3 -0
  3. package/createAcoContext.js +63 -0
  4. package/createAcoContext.js.map +1 -0
  5. package/createAcoCrud.d.ts +2 -0
  6. package/createAcoCrud.js +17 -0
  7. package/createAcoCrud.js.map +1 -0
  8. package/createAcoFields.d.ts +2 -0
  9. package/createAcoFields.js +40 -0
  10. package/createAcoFields.js.map +1 -0
  11. package/createAcoGraphQL.d.ts +3 -0
  12. package/createAcoGraphQL.js +91 -0
  13. package/createAcoGraphQL.js.map +1 -0
  14. package/createAcoHooks.d.ts +2 -0
  15. package/createAcoHooks.js +11 -0
  16. package/createAcoHooks.js.map +1 -0
  17. package/createAcoModels.d.ts +2 -0
  18. package/createAcoModels.js +67 -0
  19. package/createAcoModels.js.map +1 -0
  20. package/createAcoStorageOperations.d.ts +10 -0
  21. package/createAcoStorageOperations.js +19 -0
  22. package/createAcoStorageOperations.js.map +1 -0
  23. package/folder/folder.crud.d.ts +3 -0
  24. package/folder/folder.crud.js +92 -0
  25. package/folder/folder.crud.js.map +1 -0
  26. package/folder/folder.gql.d.ts +3 -0
  27. package/folder/folder.gql.js +103 -0
  28. package/folder/folder.gql.js.map +1 -0
  29. package/folder/folder.model.d.ts +4 -0
  30. package/folder/folder.model.js +79 -0
  31. package/folder/folder.model.js.map +1 -0
  32. package/folder/folder.so.d.ts +8 -0
  33. package/folder/folder.so.js +156 -0
  34. package/folder/folder.so.js.map +1 -0
  35. package/folder/folder.types.d.ts +83 -0
  36. package/folder/folder.types.js +5 -0
  37. package/folder/folder.types.js.map +1 -0
  38. package/folder/onFolderBeforeDelete.hook.d.ts +2 -0
  39. package/folder/onFolderBeforeDelete.hook.js +53 -0
  40. package/folder/onFolderBeforeDelete.hook.js.map +1 -0
  41. package/index.d.ts +1 -9
  42. package/index.js +7 -64
  43. package/index.js.map +1 -1
  44. package/package.json +22 -20
  45. package/record/record.crud.d.ts +3 -0
  46. package/record/record.crud.js +92 -0
  47. package/record/record.crud.js.map +1 -0
  48. package/record/record.gql.d.ts +3 -0
  49. package/record/record.gql.js +118 -0
  50. package/record/record.gql.js.map +1 -0
  51. package/record/record.model.d.ts +4 -0
  52. package/record/record.model.js +75 -0
  53. package/record/record.model.js.map +1 -0
  54. package/record/record.so.d.ts +8 -0
  55. package/record/record.so.js +100 -0
  56. package/record/record.so.js.map +1 -0
  57. package/record/record.types.d.ts +92 -0
  58. package/record/record.types.js +5 -0
  59. package/record/record.types.js.map +1 -0
  60. package/types.d.ts +20 -201
  61. package/types.js.map +1 -1
  62. package/utils/createModelField.d.ts +6 -0
  63. package/utils/createModelField.js +39 -0
  64. package/utils/createModelField.js.map +1 -0
  65. package/utils/fieldResolver.d.ts +16 -0
  66. package/utils/fieldResolver.js +44 -0
  67. package/utils/fieldResolver.js.map +1 -0
  68. package/utils/getFieldValues.d.ts +2 -0
  69. package/utils/getFieldValues.js +12 -0
  70. package/utils/getFieldValues.js.map +1 -0
  71. package/utils/isInstallationPending.d.ts +4 -0
  72. package/utils/isInstallationPending.js +21 -0
  73. package/utils/isInstallationPending.js.map +1 -0
  74. package/utils/modelFactory.d.ts +15 -0
  75. package/utils/modelFactory.js +23 -0
  76. package/utils/modelFactory.js.map +1 -0
  77. package/utils/resolve.d.ts +2 -0
  78. package/utils/resolve.js +15 -0
  79. package/utils/resolve.js.map +1 -0
@@ -0,0 +1,4 @@
1
+ import { CmsModel } from "@webiny/api-headless-cms/types";
2
+ export declare type FolderModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate">;
3
+ export declare const FOLDER_MODEL_ID = "acoFolderModelDefinition";
4
+ export declare const createFolderModelDefinition: () => FolderModelDefinition;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFolderModelDefinition = exports.FOLDER_MODEL_ID = void 0;
7
+ var _createModelField = require("../utils/createModelField");
8
+ const titleField = () => (0, _createModelField.createModelField)({
9
+ label: "Title",
10
+ type: "text",
11
+ parent: "folder",
12
+ validation: [{
13
+ name: "required",
14
+ message: "Value is required."
15
+ }, {
16
+ name: "minLength",
17
+ settings: {
18
+ value: "3"
19
+ },
20
+ message: "Value is too short."
21
+ }]
22
+ });
23
+ const slugField = () => (0, _createModelField.createModelField)({
24
+ label: "Slug",
25
+ type: "text",
26
+ parent: "folder",
27
+ validation: [{
28
+ name: "required",
29
+ message: "Value is required."
30
+ }, {
31
+ name: "minLength",
32
+ settings: {
33
+ value: "3"
34
+ },
35
+ message: "Value is too short."
36
+ }, {
37
+ name: "maxLength",
38
+ settings: {
39
+ value: "100"
40
+ },
41
+ message: "Value is too long."
42
+ }, {
43
+ name: "pattern",
44
+ settings: {
45
+ preset: "custom",
46
+ regex: "^[a-z0-9]+(-[a-z0-9]+)*$",
47
+ flags: "g"
48
+ },
49
+ message: "Value must consist of only 'a-z', '0-9' and '-'."
50
+ }]
51
+ });
52
+ const typeField = () => (0, _createModelField.createModelField)({
53
+ label: "Type",
54
+ type: "text",
55
+ parent: "folder",
56
+ validation: [{
57
+ name: "required",
58
+ message: "Value is required."
59
+ }]
60
+ });
61
+ const parentIdField = () => (0, _createModelField.createModelField)({
62
+ label: "Parent Id",
63
+ type: "text",
64
+ parent: "folder"
65
+ });
66
+ const FOLDER_MODEL_ID = "acoFolderModelDefinition";
67
+ exports.FOLDER_MODEL_ID = FOLDER_MODEL_ID;
68
+ const createFolderModelDefinition = () => {
69
+ return {
70
+ name: "ACO - Folder",
71
+ modelId: FOLDER_MODEL_ID,
72
+ titleFieldId: "title",
73
+ layout: [["folder_title"], ["folder_slug"], ["folder_type"], ["folder_parentId"]],
74
+ fields: [titleField(), slugField(), typeField(), parentIdField()],
75
+ description: "ACO - Folder content model",
76
+ isPrivate: true
77
+ };
78
+ };
79
+ exports.createFolderModelDefinition = createFolderModelDefinition;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["titleField","createModelField","label","type","parent","validation","name","message","settings","value","slugField","preset","regex","flags","typeField","parentIdField","FOLDER_MODEL_ID","createFolderModelDefinition","modelId","titleFieldId","layout","fields","description","isPrivate"],"sources":["folder.model.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nimport { createModelField } from \"~/utils/createModelField\";\n\nexport type FolderModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n>;\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n }\n ]\n });\n\nconst slugField = () =>\n createModelField({\n label: \"Slug\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n },\n {\n name: \"maxLength\",\n settings: {\n value: \"100\"\n },\n message: \"Value is too long.\"\n },\n {\n name: \"pattern\",\n settings: {\n preset: \"custom\",\n regex: \"^[a-z0-9]+(-[a-z0-9]+)*$\",\n flags: \"g\"\n },\n message: \"Value must consist of only 'a-z', '0-9' and '-'.\"\n }\n ]\n });\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst parentIdField = () =>\n createModelField({\n label: \"Parent Id\",\n type: \"text\",\n parent: \"folder\"\n });\n\nexport const FOLDER_MODEL_ID = \"acoFolderModelDefinition\";\n\nexport const createFolderModelDefinition = (): FolderModelDefinition => {\n return {\n name: \"ACO - Folder\",\n modelId: FOLDER_MODEL_ID,\n titleFieldId: \"title\",\n layout: [[\"folder_title\"], [\"folder_slug\"], [\"folder_type\"], [\"folder_parentId\"]],\n fields: [titleField(), slugField(), typeField(), parentIdField()],\n description: \"ACO - Folder content model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AAEA;AAOA,MAAMA,UAAU,GAAG,MACf,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMG,SAAS,GAAG,MACd,IAAAT,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,SAAS;IACfE,QAAQ,EAAE;MACNG,MAAM,EAAE,QAAQ;MAChBC,KAAK,EAAE,0BAA0B;MACjCC,KAAK,EAAE;IACX,CAAC;IACDN,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMO,SAAS,GAAG,MACd,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,aAAa,GAAG,MAClB,IAAAd,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEC,MAAMY,eAAe,GAAG,0BAA0B;AAAC;AAEnD,MAAMC,2BAA2B,GAAG,MAA6B;EACpE,OAAO;IACHX,IAAI,EAAE,cAAc;IACpBY,OAAO,EAAEF,eAAe;IACxBG,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACjFC,MAAM,EAAE,CAACrB,UAAU,EAAE,EAAEU,SAAS,EAAE,EAAEI,SAAS,EAAE,EAAEC,aAAa,EAAE,CAAC;IACjEO,WAAW,EAAE,4BAA4B;IACzCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
@@ -0,0 +1,8 @@
1
+ import { CmsModel } from "@webiny/api-headless-cms/types";
2
+ import { CreateAcoStorageOperationsParams } from "../createAcoStorageOperations";
3
+ import { AcoFolderStorageOperations as BaseAcoFolderStorageOperations } from "./folder.types";
4
+ interface AcoFolderStorageOperations extends BaseAcoFolderStorageOperations {
5
+ getFolderModel(): Promise<CmsModel>;
6
+ }
7
+ export declare const createFolderOperations: (params: CreateAcoStorageOperationsParams) => AcoFolderStorageOperations;
8
+ export {};
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createFolderOperations = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ var _folder = require("./folder.model");
11
+ var _createAcoStorageOperations = require("../createAcoStorageOperations");
12
+ var _getFieldValues = require("../utils/getFieldValues");
13
+ const createFolderOperations = params => {
14
+ const {
15
+ cms,
16
+ security
17
+ } = params;
18
+ const getFolderModel = async () => {
19
+ security.disableAuthorization();
20
+ const model = await cms.getModel(_folder.FOLDER_MODEL_ID);
21
+ security.enableAuthorization();
22
+ if (!model) {
23
+ throw new _error.default(`Could not find "${_folder.FOLDER_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
24
+ }
25
+ return model;
26
+ };
27
+ const getFolder = async ({
28
+ id,
29
+ slug,
30
+ type,
31
+ parentId
32
+ }) => {
33
+ const model = await getFolderModel();
34
+ security.disableAuthorization();
35
+ let entry;
36
+ if (id) {
37
+ entry = await cms.getEntryById(model, id);
38
+ } else if (slug && type) {
39
+ entry = await cms.getEntry(model, {
40
+ where: {
41
+ slug,
42
+ type,
43
+ parentId,
44
+ latest: true
45
+ }
46
+ });
47
+ }
48
+ if (!entry) {
49
+ throw new _error.default("Could not load folder.", "GET_FOLDER_ERROR", {
50
+ id,
51
+ slug,
52
+ type,
53
+ parentId
54
+ });
55
+ }
56
+ security.enableAuthorization();
57
+ return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
58
+ };
59
+ const checkExistingFolder = async ({
60
+ id,
61
+ params
62
+ }) => {
63
+ const model = await getFolderModel();
64
+ security.disableAuthorization();
65
+ const {
66
+ type,
67
+ slug,
68
+ parentId
69
+ } = params;
70
+ const [existings] = await cms.listLatestEntries(model, {
71
+ where: {
72
+ type,
73
+ slug,
74
+ parentId,
75
+ id_not: id
76
+ },
77
+ limit: 1
78
+ });
79
+ if (existings.length > 0) {
80
+ throw new _error.default(`Folder with slug "${slug}" already exists at this level.`, "FOLDER_ALREADY_EXISTS", {
81
+ id,
82
+ params
83
+ });
84
+ }
85
+ security.enableAuthorization();
86
+ return;
87
+ };
88
+ return {
89
+ getFolderModel,
90
+ getFolder,
91
+ async listFolders(params) {
92
+ const model = await getFolderModel();
93
+ security.disableAuthorization();
94
+ const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
95
+ where: (0, _objectSpread2.default)({}, params.where || {})
96
+ }));
97
+ security.enableAuthorization();
98
+ return [entries.map(entry => (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields)), meta];
99
+ },
100
+ async createFolder({
101
+ data
102
+ }) {
103
+ const model = await getFolderModel();
104
+ security.disableAuthorization();
105
+ await checkExistingFolder({
106
+ params: {
107
+ type: data.type,
108
+ slug: data.slug,
109
+ parentId: data.parentId
110
+ }
111
+ });
112
+ const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
113
+ parentId: data.parentId || null
114
+ }));
115
+ security.enableAuthorization();
116
+ return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
117
+ },
118
+ async updateFolder({
119
+ id,
120
+ data
121
+ }) {
122
+ const {
123
+ slug,
124
+ parentId
125
+ } = data;
126
+ const model = await getFolderModel();
127
+ security.disableAuthorization();
128
+ const original = await getFolder({
129
+ id
130
+ });
131
+ await checkExistingFolder({
132
+ id,
133
+ params: {
134
+ type: original.type,
135
+ slug: slug || original.slug,
136
+ parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`
137
+ }
138
+ });
139
+
140
+ const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
141
+ const entry = await cms.updateEntry(model, id, input);
142
+ security.enableAuthorization();
143
+ return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
144
+ },
145
+ async deleteFolder({
146
+ id
147
+ }) {
148
+ const model = await getFolderModel();
149
+ security.disableAuthorization();
150
+ await cms.deleteEntry(model, id);
151
+ security.enableAuthorization();
152
+ return true;
153
+ }
154
+ };
155
+ };
156
+ exports.createFolderOperations = createFolderOperations;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFolderOperations","params","cms","security","getFolderModel","disableAuthorization","model","getModel","FOLDER_MODEL_ID","enableAuthorization","WebinyError","getFolder","id","slug","type","parentId","entry","getEntryById","getEntry","where","latest","getFieldValues","baseFields","checkExistingFolder","existings","listLatestEntries","id_not","limit","length","listFolders","entries","meta","map","createFolder","data","createEntry","updateFolder","original","undefined","input","updateEntry","deleteFolder","deleteEntry"],"sources":["folder.so.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { FOLDER_MODEL_ID } from \"./folder.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { getFieldValues } from \"~/utils/getFieldValues\";\n\nimport { AcoFolderStorageOperations as BaseAcoFolderStorageOperations } from \"./folder.types\";\n\ninterface AcoFolderStorageOperations extends BaseAcoFolderStorageOperations {\n getFolderModel(): Promise<CmsModel>;\n}\n\ninterface AcoCheckExistingFolderParams {\n params: {\n type: string;\n slug: string;\n parentId?: string | null;\n };\n id?: string;\n}\n\nexport const createFolderOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoFolderStorageOperations => {\n const { cms, security } = params;\n const getFolderModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(FOLDER_MODEL_ID);\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n `Could not find \"${FOLDER_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n\n const getFolder: AcoFolderStorageOperations[\"getFolder\"] = async ({\n id,\n slug,\n type,\n parentId\n }) => {\n const model = await getFolderModel();\n security.disableAuthorization();\n\n let entry;\n\n if (id) {\n entry = await cms.getEntryById(model, id);\n } else if (slug && type) {\n entry = await cms.getEntry(model, { where: { slug, type, parentId, latest: true } });\n }\n\n if (!entry) {\n throw new WebinyError(\"Could not load folder.\", \"GET_FOLDER_ERROR\", {\n id,\n slug,\n type,\n parentId\n });\n }\n\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n };\n\n const checkExistingFolder = async ({ id, params }: AcoCheckExistingFolderParams) => {\n const model = await getFolderModel();\n security.disableAuthorization();\n\n const { type, slug, parentId } = params;\n\n const [existings] = await cms.listLatestEntries(model, {\n where: {\n type,\n slug,\n parentId,\n id_not: id\n },\n limit: 1\n });\n\n if (existings.length > 0) {\n throw new WebinyError(\n `Folder with slug \"${slug}\" already exists at this level.`,\n \"FOLDER_ALREADY_EXISTS\",\n {\n id,\n params\n }\n );\n }\n\n security.enableAuthorization();\n return;\n };\n\n return {\n getFolderModel,\n getFolder,\n async listFolders(params) {\n const model = await getFolderModel();\n security.disableAuthorization();\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...(params.where || {})\n }\n });\n\n security.enableAuthorization();\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createFolder({ data }) {\n const model = await getFolderModel();\n security.disableAuthorization();\n\n await checkExistingFolder({\n params: {\n type: data.type,\n slug: data.slug,\n parentId: data.parentId\n }\n });\n\n const entry = await cms.createEntry(model, {\n ...data,\n parentId: data.parentId || null\n });\n\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async updateFolder({ id, data }) {\n const { slug, parentId } = data;\n const model = await getFolderModel();\n security.disableAuthorization();\n\n const original = await getFolder({ id });\n\n await checkExistingFolder({\n id,\n params: {\n type: original.type,\n slug: slug || original.slug,\n parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`\n }\n });\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(model, id, input);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async deleteFolder({ id }) {\n const model = await getFolderModel();\n security.disableAuthorization();\n\n await cms.deleteEntry(model, id);\n\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AAEA;AACA;AACA;AAiBO,MAAMA,s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EAACL,KAAK,EAAEM,sCAAU,CAAC;IAC5C,CAAC;IACD,MAAMmB,YAAY,CAAC;MAAE7B;IAAG,CAAC,EAAE;MACvB,MAAMN,KAAK,GAAG,MAAMF,cAAc,EAAE;MACpCD,QAAQ,CAACE,oBAAoB,EAAE;MAE/B,MAAMH,GAAG,CAACwC,WAAW,CAACpC,KAAK,EAAEM,EAAE,CAAC;MAEhCT,QAAQ,CAACM,mBAAmB,EAAE;MAC9B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -0,0 +1,83 @@
1
+ import { AcoBaseFields, ListMeta } from "../types";
2
+ import { Topic } from "@webiny/pubsub/types";
3
+ export interface Folder extends AcoBaseFields {
4
+ title: string;
5
+ slug: string;
6
+ type: string;
7
+ parentId?: string | null;
8
+ }
9
+ export interface ListFoldersWhere {
10
+ type: string;
11
+ parentId?: string | null;
12
+ }
13
+ export interface ListFoldersParams {
14
+ where: ListFoldersWhere;
15
+ sort?: string[];
16
+ limit?: number;
17
+ after?: string | null;
18
+ }
19
+ export declare type CreateFolderParams = Pick<Folder, "title" | "slug" | "type" | "parentId">;
20
+ export interface UpdateFolderParams {
21
+ title?: string;
22
+ slug?: string;
23
+ parentId?: string;
24
+ }
25
+ export interface DeleteFolderParams {
26
+ id: string;
27
+ }
28
+ export interface StorageOperationsGetFolderParams {
29
+ id?: string;
30
+ slug?: string;
31
+ type?: string;
32
+ parentId?: string | null;
33
+ }
34
+ export declare type StorageOperationsListFoldersParams = ListFoldersParams;
35
+ export interface StorageOperationsCreateFolderParams {
36
+ data: CreateFolderParams;
37
+ }
38
+ export interface StorageOperationsUpdateFolderParams {
39
+ id: string;
40
+ data: UpdateFolderParams;
41
+ }
42
+ export declare type StorageOperationsDeleteFolderParams = DeleteFolderParams;
43
+ export interface OnFolderBeforeCreateTopicParams {
44
+ input: CreateFolderParams;
45
+ }
46
+ export interface OnFolderAfterCreateTopicParams {
47
+ folder: Folder;
48
+ }
49
+ export interface OnFolderBeforeUpdateTopicParams {
50
+ original: Folder;
51
+ input: Record<string, any>;
52
+ }
53
+ export interface OnFolderAfterUpdateTopicParams {
54
+ original: Folder;
55
+ folder: Folder;
56
+ input: Record<string, any>;
57
+ }
58
+ export interface OnFolderBeforeDeleteTopicParams {
59
+ folder: Folder;
60
+ }
61
+ export interface OnFolderAfterDeleteTopicParams {
62
+ folder: Folder;
63
+ }
64
+ export interface AcoFolderCrud {
65
+ get(id: string): Promise<Folder>;
66
+ list(params: ListFoldersParams): Promise<[Folder[], ListMeta]>;
67
+ create(data: CreateFolderParams): Promise<Folder>;
68
+ update(id: string, data: UpdateFolderParams): Promise<Folder>;
69
+ delete(id: string): Promise<Boolean>;
70
+ onFolderBeforeCreate: Topic<OnFolderBeforeCreateTopicParams>;
71
+ onFolderAfterCreate: Topic<OnFolderAfterCreateTopicParams>;
72
+ onFolderBeforeUpdate: Topic<OnFolderBeforeUpdateTopicParams>;
73
+ onFolderAfterUpdate: Topic<OnFolderAfterUpdateTopicParams>;
74
+ onFolderBeforeDelete: Topic<OnFolderBeforeDeleteTopicParams>;
75
+ onFolderAfterDelete: Topic<OnFolderAfterDeleteTopicParams>;
76
+ }
77
+ export interface AcoFolderStorageOperations {
78
+ getFolder(params: StorageOperationsGetFolderParams): Promise<Folder>;
79
+ listFolders(params: StorageOperationsListFoldersParams): Promise<[Folder[], ListMeta]>;
80
+ createFolder(params: StorageOperationsCreateFolderParams): Promise<Folder>;
81
+ updateFolder(params: StorageOperationsUpdateFolderParams): Promise<Folder>;
82
+ deleteFolder(params: StorageOperationsDeleteFolderParams): Promise<boolean>;
83
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["folder.types.ts"],"sourcesContent":["import { AcoBaseFields, ListMeta } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport interface Folder extends AcoBaseFields {\n title: string;\n slug: string;\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersWhere {\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersParams {\n where: ListFoldersWhere;\n sort?: string[];\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateFolderParams = Pick<Folder, \"title\" | \"slug\" | \"type\" | \"parentId\">;\n\nexport interface UpdateFolderParams {\n title?: string;\n slug?: string;\n parentId?: string;\n}\n\nexport interface DeleteFolderParams {\n id: string;\n}\n\nexport interface StorageOperationsGetFolderParams {\n id?: string;\n slug?: string;\n type?: string;\n parentId?: string | null;\n}\n\nexport type StorageOperationsListFoldersParams = ListFoldersParams;\n\nexport interface StorageOperationsCreateFolderParams {\n data: CreateFolderParams;\n}\n\nexport interface StorageOperationsUpdateFolderParams {\n id: string;\n data: UpdateFolderParams;\n}\n\nexport type StorageOperationsDeleteFolderParams = DeleteFolderParams;\n\nexport interface OnFolderBeforeCreateTopicParams {\n input: CreateFolderParams;\n}\n\nexport interface OnFolderAfterCreateTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderBeforeUpdateTopicParams {\n original: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderAfterUpdateTopicParams {\n original: Folder;\n folder: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderBeforeDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderAfterDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface AcoFolderCrud {\n get(id: string): Promise<Folder>;\n list(params: ListFoldersParams): Promise<[Folder[], ListMeta]>;\n create(data: CreateFolderParams): Promise<Folder>;\n update(id: string, data: UpdateFolderParams): Promise<Folder>;\n delete(id: string): Promise<Boolean>;\n onFolderBeforeCreate: Topic<OnFolderBeforeCreateTopicParams>;\n onFolderAfterCreate: Topic<OnFolderAfterCreateTopicParams>;\n onFolderBeforeUpdate: Topic<OnFolderBeforeUpdateTopicParams>;\n onFolderAfterUpdate: Topic<OnFolderAfterUpdateTopicParams>;\n onFolderBeforeDelete: Topic<OnFolderBeforeDeleteTopicParams>;\n onFolderAfterDelete: Topic<OnFolderAfterDeleteTopicParams>;\n}\n\nexport interface AcoFolderStorageOperations {\n getFolder(params: StorageOperationsGetFolderParams): Promise<Folder>;\n listFolders(params: StorageOperationsListFoldersParams): Promise<[Folder[], ListMeta]>;\n createFolder(params: StorageOperationsCreateFolderParams): Promise<Folder>;\n updateFolder(params: StorageOperationsUpdateFolderParams): Promise<Folder>;\n deleteFolder(params: StorageOperationsDeleteFolderParams): Promise<boolean>;\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { AcoContext } from "../types";
2
+ export declare const onFolderBeforeDeleteHook: ({ aco }: AcoContext) => void;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onFolderBeforeDeleteHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ const onFolderBeforeDeleteHook = ({
10
+ aco
11
+ }) => {
12
+ try {
13
+ aco.folder.onFolderBeforeDelete.subscribe(async ({
14
+ folder
15
+ }) => {
16
+ const {
17
+ id,
18
+ type
19
+ } = folder;
20
+
21
+ // Fetching all child folders
22
+ const [children] = await aco.folder.list({
23
+ where: {
24
+ type,
25
+ parentId: id
26
+ },
27
+ limit: 1
28
+ });
29
+
30
+ // Fetching all records inside the folder
31
+ const [records] = await aco.search.list({
32
+ where: {
33
+ type,
34
+ location: {
35
+ folderId: id
36
+ }
37
+ },
38
+ limit: 1
39
+ });
40
+ if (children.length > 0 || records.length > 0) {
41
+ throw new _error.default("Error: delete all child folders and entries before proceeding.", "DELETE_FOLDER_WITH_CHILDREN", {
42
+ folder
43
+ });
44
+ }
45
+ });
46
+ } catch (error) {
47
+ throw _error.default.from(error, {
48
+ message: "Error while executing onFolderBeforeDelete hook",
49
+ code: "ACO_BEFORE_FOLDER_DELETE_HOOK"
50
+ });
51
+ }
52
+ };
53
+ exports.onFolderBeforeDeleteHook = onFolderBeforeDeleteHook;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["onFolderBeforeDeleteHook","aco","folder","onFolderBeforeDelete","subscribe","id","type","children","list","where","parentId","limit","records","search","location","folderId","length","WebinyError","error","from","message","code"],"sources":["onFolderBeforeDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoContext } from \"~/types\";\n\nexport const onFolderBeforeDeleteHook = ({ aco }: AcoContext) => {\n try {\n aco.folder.onFolderBeforeDelete.subscribe(async ({ folder }) => {\n const { id, type } = folder;\n\n // Fetching all child folders\n const [children] = await aco.folder.list({\n where: { type, parentId: id },\n limit: 1\n });\n\n // Fetching all records inside the folder\n const [records] = await aco.search.list({\n where: { type, location: { folderId: id } },\n limit: 1\n });\n\n if (children.length > 0 || records.length > 0) {\n throw new WebinyError(\n \"Error: delete all child folders and entries before proceeding.\",\n \"DELETE_FOLDER_WITH_CHILDREN\",\n {\n folder\n }\n );\n }\n });\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFolderBeforeDelete hook\",\n code: \"ACO_BEFORE_FOLDER_DELETE_HOOK\"\n });\n }\n};\n"],"mappings":";;;;;;;AAAA;AAGO,MAAMA,wBAAwB,GAAG,CAAC;EAAEC;AAAgB,CAAC,KAAK;EAC7D,IAAI;IACAA,GAAG,CAACC,MAAM,CAACC,oBAAoB,CAACC,SAAS,CAAC,OAAO;MAAEF;IAAO,CAAC,KAAK;MAC5D,MAAM;QAAEG,EAAE;QAAEC;MAAK,CAAC,GAAGJ,MAAM;;MAE3B;MACA,MAAM,CAACK,QAAQ,CAAC,GAAG,MAAMN,GAAG,CAACC,MAAM,CAACM,IAAI,CAAC;QACrCC,KAAK,EAAE;UAAEH,IAAI;UAAEI,QAAQ,EAAEL;QAAG,CAAC;QAC7BM,KAAK,EAAE;MACX,CAAC,CAAC;;MAEF;MACA,MAAM,CAACC,OAAO,CAAC,GAAG,MAAMX,GAAG,CAACY,MAAM,CAACL,IAAI,CAAC;QACpCC,KAAK,EAAE;UAAEH,IAAI;UAAEQ,QAAQ,EAAE;YAAEC,QAAQ,EAAEV;UAAG;QAAE,CAAC;QAC3CM,KAAK,EAAE;MACX,CAAC,CAAC;MAEF,IAAIJ,QAAQ,CAACS,MAAM,GAAG,CAAC,IAAIJ,OAAO,CAACI,MAAM,GAAG,CAAC,EAAE;QAC3C,MAAM,IAAIC,cAAW,CACjB,gEAAgE,EAChE,6BAA6B,EAC7B;UACIf;QACJ,CAAC,CACJ;MACL;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOgB,KAAK,EAAE;IACZ,MAAMD,cAAW,CAACE,IAAI,CAACD,KAAK,EAAE;MAC1BE,OAAO,EAAE,iDAAiD;MAC1DC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ,CAAC;AAAC"}
package/index.d.ts CHANGED
@@ -1,9 +1 @@
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>[];
1
+ export declare const createACO: () => (import("@webiny/api").ContextPlugin<import("./types").AcoContext> | import("@webiny/api-headless-cms/types").CmsModelFieldToGraphQLPlugin<import("@webiny/api-headless-cms/types").CmsModelField>[] | import("@webiny/api").ContextPlugin<import("@webiny/api-admin-settings/types").AdminSettingsContext>)[];
package/index.js CHANGED
@@ -1,71 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
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
-
6
+ exports.createACO = void 0;
7
+ var _apiAdminSettings = require("@webiny/api-admin-settings");
8
+ var _createAcoContext = require("./createAcoContext");
9
+ var _createAcoFields = require("./createAcoFields");
10
+ var _createAcoGraphQL = require("./createAcoGraphQL");
20
11
  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
- });
12
+ return [...(0, _apiAdminSettings.createAdminSettingsContext)(), (0, _createAcoContext.createAcoContext)(), (0, _createAcoFields.createAcoFields)(), (0, _createAcoGraphQL.createAcoGraphQL)()];
61
13
  };
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;
14
+ exports.createACO = createACO;
package/index.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"names":["createACO","createAdminSettingsContext","createAcoContext","createAcoFields","createAcoGraphQL"],"sources":["index.ts"],"sourcesContent":["import { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nimport { createAcoContext } from \"~/createAcoContext\";\nimport { createAcoFields } from \"~/createAcoFields\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL\";\n\nexport const createACO = () => {\n return [\n ...createAdminSettingsContext(),\n createAcoContext(),\n createAcoFields(),\n createAcoGraphQL()\n ];\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAEO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,CACH,GAAG,IAAAC,4CAA0B,GAAE,EAC/B,IAAAC,kCAAgB,GAAE,EAClB,IAAAC,gCAAe,GAAE,EACjB,IAAAC,kCAAgB,GAAE,CACrB;AACL,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco",
3
- "version": "0.0.0-unstable.aad28a72ae",
3
+ "version": "0.0.0-unstable.bca7b3e350",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "aco:base"
@@ -27,29 +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-i18n-ddb": "^0.0.0-unstable.aad28a72ae",
31
- "@webiny/api-security-so-ddb": "^0.0.0-unstable.aad28a72ae",
32
- "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.aad28a72ae",
33
- "@webiny/api-wcp": "^0.0.0-unstable.aad28a72ae",
34
- "@webiny/cli": "^0.0.0-unstable.aad28a72ae",
35
- "@webiny/handler-aws": "^0.0.0-unstable.aad28a72ae",
36
- "@webiny/plugins": "^0.0.0-unstable.aad28a72ae",
37
- "@webiny/project-utils": "^0.0.0-unstable.aad28a72ae",
30
+ "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.bca7b3e350",
31
+ "@webiny/api-i18n-ddb": "^0.0.0-unstable.bca7b3e350",
32
+ "@webiny/api-security-so-ddb": "^0.0.0-unstable.bca7b3e350",
33
+ "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.bca7b3e350",
34
+ "@webiny/api-wcp": "^0.0.0-unstable.bca7b3e350",
35
+ "@webiny/cli": "^0.0.0-unstable.bca7b3e350",
36
+ "@webiny/handler-aws": "^0.0.0-unstable.bca7b3e350",
37
+ "@webiny/plugins": "^0.0.0-unstable.bca7b3e350",
38
+ "@webiny/project-utils": "^0.0.0-unstable.bca7b3e350",
38
39
  "rimraf": "^3.0.2",
39
40
  "ttypescript": "^1.5.13",
40
41
  "typescript": "^4.7.4"
41
42
  },
42
43
  "dependencies": {
43
- "@webiny/api": "0.0.0-unstable.aad28a72ae",
44
- "@webiny/api-i18n": "0.0.0-unstable.aad28a72ae",
45
- "@webiny/api-security": "0.0.0-unstable.aad28a72ae",
46
- "@webiny/api-tenancy": "0.0.0-unstable.aad28a72ae",
47
- "@webiny/error": "0.0.0-unstable.aad28a72ae",
48
- "@webiny/handler": "0.0.0-unstable.aad28a72ae",
49
- "@webiny/handler-graphql": "0.0.0-unstable.aad28a72ae",
50
- "@webiny/pubsub": "0.0.0-unstable.aad28a72ae",
51
- "joi": "17.6.2",
52
- "mdbid": "1.0.0"
44
+ "@webiny/api": "0.0.0-unstable.bca7b3e350",
45
+ "@webiny/api-admin-settings": "0.0.0-unstable.bca7b3e350",
46
+ "@webiny/api-headless-cms": "0.0.0-unstable.bca7b3e350",
47
+ "@webiny/api-i18n": "0.0.0-unstable.bca7b3e350",
48
+ "@webiny/api-security": "0.0.0-unstable.bca7b3e350",
49
+ "@webiny/api-tenancy": "0.0.0-unstable.bca7b3e350",
50
+ "@webiny/error": "0.0.0-unstable.bca7b3e350",
51
+ "@webiny/handler": "0.0.0-unstable.bca7b3e350",
52
+ "@webiny/handler-graphql": "0.0.0-unstable.bca7b3e350",
53
+ "@webiny/pubsub": "0.0.0-unstable.bca7b3e350",
54
+ "lodash": "4.17.21"
53
55
  },
54
- "gitHead": "aad28a72ae72f19b80a3196d2b4439399acc67ad"
56
+ "gitHead": "bca7b3e35084d7012061bda0d3f08202fe611581"
55
57
  }
@@ -0,0 +1,3 @@
1
+ import { CreateAcoParams } from "../types";
2
+ import { AcoSearchRecordCrud } from "./record.types";
3
+ export declare const createSearchRecordCrudMethods: ({ storageOperations }: CreateAcoParams) => AcoSearchRecordCrud;