@strapi/data-transfer 4.13.0 → 4.13.1

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.
Files changed (169) hide show
  1. package/dist/engine/diagnostic.d.ts +40 -0
  2. package/dist/engine/diagnostic.js +50 -0
  3. package/dist/engine/diagnostic.js.map +1 -0
  4. package/dist/engine/errors.d.ts +28 -0
  5. package/dist/engine/errors.js +29 -0
  6. package/dist/engine/errors.js.map +1 -0
  7. package/dist/engine/index.d.ts +64 -0
  8. package/dist/engine/index.js +675 -0
  9. package/dist/engine/index.js.map +1 -0
  10. package/dist/engine/validation/index.d.ts +2 -0
  11. package/dist/engine/validation/index.js +19 -0
  12. package/dist/engine/validation/index.js.map +1 -0
  13. package/dist/engine/validation/provider.d.ts +3 -0
  14. package/dist/engine/validation/provider.js +18 -0
  15. package/dist/engine/validation/provider.js.map +1 -0
  16. package/dist/engine/validation/schemas/index.d.ts +7 -0
  17. package/dist/engine/validation/schemas/index.js +70 -0
  18. package/dist/engine/validation/schemas/index.js.map +1 -0
  19. package/dist/errors/base.d.ts +8 -0
  20. package/dist/errors/base.js +13 -0
  21. package/dist/errors/base.js.map +1 -0
  22. package/dist/errors/constants.d.ts +3 -0
  23. package/dist/errors/constants.js +9 -0
  24. package/dist/errors/constants.js.map +1 -0
  25. package/dist/errors/index.d.ts +2 -0
  26. package/dist/errors/index.js +19 -0
  27. package/dist/errors/index.js.map +1 -0
  28. package/dist/errors/providers.d.ts +23 -0
  29. package/dist/errors/providers.js +32 -0
  30. package/dist/errors/providers.js.map +1 -0
  31. package/dist/file/index.d.ts +1 -0
  32. package/dist/file/index.js +28 -0
  33. package/dist/file/index.js.map +1 -0
  34. package/dist/file/providers/destination/index.d.ts +46 -0
  35. package/dist/file/providers/destination/index.js +181 -0
  36. package/dist/file/providers/destination/index.js.map +1 -0
  37. package/dist/file/providers/destination/utils.d.ts +9 -0
  38. package/dist/file/providers/destination/utils.js +62 -0
  39. package/dist/file/providers/destination/utils.js.map +1 -0
  40. package/dist/file/providers/index.d.ts +2 -0
  41. package/dist/file/providers/index.js +19 -0
  42. package/dist/file/providers/index.js.map +1 -0
  43. package/dist/file/providers/source/index.d.ts +40 -0
  44. package/dist/file/providers/source/index.js +242 -0
  45. package/dist/file/providers/source/index.js.map +1 -0
  46. package/dist/file/providers/source/utils.d.ts +37 -0
  47. package/dist/file/providers/source/utils.js +62 -0
  48. package/dist/file/providers/source/utils.js.map +1 -0
  49. package/dist/index.d.ts +4 -0
  50. package/dist/index.js +31 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/strapi/index.d.ts +3 -0
  53. package/dist/strapi/index.js +30 -0
  54. package/dist/strapi/index.js.map +1 -0
  55. package/dist/strapi/providers/index.d.ts +4 -0
  56. package/dist/strapi/providers/index.js +23 -0
  57. package/dist/strapi/providers/index.js.map +1 -0
  58. package/dist/strapi/providers/local-destination/index.d.ts +34 -0
  59. package/dist/strapi/providers/local-destination/index.js +365 -0
  60. package/dist/strapi/providers/local-destination/index.js.map +1 -0
  61. package/dist/strapi/providers/local-destination/strategies/index.d.ts +1 -0
  62. package/dist/strapi/providers/local-destination/strategies/index.js +28 -0
  63. package/dist/strapi/providers/local-destination/strategies/index.js.map +1 -0
  64. package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +5 -0
  65. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +51 -0
  66. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
  67. package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +11 -0
  68. package/dist/strapi/providers/local-destination/strategies/restore/entities.js +103 -0
  69. package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
  70. package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +32 -0
  71. package/dist/strapi/providers/local-destination/strategies/restore/index.js +109 -0
  72. package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
  73. package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +4 -0
  74. package/dist/strapi/providers/local-destination/strategies/restore/links.js +32 -0
  75. package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
  76. package/dist/strapi/providers/local-source/assets.d.ts +5 -0
  77. package/dist/strapi/providers/local-source/assets.js +98 -0
  78. package/dist/strapi/providers/local-source/assets.js.map +1 -0
  79. package/dist/strapi/providers/local-source/configuration.d.ts +5 -0
  80. package/dist/strapi/providers/local-source/configuration.js +36 -0
  81. package/dist/strapi/providers/local-source/configuration.js.map +1 -0
  82. package/dist/strapi/providers/local-source/entities.d.ts +10 -0
  83. package/dist/strapi/providers/local-source/entities.js +85 -0
  84. package/dist/strapi/providers/local-source/entities.js.map +1 -0
  85. package/dist/strapi/providers/local-source/index.d.ts +26 -0
  86. package/dist/strapi/providers/local-source/index.js +98 -0
  87. package/dist/strapi/providers/local-source/index.js.map +1 -0
  88. package/dist/strapi/providers/local-source/links.d.ts +5 -0
  89. package/dist/strapi/providers/local-source/links.js +23 -0
  90. package/dist/strapi/providers/local-source/links.js.map +1 -0
  91. package/dist/strapi/providers/remote-destination/index.d.ts +39 -0
  92. package/dist/strapi/providers/remote-destination/index.js +269 -0
  93. package/dist/strapi/providers/remote-destination/index.js.map +1 -0
  94. package/dist/strapi/providers/remote-source/index.d.ts +39 -0
  95. package/dist/strapi/providers/remote-source/index.js +239 -0
  96. package/dist/strapi/providers/remote-source/index.js.map +1 -0
  97. package/dist/strapi/providers/utils.d.ts +39 -0
  98. package/dist/strapi/providers/utils.js +138 -0
  99. package/dist/strapi/providers/utils.js.map +1 -0
  100. package/dist/strapi/queries/entity.d.ts +2 -0
  101. package/dist/strapi/queries/entity.js +130 -0
  102. package/dist/strapi/queries/entity.js.map +1 -0
  103. package/dist/strapi/queries/index.d.ts +2 -0
  104. package/dist/strapi/queries/index.js +29 -0
  105. package/dist/strapi/queries/index.js.map +1 -0
  106. package/dist/strapi/queries/link.d.ts +7 -0
  107. package/dist/strapi/queries/link.js +215 -0
  108. package/dist/strapi/queries/link.js.map +1 -0
  109. package/dist/strapi/remote/constants.d.ts +4 -0
  110. package/dist/strapi/remote/constants.js +6 -0
  111. package/dist/strapi/remote/constants.js.map +1 -0
  112. package/dist/strapi/remote/flows/default.d.ts +3 -0
  113. package/dist/strapi/remote/flows/default.js +41 -0
  114. package/dist/strapi/remote/flows/default.js.map +1 -0
  115. package/dist/strapi/remote/flows/index.d.ts +18 -0
  116. package/dist/strapi/remote/flows/index.js +59 -0
  117. package/dist/strapi/remote/flows/index.js.map +1 -0
  118. package/dist/strapi/remote/handlers/abstract.d.ts +71 -0
  119. package/dist/strapi/remote/handlers/abstract.js +3 -0
  120. package/dist/strapi/remote/handlers/abstract.js.map +1 -0
  121. package/dist/strapi/remote/handlers/constants.d.ts +2 -0
  122. package/dist/strapi/remote/handlers/constants.js +5 -0
  123. package/dist/strapi/remote/handlers/constants.js.map +1 -0
  124. package/dist/strapi/remote/handlers/index.d.ts +3 -0
  125. package/dist/strapi/remote/handlers/index.js +10 -0
  126. package/dist/strapi/remote/handlers/index.js.map +1 -0
  127. package/dist/strapi/remote/handlers/pull.d.ts +22 -0
  128. package/dist/strapi/remote/handlers/pull.js +243 -0
  129. package/dist/strapi/remote/handlers/pull.js.map +1 -0
  130. package/dist/strapi/remote/handlers/push.d.ts +75 -0
  131. package/dist/strapi/remote/handlers/push.js +311 -0
  132. package/dist/strapi/remote/handlers/push.js.map +1 -0
  133. package/dist/strapi/remote/handlers/utils.d.ts +25 -0
  134. package/dist/strapi/remote/handlers/utils.js +217 -0
  135. package/dist/strapi/remote/handlers/utils.js.map +1 -0
  136. package/dist/strapi/remote/index.d.ts +2 -0
  137. package/dist/strapi/remote/index.js +29 -0
  138. package/dist/strapi/remote/index.js.map +1 -0
  139. package/dist/utils/encryption/decrypt.d.ts +11 -0
  140. package/dist/utils/encryption/decrypt.js +47 -0
  141. package/dist/utils/encryption/decrypt.js.map +1 -0
  142. package/dist/utils/encryption/encrypt.d.ts +11 -0
  143. package/dist/utils/encryption/encrypt.js +47 -0
  144. package/dist/utils/encryption/encrypt.js.map +1 -0
  145. package/dist/utils/encryption/index.d.ts +2 -0
  146. package/dist/utils/encryption/index.js +19 -0
  147. package/dist/utils/encryption/index.js.map +1 -0
  148. package/dist/utils/index.d.ts +6 -0
  149. package/dist/utils/index.js +33 -0
  150. package/dist/utils/index.js.map +1 -0
  151. package/dist/utils/json.d.ts +30 -0
  152. package/dist/utils/json.js +68 -0
  153. package/dist/utils/json.js.map +1 -0
  154. package/dist/utils/middleware.d.ts +2 -0
  155. package/dist/utils/middleware.js +14 -0
  156. package/dist/utils/middleware.js.map +1 -0
  157. package/dist/utils/providers.d.ts +2 -0
  158. package/dist/utils/providers.js +11 -0
  159. package/dist/utils/providers.js.map +1 -0
  160. package/dist/utils/schema.d.ts +6 -0
  161. package/dist/utils/schema.js +29 -0
  162. package/dist/utils/schema.js.map +1 -0
  163. package/dist/utils/stream.d.ts +27 -0
  164. package/dist/utils/stream.js +59 -0
  165. package/dist/utils/stream.js.map +1 -0
  166. package/dist/utils/transaction.d.ts +3 -0
  167. package/dist/utils/transaction.js +88 -0
  168. package/dist/utils/transaction.js.map +1 -0
  169. package/package.json +4 -4
