@webiny/api-aco 0.0.0-ee-vpcs.549378cf03 → 0.0.0-unstable.085ff6572f

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 (149) hide show
  1. package/README.md +15 -0
  2. package/apps/AcoApp.d.ts +16 -0
  3. package/apps/AcoApp.js +108 -0
  4. package/apps/AcoApp.js.map +1 -0
  5. package/apps/AcoApps.d.ts +10 -0
  6. package/apps/AcoApps.js +76 -0
  7. package/apps/AcoApps.js.map +1 -0
  8. package/apps/app.gql.d.ts +3 -0
  9. package/apps/app.gql.js +58 -0
  10. package/apps/app.gql.js.map +1 -0
  11. package/apps/index.d.ts +2 -0
  12. package/apps/index.js +27 -0
  13. package/apps/index.js.map +1 -0
  14. package/createAcoContext.d.ts +3 -0
  15. package/createAcoContext.js +100 -0
  16. package/createAcoContext.js.map +1 -0
  17. package/createAcoGraphQL.d.ts +3 -0
  18. package/createAcoGraphQL.js +121 -0
  19. package/createAcoGraphQL.js.map +1 -0
  20. package/createAcoHooks.d.ts +2 -0
  21. package/createAcoHooks.js +11 -0
  22. package/createAcoHooks.js.map +1 -0
  23. package/createAcoModels.d.ts +2 -0
  24. package/createAcoModels.js +42 -0
  25. package/createAcoModels.js.map +1 -0
  26. package/createAcoStorageOperations.d.ts +10 -0
  27. package/createAcoStorageOperations.js +19 -0
  28. package/createAcoStorageOperations.js.map +1 -0
  29. package/fields/index.d.ts +2 -0
  30. package/fields/index.js +12 -0
  31. package/fields/index.js.map +1 -0
  32. package/fields/location.d.ts +2 -0
  33. package/fields/location.js +44 -0
  34. package/fields/location.js.map +1 -0
  35. package/folder/folder.crud.d.ts +3 -0
  36. package/folder/folder.crud.js +110 -0
  37. package/folder/folder.crud.js.map +1 -0
  38. package/folder/folder.gql.d.ts +3 -0
  39. package/folder/folder.gql.js +118 -0
  40. package/folder/folder.gql.js.map +1 -0
  41. package/folder/folder.model.d.ts +4 -0
  42. package/folder/folder.model.js +75 -0
  43. package/folder/folder.model.js.map +1 -0
  44. package/folder/folder.so.d.ts +3 -0
  45. package/folder/folder.so.js +151 -0
  46. package/folder/folder.so.js.map +1 -0
  47. package/folder/folder.types.d.ts +89 -0
  48. package/folder/folder.types.js +5 -0
  49. package/folder/folder.types.js.map +1 -0
  50. package/folder/onFolderBeforeDelete.hook.d.ts +2 -0
  51. package/folder/onFolderBeforeDelete.hook.js +66 -0
  52. package/folder/onFolderBeforeDelete.hook.js.map +1 -0
  53. package/index.d.ts +5 -9
  54. package/index.js +48 -63
  55. package/index.js.map +1 -1
  56. package/package.json +35 -30
  57. package/plugins/AcoAppModifierPlugin.d.ts +43 -0
  58. package/plugins/AcoAppModifierPlugin.js +59 -0
  59. package/plugins/AcoAppModifierPlugin.js.map +1 -0
  60. package/plugins/AcoAppRegisterPlugin.d.ts +8 -0
  61. package/plugins/AcoAppRegisterPlugin.js +22 -0
  62. package/plugins/AcoAppRegisterPlugin.js.map +1 -0
  63. package/plugins/index.d.ts +2 -0
  64. package/plugins/index.js +27 -0
  65. package/plugins/index.js.map +1 -0
  66. package/record/graphql/createAppResolvers.d.ts +14 -0
  67. package/record/graphql/createAppResolvers.js +108 -0
  68. package/record/graphql/createAppResolvers.js.map +1 -0
  69. package/record/graphql/createAppSchema.d.ts +9 -0
  70. package/record/graphql/createAppSchema.js +142 -0
  71. package/record/graphql/createAppSchema.js.map +1 -0
  72. package/record/record.crud.d.ts +3 -0
  73. package/record/record.crud.js +126 -0
  74. package/record/record.crud.js.map +1 -0
  75. package/record/record.gql.d.ts +8 -0
  76. package/record/record.gql.js +41 -0
  77. package/record/record.gql.js.map +1 -0
  78. package/record/record.model.d.ts +10 -0
  79. package/record/record.model.js +86 -0
  80. package/record/record.model.js.map +1 -0
  81. package/record/record.so.d.ts +3 -0
  82. package/record/record.so.js +150 -0
  83. package/record/record.so.js.map +1 -0
  84. package/record/record.types.d.ts +143 -0
  85. package/record/record.types.js +5 -0
  86. package/record/record.types.js.map +1 -0
  87. package/types.d.ts +73 -201
  88. package/types.js +35 -1
  89. package/types.js.map +1 -1
  90. package/utils/acoRecordId.d.ts +6 -0
  91. package/utils/acoRecordId.js +33 -0
  92. package/utils/acoRecordId.js.map +1 -0
  93. package/utils/checkPermissions.d.ts +2 -0
  94. package/utils/checkPermissions.js +14 -0
  95. package/utils/checkPermissions.js.map +1 -0
  96. package/utils/createListSort.d.ts +2 -0
  97. package/utils/createListSort.js +13 -0
  98. package/utils/createListSort.js.map +1 -0
  99. package/utils/createModelField.d.ts +5 -0
  100. package/utils/createModelField.js +37 -0
  101. package/utils/createModelField.js.map +1 -0
  102. package/utils/createOperationsWrapper.d.ts +9 -0
  103. package/utils/createOperationsWrapper.js +29 -0
  104. package/utils/createOperationsWrapper.js.map +1 -0
  105. package/utils/fieldResolver.d.ts +16 -0
  106. package/utils/fieldResolver.js +44 -0
  107. package/utils/fieldResolver.js.map +1 -0
  108. package/utils/getFieldValues.d.ts +5 -0
  109. package/utils/getFieldValues.js +16 -0
  110. package/utils/getFieldValues.js.map +1 -0
  111. package/utils/getFolderAndItsAncestors.d.ts +7 -0
  112. package/utils/getFolderAndItsAncestors.js +48 -0
  113. package/utils/getFolderAndItsAncestors.js.map +1 -0
  114. package/utils/isInstallationPending.d.ts +4 -0
  115. package/utils/isInstallationPending.js +21 -0
  116. package/utils/isInstallationPending.js.map +1 -0
  117. package/utils/modelFactory.d.ts +15 -0
  118. package/utils/modelFactory.js +25 -0
  119. package/utils/modelFactory.js.map +1 -0
  120. package/utils/resolve.d.ts +3 -0
  121. package/utils/resolve.js +24 -0
  122. package/utils/resolve.js.map +1 -0
  123. package/context/folders.d.ts +0 -2
  124. package/context/folders.js +0 -261
  125. package/context/folders.js.map +0 -1
  126. package/context/index.d.ts +0 -2
  127. package/context/index.js +0 -22
  128. package/context/index.js.map +0 -1
  129. package/context/links.d.ts +0 -2
  130. package/context/links.js +0 -270
  131. package/context/links.js.map +0 -1
  132. package/graphql/base.gql.d.ts +0 -3
  133. package/graphql/base.gql.js +0 -63
  134. package/graphql/base.gql.js.map +0 -1
  135. package/graphql/folders.gql.d.ts +0 -3
  136. package/graphql/folders.gql.js +0 -126
  137. package/graphql/folders.gql.js.map +0 -1
  138. package/graphql/index.d.ts +0 -1
  139. package/graphql/index.js +0 -15
  140. package/graphql/index.js.map +0 -1
  141. package/graphql/links.gql.d.ts +0 -3
  142. package/graphql/links.gql.js +0 -123
  143. package/graphql/links.gql.js.map +0 -1
  144. package/subscriptions/afterFolderDelete.d.ts +0 -3
  145. package/subscriptions/afterFolderDelete.js +0 -62
  146. package/subscriptions/afterFolderDelete.js.map +0 -1
  147. package/subscriptions/index.d.ts +0 -3
  148. package/subscriptions/index.js +0 -14
  149. package/subscriptions/index.js.map +0 -1
