@strapi/data-transfer 4.11.4 → 4.11.6

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/package.json +7 -7
  2. package/dist/engine/diagnostic.d.ts +0 -40
  3. package/dist/engine/diagnostic.js +0 -50
  4. package/dist/engine/diagnostic.js.map +0 -1
  5. package/dist/engine/errors.d.ts +0 -28
  6. package/dist/engine/errors.js +0 -29
  7. package/dist/engine/errors.js.map +0 -1
  8. package/dist/engine/index.d.ts +0 -62
  9. package/dist/engine/index.js +0 -644
  10. package/dist/engine/index.js.map +0 -1
  11. package/dist/engine/validation/index.d.ts +0 -2
  12. package/dist/engine/validation/index.js +0 -19
  13. package/dist/engine/validation/index.js.map +0 -1
  14. package/dist/engine/validation/provider.d.ts +0 -3
  15. package/dist/engine/validation/provider.js +0 -18
  16. package/dist/engine/validation/provider.js.map +0 -1
  17. package/dist/engine/validation/schemas/index.d.ts +0 -7
  18. package/dist/engine/validation/schemas/index.js +0 -70
  19. package/dist/engine/validation/schemas/index.js.map +0 -1
  20. package/dist/errors/base.d.ts +0 -8
  21. package/dist/errors/base.js +0 -13
  22. package/dist/errors/base.js.map +0 -1
  23. package/dist/errors/constants.d.ts +0 -3
  24. package/dist/errors/constants.js +0 -9
  25. package/dist/errors/constants.js.map +0 -1
  26. package/dist/errors/index.d.ts +0 -2
  27. package/dist/errors/index.js +0 -19
  28. package/dist/errors/index.js.map +0 -1
  29. package/dist/errors/providers.d.ts +0 -21
  30. package/dist/errors/providers.js +0 -32
  31. package/dist/errors/providers.js.map +0 -1
  32. package/dist/file/index.d.ts +0 -1
  33. package/dist/file/index.js +0 -28
  34. package/dist/file/index.js.map +0 -1
  35. package/dist/file/providers/destination/index.d.ts +0 -46
  36. package/dist/file/providers/destination/index.js +0 -175
  37. package/dist/file/providers/destination/index.js.map +0 -1
  38. package/dist/file/providers/destination/utils.d.ts +0 -9
  39. package/dist/file/providers/destination/utils.js +0 -62
  40. package/dist/file/providers/destination/utils.js.map +0 -1
  41. package/dist/file/providers/index.d.ts +0 -2
  42. package/dist/file/providers/index.js +0 -19
  43. package/dist/file/providers/index.js.map +0 -1
  44. package/dist/file/providers/source/index.d.ts +0 -40
  45. package/dist/file/providers/source/index.js +0 -230
  46. package/dist/file/providers/source/index.js.map +0 -1
  47. package/dist/file/providers/source/utils.d.ts +0 -37
  48. package/dist/file/providers/source/utils.js +0 -62
  49. package/dist/file/providers/source/utils.js.map +0 -1
  50. package/dist/index.d.ts +0 -4
  51. package/dist/index.js +0 -31
  52. package/dist/index.js.map +0 -1
  53. package/dist/strapi/index.d.ts +0 -3
  54. package/dist/strapi/index.js +0 -30
  55. package/dist/strapi/index.js.map +0 -1
  56. package/dist/strapi/providers/index.d.ts +0 -4
  57. package/dist/strapi/providers/index.js +0 -23
  58. package/dist/strapi/providers/index.js.map +0 -1
  59. package/dist/strapi/providers/local-destination/index.d.ts +0 -33
  60. package/dist/strapi/providers/local-destination/index.js +0 -225
  61. package/dist/strapi/providers/local-destination/index.js.map +0 -1
  62. package/dist/strapi/providers/local-destination/strategies/index.d.ts +0 -1
  63. package/dist/strapi/providers/local-destination/strategies/index.js +0 -28
  64. package/dist/strapi/providers/local-destination/strategies/index.js.map +0 -1
  65. package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +0 -5
  66. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +0 -51
  67. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +0 -1
  68. package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +0 -11
  69. package/dist/strapi/providers/local-destination/strategies/restore/entities.js +0 -103
  70. package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +0 -1
  71. package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +0 -32
  72. package/dist/strapi/providers/local-destination/strategies/restore/index.js +0 -107
  73. package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +0 -1
  74. package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +0 -4
  75. package/dist/strapi/providers/local-destination/strategies/restore/links.js +0 -32
  76. package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +0 -1
  77. package/dist/strapi/providers/local-source/assets.d.ts +0 -5
  78. package/dist/strapi/providers/local-source/assets.js +0 -31
  79. package/dist/strapi/providers/local-source/assets.js.map +0 -1
  80. package/dist/strapi/providers/local-source/configuration.d.ts +0 -5
  81. package/dist/strapi/providers/local-source/configuration.js +0 -36
  82. package/dist/strapi/providers/local-source/configuration.js.map +0 -1
  83. package/dist/strapi/providers/local-source/entities.d.ts +0 -10
  84. package/dist/strapi/providers/local-source/entities.js +0 -85
  85. package/dist/strapi/providers/local-source/entities.js.map +0 -1
  86. package/dist/strapi/providers/local-source/index.d.ts +0 -26
  87. package/dist/strapi/providers/local-source/index.js +0 -98
  88. package/dist/strapi/providers/local-source/index.js.map +0 -1
  89. package/dist/strapi/providers/local-source/links.d.ts +0 -5
  90. package/dist/strapi/providers/local-source/links.js +0 -23
  91. package/dist/strapi/providers/local-source/links.js.map +0 -1
  92. package/dist/strapi/providers/remote-destination/index.d.ts +0 -39
  93. package/dist/strapi/providers/remote-destination/index.js +0 -269
  94. package/dist/strapi/providers/remote-destination/index.js.map +0 -1
  95. package/dist/strapi/providers/remote-source/index.d.ts +0 -39
  96. package/dist/strapi/providers/remote-source/index.js +0 -239
  97. package/dist/strapi/providers/remote-source/index.js.map +0 -1
  98. package/dist/strapi/providers/utils.d.ts +0 -39
  99. package/dist/strapi/providers/utils.js +0 -125
  100. package/dist/strapi/providers/utils.js.map +0 -1
  101. package/dist/strapi/queries/entity.d.ts +0 -20
  102. package/dist/strapi/queries/entity.js +0 -130
  103. package/dist/strapi/queries/entity.js.map +0 -1
  104. package/dist/strapi/queries/index.d.ts +0 -2
  105. package/dist/strapi/queries/index.js +0 -29
  106. package/dist/strapi/queries/index.js.map +0 -1
  107. package/dist/strapi/queries/link.d.ts +0 -7
  108. package/dist/strapi/queries/link.js +0 -215
  109. package/dist/strapi/queries/link.js.map +0 -1
  110. package/dist/strapi/remote/constants.d.ts +0 -4
  111. package/dist/strapi/remote/constants.js +0 -6
  112. package/dist/strapi/remote/constants.js.map +0 -1
  113. package/dist/strapi/remote/flows/default.d.ts +0 -3
  114. package/dist/strapi/remote/flows/default.js +0 -41
  115. package/dist/strapi/remote/flows/default.js.map +0 -1
  116. package/dist/strapi/remote/flows/index.d.ts +0 -18
  117. package/dist/strapi/remote/flows/index.js +0 -59
  118. package/dist/strapi/remote/flows/index.js.map +0 -1
  119. package/dist/strapi/remote/handlers/abstract.d.ts +0 -71
  120. package/dist/strapi/remote/handlers/abstract.js +0 -3
  121. package/dist/strapi/remote/handlers/abstract.js.map +0 -1
  122. package/dist/strapi/remote/handlers/constants.d.ts +0 -2
  123. package/dist/strapi/remote/handlers/constants.js +0 -5
  124. package/dist/strapi/remote/handlers/constants.js.map +0 -1
  125. package/dist/strapi/remote/handlers/index.d.ts +0 -3
  126. package/dist/strapi/remote/handlers/index.js +0 -10
  127. package/dist/strapi/remote/handlers/index.js.map +0 -1
  128. package/dist/strapi/remote/handlers/pull.d.ts +0 -22
  129. package/dist/strapi/remote/handlers/pull.js +0 -243
  130. package/dist/strapi/remote/handlers/pull.js.map +0 -1
  131. package/dist/strapi/remote/handlers/push.d.ts +0 -75
  132. package/dist/strapi/remote/handlers/push.js +0 -305
  133. package/dist/strapi/remote/handlers/push.js.map +0 -1
  134. package/dist/strapi/remote/handlers/utils.d.ts +0 -25
  135. package/dist/strapi/remote/handlers/utils.js +0 -200
  136. package/dist/strapi/remote/handlers/utils.js.map +0 -1
  137. package/dist/strapi/remote/index.d.ts +0 -2
  138. package/dist/strapi/remote/index.js +0 -29
  139. package/dist/strapi/remote/index.js.map +0 -1
  140. package/dist/utils/encryption/decrypt.d.ts +0 -11
  141. package/dist/utils/encryption/decrypt.js +0 -47
  142. package/dist/utils/encryption/decrypt.js.map +0 -1
  143. package/dist/utils/encryption/encrypt.d.ts +0 -11
  144. package/dist/utils/encryption/encrypt.js +0 -47
  145. package/dist/utils/encryption/encrypt.js.map +0 -1
  146. package/dist/utils/encryption/index.d.ts +0 -2
  147. package/dist/utils/encryption/index.js +0 -19
  148. package/dist/utils/encryption/index.js.map +0 -1
  149. package/dist/utils/index.d.ts +0 -6
  150. package/dist/utils/index.js +0 -33
  151. package/dist/utils/index.js.map +0 -1
  152. package/dist/utils/json.d.ts +0 -30
  153. package/dist/utils/json.js +0 -68
  154. package/dist/utils/json.js.map +0 -1
  155. package/dist/utils/middleware.d.ts +0 -2
  156. package/dist/utils/middleware.js +0 -14
  157. package/dist/utils/middleware.js.map +0 -1
  158. package/dist/utils/providers.d.ts +0 -2
  159. package/dist/utils/providers.js +0 -11
  160. package/dist/utils/providers.js.map +0 -1
  161. package/dist/utils/schema.d.ts +0 -6
  162. package/dist/utils/schema.js +0 -29
  163. package/dist/utils/schema.js.map +0 -1
  164. package/dist/utils/stream.d.ts +0 -27
  165. package/dist/utils/stream.js +0 -59
  166. package/dist/utils/stream.js.map +0 -1
  167. package/dist/utils/transaction.d.ts +0 -3
  168. package/dist/utils/transaction.js +0 -88
  169. package/dist/utils/transaction.js.map +0 -1