@@ -0,0 +1,365 @@
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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
+ if (kind === "m") throw new TypeError("Private method is not writable");
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
+ 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");
29
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
+ };
31
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
+ 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");
34
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ var _LocalStrapiDestinationProvider_instances, _LocalStrapiDestinationProvider_entitiesMapper, _LocalStrapiDestinationProvider_areAssetsIncluded, _LocalStrapiDestinationProvider_isContentTypeIncluded, _LocalStrapiDestinationProvider_validateOptions, _LocalStrapiDestinationProvider_deleteFromRestoreOptions, _LocalStrapiDestinationProvider_deleteAllAssets, _LocalStrapiDestinationProvider_handleAssetsBackup, _LocalStrapiDestinationProvider_removeAssetsBackup;
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.createLocalStrapiDestinationProvider = exports.DEFAULT_CONFLICT_STRATEGY = exports.VALID_CONFLICT_STRATEGIES = void 0;
42
+ const stream_1 = require("stream");
43
+ const path_1 = __importDefault(require("path"));
44
+ const fse = __importStar(require("fs-extra"));
45
+ const strategies_1 = require("./strategies");
46
+ const utils = __importStar(require("../../../utils"));
47
+ const providers_1 = require("../../../errors/providers");
48
+ const providers_2 = require("../../../utils/providers");
49
+ exports.VALID_CONFLICT_STRATEGIES = ['restore'];
50
+ exports.DEFAULT_CONFLICT_STRATEGY = 'restore';
51
+ class LocalStrapiDestinationProvider {
52
+ constructor(options) {
53
+ _LocalStrapiDestinationProvider_instances.add(this);
54
+ this.name = 'destination::local-strapi';
55
+ this.type = 'destination';
56
+ /**
57
+ * The entities mapper is used to map old entities to their new IDs
58
+ */
59
+ _LocalStrapiDestinationProvider_entitiesMapper.set(this, void 0);
60
+ // TODO: either move this to restore strategy, or restore strategy should given access to these instead of repeating the logic possibly in a different way
61
+ _LocalStrapiDestinationProvider_areAssetsIncluded.set(this, () => {
62
+ return this.options.restore?.assets;
63
+ });
64
+ _LocalStrapiDestinationProvider_isContentTypeIncluded.set(this, (type) => {
65
+ const notIncluded = this.options.restore?.entities?.include &&
66
+ !this.options.restore?.entities?.include?.includes(type);
67
+ const excluded = this.options.restore?.entities?.exclude &&
68
+ this.options.restore?.entities.exclude.includes(type);
69
+ return !excluded && !notIncluded;
70
+ });
71
+ this.options = options;
72
+ __classPrivateFieldSet(this, _LocalStrapiDestinationProvider_entitiesMapper, {}, "f");
73
+ this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;
74
+ }
75
+ async bootstrap() {
76
+ __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_validateOptions).call(this);
77
+ this.strapi = await this.options.getStrapi();
78
+ if (!this.strapi) {
79
+ throw new providers_1.ProviderInitializationError('Could not access local strapi');
80
+ }
81
+ this.transaction = utils.transaction.createTransaction(this.strapi);
82
+ }
83
+ async close() {
84
+ const { autoDestroy } = this.options;
85
+ this.transaction?.end();
86
+ // Basically `!== false` but more deterministic
87
+ if (autoDestroy === undefined || autoDestroy === true) {
88
+ await this.strapi?.destroy();
89
+ }
90
+ }
91
+ async rollback() {
92
+ await this.transaction?.rollback();
93
+ }
94
+ async beforeTransfer() {
95
+ if (!this.strapi) {
96
+ throw new Error('Strapi instance not found');
97
+ }
98
+ await this.transaction?.attach(async (trx) => {
99
+ try {
100
+ if (this.options.strategy === 'restore') {
101
+ await __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_handleAssetsBackup).call(this);
102
+ await __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_deleteAllAssets).call(this, trx);
103
+ await __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_deleteFromRestoreOptions).call(this);
104
+ }
105
+ }
106
+ catch (error) {
107
+ throw new Error(`restore failed ${error}`);
108
+ }
109
+ });
110
+ }
111
+ getMetadata() {
112
+ (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to get Schemas');
113
+ const strapiVersion = this.strapi.config.get('info.strapi');
114
+ const createdAt = new Date().toISOString();
115
+ return {
116
+ createdAt,
117
+ strapi: {
118
+ version: strapiVersion,
119
+ },
120
+ };
121
+ }
122
+ getSchemas() {
123
+ (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to get Schemas');
124
+ const schemas = {
125
+ ...this.strapi.contentTypes,
126
+ ...this.strapi.components,
127
+ };
128
+ return utils.schema.mapSchemasValues(schemas);
129
+ }
130
+ createEntitiesWriteStream() {
131
+ (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to import entities');
132
+ const { strategy } = this.options;
133
+ const updateMappingTable = (type, oldID, newID) => {
134
+ if (!__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type]) {
135
+ __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type] = {};
136
+ }
137
+ Object.assign(__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type], { [oldID]: newID });
138
+ };
139
+ if (strategy === 'restore') {
140
+ return strategies_1.restore.createEntitiesWriteStream({
141
+ strapi: this.strapi,
142
+ updateMappingTable,
143
+ transaction: this.transaction,
144
+ });
145
+ }
146
+ throw new providers_1.ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
147
+ check: 'strategy',
148
+ strategy: this.options.strategy,
149
+ validStrategies: exports.VALID_CONFLICT_STRATEGIES,
150
+ });
151
+ }
152
+ // TODO: Move this logic to the restore strategy
153
+ async createAssetsWriteStream() {
154
+ (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to stream Assets');
155
+ if (!__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_areAssetsIncluded, "f").call(this)) {
156
+ throw new providers_1.ProviderTransferError('Attempting to transfer assets when they are not included');
157
+ }
158
+ const removeAssetsBackup = __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_removeAssetsBackup).bind(this);
159
+ const strapi = this.strapi;
160
+ const transaction = this.transaction;
161
+ const backupDirectory = this.uploadsBackupDirectoryName;
162
+ const restoreMediaEntitiesContent = __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_isContentTypeIncluded, "f").call(this, 'plugin::upload.file');
163
+ return new stream_1.Writable({
164
+ objectMode: true,
165
+ async final(next) {
166
+ // Delete the backup folder
167
+ await removeAssetsBackup();
168
+ next();
169
+ },
170
+ async write(chunk, _encoding, callback) {
171
+ await transaction?.attach(async () => {
172
+ // TODO: Remove this logic in V5
173
+ if (!chunk.metadata) {
174
+ // If metadata does not exist is because it is an old backup file
175
+ const assetsDirectory = path_1.default.join(strapi.dirs.static.public, 'uploads');
176
+ const entryPath = path_1.default.join(assetsDirectory, chunk.filename);
177
+ const writableStream = fse.createWriteStream(entryPath);
178
+ chunk.stream
179
+ .pipe(writableStream)
180
+ .on('close', () => {
181
+ callback(null);
182
+ })
183
+ .on('error', async (error) => {
184
+ const errorMessage = error.code === 'ENOSPC'
185
+ ? " Your server doesn't have space to proceed with the import. "
186
+ : ' ';
187
+ try {
188
+ await fse.rm(assetsDirectory, { recursive: true, force: true });
189
+ this.destroy(new providers_1.ProviderTransferError(`There was an error during the transfer process.${errorMessage}The original files have been restored to ${assetsDirectory}`));
190
+ }
191
+ catch (err) {
192
+ throw new providers_1.ProviderTransferError(`There was an error doing the rollback process. The original files are in ${backupDirectory}, but we failed to restore them to ${assetsDirectory}`);
193
+ }
194
+ finally {
195
+ callback(error);
196
+ }
197
+ });
198
+ return;
199
+ }
200
+ const uploadData = {
201
+ ...chunk.metadata,
202
+ stream: stream_1.Readable.from(chunk.stream),
203
+ buffer: chunk?.buffer,
204
+ };
205
+ const provider = strapi.config.get('plugin.upload').provider;
206
+ try {
207
+ await strapi.plugin('upload').provider.uploadStream(uploadData);
208
+ // if we're not supposed to transfer the associated entities, stop here
209
+ if (!restoreMediaEntitiesContent) {
210
+ return callback();
211
+ }
212
+ // Files formats are stored within the parent file entity
213
+ if (uploadData?.type) {
214
+ const entry = await strapi.db.query('plugin::upload.file').findOne({
215
+ where: { hash: uploadData.mainHash },
216
+ });
217
+ const specificFormat = entry?.formats?.[uploadData.type];
218
+ if (specificFormat) {
219
+ specificFormat.url = uploadData.url;
220
+ }
221
+ await strapi.db.query('plugin::upload.file').update({
222
+ where: { hash: uploadData.mainHash },
223
+ data: {
224
+ formats: entry.formats,
225
+ provider,
226
+ },
227
+ });
228
+ return callback();
229
+ }
230
+ const entry = await strapi.db.query('plugin::upload.file').findOne({
231
+ where: { hash: uploadData.hash },
232
+ });
233
+ entry.url = uploadData.url;
234
+ await strapi.db.query('plugin::upload.file').update({
235
+ where: { hash: uploadData.hash },
236
+ data: {
237
+ url: entry.url,
238
+ provider,
239
+ },
240
+ });
241
+ callback();
242
+ }
243
+ catch (error) {
244
+ callback(new Error(`Error while uploading asset ${chunk.filename} ${error}`));
245
+ }
246
+ });
247
+ },
248
+ });
249
+ }
250
+ async createConfigurationWriteStream() {
251
+ (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to stream Configurations');
252
+ const { strategy } = this.options;
253
+ if (strategy === 'restore') {
254
+ return strategies_1.restore.createConfigurationWriteStream(this.strapi, this.transaction);
255
+ }
256
+ throw new providers_1.ProviderValidationError(`Invalid strategy ${strategy}`, {
257
+ check: 'strategy',
258
+ strategy,
259
+ validStrategies: exports.VALID_CONFLICT_STRATEGIES,
260
+ });
261
+ }
262
+ async createLinksWriteStream() {
263
+ if (!this.strapi) {
264
+ throw new Error('Not able to stream links. Strapi instance not found');
265
+ }
266
+ const { strategy } = this.options;
267
+ const mapID = (uid, id) => __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[uid]?.[id];
268
+ if (strategy === 'restore') {
269
+ return strategies_1.restore.createLinksWriteStream(mapID, this.strapi, this.transaction);
270
+ }
271
+ throw new providers_1.ProviderValidationError(`Invalid strategy ${strategy}`, {
272
+ check: 'strategy',
273
+ strategy,
274
+ validStrategies: exports.VALID_CONFLICT_STRATEGIES,
275
+ });
276
+ }
277
+ }
278
+ _LocalStrapiDestinationProvider_entitiesMapper = new WeakMap(), _LocalStrapiDestinationProvider_areAssetsIncluded = new WeakMap(), _LocalStrapiDestinationProvider_isContentTypeIncluded = new WeakMap(), _LocalStrapiDestinationProvider_instances = new WeakSet(), _LocalStrapiDestinationProvider_validateOptions = function _LocalStrapiDestinationProvider_validateOptions() {
279
+ if (!exports.VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {
280
+ throw new providers_1.ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
281
+ check: 'strategy',
282
+ strategy: this.options.strategy,
283
+ validStrategies: exports.VALID_CONFLICT_STRATEGIES,
284
+ });
285
+ }
286
+ // require restore options when using restore
287
+ if (this.options.strategy === 'restore' && !this.options.restore) {
288
+ throw new providers_1.ProviderValidationError('Missing restore options');
289
+ }
290
+ }, _LocalStrapiDestinationProvider_deleteFromRestoreOptions = async function _LocalStrapiDestinationProvider_deleteFromRestoreOptions() {
291
+ (0, providers_2.assertValidStrapi)(this.strapi);
292
+ if (!this.options.restore) {
293
+ throw new providers_1.ProviderValidationError('Missing restore options');
294
+ }
295
+ return strategies_1.restore.deleteRecords(this.strapi, this.options.restore);
296
+ }, _LocalStrapiDestinationProvider_deleteAllAssets = async function _LocalStrapiDestinationProvider_deleteAllAssets(trx) {
297
+ (0, providers_2.assertValidStrapi)(this.strapi);
298
+ // if we're not restoring files, don't touch the files
299
+ if (!__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_areAssetsIncluded, "f").call(this)) {
300
+ return;
301
+ }
302
+ const stream = this.strapi.db
303
+ // Create a query builder instance (default type is 'select')
304
+ .queryBuilder('plugin::upload.file')
305
+ // Fetch all columns
306
+ .select('*')
307
+ // Attach the transaction
308
+ .transacting(trx)
309
+ // Get a readable stream
310
+ .stream();
311
+ // TODO use bulk delete when exists in providers
312
+ for await (const file of stream) {
313
+ await this.strapi.plugin('upload').provider.delete(file);
314
+ if (file.formats) {
315
+ for (const fileFormat of Object.values(file.formats)) {
316
+ await this.strapi.plugin('upload').provider.delete(fileFormat);
317
+ }
318
+ }
319
+ }
320
+ }, _LocalStrapiDestinationProvider_handleAssetsBackup = async function _LocalStrapiDestinationProvider_handleAssetsBackup() {
321
+ (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to create the assets backup');
322
+ // if we're not restoring assets, don't back them up because they won't be touched
323
+ if (!__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_areAssetsIncluded, "f").call(this)) {
324
+ return;
325
+ }
326
+ if (this.strapi.config.get('plugin.upload').provider === 'local') {
327
+ const assetsDirectory = path_1.default.join(this.strapi.dirs.static.public, 'uploads');
328
+ const backupDirectory = path_1.default.join(this.strapi.dirs.static.public, this.uploadsBackupDirectoryName);
329
+ try {
330
+ // Check access before attempting to do anything
331
+ await fse.access(assetsDirectory,
332
+ // eslint-disable-next-line no-bitwise
333
+ fse.constants.W_OK | fse.constants.R_OK | fse.constants.F_OK);
334
+ // eslint-disable-next-line no-bitwise
335
+ await fse.access(path_1.default.join(assetsDirectory, '..'), fse.constants.W_OK | fse.constants.R_OK);
336
+ await fse.move(assetsDirectory, backupDirectory);
337
+ await fse.mkdir(assetsDirectory);
338
+ // Create a .gitkeep file to ensure the directory is not empty
339
+ await fse.outputFile(path_1.default.join(assetsDirectory, '.gitkeep'), '');
340
+ }
341
+ catch (err) {
342
+ throw new providers_1.ProviderTransferError('The backup folder for the assets could not be created inside the public folder. Please ensure Strapi has write permissions on the public directory', {
343
+ code: 'ASSETS_DIRECTORY_ERR',
344
+ });
345
+ }
346
+ return backupDirectory;
347
+ }
348
+ }, _LocalStrapiDestinationProvider_removeAssetsBackup = async function _LocalStrapiDestinationProvider_removeAssetsBackup() {
349
+ (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to remove Assets');
350
+ // if we're not restoring assets, don't back them up because they won't be touched
351
+ if (!__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_areAssetsIncluded, "f").call(this)) {
352
+ return;
353
+ }
354
+ // TODO: this should catch all thrown errors and bubble it up to engine so it can be reported as a non-fatal diagnostic message telling the user they may need to manually delete assets
355
+ if (this.strapi.config.get('plugin.upload').provider === 'local') {
356
+ (0, providers_2.assertValidStrapi)(this.strapi);
357
+ const backupDirectory = path_1.default.join(this.strapi.dirs.static.public, this.uploadsBackupDirectoryName);
358
+ await fse.rm(backupDirectory, { recursive: true, force: true });
359
+ }
360
+ };
361
+ const createLocalStrapiDestinationProvider = (options) => {
362
+ return new LocalStrapiDestinationProvider(options);
363
+ };
364
+ exports.createLocalStrapiDestinationProvider = createLocalStrapiDestinationProvider;
365
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-destination/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAC5C,gDAAwB;AACxB,8CAAgC;AAWhC,6CAAuC;AACvC,sDAAwC;AACxC,yDAImC;AACnC,wDAA6D;A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MAAM,GAAG,CAAC,EAAE,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;KACjE;AACH,CAAC;AAuJI,MAAM,oCAAoC,GAAG,CAClD,OAA+C,EAC/C,EAAE;IACF,OAAO,IAAI,8BAA8B,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC,CAAC;AAJW,QAAA,oCAAoC,wCAI/C"}
@@ -0,0 +1 @@
1
+ export * as restore from './restore';
@@ -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.restore = void 0;
27
+ exports.restore = __importStar(require("./restore"));
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/strapi/providers/local-destination/strategies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAqC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="node" />
2
+ import { Writable } from 'stream';
3
+ import { IConfiguration, Transaction } from '../../../../../../types';
4
+ export declare const restoreConfigs: (strapi: Strapi.Strapi, config: IConfiguration) => Promise<any>;
5
+ export declare const createConfigurationWriteStream: (strapi: Strapi.Strapi, transaction?: Transaction) => Promise<Writable>;
@@ -0,0 +1,51 @@
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.createConfigurationWriteStream = exports.restoreConfigs = void 0;
7
+ const stream_1 = require("stream");
8
+ const fp_1 = require("lodash/fp");
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const providers_1 = require("../../../../../errors/providers");
11
+ const omitInvalidCreationAttributes = (0, fp_1.omit)(['id']);
12
+ const restoreCoreStore = async (strapi, values) => {
13
+ const data = omitInvalidCreationAttributes(values);
14
+ return strapi.db.query('strapi::core-store').create({
15
+ data: {
16
+ ...data,
17
+ value: JSON.stringify(data.value),
18
+ },
19
+ });
20
+ };
21
+ const restoreWebhooks = async (strapi, values) => {
22
+ const data = omitInvalidCreationAttributes(values);
23
+ return strapi.db.query('webhook').create({ data });
24
+ };
25
+ const restoreConfigs = async (strapi, config) => {
26
+ if (config.type === 'core-store') {
27
+ return restoreCoreStore(strapi, config.value);
28
+ }
29
+ if (config.type === 'webhook') {
30
+ return restoreWebhooks(strapi, config.value);
31
+ }
32
+ };
33
+ exports.restoreConfigs = restoreConfigs;
34
+ const createConfigurationWriteStream = async (strapi, transaction) => {
35
+ return new stream_1.Writable({
36
+ objectMode: true,
37
+ async write(config, _encoding, callback) {
38
+ await transaction?.attach(async () => {
39
+ try {
40
+ await (0, exports.restoreConfigs)(strapi, config);
41
+ }
42
+ catch (error) {
43
+ return callback(new providers_1.ProviderTransferError(`Failed to import ${chalk_1.default.yellowBright(config.type)} (${chalk_1.default.greenBright(config.value.id)}`));
44
+ }
45
+ callback();
46
+ });
47
+ },
48
+ });
49
+ };
50
+ exports.createConfigurationWriteStream = createConfigurationWriteStream;
51
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/configuration.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAkC;AAClC,kCAAiC;AACjC,kDAA0B;AAC1B,+DAAwE;AAGxE,MAAM,6BAA6B,GAAG,IAAA,SAAI,EAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAEnD,MAAM,gBAAgB,GAAG,KAAK,EAAgC,MAAqB,EAAE,MAAS,EAAE,EAAE;IAChG,MAAM,IAAI,GAAG,6BAA6B,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC;QAClD,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;SAClC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,KAAK,EAAgC,MAAqB,EAAE,MAAS,EAAE,EAAE;IAC/F,MAAM,IAAI,GAAG,6BAA6B,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAEK,MAAM,cAAc,GAAG,KAAK,EAAE,MAAqB,EAAE,MAAsB,EAAE,EAAE;IACpF,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE;QAChC,OAAO,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,KAA2B,CAAC,CAAC;KACrE;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE;QAC7B,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,KAA2B,CAAC,CAAC;KACpE;AACH,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB;AAEK,MAAM,8BAA8B,GAAG,KAAK,EACjD,MAAqB,EACrB,WAAyB,EACzB,EAAE;IACF,OAAO,IAAI,iBAAQ,CAAC;QAClB,UAAU,EAAE,IAAI;QAChB,KAAK,CAAC,KAAK,CACT,MAAyB,EACzB,SAAyB,EACzB,QAAwC;YAExC,MAAM,WAAW,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;gBACnC,IAAI;oBACF,MAAM,IAAA,sBAAc,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;iBACtC;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,QAAQ,CACb,IAAI,iCAAqB,CACvB,oBAAoB,eAAK,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,eAAK,CAAC,WAAW,CACvE,MAAM,CAAC,KAAK,CAAC,EAAE,CAChB,EAAE,CACJ,CACF,CAAC;iBACH;gBACD,QAAQ,EAAE,CAAC;YACb,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA3BW,QAAA,8BAA8B,kCA2BzC"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { Writable } from 'stream';
3
+ import type { Common } from '@strapi/strapi';
4
+ import type { Transaction } from '../../../../../../types';
5
+ interface IEntitiesRestoreStreamOptions {
6
+ strapi: Strapi.Strapi;
7
+ updateMappingTable<TSchemaUID extends Common.UID.Schema>(type: TSchemaUID, oldID: number, newID: number): void;
8
+ transaction?: Transaction;
9
+ }
10
+ declare const createEntitiesWriteStream: (options: IEntitiesRestoreStreamOptions) => Writable;
11
+ export { createEntitiesWriteStream };
@@ -0,0 +1,103 @@
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.createEntitiesWriteStream = void 0;
27
+ const stream_1 = require("stream");
28
+ const fp_1 = require("lodash/fp");
29
+ const providers_1 = require("../../../../../errors/providers");
30
+ const utils_1 = require("../../../../../utils");
31
+ const queries = __importStar(require("../../../../queries"));
32
+ const createEntitiesWriteStream = (options) => {
33
+ const { strapi, updateMappingTable, transaction } = options;
34
+ const query = queries.entity.createEntityQuery(strapi);
35
+ return new stream_1.Writable({
36
+ objectMode: true,
37
+ async write(entity, _encoding, callback) {
38
+ await transaction?.attach(async () => {
39
+ const { type, id, data } = entity;
40
+ const { create, getDeepPopulateComponentLikeQuery } = query(type);
41
+ const contentType = strapi.getModel(type);
42
+ /**
43
+ * Resolve the component UID of an entity's attribute based
44
+ * on a given path (components & dynamic zones only)
45
+ */
46
+ const resolveType = (paths) => {
47
+ let cType = contentType;
48
+ let value = data;
49
+ for (const path of paths) {
50
+ value = (0, fp_1.get)(path, value);
51
+ // Needed when the value of cType should be computed
52
+ // based on the next value (eg: dynamic zones)
53
+ if (typeof cType === 'function') {
54
+ cType = cType(value);
55
+ }
56
+ if (path in cType.attributes) {
57
+ const attribute = cType.attributes[path];
58
+ if (attribute.type === 'component') {
59
+ cType = strapi.getModel(attribute.component);
60
+ }
61
+ if (attribute.type === 'dynamiczone') {
62
+ cType = ({ __component }) => strapi.getModel(__component);
63
+ }
64
+ }
65
+ }
66
+ return cType?.uid;
67
+ };
68
+ try {
69
+ const created = await create({
70
+ data,
71
+ populate: getDeepPopulateComponentLikeQuery(contentType, { select: 'id' }),
72
+ select: 'id',
73
+ });
74
+ // Compute differences between original & new entities
75
+ const diffs = utils_1.json.diff(data, created);
76
+ updateMappingTable(type, id, created.id);
77
+ // For each difference found on an ID attribute,
78
+ // update the mapping the table accordingly
79
+ diffs.forEach((diff) => {
80
+ if (diff.kind === 'modified' && (0, fp_1.last)(diff.path) === 'id') {
81
+ const target = resolveType(diff.path);
82
+ // If no type is found for the given path, then ignore the diff
83
+ if (!target) {
84
+ return;
85
+ }
86
+ const [oldID, newID] = diff.values;
87
+ updateMappingTable(target, oldID, newID);
88
+ }
89
+ });
90
+ }
91
+ catch (e) {
92
+ if (e instanceof Error) {
93
+ return callback(e);
94
+ }
95
+ return callback(new providers_1.ProviderTransferError(`Failed to create "${type}" (${id})`));
96
+ }
97
+ return callback(null);
98
+ });
99
+ },
100
+ });
101
+ };
102
+ exports.createEntitiesWriteStream = createEntitiesWriteStream;
103
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAGlC,kCAAsC;AAEtC,+DAAwE;AAExE,gDAA4C;AAC5C,6DAA+C;AAY/C,MAAM,yBAAyB,GAAG,CAAC,OAAsC,EAAE,EAAE;IAC3E,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC5D,MAAM,KA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AC,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEO,8DAAyB"}
@@ -0,0 +1,32 @@
1
+ import type { Schema } from '@strapi/strapi';
2
+ export interface IRestoreOptions {
3
+ assets?: boolean;
4
+ configuration?: {
5
+ webhook?: boolean;
6
+ coreStore?: boolean;
7
+ };
8
+ entities?: {
9
+ include?: string[];
10
+ exclude?: string[];
11
+ filters?: ((contentType: Schema.ContentType) => boolean)[];
12
+ params?: {
13
+ [uid: string]: unknown;
14
+ };
15
+ };
16
+ }
17
+ interface IDeleteResults {
18
+ count: number;
19
+ aggregate: {
20
+ [uid: string]: {
21
+ count: number;
22
+ };
23
+ };
24
+ }
25
+ export declare const deleteRecords: (strapi: Strapi.Strapi, options: IRestoreOptions) => Promise<{
26
+ count: number;
27
+ entities: IDeleteResults;
28
+ configuration: IDeleteResults;
29
+ }>;
30
+ export * from './entities';
31
+ export * from './configuration';
32
+ export * from './links';