@webiny/migrations 5.39.9-beta.1 → 5.39.10-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.
|
@@ -90,6 +90,7 @@ const createInitialStatus = () => {
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
+
const BATCH_WRITE_MAX_CHUNK = 20;
|
|
93
94
|
(async () => {
|
|
94
95
|
const logger = (0, _logger.createPinoLogger)({
|
|
95
96
|
level: (0, _logger.getLogLevel)(process.env.MIGRATIONS_LOG_LEVEL, "trace"),
|
|
@@ -119,234 +120,270 @@ const createInitialStatus = () => {
|
|
|
119
120
|
maxWaitingTime: argv.esHealthMaxWaitingTime,
|
|
120
121
|
waitingTimeStep: argv.esHealthWaitingTimeStep
|
|
121
122
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}, async result => {
|
|
135
|
-
status.stats.iterationsCount++;
|
|
136
|
-
status.stats.recordsScanned += result.items.length;
|
|
137
|
-
if (status.stats.iterationsCount % 5 === 0) {
|
|
138
|
-
// We log every 5th iteration.
|
|
139
|
-
logger.trace(`[iteration #${status.stats.iterationsCount}] Reading ${result.items.length} record(s)...`);
|
|
140
|
-
}
|
|
141
|
-
const ddbItemsToBatchWrite = [];
|
|
142
|
-
const ddbEsItemsToBatchWrite = [];
|
|
143
|
-
const ddbEsItemsToBatchRead = {};
|
|
144
|
-
const fallbackDateTime = new Date().toISOString();
|
|
145
|
-
|
|
146
|
-
// Update records in primary DynamoDB table. Also do preparations for
|
|
147
|
-
// subsequent updates on DDB-ES DynamoDB table, and in Elasticsearch.
|
|
148
|
-
for (const item of result.items) {
|
|
149
|
-
const isFullyMigrated = (0, _isMigratedEntry.isMigratedEntry)(item) && (0, _hasValidTypeFieldValue.hasValidTypeFieldValue)(item) && (0, _hasAllNonNullableValues.hasAllNonNullableValues)(item);
|
|
150
|
-
if (isFullyMigrated) {
|
|
151
|
-
status.stats.recordsSkipped++;
|
|
152
|
-
continue;
|
|
123
|
+
try {
|
|
124
|
+
await (0, _utils2.ddbScanWithCallback)({
|
|
125
|
+
entity: ddbEntryEntity,
|
|
126
|
+
options: {
|
|
127
|
+
segment: argv.segmentIndex,
|
|
128
|
+
segments: argv.totalSegments,
|
|
129
|
+
filters: [{
|
|
130
|
+
attr: "_et",
|
|
131
|
+
eq: "CmsEntries"
|
|
132
|
+
}],
|
|
133
|
+
startKey: status.lastEvaluatedKey || undefined,
|
|
134
|
+
limit: 100
|
|
153
135
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
entryEntity: ddbEntryEntity
|
|
161
|
-
});
|
|
162
|
-
const firstLastPublishedOnByFields = await (0, _getFirstLastPublishedOn.getFirstLastPublishedOnBy)({
|
|
163
|
-
entry: item,
|
|
164
|
-
entryEntity: ddbEntryEntity
|
|
165
|
-
});
|
|
166
|
-
(0, _assignNewMetaFields.assignNewMetaFields)(item, {
|
|
167
|
-
createdOn,
|
|
168
|
-
...firstLastPublishedOnByFields
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// 2. We've noticed some of the records had an invalid `TYPE` field value
|
|
173
|
-
// in the database. This step addresses this issue.
|
|
174
|
-
if (!(0, _hasValidTypeFieldValue.hasValidTypeFieldValue)(item)) {
|
|
175
|
-
// Fixes the value of the `TYPE` field, if it's not valid.
|
|
176
|
-
(0, _fixTypeFieldValue.fixTypeFieldValue)(item);
|
|
136
|
+
}, async result => {
|
|
137
|
+
status.stats.iterationsCount++;
|
|
138
|
+
status.stats.recordsScanned += result.items.length;
|
|
139
|
+
if (status.stats.iterationsCount % 5 === 0) {
|
|
140
|
+
// We log every 5th iteration.
|
|
141
|
+
logger.trace(`[iteration #${status.stats.iterationsCount}] Reading ${result.items.length} record(s)...`);
|
|
177
142
|
}
|
|
143
|
+
const ddbItemsToBatchWrite = [];
|
|
144
|
+
const ddbEsItemsToBatchWrite = [];
|
|
145
|
+
const ddbEsItemsToBatchRead = {};
|
|
146
|
+
const fallbackDateTime = new Date().toISOString();
|
|
178
147
|
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
entity: ddbEntryEntity,
|
|
186
|
-
tenant: item.tenant
|
|
187
|
-
});
|
|
188
|
-
(0, _ensureAllNonNullableValues.ensureAllNonNullableValues)(item, {
|
|
189
|
-
dateTime: fallbackDateTime,
|
|
190
|
-
identity: fallbackIdentity
|
|
191
|
-
});
|
|
192
|
-
logger.trace(`Successfully ensured all non-nullable meta fields have values (${item.modelId}/${item.id}). Will be saving into the database soon.`);
|
|
193
|
-
} catch (e) {
|
|
194
|
-
logger.debug(`Failed to ensure all non-nullable meta fields have values (${item.modelId}/${item.id}): ${e.message}`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
ddbItemsToBatchWrite.push(ddbEntryEntity.putBatch(item));
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Prepare the loading of DynamoDB Elasticsearch part of the records.
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
const ddbEsLatestRecordKey = `${item.entryId}:L`;
|
|
204
|
-
if (ddbEsItemsToBatchRead[ddbEsLatestRecordKey]) {
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
ddbEsItemsToBatchRead[ddbEsLatestRecordKey] = ddbEsEntryEntity.getBatch({
|
|
208
|
-
PK: item.PK,
|
|
209
|
-
SK: "L"
|
|
210
|
-
});
|
|
211
|
-
const ddbEsPublishedRecordKey = `${item.entryId}:P`;
|
|
212
|
-
if (item.status === "published" || !!item.locked) {
|
|
213
|
-
ddbEsItemsToBatchRead[ddbEsPublishedRecordKey] = ddbEsEntryEntity.getBatch({
|
|
214
|
-
PK: item.PK,
|
|
215
|
-
SK: "P"
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (Object.keys(ddbEsItemsToBatchRead).length > 0) {
|
|
220
|
-
/**
|
|
221
|
-
* Get all the records from DynamoDB Elasticsearch.
|
|
222
|
-
*/
|
|
223
|
-
const ddbEsRecords = await (0, _utils2.batchReadAll)({
|
|
224
|
-
table: ddbEsEntryEntity.table,
|
|
225
|
-
items: Object.values(ddbEsItemsToBatchRead)
|
|
226
|
-
});
|
|
227
|
-
for (const ddbEsRecord of ddbEsRecords) {
|
|
228
|
-
const decompressedData = await (0, _getDecompressedData.getDecompressedData)(ddbEsRecord.data);
|
|
229
|
-
if (!decompressedData) {
|
|
230
|
-
logger.trace(`[DDB-ES Table] Skipping record "${ddbEsRecord.PK}" as it is not a valid CMS entry...`);
|
|
148
|
+
// Update records in primary DynamoDB table. Also do preparations for
|
|
149
|
+
// subsequent updates on DDB-ES DynamoDB table, and in Elasticsearch.
|
|
150
|
+
for (const item of result.items) {
|
|
151
|
+
const isFullyMigrated = (0, _isMigratedEntry.isMigratedEntry)(item) && (0, _hasValidTypeFieldValue.hasValidTypeFieldValue)(item) && (0, _hasAllNonNullableValues.hasAllNonNullableValues)(item);
|
|
152
|
+
if (isFullyMigrated) {
|
|
153
|
+
status.stats.recordsSkipped++;
|
|
231
154
|
continue;
|
|
232
155
|
}
|
|
233
156
|
|
|
234
157
|
// 1. Check if the data migration was ever performed. If not, let's perform it.
|
|
235
|
-
if (!(0, _isMigratedEntry.isMigratedEntry)(
|
|
158
|
+
if (!(0, _isMigratedEntry.isMigratedEntry)(item)) {
|
|
236
159
|
// Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value.
|
|
237
160
|
const createdOn = await (0, _getOldestRevisionCreatedOn.getOldestRevisionCreatedOn)({
|
|
238
|
-
entry:
|
|
239
|
-
...decompressedData,
|
|
240
|
-
PK: ddbEsRecord.PK
|
|
241
|
-
},
|
|
161
|
+
entry: item,
|
|
242
162
|
entryEntity: ddbEntryEntity
|
|
243
163
|
});
|
|
244
164
|
const firstLastPublishedOnByFields = await (0, _getFirstLastPublishedOn.getFirstLastPublishedOnBy)({
|
|
245
|
-
entry:
|
|
246
|
-
...decompressedData,
|
|
247
|
-
PK: ddbEsRecord.PK
|
|
248
|
-
},
|
|
165
|
+
entry: item,
|
|
249
166
|
entryEntity: ddbEntryEntity
|
|
250
167
|
});
|
|
251
|
-
(0, _assignNewMetaFields.assignNewMetaFields)(
|
|
168
|
+
(0, _assignNewMetaFields.assignNewMetaFields)(item, {
|
|
252
169
|
createdOn,
|
|
253
170
|
...firstLastPublishedOnByFields
|
|
254
171
|
});
|
|
255
172
|
}
|
|
256
173
|
|
|
257
|
-
// 2.
|
|
258
|
-
|
|
259
|
-
|
|
174
|
+
// 2. We've noticed some of the records had an invalid `TYPE` field value
|
|
175
|
+
// in the database. This step addresses this issue.
|
|
176
|
+
if (!(0, _hasValidTypeFieldValue.hasValidTypeFieldValue)(item)) {
|
|
177
|
+
// Fixes the value of the `TYPE` field, if it's not valid.
|
|
178
|
+
(0, _fixTypeFieldValue.fixTypeFieldValue)(item);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 3. Finally, once both of the steps were performed, ensure that all
|
|
182
|
+
// new non-nullable meta fields have a value and nothing is missing.
|
|
183
|
+
if (!(0, _hasAllNonNullableValues.hasAllNonNullableValues)(item)) {
|
|
184
|
+
logger.trace((0, _getNonNullableFieldsWithMissingValues.getNonNullableFieldsWithMissingValues)(item), `Detected an entry with missing values for non-nullable meta fields (${item.modelId}/${item.id}).`);
|
|
260
185
|
try {
|
|
261
186
|
const fallbackIdentity = await (0, _getFallbackIdentity.getFallbackIdentity)({
|
|
262
187
|
entity: ddbEntryEntity,
|
|
263
|
-
tenant:
|
|
188
|
+
tenant: item.tenant
|
|
264
189
|
});
|
|
265
|
-
(0, _ensureAllNonNullableValues.ensureAllNonNullableValues)(
|
|
190
|
+
(0, _ensureAllNonNullableValues.ensureAllNonNullableValues)(item, {
|
|
266
191
|
dateTime: fallbackDateTime,
|
|
267
192
|
identity: fallbackIdentity
|
|
268
193
|
});
|
|
269
|
-
logger.trace(
|
|
194
|
+
logger.trace(`Successfully ensured all non-nullable meta fields have values (${item.modelId}/${item.id}). Will be saving into the database soon.`);
|
|
270
195
|
} catch (e) {
|
|
271
|
-
logger.
|
|
196
|
+
logger.debug(`Failed to ensure all non-nullable meta fields have values (${item.modelId}/${item.id}): ${e.message}`);
|
|
272
197
|
}
|
|
273
198
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
199
|
+
ddbItemsToBatchWrite.push(ddbEntryEntity.putBatch(item));
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Prepare the loading of DynamoDB Elasticsearch part of the records.
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
const ddbEsLatestRecordKey = `${item.entryId}:L`;
|
|
206
|
+
if (ddbEsItemsToBatchRead[ddbEsLatestRecordKey]) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
ddbEsItemsToBatchRead[ddbEsLatestRecordKey] = ddbEsEntryEntity.getBatch({
|
|
210
|
+
PK: item.PK,
|
|
211
|
+
SK: "L"
|
|
287
212
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
213
|
+
const ddbEsPublishedRecordKey = `${item.entryId}:P`;
|
|
214
|
+
if (item.status === "published" || !!item.locked) {
|
|
215
|
+
ddbEsItemsToBatchRead[ddbEsPublishedRecordKey] = ddbEsEntryEntity.getBatch({
|
|
216
|
+
PK: item.PK,
|
|
217
|
+
SK: "P"
|
|
218
|
+
});
|
|
293
219
|
}
|
|
294
|
-
}
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
220
|
+
}
|
|
221
|
+
if (Object.keys(ddbEsItemsToBatchRead).length > 0) {
|
|
222
|
+
/**
|
|
223
|
+
* Get all the records from DynamoDB Elasticsearch.
|
|
224
|
+
*/
|
|
225
|
+
const ddbEsRecords = await (0, _utils2.batchReadAll)({
|
|
226
|
+
table: ddbEsEntryEntity.table,
|
|
227
|
+
items: Object.values(ddbEsItemsToBatchRead)
|
|
228
|
+
});
|
|
229
|
+
for (const ddbEsRecord of ddbEsRecords) {
|
|
230
|
+
const decompressedData = await (0, _getDecompressedData.getDecompressedData)(ddbEsRecord.data);
|
|
231
|
+
if (!decompressedData) {
|
|
232
|
+
logger.trace(`[DDB-ES Table] Skipping record "${ddbEsRecord.PK}" as it is not a valid CMS entry...`);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// 1. Check if the data migration was ever performed. If not, let's perform it.
|
|
237
|
+
if (!(0, _isMigratedEntry.isMigratedEntry)(decompressedData)) {
|
|
238
|
+
// Get the oldest revision's `createdOn` value. We use that to set the entry-level `createdOn` value.
|
|
239
|
+
const createdOn = await (0, _getOldestRevisionCreatedOn.getOldestRevisionCreatedOn)({
|
|
240
|
+
entry: {
|
|
241
|
+
...decompressedData,
|
|
242
|
+
PK: ddbEsRecord.PK
|
|
243
|
+
},
|
|
244
|
+
entryEntity: ddbEntryEntity
|
|
245
|
+
});
|
|
246
|
+
const firstLastPublishedOnByFields = await (0, _getFirstLastPublishedOn.getFirstLastPublishedOnBy)({
|
|
247
|
+
entry: {
|
|
248
|
+
...decompressedData,
|
|
249
|
+
PK: ddbEsRecord.PK
|
|
250
|
+
},
|
|
251
|
+
entryEntity: ddbEntryEntity
|
|
252
|
+
});
|
|
253
|
+
(0, _assignNewMetaFields.assignNewMetaFields)(decompressedData, {
|
|
254
|
+
createdOn,
|
|
255
|
+
...firstLastPublishedOnByFields
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// 2. Ensure new non-nullable meta fields have a value and nothing is missing.
|
|
260
|
+
if (!(0, _hasAllNonNullableValues.hasAllNonNullableValues)(decompressedData)) {
|
|
261
|
+
logger.trace((0, _getNonNullableFieldsWithMissingValues.getNonNullableFieldsWithMissingValues)(decompressedData), [`[DDB-ES Table] Detected an entry with missing values for non-nullable meta fields`, `(${decompressedData.modelId}/${decompressedData.id}).`].join(" "));
|
|
262
|
+
try {
|
|
263
|
+
const fallbackIdentity = await (0, _getFallbackIdentity.getFallbackIdentity)({
|
|
264
|
+
entity: ddbEntryEntity,
|
|
265
|
+
tenant: decompressedData.tenant
|
|
266
|
+
});
|
|
267
|
+
(0, _ensureAllNonNullableValues.ensureAllNonNullableValues)(decompressedData, {
|
|
268
|
+
dateTime: fallbackDateTime,
|
|
269
|
+
identity: fallbackIdentity
|
|
270
|
+
});
|
|
271
|
+
logger.trace([`[DDB-ES Table] Successfully ensured all non-nullable meta fields`, `have values (${decompressedData.modelId}/${decompressedData.id}).`, "Will be saving the changes soon."].join(" "));
|
|
272
|
+
} catch (e) {
|
|
273
|
+
logger.error(["[DDB-ES Table] Failed to ensure all non-nullable meta fields have values", `(${decompressedData.modelId}/${decompressedData.id}): ${e.message}`].join(" "));
|
|
305
274
|
}
|
|
306
275
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
276
|
+
const compressedData = await (0, _getCompressedData.getCompressedData)(decompressedData);
|
|
277
|
+
ddbEsItemsToBatchWrite.push(ddbEsEntryEntity.putBatch({
|
|
278
|
+
...ddbEsRecord,
|
|
279
|
+
data: compressedData
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (ddbItemsToBatchWrite.length) {
|
|
284
|
+
let ddbWriteError = false;
|
|
285
|
+
let ddbEsWriteError = false;
|
|
310
286
|
|
|
311
|
-
// Store data in
|
|
312
|
-
const
|
|
287
|
+
// Store data in primary DynamoDB table.
|
|
288
|
+
const execute = () => {
|
|
313
289
|
return (0, _utils2.batchWriteAll)({
|
|
314
|
-
table:
|
|
315
|
-
items:
|
|
316
|
-
});
|
|
290
|
+
table: ddbEntryEntity.table,
|
|
291
|
+
items: ddbItemsToBatchWrite
|
|
292
|
+
}, BATCH_WRITE_MAX_CHUNK);
|
|
317
293
|
};
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
294
|
+
logger.trace(`Storing ${ddbItemsToBatchWrite.length} record(s) in primary DynamoDB table...`);
|
|
295
|
+
try {
|
|
296
|
+
await (0, _utils.executeWithRetry)(execute, {
|
|
297
|
+
onFailedAttempt: error => {
|
|
298
|
+
logger.warn(`Batch write attempt #${error.attemptNumber} failed: ${error.message}`);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
} catch (e) {
|
|
302
|
+
ddbWriteError = true;
|
|
303
|
+
logger.error({
|
|
304
|
+
error: e,
|
|
305
|
+
ddbItemsToBatchWrite
|
|
306
|
+
}, "After multiple retries, failed to batch-store records in primary DynamoDB table.");
|
|
307
|
+
}
|
|
308
|
+
if (ddbEsItemsToBatchWrite.length) {
|
|
309
|
+
logger.trace(`Storing ${ddbEsItemsToBatchWrite.length} record(s) in DDB-ES DynamoDB table...`);
|
|
310
|
+
try {
|
|
311
|
+
const results = await waitUntilHealthy.wait({
|
|
312
|
+
async onUnhealthy(params) {
|
|
313
|
+
const shouldWaitReason = params.waitingReason.name;
|
|
314
|
+
logger.warn(`Cluster is unhealthy (${shouldWaitReason}). Waiting for the cluster to become healthy...`, params);
|
|
315
|
+
if (status.stats.esHealthChecks.unhealthyReasons[shouldWaitReason]) {
|
|
316
|
+
status.stats.esHealthChecks.unhealthyReasons[shouldWaitReason]++;
|
|
317
|
+
} else {
|
|
318
|
+
status.stats.esHealthChecks.unhealthyReasons[shouldWaitReason] = 1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
status.stats.esHealthChecks.checksCount++;
|
|
323
|
+
status.stats.esHealthChecks.timeSpentWaiting += results.runningTime;
|
|
324
|
+
|
|
325
|
+
// Store data in DDB-ES DynamoDB table.
|
|
326
|
+
const executeDdbEs = () => {
|
|
327
|
+
return (0, _utils2.batchWriteAll)({
|
|
328
|
+
table: ddbEsEntryEntity.table,
|
|
329
|
+
items: ddbEsItemsToBatchWrite
|
|
330
|
+
}, BATCH_WRITE_MAX_CHUNK);
|
|
331
|
+
};
|
|
332
|
+
await (0, _utils.executeWithRetry)(executeDdbEs, {
|
|
333
|
+
onFailedAttempt: error => {
|
|
334
|
+
logger.warn(`[DDB-ES Table] Batch write attempt #${error.attemptNumber} failed: ${error.message}`);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
} catch (e) {
|
|
338
|
+
ddbEsWriteError = true;
|
|
339
|
+
logger.error({
|
|
340
|
+
error: e,
|
|
341
|
+
ddbEsItemsToBatchWrite
|
|
342
|
+
}, "After multiple retries, failed to batch-store records in DDB-ES DynamoDB table.");
|
|
321
343
|
}
|
|
322
|
-
}
|
|
344
|
+
}
|
|
345
|
+
if (ddbEsWriteError || ddbWriteError) {
|
|
346
|
+
logger.warn('Not increasing the "recordsUpdated" count due to write errors.');
|
|
347
|
+
} else {
|
|
348
|
+
status.stats.recordsUpdated += ddbItemsToBatchWrite.length;
|
|
349
|
+
}
|
|
323
350
|
}
|
|
324
|
-
status.stats.recordsUpdated += ddbItemsToBatchWrite.length;
|
|
325
|
-
}
|
|
326
351
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
352
|
+
// Update checkpoint after every batch.
|
|
353
|
+
let lastEvaluatedKey = true;
|
|
354
|
+
if (result.lastEvaluatedKey) {
|
|
355
|
+
lastEvaluatedKey = result.lastEvaluatedKey;
|
|
356
|
+
}
|
|
357
|
+
status.lastEvaluatedKey = lastEvaluatedKey;
|
|
358
|
+
if (lastEvaluatedKey === true) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
336
361
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
362
|
+
// Continue further scanning.
|
|
363
|
+
return true;
|
|
364
|
+
});
|
|
340
365
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
366
|
+
// Store status in tmp file.
|
|
367
|
+
logger.trace({
|
|
368
|
+
status
|
|
369
|
+
}, "Segment processing completed. Saving status to tmp file...");
|
|
370
|
+
const logFilePath = _path.default.join(_os.default.tmpdir(), `webiny-5-39-6-meta-fields-data-migration-log-${argv.runId}-${argv.segmentIndex}.log`);
|
|
346
371
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
372
|
+
// Save segment processing stats to a file.
|
|
373
|
+
_fs.default.writeFileSync(logFilePath, JSON.stringify(status.stats, null, 2));
|
|
374
|
+
logger.trace(`Segment processing stats saved in ${logFilePath}.`);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
// Store status in tmp file.
|
|
377
|
+
logger.error({
|
|
378
|
+
status,
|
|
379
|
+
error
|
|
380
|
+
}, "Segment processing failed to complete. Saving status to tmp file...");
|
|
381
|
+
const logFilePath = _path.default.join(_os.default.tmpdir(), `webiny-5-39-6-meta-fields-data-migration-log-${argv.runId}-${argv.segmentIndex}.log`);
|
|
382
|
+
|
|
383
|
+
// Save segment processing stats to a file.
|
|
384
|
+
_fs.default.writeFileSync(logFilePath, JSON.stringify(status.stats, null, 2));
|
|
385
|
+
logger.trace(`Segment processing stats saved in ${logFilePath}.`);
|
|
386
|
+
}
|
|
350
387
|
})();
|
|
351
388
|
|
|
352
389
|
//# sourceMappingURL=worker.js.map
|
|
@@ -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","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","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\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 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>(ddbEsRecord.data);\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 // Store data in primary DynamoDB table.\n const execute = () => {\n return batchWriteAll({\n table: ddbEntryEntity.table,\n items: ddbItemsToBatchWrite\n });\n };\n\n logger.trace(\n `Storing ${ddbItemsToBatchWrite.length} record(s) in primary DynamoDB table...`\n );\n await executeWithRetry(execute, {\n onFailedAttempt: error => {\n logger.warn(\n `Batch write attempt #${error.attemptNumber} failed: ${error.message}`\n );\n }\n });\n\n if (ddbEsItemsToBatchWrite.length) {\n logger.trace(\n `Storing ${ddbEsItemsToBatchWrite.length} record(s) in DDB-ES DynamoDB table...`\n );\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 (status.stats.esHealthChecks.unhealthyReasons[shouldWaitReason]) {\n status.stats.esHealthChecks.unhealthyReasons[shouldWaitReason]++;\n } else {\n status.stats.esHealthChecks.unhealthyReasons[shouldWaitReason] = 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 table: ddbEsEntryEntity.table,\n items: ddbEsItemsToBatchWrite\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 }\n\n status.stats.recordsUpdated += ddbItemsToBatchWrite.length;\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})();\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,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AED,MAAM,IAAAuD,uBAAgB,EAACW,YAAY,EAAE;UACjCV,eAAe,EAAEN,KAAK,IAAI;YACtB/F,MAAM,CAACsG,IAAI,CACN,uCAAsCP,KAAK,CAACQ,aAAc,YAAWR,KAAK,CAACrB,OAAQ,EACxF,CAAC;UACL;QACJ,CAAC,CAAC;MACN;MAEApD,MAAM,CAAC/B,KAAK,CAACG,cAAc,IAAIkD,oBAAoB,CAACF,MAAM;IAC9D;;IAEA;IACA,IAAIpD,gBAAkC,GAAG,IAAI;IAC7C,IAAIkD,MAAM,CAAClD,gBAAgB,EAAE;MACzBA,gBAAgB,GAAGkD,MAAM,CAAClD,gBAAqD;IACnF;IAEAgC,MAAM,CAAChC,gBAAgB,GAAGA,gBAAgB;IAE1C,IAAIA,gBAAgB,KAAK,IAAI,EAAE;MAC3B,OAAO,KAAK;IAChB;;IAEA;IACA,OAAO,IAAI;EACf,CACJ,CAAC;;EAED;EACAU,MAAM,CAAC2C,KAAK,CAAC;IAAErB;EAAO,CAAC,EAAE,4DAA4D,CAAC;EACtF,MAAM0F,WAAW,GAAGC,aAAI,CAACnB,IAAI,CACzBoB,WAAE,CAACC,MAAM,CAAC,CAAC,EACV,gDAA+CjJ,IAAI,CAACK,KAAM,IAAGL,IAAI,CAACW,YAAa,MACpF,CAAC;;EAED;EACAuI,WAAE,CAACC,aAAa,CAACL,WAAW,EAAEM,IAAI,CAACC,SAAS,CAACjG,MAAM,CAAC/B,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;EAEpES,MAAM,CAAC2C,KAAK,CAAE,qCAAoCqE,WAAY,GAAE,CAAC;AACrE,CAAC,EAAE,CAAC"}
|
|
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;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,WAAA,GAAAhB,sBAAA,CAAAN,OAAA;AAEA,IAAAuB,KAAA,GAAAjB,sBAAA,CAAAN,OAAA;AACA,IAAAwB,GAAA,GAAAlB,sBAAA,CAAAN,OAAA;AACA,IAAAyB,GAAA,GAAAnB,sBAAA,CAAAN,OAAA;AACA,IAAA0B,sCAAA,GAAA1B,OAAA;AAEA,MAAM2B,IAAI,GAAG,IAAAC,cAAK,EAAC,IAAAC,gBAAO,EAAC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AE,CAACC,MAAM,CAAC,CAAC,EACV,gDAA+CpJ,IAAI,CAACK,KAAM,IAAGL,IAAI,CAACW,YAAa,MACpF,CAAC;;IAED;IACA0I,WAAE,CAACC,aAAa,CAACL,WAAW,EAAEM,IAAI,CAACC,SAAS,CAACnG,MAAM,CAAChC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEpEU,MAAM,CAAC2C,KAAK,CAAE,qCAAoCuE,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.
|
|
3
|
+
"version": "5.39.10-beta.0",
|
|
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.
|
|
11
|
-
"@webiny/aws-sdk": "5.39.
|
|
12
|
-
"@webiny/cli-plugin-deploy-pulumi": "5.39.
|
|
13
|
-
"@webiny/data-migration": "5.39.
|
|
14
|
-
"@webiny/db-dynamodb": "5.39.
|
|
15
|
-
"@webiny/error": "5.39.
|
|
16
|
-
"@webiny/ioc": "5.39.
|
|
17
|
-
"@webiny/logger": "5.39.
|
|
18
|
-
"@webiny/utils": "5.39.
|
|
10
|
+
"@webiny/api-elasticsearch": "5.39.10-beta.0",
|
|
11
|
+
"@webiny/aws-sdk": "5.39.10-beta.0",
|
|
12
|
+
"@webiny/cli-plugin-deploy-pulumi": "5.39.10-beta.0",
|
|
13
|
+
"@webiny/data-migration": "5.39.10-beta.0",
|
|
14
|
+
"@webiny/db-dynamodb": "5.39.10-beta.0",
|
|
15
|
+
"@webiny/error": "5.39.10-beta.0",
|
|
16
|
+
"@webiny/ioc": "5.39.10-beta.0",
|
|
17
|
+
"@webiny/logger": "5.39.10-beta.0",
|
|
18
|
+
"@webiny/utils": "5.39.10-beta.0",
|
|
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.
|
|
34
|
-
"@webiny/api-headless-cms-ddb-es": "5.39.
|
|
35
|
-
"@webiny/cli": "5.39.
|
|
36
|
-
"@webiny/handler-aws": "5.39.
|
|
37
|
-
"@webiny/plugins": "5.39.
|
|
38
|
-
"@webiny/project-utils": "5.39.
|
|
33
|
+
"@webiny/api-headless-cms": "5.39.10-beta.0",
|
|
34
|
+
"@webiny/api-headless-cms-ddb-es": "5.39.10-beta.0",
|
|
35
|
+
"@webiny/cli": "5.39.10-beta.0",
|
|
36
|
+
"@webiny/handler-aws": "5.39.10-beta.0",
|
|
37
|
+
"@webiny/plugins": "5.39.10-beta.0",
|
|
38
|
+
"@webiny/project-utils": "5.39.10-beta.0",
|
|
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": "
|
|
44
|
+
"gitHead": "ea9221b8891b62797e288a71eb2c0acc08c8db19"
|
|
45
45
|
}
|