@strapi/data-transfer 4.6.0-beta.1 → 4.6.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist → lib}/engine/index.d.ts +7 -1
- package/{dist → lib}/engine/index.js +74 -18
- package/lib/engine/validation/index.d.ts +1 -0
- package/{dist/providers/shared → lib/engine/validation}/index.js +2 -2
- package/{dist/strategies → lib/engine/validation/schemas}/index.d.ts +2 -2
- package/{dist/strategies → lib/engine/validation/schemas}/index.js +3 -2
- package/lib/file/index.d.ts +1 -0
- package/lib/file/index.js +28 -0
- package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/index.d.ts +6 -6
- package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/index.js +7 -7
- package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/utils.d.ts +0 -0
- package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/utils.js +0 -0
- package/lib/file/providers/index.d.ts +2 -0
- package/{dist → lib/file}/providers/index.js +2 -6
- package/{dist/providers/local-file-source-provider → lib/file/providers/source}/index.d.ts +9 -8
- package/{dist/providers/local-file-source-provider → lib/file/providers/source}/index.js +33 -45
- package/lib/index.d.ts +4 -0
- package/lib/index.js +31 -0
- package/lib/strapi/index.d.ts +4 -0
- package/lib/strapi/index.js +35 -0
- package/lib/strapi/providers/index.d.ts +3 -0
- package/lib/strapi/providers/index.js +22 -0
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/index.d.ts +8 -7
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/index.js +14 -6
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/index.d.ts +0 -0
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/index.js +0 -0
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/configuration.d.ts +1 -1
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/configuration.js +0 -0
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/entities.d.ts +0 -0
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/entities.js +25 -13
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/index.d.ts +0 -0
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/index.js +2 -2
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/links.d.ts +0 -0
- package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/links.js +1 -1
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/assets.d.ts +0 -0
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/assets.js +0 -0
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/configuration.d.ts +0 -0
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/configuration.js +12 -13
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/entities.d.ts +0 -0
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/entities.js +11 -4
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/index.d.ts +6 -6
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/index.js +6 -6
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/links.d.ts +0 -0
- package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/links.js +1 -1
- package/lib/strapi/providers/remote-destination/index.d.ts +40 -0
- package/lib/strapi/providers/remote-destination/index.js +171 -0
- package/lib/strapi/providers/remote-destination/utils.d.ts +31 -0
- package/lib/strapi/providers/remote-destination/utils.js +72 -0
- package/{dist/providers/shared/strapi → lib/strapi/queries}/entity.d.ts +0 -0
- package/{dist/providers/shared/strapi → lib/strapi/queries}/entity.js +0 -0
- package/{dist/providers/shared/strapi → lib/strapi/queries}/index.d.ts +0 -0
- package/{dist/providers/shared/strapi → lib/strapi/queries}/index.js +0 -0
- package/{dist/providers/shared/strapi → lib/strapi/queries}/link.d.ts +1 -1
- package/{dist/providers/shared/strapi → lib/strapi/queries}/link.js +0 -0
- package/lib/strapi/register.d.ts +7 -0
- package/lib/strapi/register.js +13 -0
- package/lib/strapi/remote/constants.d.ts +1 -0
- package/lib/strapi/remote/constants.js +5 -0
- package/lib/strapi/remote/controllers/index.d.ts +1 -0
- package/{dist → lib/strapi/remote/controllers}/index.js +1 -2
- package/lib/strapi/remote/controllers/push.d.ts +25 -0
- package/lib/strapi/remote/controllers/push.js +95 -0
- package/lib/strapi/remote/handlers.d.ts +3 -0
- package/lib/strapi/remote/handlers.js +177 -0
- package/lib/strapi/remote/index.d.ts +3 -0
- package/lib/strapi/remote/index.js +30 -0
- package/lib/strapi/remote/routes.d.ts +21 -0
- package/lib/strapi/remote/routes.js +22 -0
- package/lib/utils/encryption/decrypt.d.ts +11 -0
- package/{dist → lib/utils}/encryption/decrypt.js +8 -0
- package/lib/utils/encryption/encrypt.d.ts +11 -0
- package/{dist → lib/utils}/encryption/encrypt.js +8 -0
- package/{dist → lib/utils}/encryption/index.d.ts +0 -0
- package/{dist → lib/utils}/encryption/index.js +0 -0
- package/{dist → lib}/utils/index.d.ts +1 -0
- package/{dist → lib}/utils/index.js +2 -1
- package/{dist → lib}/utils/json.d.ts +7 -0
- package/{dist → lib}/utils/json.js +8 -1
- package/{dist → lib}/utils/schema.d.ts +4 -0
- package/{dist → lib}/utils/schema.js +9 -2
- package/lib/utils/stream.d.ts +27 -0
- package/lib/utils/stream.js +59 -0
- package/package.json +19 -12
- package/dist/encryption/decrypt.d.ts +0 -3
- package/dist/encryption/encrypt.d.ts +0 -3
- package/dist/index.d.ts +0 -2
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/shared/index.d.ts +0 -1
- package/dist/providers/test-utils/index.d.ts +0 -111
- package/dist/providers/test-utils/index.js +0 -64
- package/dist/utils/stream.d.ts +0 -10
- package/dist/utils/stream.js +0 -39
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PassThrough } from 'stream';
|
|
3
|
-
import type { IDestinationProvider, ISourceProvider, ITransferEngine, ITransferEngineOptions, TransferProgress, ITransferResults, TransferStage } from '../../types';
|
|
3
|
+
import type { IDestinationProvider, ISourceProvider, ITransferEngine, ITransferEngineOptions, TransferProgress, ITransferResults, TransferStage, TransferFilters, TransferFilterPreset } from '../../types';
|
|
4
4
|
export declare const TRANSFER_STAGES: ReadonlyArray<TransferStage>;
|
|
5
|
+
export declare type TransferGroupFilter = Record<TransferFilterPreset, TransferFilters>;
|
|
6
|
+
/**
|
|
7
|
+
* Preset filters for only/exclude options
|
|
8
|
+
* */
|
|
9
|
+
export declare const TransferGroupPresets: TransferGroupFilter;
|
|
5
10
|
export declare const DEFAULT_VERSION_STRATEGY = "ignore";
|
|
6
11
|
export declare const DEFAULT_SCHEMA_STRATEGY = "strict";
|
|
7
12
|
declare class TransferEngine<S extends ISourceProvider = ISourceProvider, D extends IDestinationProvider = IDestinationProvider> implements ITransferEngine {
|
|
@@ -14,6 +19,7 @@ declare class TransferEngine<S extends ISourceProvider = ISourceProvider, D exte
|
|
|
14
19
|
stream: PassThrough;
|
|
15
20
|
};
|
|
16
21
|
constructor(sourceProvider: ISourceProvider, destinationProvider: IDestinationProvider, options: ITransferEngineOptions);
|
|
22
|
+
shouldSkipStage(stage: TransferStage): boolean;
|
|
17
23
|
init(): Promise<void>;
|
|
18
24
|
bootstrap(): Promise<void>;
|
|
19
25
|
close(): Promise<void>;
|
|
@@ -4,17 +4,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
-
};
|
|
10
7
|
var _TransferEngine_instances, _TransferEngine_metadata, _TransferEngine_createStageTransformStream, _TransferEngine_updateTransferProgress, _TransferEngine_progressTracker, _TransferEngine_emitTransferUpdate, _TransferEngine_emitStageUpdate, _TransferEngine_assertStrapiVersionIntegrity, _TransferEngine_assertSchemasMatching, _TransferEngine_transferStage, _TransferEngine_resolveProviderResource;
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createTransferEngine = exports.DEFAULT_SCHEMA_STRATEGY = exports.DEFAULT_VERSION_STRATEGY = exports.TRANSFER_STAGES = void 0;
|
|
9
|
+
exports.createTransferEngine = exports.DEFAULT_SCHEMA_STRATEGY = exports.DEFAULT_VERSION_STRATEGY = exports.TransferGroupPresets = exports.TRANSFER_STAGES = void 0;
|
|
13
10
|
const stream_1 = require("stream");
|
|
14
11
|
const path_1 = require("path");
|
|
15
12
|
const fp_1 = require("lodash/fp");
|
|
16
13
|
const semver_1 = require("semver");
|
|
17
|
-
const
|
|
14
|
+
const schemas_1 = require("./validation/schemas");
|
|
18
15
|
const stream_2 = require("../utils/stream");
|
|
19
16
|
exports.TRANSFER_STAGES = Object.freeze([
|
|
20
17
|
'entities',
|
|
@@ -23,6 +20,31 @@ exports.TRANSFER_STAGES = Object.freeze([
|
|
|
23
20
|
'schemas',
|
|
24
21
|
'configuration',
|
|
25
22
|
]);
|
|
23
|
+
/**
|
|
24
|
+
* Preset filters for only/exclude options
|
|
25
|
+
* */
|
|
26
|
+
exports.TransferGroupPresets = {
|
|
27
|
+
content: {
|
|
28
|
+
links: true,
|
|
29
|
+
entities: true,
|
|
30
|
+
// TODO: If we need to implement filtering on a running stage, it would be done like this, but we still need to implement it
|
|
31
|
+
// [
|
|
32
|
+
// // Example: content processes the entities stage, but filters individual entities
|
|
33
|
+
// {
|
|
34
|
+
// filter(data) {
|
|
35
|
+
// return shouldIncludeThisData(data);
|
|
36
|
+
// },
|
|
37
|
+
// },
|
|
38
|
+
// ],
|
|
39
|
+
},
|
|
40
|
+
files: {
|
|
41
|
+
assets: true,
|
|
42
|
+
links: true,
|
|
43
|
+
},
|
|
44
|
+
config: {
|
|
45
|
+
configuration: true,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
26
48
|
exports.DEFAULT_VERSION_STRATEGY = 'ignore';
|
|
27
49
|
exports.DEFAULT_SCHEMA_STRATEGY = 'strict';
|
|
28
50
|
class TransferEngine {
|
|
@@ -40,6 +62,28 @@ class TransferEngine {
|
|
|
40
62
|
this.options = options;
|
|
41
63
|
this.progress = { data: {}, stream: new stream_1.PassThrough({ objectMode: true }) };
|
|
42
64
|
}
|
|
65
|
+
shouldSkipStage(stage) {
|
|
66
|
+
const { exclude, only } = this.options;
|
|
67
|
+
// schemas must always be included
|
|
68
|
+
if (stage === 'schemas') {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
// everything is included by default unless 'only' has been set
|
|
72
|
+
let included = (0, fp_1.isEmpty)(only);
|
|
73
|
+
if (only?.length > 0) {
|
|
74
|
+
included = only.some((transferGroup) => {
|
|
75
|
+
return exports.TransferGroupPresets[transferGroup][stage];
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (exclude?.length > 0) {
|
|
79
|
+
if (included) {
|
|
80
|
+
included = !exclude.some((transferGroup) => {
|
|
81
|
+
return exports.TransferGroupPresets[transferGroup][stage];
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return !included;
|
|
86
|
+
}
|
|
43
87
|
async init() {
|
|
44
88
|
// Resolve providers' resource and store
|
|
45
89
|
// them in the engine's internal state
|
|
@@ -77,8 +121,8 @@ class TransferEngine {
|
|
|
77
121
|
async transfer() {
|
|
78
122
|
// reset data between transfers
|
|
79
123
|
this.progress.data = {};
|
|
80
|
-
__classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_emitTransferUpdate).call(this, 'start');
|
|
81
124
|
try {
|
|
125
|
+
__classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_emitTransferUpdate).call(this, 'init');
|
|
82
126
|
await this.bootstrap();
|
|
83
127
|
await this.init();
|
|
84
128
|
const isValidTransfer = await this.integrityCheck();
|
|
@@ -86,6 +130,7 @@ class TransferEngine {
|
|
|
86
130
|
// TODO: provide the log from the integrity check
|
|
87
131
|
throw new Error(`Unable to transfer the data between ${this.sourceProvider.name} and ${this.destinationProvider.name}.\nPlease refer to the log above for more information.`);
|
|
88
132
|
}
|
|
133
|
+
__classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_emitTransferUpdate).call(this, 'start');
|
|
89
134
|
await this.beforeTransfer();
|
|
90
135
|
// Run the transfer stages
|
|
91
136
|
await this.transferSchemas();
|
|
@@ -116,32 +161,32 @@ class TransferEngine {
|
|
|
116
161
|
}
|
|
117
162
|
async transferSchemas() {
|
|
118
163
|
const stage = 'schemas';
|
|
119
|
-
const source = await this.sourceProvider.
|
|
120
|
-
const destination = await this.destinationProvider.
|
|
164
|
+
const source = await this.sourceProvider.createSchemasReadStream?.();
|
|
165
|
+
const destination = await this.destinationProvider.createSchemasWriteStream?.();
|
|
121
166
|
const transform = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_createStageTransformStream).call(this, stage);
|
|
122
167
|
const tracker = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_progressTracker).call(this, stage, { key: (value) => value.modelType });
|
|
123
168
|
await __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_transferStage).call(this, { stage, source, destination, transform, tracker });
|
|
124
169
|
}
|
|
125
170
|
async transferEntities() {
|
|
126
171
|
const stage = 'entities';
|
|
127
|
-
const source = await this.sourceProvider.
|
|
128
|
-
const destination = await this.destinationProvider.
|
|
172
|
+
const source = await this.sourceProvider.createEntitiesReadStream?.();
|
|
173
|
+
const destination = await this.destinationProvider.createEntitiesWriteStream?.();
|
|
129
174
|
const transform = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_createStageTransformStream).call(this, stage);
|
|
130
175
|
const tracker = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_progressTracker).call(this, stage, { key: (value) => value.type });
|
|
131
176
|
await __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_transferStage).call(this, { stage, source, destination, transform, tracker });
|
|
132
177
|
}
|
|
133
178
|
async transferLinks() {
|
|
134
179
|
const stage = 'links';
|
|
135
|
-
const source = await this.sourceProvider.
|
|
136
|
-
const destination = await this.destinationProvider.
|
|
180
|
+
const source = await this.sourceProvider.createLinksReadStream?.();
|
|
181
|
+
const destination = await this.destinationProvider.createLinksWriteStream?.();
|
|
137
182
|
const transform = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_createStageTransformStream).call(this, stage);
|
|
138
183
|
const tracker = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_progressTracker).call(this, stage);
|
|
139
184
|
await __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_transferStage).call(this, { stage, source, destination, transform, tracker });
|
|
140
185
|
}
|
|
141
186
|
async transferAssets() {
|
|
142
187
|
const stage = 'assets';
|
|
143
|
-
const source = await this.sourceProvider.
|
|
144
|
-
const destination = await this.destinationProvider.
|
|
188
|
+
const source = await this.sourceProvider.createAssetsReadStream?.();
|
|
189
|
+
const destination = await this.destinationProvider.createAssetsWriteStream?.();
|
|
145
190
|
const transform = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_createStageTransformStream).call(this, stage);
|
|
146
191
|
const tracker = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_progressTracker).call(this, stage, {
|
|
147
192
|
size: (value) => value.stats.size,
|
|
@@ -151,8 +196,8 @@ class TransferEngine {
|
|
|
151
196
|
}
|
|
152
197
|
async transferConfiguration() {
|
|
153
198
|
const stage = 'configuration';
|
|
154
|
-
const source = await this.sourceProvider.
|
|
155
|
-
const destination = await this.destinationProvider.
|
|
199
|
+
const source = await this.sourceProvider.createConfigurationReadStream?.();
|
|
200
|
+
const destination = await this.destinationProvider.createConfigurationWriteStream?.();
|
|
156
201
|
const transform = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_createStageTransformStream).call(this, stage);
|
|
157
202
|
const tracker = __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_progressTracker).call(this, stage);
|
|
158
203
|
await __classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_transferStage).call(this, { stage, source, destination, transform, tracker });
|
|
@@ -258,7 +303,7 @@ _TransferEngine_metadata = new WeakMap(), _TransferEngine_instances = new WeakSe
|
|
|
258
303
|
keys.forEach((key) => {
|
|
259
304
|
const sourceSchema = sourceSchemas[key];
|
|
260
305
|
const destinationSchema = destinationSchemas[key];
|
|
261
|
-
const schemaDiffs = (0,
|
|
306
|
+
const schemaDiffs = (0, schemas_1.compareSchemas)(sourceSchema, destinationSchema, strategy);
|
|
262
307
|
if (schemaDiffs.length) {
|
|
263
308
|
diffs[key] = schemaDiffs;
|
|
264
309
|
}
|
|
@@ -270,7 +315,18 @@ _TransferEngine_metadata = new WeakMap(), _TransferEngine_instances = new WeakSe
|
|
|
270
315
|
}
|
|
271
316
|
}, _TransferEngine_transferStage = async function _TransferEngine_transferStage(options) {
|
|
272
317
|
const { stage, source, destination, transform, tracker } = options;
|
|
273
|
-
if (!source || !destination) {
|
|
318
|
+
if (!source || !destination || this.shouldSkipStage(stage)) {
|
|
319
|
+
// Wait until source and destination are closed
|
|
320
|
+
await Promise.allSettled([source, destination].map((stream) => {
|
|
321
|
+
// if stream is undefined or already closed, resolve immediately
|
|
322
|
+
if (!stream || stream.destroyed) {
|
|
323
|
+
return Promise.resolve();
|
|
324
|
+
}
|
|
325
|
+
// Wait until the close event is produced and then destroy the stream and resolve
|
|
326
|
+
return new Promise((resolve, reject) => {
|
|
327
|
+
stream.on('close', resolve).on('error', reject).destroy();
|
|
328
|
+
});
|
|
329
|
+
}));
|
|
274
330
|
__classPrivateFieldGet(this, _TransferEngine_instances, "m", _TransferEngine_emitStageUpdate).call(this, 'skip', stage);
|
|
275
331
|
return;
|
|
276
332
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as schemas from './schemas';
|
|
@@ -23,6 +23,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
26
|
+
exports.schemas = void 0;
|
|
27
|
+
exports.schemas = __importStar(require("./schemas"));
|
|
28
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Diff } from '
|
|
1
|
+
import type { Diff } from '../../../utils/json';
|
|
2
2
|
declare const strategies: {
|
|
3
3
|
exact(diffs: Diff[]): Diff[];
|
|
4
4
|
strict(diffs: Diff[]): Diff[];
|
|
5
5
|
};
|
|
6
6
|
declare const compareSchemas: <T, P>(a: T, b: P, strategy: keyof typeof strategies) => Diff[];
|
|
7
|
-
export
|
|
7
|
+
export { compareSchemas };
|
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
26
|
+
exports.compareSchemas = void 0;
|
|
27
|
+
const utils = __importStar(require("../../../utils"));
|
|
27
28
|
const strategies = {
|
|
28
29
|
// No diffs
|
|
29
30
|
exact(diffs) {
|
|
@@ -48,5 +49,5 @@ const compareSchemas = (a, b, strategy) => {
|
|
|
48
49
|
const diffs = utils.json.diff(a, b);
|
|
49
50
|
return strategies[strategy](diffs);
|
|
50
51
|
};
|
|
51
|
-
exports.
|
|
52
|
+
exports.compareSchemas = compareSchemas;
|
|
52
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as providers from './providers';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.providers = void 0;
|
|
27
|
+
exports.providers = __importStar(require("./providers"));
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/index.d.ts
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="stream-chain" />
|
|
3
3
|
import zlib from 'zlib';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
|
-
import type { IDestinationProvider, IDestinationProviderTransferResults, IMetadata, ProviderType } from '
|
|
5
|
+
import type { IDestinationProvider, IDestinationProviderTransferResults, IMetadata, ProviderType } from '../../../../types';
|
|
6
6
|
export interface ILocalFileDestinationProviderOptions {
|
|
7
7
|
encryption: {
|
|
8
8
|
enabled: boolean;
|
|
@@ -36,10 +36,10 @@ declare class LocalFileDestinationProvider implements IDestinationProvider {
|
|
|
36
36
|
close(): Promise<void>;
|
|
37
37
|
rollback(): Promise<void>;
|
|
38
38
|
getMetadata(): null;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
createSchemasWriteStream(): import("stream-chain");
|
|
40
|
+
createEntitiesWriteStream(): Writable;
|
|
41
|
+
createLinksWriteStream(): Writable;
|
|
42
|
+
createConfigurationWriteStream(): Writable;
|
|
43
|
+
createAssetsWriteStream(): Writable;
|
|
44
44
|
}
|
|
45
45
|
export {};
|
package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/index.js
RENAMED
|
@@ -17,7 +17,7 @@ const zlib_1 = __importDefault(require("zlib"));
|
|
|
17
17
|
const Stringer_1 = require("stream-json/jsonl/Stringer");
|
|
18
18
|
const stream_chain_1 = require("stream-chain");
|
|
19
19
|
const stream_1 = require("stream");
|
|
20
|
-
const
|
|
20
|
+
const encryption_1 = require("../../../utils/encryption");
|
|
21
21
|
const utils_1 = require("./utils");
|
|
22
22
|
const createLocalFileDestinationProvider = (options) => {
|
|
23
23
|
return new LocalFileDestinationProvider(options);
|
|
@@ -52,7 +52,7 @@ class LocalFileDestinationProvider {
|
|
|
52
52
|
archiveTransforms.push(this.createGzip());
|
|
53
53
|
}
|
|
54
54
|
if (encryption.enabled && encryption.key) {
|
|
55
|
-
archiveTransforms.push((0,
|
|
55
|
+
archiveTransforms.push((0, encryption_1.createEncryptionCipher)(encryption.key));
|
|
56
56
|
}
|
|
57
57
|
__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").pipeline = (0, stream_chain_1.chain)([__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream, ...archiveTransforms, outStream]);
|
|
58
58
|
this.results.file = { path: __classPrivateFieldGet(this, _LocalFileDestinationProvider_instances, "a", _LocalFileDestinationProvider_archivePath_get) };
|
|
@@ -77,7 +77,7 @@ class LocalFileDestinationProvider {
|
|
|
77
77
|
getMetadata() {
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
createSchemasWriteStream() {
|
|
81
81
|
if (!__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream) {
|
|
82
82
|
throw new Error('Archive stream is unavailable');
|
|
83
83
|
}
|
|
@@ -85,7 +85,7 @@ class LocalFileDestinationProvider {
|
|
|
85
85
|
const entryStream = (0, utils_1.createTarEntryStream)(__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream, filePathFactory, this.options.file.maxSizeJsonl);
|
|
86
86
|
return (0, stream_chain_1.chain)([(0, Stringer_1.stringer)(), entryStream]);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
createEntitiesWriteStream() {
|
|
89
89
|
if (!__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream) {
|
|
90
90
|
throw new Error('Archive stream is unavailable');
|
|
91
91
|
}
|
|
@@ -93,7 +93,7 @@ class LocalFileDestinationProvider {
|
|
|
93
93
|
const entryStream = (0, utils_1.createTarEntryStream)(__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream, filePathFactory, this.options.file.maxSizeJsonl);
|
|
94
94
|
return (0, stream_chain_1.chain)([(0, Stringer_1.stringer)(), entryStream]);
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
createLinksWriteStream() {
|
|
97
97
|
if (!__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream) {
|
|
98
98
|
throw new Error('Archive stream is unavailable');
|
|
99
99
|
}
|
|
@@ -101,7 +101,7 @@ class LocalFileDestinationProvider {
|
|
|
101
101
|
const entryStream = (0, utils_1.createTarEntryStream)(__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream, filePathFactory, this.options.file.maxSizeJsonl);
|
|
102
102
|
return (0, stream_chain_1.chain)([(0, Stringer_1.stringer)(), entryStream]);
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
createConfigurationWriteStream() {
|
|
105
105
|
if (!__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream) {
|
|
106
106
|
throw new Error('Archive stream is unavailable');
|
|
107
107
|
}
|
|
@@ -109,7 +109,7 @@ class LocalFileDestinationProvider {
|
|
|
109
109
|
const entryStream = (0, utils_1.createTarEntryStream)(__classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f").stream, filePathFactory, this.options.file.maxSizeJsonl);
|
|
110
110
|
return (0, stream_chain_1.chain)([(0, Stringer_1.stringer)(), entryStream]);
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
createAssetsWriteStream() {
|
|
113
113
|
const { stream: archiveStream } = __classPrivateFieldGet(this, _LocalFileDestinationProvider_archive, "f");
|
|
114
114
|
if (!archiveStream) {
|
|
115
115
|
throw new Error('Archive stream is unavailable');
|
package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/utils.d.ts
RENAMED
|
File without changes
|
package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/utils.js
RENAMED
|
File without changes
|
|
@@ -14,10 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./local-strapi-source-provider"), exports);
|
|
20
|
-
// destination providers
|
|
21
|
-
__exportStar(require("./local-file-destination-provider"), exports);
|
|
22
|
-
__exportStar(require("./local-strapi-destination-provider"), exports);
|
|
17
|
+
__exportStar(require("./source"), exports);
|
|
18
|
+
__exportStar(require("./destination"), exports);
|
|
23
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { Readable } from 'stream';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Schema } from '@strapi/strapi';
|
|
5
|
+
import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
|
|
5
6
|
/**
|
|
6
7
|
* Provider options
|
|
7
8
|
*/
|
|
@@ -25,15 +26,15 @@ declare class LocalFileSourceProvider implements ISourceProvider {
|
|
|
25
26
|
options: ILocalFileSourceProviderOptions;
|
|
26
27
|
constructor(options: ILocalFileSourceProviderOptions);
|
|
27
28
|
/**
|
|
28
|
-
* Pre flight checks regarding the provided options
|
|
29
|
+
* Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
|
|
29
30
|
*/
|
|
30
31
|
bootstrap(): Promise<void>;
|
|
31
32
|
getMetadata(): Promise<IMetadata>;
|
|
32
|
-
getSchemas(): Promise<import("lodash").Dictionary<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
getSchemas(): Promise<import("lodash").Dictionary<Schema>>;
|
|
34
|
+
createEntitiesReadStream(): Readable;
|
|
35
|
+
createSchemasReadStream(): Readable;
|
|
36
|
+
createLinksReadStream(): Readable;
|
|
37
|
+
createConfigurationReadStream(): Readable;
|
|
38
|
+
createAssetsReadStream(): Readable | Promise<Readable>;
|
|
38
39
|
}
|
|
39
40
|
export {};
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
24
7
|
};
|
|
25
8
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
9
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
@@ -30,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
30
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
15
|
};
|
|
33
|
-
var _LocalFileSourceProvider_instances, _LocalFileSourceProvider_getBackupStream, _LocalFileSourceProvider_streamJsonlDirectory, _LocalFileSourceProvider_parseJSONFile;
|
|
16
|
+
var _LocalFileSourceProvider_instances, _LocalFileSourceProvider_metadata, _LocalFileSourceProvider_getBackupStream, _LocalFileSourceProvider_streamJsonlDirectory, _LocalFileSourceProvider_parseJSONFile;
|
|
34
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
18
|
exports.createLocalFileSourceProvider = void 0;
|
|
36
19
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -41,8 +24,8 @@ const fp_1 = require("lodash/fp");
|
|
|
41
24
|
const stream_chain_1 = require("stream-chain");
|
|
42
25
|
const stream_1 = require("stream");
|
|
43
26
|
const Parser_1 = require("stream-json/jsonl/Parser");
|
|
44
|
-
const encryption_1 = require("
|
|
45
|
-
const
|
|
27
|
+
const encryption_1 = require("../../../utils/encryption");
|
|
28
|
+
const stream_2 = require("../../../utils/stream");
|
|
46
29
|
/**
|
|
47
30
|
* Constant for the metadata file path
|
|
48
31
|
*/
|
|
@@ -56,6 +39,7 @@ class LocalFileSourceProvider {
|
|
|
56
39
|
_LocalFileSourceProvider_instances.add(this);
|
|
57
40
|
this.type = 'source';
|
|
58
41
|
this.name = 'source::local-file';
|
|
42
|
+
_LocalFileSourceProvider_metadata.set(this, void 0);
|
|
59
43
|
this.options = options;
|
|
60
44
|
const { encryption } = this.options;
|
|
61
45
|
if (encryption.enabled && encryption.key === undefined) {
|
|
@@ -63,16 +47,16 @@ class LocalFileSourceProvider {
|
|
|
63
47
|
}
|
|
64
48
|
}
|
|
65
49
|
/**
|
|
66
|
-
* Pre flight checks regarding the provided options
|
|
50
|
+
* Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
|
|
67
51
|
*/
|
|
68
52
|
async bootstrap() {
|
|
69
53
|
const { path: filePath } = this.options.file;
|
|
70
54
|
try {
|
|
71
|
-
//
|
|
72
|
-
await
|
|
55
|
+
// Read the metadata to ensure the file can be parsed
|
|
56
|
+
__classPrivateFieldSet(this, _LocalFileSourceProvider_metadata, await this.getMetadata(), "f");
|
|
73
57
|
}
|
|
74
58
|
catch (e) {
|
|
75
|
-
throw new Error(`Can't
|
|
59
|
+
throw new Error(`Can't read file "${filePath}".`);
|
|
76
60
|
}
|
|
77
61
|
}
|
|
78
62
|
getMetadata() {
|
|
@@ -82,23 +66,23 @@ class LocalFileSourceProvider {
|
|
|
82
66
|
return __classPrivateFieldGet(this, _LocalFileSourceProvider_instances, "m", _LocalFileSourceProvider_parseJSONFile).call(this, backupStream, METADATA_FILE_PATH);
|
|
83
67
|
}
|
|
84
68
|
async getSchemas() {
|
|
85
|
-
const schemas = await
|
|
69
|
+
const schemas = await (0, stream_2.collect)(this.createSchemasReadStream());
|
|
86
70
|
return (0, fp_1.keyBy)('uid', schemas);
|
|
87
71
|
}
|
|
88
|
-
|
|
72
|
+
createEntitiesReadStream() {
|
|
89
73
|
return __classPrivateFieldGet(this, _LocalFileSourceProvider_instances, "m", _LocalFileSourceProvider_streamJsonlDirectory).call(this, 'entities');
|
|
90
74
|
}
|
|
91
|
-
|
|
75
|
+
createSchemasReadStream() {
|
|
92
76
|
return __classPrivateFieldGet(this, _LocalFileSourceProvider_instances, "m", _LocalFileSourceProvider_streamJsonlDirectory).call(this, 'schemas');
|
|
93
77
|
}
|
|
94
|
-
|
|
78
|
+
createLinksReadStream() {
|
|
95
79
|
return __classPrivateFieldGet(this, _LocalFileSourceProvider_instances, "m", _LocalFileSourceProvider_streamJsonlDirectory).call(this, 'links');
|
|
96
80
|
}
|
|
97
|
-
|
|
81
|
+
createConfigurationReadStream() {
|
|
98
82
|
// NOTE: TBD
|
|
99
83
|
return __classPrivateFieldGet(this, _LocalFileSourceProvider_instances, "m", _LocalFileSourceProvider_streamJsonlDirectory).call(this, 'configuration');
|
|
100
84
|
}
|
|
101
|
-
|
|
85
|
+
createAssetsReadStream() {
|
|
102
86
|
const inStream = __classPrivateFieldGet(this, _LocalFileSourceProvider_instances, "m", _LocalFileSourceProvider_getBackupStream).call(this);
|
|
103
87
|
const outStream = new stream_1.PassThrough({ objectMode: true });
|
|
104
88
|
(0, stream_1.pipeline)([
|
|
@@ -127,7 +111,7 @@ class LocalFileSourceProvider {
|
|
|
127
111
|
return outStream;
|
|
128
112
|
}
|
|
129
113
|
}
|
|
130
|
-
_LocalFileSourceProvider_instances = new WeakSet(), _LocalFileSourceProvider_getBackupStream = function _LocalFileSourceProvider_getBackupStream() {
|
|
114
|
+
_LocalFileSourceProvider_metadata = new WeakMap(), _LocalFileSourceProvider_instances = new WeakSet(), _LocalFileSourceProvider_getBackupStream = function _LocalFileSourceProvider_getBackupStream() {
|
|
131
115
|
const { file, encryption, compression } = this.options;
|
|
132
116
|
const streams = [];
|
|
133
117
|
try {
|
|
@@ -193,18 +177,22 @@ _LocalFileSourceProvider_instances = new WeakSet(), _LocalFileSourceProvider_get
|
|
|
193
177
|
filter(entryPath, entry) {
|
|
194
178
|
return entryPath === filePath && entry.type === 'File';
|
|
195
179
|
},
|
|
196
|
-
/**
|
|
197
|
-
* Whenever an entry passes the filter method, process it
|
|
198
|
-
*/
|
|
199
180
|
async onentry(entry) {
|
|
200
181
|
// Collect all the content of the entry file
|
|
201
182
|
const content = await entry.collect();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
183
|
+
try {
|
|
184
|
+
// Parse from buffer to string to JSON
|
|
185
|
+
const parsedContent = JSON.parse(content.toString());
|
|
186
|
+
// Resolve the Promise with the parsed content
|
|
187
|
+
resolve(parsedContent);
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
reject(e);
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
// Cleanup (close the stream associated to the entry)
|
|
194
|
+
entry.destroy();
|
|
195
|
+
}
|
|
208
196
|
},
|
|
209
197
|
}),
|
|
210
198
|
], () => {
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.utils = exports.file = exports.strapi = exports.engine = void 0;
|
|
27
|
+
exports.engine = __importStar(require("./engine"));
|
|
28
|
+
exports.strapi = __importStar(require("./strapi"));
|
|
29
|
+
exports.file = __importStar(require("./file"));
|
|
30
|
+
exports.utils = __importStar(require("./utils"));
|
|
31
|
+
//# sourceMappingURL=index.js.map
|