@strapi/data-transfer 4.12.2 → 4.13.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/diagnostic.d.ts +40 -0
- package/dist/engine/diagnostic.js +50 -0
- package/dist/engine/diagnostic.js.map +1 -0
- package/dist/engine/errors.d.ts +28 -0
- package/dist/engine/errors.js +29 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/index.d.ts +64 -0
- package/dist/engine/index.js +664 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/validation/index.d.ts +2 -0
- package/dist/engine/validation/index.js +19 -0
- package/dist/engine/validation/index.js.map +1 -0
- package/dist/engine/validation/provider.d.ts +3 -0
- package/dist/engine/validation/provider.js +18 -0
- package/dist/engine/validation/provider.js.map +1 -0
- package/dist/engine/validation/schemas/index.d.ts +7 -0
- package/dist/engine/validation/schemas/index.js +70 -0
- package/dist/engine/validation/schemas/index.js.map +1 -0
- package/dist/errors/base.d.ts +8 -0
- package/dist/errors/base.js +13 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/constants.d.ts +3 -0
- package/dist/errors/constants.js +9 -0
- package/dist/errors/constants.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +19 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/providers.d.ts +23 -0
- package/dist/errors/providers.js +32 -0
- package/dist/errors/providers.js.map +1 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +28 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/providers/destination/index.d.ts +46 -0
- package/dist/file/providers/destination/index.js +181 -0
- package/dist/file/providers/destination/index.js.map +1 -0
- package/dist/file/providers/destination/utils.d.ts +9 -0
- package/dist/file/providers/destination/utils.js +62 -0
- package/dist/file/providers/destination/utils.js.map +1 -0
- package/dist/file/providers/index.d.ts +2 -0
- package/dist/file/providers/index.js +19 -0
- package/dist/file/providers/index.js.map +1 -0
- package/dist/file/providers/source/index.d.ts +40 -0
- package/dist/file/providers/source/index.js +242 -0
- package/dist/file/providers/source/index.js.map +1 -0
- package/dist/file/providers/source/utils.d.ts +37 -0
- package/dist/file/providers/source/utils.js +62 -0
- package/dist/file/providers/source/utils.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/strapi/index.d.ts +3 -0
- package/dist/strapi/index.js +30 -0
- package/dist/strapi/index.js.map +1 -0
- package/dist/strapi/providers/index.d.ts +4 -0
- package/dist/strapi/providers/index.js +23 -0
- package/dist/strapi/providers/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/index.d.ts +34 -0
- package/dist/strapi/providers/local-destination/index.js +321 -0
- package/dist/strapi/providers/local-destination/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/index.d.ts +1 -0
- package/dist/strapi/providers/local-destination/strategies/index.js +28 -0
- package/dist/strapi/providers/local-destination/strategies/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +5 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +51 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +11 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js +103 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +32 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.js +107 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +4 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.js +32 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
- package/dist/strapi/providers/local-source/assets.d.ts +5 -0
- package/dist/strapi/providers/local-source/assets.js +98 -0
- package/dist/strapi/providers/local-source/assets.js.map +1 -0
- package/dist/strapi/providers/local-source/configuration.d.ts +5 -0
- package/dist/strapi/providers/local-source/configuration.js +36 -0
- package/dist/strapi/providers/local-source/configuration.js.map +1 -0
- package/dist/strapi/providers/local-source/entities.d.ts +10 -0
- package/dist/strapi/providers/local-source/entities.js +85 -0
- package/dist/strapi/providers/local-source/entities.js.map +1 -0
- package/dist/strapi/providers/local-source/index.d.ts +26 -0
- package/dist/strapi/providers/local-source/index.js +98 -0
- package/dist/strapi/providers/local-source/index.js.map +1 -0
- package/dist/strapi/providers/local-source/links.d.ts +5 -0
- package/dist/strapi/providers/local-source/links.js +23 -0
- package/dist/strapi/providers/local-source/links.js.map +1 -0
- package/dist/strapi/providers/remote-destination/index.d.ts +39 -0
- package/dist/strapi/providers/remote-destination/index.js +269 -0
- package/dist/strapi/providers/remote-destination/index.js.map +1 -0
- package/dist/strapi/providers/remote-source/index.d.ts +39 -0
- package/dist/strapi/providers/remote-source/index.js +239 -0
- package/dist/strapi/providers/remote-source/index.js.map +1 -0
- package/dist/strapi/providers/utils.d.ts +39 -0
- package/dist/strapi/providers/utils.js +138 -0
- package/dist/strapi/providers/utils.js.map +1 -0
- package/dist/strapi/queries/entity.d.ts +2 -0
- package/dist/strapi/queries/entity.js +130 -0
- package/dist/strapi/queries/entity.js.map +1 -0
- package/dist/strapi/queries/index.d.ts +2 -0
- package/dist/strapi/queries/index.js +29 -0
- package/dist/strapi/queries/index.js.map +1 -0
- package/dist/strapi/queries/link.d.ts +7 -0
- package/dist/strapi/queries/link.js +215 -0
- package/dist/strapi/queries/link.js.map +1 -0
- package/dist/strapi/remote/constants.d.ts +4 -0
- package/dist/strapi/remote/constants.js +6 -0
- package/dist/strapi/remote/constants.js.map +1 -0
- package/dist/strapi/remote/flows/default.d.ts +3 -0
- package/dist/strapi/remote/flows/default.js +41 -0
- package/dist/strapi/remote/flows/default.js.map +1 -0
- package/dist/strapi/remote/flows/index.d.ts +18 -0
- package/dist/strapi/remote/flows/index.js +59 -0
- package/dist/strapi/remote/flows/index.js.map +1 -0
- package/dist/strapi/remote/handlers/abstract.d.ts +71 -0
- package/dist/strapi/remote/handlers/abstract.js +3 -0
- package/dist/strapi/remote/handlers/abstract.js.map +1 -0
- package/dist/strapi/remote/handlers/constants.d.ts +2 -0
- package/dist/strapi/remote/handlers/constants.js +5 -0
- package/dist/strapi/remote/handlers/constants.js.map +1 -0
- package/dist/strapi/remote/handlers/index.d.ts +3 -0
- package/dist/strapi/remote/handlers/index.js +10 -0
- package/dist/strapi/remote/handlers/index.js.map +1 -0
- package/dist/strapi/remote/handlers/pull.d.ts +22 -0
- package/dist/strapi/remote/handlers/pull.js +243 -0
- package/dist/strapi/remote/handlers/pull.js.map +1 -0
- package/dist/strapi/remote/handlers/push.d.ts +75 -0
- package/dist/strapi/remote/handlers/push.js +311 -0
- package/dist/strapi/remote/handlers/push.js.map +1 -0
- package/dist/strapi/remote/handlers/utils.d.ts +25 -0
- package/dist/strapi/remote/handlers/utils.js +217 -0
- package/dist/strapi/remote/handlers/utils.js.map +1 -0
- package/dist/strapi/remote/index.d.ts +2 -0
- package/dist/strapi/remote/index.js +29 -0
- package/dist/strapi/remote/index.js.map +1 -0
- package/dist/utils/encryption/decrypt.d.ts +11 -0
- package/dist/utils/encryption/decrypt.js +47 -0
- package/dist/utils/encryption/decrypt.js.map +1 -0
- package/dist/utils/encryption/encrypt.d.ts +11 -0
- package/dist/utils/encryption/encrypt.js +47 -0
- package/dist/utils/encryption/encrypt.js.map +1 -0
- package/dist/utils/encryption/index.d.ts +2 -0
- package/dist/utils/encryption/index.js +19 -0
- package/dist/utils/encryption/index.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json.d.ts +30 -0
- package/dist/utils/json.js +68 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/middleware.d.ts +2 -0
- package/dist/utils/middleware.js +14 -0
- package/dist/utils/middleware.js.map +1 -0
- package/dist/utils/providers.d.ts +2 -0
- package/dist/utils/providers.js +11 -0
- package/dist/utils/providers.js.map +1 -0
- package/dist/utils/schema.d.ts +6 -0
- package/dist/utils/schema.js +29 -0
- package/dist/utils/schema.js.map +1 -0
- package/dist/utils/stream.d.ts +27 -0
- package/dist/utils/stream.js +59 -0
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/transaction.d.ts +3 -0
- package/dist/utils/transaction.js +88 -0
- package/dist/utils/transaction.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,107 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.deleteRecords = void 0;
|
|
30
|
+
const providers_1 = require("../../../../../errors/providers");
|
|
31
|
+
const queries = __importStar(require("../../../../queries"));
|
|
32
|
+
const deleteRecords = async (strapi, options) => {
|
|
33
|
+
const entities = await deleteEntitiesRecord(strapi, options);
|
|
34
|
+
const configuration = await deleteConfigurationRecords(strapi, options);
|
|
35
|
+
return {
|
|
36
|
+
count: entities.count + configuration.count,
|
|
37
|
+
entities,
|
|
38
|
+
configuration,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.deleteRecords = deleteRecords;
|
|
42
|
+
const deleteEntitiesRecord = async (strapi, options = {}) => {
|
|
43
|
+
const { entities } = options;
|
|
44
|
+
const query = queries.entity.createEntityQuery(strapi);
|
|
45
|
+
const contentTypes = Object.values(strapi.contentTypes);
|
|
46
|
+
const contentTypesToClear = contentTypes.filter((contentType) => {
|
|
47
|
+
let keep = true;
|
|
48
|
+
if (entities?.include) {
|
|
49
|
+
keep = entities.include.includes(contentType.uid);
|
|
50
|
+
}
|
|
51
|
+
if (entities?.exclude) {
|
|
52
|
+
keep = !entities.exclude.includes(contentType.uid);
|
|
53
|
+
}
|
|
54
|
+
if (entities?.filters) {
|
|
55
|
+
keep = entities.filters.every((filter) => filter(contentType));
|
|
56
|
+
}
|
|
57
|
+
return keep;
|
|
58
|
+
});
|
|
59
|
+
const [results, updateResults] = useResults(contentTypesToClear.map((contentType) => contentType.uid));
|
|
60
|
+
const deletePromises = contentTypesToClear.map(async (contentType) => {
|
|
61
|
+
const result = await query(contentType.uid).deleteMany(entities?.params);
|
|
62
|
+
if (result) {
|
|
63
|
+
updateResults(result.count || 0, contentType.uid);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
await Promise.all(deletePromises);
|
|
67
|
+
return results;
|
|
68
|
+
};
|
|
69
|
+
const deleteConfigurationRecords = async (strapi, options = {}) => {
|
|
70
|
+
const { coreStore = true, webhook = true } = options?.configuration ?? {};
|
|
71
|
+
const models = [];
|
|
72
|
+
if (coreStore) {
|
|
73
|
+
models.push('strapi::core-store');
|
|
74
|
+
}
|
|
75
|
+
if (webhook) {
|
|
76
|
+
models.push('webhook');
|
|
77
|
+
}
|
|
78
|
+
const [results, updateResults] = useResults(models);
|
|
79
|
+
const deletePromises = models.map(async (uid) => {
|
|
80
|
+
const result = await strapi.db.query(uid).deleteMany({});
|
|
81
|
+
if (result) {
|
|
82
|
+
updateResults(result.count, uid);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
await Promise.all(deletePromises);
|
|
86
|
+
return results;
|
|
87
|
+
};
|
|
88
|
+
const useResults = (keys) => {
|
|
89
|
+
const results = {
|
|
90
|
+
count: 0,
|
|
91
|
+
aggregate: keys.reduce((acc, key) => ({ ...acc, [key]: { count: 0 } }), {}),
|
|
92
|
+
};
|
|
93
|
+
const update = (count, key) => {
|
|
94
|
+
if (key) {
|
|
95
|
+
if (!(key in results.aggregate)) {
|
|
96
|
+
throw new providers_1.ProviderTransferError(`Unknown key "${key}" provided in results update`);
|
|
97
|
+
}
|
|
98
|
+
results.aggregate[key].count += count;
|
|
99
|
+
}
|
|
100
|
+
results.count += count;
|
|
101
|
+
};
|
|
102
|
+
return [results, update];
|
|
103
|
+
};
|
|
104
|
+
__exportStar(require("./entities"), exports);
|
|
105
|
+
__exportStar(require("./configuration"), exports);
|
|
106
|
+
__exportStar(require("./links"), exports);
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+DAAwE;AACxE,6DAA+C;AAqBxC,MAAM,aAAa,GAAG,KAAK,EAAE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AM,EAAE;YACV,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAClC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CACjB,IAAc,EACmD,EAAE;IACnE,MAAM,OAAO,GAAmB;QAC9B,KAAK,EAAE,CAAC;QACR,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;KAC5E,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,GAAY,EAAE,EAAE;QAC7C,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE;gBAC/B,MAAM,IAAI,iCAAqB,CAAC,gBAAgB,GAAG,8BAA8B,CAAC,CAAC;aACpF;YAED,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC;SACvC;QAED,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,6CAA2B;AAC3B,kDAAgC;AAChC,0CAAwB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import { Transaction } from '../../../../../../types';
|
|
4
|
+
export declare const createLinksWriteStream: (mapID: (uid: string, id: number) => number | undefined, strapi: Strapi.Strapi, transaction?: Transaction) => Writable;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLinksWriteStream = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
const providers_1 = require("../../../../../errors/providers");
|
|
6
|
+
const link_1 = require("../../../../queries/link");
|
|
7
|
+
const createLinksWriteStream = (mapID, strapi, transaction) => {
|
|
8
|
+
return new stream_1.Writable({
|
|
9
|
+
objectMode: true,
|
|
10
|
+
async write(link, _encoding, callback) {
|
|
11
|
+
await transaction?.attach(async (trx) => {
|
|
12
|
+
const { left, right } = link;
|
|
13
|
+
const query = (0, link_1.createLinkQuery)(strapi, trx);
|
|
14
|
+
// Map IDs if needed
|
|
15
|
+
left.ref = mapID(left.type, left.ref) ?? left.ref;
|
|
16
|
+
right.ref = mapID(right.type, right.ref) ?? right.ref;
|
|
17
|
+
try {
|
|
18
|
+
await query().insert(link);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
if (e instanceof Error) {
|
|
22
|
+
return callback(e);
|
|
23
|
+
}
|
|
24
|
+
return callback(new providers_1.ProviderTransferError(`An error happened while trying to import a ${left.type} link.`));
|
|
25
|
+
}
|
|
26
|
+
callback(null);
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.createLinksWriteStream = createLinksWriteStream;
|
|
32
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/links.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAClC,+DAAwE;AAExE,mDAA2D;AAEpD,MAAM,sBAAsB,GAAG,CACpC,KAAsD,EACtD,MAAqB,EACrB,WAAyB,EACzB,EAAE;IACF,OAAO,IAAI,iBAAQ,CAAC;QAClB,UAAU,EAAE,IAAI;QAChB,KAAK,CAAC,KAAK,CAAC,IAAW,EAAE,SAAS,EAAE,QAAQ;YAC1C,MAAM,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBACtC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;gBAC7B,MAAM,KAAK,GAAG,IAAA,sBAAe,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAE3C,oBAAoB;gBACpB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC;gBAClD,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC;gBAEtD,IAAI;oBACF,MAAM,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;iBAC5B;gBAAC,OAAO,CAAC,EAAE;oBACV,IAAI,CAAC,YAAY,KAAK,EAAE;wBACtB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;qBACpB;oBAED,OAAO,QAAQ,CACb,IAAI,iCAAqB,CACvB,8CAA8C,IAAI,CAAC,IAAI,QAAQ,CAChE,CACF,CAAC;iBACH;gBAED,QAAQ,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAlCW,QAAA,sBAAsB,0BAkCjC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createAssetsStream = void 0;
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const https_1 = __importDefault(require("https"));
|
|
9
|
+
const stream_1 = require("stream");
|
|
10
|
+
const fs_extra_1 = require("fs-extra");
|
|
11
|
+
function getFileStream(filepath, isLocal = false) {
|
|
12
|
+
if (isLocal) {
|
|
13
|
+
return (0, fs_extra_1.createReadStream)(filepath);
|
|
14
|
+
}
|
|
15
|
+
const readableStream = new stream_1.PassThrough();
|
|
16
|
+
https_1.default
|
|
17
|
+
.get(filepath, (res) => {
|
|
18
|
+
if (res.statusCode !== 200) {
|
|
19
|
+
readableStream.emit('error', new Error(`Request failed with status code ${res.statusCode}`));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
res.pipe(readableStream);
|
|
23
|
+
})
|
|
24
|
+
.on('error', (error) => {
|
|
25
|
+
readableStream.emit('error', error);
|
|
26
|
+
});
|
|
27
|
+
return readableStream;
|
|
28
|
+
}
|
|
29
|
+
function getFileStats(filepath, isLocal = false) {
|
|
30
|
+
if (isLocal) {
|
|
31
|
+
return (0, fs_extra_1.stat)(filepath);
|
|
32
|
+
}
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
https_1.default
|
|
35
|
+
.get(filepath, (res) => {
|
|
36
|
+
if (res.statusCode !== 200) {
|
|
37
|
+
reject(new Error(`Request failed with status code ${res.statusCode}`));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const contentLength = res.headers['content-length'];
|
|
41
|
+
const stats = {
|
|
42
|
+
size: contentLength ? parseInt(contentLength, 10) : 0,
|
|
43
|
+
};
|
|
44
|
+
resolve(stats);
|
|
45
|
+
})
|
|
46
|
+
.on('error', (error) => {
|
|
47
|
+
reject(error);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generate and consume assets streams in order to stream each file individually
|
|
53
|
+
*/
|
|
54
|
+
const createAssetsStream = (strapi) => {
|
|
55
|
+
const generator = async function* () {
|
|
56
|
+
const stream = strapi.db
|
|
57
|
+
// Create a query builder instance (default type is 'select')
|
|
58
|
+
.queryBuilder('plugin::upload.file')
|
|
59
|
+
// Fetch all columns
|
|
60
|
+
.select('*')
|
|
61
|
+
// Get a readable stream
|
|
62
|
+
.stream();
|
|
63
|
+
for await (const file of stream) {
|
|
64
|
+
const isLocalProvider = file.provider === 'local';
|
|
65
|
+
const filepath = isLocalProvider ? (0, path_1.join)(strapi.dirs.static.public, file.url) : file.url;
|
|
66
|
+
const stats = await getFileStats(filepath, isLocalProvider);
|
|
67
|
+
const stream = getFileStream(filepath, isLocalProvider);
|
|
68
|
+
yield {
|
|
69
|
+
metadata: file,
|
|
70
|
+
filepath,
|
|
71
|
+
filename: file.hash + file.ext,
|
|
72
|
+
stream,
|
|
73
|
+
stats: { size: stats.size },
|
|
74
|
+
};
|
|
75
|
+
if (file.formats) {
|
|
76
|
+
for (const format of Object.keys(file.formats)) {
|
|
77
|
+
const fileFormat = file.formats[format];
|
|
78
|
+
const fileFormatFilepath = isLocalProvider
|
|
79
|
+
? (0, path_1.join)(strapi.dirs.static.public, fileFormat.url)
|
|
80
|
+
: fileFormat.url;
|
|
81
|
+
const fileFormatStats = await getFileStats(fileFormatFilepath, isLocalProvider);
|
|
82
|
+
const fileFormatStream = getFileStream(fileFormatFilepath, isLocalProvider);
|
|
83
|
+
const metadata = { ...fileFormat, type: format, mainHash: file.hash };
|
|
84
|
+
yield {
|
|
85
|
+
metadata,
|
|
86
|
+
filepath: fileFormatFilepath,
|
|
87
|
+
filename: fileFormat.hash + fileFormat.ext,
|
|
88
|
+
stream: fileFormatStream,
|
|
89
|
+
stats: { size: fileFormatStats.size },
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return stream_1.Duplex.from(generator());
|
|
96
|
+
};
|
|
97
|
+
exports.createAssetsStream = createAssetsStream;
|
|
98
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/assets.ts"],"names":[],"mappings":";;;;;;AAAA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B,CAAC;YAEF,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;oBAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACxC,MAAM,kBAAkB,GAAG,eAAe;wBACxC,CAAC,CAAC,IAAA,WAAI,EAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC;wBACjD,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;oBAEnB,MAAM,eAAe,GAAG,MAAM,YAAY,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;oBAChF,MAAM,gBAAgB,GAAG,aAAa,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;oBAC5E,MAAM,QAAQ,GAAG,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;oBACtE,MAAM;wBACJ,QAAQ;wBACR,QAAQ,EAAE,kBAAkB;wBAC5B,QAAQ,EAAE,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG;wBAC1C,MAAM,EAAE,gBAAgB;wBACxB,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE;qBACtC,CAAC;iBACH;aACF;SACF;IACH,CAAC,CAAC;IAEF,OAAO,eAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;AAClC,CAAC,CAAC;AA/CW,QAAA,kBAAkB,sBA+C7B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConfigurationStream = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
const stream_chain_1 = require("stream-chain");
|
|
6
|
+
const fp_1 = require("lodash/fp");
|
|
7
|
+
/**
|
|
8
|
+
* Create a readable stream that export the Strapi app configuration
|
|
9
|
+
*/
|
|
10
|
+
const createConfigurationStream = (strapi) => {
|
|
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];
|
|
24
|
+
for (const stream of streams) {
|
|
25
|
+
for await (const item of stream) {
|
|
26
|
+
yield item;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})());
|
|
30
|
+
};
|
|
31
|
+
exports.createConfigurationStream = createConfigurationStream;
|
|
32
|
+
const wrapConfigurationItem = (type) => (value) => ({
|
|
33
|
+
type,
|
|
34
|
+
value,
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAClC,+CAAqC;AACrC,kCAAgC;AAIhC;;GAEG;AACI,MAAM,yBAAyB,GAAG,CAAC,MAAqB,EAAY,EAAE;IAC3E,OAAO,iBAAQ,CAAC,IAAI,CAClB,CAAC,KAAK,SAAS,CAAC,CAAC,sBAAsB;QACrC,aAAa;QACb,MAAM,eAAe,GAAG,IAAA,oBAAK,EAAC;YAC5B,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE;YACrD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,QAAG,EAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;YACpD,qBAAqB,CAAC,YAAY,CAAC;SACpC,CAAC,CAAC;QAEH,UAAU;QACV,MAAM,cAAc,GAAG,IAAA,oBAAK,EAAC;YAC3B,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE;YAC1C,qBAAqB,CAAC,SAAS,CAAC;SACjC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QAElD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,MAAM,EAAE;gBAC/B,MAAM,IAAI,CAAC;aACZ;SACF;IACH,CAAC,CAAC,EAAE,CACL,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,yBAAyB,6BAyBpC;AAEF,MAAM,qBAAqB,GAAG,CAAC,IAA8B,EAAE,EAAE,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC;IACrF,IAAI;IACJ,KAAK;CACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Readable, Transform } from 'stream';
|
|
2
|
+
/**
|
|
3
|
+
* Generate and consume content-types streams in order to stream each entity individually
|
|
4
|
+
*/
|
|
5
|
+
export declare const createEntitiesStream: (strapi: Strapi.Strapi) => Readable;
|
|
6
|
+
/**
|
|
7
|
+
* Create an entity transform stream which convert the output of
|
|
8
|
+
* the multi-content-types stream to the transfer entity format
|
|
9
|
+
*/
|
|
10
|
+
export declare const createEntitiesTransformStream: () => Transform;
|
|
@@ -0,0 +1,85 @@
|
|
|
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.createEntitiesTransformStream = exports.createEntitiesStream = void 0;
|
|
27
|
+
const stream_1 = require("stream");
|
|
28
|
+
const shared = __importStar(require("../../queries"));
|
|
29
|
+
/**
|
|
30
|
+
* Generate and consume content-types streams in order to stream each entity individually
|
|
31
|
+
*/
|
|
32
|
+
const createEntitiesStream = (strapi) => {
|
|
33
|
+
const contentTypes = Object.values(strapi.contentTypes);
|
|
34
|
+
async function* contentTypeStreamGenerator() {
|
|
35
|
+
for (const contentType of contentTypes) {
|
|
36
|
+
const query = shared.entity.createEntityQuery(strapi).call(null, contentType.uid);
|
|
37
|
+
const stream = strapi.db
|
|
38
|
+
// Create a query builder instance (default type is 'select')
|
|
39
|
+
.queryBuilder(contentType.uid)
|
|
40
|
+
// Fetch all columns
|
|
41
|
+
.select('*')
|
|
42
|
+
// Apply the populate
|
|
43
|
+
.populate(query.deepPopulateComponentLikeQuery)
|
|
44
|
+
// Get a readable stream
|
|
45
|
+
.stream();
|
|
46
|
+
yield { contentType, stream };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return stream_1.Readable.from((async function* entitiesGenerator() {
|
|
50
|
+
for await (const { stream, contentType } of contentTypeStreamGenerator()) {
|
|
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();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})());
|
|
64
|
+
};
|
|
65
|
+
exports.createEntitiesStream = createEntitiesStream;
|
|
66
|
+
/**
|
|
67
|
+
* Create an entity transform stream which convert the output of
|
|
68
|
+
* the multi-content-types stream to the transfer entity format
|
|
69
|
+
*/
|
|
70
|
+
const createEntitiesTransformStream = () => {
|
|
71
|
+
return new stream_1.Transform({
|
|
72
|
+
objectMode: true,
|
|
73
|
+
transform(data, _encoding, callback) {
|
|
74
|
+
const { entity, contentType } = data;
|
|
75
|
+
const { id, ...attributes } = entity;
|
|
76
|
+
callback(null, {
|
|
77
|
+
type: contentType.uid,
|
|
78
|
+
id,
|
|
79
|
+
data: attributes,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
exports.createEntitiesTransformStream = createEntitiesTransformStream;
|
|
85
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA6C;AAG7C,sDAAwC;AA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AU,EAAE,IAAI;QAChB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ;YACjC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;YACrC,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;YAErC,QAAQ,CAAC,IAAI,EAAE;gBACb,IAAI,EAAE,WAAW,CAAC,GAAG;gBACrB,EAAE;gBACF,IAAI,EAAE,UAAU;aACjB,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAdW,QAAA,6BAA6B,iCAcxC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
|
|
4
|
+
export interface ILocalStrapiSourceProviderOptions {
|
|
5
|
+
getStrapi(): Strapi.Strapi | Promise<Strapi.Strapi>;
|
|
6
|
+
autoDestroy?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const createLocalStrapiSourceProvider: (options: ILocalStrapiSourceProviderOptions) => LocalStrapiSourceProvider;
|
|
9
|
+
declare class LocalStrapiSourceProvider implements ISourceProvider {
|
|
10
|
+
name: string;
|
|
11
|
+
type: ProviderType;
|
|
12
|
+
options: ILocalStrapiSourceProviderOptions;
|
|
13
|
+
strapi?: Strapi.Strapi;
|
|
14
|
+
constructor(options: ILocalStrapiSourceProviderOptions);
|
|
15
|
+
bootstrap(): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
getMetadata(): IMetadata;
|
|
18
|
+
createEntitiesReadStream(): Promise<Readable>;
|
|
19
|
+
createLinksReadStream(): Readable;
|
|
20
|
+
createConfigurationReadStream(): Readable;
|
|
21
|
+
getSchemas(): import("@strapi/strapi/lib/types/utils/string").Dict<import("@strapi/strapi/lib/types/core/schemas").Schema>;
|
|
22
|
+
createSchemasReadStream(): Readable;
|
|
23
|
+
createAssetsReadStream(): Readable;
|
|
24
|
+
}
|
|
25
|
+
export type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
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.createLocalStrapiSourceProvider = void 0;
|
|
27
|
+
const stream_1 = require("stream");
|
|
28
|
+
const stream_chain_1 = require("stream-chain");
|
|
29
|
+
const entities_1 = require("./entities");
|
|
30
|
+
const links_1 = require("./links");
|
|
31
|
+
const configuration_1 = require("./configuration");
|
|
32
|
+
const assets_1 = require("./assets");
|
|
33
|
+
const utils = __importStar(require("../../../utils"));
|
|
34
|
+
const providers_1 = require("../../../utils/providers");
|
|
35
|
+
const createLocalStrapiSourceProvider = (options) => {
|
|
36
|
+
return new LocalStrapiSourceProvider(options);
|
|
37
|
+
};
|
|
38
|
+
exports.createLocalStrapiSourceProvider = createLocalStrapiSourceProvider;
|
|
39
|
+
class LocalStrapiSourceProvider {
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.name = 'source::local-strapi';
|
|
42
|
+
this.type = 'source';
|
|
43
|
+
this.options = options;
|
|
44
|
+
}
|
|
45
|
+
async bootstrap() {
|
|
46
|
+
this.strapi = await this.options.getStrapi();
|
|
47
|
+
}
|
|
48
|
+
async close() {
|
|
49
|
+
const { autoDestroy } = this.options;
|
|
50
|
+
// Basically `!== false` but more deterministic
|
|
51
|
+
if (autoDestroy === undefined || autoDestroy === true) {
|
|
52
|
+
await this.strapi?.destroy();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
getMetadata() {
|
|
56
|
+
const strapiVersion = strapi.config.get('info.strapi');
|
|
57
|
+
const createdAt = new Date().toISOString();
|
|
58
|
+
return {
|
|
59
|
+
createdAt,
|
|
60
|
+
strapi: {
|
|
61
|
+
version: strapiVersion,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async createEntitiesReadStream() {
|
|
66
|
+
(0, providers_1.assertValidStrapi)(this.strapi, 'Not able to stream entities');
|
|
67
|
+
return (0, stream_chain_1.chain)([
|
|
68
|
+
// Entities stream
|
|
69
|
+
(0, entities_1.createEntitiesStream)(this.strapi),
|
|
70
|
+
// Transform stream
|
|
71
|
+
(0, entities_1.createEntitiesTransformStream)(),
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
createLinksReadStream() {
|
|
75
|
+
(0, providers_1.assertValidStrapi)(this.strapi, 'Not able to stream links');
|
|
76
|
+
return (0, links_1.createLinksStream)(this.strapi);
|
|
77
|
+
}
|
|
78
|
+
createConfigurationReadStream() {
|
|
79
|
+
(0, providers_1.assertValidStrapi)(this.strapi, 'Not able to stream configuration');
|
|
80
|
+
return (0, configuration_1.createConfigurationStream)(strapi);
|
|
81
|
+
}
|
|
82
|
+
getSchemas() {
|
|
83
|
+
(0, providers_1.assertValidStrapi)(this.strapi, 'Not able to get Schemas');
|
|
84
|
+
const schemas = {
|
|
85
|
+
...this.strapi.contentTypes,
|
|
86
|
+
...this.strapi.components,
|
|
87
|
+
};
|
|
88
|
+
return utils.schema.mapSchemasValues(schemas);
|
|
89
|
+
}
|
|
90
|
+
createSchemasReadStream() {
|
|
91
|
+
return stream_1.Readable.from(Object.values(this.getSchemas()));
|
|
92
|
+
}
|
|
93
|
+
createAssetsReadStream() {
|
|
94
|
+
(0, providers_1.assertValidStrapi)(this.strapi, 'Not able to stream assets');
|
|
95
|
+
return (0, assets_1.createAssetsStream)(this.strapi);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAClC,+CAAqC;AAGrC,yCAAiF;AACjF,mCAA4C;AAC5C,mDAA4D;AAC5D,qCAA8C;AAC9C,sDAAwC;AACxC,wDAA6D;AAQtD,MAAM,+BAA+B,GAAG,CAAC,OAA0C,EAAE,EAAE;IAC5F,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC,CAAC;AAFW,QAAA,+BAA+B,mCAE1C;AAEF,MAAM,yBAAyB;IAS7B,YAAY,OAA0C;QARtD,SAAI,GAAG,sBAAsB,CAAC;QAE9B,SAAI,GAAiB,QAAQ,CAAC;QAO5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,MAAM,GAA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,IAAI,CAAC,MAAM,CAAC,YAAY;YAC3B,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU;SAC1B,CAAC;QAEF,OAAO,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,uBAAuB;QACrB,OAAO,iBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,sBAAsB;QACpB,IAAA,6BAAiB,EAAC,IAAI,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;QAE5D,OAAO,IAAA,2BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLinksStream = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
const link_1 = require("../../queries/link");
|
|
6
|
+
/**
|
|
7
|
+
* Create a Readable which will stream all the links from a Strapi instance
|
|
8
|
+
*/
|
|
9
|
+
const createLinksStream = (strapi) => {
|
|
10
|
+
const uids = [...Object.keys(strapi.contentTypes), ...Object.keys(strapi.components)];
|
|
11
|
+
// Async generator stream that returns every link from a Strapi instance
|
|
12
|
+
return stream_1.Readable.from((async function* linkGenerator() {
|
|
13
|
+
const query = (0, link_1.createLinkQuery)(strapi);
|
|
14
|
+
for (const uid of uids) {
|
|
15
|
+
const generator = query().generateAll(uid);
|
|
16
|
+
for await (const link of generator) {
|
|
17
|
+
yield link;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})());
|
|
21
|
+
};
|
|
22
|
+
exports.createLinksStream = createLinksStream;
|
|
23
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/links.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAGlC,6CAAqD;AAErD;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAAqB,EAAY,EAAE;IACnE,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAa,CAAC;IAElG,wEAAwE;IACxE,OAAO,iBAAQ,CAAC,IAAI,CAClB,CAAC,KAAK,SAAS,CAAC,CAAC,aAAa;QAC5B,MAAM,KAAK,GAAG,IAAA,sBAAe,EAAC,MAAM,CAAC,CAAC;QAEtC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAE3C,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,SAAS,EAAE;gBAClC,MAAM,IAAI,CAAC;aACZ;SACF;IACH,CAAC,CAAC,EAAE,CACL,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,iBAAiB,qBAiB5B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import { WebSocket } from 'ws';
|
|
4
|
+
import type { Schema, Utils } from '@strapi/strapi';
|
|
5
|
+
import { createDispatcher } from '../utils';
|
|
6
|
+
import type { IDestinationProvider, IMetadata, ProviderType } from '../../../../types';
|
|
7
|
+
import type { Auth } from '../../../../types/remote/protocol';
|
|
8
|
+
import type { ILocalStrapiDestinationProviderOptions } from '../local-destination';
|
|
9
|
+
export interface IRemoteStrapiDestinationProviderOptions extends Pick<ILocalStrapiDestinationProviderOptions, 'restore' | 'strategy'> {
|
|
10
|
+
url: URL;
|
|
11
|
+
auth?: Auth.ITransferTokenAuth;
|
|
12
|
+
retryMessageOptions?: {
|
|
13
|
+
retryMessageTimeout: number;
|
|
14
|
+
retryMessageMaxRetries: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
declare class RemoteStrapiDestinationProvider implements IDestinationProvider {
|
|
18
|
+
#private;
|
|
19
|
+
name: string;
|
|
20
|
+
type: ProviderType;
|
|
21
|
+
options: IRemoteStrapiDestinationProviderOptions;
|
|
22
|
+
ws: WebSocket | null;
|
|
23
|
+
dispatcher: ReturnType<typeof createDispatcher> | null;
|
|
24
|
+
transferID: string | null;
|
|
25
|
+
constructor(options: IRemoteStrapiDestinationProviderOptions);
|
|
26
|
+
initTransfer(): Promise<string>;
|
|
27
|
+
bootstrap(): Promise<void>;
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
getMetadata(): Promise<IMetadata | null> | null;
|
|
30
|
+
beforeTransfer(): Promise<void>;
|
|
31
|
+
rollback(): Promise<void>;
|
|
32
|
+
getSchemas(): Promise<Utils.String.Dict<Schema.Schema> | null>;
|
|
33
|
+
createEntitiesWriteStream(): Writable;
|
|
34
|
+
createLinksWriteStream(): Writable;
|
|
35
|
+
createConfigurationWriteStream(): Writable;
|
|
36
|
+
createAssetsWriteStream(): Writable | Promise<Writable>;
|
|
37
|
+
}
|
|
38
|
+
export declare const createRemoteStrapiDestinationProvider: (options: IRemoteStrapiDestinationProviderOptions) => RemoteStrapiDestinationProvider;
|
|
39
|
+
export {};
|