@strapi/data-transfer 5.4.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/errors/constants.d.ts +1 -1
- package/dist/errors/constants.d.ts.map +1 -1
- package/dist/file/providers/destination/index.d.ts +1 -1
- package/dist/file/providers/destination/index.d.ts.map +1 -1
- package/dist/file/providers/source/index.d.ts +1 -1
- package/dist/file/providers/source/index.d.ts.map +1 -1
- package/dist/index.js +152 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -90
- package/dist/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/index.d.ts +1 -1
- package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-destination/index.d.ts +1 -1
- package/dist/strapi/providers/remote-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-source/index.d.ts +1 -1
- package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/utils.d.ts +2 -1
- package/dist/strapi/providers/utils.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/abstract.d.ts +4 -0
- package/dist/strapi/remote/handlers/abstract.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/pull.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/push.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/utils.d.ts.map +1 -1
- package/dist/{engine → utils}/diagnostic.d.ts +1 -1
- package/dist/utils/diagnostic.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/engine/diagnostic.d.ts.map +0 -1
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PassThrough } from 'stream';
|
|
3
3
|
import type { IDestinationProvider, ISourceProvider, ITransferEngine, ITransferEngineOptions, TransferProgress, ITransferResults, TransferStage, TransferFilters, TransferFilterPreset, SchemaDiffHandler, SchemaDiffHandlerContext, ErrorHandler, ErrorHandlerContext, ErrorCode } from '../../types';
|
|
4
|
-
import { IDiagnosticReporter, ErrorDiagnosticSeverity } from '
|
|
4
|
+
import { IDiagnosticReporter, ErrorDiagnosticSeverity } from '../utils/diagnostic';
|
|
5
5
|
export declare const TRANSFER_STAGES: ReadonlyArray<TransferStage>;
|
|
6
6
|
export type TransferGroupFilter = Record<TransferFilterPreset, TransferFilters>;
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAiC,MAAM,QAAQ,CAAC;AAUpE,OAAO,KAAK,EAEV,oBAAoB,EAIpB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EAGb,eAAe,EACf,oBAAoB,EAEpB,iBAAiB,EACjB,wBAAwB,EACxB,YAAY,EACZ,mBAAmB,EAEnB,SAAS,EACV,MAAM,aAAa,CAAC;AAMrB,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAiC,MAAM,QAAQ,CAAC;AAUpE,OAAO,KAAK,EAEV,oBAAoB,EAIpB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EAGb,eAAe,EACf,oBAAoB,EAEpB,iBAAiB,EACjB,wBAAwB,EACxB,YAAY,EACZ,mBAAmB,EAEnB,SAAS,EACV,MAAM,aAAa,CAAC;AAMrB,OA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B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAahC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyCtB,cAAc;IAyDd,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAmD3C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB/B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBhC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IA6CjC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAsC9B,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB/B,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAc7C;AAED,eAAO,MAAM,oBAAoB,8EACf,CAAC,uBACI,CAAC,WACb,sBAAsB,KAC9B,eAAe,CAAC,EAAE,CAAC,CAErB,CAAC;AAEF,YAAY,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,GACjB,CAAC;AAEF,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorDiagnosticSeverity } from '../
|
|
1
|
+
import { ErrorDiagnosticSeverity } from '../utils/diagnostic';
|
|
2
2
|
export declare const SeverityKind: Record<string, ErrorDiagnosticSeverity>;
|
|
3
3
|
export type Severity = (typeof SeverityKind)[keyof typeof SeverityKind];
|
|
4
4
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/errors/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/errors/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAIvD,CAAC;AACX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import zlib from 'zlib';
|
|
5
5
|
import { Writable } from 'stream';
|
|
6
6
|
import type { IDestinationProvider, IDestinationProviderTransferResults, IMetadata, ProviderType } from '../../../../types';
|
|
7
|
-
import type { IDiagnosticReporter } from '../../../
|
|
7
|
+
import type { IDiagnosticReporter } from '../../../utils/diagnostic';
|
|
8
8
|
export interface ILocalFileDestinationProviderOptions {
|
|
9
9
|
encryption: {
|
|
10
10
|
enabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/destination/index.ts"],"names":[],"mappings":";;;AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAY,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAO5C,OAAO,KAAK,EAEV,oBAAoB,EACpB,mCAAmC,EACnC,SAAS,EACT,YAAY,EAEb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/destination/index.ts"],"names":[],"mappings":";;;AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAY,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAO5C,OAAO,KAAK,EAEV,oBAAoB,EACpB,mCAAmC,EACnC,SAAS,EACT,YAAY,EAEb,MA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Readable } from 'stream';
|
|
3
3
|
import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
|
|
4
|
-
import type { IDiagnosticReporter } from '../../../
|
|
4
|
+
import type { IDiagnosticReporter } from '../../../utils/diagnostic';
|
|
5
5
|
/**
|
|
6
6
|
* Provider options
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/source/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAYvC,OAAO,KAAK,EAAU,SAAS,EAAE,eAAe,EAAE,YAAY,EAAS,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/source/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAYvC,OAAO,KAAK,EAAU,SAAS,EAAE,eAAe,EAAE,YAAY,EAAS,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAarE;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,UAAU,EAAE;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,WAAW,EAAE;QACX,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,YAAa,+BAA+B,4BAErF,CAAC;AAEF,cAAM,uBAAwB,YAAW,eAAe;;IACtD,IAAI,EAAE,YAAY,CAAY;IAE9B,IAAI,SAAwB;IAE5B,OAAO,EAAE,+BAA+B,CAAC;gBAM7B,OAAO,EAAE,+BAA+B;IAqBpD;;OAEG;IACG,SAAS,CAAC,WAAW,EAAE,mBAAmB;IAgC1C,WAAW;IASX,UAAU;IAiBhB,wBAAwB,IAAI,QAAQ;IAKpC,uBAAuB,IAAI,QAAQ;IAKnC,qBAAqB,IAAI,QAAQ;IAKjC,6BAA6B,IAAI,QAAQ;IAMzC,sBAAsB,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CA6KvD"}
|
package/dist/index.js
CHANGED
|
@@ -21,8 +21,7 @@ const tar$1 = require("tar-stream");
|
|
|
21
21
|
const Stringer = require("stream-json/jsonl/Stringer");
|
|
22
22
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
23
23
|
function _interopNamespace(e) {
|
|
24
|
-
if (e && e.__esModule)
|
|
25
|
-
return e;
|
|
24
|
+
if (e && e.__esModule) return e;
|
|
26
25
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
27
26
|
if (e) {
|
|
28
27
|
for (const k in e) {
|
|
@@ -326,8 +325,57 @@ const middleware = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
326
325
|
__proto__: null,
|
|
327
326
|
runMiddleware
|
|
328
327
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
328
|
+
const createDiagnosticReporter = (options = {}) => {
|
|
329
|
+
const { stackSize = -1 } = options;
|
|
330
|
+
const emitter = new events.EventEmitter();
|
|
331
|
+
const stack = [];
|
|
332
|
+
const addListener = (event, listener) => {
|
|
333
|
+
emitter.on(event, listener);
|
|
334
|
+
};
|
|
335
|
+
const isDiagnosticValid = (diagnostic2) => {
|
|
336
|
+
if (!diagnostic2.kind || !diagnostic2.details || !diagnostic2.details.message) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
return true;
|
|
340
|
+
};
|
|
341
|
+
return {
|
|
342
|
+
stack: {
|
|
343
|
+
get size() {
|
|
344
|
+
return stack.length;
|
|
345
|
+
},
|
|
346
|
+
get items() {
|
|
347
|
+
return stack;
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
report(diagnostic2) {
|
|
351
|
+
if (!isDiagnosticValid(diagnostic2)) {
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
emitter.emit("diagnostic", diagnostic2);
|
|
355
|
+
emitter.emit(`diagnostic.${diagnostic2.kind}`, diagnostic2);
|
|
356
|
+
if (stackSize !== -1 && stack.length >= stackSize) {
|
|
357
|
+
stack.shift();
|
|
358
|
+
}
|
|
359
|
+
stack.push(diagnostic2);
|
|
360
|
+
return this;
|
|
361
|
+
},
|
|
362
|
+
onDiagnostic(listener) {
|
|
363
|
+
addListener("diagnostic", listener);
|
|
364
|
+
return this;
|
|
365
|
+
},
|
|
366
|
+
on(kind, listener) {
|
|
367
|
+
addListener(`diagnostic.${kind}`, listener);
|
|
368
|
+
return this;
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
const diagnostic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
373
|
+
__proto__: null,
|
|
374
|
+
createDiagnosticReporter
|
|
375
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
329
376
|
const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
330
377
|
__proto__: null,
|
|
378
|
+
diagnostics: diagnostic,
|
|
331
379
|
encryption: index$9,
|
|
332
380
|
json,
|
|
333
381
|
middleware,
|
|
@@ -428,50 +476,6 @@ const validateProvider = (type, provider) => {
|
|
|
428
476
|
);
|
|
429
477
|
}
|
|
430
478
|
};
|
|
431
|
-
const createDiagnosticReporter = (options = {}) => {
|
|
432
|
-
const { stackSize = -1 } = options;
|
|
433
|
-
const emitter = new events.EventEmitter();
|
|
434
|
-
const stack = [];
|
|
435
|
-
const addListener = (event, listener) => {
|
|
436
|
-
emitter.on(event, listener);
|
|
437
|
-
};
|
|
438
|
-
const isDiagnosticValid = (diagnostic) => {
|
|
439
|
-
if (!diagnostic.kind || !diagnostic.details || !diagnostic.details.message) {
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
return true;
|
|
443
|
-
};
|
|
444
|
-
return {
|
|
445
|
-
stack: {
|
|
446
|
-
get size() {
|
|
447
|
-
return stack.length;
|
|
448
|
-
},
|
|
449
|
-
get items() {
|
|
450
|
-
return stack;
|
|
451
|
-
}
|
|
452
|
-
},
|
|
453
|
-
report(diagnostic) {
|
|
454
|
-
if (!isDiagnosticValid(diagnostic)) {
|
|
455
|
-
return this;
|
|
456
|
-
}
|
|
457
|
-
emitter.emit("diagnostic", diagnostic);
|
|
458
|
-
emitter.emit(`diagnostic.${diagnostic.kind}`, diagnostic);
|
|
459
|
-
if (stackSize !== -1 && stack.length >= stackSize) {
|
|
460
|
-
stack.shift();
|
|
461
|
-
}
|
|
462
|
-
stack.push(diagnostic);
|
|
463
|
-
return this;
|
|
464
|
-
},
|
|
465
|
-
onDiagnostic(listener) {
|
|
466
|
-
addListener("diagnostic", listener);
|
|
467
|
-
return this;
|
|
468
|
-
},
|
|
469
|
-
on(kind, listener) {
|
|
470
|
-
addListener(`diagnostic.${kind}`, listener);
|
|
471
|
-
return this;
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
};
|
|
475
479
|
class ProviderError extends DataTransferError {
|
|
476
480
|
constructor(severity, message, details) {
|
|
477
481
|
super("provider", severity, message, details);
|
|
@@ -604,7 +608,7 @@ class TransferEngine {
|
|
|
604
608
|
reportInfo(message, params) {
|
|
605
609
|
this.diagnostics.report({
|
|
606
610
|
kind: "info",
|
|
607
|
-
details: { createdAt: /* @__PURE__ */ new Date(), message, params,
|
|
611
|
+
details: { createdAt: /* @__PURE__ */ new Date(), message, params, origin: "engine" }
|
|
608
612
|
});
|
|
609
613
|
}
|
|
610
614
|
/**
|
|
@@ -1935,7 +1939,7 @@ class LocalStrapiDestinationProvider {
|
|
|
1935
1939
|
details: {
|
|
1936
1940
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1937
1941
|
message,
|
|
1938
|
-
|
|
1942
|
+
origin: "local-destination-provider"
|
|
1939
1943
|
},
|
|
1940
1944
|
kind: "info"
|
|
1941
1945
|
});
|
|
@@ -2112,7 +2116,6 @@ class LocalStrapiDestinationProvider {
|
|
|
2112
2116
|
const removeAssetsBackup = this.#removeAssetsBackup.bind(this);
|
|
2113
2117
|
const strapi2 = this.strapi;
|
|
2114
2118
|
const transaction2 = this.transaction;
|
|
2115
|
-
const backupDirectory = this.uploadsBackupDirectoryName;
|
|
2116
2119
|
const fileEntitiesMapper = this.#entitiesMapper["plugin::upload.file"];
|
|
2117
2120
|
const restoreMediaEntitiesContent = this.#isContentTypeIncluded("plugin::upload.file");
|
|
2118
2121
|
return new stream$1.Writable({
|
|
@@ -2123,47 +2126,28 @@ class LocalStrapiDestinationProvider {
|
|
|
2123
2126
|
},
|
|
2124
2127
|
async write(chunk, _encoding, callback) {
|
|
2125
2128
|
await transaction2?.attach(async () => {
|
|
2126
|
-
if (!chunk.metadata) {
|
|
2127
|
-
const assetsDirectory = path__default.default.join(strapi2.dirs.static.public, "uploads");
|
|
2128
|
-
const entryPath = path__default.default.join(assetsDirectory, chunk.filename);
|
|
2129
|
-
const writableStream = fse__namespace.createWriteStream(entryPath);
|
|
2130
|
-
chunk.stream.pipe(writableStream).on("close", () => {
|
|
2131
|
-
callback(null);
|
|
2132
|
-
}).on("error", async (error) => {
|
|
2133
|
-
const errorMessage = error.code === "ENOSPC" ? " Your server doesn't have space to proceed with the import. " : " ";
|
|
2134
|
-
try {
|
|
2135
|
-
await fse__namespace.rm(assetsDirectory, { recursive: true, force: true });
|
|
2136
|
-
this.destroy(
|
|
2137
|
-
new ProviderTransferError(
|
|
2138
|
-
`There was an error during the transfer process.${errorMessage}The original files have been restored to ${assetsDirectory}`
|
|
2139
|
-
)
|
|
2140
|
-
);
|
|
2141
|
-
} catch (err) {
|
|
2142
|
-
throw new ProviderTransferError(
|
|
2143
|
-
`There was an error doing the rollback process. The original files are in ${backupDirectory}, but we failed to restore them to ${assetsDirectory}`
|
|
2144
|
-
);
|
|
2145
|
-
} finally {
|
|
2146
|
-
callback(error);
|
|
2147
|
-
}
|
|
2148
|
-
});
|
|
2149
|
-
return;
|
|
2150
|
-
}
|
|
2151
2129
|
const uploadData = {
|
|
2152
2130
|
...chunk.metadata,
|
|
2153
2131
|
stream: stream$1.Readable.from(chunk.stream),
|
|
2154
2132
|
buffer: chunk?.buffer
|
|
2155
2133
|
};
|
|
2156
2134
|
const provider = strapi2.config.get("plugin::upload").provider;
|
|
2135
|
+
const fileId = fileEntitiesMapper?.[uploadData.id];
|
|
2136
|
+
if (!fileId) {
|
|
2137
|
+
callback(new Error(`File ID not found for ID: ${uploadData.id}`));
|
|
2138
|
+
}
|
|
2157
2139
|
try {
|
|
2158
2140
|
await strapi2.plugin("upload").provider.uploadStream(uploadData);
|
|
2159
2141
|
if (!restoreMediaEntitiesContent) {
|
|
2160
2142
|
return callback();
|
|
2161
2143
|
}
|
|
2162
2144
|
if (uploadData?.type) {
|
|
2163
|
-
const condition = uploadData?.id ? { id: fileEntitiesMapper[uploadData.id] } : { hash: uploadData.mainHash };
|
|
2164
2145
|
const entry2 = await strapi2.db.query("plugin::upload.file").findOne({
|
|
2165
|
-
where:
|
|
2146
|
+
where: { id: fileId }
|
|
2166
2147
|
});
|
|
2148
|
+
if (!entry2) {
|
|
2149
|
+
throw new Error("file not found");
|
|
2150
|
+
}
|
|
2167
2151
|
const specificFormat = entry2?.formats?.[uploadData.type];
|
|
2168
2152
|
if (specificFormat) {
|
|
2169
2153
|
specificFormat.url = uploadData.url;
|
|
@@ -2178,8 +2162,11 @@ class LocalStrapiDestinationProvider {
|
|
|
2178
2162
|
return callback();
|
|
2179
2163
|
}
|
|
2180
2164
|
const entry = await strapi2.db.query("plugin::upload.file").findOne({
|
|
2181
|
-
where: { id:
|
|
2165
|
+
where: { id: fileId }
|
|
2182
2166
|
});
|
|
2167
|
+
if (!entry) {
|
|
2168
|
+
throw new Error("file not found");
|
|
2169
|
+
}
|
|
2183
2170
|
entry.url = uploadData.url;
|
|
2184
2171
|
await strapi2.db.query("plugin::upload.file").update({
|
|
2185
2172
|
where: { id: entry.id },
|
|
@@ -2422,7 +2409,7 @@ class LocalStrapiSourceProvider {
|
|
|
2422
2409
|
details: {
|
|
2423
2410
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2424
2411
|
message,
|
|
2425
|
-
|
|
2412
|
+
origin: "local-source-provider"
|
|
2426
2413
|
},
|
|
2427
2414
|
kind: "info"
|
|
2428
2415
|
});
|
|
@@ -2532,12 +2519,12 @@ const createDispatcher = (ws2, retryMessageOptions = {
|
|
|
2532
2519
|
const response = JSON.parse(raw.toString());
|
|
2533
2520
|
if (message.type === "command") {
|
|
2534
2521
|
reportInfo?.(
|
|
2535
|
-
`
|
|
2522
|
+
`received response to message command: ${message.command} uuid: ${uuid} sent: ${numberOfTimesMessageWasSent}`
|
|
2536
2523
|
);
|
|
2537
2524
|
} else if (message.type === "transfer") {
|
|
2538
2525
|
const messageToSend = message;
|
|
2539
2526
|
reportInfo?.(
|
|
2540
|
-
`
|
|
2527
|
+
`received response to message action:${messageToSend.action} ${messageToSend.kind === "step" ? `step:${messageToSend.step}` : ""} uuid:${uuid} sent:${numberOfTimesMessageWasSent}`
|
|
2541
2528
|
);
|
|
2542
2529
|
}
|
|
2543
2530
|
if (response.uuid === uuid) {
|
|
@@ -2596,7 +2583,7 @@ const createDispatcher = (ws2, retryMessageOptions = {
|
|
|
2596
2583
|
dispatchTransferStep
|
|
2597
2584
|
};
|
|
2598
2585
|
};
|
|
2599
|
-
const connectToWebsocket = (address, options) => {
|
|
2586
|
+
const connectToWebsocket = (address, options, diagnostics) => {
|
|
2600
2587
|
return new Promise((resolve, reject2) => {
|
|
2601
2588
|
const server = new ws.WebSocket(address, options);
|
|
2602
2589
|
server.once("open", () => {
|
|
@@ -2630,6 +2617,14 @@ const connectToWebsocket = (address, options) => {
|
|
|
2630
2617
|
)
|
|
2631
2618
|
);
|
|
2632
2619
|
});
|
|
2620
|
+
server.on("message", (raw) => {
|
|
2621
|
+
const response = JSON.parse(raw.toString());
|
|
2622
|
+
if (response.diagnostic) {
|
|
2623
|
+
diagnostics?.report({
|
|
2624
|
+
...response.diagnostic
|
|
2625
|
+
});
|
|
2626
|
+
}
|
|
2627
|
+
});
|
|
2633
2628
|
server.once("error", (err) => {
|
|
2634
2629
|
reject2(
|
|
2635
2630
|
new ProviderTransferError(err.message, {
|
|
@@ -2803,7 +2798,7 @@ class RemoteStrapiDestinationProvider {
|
|
|
2803
2798
|
details: {
|
|
2804
2799
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2805
2800
|
message,
|
|
2806
|
-
|
|
2801
|
+
origin: "remote-destination-provider"
|
|
2807
2802
|
},
|
|
2808
2803
|
kind: "info"
|
|
2809
2804
|
});
|
|
@@ -2828,10 +2823,10 @@ class RemoteStrapiDestinationProvider {
|
|
|
2828
2823
|
)}${TRANSFER_PATH}/push`;
|
|
2829
2824
|
this.#reportInfo("establishing websocket connection");
|
|
2830
2825
|
if (!auth) {
|
|
2831
|
-
ws2 = await connectToWebsocket(wsUrl);
|
|
2826
|
+
ws2 = await connectToWebsocket(wsUrl, void 0, this.#diagnostics);
|
|
2832
2827
|
} else if (auth.type === "token") {
|
|
2833
2828
|
const headers = { Authorization: `Bearer ${auth.token}` };
|
|
2834
|
-
ws2 = await connectToWebsocket(wsUrl, { headers });
|
|
2829
|
+
ws2 = await connectToWebsocket(wsUrl, { headers }, this.#diagnostics);
|
|
2835
2830
|
} else {
|
|
2836
2831
|
throw new ProviderValidationError("Auth method not available", {
|
|
2837
2832
|
check: "auth.type",
|
|
@@ -3167,7 +3162,7 @@ class RemoteStrapiSourceProvider {
|
|
|
3167
3162
|
details: {
|
|
3168
3163
|
createdAt: /* @__PURE__ */ new Date(),
|
|
3169
3164
|
message,
|
|
3170
|
-
|
|
3165
|
+
origin: "remote-source-provider"
|
|
3171
3166
|
},
|
|
3172
3167
|
kind: "info"
|
|
3173
3168
|
});
|
|
@@ -3183,10 +3178,10 @@ class RemoteStrapiSourceProvider {
|
|
|
3183
3178
|
)}${TRANSFER_PATH}/pull`;
|
|
3184
3179
|
this.#reportInfo("establishing websocket connection");
|
|
3185
3180
|
if (!auth) {
|
|
3186
|
-
ws2 = await connectToWebsocket(wsUrl);
|
|
3181
|
+
ws2 = await connectToWebsocket(wsUrl, void 0, this.#diagnostics);
|
|
3187
3182
|
} else if (auth.type === "token") {
|
|
3188
3183
|
const headers = { Authorization: `Bearer ${auth.token}` };
|
|
3189
|
-
ws2 = await connectToWebsocket(wsUrl, { headers });
|
|
3184
|
+
ws2 = await connectToWebsocket(wsUrl, { headers }, this.#diagnostics);
|
|
3190
3185
|
} else {
|
|
3191
3186
|
throw new ProviderValidationError("Auth method not available", {
|
|
3192
3187
|
check: "auth.type",
|
|
@@ -3437,6 +3432,7 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3437
3432
|
const cb = (ws2) => {
|
|
3438
3433
|
const state = { id: void 0 };
|
|
3439
3434
|
const messageUUIDs = /* @__PURE__ */ new Set();
|
|
3435
|
+
const diagnostics = createDiagnosticReporter();
|
|
3440
3436
|
const cannotRespondHandler = (err) => {
|
|
3441
3437
|
strapi?.log?.error(
|
|
3442
3438
|
"[Data transfer] Cannot send error response to client, closing connection"
|
|
@@ -3470,6 +3466,9 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3470
3466
|
set response(response) {
|
|
3471
3467
|
state.response = response;
|
|
3472
3468
|
},
|
|
3469
|
+
get diagnostics() {
|
|
3470
|
+
return diagnostics;
|
|
3471
|
+
},
|
|
3473
3472
|
addUUID(uuid) {
|
|
3474
3473
|
messageUUIDs.add(uuid);
|
|
3475
3474
|
},
|
|
@@ -3585,6 +3584,10 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3585
3584
|
onError() {
|
|
3586
3585
|
},
|
|
3587
3586
|
onClose() {
|
|
3587
|
+
},
|
|
3588
|
+
onInfo() {
|
|
3589
|
+
},
|
|
3590
|
+
onWarning() {
|
|
3588
3591
|
}
|
|
3589
3592
|
};
|
|
3590
3593
|
const handler = Object.assign(Object.create(prototype), implementation(prototype));
|
|
@@ -3617,6 +3620,14 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3617
3620
|
cannotRespondHandler(err);
|
|
3618
3621
|
}
|
|
3619
3622
|
});
|
|
3623
|
+
diagnostics.onDiagnostic((diagnostic2) => {
|
|
3624
|
+
const uuid = crypto.randomUUID();
|
|
3625
|
+
const payload = JSON.stringify({
|
|
3626
|
+
diagnostic: diagnostic2,
|
|
3627
|
+
uuid
|
|
3628
|
+
});
|
|
3629
|
+
handler.send(payload);
|
|
3630
|
+
});
|
|
3620
3631
|
};
|
|
3621
3632
|
try {
|
|
3622
3633
|
handleWSUpgrade(wss, ctx, cb);
|
|
@@ -3652,6 +3663,26 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3652
3663
|
verifyAuth() {
|
|
3653
3664
|
return proto.verifyAuth.call(this, TRANSFER_KIND$1);
|
|
3654
3665
|
},
|
|
3666
|
+
onInfo(message) {
|
|
3667
|
+
this.diagnostics?.report({
|
|
3668
|
+
details: {
|
|
3669
|
+
message,
|
|
3670
|
+
origin: "push-handler",
|
|
3671
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
3672
|
+
},
|
|
3673
|
+
kind: "info"
|
|
3674
|
+
});
|
|
3675
|
+
},
|
|
3676
|
+
onWarning(message) {
|
|
3677
|
+
this.diagnostics?.report({
|
|
3678
|
+
details: {
|
|
3679
|
+
message,
|
|
3680
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
3681
|
+
origin: "push-handler"
|
|
3682
|
+
},
|
|
3683
|
+
kind: "warning"
|
|
3684
|
+
});
|
|
3685
|
+
},
|
|
3655
3686
|
cleanup() {
|
|
3656
3687
|
proto.cleanup.call(this);
|
|
3657
3688
|
this.streams = {};
|
|
@@ -3728,6 +3759,7 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3728
3759
|
proto.addUUID(uuid);
|
|
3729
3760
|
if (type === "command") {
|
|
3730
3761
|
const { command } = msg;
|
|
3762
|
+
this.onInfo(`received command:${command} uuid:${uuid}`);
|
|
3731
3763
|
await this.executeAndRespond(uuid, () => {
|
|
3732
3764
|
this.assertValidTransferCommand(command);
|
|
3733
3765
|
if (command === "status") {
|
|
@@ -3736,6 +3768,7 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3736
3768
|
return this[command](msg.params);
|
|
3737
3769
|
});
|
|
3738
3770
|
} else if (type === "transfer") {
|
|
3771
|
+
this.onInfo(`received transfer action:${msg.action} step:${msg.kind} uuid:${uuid}`);
|
|
3739
3772
|
await this.executeAndRespond(uuid, async () => {
|
|
3740
3773
|
await this.verifyAuth();
|
|
3741
3774
|
this.assertValidTransfer();
|
|
@@ -3837,6 +3870,9 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3837
3870
|
}
|
|
3838
3871
|
this.flow?.set(step);
|
|
3839
3872
|
}
|
|
3873
|
+
if (action === "bootstrap") {
|
|
3874
|
+
return this.provider?.[action](this.diagnostics);
|
|
3875
|
+
}
|
|
3840
3876
|
return this.provider?.[action]();
|
|
3841
3877
|
},
|
|
3842
3878
|
async streamAsset(payload) {
|
|
@@ -3902,6 +3938,7 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3902
3938
|
getStrapi: () => strapi
|
|
3903
3939
|
});
|
|
3904
3940
|
this.provider.onWarning = (message) => {
|
|
3941
|
+
this.onWarning(message);
|
|
3905
3942
|
strapi.log.warn(message);
|
|
3906
3943
|
};
|
|
3907
3944
|
return { transferID: this.transferID };
|
|
@@ -3942,6 +3979,26 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3942
3979
|
this.streams = {};
|
|
3943
3980
|
delete this.provider;
|
|
3944
3981
|
},
|
|
3982
|
+
onInfo(message) {
|
|
3983
|
+
this.diagnostics?.report({
|
|
3984
|
+
details: {
|
|
3985
|
+
message,
|
|
3986
|
+
origin: "pull-handler",
|
|
3987
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
3988
|
+
},
|
|
3989
|
+
kind: "info"
|
|
3990
|
+
});
|
|
3991
|
+
},
|
|
3992
|
+
onWarning(message) {
|
|
3993
|
+
this.diagnostics?.report({
|
|
3994
|
+
details: {
|
|
3995
|
+
message,
|
|
3996
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
3997
|
+
origin: "pull-handler"
|
|
3998
|
+
},
|
|
3999
|
+
kind: "warning"
|
|
4000
|
+
});
|
|
4001
|
+
},
|
|
3945
4002
|
assertValidTransferAction(action) {
|
|
3946
4003
|
const validActions = VALID_TRANSFER_ACTIONS;
|
|
3947
4004
|
if (validActions.includes(action)) {
|
|
@@ -3971,6 +4028,7 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3971
4028
|
proto.addUUID(uuid);
|
|
3972
4029
|
if (type === "command") {
|
|
3973
4030
|
const { command } = msg;
|
|
4031
|
+
this.onInfo(`received command:${command} uuid:${uuid}`);
|
|
3974
4032
|
await this.executeAndRespond(uuid, () => {
|
|
3975
4033
|
this.assertValidTransferCommand(command);
|
|
3976
4034
|
if (command === "status") {
|
|
@@ -3979,6 +4037,7 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3979
4037
|
return this[command](msg.params);
|
|
3980
4038
|
});
|
|
3981
4039
|
} else if (type === "transfer") {
|
|
4040
|
+
this.onInfo(`received transfer action:${msg.action} step:${msg.kind} uuid:${uuid}`);
|
|
3982
4041
|
await this.executeAndRespond(uuid, async () => {
|
|
3983
4042
|
await this.verifyAuth();
|
|
3984
4043
|
this.assertValidTransfer();
|
|
@@ -4000,6 +4059,9 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
4000
4059
|
async onTransferAction(msg) {
|
|
4001
4060
|
const { action } = msg;
|
|
4002
4061
|
this.assertValidTransferAction(action);
|
|
4062
|
+
if (action === "bootstrap") {
|
|
4063
|
+
return this.provider?.[action](this.diagnostics);
|
|
4064
|
+
}
|
|
4003
4065
|
return this.provider?.[action]();
|
|
4004
4066
|
},
|
|
4005
4067
|
async flush(stage, id) {
|
|
@@ -4211,7 +4273,7 @@ class LocalFileSourceProvider {
|
|
|
4211
4273
|
details: {
|
|
4212
4274
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4213
4275
|
message,
|
|
4214
|
-
|
|
4276
|
+
origin: "file-source-provider"
|
|
4215
4277
|
},
|
|
4216
4278
|
kind: "info"
|
|
4217
4279
|
});
|
|
@@ -4302,9 +4364,7 @@ class LocalFileSourceProvider {
|
|
|
4302
4364
|
try {
|
|
4303
4365
|
metadata = await loadAssetMetadata(`assets/metadata/${file}.json`);
|
|
4304
4366
|
} catch (error) {
|
|
4305
|
-
|
|
4306
|
-
` Failed to read metadata for ${file}, Strapi will try to fix this issue automatically`
|
|
4307
|
-
);
|
|
4367
|
+
throw new Error(`Failed to read metadata for ${file}`);
|
|
4308
4368
|
}
|
|
4309
4369
|
const asset = {
|
|
4310
4370
|
metadata,
|
|
@@ -4492,7 +4552,7 @@ class LocalFileDestinationProvider {
|
|
|
4492
4552
|
details: {
|
|
4493
4553
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4494
4554
|
message,
|
|
4495
|
-
|
|
4555
|
+
origin: "file-destination-provider"
|
|
4496
4556
|
},
|
|
4497
4557
|
kind: "info"
|
|
4498
4558
|
});
|