@webiny/api-headless-cms-bulk-actions 5.41.1-beta.4 → 5.41.2-beta.0
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/handlers/eventBridgeEventHandler.js +2 -3
- package/handlers/eventBridgeEventHandler.js.map +1 -1
- package/package.json +18 -18
- package/plugins/createBulkActionGraphQL.js +5 -2
- package/plugins/createBulkActionGraphQL.js.map +1 -1
- package/plugins/createDefaultGraphQL.js +5 -2
- package/plugins/createDefaultGraphQL.js.map +1 -1
- package/tasks/createEmptyTrashBinsTask.d.ts +2 -2
- package/tasks/createEmptyTrashBinsTask.js +68 -85
- package/tasks/createEmptyTrashBinsTask.js.map +1 -1
- package/types.d.ts +7 -3
- package/types.js +1 -1
- package/types.js.map +1 -1
|
@@ -26,10 +26,9 @@ const createEventBridgeHandler = () => {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Since the event is at the infrastructure level, it has no knowledge about tenancy.
|
|
29
|
-
* We
|
|
29
|
+
* We trigger the `hcmsEntriesEmptyTrashBins` using root tenant.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
await context.tenancy.withEachTenant(tenants, async () => {
|
|
31
|
+
await context.tenancy.withRootTenant(async () => {
|
|
33
32
|
await context.tasks.trigger({
|
|
34
33
|
definition: "hcmsEntriesEmptyTrashBins"
|
|
35
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerAws","require","DETAIL_TYPE","createEventBridgeHandler","createEventBridgeEventHandler","context","ctx","payload","tasks","tenancy","console","error","
|
|
1
|
+
{"version":3,"names":["_handlerAws","require","DETAIL_TYPE","createEventBridgeHandler","createEventBridgeEventHandler","context","ctx","payload","tasks","tenancy","console","error","withRootTenant","trigger","definition","ex","JSON","stringify","message","code","data","exports"],"sources":["eventBridgeEventHandler.ts"],"sourcesContent":["import { createEventBridgeEventHandler } from \"@webiny/handler-aws\";\nimport { HcmsBulkActionsContext } from \"~/types\";\n\nconst DETAIL_TYPE = \"WebinyEmptyTrashBin\";\n\nexport const createEventBridgeHandler = () => {\n return createEventBridgeEventHandler<typeof DETAIL_TYPE, Record<string, any>>(\n async ({ context: ctx, payload }) => {\n try {\n /**\n * If we receive an event that is not \"WebinyEmptyTrashBin\", we should exit.\n */\n if (payload[\"detail-type\"] !== DETAIL_TYPE) {\n return;\n }\n\n const context = ctx as unknown as HcmsBulkActionsContext;\n\n if (!context.tasks || !context.tenancy) {\n console.error(\"Missing tasks or tenancy definition on context.\");\n return;\n }\n\n /**\n * Since the event is at the infrastructure level, it has no knowledge about tenancy.\n * We trigger the `hcmsEntriesEmptyTrashBins` using root tenant.\n */\n await context.tenancy.withRootTenant(async () => {\n await context.tasks.trigger({\n definition: \"hcmsEntriesEmptyTrashBins\"\n });\n });\n\n return;\n } catch (ex) {\n console.error(\n \"[EVENT_BRIDGE_HANDLER_EMPTY_TRASH_BIN] => \",\n JSON.stringify({\n message: ex.message,\n code: ex.code,\n data: ex.data\n })\n );\n }\n }\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAGA,MAAMC,WAAW,GAAG,qBAAqB;AAElC,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,OAAO,IAAAC,yCAA6B,EAChC,OAAO;IAAEC,OAAO,EAAEC,GAAG;IAAEC;EAAQ,CAAC,KAAK;IACjC,IAAI;MACA;AAChB;AACA;MACgB,IAAIA,OAAO,CAAC,aAAa,CAAC,KAAKL,WAAW,EAAE;QACxC;MACJ;MAEA,MAAMG,OAAO,GAAGC,GAAwC;MAExD,IAAI,CAACD,OAAO,CAACG,KAAK,IAAI,CAACH,OAAO,CAACI,OAAO,EAAE;QACpCC,OAAO,CAACC,KAAK,CAAC,iDAAiD,CAAC;QAChE;MACJ;;MAEA;AAChB;AACA;AACA;MACgB,MAAMN,OAAO,CAACI,OAAO,CAACG,cAAc,CAAC,YAAY;QAC7C,MAAMP,OAAO,CAACG,KAAK,CAACK,OAAO,CAAC;UACxBC,UAAU,EAAE;QAChB,CAAC,CAAC;MACN,CAAC,CAAC;MAEF;IACJ,CAAC,CAAC,OAAOC,EAAE,EAAE;MACTL,OAAO,CAACC,KAAK,CACT,4CAA4C,EAC5CK,IAAI,CAACC,SAAS,CAAC;QACXC,OAAO,EAAEH,EAAE,CAACG,OAAO;QACnBC,IAAI,EAAEJ,EAAE,CAACI,IAAI;QACbC,IAAI,EAAEL,EAAE,CAACK;MACb,CAAC,CACL,CAAC;IACL;EACJ,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAlB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-bulk-actions",
|
|
3
|
-
"version": "5.41.
|
|
3
|
+
"version": "5.41.2-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Webiny Headless CMS bulk actions",
|
|
6
6
|
"keywords": [
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/api-headless-cms": "5.41.
|
|
17
|
-
"@webiny/handler": "5.41.
|
|
18
|
-
"@webiny/handler-aws": "5.41.
|
|
19
|
-
"@webiny/tasks": "5.41.
|
|
20
|
-
"@webiny/utils": "5.41.
|
|
16
|
+
"@webiny/api-headless-cms": "5.41.2-beta.0",
|
|
17
|
+
"@webiny/handler": "5.41.2-beta.0",
|
|
18
|
+
"@webiny/handler-aws": "5.41.2-beta.0",
|
|
19
|
+
"@webiny/tasks": "5.41.2-beta.0",
|
|
20
|
+
"@webiny/utils": "5.41.2-beta.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@babel/cli": "7.24.1",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"@babel/preset-env": "7.24.3",
|
|
26
26
|
"@babel/preset-typescript": "7.24.1",
|
|
27
27
|
"@babel/runtime": "7.24.1",
|
|
28
|
-
"@webiny/api": "5.41.
|
|
29
|
-
"@webiny/api-admin-users": "5.41.
|
|
30
|
-
"@webiny/api-i18n": "5.41.
|
|
31
|
-
"@webiny/api-security": "5.41.
|
|
32
|
-
"@webiny/api-tenancy": "5.41.
|
|
33
|
-
"@webiny/api-wcp": "5.41.
|
|
34
|
-
"@webiny/cli": "5.41.
|
|
35
|
-
"@webiny/handler-graphql": "5.41.
|
|
36
|
-
"@webiny/plugins": "5.41.
|
|
37
|
-
"@webiny/project-utils": "5.41.
|
|
38
|
-
"@webiny/wcp": "5.41.
|
|
28
|
+
"@webiny/api": "5.41.2-beta.0",
|
|
29
|
+
"@webiny/api-admin-users": "5.41.2-beta.0",
|
|
30
|
+
"@webiny/api-i18n": "5.41.2-beta.0",
|
|
31
|
+
"@webiny/api-security": "5.41.2-beta.0",
|
|
32
|
+
"@webiny/api-tenancy": "5.41.2-beta.0",
|
|
33
|
+
"@webiny/api-wcp": "5.41.2-beta.0",
|
|
34
|
+
"@webiny/cli": "5.41.2-beta.0",
|
|
35
|
+
"@webiny/handler-graphql": "5.41.2-beta.0",
|
|
36
|
+
"@webiny/plugins": "5.41.2-beta.0",
|
|
37
|
+
"@webiny/project-utils": "5.41.2-beta.0",
|
|
38
|
+
"@webiny/wcp": "5.41.2-beta.0",
|
|
39
39
|
"graphql": "15.8.0",
|
|
40
40
|
"ttypescript": "1.5.15",
|
|
41
41
|
"typescript": "4.9.5"
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"access": "public",
|
|
49
49
|
"directory": "dist"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "a259e2af938ceb1e2d35b2bef9edcee4459352de"
|
|
52
52
|
}
|
|
@@ -9,7 +9,9 @@ var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
|
9
9
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
10
10
|
const createBulkActionGraphQL = config => {
|
|
11
11
|
return new _api.ContextPlugin(async context => {
|
|
12
|
-
|
|
12
|
+
const tenant = context.tenancy.getCurrentTenant();
|
|
13
|
+
const locale = context.i18n.getContentLocale();
|
|
14
|
+
if (!locale || !(await (0, _apiHeadlessCms.isHeadlessCmsReady)(context))) {
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
15
17
|
const models = await context.security.withoutAuthorization(async () => {
|
|
@@ -43,7 +45,8 @@ const createBulkActionGraphQL = config => {
|
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
|
-
}
|
|
48
|
+
},
|
|
49
|
+
isApplicable: context => context.tenancy.getCurrentTenant().id === tenant.id && context.i18n.getContentLocale()?.code === locale.code
|
|
47
50
|
});
|
|
48
51
|
plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${config.name}`;
|
|
49
52
|
plugins.push(plugin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_api","require","_apiHeadlessCms","_handlerGraphql","createBulkActionGraphQL","config","ContextPlugin","context","isHeadlessCmsReady","models","security","withoutAuthorization","allModels","cms","listModels","filter","model","isPrivate","modelIds","length","includes","modelId","plugins","forEach","plugin","CmsGraphQLSchemaPlugin","typeDefs","singularApiName","name","resolvers","Mutation","_","args","identity","getIdentity","response","tasks","trigger","definition","action","input","where","search","data","Response","id","push","register","exports"],"sources":["createBulkActionGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { HcmsBulkActionsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport { Response } from \"@webiny/handler-graphql\";\n\nexport interface CreateBulkActionGraphQL {\n name: string;\n modelIds?: string[];\n}\n\nexport const createBulkActionGraphQL = (config: CreateBulkActionGraphQL) => {\n return new ContextPlugin<HcmsBulkActionsContext>(async context => {\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n const models = await context.security.withoutAuthorization(async () => {\n const allModels = await context.cms.listModels();\n return allModels.filter(\n model =>\n !model.isPrivate &&\n (!config.modelIds?.length || config.modelIds.includes(model.modelId))\n );\n });\n\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n extend enum BulkAction${model.singularApiName}Name {\n ${config.name}\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args) => {\n const identity = context.security.getIdentity();\n\n const response = await context.tasks.trigger({\n definition: `hcmsBulkList${args.action}Entries`,\n input: {\n modelId: model.modelId,\n where: args.where,\n search: args.search,\n data: args.data,\n identity\n }\n });\n\n return new Response({\n id: response.id\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${config.name}`;\n plugins.push(plugin);\n });\n\n context.plugins.register([...plugins]);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAOO,MAAMG,uBAAuB,GAAIC,MAA+B,IAAK;EACxE,OAAO,IAAIC,kBAAa,CAAyB,MAAMC,OAAO,IAAI;IAC9D,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"names":["_api","require","_apiHeadlessCms","_handlerGraphql","createBulkActionGraphQL","config","ContextPlugin","context","tenant","tenancy","getCurrentTenant","locale","i18n","getContentLocale","isHeadlessCmsReady","models","security","withoutAuthorization","allModels","cms","listModels","filter","model","isPrivate","modelIds","length","includes","modelId","plugins","forEach","plugin","CmsGraphQLSchemaPlugin","typeDefs","singularApiName","name","resolvers","Mutation","_","args","identity","getIdentity","response","tasks","trigger","definition","action","input","where","search","data","Response","id","isApplicable","code","push","register","exports"],"sources":["createBulkActionGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { HcmsBulkActionsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport { Response } from \"@webiny/handler-graphql\";\n\nexport interface CreateBulkActionGraphQL {\n name: string;\n modelIds?: string[];\n}\n\nexport const createBulkActionGraphQL = (config: CreateBulkActionGraphQL) => {\n return new ContextPlugin<HcmsBulkActionsContext>(async context => {\n const tenant = context.tenancy.getCurrentTenant();\n const locale = context.i18n.getContentLocale();\n\n if (!locale || !(await isHeadlessCmsReady(context))) {\n return;\n }\n\n const models = await context.security.withoutAuthorization(async () => {\n const allModels = await context.cms.listModels();\n return allModels.filter(\n model =>\n !model.isPrivate &&\n (!config.modelIds?.length || config.modelIds.includes(model.modelId))\n );\n });\n\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n extend enum BulkAction${model.singularApiName}Name {\n ${config.name}\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args) => {\n const identity = context.security.getIdentity();\n\n const response = await context.tasks.trigger({\n definition: `hcmsBulkList${args.action}Entries`,\n input: {\n modelId: model.modelId,\n where: args.where,\n search: args.search,\n data: args.data,\n identity\n }\n });\n\n return new Response({\n id: response.id\n });\n }\n }\n },\n isApplicable: context =>\n context.tenancy.getCurrentTenant().id === tenant.id &&\n context.i18n.getContentLocale()?.code === locale.code\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${config.name}`;\n plugins.push(plugin);\n });\n\n context.plugins.register([...plugins]);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAOO,MAAMG,uBAAuB,GAAIC,MAA+B,IAAK;EACxE,OAAO,IAAIC,kBAAa,CAAyB,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,OAAO,EAAEL,KAAK,CAACK,OAAO;kBACtBoB,KAAK,EAAET,IAAI,CAACS,KAAK;kBACjBC,MAAM,EAAEV,IAAI,CAACU,MAAM;kBACnBC,IAAI,EAAEX,IAAI,CAACW,IAAI;kBACfV;gBACJ;cACJ,CAAC,CAAC;cAEF,OAAO,IAAIW,wBAAQ,CAAC;gBAChBC,EAAE,EAAEV,QAAQ,CAACU;cACjB,CAAC,CAAC;YACN;UACJ;QACJ,CAAC;QACDC,YAAY,EAAE7C,OAAO,IACjBA,OAAO,CAACE,OAAO,CAACC,gBAAgB,CAAC,CAAC,CAACyC,EAAE,KAAK3C,MAAM,CAAC2C,EAAE,IACnD5C,OAAO,CAACK,IAAI,CAACC,gBAAgB,CAAC,CAAC,EAAEwC,IAAI,KAAK1C,MAAM,CAAC0C;MACzD,CAAC,CAAC;MAEFvB,MAAM,CAACI,IAAI,GAAI,0CAAyCZ,KAAK,CAACK,OAAQ,IAAGtB,MAAM,CAAC6B,IAAK,EAAC;MACtFN,OAAO,CAAC0B,IAAI,CAACxB,MAAM,CAAC;IACxB,CAAC,CAAC;IAEFvB,OAAO,CAACqB,OAAO,CAAC2B,QAAQ,CAAC,CAAC,GAAG3B,OAAO,CAAC,CAAC;EAC1C,CAAC,CAAC;AACN,CAAC;AAAC4B,OAAA,CAAApD,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -8,7 +8,9 @@ var _api = require("@webiny/api");
|
|
|
8
8
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
9
9
|
const createDefaultGraphQL = () => {
|
|
10
10
|
return new _api.ContextPlugin(async context => {
|
|
11
|
-
|
|
11
|
+
const tenant = context.tenancy.getCurrentTenant();
|
|
12
|
+
const locale = context.i18n.getContentLocale();
|
|
13
|
+
if (!locale || !(await (0, _apiHeadlessCms.isHeadlessCmsReady)(context))) {
|
|
12
14
|
return;
|
|
13
15
|
}
|
|
14
16
|
const defaultPlugin = new _apiHeadlessCms.CmsGraphQLSchemaPlugin({
|
|
@@ -44,7 +46,8 @@ const createDefaultGraphQL = () => {
|
|
|
44
46
|
data: JSON
|
|
45
47
|
): BulkActionResponse
|
|
46
48
|
}
|
|
47
|
-
|
|
49
|
+
`,
|
|
50
|
+
isApplicable: context => context.tenancy.getCurrentTenant().id === tenant.id && context.i18n.getContentLocale()?.code === locale.code
|
|
48
51
|
});
|
|
49
52
|
plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;
|
|
50
53
|
modelPlugins.push(plugin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_api","require","_apiHeadlessCms","createDefaultGraphQL","ContextPlugin","context","isHeadlessCmsReady","defaultPlugin","CmsGraphQLSchemaPlugin","typeDefs","name","models","security","withoutAuthorization","allModels","cms","listModels","filter","model","isPrivate","modelPlugins","forEach","plugin","singularApiName","modelId","push","plugins","register","exports"],"sources":["createDefaultGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { HcmsBulkActionsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\n\nexport const createDefaultGraphQL = () => {\n return new ContextPlugin<HcmsBulkActionsContext>(async context => {\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n const defaultPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type BulkActionResponseData {\n id: String\n }\n\n type BulkActionResponse {\n data: BulkActionResponseData\n error: CmsError\n }\n `\n });\n defaultPlugin.name = `headless-cms.graphql.schema.bulkAction.default`;\n\n const models = await context.security.withoutAuthorization(async () => {\n const allModels = await context.cms.listModels();\n return allModels.filter(model => !model.isPrivate);\n });\n\n const modelPlugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n enum BulkAction${model.singularApiName}Name {\n _empty\n }\n \n extend type Mutation {\n bulkAction${model.singularApiName}(\n action: BulkAction${model.singularApiName}Name!\n where: ${model.singularApiName}ListWhereInput\n search: String\n data: JSON\n ): BulkActionResponse\n }\n
|
|
1
|
+
{"version":3,"names":["_api","require","_apiHeadlessCms","createDefaultGraphQL","ContextPlugin","context","tenant","tenancy","getCurrentTenant","locale","i18n","getContentLocale","isHeadlessCmsReady","defaultPlugin","CmsGraphQLSchemaPlugin","typeDefs","name","models","security","withoutAuthorization","allModels","cms","listModels","filter","model","isPrivate","modelPlugins","forEach","plugin","singularApiName","isApplicable","id","code","modelId","push","plugins","register","exports"],"sources":["createDefaultGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { HcmsBulkActionsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\n\nexport const createDefaultGraphQL = () => {\n return new ContextPlugin<HcmsBulkActionsContext>(async context => {\n const tenant = context.tenancy.getCurrentTenant();\n const locale = context.i18n.getContentLocale();\n\n if (!locale || !(await isHeadlessCmsReady(context))) {\n return;\n }\n\n const defaultPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type BulkActionResponseData {\n id: String\n }\n\n type BulkActionResponse {\n data: BulkActionResponseData\n error: CmsError\n }\n `\n });\n defaultPlugin.name = `headless-cms.graphql.schema.bulkAction.default`;\n\n const models = await context.security.withoutAuthorization(async () => {\n const allModels = await context.cms.listModels();\n return allModels.filter(model => !model.isPrivate);\n });\n\n const modelPlugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n enum BulkAction${model.singularApiName}Name {\n _empty\n }\n \n extend type Mutation {\n bulkAction${model.singularApiName}(\n action: BulkAction${model.singularApiName}Name!\n where: ${model.singularApiName}ListWhereInput\n search: String\n data: JSON\n ): BulkActionResponse\n }\n `,\n isApplicable: context =>\n context.tenancy.getCurrentTenant().id === tenant.id &&\n context.i18n.getContentLocale()?.code === locale.code\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;\n modelPlugins.push(plugin);\n });\n\n context.plugins.register([defaultPlugin, ...modelPlugins]);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAEO,MAAME,oBAAoB,GAAGA,CAAA,KAAM;EACtC,OAAO,IAAIC,kBAAa,CAAyB,MAAMC,OAAO,IAAI;IAC9D,MAAMC,MAAM,GAAGD,OAAO,CAACE,OAAO,CAACC,gBAAgB,CAAC,CAAC;IACjD,MAAMC,MAAM,GAAGJ,OAAO,CAACK,IAAI,CAACC,gBAAgB,CAAC,CAAC;IAE9C,IAAI,CAACF,MAAM,IAAI,EAAE,MAAM,IAAAG,kCAAkB,EAACP,OAAO,CAAC,CAAC,EAAE;MACjD;IACJ;IAEA,MAAMQ,aAAa,GAAG,IAAIC,sCAAsB,CAAC;MAC7CC,QAAQ,EAAE,aAAe;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACQ,CAAC,CAAC;IACFF,aAAa,CAACG,IAAI,GAAI,gDAA+C;IAErE,MAAMC,MAAM,GAAG,MAAMZ,OAAO,CAACa,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACnE,MAAMC,SAAS,GAAG,MAAMf,OAAO,CAACgB,GAAG,CAACC,UAAU,CAAC,CAAC;MAChD,OAAOF,SAAS,CAACG,MAAM,CAACC,KAAK,IAAI,CAACA,KAAK,CAACC,SAAS,CAAC;IACtD,CAAC,CAAC;IAEF,MAAMC,YAA8D,GAAG,EAAE;IAEzET,MAAM,CAACU,OAAO,CAACH,KAAK,IAAI;MACpB,MAAMI,MAAM,GAAG,IAAId,sCAAsB,CAAC;QACtCC,QAAQ,EAAE,aAAe;AACzC,qCAAqCS,KAAK,CAACK,eAAgB;AAC3D;AACA;AACA;AACA;AACA,oCAAoCL,KAAK,CAACK,eAAgB;AAC1D,gDAAgDL,KAAK,CAACK,eAAgB;AACtE,qCAAqCL,KAAK,CAACK,eAAgB;AAC3D;AACA;AACA;AACA;AACA,iBAAiB;QACDC,YAAY,EAAEzB,OAAO,IACjBA,OAAO,CAACE,OAAO,CAACC,gBAAgB,CAAC,CAAC,CAACuB,EAAE,KAAKzB,MAAM,CAACyB,EAAE,IACnD1B,OAAO,CAACK,IAAI,CAACC,gBAAgB,CAAC,CAAC,EAAEqB,IAAI,KAAKvB,MAAM,CAACuB;MACzD,CAAC,CAAC;MAEFJ,MAAM,CAACZ,IAAI,GAAI,kDAAiDQ,KAAK,CAACS,OAAQ,EAAC;MAC/EP,YAAY,CAACQ,IAAI,CAACN,MAAM,CAAC;IAC7B,CAAC,CAAC;IAEFvB,OAAO,CAAC8B,OAAO,CAACC,QAAQ,CAAC,CAACvB,aAAa,EAAE,GAAGa,YAAY,CAAC,CAAC;EAC9D,CAAC,CAAC;AACN,CAAC;AAACW,OAAA,CAAAlC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HcmsBulkActionsContext } from "../types";
|
|
2
|
-
export declare const createEmptyTrashBinsTask: () => import("@webiny/tasks").TaskDefinitionPlugin<HcmsBulkActionsContext,
|
|
1
|
+
import { HcmsBulkActionsContext, IEmptyTrashBinsInput } from "../types";
|
|
2
|
+
export declare const createEmptyTrashBinsTask: () => import("@webiny/tasks").TaskDefinitionPlugin<HcmsBulkActionsContext, IEmptyTrashBinsInput, import("@webiny/tasks").ITaskResponseDoneResultOutput>;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createEmptyTrashBinsTask = void 0;
|
|
7
7
|
var _tasks = require("@webiny/tasks");
|
|
8
|
-
var
|
|
8
|
+
var _useCases = require("../useCases");
|
|
9
9
|
const calculateDateTimeString = () => {
|
|
10
10
|
// Retrieve the retention period from the environment variable WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS,
|
|
11
11
|
// or default to 90 days if not set or set to 0.
|
|
@@ -19,112 +19,95 @@ const calculateDateTimeString = () => {
|
|
|
19
19
|
// Return the calculated date-time string in ISO 8601 format.
|
|
20
20
|
return currentDate.toISOString();
|
|
21
21
|
};
|
|
22
|
-
const cleanup = async ({
|
|
23
|
-
context,
|
|
24
|
-
task
|
|
25
|
-
}) => {
|
|
26
|
-
// We want to clean all child tasks and logs, which have no errors.
|
|
27
|
-
const childTasksCleanup = new _internals.ChildTasksCleanup();
|
|
28
|
-
try {
|
|
29
|
-
await childTasksCleanup.execute({
|
|
30
|
-
context,
|
|
31
|
-
task
|
|
32
|
-
});
|
|
33
|
-
} catch (ex) {
|
|
34
|
-
console.error(`Error while cleaning "EmptyTrashBins" child tasks.`, ex);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
22
|
const createEmptyTrashBinsTask = () => {
|
|
38
|
-
return (0, _tasks.
|
|
23
|
+
return (0, _tasks.createTaskDefinition)({
|
|
24
|
+
isPrivate: true,
|
|
39
25
|
id: "hcmsEntriesEmptyTrashBins",
|
|
40
26
|
title: "Headless CMS - Empty all trash bins",
|
|
41
|
-
description: "Delete all entries
|
|
42
|
-
maxIterations:
|
|
27
|
+
description: "Delete all entries in the trash bin for each model in the system.",
|
|
28
|
+
maxIterations: 120,
|
|
43
29
|
disableDatabaseLogs: true,
|
|
44
30
|
run: async params => {
|
|
45
31
|
const {
|
|
46
32
|
response,
|
|
47
33
|
isAborted,
|
|
48
|
-
isCloseToTimeout,
|
|
49
34
|
context,
|
|
50
|
-
trigger,
|
|
51
35
|
input,
|
|
52
|
-
|
|
36
|
+
isCloseToTimeout
|
|
53
37
|
} = params;
|
|
38
|
+
|
|
39
|
+
// Abort the task if needed.
|
|
54
40
|
if (isAborted()) {
|
|
55
41
|
return response.aborted();
|
|
56
|
-
} else if (isCloseToTimeout()) {
|
|
57
|
-
return response.continue({
|
|
58
|
-
...input
|
|
59
|
-
}, {
|
|
60
|
-
seconds: 30
|
|
61
|
-
});
|
|
62
42
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
for (const item of items) {
|
|
77
|
-
const status = await context.tasks.fetchServiceInfo(item.id);
|
|
78
|
-
if (status?.status === "FAILED" || status?.status === "TIMED_OUT") {
|
|
79
|
-
await context.tasks.updateTask(item.id, {
|
|
80
|
-
taskStatus: _tasks.TaskDataStatus.FAILED
|
|
81
|
-
});
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (status?.status === "ABORTED") {
|
|
85
|
-
await context.tasks.updateTask(item.id, {
|
|
86
|
-
taskStatus: _tasks.TaskDataStatus.ABORTED
|
|
87
|
-
});
|
|
88
|
-
}
|
|
43
|
+
|
|
44
|
+
// Fetch all tenants, excluding those already processed.
|
|
45
|
+
const baseTenants = await context.tenancy.listTenants();
|
|
46
|
+
const executedTenantIds = input.executedTenantIds || [];
|
|
47
|
+
const tenants = baseTenants.filter(tenant => !executedTenantIds.includes(tenant.id));
|
|
48
|
+
let shouldContinue = false; // Flag to check if task should continue.
|
|
49
|
+
|
|
50
|
+
// Iterate over each tenant.
|
|
51
|
+
await context.tenancy.withEachTenant(tenants, async tenant => {
|
|
52
|
+
if (isCloseToTimeout()) {
|
|
53
|
+
shouldContinue = true;
|
|
54
|
+
return;
|
|
89
55
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, {
|
|
93
|
-
seconds: 3600
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
56
|
+
|
|
57
|
+
// Fetch all locales for the tenant.
|
|
97
58
|
const locales = context.i18n.getLocales();
|
|
98
59
|
await context.i18n.withEachLocale(locales, async () => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
60
|
+
if (isCloseToTimeout()) {
|
|
61
|
+
shouldContinue = true;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// List all non-private models for the current locale.
|
|
66
|
+
const models = await context.security.withoutAuthorization(async () => (await context.cms.listModels()).filter(m => !m.isPrivate));
|
|
67
|
+
|
|
68
|
+
// Process each model to delete trashed entries.
|
|
102
69
|
for (const model of models) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
70
|
+
const list = (0, _useCases.createListDeletedEntries)(context); // List trashed entries.
|
|
71
|
+
const mutation = (0, _useCases.createDeleteEntry)(context); // Mutation to delete entries.
|
|
72
|
+
|
|
73
|
+
// Query parameters for fetching deleted entries older than a minute ago.
|
|
74
|
+
const listEntriesParams = {
|
|
75
|
+
where: {
|
|
76
|
+
deletedOn_lt: calculateDateTimeString()
|
|
77
|
+
},
|
|
78
|
+
limit: 50
|
|
79
|
+
};
|
|
80
|
+
let result;
|
|
81
|
+
// Continue deleting entries while there are entries left to delete.
|
|
82
|
+
while ((result = await list.execute(model.modelId, listEntriesParams)) && result.meta.totalCount > 0) {
|
|
83
|
+
if (isCloseToTimeout()) {
|
|
84
|
+
shouldContinue = true;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
for (const entry of result.entries) {
|
|
88
|
+
if (isCloseToTimeout()) {
|
|
89
|
+
shouldContinue = true;
|
|
90
|
+
break;
|
|
110
91
|
}
|
|
92
|
+
// Delete each entry individually.
|
|
93
|
+
await mutation.execute(model, entry.id);
|
|
111
94
|
}
|
|
112
|
-
}
|
|
95
|
+
}
|
|
113
96
|
}
|
|
114
97
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
|
|
99
|
+
// If the task isn't continuing, add the tenant to the executed list.
|
|
100
|
+
if (!shouldContinue) {
|
|
101
|
+
executedTenantIds.push(tenant.id);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Continue the task or mark it as done based on the `shouldContinue` flag.
|
|
106
|
+
return shouldContinue ? response.continue({
|
|
107
|
+
...input,
|
|
108
|
+
executedTenantIds
|
|
109
|
+
}) : response.done("Task done: emptied the trash bin for all registered models.");
|
|
110
|
+
}
|
|
128
111
|
});
|
|
129
112
|
};
|
|
130
113
|
exports.createEmptyTrashBinsTask = createEmptyTrashBinsTask;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_tasks","require","
|
|
1
|
+
{"version":3,"names":["_tasks","require","_useCases","calculateDateTimeString","retentionPeriodFromEnv","process","env","retentionPeriod","Number","currentDate","Date","setDate","getDate","toISOString","createEmptyTrashBinsTask","createTaskDefinition","isPrivate","id","title","description","maxIterations","disableDatabaseLogs","run","params","response","isAborted","context","input","isCloseToTimeout","aborted","baseTenants","tenancy","listTenants","executedTenantIds","tenants","filter","tenant","includes","shouldContinue","withEachTenant","locales","i18n","getLocales","withEachLocale","models","security","withoutAuthorization","cms","listModels","m","model","list","createListDeletedEntries","mutation","createDeleteEntry","listEntriesParams","where","deletedOn_lt","limit","result","execute","modelId","meta","totalCount","entry","entries","push","continue","done","exports"],"sources":["createEmptyTrashBinsTask.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport { createDeleteEntry, createListDeletedEntries } from \"~/useCases\";\nimport {\n HcmsBulkActionsContext,\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput,\n IEmptyTrashBinsTaskParams\n} from \"~/types\";\n\nconst calculateDateTimeString = () => {\n // Retrieve the retention period from the environment variable WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS,\n // or default to 90 days if not set or set to 0.\n const retentionPeriodFromEnv = process.env[\"WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS\"];\n const retentionPeriod =\n retentionPeriodFromEnv && Number(retentionPeriodFromEnv) !== 0\n ? Number(retentionPeriodFromEnv)\n : 90;\n\n // Calculate the date-time by subtracting the retention period (in days) from the current date.\n const currentDate = new Date();\n currentDate.setDate(currentDate.getDate() - retentionPeriod);\n\n // Return the calculated date-time string in ISO 8601 format.\n return currentDate.toISOString();\n};\n\nexport const createEmptyTrashBinsTask = () => {\n return createTaskDefinition<\n HcmsBulkActionsContext,\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n >({\n isPrivate: true,\n id: \"hcmsEntriesEmptyTrashBins\",\n title: \"Headless CMS - Empty all trash bins\",\n description: \"Delete all entries in the trash bin for each model in the system.\",\n maxIterations: 120,\n disableDatabaseLogs: true,\n run: async (params: IEmptyTrashBinsTaskParams) => {\n const { response, isAborted, context, input, isCloseToTimeout } = params;\n\n // Abort the task if needed.\n if (isAborted()) {\n return response.aborted();\n }\n\n // Fetch all tenants, excluding those already processed.\n const baseTenants = await context.tenancy.listTenants();\n const executedTenantIds = input.executedTenantIds || [];\n const tenants = baseTenants.filter(tenant => !executedTenantIds.includes(tenant.id));\n let shouldContinue = false; // Flag to check if task should continue.\n\n // Iterate over each tenant.\n await context.tenancy.withEachTenant(tenants, async tenant => {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n return;\n }\n\n // Fetch all locales for the tenant.\n const locales = context.i18n.getLocales();\n await context.i18n.withEachLocale(locales, async () => {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n return;\n }\n\n // List all non-private models for the current locale.\n const models = await context.security.withoutAuthorization(async () =>\n (await context.cms.listModels()).filter(m => !m.isPrivate)\n );\n\n // Process each model to delete trashed entries.\n for (const model of models) {\n const list = createListDeletedEntries(context); // List trashed entries.\n const mutation = createDeleteEntry(context); // Mutation to delete entries.\n\n // Query parameters for fetching deleted entries older than a minute ago.\n const listEntriesParams = {\n where: { deletedOn_lt: calculateDateTimeString() },\n limit: 50\n };\n\n let result;\n // Continue deleting entries while there are entries left to delete.\n while (\n (result = await list.execute(model.modelId, listEntriesParams)) &&\n result.meta.totalCount > 0\n ) {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n break;\n }\n for (const entry of result.entries) {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n break;\n }\n // Delete each entry individually.\n await mutation.execute(model, entry.id);\n }\n }\n }\n });\n\n // If the task isn't continuing, add the tenant to the executed list.\n if (!shouldContinue) {\n executedTenantIds.push(tenant.id);\n }\n });\n\n // Continue the task or mark it as done based on the `shouldContinue` flag.\n return shouldContinue\n ? response.continue({ ...input, executedTenantIds })\n : response.done(\"Task done: emptied the trash bin for all registered models.\");\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAQA,MAAME,uBAAuB,GAAGA,CAAA,KAAM;EAClC;EACA;EACA,MAAMC,sBAAsB,GAAGC,OAAO,CAACC,GAAG,CAAC,wCAAwC,CAAC;EACpF,MAAMC,eAAe,GACjBH,sBAAsB,IAAII,MAAM,CAACJ,sBAAsB,CAAC,KAAK,CAAC,GACxDI,MAAM,CAACJ,sBAAsB,CAAC,GAC9B,EAAE;;EAEZ;EACA,MAAMK,WAAW,GAAG,IAAIC,IAAI,CAAC,CAAC;EAC9BD,WAAW,CAACE,OAAO,CAACF,WAAW,CAACG,OAAO,CAAC,CAAC,GAAGL,eAAe,CAAC;;EAE5D;EACA,OAAOE,WAAW,CAACI,WAAW,CAAC,CAAC;AACpC,CAAC;AAEM,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,OAAO,IAAAC,2BAAoB,EAIzB;IACEC,SAAS,EAAE,IAAI;IACfC,EAAE,EAAE,2BAA2B;IAC/BC,KAAK,EAAE,qCAAqC;IAC5CC,WAAW,EAAE,mEAAmE;IAChFC,aAAa,EAAE,GAAG;IAClBC,mBAAmB,EAAE,IAAI;IACzBC,GAA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|
import { Context as BaseContext } from "@webiny/handler/types";
|
|
3
|
-
import { Context as TasksContext,
|
|
3
|
+
import { Context as TasksContext, ITaskResponseDoneResultOutput, ITaskRunParams } from "@webiny/tasks/types";
|
|
4
4
|
import { SecurityIdentity } from "@webiny/api-security/types";
|
|
5
5
|
export interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {
|
|
6
6
|
}
|
|
@@ -44,6 +44,10 @@ export interface IBulkActionOperationByModelOutput extends ITaskResponseDoneResu
|
|
|
44
44
|
}
|
|
45
45
|
export type IBulkActionOperationByModelTaskParams = ITaskRunParams<HcmsBulkActionsContext, IBulkActionOperationByModelInput, IBulkActionOperationByModelOutput>;
|
|
46
46
|
/**
|
|
47
|
-
* Trash Bin
|
|
47
|
+
* Empty Trash Bin
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export interface IEmptyTrashBinsInput {
|
|
50
|
+
executedTenantIds?: string[] | null;
|
|
51
|
+
}
|
|
52
|
+
export type IEmptyTrashBinsOutput = ITaskResponseDoneResultOutput;
|
|
53
|
+
export type IEmptyTrashBinsTaskParams = ITaskRunParams<HcmsBulkActionsContext, IEmptyTrashBinsInput, IEmptyTrashBinsOutput>;
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BulkActionOperationByModelAction","exports"],"sources":["types.ts"],"sourcesContent":["import { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport {\n Context as TasksContext,\n
|
|
1
|
+
{"version":3,"names":["BulkActionOperationByModelAction","exports"],"sources":["types.ts"],"sourcesContent":["import { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport {\n Context as TasksContext,\n ITaskResponseDoneResultOutput,\n ITaskRunParams\n} from \"@webiny/tasks/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {}\n\n/**\n * Bulk Action Operation\n */\n\nexport interface IBulkActionOperationInput {\n modelId: string;\n ids: string[];\n data?: Record<string, any>;\n identity: SecurityIdentity;\n done?: string[];\n failed?: string[];\n}\n\nexport interface IBulkActionOperationOutput extends ITaskResponseDoneResultOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationTaskParams = ITaskRunParams<\n HcmsBulkActionsContext,\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n>;\n\n/**\n * Bulk Action Operation By Model\n */\n\nexport enum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport interface IBulkActionOperationByModelInput {\n modelId: string;\n identity?: SecurityIdentity;\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n data?: Record<string, any>;\n action?: BulkActionOperationByModelAction;\n}\n\nexport interface IBulkActionOperationByModelOutput extends ITaskResponseDoneResultOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationByModelTaskParams = ITaskRunParams<\n HcmsBulkActionsContext,\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n>;\n\n/**\n * Empty Trash Bin\n */\n\nexport interface IEmptyTrashBinsInput {\n executedTenantIds?: string[] | null;\n}\n\nexport type IEmptyTrashBinsOutput = ITaskResponseDoneResultOutput;\n\nexport type IEmptyTrashBinsTaskParams = ITaskRunParams<\n HcmsBulkActionsContext,\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n>;\n"],"mappings":";;;;;;AAWA;AACA;AACA;AAsBA;AACA;AACA;AAFA,IAIYA,gCAAgC,GAAAC,OAAA,CAAAD,gCAAA,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA;AA4B5C;AACA;AACA","ignoreList":[]}
|