@webiny/api-headless-cms-bulk-actions 5.43.0-beta.0 → 5.43.0-beta.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-bulk-actions",
|
|
3
|
-
"version": "5.43.0-beta.
|
|
3
|
+
"version": "5.43.0-beta.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Webiny Headless CMS bulk actions",
|
|
6
6
|
"keywords": [
|
|
@@ -13,26 +13,25 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/api-headless-cms": "5.43.0-beta.
|
|
17
|
-
"@webiny/handler": "5.43.0-beta.
|
|
18
|
-
"@webiny/handler-aws": "5.43.0-beta.
|
|
19
|
-
"@webiny/tasks": "5.43.0-beta.
|
|
20
|
-
"@webiny/utils": "5.43.0-beta.
|
|
16
|
+
"@webiny/api-headless-cms": "5.43.0-beta.2",
|
|
17
|
+
"@webiny/handler": "5.43.0-beta.2",
|
|
18
|
+
"@webiny/handler-aws": "5.43.0-beta.2",
|
|
19
|
+
"@webiny/tasks": "5.43.0-beta.2",
|
|
20
|
+
"@webiny/utils": "5.43.0-beta.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@webiny/api": "5.43.0-beta.
|
|
24
|
-
"@webiny/api-admin-users": "5.43.0-beta.
|
|
25
|
-
"@webiny/api-i18n": "5.43.0-beta.
|
|
26
|
-
"@webiny/api-security": "5.43.0-beta.
|
|
27
|
-
"@webiny/api-tenancy": "5.43.0-beta.
|
|
28
|
-
"@webiny/api-wcp": "5.43.0-beta.
|
|
29
|
-
"@webiny/handler-graphql": "5.43.0-beta.
|
|
30
|
-
"@webiny/plugins": "5.43.0-beta.
|
|
31
|
-
"@webiny/project-utils": "5.43.0-beta.
|
|
32
|
-
"@webiny/wcp": "5.43.0-beta.
|
|
23
|
+
"@webiny/api": "5.43.0-beta.2",
|
|
24
|
+
"@webiny/api-admin-users": "5.43.0-beta.2",
|
|
25
|
+
"@webiny/api-i18n": "5.43.0-beta.2",
|
|
26
|
+
"@webiny/api-security": "5.43.0-beta.2",
|
|
27
|
+
"@webiny/api-tenancy": "5.43.0-beta.2",
|
|
28
|
+
"@webiny/api-wcp": "5.43.0-beta.2",
|
|
29
|
+
"@webiny/handler-graphql": "5.43.0-beta.2",
|
|
30
|
+
"@webiny/plugins": "5.43.0-beta.2",
|
|
31
|
+
"@webiny/project-utils": "5.43.0-beta.2",
|
|
32
|
+
"@webiny/wcp": "5.43.0-beta.2",
|
|
33
33
|
"graphql": "15.9.0",
|
|
34
|
-
"
|
|
35
|
-
"typescript": "4.9.5"
|
|
34
|
+
"typescript": "5.3.3"
|
|
36
35
|
},
|
|
37
36
|
"scripts": {
|
|
38
37
|
"build": "node ../cli/bin.js run build",
|
|
@@ -42,5 +41,5 @@
|
|
|
42
41
|
"access": "public",
|
|
43
42
|
"directory": "dist"
|
|
44
43
|
},
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "dbed8c263df662358aca18c3cf452cd280f2dfd9"
|
|
46
45
|
}
|
|
@@ -54,6 +54,9 @@ const createEmptyTrashBinsTask = () => {
|
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// Reloading locales for the current tenant to ensure the correct data is available before proceeding.
|
|
58
|
+
await context.i18n.reloadLocales();
|
|
59
|
+
|
|
57
60
|
// Fetch all locales for the tenant.
|
|
58
61
|
const locales = context.i18n.getLocales();
|
|
59
62
|
await context.i18n.withEachLocale(locales, async () => {
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","i18n","reloadLocales","locales","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 // Reloading locales for the current tenant to ensure the correct data is available before proceeding.\n await context.i18n.reloadLocales();\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,GAAG,EAAE,MAAOC,MAAiC,IAAK;MAC9C,MAAM;QAAEC,QAAQ;QAAEC,SAAS;QAAEC,OAAO;QAAEC,KAAK;QAAEC;MAAiB,CAAC,GAAGL,MAAM;;MAExE;MACA,IAAIE,SAAS,CAAC,CAAC,EAAE;QACb,OAAOD,QAAQ,CAACK,OAAO,CAAC,CAAC;MAC7B;;MAEA;MACA,MAAMC,WAAW,GAAG,MAAMJ,OAAO,CAAC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