@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
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.register = exports.remote = exports.queries = exports.providers = void 0;
|
|
30
|
+
exports.providers = __importStar(require("./providers"));
|
|
31
|
+
exports.queries = __importStar(require("./queries"));
|
|
32
|
+
exports.remote = __importStar(require("./remote"));
|
|
33
|
+
var register_1 = require("./register");
|
|
34
|
+
Object.defineProperty(exports, "register", { enumerable: true, get: function () { return __importDefault(register_1).default; } });
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Local
|
|
18
|
+
__exportStar(require("./local-destination"), exports);
|
|
19
|
+
__exportStar(require("./local-source"), exports);
|
|
20
|
+
// Remote
|
|
21
|
+
__exportStar(require("./remote-destination"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Writable } from 'stream';
|
|
4
|
-
import type { IDestinationProvider, IMetadata, ProviderType } from '
|
|
4
|
+
import type { IDestinationProvider, IMetadata, ProviderType } from '../../../../types';
|
|
5
5
|
import { restore } from './strategies';
|
|
6
6
|
export declare const VALID_CONFLICT_STRATEGIES: string[];
|
|
7
7
|
export declare const DEFAULT_CONFLICT_STRATEGY = "restore";
|
|
8
|
-
interface ILocalStrapiDestinationProviderOptions {
|
|
8
|
+
export interface ILocalStrapiDestinationProviderOptions {
|
|
9
9
|
getStrapi(): Strapi.Strapi | Promise<Strapi.Strapi>;
|
|
10
|
+
autoDestroy?: boolean;
|
|
10
11
|
restore?: restore.IRestoreOptions;
|
|
11
12
|
strategy: 'restore' | 'merge';
|
|
12
13
|
}
|
|
@@ -20,12 +21,12 @@ declare class LocalStrapiDestinationProvider implements IDestinationProvider {
|
|
|
20
21
|
bootstrap(): Promise<void>;
|
|
21
22
|
close(): Promise<void>;
|
|
22
23
|
beforeTransfer(): Promise<void>;
|
|
23
|
-
getMetadata(): IMetadata
|
|
24
|
+
getMetadata(): IMetadata;
|
|
24
25
|
getSchemas(): import("lodash").Dictionary<Partial<import("@strapi/strapi").Schema>>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
createEntitiesWriteStream(): Writable;
|
|
27
|
+
createAssetsWriteStream(): Promise<Writable>;
|
|
28
|
+
createConfigurationWriteStream(): Promise<Writable>;
|
|
29
|
+
createLinksWriteStream(): Promise<Writable>;
|
|
29
30
|
}
|
|
30
31
|
export declare const createLocalStrapiDestinationProvider: (options: ILocalStrapiDestinationProviderOptions) => LocalStrapiDestinationProvider;
|
|
31
32
|
export {};
|
|
@@ -43,7 +43,7 @@ const stream_1 = require("stream");
|
|
|
43
43
|
const path_1 = __importDefault(require("path"));
|
|
44
44
|
const fse = __importStar(require("fs-extra"));
|
|
45
45
|
const strategies_1 = require("./strategies");
|
|
46
|
-
const utils = __importStar(require("
|
|
46
|
+
const utils = __importStar(require("../../../utils"));
|
|
47
47
|
exports.VALID_CONFLICT_STRATEGIES = ['restore', 'merge'];
|
|
48
48
|
exports.DEFAULT_CONFLICT_STRATEGY = 'restore';
|
|
49
49
|
class LocalStrapiDestinationProvider {
|
|
@@ -51,6 +51,9 @@ class LocalStrapiDestinationProvider {
|
|
|
51
51
|
_LocalStrapiDestinationProvider_instances.add(this);
|
|
52
52
|
this.name = 'destination::local-strapi';
|
|
53
53
|
this.type = 'destination';
|
|
54
|
+
/**
|
|
55
|
+
* The entities mapper is used to map old entities to their new IDs
|
|
56
|
+
*/
|
|
54
57
|
_LocalStrapiDestinationProvider_entitiesMapper.set(this, void 0);
|
|
55
58
|
this.options = options;
|
|
56
59
|
__classPrivateFieldSet(this, _LocalStrapiDestinationProvider_entitiesMapper, {}, "f");
|
|
@@ -60,7 +63,11 @@ class LocalStrapiDestinationProvider {
|
|
|
60
63
|
this.strapi = await this.options.getStrapi();
|
|
61
64
|
}
|
|
62
65
|
async close() {
|
|
63
|
-
|
|
66
|
+
const { autoDestroy } = this.options;
|
|
67
|
+
// Basically `!== false` but more deterministic
|
|
68
|
+
if (autoDestroy === undefined || autoDestroy === true) {
|
|
69
|
+
await this.strapi?.destroy();
|
|
70
|
+
}
|
|
64
71
|
}
|
|
65
72
|
async beforeTransfer() {
|
|
66
73
|
if (this.options.strategy === 'restore') {
|
|
@@ -93,7 +100,7 @@ class LocalStrapiDestinationProvider {
|
|
|
93
100
|
};
|
|
94
101
|
return utils.schema.mapSchemasValues(schemas);
|
|
95
102
|
}
|
|
96
|
-
|
|
103
|
+
createEntitiesWriteStream() {
|
|
97
104
|
if (!this.strapi) {
|
|
98
105
|
throw new Error('Not able to import entities. Strapi instance not found');
|
|
99
106
|
}
|
|
@@ -112,7 +119,8 @@ class LocalStrapiDestinationProvider {
|
|
|
112
119
|
}
|
|
113
120
|
throw new Error(`Invalid strategy supplied: "${strategy}"`);
|
|
114
121
|
}
|
|
115
|
-
|
|
122
|
+
// TODO: Move this logic to the restore strategy
|
|
123
|
+
async createAssetsWriteStream() {
|
|
116
124
|
if (!this.strapi) {
|
|
117
125
|
throw new Error('Not able to stream Assets. Strapi instance not found');
|
|
118
126
|
}
|
|
@@ -148,7 +156,7 @@ class LocalStrapiDestinationProvider {
|
|
|
148
156
|
},
|
|
149
157
|
});
|
|
150
158
|
}
|
|
151
|
-
async
|
|
159
|
+
async createConfigurationWriteStream() {
|
|
152
160
|
if (!this.strapi) {
|
|
153
161
|
throw new Error('Not able to stream Configurations. Strapi instance not found');
|
|
154
162
|
}
|
|
@@ -158,7 +166,7 @@ class LocalStrapiDestinationProvider {
|
|
|
158
166
|
}
|
|
159
167
|
throw new Error(`Invalid strategy supplied: "${strategy}"`);
|
|
160
168
|
}
|
|
161
|
-
async
|
|
169
|
+
async createLinksWriteStream() {
|
|
162
170
|
if (!this.strapi) {
|
|
163
171
|
throw new Error('Not able to stream links. Strapi instance not found');
|
|
164
172
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Writable } from 'stream';
|
|
3
|
-
import { IConfiguration } from '
|
|
3
|
+
import { IConfiguration } from '../../../../../../types';
|
|
4
4
|
export declare const restoreConfigs: (strapi: Strapi.Strapi, config: IConfiguration) => Promise<any>;
|
|
5
5
|
export declare const createConfigurationWriteStream: (strapi: Strapi.Strapi) => Promise<Writable>;
|
|
File without changes
|
|
File without changes
|
|
@@ -26,49 +26,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.createEntitiesWriteStream = void 0;
|
|
27
27
|
const fp_1 = require("lodash/fp");
|
|
28
28
|
const stream_1 = require("stream");
|
|
29
|
-
const utils_1 = require("
|
|
30
|
-
const
|
|
29
|
+
const utils_1 = require("../../../../../utils");
|
|
30
|
+
const queries = __importStar(require("../../../../queries"));
|
|
31
31
|
const createEntitiesWriteStream = (options) => {
|
|
32
32
|
const { strapi, updateMappingTable } = options;
|
|
33
|
-
const query =
|
|
33
|
+
const query = queries.entity.createEntityQuery(strapi);
|
|
34
34
|
return new stream_1.Writable({
|
|
35
35
|
objectMode: true,
|
|
36
36
|
async write(entity, _encoding, callback) {
|
|
37
37
|
const { type, id, data } = entity;
|
|
38
38
|
const { create, getDeepPopulateComponentLikeQuery } = query(type);
|
|
39
39
|
const contentType = strapi.getModel(type);
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the component UID of an entity's attribute based
|
|
42
|
+
* on a given path (components & dynamic zones only)
|
|
43
|
+
*/
|
|
40
44
|
const resolveType = (paths) => {
|
|
41
|
-
let
|
|
45
|
+
let cType = contentType;
|
|
42
46
|
let value = data;
|
|
43
47
|
for (const path of paths) {
|
|
44
48
|
value = (0, fp_1.get)(path, value);
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
// Needed when the value of cType should be computed
|
|
50
|
+
// based on the next value (eg: dynamic zones)
|
|
51
|
+
if (typeof cType === 'function') {
|
|
52
|
+
cType = cType(value);
|
|
47
53
|
}
|
|
48
|
-
if (path in
|
|
49
|
-
const attribute =
|
|
54
|
+
if (path in cType.attributes) {
|
|
55
|
+
const attribute = cType.attributes[path];
|
|
50
56
|
if (attribute.type === 'component') {
|
|
51
|
-
|
|
57
|
+
cType = strapi.getModel(attribute.component);
|
|
52
58
|
}
|
|
53
59
|
if (attribute.type === 'dynamiczone') {
|
|
54
|
-
|
|
60
|
+
cType = ({ __component }) => strapi.getModel(__component);
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
|
-
return
|
|
64
|
+
return cType?.uid;
|
|
59
65
|
};
|
|
60
66
|
try {
|
|
61
|
-
// Create the entity
|
|
62
67
|
const created = await create({
|
|
63
68
|
data,
|
|
64
69
|
populate: getDeepPopulateComponentLikeQuery(contentType, { select: 'id' }),
|
|
65
70
|
select: 'id',
|
|
66
71
|
});
|
|
72
|
+
// Compute differences between original & new entities
|
|
67
73
|
const diffs = utils_1.json.diff(data, created);
|
|
68
74
|
updateMappingTable(type, id, created.id);
|
|
75
|
+
// For each difference found on an ID attribute,
|
|
76
|
+
// update the mapping the table accordingly
|
|
69
77
|
diffs.forEach((diff) => {
|
|
70
|
-
if (diff.kind === 'modified' && diff.path
|
|
78
|
+
if (diff.kind === 'modified' && (0, fp_1.last)(diff.path) === 'id') {
|
|
71
79
|
const target = resolveType(diff.path);
|
|
80
|
+
// If no type is found for the given path, then ignore the diff
|
|
81
|
+
if (!target) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
72
84
|
const [oldID, newID] = diff.values;
|
|
73
85
|
updateMappingTable(target, oldID, newID);
|
|
74
86
|
}
|
|
File without changes
|
|
@@ -27,7 +27,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.deleteRecords = void 0;
|
|
30
|
-
const
|
|
30
|
+
const queries = __importStar(require("../../../../queries"));
|
|
31
31
|
const deleteRecords = async (strapi, options) => {
|
|
32
32
|
const entities = await deleteEntitiesRecord(strapi, options);
|
|
33
33
|
const configuration = await deleteConfigurationRecords(strapi, options);
|
|
@@ -40,7 +40,7 @@ const deleteRecords = async (strapi, options) => {
|
|
|
40
40
|
exports.deleteRecords = deleteRecords;
|
|
41
41
|
const deleteEntitiesRecord = async (strapi, options = {}) => {
|
|
42
42
|
const { entities } = options;
|
|
43
|
-
const query =
|
|
43
|
+
const query = queries.entity.createEntityQuery(strapi);
|
|
44
44
|
const contentTypes = Object.values(strapi.contentTypes);
|
|
45
45
|
const contentTypesToClear = contentTypes.filter((contentType) => {
|
|
46
46
|
let keep = true;
|
|
File without changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLinksWriteStream = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
-
const link_1 = require("
|
|
5
|
+
const link_1 = require("../../../../queries/link");
|
|
6
6
|
const createLinksWriteStream = (mapID, strapi) => {
|
|
7
7
|
return new stream_1.Writable({
|
|
8
8
|
objectMode: true,
|
|
File without changes
|
package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/assets.js
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -8,20 +8,19 @@ const fp_1 = require("lodash/fp");
|
|
|
8
8
|
* Create a readable stream that export the Strapi app configuration
|
|
9
9
|
*/
|
|
10
10
|
const createConfigurationStream = (strapi) => {
|
|
11
|
-
// Core Store
|
|
12
|
-
const coreStoreStream = (0, stream_chain_1.chain)([
|
|
13
|
-
strapi.db.queryBuilder('strapi::core-store').stream(),
|
|
14
|
-
(data) => (0, fp_1.set)('value', JSON.parse(data.value), data),
|
|
15
|
-
wrapConfigurationItem('core-store'),
|
|
16
|
-
]);
|
|
17
|
-
// Webhook
|
|
18
|
-
const webhooksStream = (0, stream_chain_1.chain)([
|
|
19
|
-
strapi.db.queryBuilder('webhook').stream(),
|
|
20
|
-
wrapConfigurationItem('webhook'),
|
|
21
|
-
]);
|
|
22
|
-
const streams = [coreStoreStream, webhooksStream];
|
|
23
|
-
// Readable configuration stream
|
|
24
11
|
return stream_1.Readable.from((async function* configurationGenerator() {
|
|
12
|
+
// Core Store
|
|
13
|
+
const coreStoreStream = (0, stream_chain_1.chain)([
|
|
14
|
+
strapi.db.queryBuilder('strapi::core-store').stream(),
|
|
15
|
+
(data) => (0, fp_1.set)('value', JSON.parse(data.value), data),
|
|
16
|
+
wrapConfigurationItem('core-store'),
|
|
17
|
+
]);
|
|
18
|
+
// Webhook
|
|
19
|
+
const webhooksStream = (0, stream_chain_1.chain)([
|
|
20
|
+
strapi.db.queryBuilder('webhook').stream(),
|
|
21
|
+
wrapConfigurationItem('webhook'),
|
|
22
|
+
]);
|
|
23
|
+
const streams = [coreStoreStream, webhooksStream];
|
|
25
24
|
for (const stream of streams) {
|
|
26
25
|
for await (const item of stream) {
|
|
27
26
|
yield item;
|
|
File without changes
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.createEntitiesTransformStream = exports.createEntitiesStream = void 0;
|
|
27
27
|
const stream_1 = require("stream");
|
|
28
|
-
const shared = __importStar(require("
|
|
28
|
+
const shared = __importStar(require("../../queries"));
|
|
29
29
|
/**
|
|
30
30
|
* Generate and consume content-types streams in order to stream each entity individually
|
|
31
31
|
*/
|
|
@@ -48,10 +48,17 @@ const createEntitiesStream = (strapi) => {
|
|
|
48
48
|
}
|
|
49
49
|
return stream_1.Readable.from((async function* entitiesGenerator() {
|
|
50
50
|
for await (const { stream, contentType } of contentTypeStreamGenerator()) {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
try {
|
|
52
|
+
for await (const entity of stream) {
|
|
53
|
+
yield { entity, contentType };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// ignore
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
stream.destroy();
|
|
53
61
|
}
|
|
54
|
-
stream.destroy();
|
|
55
62
|
}
|
|
56
63
|
})());
|
|
57
64
|
};
|
package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/index.d.ts
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="lodash" />
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
|
-
import type { IMetadata, ISourceProvider, ProviderType } from '
|
|
4
|
+
import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
|
|
5
5
|
export interface ILocalStrapiSourceProviderOptions {
|
|
6
6
|
getStrapi(): Strapi.Strapi | Promise<Strapi.Strapi>;
|
|
7
7
|
autoDestroy?: boolean;
|
|
@@ -16,12 +16,12 @@ declare class LocalStrapiSourceProvider implements ISourceProvider {
|
|
|
16
16
|
bootstrap(): Promise<void>;
|
|
17
17
|
close(): Promise<void>;
|
|
18
18
|
getMetadata(): IMetadata;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
createEntitiesReadStream(): Promise<Readable>;
|
|
20
|
+
createLinksReadStream(): Readable;
|
|
21
|
+
createConfigurationReadStream(): Readable;
|
|
22
22
|
getSchemas(): import("lodash").Dictionary<Partial<import("@strapi/strapi").Schema>>;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
createSchemasReadStream(): Readable;
|
|
24
|
+
createAssetsReadStream(): Readable;
|
|
25
25
|
}
|
|
26
26
|
export declare type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;
|
|
27
27
|
export {};
|
package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/index.js
RENAMED
|
@@ -30,7 +30,7 @@ const entities_1 = require("./entities");
|
|
|
30
30
|
const links_1 = require("./links");
|
|
31
31
|
const configuration_1 = require("./configuration");
|
|
32
32
|
const assets_1 = require("./assets");
|
|
33
|
-
const utils = __importStar(require("
|
|
33
|
+
const utils = __importStar(require("../../../utils"));
|
|
34
34
|
const createLocalStrapiSourceProvider = (options) => {
|
|
35
35
|
return new LocalStrapiSourceProvider(options);
|
|
36
36
|
};
|
|
@@ -67,7 +67,7 @@ class LocalStrapiSourceProvider {
|
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
async
|
|
70
|
+
async createEntitiesReadStream() {
|
|
71
71
|
if (!this.strapi) {
|
|
72
72
|
throw new Error('Not able to stream entities. Strapi instance not found');
|
|
73
73
|
}
|
|
@@ -78,13 +78,13 @@ class LocalStrapiSourceProvider {
|
|
|
78
78
|
(0, entities_1.createEntitiesTransformStream)(),
|
|
79
79
|
]);
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
createLinksReadStream() {
|
|
82
82
|
if (!this.strapi) {
|
|
83
83
|
throw new Error('Not able to stream links. Strapi instance not found');
|
|
84
84
|
}
|
|
85
85
|
return (0, links_1.createLinksStream)(this.strapi);
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
createConfigurationReadStream() {
|
|
88
88
|
if (!this.strapi) {
|
|
89
89
|
throw new Error('Not able to stream configuration. Strapi instance not found');
|
|
90
90
|
}
|
|
@@ -100,10 +100,10 @@ class LocalStrapiSourceProvider {
|
|
|
100
100
|
};
|
|
101
101
|
return utils.schema.mapSchemasValues(schemas);
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
createSchemasReadStream() {
|
|
104
104
|
return stream_1.Readable.from(Object.values(this.getSchemas()));
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
createAssetsReadStream() {
|
|
107
107
|
if (!this.strapi) {
|
|
108
108
|
throw new Error('Not able to stream assets. Strapi instance not found');
|
|
109
109
|
}
|
package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/links.d.ts
RENAMED
|
File without changes
|
package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/links.js
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLinksStream = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
-
const link_1 = require("
|
|
5
|
+
const link_1 = require("../../queries/link");
|
|
6
6
|
/**
|
|
7
7
|
* Create a Readable which will stream all the links from a Strapi instance
|
|
8
8
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { WebSocket } from 'ws';
|
|
3
|
+
import { Writable } from 'stream';
|
|
4
|
+
import { createDispatcher } from './utils';
|
|
5
|
+
import type { IDestinationProvider, IMetadata, ProviderType } from '../../../../types';
|
|
6
|
+
import type { ILocalStrapiDestinationProviderOptions } from '../local-destination';
|
|
7
|
+
interface ITokenAuth {
|
|
8
|
+
type: 'token';
|
|
9
|
+
token: string;
|
|
10
|
+
}
|
|
11
|
+
interface ICredentialsAuth {
|
|
12
|
+
type: 'credentials';
|
|
13
|
+
email: string;
|
|
14
|
+
password: string;
|
|
15
|
+
}
|
|
16
|
+
export interface IRemoteStrapiDestinationProviderOptions extends Pick<ILocalStrapiDestinationProviderOptions, 'restore' | 'strategy'> {
|
|
17
|
+
url: URL;
|
|
18
|
+
auth?: ITokenAuth | ICredentialsAuth;
|
|
19
|
+
}
|
|
20
|
+
declare class RemoteStrapiDestinationProvider implements IDestinationProvider {
|
|
21
|
+
#private;
|
|
22
|
+
name: string;
|
|
23
|
+
type: ProviderType;
|
|
24
|
+
options: IRemoteStrapiDestinationProviderOptions;
|
|
25
|
+
ws: WebSocket | null;
|
|
26
|
+
dispatcher: ReturnType<typeof createDispatcher> | null;
|
|
27
|
+
constructor(options: IRemoteStrapiDestinationProviderOptions);
|
|
28
|
+
initTransfer(): Promise<string>;
|
|
29
|
+
bootstrap(): Promise<void>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
getMetadata(): Promise<IMetadata | null> | null;
|
|
32
|
+
beforeTransfer(): Promise<void>;
|
|
33
|
+
getSchemas(): Promise<Strapi.Schemas | null>;
|
|
34
|
+
createEntitiesWriteStream(): Writable;
|
|
35
|
+
createLinksWriteStream(): Writable;
|
|
36
|
+
createConfigurationWriteStream(): Writable;
|
|
37
|
+
createAssetsWriteStream(): Writable | Promise<Writable>;
|
|
38
|
+
}
|
|
39
|
+
export declare const createRemoteStrapiDestinationProvider: (options: IRemoteStrapiDestinationProviderOptions) => RemoteStrapiDestinationProvider;
|
|
40
|
+
export {};
|