@@ -1,225 +0,0 @@
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_validateOptions, _LocalStrapiDestinationProvider_deleteAll;
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', 'merge'];
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
- this.options = options;
61
- __classPrivateFieldSet(this, _LocalStrapiDestinationProvider_entitiesMapper, {}, "f");
62
- }
63
- async bootstrap() {
64
- __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_validateOptions).call(this);
65
- this.strapi = await this.options.getStrapi();
66
- this.transaction = utils.transaction.createTransaction(this.strapi);
67
- }
68
- async close() {
69
- const { autoDestroy } = this.options;
70
- this.transaction?.end();
71
- // Basically `!== false` but more deterministic
72
- if (autoDestroy === undefined || autoDestroy === true) {
73
- await this.strapi?.destroy();
74
- }
75
- }
76
- async rollback() {
77
- await this.transaction?.rollback();
78
- }
79
- async beforeTransfer() {
80
- if (!this.strapi) {
81
- throw new Error('Strapi instance not found');
82
- }
83
- await this.transaction?.attach(async () => {
84
- try {
85
- if (this.options.strategy === 'restore') {
86
- await __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_deleteAll).call(this);
87
- }
88
- }
89
- catch (error) {
90
- throw new Error(`restore failed ${error}`);
91
- }
92
- });
93
- }
94
- getMetadata() {
95
- const strapiVersion = strapi.config.get('info.strapi');
96
- const createdAt = new Date().toISOString();
97
- return {
98
- createdAt,
99
- strapi: {
100
- version: strapiVersion,
101
- },
102
- };
103
- }
104
- getSchemas() {
105
- (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to get Schemas');
106
- const schemas = {
107
- ...this.strapi.contentTypes,
108
- ...this.strapi.components,
109
- };
110
- return utils.schema.mapSchemasValues(schemas);
111
- }
112
- createEntitiesWriteStream() {
113
- (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to import entities');
114
- const { strategy } = this.options;
115
- const updateMappingTable = (type, oldID, newID) => {
116
- if (!__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type]) {
117
- __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type] = {};
118
- }
119
- Object.assign(__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type], { [oldID]: newID });
120
- };
121
- if (strategy === 'restore') {
122
- return strategies_1.restore.createEntitiesWriteStream({
123
- strapi: this.strapi,
124
- updateMappingTable,
125
- transaction: this.transaction,
126
- });
127
- }
128
- throw new providers_1.ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
129
- check: 'strategy',
130
- strategy: this.options.strategy,
131
- validStrategies: exports.VALID_CONFLICT_STRATEGIES,
132
- });
133
- }
134
- // TODO: Move this logic to the restore strategy
135
- async createAssetsWriteStream() {
136
- (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to stream Assets');
137
- const assetsDirectory = path_1.default.join(this.strapi.dirs.static.public, 'uploads');
138
- const backupDirectory = path_1.default.join(this.strapi.dirs.static.public, `uploads_backup_${Date.now()}`);
139
- try {
140
- await fse.move(assetsDirectory, backupDirectory);
141
- await fse.mkdir(assetsDirectory);
142
- // Create a .gitkeep file to ensure the directory is not empty
143
- await fse.outputFile(path_1.default.join(assetsDirectory, '.gitkeep'), '');
144
- }
145
- catch (err) {
146
- 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');
147
- }
148
- return new stream_1.Writable({
149
- objectMode: true,
150
- async final(next) {
151
- await fse.rm(backupDirectory, { recursive: true, force: true });
152
- next();
153
- },
154
- async write(chunk, _encoding, callback) {
155
- const entryPath = path_1.default.join(assetsDirectory, chunk.filename);
156
- const writableStream = fse.createWriteStream(entryPath);
157
- chunk.stream
158
- .pipe(writableStream)
159
- .on('close', () => {
160
- callback(null);
161
- })
162
- .on('error', async (error) => {
163
- const errorMessage = error.code === 'ENOSPC'
164
- ? " Your server doesn't have space to proceed with the import. "
165
- : ' ';
166
- try {
167
- await fse.rm(assetsDirectory, { recursive: true, force: true });
168
- await fse.move(backupDirectory, assetsDirectory);
169
- this.destroy(new providers_1.ProviderTransferError(`There was an error during the transfer process.${errorMessage}The original files have been restored to ${assetsDirectory}`));
170
- }
171
- catch (err) {
172
- 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}`);
173
- }
174
- finally {
175
- callback(error);
176
- }
177
- });
178
- },
179
- });
180
- }
181
- async createConfigurationWriteStream() {
182
- (0, providers_2.assertValidStrapi)(this.strapi, 'Not able to stream Configurations');
183
- const { strategy } = this.options;
184
- if (strategy === 'restore') {
185
- return strategies_1.restore.createConfigurationWriteStream(this.strapi, this.transaction);
186
- }
187
- throw new providers_1.ProviderValidationError(`Invalid strategy ${strategy}`, {
188
- check: 'strategy',
189
- strategy,
190
- validStrategies: exports.VALID_CONFLICT_STRATEGIES,
191
- });
192
- }
193
- async createLinksWriteStream() {
194
- if (!this.strapi) {
195
- throw new Error('Not able to stream links. Strapi instance not found');
196
- }
197
- const { strategy } = this.options;
198
- const mapID = (uid, id) => __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[uid]?.[id];
199
- if (strategy === 'restore') {
200
- return strategies_1.restore.createLinksWriteStream(mapID, this.strapi, this.transaction);
201
- }
202
- throw new providers_1.ProviderValidationError(`Invalid strategy ${strategy}`, {
203
- check: 'strategy',
204
- strategy,
205
- validStrategies: exports.VALID_CONFLICT_STRATEGIES,
206
- });
207
- }
208
- }
209
- _LocalStrapiDestinationProvider_entitiesMapper = new WeakMap(), _LocalStrapiDestinationProvider_instances = new WeakSet(), _LocalStrapiDestinationProvider_validateOptions = function _LocalStrapiDestinationProvider_validateOptions() {
210
- if (!exports.VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {
211
- throw new providers_1.ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
212
- check: 'strategy',
213
- strategy: this.options.strategy,
214
- validStrategies: exports.VALID_CONFLICT_STRATEGIES,
215
- });
216
- }
217
- }, _LocalStrapiDestinationProvider_deleteAll = async function _LocalStrapiDestinationProvider_deleteAll() {
218
- (0, providers_2.assertValidStrapi)(this.strapi);
219
- return strategies_1.restore.deleteRecords(this.strapi, this.options.restore);
220
- };
221
- const createLocalStrapiDestinationProvider = (options) => {
222
- return new LocalStrapiDestinationProvider(options);
223
- };
224
- exports.createLocalStrapiDestinationProvider = createLocalStrapiDestinationProvider;
225
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-destination/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAClC,gDAAwB;AACxB,8CAAgC;AAShC,6CAAuC;AACvC,sDAAwC;AACxC,yDAA2F;AAC3F,wDAA6D;AAEhD,QAAA,yBAAyB,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACjD,QAAA,yBAAyB,GAAG,SAAS,CAAC;AAUnD,MAAM,8BAA8B;IAgBlC,YAAY,OAA+C;;QAf3D,SAAI,GAAG,2BAA2B,CAAC;QAEnC,SAAI,GAAiB,aAAa,CAAC;QAQnC;;WAEG;QACH,iEAA8D;QAG5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,uBAAA,IAAI,kDAAmB,EAAE,MAAA,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,SAAS;QACb,uBAAA,IAAI,kGAAiB,MAArB,IAAI,CAAmB,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QAE7C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MA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? (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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/strapi/providers/local-destination/strategies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAqC"}
@@ -1,5 +0,0 @@
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>;
@@ -1,51 +0,0 @@
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 fp_1 = require("lodash/fp");
8
- const stream_1 = require("stream");
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/configuration.ts"],"names":[],"mappings":";;;;;;AAAA,kCAAiC;AACjC,mCAAkC;AAClC,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,6B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b,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"}
@@ -1,11 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Common } from '@strapi/strapi';
3
- import { Writable } from 'stream';
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 };
@@ -1,103 +0,0 @@
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 fp_1 = require("lodash/fp");
28
- const stream_1 = require("stream");
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kCAAsC;AACtC,mCAAkC;AAElC,+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,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEvD,OAAO,IAAI,iBAAQ,CAAC;QAClB,UAAU,EAAE,IAAI;QAEhB,KAAK,CAAC,KAAK,CAAC,MAAe,EAAE,SAAS,EAAE,QAAQ;YAC9C,MAAM,WAAW,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;gBACnC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;gBAClC,MAAM,EAAE,MAAM,EAAE,iCAAiC,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;gBAClE,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAE1C;;;mBAGG;gBACH,MAAM,WAAW,GAAG,CAAC,KAAe,EAAoC,EAAE;oBACxE,IAAI,KAAK,GAAG,WAAW,CAAC;oBACxB,IAAI,KAAK,GAAY,IAAI,CAAC;oBAE1B,KAA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,EAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;4BACxD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;4BAEtC,+DAA+D;4BAC/D,IAAI,CAAC,MAAM,EAAE;gCACX,OAAO;6BACR;4BAED,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,MAA0B,CAAC;4BAEvD,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;yBAC1C;oBACH,CAAC,CAAC,CAAC;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACV,IAAI,CAAC,YAAY,KAAK,EAAE;wBACtB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;qBACpB;oBAED,OAAO,QAAQ,CAAC,IAAI,iCAAqB,CAAC,qBAAqB,IAAI,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;iBAClF;gBAED,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEO,8DAAyB"}
@@ -1,32 +0,0 @@
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';
@@ -1,107 +0,0 @@
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
@@ -1 +0,0 @@
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,MAAqB,EAAE,OAAyB,EAAE,EAAE;IACtF,MAAM,QAA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,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"}
@@ -1,4 +0,0 @@
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;
@@ -1,32 +0,0 @@
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