@webiny/migrations 5.39.10-beta.1 → 5.39.10-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.
@@ -1,8 +1,10 @@
1
1
  import { CmsIdentity } from "@webiny/api-headless-cms/types";
2
2
  import { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ import { ExecuteWithRetryOptions } from "@webiny/utils";
3
4
  interface GetFallbackIdentityParams {
4
5
  entity: Entity;
5
6
  tenant: string;
7
+ retryOptions?: ExecuteWithRetryOptions;
6
8
  }
7
- export declare const getFallbackIdentity: ({ entity, tenant }: GetFallbackIdentityParams) => Promise<CmsIdentity>;
9
+ export declare const getFallbackIdentity: ({ entity, tenant, retryOptions }: GetFallbackIdentityParams) => Promise<CmsIdentity>;
8
10
  export {};
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getFallbackIdentity = void 0;
7
7
  var _dbDynamodb = require("@webiny/db-dynamodb");
8
+ var _utils = require("@webiny/utils");
8
9
  const NON_EXISTING_DATA_MIGRATION_IDENTITY = {
9
10
  id: "data-migration",
10
11
  type: "data-migration",
@@ -13,18 +14,22 @@ const NON_EXISTING_DATA_MIGRATION_IDENTITY = {
13
14
  const identitiesPerTenantCache = {};
14
15
  const getFallbackIdentity = async ({
15
16
  entity,
16
- tenant
17
+ tenant,
18
+ retryOptions
17
19
  }) => {
18
20
  if (identitiesPerTenantCache[tenant]) {
19
21
  return identitiesPerTenantCache[tenant];
20
22
  }
21
- const allAdminUsersRecords = await (0, _dbDynamodb.queryAll)({
22
- entity,
23
- partitionKey: `T#${tenant}#ADMIN_USERS`,
24
- options: {
25
- index: "GSI1"
26
- }
27
- });
23
+ const executeQueryAll = () => {
24
+ return (0, _dbDynamodb.queryAll)({
25
+ entity,
26
+ partitionKey: `T#${tenant}#ADMIN_USERS`,
27
+ options: {
28
+ index: "GSI1"
29
+ }
30
+ });
31
+ };
32
+ const allAdminUsersRecords = await (0, _utils.executeWithRetry)(executeQueryAll, retryOptions);
28
33
  if (allAdminUsersRecords.length === 0) {
29
34
  // Hopefully it doesn't come to this, but we still need to consider it.
30
35
  return NON_EXISTING_DATA_MIGRATION_IDENTITY;
@@ -1 +1 @@
1
- {"version":3,"names":["_dbDynamodb","require","NON_EXISTING_DATA_MIGRATION_IDENTITY","id","type","displayName","identitiesPerTenantCache","getFallbackIdentity","entity","tenant","allAdminUsersRecords","queryAll","partitionKey","options","index","length","oldestAdminUser","sort","prev","next","data","createdOn","exports"],"sources":["getFallbackIdentity.ts"],"sourcesContent":["import { CmsIdentity } from \"@webiny/api-headless-cms/types\";\nimport { queryAll } from \"@webiny/db-dynamodb\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\n\nconst NON_EXISTING_DATA_MIGRATION_IDENTITY: CmsIdentity = {\n id: \"data-migration\",\n type: \"data-migration\",\n displayName: \"Data Migration\"\n};\n\ninterface GetFallbackIdentityParams {\n entity: Entity;\n tenant: string;\n}\n\ninterface AdminUserRecord {\n data: {\n createdOn: string;\n id: string;\n displayName: string;\n };\n}\n\nconst identitiesPerTenantCache: Record<string, CmsIdentity> = {};\n\nexport const getFallbackIdentity = async ({\n entity,\n tenant\n}: GetFallbackIdentityParams): Promise<CmsIdentity> => {\n if (identitiesPerTenantCache[tenant]) {\n return identitiesPerTenantCache[tenant];\n }\n\n const allAdminUsersRecords = await queryAll<AdminUserRecord>({\n entity,\n partitionKey: `T#${tenant}#ADMIN_USERS`,\n options: {\n index: \"GSI1\"\n }\n });\n\n if (allAdminUsersRecords.length === 0) {\n // Hopefully it doesn't come to this, but we still need to consider it.\n return NON_EXISTING_DATA_MIGRATION_IDENTITY;\n }\n\n const [oldestAdminUser] = allAdminUsersRecords.sort((prev, next) => {\n return prev.data.createdOn < next.data.createdOn ? -1 : 1;\n });\n\n identitiesPerTenantCache[tenant] = {\n id: oldestAdminUser.data.id,\n type: \"admin\",\n displayName: oldestAdminUser.data.displayName\n };\n\n return identitiesPerTenantCache[tenant];\n};\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAGA,MAAMC,oCAAiD,GAAG;EACtDC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,gBAAgB;EACtBC,WAAW,EAAE;AACjB,CAAC;AAeD,MAAMC,wBAAqD,GAAG,CAAC,CAAC;AAEzD,MAAMC,mBAAmB,GAAG,MAAAA,CAAO;EACtCC,MAAM;EACNC;AACuB,CAAC,KAA2B;EACnD,IAAIH,wBAAwB,CAACG,MAAM,CAAC,EAAE;IAClC,OAAOH,wBAAwB,CAACG,MAAM,CAAC;EAC3C;EAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAAC,oBAAQ,EAAkB;IACzDH,MAAM;IACNI,YAAY,EAAG,KAAIH,MAAO,cAAa;IACvCI,OAAO,EAAE;MACLC,KAAK,EAAE;IACX;EACJ,CAAC,CAAC;EAEF,IAAIJ,oBAAoB,CAACK,MAAM,KAAK,CAAC,EAAE;IACnC;IACA,OAAOb,oCAAoC;EAC/C;EAEA,MAAM,CAACc,eAAe,CAAC,GAAGN,oBAAoB,CAACO,IAAI,CAAC,CAACC,IAAI,EAAEC,IAAI,KAAK;IAChE,OAAOD,IAAI,CAACE,IAAI,CAACC,SAAS,GAAGF,IAAI,CAACC,IAAI,CAACC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC;EAC7D,CAAC,CAAC;EAEFf,wBAAwB,CAACG,MAAM,CAAC,GAAG;IAC/BN,EAAE,EAAEa,eAAe,CAACI,IAAI,CAACjB,EAAE;IAC3BC,IAAI,EAAE,OAAO;IACbC,WAAW,EAAEW,eAAe,CAACI,IAAI,CAACf;EACtC,CAAC;EAED,OAAOC,wBAAwB,CAACG,MAAM,CAAC;AAC3C,CAAC;AAACa,OAAA,CAAAf,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"names":["_dbDynamodb","require","_utils","NON_EXISTING_DATA_MIGRATION_IDENTITY","id","type","displayName","identitiesPerTenantCache","getFallbackIdentity","entity","tenant","retryOptions","executeQueryAll","queryAll","partitionKey","options","index","allAdminUsersRecords","executeWithRetry","length","oldestAdminUser","sort","prev","next","data","createdOn","exports"],"sources":["getFallbackIdentity.ts"],"sourcesContent":["import { CmsIdentity } from \"@webiny/api-headless-cms/types\";\nimport { queryAll } from \"@webiny/db-dynamodb\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { executeWithRetry, ExecuteWithRetryOptions } from \"@webiny/utils\";\n\nconst NON_EXISTING_DATA_MIGRATION_IDENTITY: CmsIdentity = {\n id: \"data-migration\",\n type: \"data-migration\",\n displayName: \"Data Migration\"\n};\n\ninterface GetFallbackIdentityParams {\n entity: Entity;\n tenant: string;\n retryOptions?: ExecuteWithRetryOptions;\n}\n\ninterface AdminUserRecord {\n data: {\n createdOn: string;\n id: string;\n displayName: string;\n };\n}\n\nconst identitiesPerTenantCache: Record<string, CmsIdentity> = {};\n\nexport const getFallbackIdentity = async ({\n entity,\n tenant,\n retryOptions\n}: GetFallbackIdentityParams): Promise<CmsIdentity> => {\n if (identitiesPerTenantCache[tenant]) {\n return identitiesPerTenantCache[tenant];\n }\n\n const executeQueryAll = () => {\n return queryAll<AdminUserRecord>({\n entity,\n partitionKey: `T#${tenant}#ADMIN_USERS`,\n options: {\n index: \"GSI1\"\n }\n });\n };\n\n const allAdminUsersRecords = await executeWithRetry(executeQueryAll, retryOptions);\n\n if (allAdminUsersRecords.length === 0) {\n // Hopefully it doesn't come to this, but we still need to consider it.\n return NON_EXISTING_DATA_MIGRATION_IDENTITY;\n }\n\n const [oldestAdminUser] = allAdminUsersRecords.sort((prev, next) => {\n return prev.data.createdOn < next.data.createdOn ? -1 : 1;\n });\n\n identitiesPerTenantCache[tenant] = {\n id: oldestAdminUser.data.id,\n type: \"admin\",\n displayName: oldestAdminUser.data.displayName\n };\n\n return identitiesPerTenantCache[tenant];\n};\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,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@@ -1,11 +1,13 @@
1
1
  import { createDdbEntryEntity } from "./../entities/createEntryEntity";
2
2
  import { CmsEntry } from "../types";
3
+ import { ExecuteWithRetryOptions } from "@webiny/utils";
3
4
  interface CmsEntryWithPK extends CmsEntry {
4
5
  PK: string;
5
6
  }
6
7
  export interface getFirstLastPublishedOnParams {
7
8
  entry: CmsEntryWithPK;
8
9
  entryEntity: ReturnType<typeof createDdbEntryEntity>;
10
+ retryOptions?: ExecuteWithRetryOptions;
9
11
  }
10
12
  export declare const getFirstLastPublishedOnBy: (params: getFirstLastPublishedOnParams) => Promise<Pick<CmsEntry<import("../types").CmsEntryValues>, "firstPublishedOn" | "lastPublishedOn" | "firstPublishedBy" | "lastPublishedBy">>;
11
13
  export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getFirstLastPublishedOnBy = void 0;
7
+ var _utils = require("@webiny/utils");
7
8
  const cachedEntryFirstLastPublishedOnBy = {};
8
9
  const getFirstLastPublishedOnBy = async params => {
9
10
  const {
@@ -19,11 +20,14 @@ const getFirstLastPublishedOnBy = async params => {
19
20
  firstPublishedBy: null,
20
21
  lastPublishedBy: null
21
22
  };
22
- const result = await entryEntity.query(entry.PK, {
23
- limit: 1,
24
- eq: "P",
25
- attributes: ["modifiedBy", "createdBy", "publishedOn"]
26
- });
23
+ const executeQuery = () => {
24
+ return entryEntity.query(entry.PK, {
25
+ limit: 1,
26
+ eq: "P",
27
+ attributes: ["modifiedBy", "createdBy", "publishedOn"]
28
+ });
29
+ };
30
+ const result = await (0, _utils.executeWithRetry)(executeQuery, params.retryOptions);
27
31
  const publishedRecord = result.Items?.[0];
28
32
  if (publishedRecord) {
29
33
  cachedEntryFirstLastPublishedOnBy[entry.PK] = {
@@ -1 +1 @@
1
- {"version":3,"names":["cachedEntryFirstLastPublishedOnBy","getFirstLastPublishedOnBy","params","entry","entryEntity","PK","firstPublishedOn","lastPublishedOn","firstPublishedBy","lastPublishedBy","result","query","limit","eq","attributes","publishedRecord","Items","publishedOn","modifiedBy","createdBy","exports"],"sources":["getFirstLastPublishedOn.ts"],"sourcesContent":["import { createDdbEntryEntity } from \"./../entities/createEntryEntity\";\nimport { CmsEntry } from \"../types\";\n\nconst cachedEntryFirstLastPublishedOnBy: Record<\n string,\n Pick<CmsEntry, \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\">\n> = {};\n\ninterface CmsEntryWithPK extends CmsEntry {\n PK: string;\n}\n\nexport interface getFirstLastPublishedOnParams {\n entry: CmsEntryWithPK;\n entryEntity: ReturnType<typeof createDdbEntryEntity>;\n}\n\nexport const getFirstLastPublishedOnBy = async (params: getFirstLastPublishedOnParams) => {\n const { entry, entryEntity } = params;\n\n if (cachedEntryFirstLastPublishedOnBy[entry.PK]) {\n return cachedEntryFirstLastPublishedOnBy[entry.PK];\n }\n\n cachedEntryFirstLastPublishedOnBy[entry.PK] = {\n firstPublishedOn: null,\n lastPublishedOn: null,\n firstPublishedBy: null,\n lastPublishedBy: null\n };\n\n const result = await entryEntity.query(entry.PK, {\n limit: 1,\n eq: \"P\",\n attributes: [\"modifiedBy\", \"createdBy\", \"publishedOn\"]\n });\n\n const publishedRecord = result.Items?.[0];\n if (publishedRecord) {\n cachedEntryFirstLastPublishedOnBy[entry.PK] = {\n firstPublishedOn: publishedRecord.publishedOn || null,\n lastPublishedOn: publishedRecord.publishedOn || null,\n firstPublishedBy: entry.modifiedBy || entry.createdBy || null,\n lastPublishedBy: entry.modifiedBy || entry.createdBy || null\n };\n }\n\n return cachedEntryFirstLastPublishedOnBy[entry.PK];\n};\n"],"mappings":";;;;;;AAGA,MAAMA,iCAGL,GAAG,CAAC,CAAC;AAWC,MAAMC,yBAAyB,GAAG,MAAOC,MAAqC,IAAK;EACtF,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGF,MAAM;EAErC,IAAIF,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC,EAAE;IAC7C,OAAOL,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC;EACtD;EAEAL,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC,GAAG;IAC1CC,gBAAgB,EAAE,IAAI;IACtBC,eAAe,EAAE,IAAI;IACrBC,gBAAgB,EAAE,IAAI;IACtBC,eAAe,EAAE;EACrB,CAAC;EAED,MAAMC,MAAM,GAAG,MAAMN,WAAW,CAACO,KAAK,CAACR,KAAK,CAACE,EAAE,EAAE;IAC7CO,KAAK,EAAE,CAAC;IACRC,EAAE,EAAE,GAAG;IACPC,UAAU,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,aAAa;EACzD,CAAC,CAAC;EAEF,MAAMC,eAAe,GAAGL,MAAM,CAACM,KAAK,GAAG,CAAC,CAAC;EACzC,IAAID,eAAe,EAAE;IACjBf,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC,GAAG;MAC1CC,gBAAgB,EAAES,eAAe,CAACE,WAAW,IAAI,IAAI;MACrDV,eAAe,EAAEQ,eAAe,CAACE,WAAW,IAAI,IAAI;MACpDT,gBAAgB,EAAEL,KAAK,CAACe,UAAU,IAAIf,KAAK,CAACgB,SAAS,IAAI,IAAI;MAC7DV,eAAe,EAAEN,KAAK,CAACe,UAAU,IAAIf,KAAK,CAACgB,SAAS,IAAI;IAC5D,CAAC;EACL;EAEA,OAAOnB,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC;AACtD,CAAC;AAACe,OAAA,CAAAnB,yBAAA,GAAAA,yBAAA"}
1
+ {"version":3,"names":["_utils","require","cachedEntryFirstLastPublishedOnBy","getFirstLastPublishedOnBy","params","entry","entryEntity","PK","firstPublishedOn","lastPublishedOn","firstPublishedBy","lastPublishedBy","executeQuery","query","limit","eq","attributes","result","executeWithRetry","retryOptions","publishedRecord","Items","publishedOn","modifiedBy","createdBy","exports"],"sources":["getFirstLastPublishedOn.ts"],"sourcesContent":["import { createDdbEntryEntity } from \"./../entities/createEntryEntity\";\nimport { CmsEntry } from \"../types\";\nimport { executeWithRetry, ExecuteWithRetryOptions } from \"@webiny/utils\";\n\nconst cachedEntryFirstLastPublishedOnBy: Record<\n string,\n Pick<CmsEntry, \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\">\n> = {};\n\ninterface CmsEntryWithPK extends CmsEntry {\n PK: string;\n}\n\nexport interface getFirstLastPublishedOnParams {\n entry: CmsEntryWithPK;\n entryEntity: ReturnType<typeof createDdbEntryEntity>;\n retryOptions?: ExecuteWithRetryOptions;\n}\n\nexport const getFirstLastPublishedOnBy = async (params: getFirstLastPublishedOnParams) => {\n const { entry, entryEntity } = params;\n\n if (cachedEntryFirstLastPublishedOnBy[entry.PK]) {\n return cachedEntryFirstLastPublishedOnBy[entry.PK];\n }\n\n cachedEntryFirstLastPublishedOnBy[entry.PK] = {\n firstPublishedOn: null,\n lastPublishedOn: null,\n firstPublishedBy: null,\n lastPublishedBy: null\n };\n\n const executeQuery = () => {\n return entryEntity.query(entry.PK, {\n limit: 1,\n eq: \"P\",\n attributes: [\"modifiedBy\", \"createdBy\", \"publishedOn\"]\n });\n };\n\n const result = await executeWithRetry(executeQuery, params.retryOptions);\n\n const publishedRecord = result.Items?.[0];\n if (publishedRecord) {\n cachedEntryFirstLastPublishedOnBy[entry.PK] = {\n firstPublishedOn: publishedRecord.publishedOn || null,\n lastPublishedOn: publishedRecord.publishedOn || null,\n firstPublishedBy: entry.modifiedBy || entry.createdBy || null,\n lastPublishedBy: entry.modifiedBy || entry.createdBy || null\n };\n }\n\n return cachedEntryFirstLastPublishedOnBy[entry.PK];\n};\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,iCAGL,GAAG,CAAC,CAAC;AAYC,MAAMC,yBAAyB,GAAG,MAAOC,MAAqC,IAAK;EACtF,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGF,MAAM;EAErC,IAAIF,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC,EAAE;IAC7C,OAAOL,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC;EACtD;EAEAL,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC,GAAG;IAC1CC,gBAAgB,EAAE,IAAI;IACtBC,eAAe,EAAE,IAAI;IACrBC,gBAAgB,EAAE,IAAI;IACtBC,eAAe,EAAE;EACrB,CAAC;EAED,MAAMC,YAAY,GAAGA,CAAA,KAAM;IACvB,OAAON,WAAW,CAACO,KAAK,CAACR,KAAK,CAACE,EAAE,EAAE;MAC/BO,KAAK,EAAE,CAAC;MACRC,EAAE,EAAE,GAAG;MACPC,UAAU,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,aAAa;IACzD,CAAC,CAAC;EACN,CAAC;EAED,MAAMC,MAAM,GAAG,MAAM,IAAAC,uBAAgB,EAACN,YAAY,EAAER,MAAM,CAACe,YAAY,CAAC;EAExE,MAAMC,eAAe,GAAGH,MAAM,CAACI,KAAK,GAAG,CAAC,CAAC;EACzC,IAAID,eAAe,EAAE;IACjBlB,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC,GAAG;MAC1CC,gBAAgB,EAAEY,eAAe,CAACE,WAAW,IAAI,IAAI;MACrDb,eAAe,EAAEW,eAAe,CAACE,WAAW,IAAI,IAAI;MACpDZ,gBAAgB,EAAEL,KAAK,CAACkB,UAAU,IAAIlB,KAAK,CAACmB,SAAS,IAAI,IAAI;MAC7Db,eAAe,EAAEN,KAAK,CAACkB,UAAU,IAAIlB,KAAK,CAACmB,SAAS,IAAI;IAC5D,CAAC;EACL;EAEA,OAAOtB,iCAAiC,CAACG,KAAK,CAACE,EAAE,CAAC;AACtD,CAAC;AAACkB,OAAA,CAAAtB,yBAAA,GAAAA,yBAAA"}
@@ -1,11 +1,13 @@
1
1
  import { createDdbEntryEntity } from "./../entities/createEntryEntity";
2
2
  import { CmsEntry } from "../types";
3
+ import { ExecuteWithRetryOptions } from "@webiny/utils";
3
4
  interface CmsEntryWithPK extends CmsEntry {
4
5
  PK: string;
5
6
  }
6
7
  export interface GetOldestRevisionCreatedOnParams {
7
8
  entry: CmsEntryWithPK;
8
9
  entryEntity: ReturnType<typeof createDdbEntryEntity>;
10
+ retryOptions?: ExecuteWithRetryOptions;
9
11
  }
10
12
  export declare const getOldestRevisionCreatedOn: (params: GetOldestRevisionCreatedOnParams) => Promise<string>;
11
13
  export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getOldestRevisionCreatedOn = void 0;
7
+ var _utils = require("@webiny/utils");
7
8
  const cachedEntryCreatedOn = {};
8
9
  const getOldestRevisionCreatedOn = async params => {
9
10
  const {
@@ -16,11 +17,14 @@ const getOldestRevisionCreatedOn = async params => {
16
17
  if (entry.version === 1) {
17
18
  cachedEntryCreatedOn[entry.PK] = entry.createdOn;
18
19
  } else {
19
- const result = await entryEntity.query(entry.PK, {
20
- limit: 1,
21
- beginsWith: "REV#",
22
- attributes: ["createdOn"]
23
- });
20
+ const executeQuery = () => {
21
+ return entryEntity.query(entry.PK, {
22
+ limit: 1,
23
+ beginsWith: "REV#",
24
+ attributes: ["createdOn"]
25
+ });
26
+ };
27
+ const result = await (0, _utils.executeWithRetry)(executeQuery, params.retryOptions);
24
28
  const oldestRevision = result.Items?.[0];
25
29
  if (oldestRevision) {
26
30
  cachedEntryCreatedOn[entry.PK] = oldestRevision.createdOn;
@@ -1 +1 @@
1
- {"version":3,"names":["cachedEntryCreatedOn","getOldestRevisionCreatedOn","params","entry","entryEntity","PK","version","createdOn","result","query","limit","beginsWith","attributes","oldestRevision","Items","exports"],"sources":["getOldestRevisionCreatedOn.ts"],"sourcesContent":["import { createDdbEntryEntity } from \"./../entities/createEntryEntity\";\nimport { CmsEntry } from \"../types\";\n\nconst cachedEntryCreatedOn: Record<string, string> = {};\n\ninterface CmsEntryWithPK extends CmsEntry {\n PK: string;\n}\n\nexport interface GetOldestRevisionCreatedOnParams {\n entry: CmsEntryWithPK;\n entryEntity: ReturnType<typeof createDdbEntryEntity>;\n}\n\nexport const getOldestRevisionCreatedOn = async (params: GetOldestRevisionCreatedOnParams) => {\n const { entry, entryEntity } = params;\n\n if (cachedEntryCreatedOn[entry.PK]) {\n return cachedEntryCreatedOn[entry.PK];\n }\n\n if (entry.version === 1) {\n cachedEntryCreatedOn[entry.PK] = entry.createdOn;\n } else {\n const result = await entryEntity.query(entry.PK, {\n limit: 1,\n beginsWith: \"REV#\",\n attributes: [\"createdOn\"]\n });\n\n const oldestRevision = result.Items?.[0];\n if (oldestRevision) {\n cachedEntryCreatedOn[entry.PK] = oldestRevision.createdOn;\n }\n }\n\n return cachedEntryCreatedOn[entry.PK];\n};\n"],"mappings":";;;;;;AAGA,MAAMA,oBAA4C,GAAG,CAAC,CAAC;AAWhD,MAAMC,0BAA0B,GAAG,MAAOC,MAAwC,IAAK;EAC1F,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGF,MAAM;EAErC,IAAIF,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC,EAAE;IAChC,OAAOL,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC;EACzC;EAEA,IAAIF,KAAK,CAACG,OAAO,KAAK,CAAC,EAAE;IACrBN,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC,GAAGF,KAAK,CAACI,SAAS;EACpD,CAAC,MAAM;IACH,MAAMC,MAAM,GAAG,MAAMJ,WAAW,CAACK,KAAK,CAACN,KAAK,CAACE,EAAE,EAAE;MAC7CK,KAAK,EAAE,CAAC;MACRC,UAAU,EAAE,MAAM;MAClBC,UAAU,EAAE,CAAC,WAAW;IAC5B,CAAC,CAAC;IAEF,MAAMC,cAAc,GAAGL,MAAM,CAACM,KAAK,GAAG,CAAC,CAAC;IACxC,IAAID,cAAc,EAAE;MAChBb,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC,GAAGQ,cAAc,CAACN,SAAS;IAC7D;EACJ;EAEA,OAAOP,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC;AACzC,CAAC;AAACU,OAAA,CAAAd,0BAAA,GAAAA,0BAAA"}
1
+ {"version":3,"names":["_utils","require","cachedEntryCreatedOn","getOldestRevisionCreatedOn","params","entry","entryEntity","PK","version","createdOn","executeQuery","query","limit","beginsWith","attributes","result","executeWithRetry","retryOptions","oldestRevision","Items","exports"],"sources":["getOldestRevisionCreatedOn.ts"],"sourcesContent":["import { createDdbEntryEntity } from \"./../entities/createEntryEntity\";\nimport { CmsEntry } from \"../types\";\nimport { executeWithRetry, ExecuteWithRetryOptions } from \"@webiny/utils\";\n\nconst cachedEntryCreatedOn: Record<string, string> = {};\n\ninterface CmsEntryWithPK extends CmsEntry {\n PK: string;\n}\n\nexport interface GetOldestRevisionCreatedOnParams {\n entry: CmsEntryWithPK;\n entryEntity: ReturnType<typeof createDdbEntryEntity>;\n retryOptions?: ExecuteWithRetryOptions;\n}\n\nexport const getOldestRevisionCreatedOn = async (params: GetOldestRevisionCreatedOnParams) => {\n const { entry, entryEntity } = params;\n\n if (cachedEntryCreatedOn[entry.PK]) {\n return cachedEntryCreatedOn[entry.PK];\n }\n\n if (entry.version === 1) {\n cachedEntryCreatedOn[entry.PK] = entry.createdOn;\n } else {\n const executeQuery = () => {\n return entryEntity.query(entry.PK, {\n limit: 1,\n beginsWith: \"REV#\",\n attributes: [\"createdOn\"]\n });\n };\n\n const result = await executeWithRetry(executeQuery, params.retryOptions);\n\n const oldestRevision = result.Items?.[0];\n if (oldestRevision) {\n cachedEntryCreatedOn[entry.PK] = oldestRevision.createdOn;\n }\n }\n\n return cachedEntryCreatedOn[entry.PK];\n};\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,oBAA4C,GAAG,CAAC,CAAC;AAYhD,MAAMC,0BAA0B,GAAG,MAAOC,MAAwC,IAAK;EAC1F,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGF,MAAM;EAErC,IAAIF,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC,EAAE;IAChC,OAAOL,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC;EACzC;EAEA,IAAIF,KAAK,CAACG,OAAO,KAAK,CAAC,EAAE;IACrBN,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC,GAAGF,KAAK,CAACI,SAAS;EACpD,CAAC,MAAM;IACH,MAAMC,YAAY,GAAGA,CAAA,KAAM;MACvB,OAAOJ,WAAW,CAACK,KAAK,CAACN,KAAK,CAACE,EAAE,EAAE;QAC/BK,KAAK,EAAE,CAAC;QACRC,UAAU,EAAE,MAAM;QAClBC,UAAU,EAAE,CAAC,WAAW;MAC5B,CAAC,CAAC;IACN,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAAC,uBAAgB,EAACN,YAAY,EAAEN,MAAM,CAACa,YAAY,CAAC;IAExE,MAAMC,cAAc,GAAGH,MAAM,CAACI,KAAK,GAAG,CAAC,CAAC;IACxC,IAAID,cAAc,EAAE;MAChBhB,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC,GAAGW,cAAc,CAACT,SAAS;IAC7D;EACJ;EAEA,OAAOP,oBAAoB,CAACG,KAAK,CAACE,EAAE,CAAC;AACzC,CAAC;AAACa,OAAA,CAAAjB,0BAAA,GAAAA,0BAAA"}
@@ -90,7 +90,10 @@ const createInitialStatus = () => {
90
90
  }
91
91
  };
92
92
  };
93
- const BATCH_WRITE_MAX_CHUNK = 20;
93
+ let BATCH_WRITE_MAX_CHUNK = 20;
94
+ if (process.env.WEBINY_MIGRATION_5_39_6_001_BATCH_WRITE_MAX_CHUNK) {
95
+ BATCH_WRITE_MAX_CHUNK = parseInt(process.env.WEBINY_MIGRATION_5_39_6_001_BATCH_WRITE_MAX_CHUNK);
96
+ }
94
97
  (async () => {
95
98
  const logger = (0, _logger.createPinoLogger)({
96
99
  level: (0, _logger.getLogLevel)(process.env.MIGRATIONS_LOG_LEVEL, "trace"),
@@ -159,11 +162,27 @@ const BATCH_WRITE_MAX_CHUNK = 20;
159
162
  // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value.
160
163
  const createdOn = await (0, _getOldestRevisionCreatedOn.getOldestRevisionCreatedOn)({
161
164
  entry: item,
162
- entryEntity: ddbEntryEntity
165
+ entryEntity: ddbEntryEntity,
166
+ retryOptions: {
167
+ onFailedAttempt: error => {
168
+ logger.warn({
169
+ error,
170
+ item
171
+ }, `getOldestRevisionCreatedOn attempt #${error.attemptNumber} failed: ${error.message}`);
172
+ }
173
+ }
163
174
  });
164
175
  const firstLastPublishedOnByFields = await (0, _getFirstLastPublishedOn.getFirstLastPublishedOnBy)({
165
176
  entry: item,
166
- entryEntity: ddbEntryEntity
177
+ entryEntity: ddbEntryEntity,
178
+ retryOptions: {
179
+ onFailedAttempt: error => {
180
+ logger.warn({
181
+ error,
182
+ item
183
+ }, `getFirstLastPublishedOnBy attempt #${error.attemptNumber} failed: ${error.message}`);
184
+ }
185
+ }
167
186
  });
168
187
  (0, _assignNewMetaFields.assignNewMetaFields)(item, {
169
188
  createdOn,
@@ -185,7 +204,15 @@ const BATCH_WRITE_MAX_CHUNK = 20;
185
204
  try {
186
205
  const fallbackIdentity = await (0, _getFallbackIdentity.getFallbackIdentity)({
187
206
  entity: ddbEntryEntity,
188
- tenant: item.tenant
207
+ tenant: item.tenant,
208
+ retryOptions: {
209
+ onFailedAttempt: error => {
210
+ logger.warn({
211
+ error,
212
+ item
213
+ }, `getFallbackIdentity attempt #${error.attemptNumber} failed: ${error.message}`);
214
+ }
215
+ }
189
216
  });
190
217
  (0, _ensureAllNonNullableValues.ensureAllNonNullableValues)(item, {
191
218
  dateTime: fallbackDateTime,
@@ -222,9 +249,19 @@ const BATCH_WRITE_MAX_CHUNK = 20;
222
249
  /**
223
250
  * Get all the records from DynamoDB Elasticsearch.
224
251
  */
225
- const ddbEsRecords = await (0, _utils2.batchReadAll)({
226
- table: ddbEsEntryEntity.table,
227
- items: Object.values(ddbEsItemsToBatchRead)
252
+ const executeBatchReadAll = () => {
253
+ return (0, _utils2.batchReadAll)({
254
+ table: ddbEsEntryEntity.table,
255
+ items: Object.values(ddbEsItemsToBatchRead)
256
+ });
257
+ };
258
+ const ddbEsRecords = await (0, _utils.executeWithRetry)(executeBatchReadAll, {
259
+ onFailedAttempt: error => {
260
+ logger.warn({
261
+ error,
262
+ items: Object.values(ddbEsItemsToBatchRead)
263
+ }, `[DDB-ES Table] Batch (ddbEsItemsToBatchRead) read attempt #${error.attemptNumber} failed: ${error.message}`);
264
+ }
228
265
  });
229
266
  for (const ddbEsRecord of ddbEsRecords) {
230
267
  const decompressedData = await (0, _getDecompressedData.getDecompressedData)(ddbEsRecord.data);
@@ -241,14 +278,36 @@ const BATCH_WRITE_MAX_CHUNK = 20;
241
278
  ...decompressedData,
242
279
  PK: ddbEsRecord.PK
243
280
  },
244
- entryEntity: ddbEntryEntity
281
+ entryEntity: ddbEntryEntity,
282
+ retryOptions: {
283
+ onFailedAttempt: error => {
284
+ logger.warn({
285
+ error,
286
+ item: {
287
+ ...decompressedData,
288
+ PK: ddbEsRecord.PK
289
+ }
290
+ }, `[DDB-ES Table] getOldestRevisionCreatedOn attempt #${error.attemptNumber} failed: ${error.message}`);
291
+ }
292
+ }
245
293
  });
246
294
  const firstLastPublishedOnByFields = await (0, _getFirstLastPublishedOn.getFirstLastPublishedOnBy)({
247
295
  entry: {
248
296
  ...decompressedData,
249
297
  PK: ddbEsRecord.PK
250
298
  },
251
- entryEntity: ddbEntryEntity
299
+ entryEntity: ddbEntryEntity,
300
+ retryOptions: {
301
+ onFailedAttempt: error => {
302
+ logger.warn({
303
+ error,
304
+ item: {
305
+ ...decompressedData,
306
+ PK: ddbEsRecord.PK
307
+ }
308
+ }, `[DDB-ES Table] getFirstLastPublishedOnBy attempt #${error.attemptNumber} failed: ${error.message}`);
309
+ }
310
+ }
252
311
  });
253
312
  (0, _assignNewMetaFields.assignNewMetaFields)(decompressedData, {
254
313
  createdOn,
@@ -262,7 +321,15 @@ const BATCH_WRITE_MAX_CHUNK = 20;
262
321
  try {
263
322
  const fallbackIdentity = await (0, _getFallbackIdentity.getFallbackIdentity)({
264
323
  entity: ddbEntryEntity,
265
- tenant: decompressedData.tenant
324
+ tenant: decompressedData.tenant,
325
+ retryOptions: {
326
+ onFailedAttempt: error => {
327
+ logger.warn({
328
+ error,
329
+ item: ddbEntryEntity
330
+ }, `[DDB-ES Table] getFallbackIdentity attempt #${error.attemptNumber} failed: ${error.message}`);
331
+ }
332
+ }
266
333
  });
267
334
  (0, _ensureAllNonNullableValues.ensureAllNonNullableValues)(decompressedData, {
268
335
  dateTime: fallbackDateTime,
@@ -361,6 +428,15 @@ const BATCH_WRITE_MAX_CHUNK = 20;
361
428
 
362
429
  // Continue further scanning.
363
430
  return true;
431
+ }, {
432
+ retry: {
433
+ onFailedAttempt: error => {
434
+ logger.warn({
435
+ lastEvaluatedKey: status.lastEvaluatedKey,
436
+ error
437
+ }, `ddbScanWithCallback attempt #${error.attemptNumber} failed: ${error.message}`);
438
+ }
439
+ }
364
440
  });
365
441
 
366
442
  // Store status in tmp file.
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_logger","_dataMigration","_clientDynamodb","_apiElasticsearch","_yargs","_interopRequireDefault","_helpers","_isMigratedEntry","_hasValidTypeFieldValue","_hasAllNonNullableValues","_getOldestRevisionCreatedOn","_getFirstLastPublishedOn","_assignNewMetaFields","_fixTypeFieldValue","_getFallbackIdentity","_ensureAllNonNullableValues","_getDecompressedData","_getCompressedData","_createEntryEntity","_utils2","_waitUntilHealthy","_pinoPretty","_path","_os","_fs","_getNonNullableFieldsWithMissingValues","argv","yargs","hideBin","process","options","runId","type","demandOption","ddbTable","ddbEsTable","esEndpoint","segmentIndex","totalSegments","esHealthMinClusterHealthStatus","esHealthMaxProcessorPercent","esHealthMaxRamPercent","esHealthMaxWaitingTime","esHealthWaitingTimeStep","parseSync","createInitialStatus","lastEvaluatedKey","stats","iterationsCount","recordsScanned","recordsUpdated","recordsSkipped","esHealthChecks","timeSpentWaiting","checksCount","unhealthyReasons","BATCH_WRITE_MAX_CHUNK","logger","createPinoLogger","level","getLogLevel","env","MIGRATIONS_LOG_LEVEL","msgPrefix","pinoPretty","ignore","documentClient","getDocumentClient","elasticsearchClient","createElasticsearchClient","endpoint","primaryTable","createTable","name","dynamoToEsTable","ddbEntryEntity","createDdbEntryEntity","ddbEsEntryEntity","createDdbEsEntryEntity","status","waitUntilHealthy","createWaitUntilHealthy","minClusterHealthStatus","maxProcessorPercent","maxRamPercent","maxWaitingTime","waitingTimeStep","ddbScanWithCallback","entity","segment","segments","filters","attr","eq","startKey","undefined","limit","result","items","length","trace","ddbItemsToBatchWrite","ddbEsItemsToBatchWrite","ddbEsItemsToBatchRead","fallbackDateTime","Date","toISOString","item","isFullyMigrated","isMigratedEntry","hasValidTypeFieldValue","hasAllNonNullableValues","createdOn","getOldestRevisionCreatedOn","entry","entryEntity","firstLastPublishedOnByFields","getFirstLastPublishedOnBy","assignNewMetaFields","fixTypeFieldValue","getNonNullableFieldsWithMissingValues","modelId","id","fallbackIdentity","getFallbackIdentity","tenant","ensureAllNonNullableValues","dateTime","identity","e","debug","message","push","putBatch","ddbEsLatestRecordKey","entryId","getBatch","PK","SK","ddbEsPublishedRecordKey","locked","Object","keys","ddbEsRecords","batchReadAll","table","values","ddbEsRecord","decompressedData","getDecompressedData","data","join","error","compressedData","getCompressedData","ddbWriteError","ddbEsWriteError","execute","batchWriteAll","executeWithRetry","onFailedAttempt","warn","attemptNumber","results","wait","onUnhealthy","params","shouldWaitReason","waitingReason","runningTime","executeDdbEs","logFilePath","path","os","tmpdir","fs","writeFileSync","JSON","stringify"],"sources":["worker.ts"],"sourcesContent":["import { executeWithRetry } from \"@webiny/utils\";\nimport { createPinoLogger, getLogLevel } from \"@webiny/logger\";\nimport { createTable } from \"@webiny/data-migration\";\nimport { getDocumentClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { createElasticsearchClient } from \"@webiny/api-elasticsearch\";\nimport yargs from \"yargs/yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { isMigratedEntry } from \"~/migrations/5.39.0/001/utils/isMigratedEntry\";\nimport { hasValidTypeFieldValue } from \"~/migrations/5.39.0/001/utils/hasValidTypeFieldValue\";\nimport { hasAllNonNullableValues } from \"~/migrations/5.39.0/001/utils/hasAllNonNullableValues\";\nimport { getOldestRevisionCreatedOn } from \"~/migrations/5.39.0/001/utils/getOldestRevisionCreatedOn\";\nimport { getFirstLastPublishedOnBy } from \"~/migrations/5.39.0/001/utils/getFirstLastPublishedOn\";\nimport { assignNewMetaFields } from \"~/migrations/5.39.0/001/utils/assignNewMetaFields\";\nimport { fixTypeFieldValue } from \"~/migrations/5.39.0/001/utils/fixTypeFieldValue\";\nimport { getFallbackIdentity } from \"~/migrations/5.39.0/001/utils/getFallbackIdentity\";\nimport { ensureAllNonNullableValues } from \"~/migrations/5.39.0/001/utils/ensureAllNonNullableValues\";\nimport { getDecompressedData } from \"~/migrations/5.39.0/001/utils/getDecompressedData\";\nimport { getCompressedData } from \"~/migrations/5.39.0/001/utils/getCompressedData\";\nimport { CmsEntry } from \"~/migrations/5.39.0/001/types\";\nimport {\n createDdbEntryEntity,\n createDdbEsEntryEntity\n} from \"~/migrations/5.39.0/001/entities/createEntryEntity\";\nimport {\n batchReadAll,\n BatchReadItem,\n batchWriteAll,\n BatchWriteItem,\n ddbScanWithCallback\n} from \"~/utils\";\nimport { createWaitUntilHealthy } from \"@webiny/api-elasticsearch/utils/waitUntilHealthy\";\nimport pinoPretty from \"pino-pretty\";\nimport { EsHealthChecksParams } from \"~/migrations/5.39.6/001/ddb-es/utils\";\nimport path from \"path\";\nimport os from \"os\";\nimport fs from \"fs\";\nimport { getNonNullableFieldsWithMissingValues } from \"~/migrations/5.39.0/001/utils/getNonNullableFieldsWithMissingValues\";\n\nconst argv = yargs(hideBin(process.argv))\n .options({\n runId: { type: \"string\", demandOption: true },\n ddbTable: { type: \"string\", demandOption: true },\n ddbEsTable: { type: \"string\", demandOption: true },\n esEndpoint: { type: \"string\", demandOption: true },\n segmentIndex: { type: \"number\", demandOption: true },\n totalSegments: { type: \"number\", demandOption: true },\n\n // Elasticsearch health check options.\n esHealthMinClusterHealthStatus: { type: \"string\", demandOption: true },\n esHealthMaxProcessorPercent: { type: \"number\", demandOption: true },\n esHealthMaxRamPercent: { type: \"number\", demandOption: true },\n esHealthMaxWaitingTime: { type: \"number\", demandOption: true },\n esHealthWaitingTimeStep: { type: \"number\", demandOption: true }\n })\n .parseSync();\n\ninterface LastEvaluatedKeyObject {\n PK: string;\n SK: string;\n GSI1_PK: string;\n GSI1_SK: string;\n}\n\ntype LastEvaluatedKey = LastEvaluatedKeyObject | true | null;\n\ninterface MigrationStatus {\n lastEvaluatedKey: LastEvaluatedKey;\n stats: {\n iterationsCount: number;\n recordsScanned: number;\n recordsUpdated: number;\n recordsSkipped: number;\n esHealthChecks: {\n timeSpentWaiting: number;\n checksCount: number;\n unhealthyReasons: {\n [key: string]: number;\n };\n };\n };\n}\n\ninterface DynamoDbElasticsearchRecord {\n PK: string;\n SK: string;\n data: string;\n}\n\nconst createInitialStatus = (): MigrationStatus => {\n return {\n lastEvaluatedKey: null,\n stats: {\n iterationsCount: 0,\n recordsScanned: 0,\n recordsUpdated: 0,\n recordsSkipped: 0,\n esHealthChecks: {\n timeSpentWaiting: 0,\n checksCount: 0,\n unhealthyReasons: {}\n }\n }\n };\n};\n\nconst BATCH_WRITE_MAX_CHUNK = 20;\n\n(async () => {\n const logger = createPinoLogger(\n {\n level: getLogLevel(process.env.MIGRATIONS_LOG_LEVEL, \"trace\"),\n msgPrefix: `[segment #${argv.segmentIndex}] `\n },\n pinoPretty({ ignore: \"pid,hostname\" })\n );\n\n const documentClient = getDocumentClient();\n const elasticsearchClient = createElasticsearchClient({\n endpoint: `https://${argv.esEndpoint}`\n });\n\n const primaryTable = createTable({\n name: argv.ddbTable,\n documentClient\n });\n const dynamoToEsTable = createTable({\n name: argv.ddbEsTable,\n documentClient\n });\n\n const ddbEntryEntity = createDdbEntryEntity(primaryTable);\n const ddbEsEntryEntity = createDdbEsEntryEntity(dynamoToEsTable);\n\n const status = createInitialStatus();\n\n const waitUntilHealthy = createWaitUntilHealthy(elasticsearchClient, {\n minClusterHealthStatus:\n argv.esHealthMinClusterHealthStatus as EsHealthChecksParams[\"minClusterHealthStatus\"],\n maxProcessorPercent: argv.esHealthMaxProcessorPercent,\n maxRamPercent: argv.esHealthMaxRamPercent,\n maxWaitingTime: argv.esHealthMaxWaitingTime,\n waitingTimeStep: argv.esHealthWaitingTimeStep\n });\n\n try {\n await ddbScanWithCallback<CmsEntry>(\n {\n entity: ddbEntryEntity,\n options: {\n segment: argv.segmentIndex,\n segments: argv.totalSegments,\n filters: [\n {\n attr: \"_et\",\n eq: \"CmsEntries\"\n }\n ],\n startKey: status.lastEvaluatedKey || undefined,\n limit: 100\n }\n },\n async result => {\n status.stats.iterationsCount++;\n status.stats.recordsScanned += result.items.length;\n\n if (status.stats.iterationsCount % 5 === 0) {\n // We log every 5th iteration.\n logger.trace(\n `[iteration #${status.stats.iterationsCount}] Reading ${result.items.length} record(s)...`\n );\n }\n\n const ddbItemsToBatchWrite: BatchWriteItem[] = [];\n const ddbEsItemsToBatchWrite: BatchWriteItem[] = [];\n const ddbEsItemsToBatchRead: Record<string, BatchReadItem> = {};\n\n const fallbackDateTime = new Date().toISOString();\n\n // Update records in primary DynamoDB table. Also do preparations for\n // subsequent updates on DDB-ES DynamoDB table, and in Elasticsearch.\n for (const item of result.items) {\n const isFullyMigrated =\n isMigratedEntry(item) &&\n hasValidTypeFieldValue(item) &&\n hasAllNonNullableValues(item);\n\n if (isFullyMigrated) {\n status.stats.recordsSkipped++;\n continue;\n }\n\n // 1. Check if the data migration was ever performed. If not, let's perform it.\n if (!isMigratedEntry(item)) {\n // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value.\n const createdOn = await getOldestRevisionCreatedOn({\n entry: item,\n entryEntity: ddbEntryEntity\n });\n\n const firstLastPublishedOnByFields = await getFirstLastPublishedOnBy({\n entry: item,\n entryEntity: ddbEntryEntity\n });\n\n assignNewMetaFields(item, {\n createdOn,\n ...firstLastPublishedOnByFields\n });\n }\n\n // 2. We've noticed some of the records had an invalid `TYPE` field value\n // in the database. This step addresses this issue.\n if (!hasValidTypeFieldValue(item)) {\n // Fixes the value of the `TYPE` field, if it's not valid.\n fixTypeFieldValue(item);\n }\n\n // 3. Finally, once both of the steps were performed, ensure that all\n // new non-nullable meta fields have a value and nothing is missing.\n if (!hasAllNonNullableValues(item)) {\n logger.trace(\n getNonNullableFieldsWithMissingValues(item),\n `Detected an entry with missing values for non-nullable meta fields (${item.modelId}/${item.id}).`\n );\n\n try {\n const fallbackIdentity = await getFallbackIdentity({\n entity: ddbEntryEntity,\n tenant: item.tenant\n });\n\n ensureAllNonNullableValues(item, {\n dateTime: fallbackDateTime,\n identity: fallbackIdentity\n });\n\n logger.trace(\n `Successfully ensured all non-nullable meta fields have values (${item.modelId}/${item.id}). Will be saving into the database soon.`\n );\n } catch (e) {\n logger.debug(\n `Failed to ensure all non-nullable meta fields have values (${item.modelId}/${item.id}): ${e.message}`\n );\n }\n }\n\n ddbItemsToBatchWrite.push(ddbEntryEntity.putBatch(item));\n\n /**\n * Prepare the loading of DynamoDB Elasticsearch part of the records.\n */\n\n const ddbEsLatestRecordKey = `${item.entryId}:L`;\n if (ddbEsItemsToBatchRead[ddbEsLatestRecordKey]) {\n continue;\n }\n\n ddbEsItemsToBatchRead[ddbEsLatestRecordKey] = ddbEsEntryEntity.getBatch({\n PK: item.PK,\n SK: \"L\"\n });\n\n const ddbEsPublishedRecordKey = `${item.entryId}:P`;\n if (item.status === \"published\" || !!item.locked) {\n ddbEsItemsToBatchRead[ddbEsPublishedRecordKey] = ddbEsEntryEntity.getBatch({\n PK: item.PK,\n SK: \"P\"\n });\n }\n }\n\n if (Object.keys(ddbEsItemsToBatchRead).length > 0) {\n /**\n * Get all the records from DynamoDB Elasticsearch.\n */\n const ddbEsRecords = await batchReadAll<DynamoDbElasticsearchRecord>({\n table: ddbEsEntryEntity.table,\n items: Object.values(ddbEsItemsToBatchRead)\n });\n\n for (const ddbEsRecord of ddbEsRecords) {\n const decompressedData = await getDecompressedData<CmsEntry>(\n ddbEsRecord.data\n );\n if (!decompressedData) {\n logger.trace(\n `[DDB-ES Table] Skipping record \"${ddbEsRecord.PK}\" as it is not a valid CMS entry...`\n );\n continue;\n }\n\n // 1. Check if the data migration was ever performed. If not, let's perform it.\n if (!isMigratedEntry(decompressedData)) {\n // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value.\n const createdOn = await getOldestRevisionCreatedOn({\n entry: { ...decompressedData, PK: ddbEsRecord.PK },\n entryEntity: ddbEntryEntity\n });\n\n const firstLastPublishedOnByFields = await getFirstLastPublishedOnBy({\n entry: { ...decompressedData, PK: ddbEsRecord.PK },\n entryEntity: ddbEntryEntity\n });\n\n assignNewMetaFields(decompressedData, {\n createdOn,\n ...firstLastPublishedOnByFields\n });\n }\n\n // 2. Ensure new non-nullable meta fields have a value and nothing is missing.\n if (!hasAllNonNullableValues(decompressedData)) {\n logger.trace(\n getNonNullableFieldsWithMissingValues(decompressedData),\n [\n `[DDB-ES Table] Detected an entry with missing values for non-nullable meta fields`,\n `(${decompressedData.modelId}/${decompressedData.id}).`\n ].join(\" \")\n );\n\n try {\n const fallbackIdentity = await getFallbackIdentity({\n entity: ddbEntryEntity,\n tenant: decompressedData.tenant\n });\n\n ensureAllNonNullableValues(decompressedData, {\n dateTime: fallbackDateTime,\n identity: fallbackIdentity\n });\n\n logger.trace(\n [\n `[DDB-ES Table] Successfully ensured all non-nullable meta fields`,\n `have values (${decompressedData.modelId}/${decompressedData.id}).`,\n \"Will be saving the changes soon.\"\n ].join(\" \")\n );\n } catch (e) {\n logger.error(\n [\n \"[DDB-ES Table] Failed to ensure all non-nullable meta fields have values\",\n `(${decompressedData.modelId}/${decompressedData.id}): ${e.message}`\n ].join(\" \")\n );\n }\n }\n\n const compressedData = await getCompressedData(decompressedData);\n\n ddbEsItemsToBatchWrite.push(\n ddbEsEntryEntity.putBatch({\n ...ddbEsRecord,\n data: compressedData\n })\n );\n }\n }\n\n if (ddbItemsToBatchWrite.length) {\n let ddbWriteError = false;\n let ddbEsWriteError = false;\n\n // Store data in primary DynamoDB table.\n const execute = () => {\n return batchWriteAll(\n {\n table: ddbEntryEntity.table,\n items: ddbItemsToBatchWrite\n },\n BATCH_WRITE_MAX_CHUNK\n );\n };\n\n logger.trace(\n `Storing ${ddbItemsToBatchWrite.length} record(s) in primary DynamoDB table...`\n );\n\n try {\n await executeWithRetry(execute, {\n onFailedAttempt: error => {\n logger.warn(\n `Batch write attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n });\n } catch (e) {\n ddbWriteError = true;\n logger.error(\n {\n error: e,\n ddbItemsToBatchWrite\n },\n \"After multiple retries, failed to batch-store records in primary DynamoDB table.\"\n );\n }\n\n if (ddbEsItemsToBatchWrite.length) {\n logger.trace(\n `Storing ${ddbEsItemsToBatchWrite.length} record(s) in DDB-ES DynamoDB table...`\n );\n\n try {\n const results = await waitUntilHealthy.wait({\n async onUnhealthy(params) {\n const shouldWaitReason = params.waitingReason.name;\n\n logger.warn(\n `Cluster is unhealthy (${shouldWaitReason}). Waiting for the cluster to become healthy...`,\n params\n );\n\n if (\n status.stats.esHealthChecks.unhealthyReasons[\n shouldWaitReason\n ]\n ) {\n status.stats.esHealthChecks.unhealthyReasons[\n shouldWaitReason\n ]++;\n } else {\n status.stats.esHealthChecks.unhealthyReasons[\n shouldWaitReason\n ] = 1;\n }\n }\n });\n\n status.stats.esHealthChecks.checksCount++;\n status.stats.esHealthChecks.timeSpentWaiting += results.runningTime;\n\n // Store data in DDB-ES DynamoDB table.\n const executeDdbEs = () => {\n return batchWriteAll(\n {\n table: ddbEsEntryEntity.table,\n items: ddbEsItemsToBatchWrite\n },\n BATCH_WRITE_MAX_CHUNK\n );\n };\n\n await executeWithRetry(executeDdbEs, {\n onFailedAttempt: error => {\n logger.warn(\n `[DDB-ES Table] Batch write attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n });\n } catch (e) {\n ddbEsWriteError = true;\n logger.error(\n {\n error: e,\n ddbEsItemsToBatchWrite\n },\n \"After multiple retries, failed to batch-store records in DDB-ES DynamoDB table.\"\n );\n }\n }\n\n if (ddbEsWriteError || ddbWriteError) {\n logger.warn(\n 'Not increasing the \"recordsUpdated\" count due to write errors.'\n );\n } else {\n status.stats.recordsUpdated += ddbItemsToBatchWrite.length;\n }\n }\n\n // Update checkpoint after every batch.\n let lastEvaluatedKey: LastEvaluatedKey = true;\n if (result.lastEvaluatedKey) {\n lastEvaluatedKey = result.lastEvaluatedKey as unknown as LastEvaluatedKeyObject;\n }\n\n status.lastEvaluatedKey = lastEvaluatedKey;\n\n if (lastEvaluatedKey === true) {\n return false;\n }\n\n // Continue further scanning.\n return true;\n }\n );\n\n // Store status in tmp file.\n logger.trace({ status }, \"Segment processing completed. Saving status to tmp file...\");\n const logFilePath = path.join(\n os.tmpdir(),\n `webiny-5-39-6-meta-fields-data-migration-log-${argv.runId}-${argv.segmentIndex}.log`\n );\n\n // Save segment processing stats to a file.\n fs.writeFileSync(logFilePath, JSON.stringify(status.stats, null, 2));\n\n logger.trace(`Segment processing stats saved in ${logFilePath}.`);\n } catch (error) {\n // Store status in tmp file.\n logger.error(\n { status, error },\n \"Segment processing failed to complete. Saving status to tmp file...\"\n );\n const logFilePath = path.join(\n os.tmpdir(),\n `webiny-5-39-6-meta-fields-data-migration-log-${argv.runId}-${argv.segmentIndex}.log`\n );\n\n // Save segment processing stats to a file.\n fs.writeFileSync(logFilePath, JSON.stringify(status.stats, null, 2));\n\n logger.trace(`Segment processing stats saved in ${logFilePath}.`);\n }\n})();\n"],"mappings":";;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA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}
1
+ {"version":3,"names":["_utils","require","_logger","_dataMigration","_clientDynamodb","_apiElasticsearch","_yargs","_interopRequireDefault","_helpers","_isMigratedEntry","_hasValidTypeFieldValue","_hasAllNonNullableValues","_getOldestRevisionCreatedOn","_getFirstLastPublishedOn","_assignNewMetaFields","_fixTypeFieldValue","_getFallbackIdentity","_ensureAllNonNullableValues","_getDecompressedData","_getCompressedData","_createEntryEntity","_utils2","_waitUntilHealthy","_pinoPretty","_path","_os","_fs","_getNonNullableFieldsWithMissingValues","argv","yargs","hideBin","process","options","runId","type","demandOption","ddbTable","ddbEsTable","esEndpoint","segmentIndex","totalSegments","esHealthMinClusterHealthStatus","esHealthMaxProcessorPercent","esHealthMaxRamPercent","esHealthMaxWaitingTime","esHealthWaitingTimeStep","parseSync","createInitialStatus","lastEvaluatedKey","stats","iterationsCount","recordsScanned","recordsUpdated","recordsSkipped","esHealthChecks","timeSpentWaiting","checksCount","unhealthyReasons","BATCH_WRITE_MAX_CHUNK","env","WEBINY_MIGRATION_5_39_6_001_BATCH_WRITE_MAX_CHUNK","parseInt","logger","createPinoLogger","level","getLogLevel","MIGRATIONS_LOG_LEVEL","msgPrefix","pinoPretty","ignore","documentClient","getDocumentClient","elasticsearchClient","createElasticsearchClient","endpoint","primaryTable","createTable","name","dynamoToEsTable","ddbEntryEntity","createDdbEntryEntity","ddbEsEntryEntity","createDdbEsEntryEntity","status","waitUntilHealthy","createWaitUntilHealthy","minClusterHealthStatus","maxProcessorPercent","maxRamPercent","maxWaitingTime","waitingTimeStep","ddbScanWithCallback","entity","segment","segments","filters","attr","eq","startKey","undefined","limit","result","items","length","trace","ddbItemsToBatchWrite","ddbEsItemsToBatchWrite","ddbEsItemsToBatchRead","fallbackDateTime","Date","toISOString","item","isFullyMigrated","isMigratedEntry","hasValidTypeFieldValue","hasAllNonNullableValues","createdOn","getOldestRevisionCreatedOn","entry","entryEntity","retryOptions","onFailedAttempt","error","warn","attemptNumber","message","firstLastPublishedOnByFields","getFirstLastPublishedOnBy","assignNewMetaFields","fixTypeFieldValue","getNonNullableFieldsWithMissingValues","modelId","id","fallbackIdentity","getFallbackIdentity","tenant","ensureAllNonNullableValues","dateTime","identity","e","debug","push","putBatch","ddbEsLatestRecordKey","entryId","getBatch","PK","SK","ddbEsPublishedRecordKey","locked","Object","keys","executeBatchReadAll","batchReadAll","table","values","ddbEsRecords","executeWithRetry","ddbEsRecord","decompressedData","getDecompressedData","data","join","compressedData","getCompressedData","ddbWriteError","ddbEsWriteError","execute","batchWriteAll","results","wait","onUnhealthy","params","shouldWaitReason","waitingReason","runningTime","executeDdbEs","retry","logFilePath","path","os","tmpdir","fs","writeFileSync","JSON","stringify"],"sources":["worker.ts"],"sourcesContent":["import { executeWithRetry } from \"@webiny/utils\";\nimport { createPinoLogger, getLogLevel } from \"@webiny/logger\";\nimport { createTable } from \"@webiny/data-migration\";\nimport { getDocumentClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { createElasticsearchClient } from \"@webiny/api-elasticsearch\";\nimport yargs from \"yargs/yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { isMigratedEntry } from \"~/migrations/5.39.0/001/utils/isMigratedEntry\";\nimport { hasValidTypeFieldValue } from \"~/migrations/5.39.0/001/utils/hasValidTypeFieldValue\";\nimport { hasAllNonNullableValues } from \"~/migrations/5.39.0/001/utils/hasAllNonNullableValues\";\nimport { getOldestRevisionCreatedOn } from \"~/migrations/5.39.0/001/utils/getOldestRevisionCreatedOn\";\nimport { getFirstLastPublishedOnBy } from \"~/migrations/5.39.0/001/utils/getFirstLastPublishedOn\";\nimport { assignNewMetaFields } from \"~/migrations/5.39.0/001/utils/assignNewMetaFields\";\nimport { fixTypeFieldValue } from \"~/migrations/5.39.0/001/utils/fixTypeFieldValue\";\nimport { getFallbackIdentity } from \"~/migrations/5.39.0/001/utils/getFallbackIdentity\";\nimport { ensureAllNonNullableValues } from \"~/migrations/5.39.0/001/utils/ensureAllNonNullableValues\";\nimport { getDecompressedData } from \"~/migrations/5.39.0/001/utils/getDecompressedData\";\nimport { getCompressedData } from \"~/migrations/5.39.0/001/utils/getCompressedData\";\nimport { CmsEntry } from \"~/migrations/5.39.0/001/types\";\nimport {\n createDdbEntryEntity,\n createDdbEsEntryEntity\n} from \"~/migrations/5.39.0/001/entities/createEntryEntity\";\nimport {\n batchReadAll,\n BatchReadItem,\n batchWriteAll,\n BatchWriteItem,\n ddbScanWithCallback\n} from \"~/utils\";\nimport { createWaitUntilHealthy } from \"@webiny/api-elasticsearch/utils/waitUntilHealthy\";\nimport pinoPretty from \"pino-pretty\";\nimport { EsHealthChecksParams } from \"~/migrations/5.39.6/001/ddb-es/utils\";\nimport path from \"path\";\nimport os from \"os\";\nimport fs from \"fs\";\nimport { getNonNullableFieldsWithMissingValues } from \"~/migrations/5.39.0/001/utils/getNonNullableFieldsWithMissingValues\";\n\nconst argv = yargs(hideBin(process.argv))\n .options({\n runId: { type: \"string\", demandOption: true },\n ddbTable: { type: \"string\", demandOption: true },\n ddbEsTable: { type: \"string\", demandOption: true },\n esEndpoint: { type: \"string\", demandOption: true },\n segmentIndex: { type: \"number\", demandOption: true },\n totalSegments: { type: \"number\", demandOption: true },\n\n // Elasticsearch health check options.\n esHealthMinClusterHealthStatus: { type: \"string\", demandOption: true },\n esHealthMaxProcessorPercent: { type: \"number\", demandOption: true },\n esHealthMaxRamPercent: { type: \"number\", demandOption: true },\n esHealthMaxWaitingTime: { type: \"number\", demandOption: true },\n esHealthWaitingTimeStep: { type: \"number\", demandOption: true }\n })\n .parseSync();\n\ninterface LastEvaluatedKeyObject {\n PK: string;\n SK: string;\n GSI1_PK: string;\n GSI1_SK: string;\n}\n\ntype LastEvaluatedKey = LastEvaluatedKeyObject | true | null;\n\ninterface MigrationStatus {\n lastEvaluatedKey: LastEvaluatedKey;\n stats: {\n iterationsCount: number;\n recordsScanned: number;\n recordsUpdated: number;\n recordsSkipped: number;\n esHealthChecks: {\n timeSpentWaiting: number;\n checksCount: number;\n unhealthyReasons: {\n [key: string]: number;\n };\n };\n };\n}\n\ninterface DynamoDbElasticsearchRecord {\n PK: string;\n SK: string;\n data: string;\n}\n\nconst createInitialStatus = (): MigrationStatus => {\n return {\n lastEvaluatedKey: null,\n stats: {\n iterationsCount: 0,\n recordsScanned: 0,\n recordsUpdated: 0,\n recordsSkipped: 0,\n esHealthChecks: {\n timeSpentWaiting: 0,\n checksCount: 0,\n unhealthyReasons: {}\n }\n }\n };\n};\n\nlet BATCH_WRITE_MAX_CHUNK = 20;\nif (process.env.WEBINY_MIGRATION_5_39_6_001_BATCH_WRITE_MAX_CHUNK) {\n BATCH_WRITE_MAX_CHUNK = parseInt(process.env.WEBINY_MIGRATION_5_39_6_001_BATCH_WRITE_MAX_CHUNK);\n}\n\n(async () => {\n const logger = createPinoLogger(\n {\n level: getLogLevel(process.env.MIGRATIONS_LOG_LEVEL, \"trace\"),\n msgPrefix: `[segment #${argv.segmentIndex}] `\n },\n pinoPretty({ ignore: \"pid,hostname\" })\n );\n\n const documentClient = getDocumentClient();\n const elasticsearchClient = createElasticsearchClient({\n endpoint: `https://${argv.esEndpoint}`\n });\n\n const primaryTable = createTable({\n name: argv.ddbTable,\n documentClient\n });\n const dynamoToEsTable = createTable({\n name: argv.ddbEsTable,\n documentClient\n });\n\n const ddbEntryEntity = createDdbEntryEntity(primaryTable);\n const ddbEsEntryEntity = createDdbEsEntryEntity(dynamoToEsTable);\n\n const status = createInitialStatus();\n\n const waitUntilHealthy = createWaitUntilHealthy(elasticsearchClient, {\n minClusterHealthStatus:\n argv.esHealthMinClusterHealthStatus as EsHealthChecksParams[\"minClusterHealthStatus\"],\n maxProcessorPercent: argv.esHealthMaxProcessorPercent,\n maxRamPercent: argv.esHealthMaxRamPercent,\n maxWaitingTime: argv.esHealthMaxWaitingTime,\n waitingTimeStep: argv.esHealthWaitingTimeStep\n });\n\n try {\n await ddbScanWithCallback<CmsEntry>(\n {\n entity: ddbEntryEntity,\n options: {\n segment: argv.segmentIndex,\n segments: argv.totalSegments,\n filters: [\n {\n attr: \"_et\",\n eq: \"CmsEntries\"\n }\n ],\n startKey: status.lastEvaluatedKey || undefined,\n limit: 100\n }\n },\n async result => {\n status.stats.iterationsCount++;\n status.stats.recordsScanned += result.items.length;\n\n if (status.stats.iterationsCount % 5 === 0) {\n // We log every 5th iteration.\n logger.trace(\n `[iteration #${status.stats.iterationsCount}] Reading ${result.items.length} record(s)...`\n );\n }\n\n const ddbItemsToBatchWrite: BatchWriteItem[] = [];\n const ddbEsItemsToBatchWrite: BatchWriteItem[] = [];\n const ddbEsItemsToBatchRead: Record<string, BatchReadItem> = {};\n\n const fallbackDateTime = new Date().toISOString();\n\n // Update records in primary DynamoDB table. Also do preparations for\n // subsequent updates on DDB-ES DynamoDB table, and in Elasticsearch.\n for (const item of result.items) {\n const isFullyMigrated =\n isMigratedEntry(item) &&\n hasValidTypeFieldValue(item) &&\n hasAllNonNullableValues(item);\n\n if (isFullyMigrated) {\n status.stats.recordsSkipped++;\n continue;\n }\n\n // 1. Check if the data migration was ever performed. If not, let's perform it.\n if (!isMigratedEntry(item)) {\n // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value.\n const createdOn = await getOldestRevisionCreatedOn({\n entry: item,\n entryEntity: ddbEntryEntity,\n retryOptions: {\n onFailedAttempt: error => {\n logger.warn(\n { error, item },\n `getOldestRevisionCreatedOn attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n }\n });\n\n const firstLastPublishedOnByFields = await getFirstLastPublishedOnBy({\n entry: item,\n entryEntity: ddbEntryEntity,\n retryOptions: {\n onFailedAttempt: error => {\n logger.warn(\n { error, item },\n `getFirstLastPublishedOnBy attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n }\n });\n\n assignNewMetaFields(item, {\n createdOn,\n ...firstLastPublishedOnByFields\n });\n }\n\n // 2. We've noticed some of the records had an invalid `TYPE` field value\n // in the database. This step addresses this issue.\n if (!hasValidTypeFieldValue(item)) {\n // Fixes the value of the `TYPE` field, if it's not valid.\n fixTypeFieldValue(item);\n }\n\n // 3. Finally, once both of the steps were performed, ensure that all\n // new non-nullable meta fields have a value and nothing is missing.\n if (!hasAllNonNullableValues(item)) {\n logger.trace(\n getNonNullableFieldsWithMissingValues(item),\n `Detected an entry with missing values for non-nullable meta fields (${item.modelId}/${item.id}).`\n );\n\n try {\n const fallbackIdentity = await getFallbackIdentity({\n entity: ddbEntryEntity,\n tenant: item.tenant,\n retryOptions: {\n onFailedAttempt: error => {\n logger.warn(\n { error, item },\n `getFallbackIdentity attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n }\n });\n\n ensureAllNonNullableValues(item, {\n dateTime: fallbackDateTime,\n identity: fallbackIdentity\n });\n\n logger.trace(\n `Successfully ensured all non-nullable meta fields have values (${item.modelId}/${item.id}). Will be saving into the database soon.`\n );\n } catch (e) {\n logger.debug(\n `Failed to ensure all non-nullable meta fields have values (${item.modelId}/${item.id}): ${e.message}`\n );\n }\n }\n\n ddbItemsToBatchWrite.push(ddbEntryEntity.putBatch(item));\n\n /**\n * Prepare the loading of DynamoDB Elasticsearch part of the records.\n */\n\n const ddbEsLatestRecordKey = `${item.entryId}:L`;\n if (ddbEsItemsToBatchRead[ddbEsLatestRecordKey]) {\n continue;\n }\n\n ddbEsItemsToBatchRead[ddbEsLatestRecordKey] = ddbEsEntryEntity.getBatch({\n PK: item.PK,\n SK: \"L\"\n });\n\n const ddbEsPublishedRecordKey = `${item.entryId}:P`;\n if (item.status === \"published\" || !!item.locked) {\n ddbEsItemsToBatchRead[ddbEsPublishedRecordKey] = ddbEsEntryEntity.getBatch({\n PK: item.PK,\n SK: \"P\"\n });\n }\n }\n\n if (Object.keys(ddbEsItemsToBatchRead).length > 0) {\n /**\n * Get all the records from DynamoDB Elasticsearch.\n */\n const executeBatchReadAll = () => {\n return batchReadAll<DynamoDbElasticsearchRecord>({\n table: ddbEsEntryEntity.table,\n items: Object.values(ddbEsItemsToBatchRead)\n });\n };\n\n const ddbEsRecords = await executeWithRetry(executeBatchReadAll, {\n onFailedAttempt: error => {\n logger.warn(\n { error, items: Object.values(ddbEsItemsToBatchRead) },\n `[DDB-ES Table] Batch (ddbEsItemsToBatchRead) read attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n });\n\n for (const ddbEsRecord of ddbEsRecords) {\n const decompressedData = await getDecompressedData<CmsEntry>(\n ddbEsRecord.data\n );\n if (!decompressedData) {\n logger.trace(\n `[DDB-ES Table] Skipping record \"${ddbEsRecord.PK}\" as it is not a valid CMS entry...`\n );\n continue;\n }\n\n // 1. Check if the data migration was ever performed. If not, let's perform it.\n if (!isMigratedEntry(decompressedData)) {\n // Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value.\n const createdOn = await getOldestRevisionCreatedOn({\n entry: { ...decompressedData, PK: ddbEsRecord.PK },\n entryEntity: ddbEntryEntity,\n retryOptions: {\n onFailedAttempt: error => {\n logger.warn(\n {\n error,\n item: { ...decompressedData, PK: ddbEsRecord.PK }\n },\n `[DDB-ES Table] getOldestRevisionCreatedOn attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n }\n });\n\n const firstLastPublishedOnByFields = await getFirstLastPublishedOnBy({\n entry: { ...decompressedData, PK: ddbEsRecord.PK },\n entryEntity: ddbEntryEntity,\n retryOptions: {\n onFailedAttempt: error => {\n logger.warn(\n {\n error,\n item: { ...decompressedData, PK: ddbEsRecord.PK }\n },\n `[DDB-ES Table] getFirstLastPublishedOnBy attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n }\n });\n\n assignNewMetaFields(decompressedData, {\n createdOn,\n ...firstLastPublishedOnByFields\n });\n }\n\n // 2. Ensure new non-nullable meta fields have a value and nothing is missing.\n if (!hasAllNonNullableValues(decompressedData)) {\n logger.trace(\n getNonNullableFieldsWithMissingValues(decompressedData),\n [\n `[DDB-ES Table] Detected an entry with missing values for non-nullable meta fields`,\n `(${decompressedData.modelId}/${decompressedData.id}).`\n ].join(\" \")\n );\n\n try {\n const fallbackIdentity = await getFallbackIdentity({\n entity: ddbEntryEntity,\n tenant: decompressedData.tenant,\n retryOptions: {\n onFailedAttempt: error => {\n logger.warn(\n { error, item: ddbEntryEntity },\n `[DDB-ES Table] getFallbackIdentity attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n }\n });\n\n ensureAllNonNullableValues(decompressedData, {\n dateTime: fallbackDateTime,\n identity: fallbackIdentity\n });\n\n logger.trace(\n [\n `[DDB-ES Table] Successfully ensured all non-nullable meta fields`,\n `have values (${decompressedData.modelId}/${decompressedData.id}).`,\n \"Will be saving the changes soon.\"\n ].join(\" \")\n );\n } catch (e) {\n logger.error(\n [\n \"[DDB-ES Table] Failed to ensure all non-nullable meta fields have values\",\n `(${decompressedData.modelId}/${decompressedData.id}): ${e.message}`\n ].join(\" \")\n );\n }\n }\n\n const compressedData = await getCompressedData(decompressedData);\n\n ddbEsItemsToBatchWrite.push(\n ddbEsEntryEntity.putBatch({\n ...ddbEsRecord,\n data: compressedData\n })\n );\n }\n }\n\n if (ddbItemsToBatchWrite.length) {\n let ddbWriteError = false;\n let ddbEsWriteError = false;\n\n // Store data in primary DynamoDB table.\n const execute = () => {\n return batchWriteAll(\n {\n table: ddbEntryEntity.table,\n items: ddbItemsToBatchWrite\n },\n BATCH_WRITE_MAX_CHUNK\n );\n };\n\n logger.trace(\n `Storing ${ddbItemsToBatchWrite.length} record(s) in primary DynamoDB table...`\n );\n\n try {\n await executeWithRetry(execute, {\n onFailedAttempt: error => {\n logger.warn(\n `Batch write attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n });\n } catch (e) {\n ddbWriteError = true;\n logger.error(\n {\n error: e,\n ddbItemsToBatchWrite\n },\n \"After multiple retries, failed to batch-store records in primary DynamoDB table.\"\n );\n }\n\n if (ddbEsItemsToBatchWrite.length) {\n logger.trace(\n `Storing ${ddbEsItemsToBatchWrite.length} record(s) in DDB-ES DynamoDB table...`\n );\n\n try {\n const results = await waitUntilHealthy.wait({\n async onUnhealthy(params) {\n const shouldWaitReason = params.waitingReason.name;\n\n logger.warn(\n `Cluster is unhealthy (${shouldWaitReason}). Waiting for the cluster to become healthy...`,\n params\n );\n\n if (\n status.stats.esHealthChecks.unhealthyReasons[\n shouldWaitReason\n ]\n ) {\n status.stats.esHealthChecks.unhealthyReasons[\n shouldWaitReason\n ]++;\n } else {\n status.stats.esHealthChecks.unhealthyReasons[\n shouldWaitReason\n ] = 1;\n }\n }\n });\n\n status.stats.esHealthChecks.checksCount++;\n status.stats.esHealthChecks.timeSpentWaiting += results.runningTime;\n\n // Store data in DDB-ES DynamoDB table.\n const executeDdbEs = () => {\n return batchWriteAll(\n {\n table: ddbEsEntryEntity.table,\n items: ddbEsItemsToBatchWrite\n },\n BATCH_WRITE_MAX_CHUNK\n );\n };\n\n await executeWithRetry(executeDdbEs, {\n onFailedAttempt: error => {\n logger.warn(\n `[DDB-ES Table] Batch write attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n });\n } catch (e) {\n ddbEsWriteError = true;\n logger.error(\n {\n error: e,\n ddbEsItemsToBatchWrite\n },\n \"After multiple retries, failed to batch-store records in DDB-ES DynamoDB table.\"\n );\n }\n }\n\n if (ddbEsWriteError || ddbWriteError) {\n logger.warn(\n 'Not increasing the \"recordsUpdated\" count due to write errors.'\n );\n } else {\n status.stats.recordsUpdated += ddbItemsToBatchWrite.length;\n }\n }\n\n // Update checkpoint after every batch.\n let lastEvaluatedKey: LastEvaluatedKey = true;\n if (result.lastEvaluatedKey) {\n lastEvaluatedKey = result.lastEvaluatedKey as unknown as LastEvaluatedKeyObject;\n }\n\n status.lastEvaluatedKey = lastEvaluatedKey;\n\n if (lastEvaluatedKey === true) {\n return false;\n }\n\n // Continue further scanning.\n return true;\n },\n {\n retry: {\n onFailedAttempt: error => {\n logger.warn(\n {\n lastEvaluatedKey: status.lastEvaluatedKey,\n error\n },\n `ddbScanWithCallback attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n }\n }\n );\n\n // Store status in tmp file.\n logger.trace({ status }, \"Segment processing completed. Saving status to tmp file...\");\n const logFilePath = path.join(\n os.tmpdir(),\n `webiny-5-39-6-meta-fields-data-migration-log-${argv.runId}-${argv.segmentIndex}.log`\n );\n\n // Save segment processing stats to a file.\n fs.writeFileSync(logFilePath, JSON.stringify(status.stats, null, 2));\n\n logger.trace(`Segment processing stats saved in ${logFilePath}.`);\n } catch (error) {\n // Store status in tmp file.\n logger.error(\n { status, error },\n \"Segment processing failed to complete. Saving status to tmp file...\"\n );\n const logFilePath = path.join(\n os.tmpdir(),\n `webiny-5-39-6-meta-fields-data-migration-log-${argv.runId}-${argv.segmentIndex}.log`\n );\n\n // Save segment processing stats to a file.\n fs.writeFileSync(logFilePath, JSON.stringify(status.stats, null, 2));\n\n logger.trace(`Segment processing stats saved in ${logFilePath}.`);\n }\n})();\n"],"mappings":";;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,gBAAA,GAAAR,OAAA;AACA,IAAAS,uBAAA,GAAAT,OAAA;AACA,IAAAU,wBAAA,GAAAV,OAAA;AACA,IAAAW,2BAAA,GAAAX,OAAA;AACA,IAAAY,wBAAA,GAAAZ,OAAA;AACA,IAAAa,oBAAA,GAAAb,OAAA;AACA,IAAAc,kBAAA,GAAAd,OAAA;AACA,IAAAe,oBAAA,GAAAf,OAAA;AACA,IAAAgB,2BAAA,GAAAhB,OAAA;AACA,IAAAiB,oBAAA,GAAAjB,OAAA;AACA,IAAAkB,kBAAA,GAAAlB,OAAA;AAEA,IAAAmB,kBAAA,GAAAnB,OAAA;AAIA,IAAAoB,OAAA,GAAApB,OAAA;AAOA,IAAAqB,iBAAA,GAAArB,OAAA;AACA,IAAAsB,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ACzBkB,WAAE,CAACC,MAAM,CAAC,CAAC,EACV,gDAA+CzJ,IAAI,CAACK,KAAM,IAAGL,IAAI,CAACW,YAAa,MACpF,CAAC;;IAED;IACA+I,WAAE,CAACC,aAAa,CAACL,WAAW,EAAEM,IAAI,CAACC,SAAS,CAACtG,MAAM,CAAClC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEpEa,MAAM,CAAC0C,KAAK,CAAE,qCAAoC0E,WAAY,GAAE,CAAC;EACrE;AACJ,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@webiny/migrations",
3
- "version": "5.39.10-beta.1",
3
+ "version": "5.39.10-beta.2",
4
4
  "scripts": {
5
5
  "build": "yarn webiny run build",
6
6
  "watch": "yarn webiny run watch"
7
7
  },
8
8
  "dependencies": {
9
9
  "@elastic/elasticsearch": "7.12.0",
10
- "@webiny/api-elasticsearch": "5.39.10-beta.1",
11
- "@webiny/aws-sdk": "5.39.10-beta.1",
12
- "@webiny/cli-plugin-deploy-pulumi": "5.39.10-beta.1",
13
- "@webiny/data-migration": "5.39.10-beta.1",
14
- "@webiny/db-dynamodb": "5.39.10-beta.1",
15
- "@webiny/error": "5.39.10-beta.1",
16
- "@webiny/ioc": "5.39.10-beta.1",
17
- "@webiny/logger": "5.39.10-beta.1",
18
- "@webiny/utils": "5.39.10-beta.1",
10
+ "@webiny/api-elasticsearch": "5.39.10-beta.2",
11
+ "@webiny/aws-sdk": "5.39.10-beta.2",
12
+ "@webiny/cli-plugin-deploy-pulumi": "5.39.10-beta.2",
13
+ "@webiny/data-migration": "5.39.10-beta.2",
14
+ "@webiny/db-dynamodb": "5.39.10-beta.2",
15
+ "@webiny/error": "5.39.10-beta.2",
16
+ "@webiny/ioc": "5.39.10-beta.2",
17
+ "@webiny/logger": "5.39.10-beta.2",
18
+ "@webiny/utils": "5.39.10-beta.2",
19
19
  "execa": "5.1.1",
20
20
  "fast-glob": "3.2.12",
21
21
  "jsonpack": "1.1.5",
@@ -30,16 +30,16 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/execa": "2.0.0",
33
- "@webiny/api-headless-cms": "5.39.10-beta.1",
34
- "@webiny/api-headless-cms-ddb-es": "5.39.10-beta.1",
35
- "@webiny/cli": "5.39.10-beta.1",
36
- "@webiny/handler-aws": "5.39.10-beta.1",
37
- "@webiny/plugins": "5.39.10-beta.1",
38
- "@webiny/project-utils": "5.39.10-beta.1",
33
+ "@webiny/api-headless-cms": "5.39.10-beta.2",
34
+ "@webiny/api-headless-cms-ddb-es": "5.39.10-beta.2",
35
+ "@webiny/cli": "5.39.10-beta.2",
36
+ "@webiny/handler-aws": "5.39.10-beta.2",
37
+ "@webiny/plugins": "5.39.10-beta.2",
38
+ "@webiny/project-utils": "5.39.10-beta.2",
39
39
  "elastic-ts": "0.8.0",
40
40
  "jest-dynalite": "3.6.1",
41
41
  "ttypescript": "1.5.15",
42
42
  "typescript": "4.7.4"
43
43
  },
44
- "gitHead": "ea9221b8891b62797e288a71eb2c0acc08c8db19"
44
+ "gitHead": "641d166c7558f7d86c0aefa46127e0b67c679512"
45
45
  }