@@ -0,0 +1,151 @@
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 _createListSort = require("../utils/createListSort");
13
+ var _createOperationsWrapper = require("../utils/createOperationsWrapper");
14
+ var _getFieldValues = require("../utils/getFieldValues");
15
+ const createFolderOperations = params => {
16
+ const {
17
+ cms
18
+ } = params;
19
+ const {
20
+ withModel
21
+ } = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
22
+ modelName: _folder.FOLDER_MODEL_ID
23
+ }));
24
+ const getFolder = ({
25
+ id,
26
+ slug,
27
+ type,
28
+ parentId
29
+ }) => {
30
+ return withModel(async model => {
31
+ let entry;
32
+ if (id) {
33
+ entry = await cms.getEntryById(model, id);
34
+ } else if (slug && type) {
35
+ entry = await cms.getEntry(model, {
36
+ where: {
37
+ slug,
38
+ type,
39
+ parentId,
40
+ latest: true
41
+ }
42
+ });
43
+ }
44
+ if (!entry) {
45
+ throw new _error.default("Could not load folder.", "GET_FOLDER_ERROR", {
46
+ id,
47
+ slug,
48
+ type,
49
+ parentId
50
+ });
51
+ }
52
+ return (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields);
53
+ });
54
+ };
55
+ const checkExistingFolder = ({
56
+ id,
57
+ params
58
+ }) => {
59
+ return withModel(async model => {
60
+ const {
61
+ type,
62
+ slug,
63
+ parentId
64
+ } = params;
65
+ const [existings] = await cms.listLatestEntries(model, {
66
+ where: {
67
+ type,
68
+ slug,
69
+ parentId,
70
+ id_not: id
71
+ },
72
+ limit: 1
73
+ });
74
+ if (existings.length > 0) {
75
+ throw new _error.default(`Folder with slug "${slug}" already exists at this level.`, "FOLDER_ALREADY_EXISTS", {
76
+ id,
77
+ params
78
+ });
79
+ }
80
+ return;
81
+ });
82
+ };
83
+ return {
84
+ getFolder,
85
+ listFolders(params) {
86
+ return withModel(async model => {
87
+ const {
88
+ sort,
89
+ where
90
+ } = params;
91
+ const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
92
+ sort: (0, _createListSort.createListSort)(sort),
93
+ where: (0, _objectSpread2.default)({}, where || {})
94
+ }));
95
+ return [entries.map(entry => (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields)), meta];
96
+ });
97
+ },
98
+ createFolder({
99
+ data
100
+ }) {
101
+ return withModel(async model => {
102
+ await checkExistingFolder({
103
+ params: {
104
+ type: data.type,
105
+ slug: data.slug,
106
+ parentId: data.parentId
107
+ }
108
+ });
109
+ const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
110
+ parentId: data.parentId || null
111
+ }));
112
+ return (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields);
113
+ });
114
+ },
115
+ updateFolder({
116
+ id,
117
+ data
118
+ }) {
119
+ return withModel(async model => {
120
+ const {
121
+ slug,
122
+ parentId
123
+ } = data;
124
+ const original = await getFolder({
125
+ id
126
+ });
127
+ await checkExistingFolder({
128
+ id,
129
+ params: {
130
+ type: original.type,
131
+ slug: slug || original.slug,
132
+ parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`
133
+ }
134
+ });
135
+
136
+ const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
137
+ const entry = await cms.updateEntry(model, id, input);
138
+ return (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields);
139
+ });
140
+ },
141
+ deleteFolder({
142
+ id
143
+ }) {
144
+ return withModel(async model => {
145
+ await cms.deleteEntry(model, id);
146
+ return true;
147
+ });
148
+ }
149
+ };
150
+ };
151
+ exports.createFolderOperations = createFolderOperations;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFolderOperations","params","cms","withModel","createOperationsWrapper","modelName","FOLDER_MODEL_ID","getFolder","id","slug","type","parentId","model","entry","getEntryById","getEntry","where","latest","WebinyError","getFolderFieldValues","baseFields","checkExistingFolder","existings","listLatestEntries","id_not","limit","length","listFolders","sort","entries","meta","createListSort","map","createFolder","data","createEntry","updateFolder","original","undefined","input","updateEntry","deleteFolder","deleteEntry"],"sources":["folder.so.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { FOLDER_MODEL_ID } from \"./folder.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { createListSort } from \"~/utils/createListSort\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { getFolderFieldValues } from \"~/utils/getFieldValues\";\n\nimport { AcoFolderStorageOperations } from \"./folder.types\";\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 } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: FOLDER_MODEL_ID\n });\n\n const getFolder: AcoFolderStorageOperations[\"getFolder\"] = ({ id, slug, type, parentId }) => {\n return withModel(async model => {\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, {\n where: { slug, type, parentId, latest: true }\n });\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 return getFolderFieldValues(entry, baseFields);\n });\n };\n\n const checkExistingFolder = ({ id, params }: AcoCheckExistingFolderParams) => {\n return withModel(async model => {\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 return;\n });\n };\n\n return {\n getFolder,\n listFolders(params) {\n return withModel(async model => {\n const { sort, where } = params;\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n sort: createListSort(sort),\n where: {\n ...(where || {})\n }\n });\n\n return [entries.map(entry => getFolderFieldValues(entry, baseFields)), meta];\n });\n },\n createFolder({ data }) {\n return withModel(async model => {\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 return getFolderFieldValues(entry, baseFields);\n });\n },\n updateFolder({ id, data }) {\n return withModel(async model => {\n const { slug, parentId } = data;\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 return getFolderFieldValues(entry, baseFields);\n });\n },\n deleteFolder({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, id);\n return true;\n });\n }\n };\n};\n"],"mappings":"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"}
@@ -0,0 +1,89 @@
1
+ import { ListMeta, ListSort, User } from "../types";
2
+ import { Topic } from "@webiny/pubsub/types";
3
+ export interface Folder {
4
+ id: string;
5
+ entryId: string;
6
+ createdOn: string;
7
+ createdBy: User;
8
+ savedOn: string;
9
+ title: string;
10
+ slug: string;
11
+ type: string;
12
+ parentId?: string | null;
13
+ }
14
+ export interface ListFoldersWhere {
15
+ type: string;
16
+ parentId?: string | null;
17
+ }
18
+ export interface ListFoldersParams {
19
+ where: ListFoldersWhere;
20
+ sort?: ListSort;
21
+ limit?: number;
22
+ after?: string | null;
23
+ }
24
+ export declare type CreateFolderParams = Pick<Folder, "title" | "slug" | "type" | "parentId">;
25
+ export interface UpdateFolderParams {
26
+ title?: string;
27
+ slug?: string;
28
+ parentId?: string;
29
+ }
30
+ export interface DeleteFolderParams {
31
+ id: string;
32
+ }
33
+ export interface StorageOperationsGetFolderParams {
34
+ id?: string;
35
+ slug?: string;
36
+ type?: string;
37
+ parentId?: string | null;
38
+ }
39
+ export declare type StorageOperationsListFoldersParams = ListFoldersParams;
40
+ export interface StorageOperationsCreateFolderParams {
41
+ data: CreateFolderParams;
42
+ }
43
+ export interface StorageOperationsUpdateFolderParams {
44
+ id: string;
45
+ data: UpdateFolderParams;
46
+ }
47
+ export declare type StorageOperationsDeleteFolderParams = DeleteFolderParams;
48
+ export interface OnFolderBeforeCreateTopicParams {
49
+ input: CreateFolderParams;
50
+ }
51
+ export interface OnFolderAfterCreateTopicParams {
52
+ folder: Folder;
53
+ }
54
+ export interface OnFolderBeforeUpdateTopicParams {
55
+ original: Folder;
56
+ input: Record<string, any>;
57
+ }
58
+ export interface OnFolderAfterUpdateTopicParams {
59
+ original: Folder;
60
+ folder: Folder;
61
+ input: Record<string, any>;
62
+ }
63
+ export interface OnFolderBeforeDeleteTopicParams {
64
+ folder: Folder;
65
+ }
66
+ export interface OnFolderAfterDeleteTopicParams {
67
+ folder: Folder;
68
+ }
69
+ export interface AcoFolderCrud {
70
+ get(id: string): Promise<Folder>;
71
+ list(params: ListFoldersParams): Promise<[Folder[], ListMeta]>;
72
+ create(data: CreateFolderParams): Promise<Folder>;
73
+ update(id: string, data: UpdateFolderParams): Promise<Folder>;
74
+ delete(id: string): Promise<Boolean>;
75
+ getFolderWithAncestors(id: string): Promise<Folder[]>;
76
+ onFolderBeforeCreate: Topic<OnFolderBeforeCreateTopicParams>;
77
+ onFolderAfterCreate: Topic<OnFolderAfterCreateTopicParams>;
78
+ onFolderBeforeUpdate: Topic<OnFolderBeforeUpdateTopicParams>;
79
+ onFolderAfterUpdate: Topic<OnFolderAfterUpdateTopicParams>;
80
+ onFolderBeforeDelete: Topic<OnFolderBeforeDeleteTopicParams>;
81
+ onFolderAfterDelete: Topic<OnFolderAfterDeleteTopicParams>;
82
+ }
83
+ export interface AcoFolderStorageOperations {
84
+ getFolder(params: StorageOperationsGetFolderParams): Promise<Folder>;
85
+ listFolders(params: StorageOperationsListFoldersParams): Promise<[Folder[], ListMeta]>;
86
+ createFolder(params: StorageOperationsCreateFolderParams): Promise<Folder>;
87
+ updateFolder(params: StorageOperationsUpdateFolderParams): Promise<Folder>;
88
+ deleteFolder(params: StorageOperationsDeleteFolderParams): Promise<boolean>;
89
+ }
@@ -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 { ListMeta, ListSort, User } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport interface Folder {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n title: string;\n slug: string;\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersWhere {\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersParams {\n where: ListFoldersWhere;\n sort?: ListSort;\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateFolderParams = Pick<Folder, \"title\" | \"slug\" | \"type\" | \"parentId\">;\n\nexport interface UpdateFolderParams {\n title?: string;\n slug?: string;\n parentId?: string;\n}\n\nexport interface DeleteFolderParams {\n id: string;\n}\n\nexport interface StorageOperationsGetFolderParams {\n id?: string;\n slug?: string;\n type?: string;\n parentId?: string | null;\n}\n\nexport type StorageOperationsListFoldersParams = ListFoldersParams;\n\nexport interface StorageOperationsCreateFolderParams {\n data: CreateFolderParams;\n}\n\nexport interface StorageOperationsUpdateFolderParams {\n id: string;\n data: UpdateFolderParams;\n}\n\nexport type StorageOperationsDeleteFolderParams = DeleteFolderParams;\n\nexport interface OnFolderBeforeCreateTopicParams {\n input: CreateFolderParams;\n}\n\nexport interface OnFolderAfterCreateTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderBeforeUpdateTopicParams {\n original: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderAfterUpdateTopicParams {\n original: Folder;\n folder: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderBeforeDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderAfterDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface AcoFolderCrud {\n get(id: string): Promise<Folder>;\n list(params: ListFoldersParams): Promise<[Folder[], ListMeta]>;\n create(data: CreateFolderParams): Promise<Folder>;\n update(id: string, data: UpdateFolderParams): Promise<Folder>;\n delete(id: string): Promise<Boolean>;\n getFolderWithAncestors(id: string): Promise<Folder[]>;\n onFolderBeforeCreate: Topic<OnFolderBeforeCreateTopicParams>;\n onFolderAfterCreate: Topic<OnFolderAfterCreateTopicParams>;\n onFolderBeforeUpdate: Topic<OnFolderBeforeUpdateTopicParams>;\n onFolderAfterUpdate: Topic<OnFolderAfterUpdateTopicParams>;\n onFolderBeforeDelete: Topic<OnFolderBeforeDeleteTopicParams>;\n onFolderAfterDelete: Topic<OnFolderAfterDeleteTopicParams>;\n}\n\nexport interface AcoFolderStorageOperations {\n getFolder(params: StorageOperationsGetFolderParams): Promise<Folder>;\n listFolders(params: StorageOperationsListFoldersParams): Promise<[Folder[], ListMeta]>;\n createFolder(params: StorageOperationsCreateFolderParams): Promise<Folder>;\n updateFolder(params: StorageOperationsUpdateFolderParams): Promise<Folder>;\n deleteFolder(params: StorageOperationsDeleteFolderParams): Promise<boolean>;\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { AcoContext } from "../types";
2
+ export declare const onFolderBeforeDeleteHook: ({ aco }: AcoContext) => void;
@@ -0,0 +1,66 @@
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 throwDeleteError = folder => {
10
+ throw new _error.default("Error: delete all child folders and entries before proceeding.", "DELETE_FOLDER_WITH_CHILDREN", {
11
+ folder
12
+ });
13
+ };
14
+ const onFolderBeforeDeleteHook = ({
15
+ aco
16
+ }) => {
17
+ aco.folder.onFolderBeforeDelete.subscribe(async ({
18
+ folder
19
+ }) => {
20
+ try {
21
+ const {
22
+ id,
23
+ type
24
+ } = folder;
25
+ /**
26
+ * First we check for the child folders.
27
+ */
28
+ const [children] = await aco.folder.list({
29
+ where: {
30
+ type,
31
+ parentId: id
32
+ },
33
+ limit: 1
34
+ });
35
+ if (children.length > 0) {
36
+ throwDeleteError(folder);
37
+ }
38
+ /**
39
+ * Then for entries in each of the apps.
40
+ * Because we split the apps we must do it like this.
41
+ */
42
+ const apps = aco.listApps();
43
+ for (const app of apps) {
44
+ const [records] = await app.search.list({
45
+ where: {
46
+ type,
47
+ location: {
48
+ folderId: id
49
+ }
50
+ },
51
+ limit: 1
52
+ });
53
+ if (records.length === 0) {
54
+ continue;
55
+ }
56
+ throwDeleteError(folder);
57
+ }
58
+ } catch (error) {
59
+ throw _error.default.from(error, {
60
+ message: "Error while executing onFolderBeforeDelete hook",
61
+ code: "ACO_BEFORE_FOLDER_DELETE_HOOK"
62
+ });
63
+ }
64
+ });
65
+ };
66
+ exports.onFolderBeforeDeleteHook = onFolderBeforeDeleteHook;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["throwDeleteError","folder","WebinyError","onFolderBeforeDeleteHook","aco","onFolderBeforeDelete","subscribe","id","type","children","list","where","parentId","limit","length","apps","listApps","app","records","search","location","folderId","error","from","message","code"],"sources":["onFolderBeforeDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoContext, Folder } from \"~/types\";\n\nconst throwDeleteError = (folder: Folder) => {\n throw new WebinyError(\n \"Error: delete all child folders and entries before proceeding.\",\n \"DELETE_FOLDER_WITH_CHILDREN\",\n {\n folder\n }\n );\n};\n\nexport const onFolderBeforeDeleteHook = ({ aco }: AcoContext) => {\n aco.folder.onFolderBeforeDelete.subscribe(async ({ folder }) => {\n try {\n const { id, type } = folder;\n /**\n * First we check for the child folders.\n */\n const [children] = await aco.folder.list({\n where: {\n type,\n parentId: id\n },\n limit: 1\n });\n if (children.length > 0) {\n throwDeleteError(folder);\n }\n /**\n * Then for entries in each of the apps.\n * Because we split the apps we must do it like this.\n */\n const apps = aco.listApps();\n for (const app of apps) {\n const [records] = await app.search.list({\n where: {\n type,\n location: {\n folderId: id\n }\n },\n limit: 1\n });\n if (records.length === 0) {\n continue;\n }\n throwDeleteError(folder);\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFolderBeforeDelete hook\",\n code: \"ACO_BEFORE_FOLDER_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAGA,MAAMA,gBAAgB,GAAIC,MAAc,IAAK;EACzC,MAAM,IAAIC,cAAW,CACjB,gEAAgE,EAChE,6BAA6B,EAC7B;IACID;EACJ,CAAC,CACJ;AACL,CAAC;AAEM,MAAME,wBAAwB,GAAG,CAAC;EAAEC;AAAgB,CAAC,KAAK;EAC7DA,GAAG,CAACH,MAAM,CAACI,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEL;EAAO,CAAC,KAAK;IAC5D,IAAI;MACA,MAAM;QAAEM,EAAE;QAAEC;MAAK,CAAC,GAAGP,MAAM;MAC3B;AACZ;AACA;MACY,MAAM,CAACQ,QAAQ,CAAC,GAAG,MAAML,GAAG,CAACH,MAAM,CAACS,IAAI,CAAC;QACrCC,KAAK,EAAE;UACHH,IAAI;UACJI,QAAQ,EAAEL;QACd,CAAC;QACDM,KAAK,EAAE;MACX,CAAC,CAAC;MACF,IAAIJ,QAAQ,CAACK,MAAM,GAAG,CAAC,EAAE;QACrBd,gBAAgB,CAACC,MAAM,CAAC;MAC5B;MACA;AACZ;AACA;AACA;MACY,MAAMc,IAAI,GAAGX,GAAG,CAACY,QAAQ,EAAE;MAC3B,KAAK,MAAMC,GAAG,IAAIF,IAAI,EAAE;QACpB,MAAM,CAACG,OAAO,CAAC,GAAG,MAAMD,GAAG,CAACE,MAAM,CAACT,IAAI,CAAC;UACpCC,KAAK,EAAE;YACHH,IAAI;YACJY,QAAQ,EAAE;cACNC,QAAQ,EAAEd;YACd;UACJ,CAAC;UACDM,KAAK,EAAE;QACX,CAAC,CAAC;QACF,IAAIK,OAAO,CAACJ,MAAM,KAAK,CAAC,EAAE;UACtB;QACJ;QACAd,gBAAgB,CAACC,MAAM,CAAC;MAC5B;IACJ,CAAC,CAAC,OAAOqB,KAAK,EAAE;MACZ,MAAMpB,cAAW,CAACqB,IAAI,CAACD,KAAK,EAAE;QAC1BE,OAAO,EAAE,iDAAiD;QAC1DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
package/index.d.ts CHANGED
@@ -1,9 +1,5 @@
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 { SEARCH_RECORD_MODEL_ID } from "./record/record.model";
2
+ export { FOLDER_MODEL_ID } from "./folder/folder.model";
3
+ export * from "./apps";
4
+ export * from "./plugins";
5
+ export declare const createAco: () => (import("@webiny/api-headless-cms/types").CmsModelFieldToGraphQLPlugin<import("@webiny/api-headless-cms/types").CmsModelField> | import("@webiny/api").ContextPlugin<import("./types").AcoContext> | import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("./types").AcoContext>)[];
package/index.js CHANGED
@@ -1,71 +1,56 @@
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
-
20
- const createACO = () => {
21
- return [];
6
+ var _exportNames = {
7
+ createAco: true,
8
+ SEARCH_RECORD_MODEL_ID: true,
9
+ FOLDER_MODEL_ID: true
22
10
  };
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
- });
11
+ Object.defineProperty(exports, "FOLDER_MODEL_ID", {
12
+ enumerable: true,
13
+ get: function () {
14
+ return _folder.FOLDER_MODEL_ID;
15
+ }
16
+ });
17
+ Object.defineProperty(exports, "SEARCH_RECORD_MODEL_ID", {
18
+ enumerable: true,
19
+ get: function () {
20
+ return _record.SEARCH_RECORD_MODEL_ID;
21
+ }
22
+ });
23
+ exports.createAco = void 0;
24
+ var _createAcoContext = require("./createAcoContext");
25
+ var _createAcoGraphQL = require("./createAcoGraphQL");
26
+ var _fields = require("./fields");
27
+ var _record = require("./record/record.model");
28
+ var _folder = require("./folder/folder.model");
29
+ var _apps = require("./apps");
30
+ Object.keys(_apps).forEach(function (key) {
31
+ if (key === "default" || key === "__esModule") return;
32
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
33
+ if (key in exports && exports[key] === _apps[key]) return;
34
+ Object.defineProperty(exports, key, {
35
+ enumerable: true,
36
+ get: function () {
37
+ return _apps[key];
38
+ }
39
+ });
40
+ });
41
+ var _plugins = require("./plugins");
42
+ Object.keys(_plugins).forEach(function (key) {
43
+ if (key === "default" || key === "__esModule") return;
44
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
45
+ if (key in exports && exports[key] === _plugins[key]) return;
46
+ Object.defineProperty(exports, key, {
47
+ enumerable: true,
48
+ get: function () {
49
+ return _plugins[key];
50
+ }
60
51
  });
52
+ });
53
+ const createAco = () => {
54
+ return [...(0, _fields.createFields)(), (0, _createAcoContext.createAcoContext)(), ...(0, _createAcoGraphQL.createAcoGraphQL)()];
61
55
  };
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;
56
+ 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","createFields","createAcoContext","createAcoGraphQL"],"sources":["index.ts"],"sourcesContent":["import { createAcoContext } from \"~/createAcoContext\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL\";\nimport { createFields } from \"~/fields\";\n\nexport { SEARCH_RECORD_MODEL_ID } from \"./record/record.model\";\nexport { FOLDER_MODEL_ID } from \"./folder/folder.model\";\nexport * from \"./apps\";\nexport * from \"./plugins\";\n\nexport const createAco = () => {\n return [...createFields(), createAcoContext(), ...createAcoGraphQL()];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,CAAC,GAAG,IAAAC,oBAAY,GAAE,EAAE,IAAAC,kCAAgB,GAAE,EAAE,GAAG,IAAAC,kCAAgB,GAAE,CAAC;AACzE,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco",
3
- "version": "0.0.0-ee-vpcs.549378cf03",
3
+ "version": "0.0.0-unstable.085ff6572f",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "aco:base"
@@ -21,35 +21,40 @@
21
21
  "access": "public",
22
22
  "directory": "dist"
23
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
24
  "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"
25
+ "@ungap/structured-clone": "1.2.0",
26
+ "@webiny/api": "0.0.0-unstable.085ff6572f",
27
+ "@webiny/api-headless-cms": "0.0.0-unstable.085ff6572f",
28
+ "@webiny/api-i18n": "0.0.0-unstable.085ff6572f",
29
+ "@webiny/api-security": "0.0.0-unstable.085ff6572f",
30
+ "@webiny/api-tenancy": "0.0.0-unstable.085ff6572f",
31
+ "@webiny/error": "0.0.0-unstable.085ff6572f",
32
+ "@webiny/handler": "0.0.0-unstable.085ff6572f",
33
+ "@webiny/handler-graphql": "0.0.0-unstable.085ff6572f",
34
+ "@webiny/pubsub": "0.0.0-unstable.085ff6572f",
35
+ "@webiny/utils": "0.0.0-unstable.085ff6572f",
36
+ "lodash": "4.17.21"
37
+ },
38
+ "devDependencies": {
39
+ "@babel/cli": "7.20.7",
40
+ "@babel/core": "7.20.12",
41
+ "@babel/preset-env": "7.20.2",
42
+ "@babel/preset-typescript": "7.18.6",
43
+ "@babel/runtime": "7.20.13",
44
+ "@types/ungap__structured-clone": "0.3.0",
45
+ "@webiny/api-i18n-ddb": "0.0.0-unstable.085ff6572f",
46
+ "@webiny/api-security-so-ddb": "0.0.0-unstable.085ff6572f",
47
+ "@webiny/api-tenancy-so-ddb": "0.0.0-unstable.085ff6572f",
48
+ "@webiny/api-wcp": "0.0.0-unstable.085ff6572f",
49
+ "@webiny/cli": "0.0.0-unstable.085ff6572f",
50
+ "@webiny/handler-aws": "0.0.0-unstable.085ff6572f",
51
+ "@webiny/plugins": "0.0.0-unstable.085ff6572f",
52
+ "@webiny/project-utils": "0.0.0-unstable.085ff6572f",
53
+ "graphql": "16.6.0",
54
+ "prettier": "2.8.8",
55
+ "rimraf": "3.0.2",
56
+ "ttypescript": "1.5.15",
57
+ "typescript": "4.7.4"
53
58
  },
54
- "gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
59
+ "gitHead": "085ff6572f6bb6a76d218088b06d9f4ef92bbea7"
55
60
  }
@@ -0,0 +1,43 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { AcoContext, IAcoApp, IAcoAppAddFieldCallable, IAcoAppModifyFieldCallable, IAcoAppRemoveFieldCallable } from "../types";
3
+ import { Context } from "@webiny/handler/types";
4
+ export interface AcoAppModifierPluginModifyParams<T extends Context = AcoContext> {
5
+ app: IAcoApp;
6
+ context: T;
7
+ }
8
+ export interface AcoAppModifierPluginParamsCallable<T extends Context = AcoContext> {
9
+ (params: AppModifier<T>): Promise<void> | void;
10
+ }
11
+ export interface AcoAppModifierPluginParams<T extends Context = AcoContext> {
12
+ name: string;
13
+ cb: AcoAppModifierPluginParamsCallable<T>;
14
+ }
15
+ export interface AppModifier<T extends Context = AcoContext> {
16
+ /**
17
+ * We can access the app if really required.
18
+ * @internal
19
+ */
20
+ app: IAcoApp;
21
+ /**
22
+ * We can access the context if really required.
23
+ * @internal
24
+ */
25
+ context: T;
26
+ addField: IAcoAppAddFieldCallable;
27
+ removeField: IAcoAppRemoveFieldCallable;
28
+ modifyField: IAcoAppModifyFieldCallable;
29
+ }
30
+ export interface AppModifierParams<T extends Context = AcoContext> {
31
+ app: IAcoApp;
32
+ context: T;
33
+ }
34
+ export declare class AcoAppModifierPlugin<T extends Context = Context> extends Plugin {
35
+ static readonly type: string;
36
+ private readonly params;
37
+ private constructor();
38
+ static create<C extends Context = AcoContext>(params: AcoAppModifierPluginParams<C>): AcoAppModifierPlugin<C>;
39
+ canUse(app: IAcoApp): boolean;
40
+ modify(params: AcoAppModifierPluginModifyParams<T>): Promise<void>;
41
+ }
42
+ export declare type CreateAcoAppModifierCallable<T extends Context = AcoContext> = AcoAppModifierPluginParamsCallable<T>;
43
+ export declare const createAcoAppModifier: <T extends Context = AcoContext>(name: string, cb: CreateAcoAppModifierCallable<T>) => AcoAppModifierPlugin<T>;