@strapi/data-transfer 5.12.1 → 5.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/dist/engine/errors.js +39 -0
  2. package/dist/engine/errors.js.map +1 -0
  3. package/dist/engine/errors.mjs +34 -0
  4. package/dist/engine/errors.mjs.map +1 -0
  5. package/dist/engine/index.js +797 -0
  6. package/dist/engine/index.js.map +1 -0
  7. package/dist/engine/index.mjs +792 -0
  8. package/dist/engine/index.mjs.map +1 -0
  9. package/dist/engine/validation/provider.js +19 -0
  10. package/dist/engine/validation/provider.js.map +1 -0
  11. package/dist/engine/validation/provider.mjs +17 -0
  12. package/dist/engine/validation/provider.mjs.map +1 -0
  13. package/dist/engine/validation/schemas/index.js +57 -0
  14. package/dist/engine/validation/schemas/index.js.map +1 -0
  15. package/dist/engine/validation/schemas/index.mjs +55 -0
  16. package/dist/engine/validation/schemas/index.mjs.map +1 -0
  17. package/dist/errors/base.js +13 -0
  18. package/dist/errors/base.js.map +1 -0
  19. package/dist/errors/base.mjs +11 -0
  20. package/dist/errors/base.mjs.map +1 -0
  21. package/dist/errors/constants.js +10 -0
  22. package/dist/errors/constants.js.map +1 -0
  23. package/dist/errors/constants.mjs +8 -0
  24. package/dist/errors/constants.mjs.map +1 -0
  25. package/dist/errors/providers.js +41 -0
  26. package/dist/errors/providers.js.map +1 -0
  27. package/dist/errors/providers.mjs +36 -0
  28. package/dist/errors/providers.mjs.map +1 -0
  29. package/dist/file/index.js +8 -0
  30. package/dist/file/index.js.map +1 -0
  31. package/dist/file/index.mjs +3 -0
  32. package/dist/file/index.mjs.map +1 -0
  33. package/dist/file/providers/destination/index.js +248 -0
  34. package/dist/file/providers/destination/index.js.map +1 -0
  35. package/dist/file/providers/destination/index.mjs +246 -0
  36. package/dist/file/providers/destination/index.mjs.map +1 -0
  37. package/dist/file/providers/destination/utils.js +63 -0
  38. package/dist/file/providers/destination/utils.js.map +1 -0
  39. package/dist/file/providers/destination/utils.mjs +60 -0
  40. package/dist/file/providers/destination/utils.mjs.map +1 -0
  41. package/dist/file/providers/index.js +10 -0
  42. package/dist/file/providers/index.js.map +1 -0
  43. package/dist/file/providers/index.mjs +3 -0
  44. package/dist/file/providers/index.mjs.map +1 -0
  45. package/dist/file/providers/source/index.js +288 -0
  46. package/dist/file/providers/source/index.js.map +1 -0
  47. package/dist/file/providers/source/index.mjs +286 -0
  48. package/dist/file/providers/source/index.mjs.map +1 -0
  49. package/dist/file/providers/source/utils.js +56 -0
  50. package/dist/file/providers/source/utils.js.map +1 -0
  51. package/dist/file/providers/source/utils.mjs +52 -0
  52. package/dist/file/providers/source/utils.mjs.map +1 -0
  53. package/dist/index.js +8 -5692
  54. package/dist/index.js.map +1 -1
  55. package/dist/index.mjs +8 -5674
  56. package/dist/index.mjs.map +1 -1
  57. package/dist/strapi/index.js +12 -0
  58. package/dist/strapi/index.js.map +1 -0
  59. package/dist/strapi/index.mjs +7 -0
  60. package/dist/strapi/index.mjs.map +1 -0
  61. package/dist/strapi/providers/index.js +16 -0
  62. package/dist/strapi/providers/index.js.map +1 -0
  63. package/dist/strapi/providers/index.mjs +7 -0
  64. package/dist/strapi/providers/index.mjs.map +1 -0
  65. package/dist/strapi/providers/local-destination/index.js +419 -0
  66. package/dist/strapi/providers/local-destination/index.js.map +1 -0
  67. package/dist/strapi/providers/local-destination/index.mjs +396 -0
  68. package/dist/strapi/providers/local-destination/index.mjs.map +1 -0
  69. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +52 -0
  70. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
  71. package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs +49 -0
  72. package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs.map +1 -0
  73. package/dist/strapi/providers/local-destination/strategies/restore/entities.js +64 -0
  74. package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
  75. package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs +62 -0
  76. package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs.map +1 -0
  77. package/dist/strapi/providers/local-destination/strategies/restore/index.js +126 -0
  78. package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
  79. package/dist/strapi/providers/local-destination/strategies/restore/index.mjs +122 -0
  80. package/dist/strapi/providers/local-destination/strategies/restore/index.mjs.map +1 -0
  81. package/dist/strapi/providers/local-destination/strategies/restore/links.js +60 -0
  82. package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
  83. package/dist/strapi/providers/local-destination/strategies/restore/links.mjs +58 -0
  84. package/dist/strapi/providers/local-destination/strategies/restore/links.mjs.map +1 -0
  85. package/dist/strapi/providers/local-source/assets.js +123 -0
  86. package/dist/strapi/providers/local-source/assets.js.map +1 -0
  87. package/dist/strapi/providers/local-source/assets.mjs +121 -0
  88. package/dist/strapi/providers/local-source/assets.mjs.map +1 -0
  89. package/dist/strapi/providers/local-source/configuration.js +39 -0
  90. package/dist/strapi/providers/local-source/configuration.js.map +1 -0
  91. package/dist/strapi/providers/local-source/configuration.mjs +37 -0
  92. package/dist/strapi/providers/local-source/configuration.mjs.map +1 -0
  93. package/dist/strapi/providers/local-source/entities.js +62 -0
  94. package/dist/strapi/providers/local-source/entities.js.map +1 -0
  95. package/dist/strapi/providers/local-source/entities.mjs +59 -0
  96. package/dist/strapi/providers/local-source/entities.mjs.map +1 -0
  97. package/dist/strapi/providers/local-source/index.js +154 -0
  98. package/dist/strapi/providers/local-source/index.js.map +1 -0
  99. package/dist/strapi/providers/local-source/index.mjs +152 -0
  100. package/dist/strapi/providers/local-source/index.mjs.map +1 -0
  101. package/dist/strapi/providers/local-source/links.js +26 -0
  102. package/dist/strapi/providers/local-source/links.js.map +1 -0
  103. package/dist/strapi/providers/local-source/links.mjs +24 -0
  104. package/dist/strapi/providers/local-source/links.mjs.map +1 -0
  105. package/dist/strapi/providers/remote-destination/index.js +392 -0
  106. package/dist/strapi/providers/remote-destination/index.js.map +1 -0
  107. package/dist/strapi/providers/remote-destination/index.mjs +390 -0
  108. package/dist/strapi/providers/remote-destination/index.mjs.map +1 -0
  109. package/dist/strapi/providers/remote-source/index.js +405 -0
  110. package/dist/strapi/providers/remote-source/index.js.map +1 -0
  111. package/dist/strapi/providers/remote-source/index.mjs +403 -0
  112. package/dist/strapi/providers/remote-source/index.mjs.map +1 -0
  113. package/dist/strapi/providers/utils.js +173 -0
  114. package/dist/strapi/providers/utils.js.map +1 -0
  115. package/dist/strapi/providers/utils.mjs +169 -0
  116. package/dist/strapi/providers/utils.mjs.map +1 -0
  117. package/dist/strapi/queries/entity.js +125 -0
  118. package/dist/strapi/queries/entity.js.map +1 -0
  119. package/dist/strapi/queries/entity.mjs +123 -0
  120. package/dist/strapi/queries/entity.mjs.map +1 -0
  121. package/dist/strapi/queries/index.js +10 -0
  122. package/dist/strapi/queries/index.js.map +1 -0
  123. package/dist/strapi/queries/index.mjs +5 -0
  124. package/dist/strapi/queries/index.mjs.map +1 -0
  125. package/dist/strapi/queries/link.js +298 -0
  126. package/dist/strapi/queries/link.js.map +1 -0
  127. package/dist/strapi/queries/link.mjs +295 -0
  128. package/dist/strapi/queries/link.mjs.map +1 -0
  129. package/dist/strapi/remote/constants.js +11 -0
  130. package/dist/strapi/remote/constants.js.map +1 -0
  131. package/dist/strapi/remote/constants.mjs +8 -0
  132. package/dist/strapi/remote/constants.mjs.map +1 -0
  133. package/dist/strapi/remote/flows/default.js +43 -0
  134. package/dist/strapi/remote/flows/default.js.map +1 -0
  135. package/dist/strapi/remote/flows/default.mjs +41 -0
  136. package/dist/strapi/remote/flows/default.mjs.map +1 -0
  137. package/dist/strapi/remote/flows/index.js +54 -0
  138. package/dist/strapi/remote/flows/index.js.map +1 -0
  139. package/dist/strapi/remote/flows/index.mjs +52 -0
  140. package/dist/strapi/remote/flows/index.mjs.map +1 -0
  141. package/dist/strapi/remote/handlers/constants.js +10 -0
  142. package/dist/strapi/remote/handlers/constants.js.map +1 -0
  143. package/dist/strapi/remote/handlers/constants.mjs +8 -0
  144. package/dist/strapi/remote/handlers/constants.mjs.map +1 -0
  145. package/dist/strapi/remote/handlers/index.js +12 -0
  146. package/dist/strapi/remote/handlers/index.js.map +1 -0
  147. package/dist/strapi/remote/handlers/index.mjs +4 -0
  148. package/dist/strapi/remote/handlers/index.mjs.map +1 -0
  149. package/dist/strapi/remote/handlers/pull.js +348 -0
  150. package/dist/strapi/remote/handlers/pull.js.map +1 -0
  151. package/dist/strapi/remote/handlers/pull.mjs +346 -0
  152. package/dist/strapi/remote/handlers/pull.mjs.map +1 -0
  153. package/dist/strapi/remote/handlers/push.js +400 -0
  154. package/dist/strapi/remote/handlers/push.js.map +1 -0
  155. package/dist/strapi/remote/handlers/push.mjs +398 -0
  156. package/dist/strapi/remote/handlers/push.mjs.map +1 -0
  157. package/dist/strapi/remote/handlers/utils.js +316 -0
  158. package/dist/strapi/remote/handlers/utils.js.map +1 -0
  159. package/dist/strapi/remote/handlers/utils.mjs +310 -0
  160. package/dist/strapi/remote/handlers/utils.mjs.map +1 -0
  161. package/dist/strapi/remote/index.js +10 -0
  162. package/dist/strapi/remote/index.js.map +1 -0
  163. package/dist/strapi/remote/index.mjs +5 -0
  164. package/dist/strapi/remote/index.mjs.map +1 -0
  165. package/dist/utils/components.js +178 -0
  166. package/dist/utils/components.js.map +1 -0
  167. package/dist/utils/components.mjs +171 -0
  168. package/dist/utils/components.mjs.map +1 -0
  169. package/dist/utils/diagnostic.js +51 -0
  170. package/dist/utils/diagnostic.js.map +1 -0
  171. package/dist/utils/diagnostic.mjs +49 -0
  172. package/dist/utils/diagnostic.mjs.map +1 -0
  173. package/dist/utils/encryption/decrypt.js +47 -0
  174. package/dist/utils/encryption/decrypt.js.map +1 -0
  175. package/dist/utils/encryption/decrypt.mjs +45 -0
  176. package/dist/utils/encryption/decrypt.mjs.map +1 -0
  177. package/dist/utils/encryption/encrypt.js +47 -0
  178. package/dist/utils/encryption/encrypt.js.map +1 -0
  179. package/dist/utils/encryption/encrypt.mjs +45 -0
  180. package/dist/utils/encryption/encrypt.mjs.map +1 -0
  181. package/dist/utils/encryption/index.js +10 -0
  182. package/dist/utils/encryption/index.js.map +1 -0
  183. package/dist/utils/encryption/index.mjs +3 -0
  184. package/dist/utils/encryption/index.mjs.map +1 -0
  185. package/dist/utils/index.js +20 -0
  186. package/dist/utils/index.js.map +1 -0
  187. package/dist/utils/index.mjs +15 -0
  188. package/dist/utils/index.mjs.map +1 -0
  189. package/dist/utils/json.js +96 -0
  190. package/dist/utils/json.js.map +1 -0
  191. package/dist/utils/json.mjs +94 -0
  192. package/dist/utils/json.mjs.map +1 -0
  193. package/dist/utils/middleware.js +14 -0
  194. package/dist/utils/middleware.js.map +1 -0
  195. package/dist/utils/middleware.mjs +12 -0
  196. package/dist/utils/middleware.mjs.map +1 -0
  197. package/dist/utils/providers.js +12 -0
  198. package/dist/utils/providers.js.map +1 -0
  199. package/dist/utils/providers.mjs +10 -0
  200. package/dist/utils/providers.mjs.map +1 -0
  201. package/dist/utils/schema.js +32 -0
  202. package/dist/utils/schema.js.map +1 -0
  203. package/dist/utils/schema.mjs +29 -0
  204. package/dist/utils/schema.mjs.map +1 -0
  205. package/dist/utils/stream.js +59 -0
  206. package/dist/utils/stream.js.map +1 -0
  207. package/dist/utils/stream.mjs +55 -0
  208. package/dist/utils/stream.mjs.map +1 -0
  209. package/dist/utils/transaction.js +93 -0
  210. package/dist/utils/transaction.js.map +1 -0
  211. package/dist/utils/transaction.mjs +91 -0
  212. package/dist/utils/transaction.mjs.map +1 -0
  213. package/package.json +5 -5
@@ -0,0 +1,396 @@
1
+ import { Writable, Readable } from 'stream';
2
+ import path from 'path';
3
+ import * as fse from 'fs-extra';
4
+ import { deleteRecords } from './strategies/restore/index.mjs';
5
+ import 'crypto';
6
+ import 'lodash/fp';
7
+ import { schemasToValidJSON, mapSchemasValues } from '../../../utils/schema.mjs';
8
+ import { createTransaction } from '../../../utils/transaction.mjs';
9
+ import 'events';
10
+ import { ProviderInitializationError, ProviderValidationError, ProviderTransferError } from '../../../errors/providers.mjs';
11
+ import { assertValidStrapi } from '../../../utils/providers.mjs';
12
+ import { createEntitiesWriteStream } from './strategies/restore/entities.mjs';
13
+ import { createConfigurationWriteStream } from './strategies/restore/configuration.mjs';
14
+ import { createLinksWriteStream } from './strategies/restore/links.mjs';
15
+
16
+ function _class_private_field_loose_base(receiver, privateKey) {
17
+ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
18
+ throw new TypeError("attempted to use private field on non-instance");
19
+ }
20
+ return receiver;
21
+ }
22
+ var id = 0;
23
+ function _class_private_field_loose_key(name) {
24
+ return "__private_" + id++ + "_" + name;
25
+ }
26
+ const VALID_CONFLICT_STRATEGIES = [
27
+ 'restore'
28
+ ];
29
+ const DEFAULT_CONFLICT_STRATEGY = 'restore';
30
+ var _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"), /**
31
+ * The entities mapper is used to map old entities to their new IDs
32
+ */ _entitiesMapper = /*#__PURE__*/ _class_private_field_loose_key("_entitiesMapper"), // 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
33
+ _areAssetsIncluded = /*#__PURE__*/ _class_private_field_loose_key("_areAssetsIncluded"), _isContentTypeIncluded = /*#__PURE__*/ _class_private_field_loose_key("_isContentTypeIncluded"), _reportInfo = /*#__PURE__*/ _class_private_field_loose_key("_reportInfo"), _validateOptions = /*#__PURE__*/ _class_private_field_loose_key("_validateOptions"), _deleteFromRestoreOptions = /*#__PURE__*/ _class_private_field_loose_key("_deleteFromRestoreOptions"), _deleteAllAssets = /*#__PURE__*/ _class_private_field_loose_key("_deleteAllAssets"), _handleAssetsBackup = /*#__PURE__*/ _class_private_field_loose_key("_handleAssetsBackup"), _removeAssetsBackup = /*#__PURE__*/ _class_private_field_loose_key("_removeAssetsBackup");
34
+ class LocalStrapiDestinationProvider {
35
+ async bootstrap(diagnostics) {
36
+ _class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
37
+ _class_private_field_loose_base(this, _validateOptions)[_validateOptions]();
38
+ this.strapi = await this.options.getStrapi();
39
+ if (!this.strapi) {
40
+ throw new ProviderInitializationError('Could not access local strapi');
41
+ }
42
+ this.strapi.db.lifecycles.disable();
43
+ this.transaction = createTransaction(this.strapi);
44
+ }
45
+ async close() {
46
+ const { autoDestroy } = this.options;
47
+ assertValidStrapi(this.strapi);
48
+ this.transaction?.end();
49
+ this.strapi.db.lifecycles.enable();
50
+ // Basically `!== false` but more deterministic
51
+ if (autoDestroy === undefined || autoDestroy === true) {
52
+ await this.strapi?.destroy();
53
+ }
54
+ }
55
+ async rollback() {
56
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('Rolling back transaction');
57
+ await this.transaction?.rollback();
58
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('Rolled back transaction');
59
+ }
60
+ async beforeTransfer() {
61
+ if (!this.strapi) {
62
+ throw new Error('Strapi instance not found');
63
+ }
64
+ await this.transaction?.attach(async (trx)=>{
65
+ try {
66
+ if (this.options.strategy === 'restore') {
67
+ await _class_private_field_loose_base(this, _handleAssetsBackup)[_handleAssetsBackup]();
68
+ await _class_private_field_loose_base(this, _deleteAllAssets)[_deleteAllAssets](trx);
69
+ await _class_private_field_loose_base(this, _deleteFromRestoreOptions)[_deleteFromRestoreOptions]();
70
+ }
71
+ } catch (error) {
72
+ throw new Error(`restore failed ${error}`);
73
+ }
74
+ });
75
+ }
76
+ getMetadata() {
77
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting metadata');
78
+ assertValidStrapi(this.strapi, 'Not able to get Schemas');
79
+ const strapiVersion = this.strapi.config.get('info.strapi');
80
+ const createdAt = new Date().toISOString();
81
+ return {
82
+ createdAt,
83
+ strapi: {
84
+ version: strapiVersion
85
+ }
86
+ };
87
+ }
88
+ getSchemas() {
89
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting schema');
90
+ assertValidStrapi(this.strapi, 'Not able to get Schemas');
91
+ const schemas = schemasToValidJSON({
92
+ ...this.strapi.contentTypes,
93
+ ...this.strapi.components
94
+ });
95
+ return mapSchemasValues(schemas);
96
+ }
97
+ createEntitiesWriteStream() {
98
+ assertValidStrapi(this.strapi, 'Not able to import entities');
99
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities stream');
100
+ const { strategy } = this.options;
101
+ const updateMappingTable = (type, oldID, newID)=>{
102
+ if (!_class_private_field_loose_base(this, _entitiesMapper)[_entitiesMapper][type]) {
103
+ _class_private_field_loose_base(this, _entitiesMapper)[_entitiesMapper][type] = {};
104
+ }
105
+ Object.assign(_class_private_field_loose_base(this, _entitiesMapper)[_entitiesMapper][type], {
106
+ [oldID]: newID
107
+ });
108
+ };
109
+ if (strategy === 'restore') {
110
+ return createEntitiesWriteStream({
111
+ strapi: this.strapi,
112
+ updateMappingTable,
113
+ transaction: this.transaction
114
+ });
115
+ }
116
+ throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
117
+ check: 'strategy',
118
+ strategy: this.options.strategy,
119
+ validStrategies: VALID_CONFLICT_STRATEGIES
120
+ });
121
+ }
122
+ // TODO: Move this logic to the restore strategy
123
+ async createAssetsWriteStream() {
124
+ assertValidStrapi(this.strapi, 'Not able to stream Assets');
125
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating assets write stream');
126
+ if (!_class_private_field_loose_base(this, _areAssetsIncluded)[_areAssetsIncluded]()) {
127
+ throw new ProviderTransferError('Attempting to transfer assets when `assets` is not set in restore options');
128
+ }
129
+ const removeAssetsBackup = _class_private_field_loose_base(this, _removeAssetsBackup)[_removeAssetsBackup].bind(this);
130
+ const strapi = this.strapi;
131
+ const transaction = this.transaction;
132
+ const fileEntitiesMapper = _class_private_field_loose_base(this, _entitiesMapper)[_entitiesMapper]['plugin::upload.file'];
133
+ const restoreMediaEntitiesContent = _class_private_field_loose_base(this, _isContentTypeIncluded)[_isContentTypeIncluded]('plugin::upload.file');
134
+ return new Writable({
135
+ objectMode: true,
136
+ async final (next) {
137
+ // Delete the backup folder
138
+ await removeAssetsBackup();
139
+ next();
140
+ },
141
+ async write (chunk, _encoding, callback) {
142
+ await transaction?.attach(async ()=>{
143
+ const uploadData = {
144
+ ...chunk.metadata,
145
+ stream: Readable.from(chunk.stream),
146
+ buffer: chunk?.buffer
147
+ };
148
+ const provider = strapi.config.get('plugin::upload').provider;
149
+ const fileId = fileEntitiesMapper?.[uploadData.id];
150
+ if (!fileId) {
151
+ return callback(new Error(`File ID not found for ID: ${uploadData.id}`));
152
+ }
153
+ try {
154
+ await strapi.plugin('upload').provider.uploadStream(uploadData);
155
+ // if we're not supposed to transfer the associated entities, stop here
156
+ if (!restoreMediaEntitiesContent) {
157
+ return callback();
158
+ }
159
+ // Files formats are stored within the parent file entity
160
+ if (uploadData?.type) {
161
+ const entry = await strapi.db.query('plugin::upload.file').findOne({
162
+ where: {
163
+ id: fileId
164
+ }
165
+ });
166
+ if (!entry) {
167
+ throw new Error('file not found');
168
+ }
169
+ const specificFormat = entry?.formats?.[uploadData.type];
170
+ if (specificFormat) {
171
+ specificFormat.url = uploadData.url;
172
+ }
173
+ await strapi.db.query('plugin::upload.file').update({
174
+ where: {
175
+ id: entry.id
176
+ },
177
+ data: {
178
+ formats: entry.formats,
179
+ provider
180
+ }
181
+ });
182
+ return callback();
183
+ }
184
+ const entry = await strapi.db.query('plugin::upload.file').findOne({
185
+ where: {
186
+ id: fileId
187
+ }
188
+ });
189
+ if (!entry) {
190
+ throw new Error('file not found');
191
+ }
192
+ entry.url = uploadData.url;
193
+ await strapi.db.query('plugin::upload.file').update({
194
+ where: {
195
+ id: entry.id
196
+ },
197
+ data: {
198
+ url: entry.url,
199
+ provider
200
+ }
201
+ });
202
+ return callback();
203
+ } catch (error) {
204
+ return callback(new Error(`Error while uploading asset ${chunk.filename} ${error}`));
205
+ }
206
+ });
207
+ }
208
+ });
209
+ }
210
+ async createConfigurationWriteStream() {
211
+ assertValidStrapi(this.strapi, 'Not able to stream Configurations');
212
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating configuration write stream');
213
+ const { strategy } = this.options;
214
+ if (strategy === 'restore') {
215
+ return createConfigurationWriteStream(this.strapi, this.transaction);
216
+ }
217
+ throw new ProviderValidationError(`Invalid strategy ${strategy}`, {
218
+ check: 'strategy',
219
+ strategy,
220
+ validStrategies: VALID_CONFLICT_STRATEGIES
221
+ });
222
+ }
223
+ async createLinksWriteStream() {
224
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating links write stream');
225
+ if (!this.strapi) {
226
+ throw new Error('Not able to stream links. Strapi instance not found');
227
+ }
228
+ const { strategy } = this.options;
229
+ const mapID = (uid, id)=>_class_private_field_loose_base(this, _entitiesMapper)[_entitiesMapper][uid]?.[id];
230
+ if (strategy === 'restore') {
231
+ return createLinksWriteStream(mapID, this.strapi, this.transaction, this.onWarning);
232
+ }
233
+ throw new ProviderValidationError(`Invalid strategy ${strategy}`, {
234
+ check: 'strategy',
235
+ strategy,
236
+ validStrategies: VALID_CONFLICT_STRATEGIES
237
+ });
238
+ }
239
+ constructor(options){
240
+ Object.defineProperty(this, _reportInfo, {
241
+ value: reportInfo
242
+ });
243
+ Object.defineProperty(this, _validateOptions, {
244
+ value: validateOptions
245
+ });
246
+ Object.defineProperty(this, _deleteFromRestoreOptions, {
247
+ value: deleteFromRestoreOptions
248
+ });
249
+ Object.defineProperty(this, _deleteAllAssets, {
250
+ value: deleteAllAssets
251
+ });
252
+ Object.defineProperty(this, _handleAssetsBackup, {
253
+ value: handleAssetsBackup
254
+ });
255
+ Object.defineProperty(this, _removeAssetsBackup, {
256
+ value: removeAssetsBackup
257
+ });
258
+ Object.defineProperty(this, _diagnostics, {
259
+ writable: true,
260
+ value: void 0
261
+ });
262
+ Object.defineProperty(this, _entitiesMapper, {
263
+ writable: true,
264
+ value: void 0
265
+ });
266
+ Object.defineProperty(this, _areAssetsIncluded, {
267
+ writable: true,
268
+ value: void 0
269
+ });
270
+ Object.defineProperty(this, _isContentTypeIncluded, {
271
+ writable: true,
272
+ value: void 0
273
+ });
274
+ this.name = 'destination::local-strapi';
275
+ this.type = 'destination';
276
+ _class_private_field_loose_base(this, _areAssetsIncluded)[_areAssetsIncluded] = ()=>{
277
+ return this.options.restore?.assets;
278
+ };
279
+ _class_private_field_loose_base(this, _isContentTypeIncluded)[_isContentTypeIncluded] = (type)=>{
280
+ const notIncluded = this.options.restore?.entities?.include && !this.options.restore?.entities?.include?.includes(type);
281
+ const excluded = this.options.restore?.entities?.exclude && this.options.restore?.entities.exclude.includes(type);
282
+ return !excluded && !notIncluded;
283
+ };
284
+ this.options = options;
285
+ _class_private_field_loose_base(this, _entitiesMapper)[_entitiesMapper] = {};
286
+ this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;
287
+ }
288
+ }
289
+ function reportInfo(message) {
290
+ _class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
291
+ details: {
292
+ createdAt: new Date(),
293
+ message,
294
+ origin: 'local-destination-provider'
295
+ },
296
+ kind: 'info'
297
+ });
298
+ }
299
+ function validateOptions() {
300
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('validating options');
301
+ if (!VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {
302
+ throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
303
+ check: 'strategy',
304
+ strategy: this.options.strategy,
305
+ validStrategies: VALID_CONFLICT_STRATEGIES
306
+ });
307
+ }
308
+ // require restore options when using restore
309
+ if (this.options.strategy === 'restore' && !this.options.restore) {
310
+ throw new ProviderValidationError('Missing restore options');
311
+ }
312
+ }
313
+ async function deleteFromRestoreOptions() {
314
+ assertValidStrapi(this.strapi);
315
+ if (!this.options.restore) {
316
+ throw new ProviderValidationError('Missing restore options');
317
+ }
318
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('deleting record ');
319
+ return deleteRecords(this.strapi, this.options.restore);
320
+ }
321
+ async function deleteAllAssets(trx) {
322
+ assertValidStrapi(this.strapi);
323
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('deleting all assets');
324
+ // if we're not restoring files, don't touch the files
325
+ if (!_class_private_field_loose_base(this, _areAssetsIncluded)[_areAssetsIncluded]()) {
326
+ return;
327
+ }
328
+ const stream = this.strapi.db// Create a query builder instance (default type is 'select')
329
+ .queryBuilder('plugin::upload.file')// Fetch all columns
330
+ .select('*')// Attach the transaction
331
+ .transacting(trx)// Get a readable stream
332
+ .stream();
333
+ // TODO use bulk delete when exists in providers
334
+ for await (const file of stream){
335
+ await this.strapi.plugin('upload').provider.delete(file);
336
+ if (file.formats) {
337
+ for (const fileFormat of Object.values(file.formats)){
338
+ await this.strapi.plugin('upload').provider.delete(fileFormat);
339
+ }
340
+ }
341
+ }
342
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('deleted all assets');
343
+ }
344
+ async function handleAssetsBackup() {
345
+ assertValidStrapi(this.strapi, 'Not able to create the assets backup');
346
+ // if we're not restoring assets, don't back them up because they won't be touched
347
+ if (!_class_private_field_loose_base(this, _areAssetsIncluded)[_areAssetsIncluded]()) {
348
+ return;
349
+ }
350
+ if (this.strapi.config.get('plugin::upload').provider === 'local') {
351
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating assets backup directory');
352
+ const assetsDirectory = path.join(this.strapi.dirs.static.public, 'uploads');
353
+ const backupDirectory = path.join(this.strapi.dirs.static.public, this.uploadsBackupDirectoryName);
354
+ try {
355
+ // Check access before attempting to do anything
356
+ await fse.access(assetsDirectory, // eslint-disable-next-line no-bitwise
357
+ fse.constants.W_OK | fse.constants.R_OK | fse.constants.F_OK);
358
+ // eslint-disable-next-line no-bitwise
359
+ await fse.access(path.join(assetsDirectory, '..'), fse.constants.W_OK | fse.constants.R_OK);
360
+ await fse.move(assetsDirectory, backupDirectory);
361
+ await fse.mkdir(assetsDirectory);
362
+ // Create a .gitkeep file to ensure the directory is not empty
363
+ await fse.outputFile(path.join(assetsDirectory, '.gitkeep'), '');
364
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo](`created assets backup directory ${backupDirectory}`);
365
+ } catch (err) {
366
+ throw new 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', {
367
+ code: 'ASSETS_DIRECTORY_ERR'
368
+ });
369
+ }
370
+ return backupDirectory;
371
+ }
372
+ }
373
+ async function removeAssetsBackup() {
374
+ assertValidStrapi(this.strapi, 'Not able to remove Assets');
375
+ // if we're not restoring assets, don't back them up because they won't be touched
376
+ if (!_class_private_field_loose_base(this, _areAssetsIncluded)[_areAssetsIncluded]()) {
377
+ return;
378
+ }
379
+ // 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
380
+ if (this.strapi.config.get('plugin::upload').provider === 'local') {
381
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('removing assets backup');
382
+ assertValidStrapi(this.strapi);
383
+ const backupDirectory = path.join(this.strapi.dirs.static.public, this.uploadsBackupDirectoryName);
384
+ await fse.rm(backupDirectory, {
385
+ recursive: true,
386
+ force: true
387
+ });
388
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('successfully removed assets backup');
389
+ }
390
+ }
391
+ const createLocalStrapiDestinationProvider = (options)=>{
392
+ return new LocalStrapiDestinationProvider(options);
393
+ };
394
+
395
+ export { DEFAULT_CONFLICT_STRATEGY, VALID_CONFLICT_STRATEGIES, createLocalStrapiDestinationProvider };
396
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/strapi/providers/local-destination/index.ts"],"sourcesContent":["import { Writable, Readable } from 'stream';\nimport path from 'path';\nimport * as fse from 'fs-extra';\nimport type { Knex } from 'knex';\nimport type { Core, Struct } from '@strapi/types';\nimport type {\n IAsset,\n IDestinationProvider,\n IFile,\n IMetadata,\n ProviderType,\n Transaction,\n} from '../../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\n\nimport { restore } from './strategies';\nimport * as utils from '../../../utils';\nimport {\n ProviderInitializationError,\n ProviderTransferError,\n ProviderValidationError,\n} from '../../../errors/providers';\nimport { assertValidStrapi } from '../../../utils/providers';\n\nexport const VALID_CONFLICT_STRATEGIES = ['restore'];\nexport const DEFAULT_CONFLICT_STRATEGY = 'restore';\n\nexport interface ILocalStrapiDestinationProviderOptions {\n getStrapi(): Core.Strapi | Promise<Core.Strapi>; // return an initialized instance of Strapi\n\n autoDestroy?: boolean; // shut down the instance returned by getStrapi() at the end of the transfer\n restore?: restore.IRestoreOptions; // erase data in strapi database before transfer; required if strategy is 'restore'\n strategy: 'restore'; // conflict management strategy; only the restore strategy is available at this time\n}\n\nclass LocalStrapiDestinationProvider implements IDestinationProvider {\n name = 'destination::local-strapi';\n\n type: ProviderType = 'destination';\n\n options: ILocalStrapiDestinationProviderOptions;\n\n strapi?: Core.Strapi;\n\n transaction?: Transaction;\n\n uploadsBackupDirectoryName: string;\n\n onWarning?: ((message: string) => void) | undefined;\n\n #diagnostics?: IDiagnosticReporter;\n\n /**\n * The entities mapper is used to map old entities to their new IDs\n */\n #entitiesMapper: { [type: string]: { [id: number]: number } };\n\n constructor(options: ILocalStrapiDestinationProviderOptions) {\n this.options = options;\n this.#entitiesMapper = {};\n this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;\n }\n\n async bootstrap(diagnostics?: IDiagnosticReporter): Promise<void> {\n this.#diagnostics = diagnostics;\n this.#validateOptions();\n this.strapi = await this.options.getStrapi();\n if (!this.strapi) {\n throw new ProviderInitializationError('Could not access local strapi');\n }\n this.strapi.db.lifecycles.disable();\n this.transaction = utils.transaction.createTransaction(this.strapi);\n }\n\n // 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\n #areAssetsIncluded = () => {\n return this.options.restore?.assets;\n };\n\n #isContentTypeIncluded = (type: string) => {\n const notIncluded =\n this.options.restore?.entities?.include &&\n !this.options.restore?.entities?.include?.includes(type);\n const excluded =\n this.options.restore?.entities?.exclude &&\n this.options.restore?.entities.exclude.includes(type);\n\n return !excluded && !notIncluded;\n };\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-destination-provider',\n },\n kind: 'info',\n });\n }\n\n async close(): Promise<void> {\n const { autoDestroy } = this.options;\n assertValidStrapi(this.strapi);\n this.transaction?.end();\n this.strapi.db.lifecycles.enable();\n // Basically `!== false` but more deterministic\n if (autoDestroy === undefined || autoDestroy === true) {\n await this.strapi?.destroy();\n }\n }\n\n #validateOptions() {\n this.#reportInfo('validating options');\n if (!VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {\n throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {\n check: 'strategy',\n strategy: this.options.strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n // require restore options when using restore\n if (this.options.strategy === 'restore' && !this.options.restore) {\n throw new ProviderValidationError('Missing restore options');\n }\n }\n\n async #deleteFromRestoreOptions() {\n assertValidStrapi(this.strapi);\n if (!this.options.restore) {\n throw new ProviderValidationError('Missing restore options');\n }\n this.#reportInfo('deleting record ');\n return restore.deleteRecords(this.strapi, this.options.restore);\n }\n\n async #deleteAllAssets(trx?: Knex.Transaction) {\n assertValidStrapi(this.strapi);\n this.#reportInfo('deleting all assets');\n // if we're not restoring files, don't touch the files\n if (!this.#areAssetsIncluded()) {\n return;\n }\n\n const stream: Readable = this.strapi.db\n // Create a query builder instance (default type is 'select')\n .queryBuilder('plugin::upload.file')\n // Fetch all columns\n .select('*')\n // Attach the transaction\n .transacting(trx)\n // Get a readable stream\n .stream();\n\n // TODO use bulk delete when exists in providers\n for await (const file of stream) {\n await this.strapi.plugin('upload').provider.delete(file);\n if (file.formats) {\n for (const fileFormat of Object.values(file.formats)) {\n await this.strapi.plugin('upload').provider.delete(fileFormat);\n }\n }\n }\n\n this.#reportInfo('deleted all assets');\n }\n\n async rollback() {\n this.#reportInfo('Rolling back transaction');\n await this.transaction?.rollback();\n this.#reportInfo('Rolled back transaction');\n }\n\n async beforeTransfer() {\n if (!this.strapi) {\n throw new Error('Strapi instance not found');\n }\n\n await this.transaction?.attach(async (trx) => {\n try {\n if (this.options.strategy === 'restore') {\n await this.#handleAssetsBackup();\n await this.#deleteAllAssets(trx);\n await this.#deleteFromRestoreOptions();\n }\n } catch (error) {\n throw new Error(`restore failed ${error}`);\n }\n });\n }\n\n getMetadata(): IMetadata {\n this.#reportInfo('getting metadata');\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n const strapiVersion = this.strapi.config.get<string>('info.strapi');\n const createdAt = new Date().toISOString();\n\n return {\n createdAt,\n strapi: {\n version: strapiVersion,\n },\n };\n }\n\n getSchemas(): Record<string, Struct.Schema> {\n this.#reportInfo('getting schema');\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n\n const schemas = utils.schema.schemasToValidJSON({\n ...this.strapi.contentTypes,\n ...this.strapi.components,\n });\n\n return utils.schema.mapSchemasValues(schemas);\n }\n\n createEntitiesWriteStream(): Writable {\n assertValidStrapi(this.strapi, 'Not able to import entities');\n this.#reportInfo('creating entities stream');\n const { strategy } = this.options;\n\n const updateMappingTable = (type: string, oldID: number, newID: number) => {\n if (!this.#entitiesMapper[type]) {\n this.#entitiesMapper[type] = {};\n }\n\n Object.assign(this.#entitiesMapper[type], { [oldID]: newID });\n };\n\n if (strategy === 'restore') {\n return restore.createEntitiesWriteStream({\n strapi: this.strapi,\n updateMappingTable,\n transaction: this.transaction,\n });\n }\n\n throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {\n check: 'strategy',\n strategy: this.options.strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n async #handleAssetsBackup() {\n assertValidStrapi(this.strapi, 'Not able to create the assets backup');\n\n // if we're not restoring assets, don't back them up because they won't be touched\n if (!this.#areAssetsIncluded()) {\n return;\n }\n\n if (this.strapi.config.get<{ provider: string }>('plugin::upload').provider === 'local') {\n this.#reportInfo('creating assets backup directory');\n const assetsDirectory = path.join(this.strapi.dirs.static.public, 'uploads');\n const backupDirectory = path.join(\n this.strapi.dirs.static.public,\n this.uploadsBackupDirectoryName\n );\n\n try {\n // Check access before attempting to do anything\n await fse.access(\n assetsDirectory,\n // eslint-disable-next-line no-bitwise\n fse.constants.W_OK | fse.constants.R_OK | fse.constants.F_OK\n );\n // eslint-disable-next-line no-bitwise\n await fse.access(path.join(assetsDirectory, '..'), fse.constants.W_OK | fse.constants.R_OK);\n\n await fse.move(assetsDirectory, backupDirectory);\n await fse.mkdir(assetsDirectory);\n // Create a .gitkeep file to ensure the directory is not empty\n await fse.outputFile(path.join(assetsDirectory, '.gitkeep'), '');\n this.#reportInfo(`created assets backup directory ${backupDirectory}`);\n } catch (err) {\n throw new ProviderTransferError(\n 'The backup folder for the assets could not be created inside the public folder. Please ensure Strapi has write permissions on the public directory',\n {\n code: 'ASSETS_DIRECTORY_ERR',\n }\n );\n }\n return backupDirectory;\n }\n }\n\n async #removeAssetsBackup() {\n assertValidStrapi(this.strapi, 'Not able to remove Assets');\n // if we're not restoring assets, don't back them up because they won't be touched\n if (!this.#areAssetsIncluded()) {\n return;\n }\n // 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\n if (this.strapi.config.get<{ provider: string }>('plugin::upload').provider === 'local') {\n this.#reportInfo('removing assets backup');\n assertValidStrapi(this.strapi);\n const backupDirectory = path.join(\n this.strapi.dirs.static.public,\n this.uploadsBackupDirectoryName\n );\n await fse.rm(backupDirectory, { recursive: true, force: true });\n this.#reportInfo('successfully removed assets backup');\n }\n }\n\n // TODO: Move this logic to the restore strategy\n async createAssetsWriteStream(): Promise<Writable> {\n assertValidStrapi(this.strapi, 'Not able to stream Assets');\n this.#reportInfo('creating assets write stream');\n if (!this.#areAssetsIncluded()) {\n throw new ProviderTransferError(\n 'Attempting to transfer assets when `assets` is not set in restore options'\n );\n }\n\n const removeAssetsBackup = this.#removeAssetsBackup.bind(this);\n const strapi = this.strapi;\n const transaction = this.transaction;\n const fileEntitiesMapper = this.#entitiesMapper['plugin::upload.file'];\n\n const restoreMediaEntitiesContent = this.#isContentTypeIncluded('plugin::upload.file');\n\n return new Writable({\n objectMode: true,\n async final(next) {\n // Delete the backup folder\n await removeAssetsBackup();\n next();\n },\n async write(chunk: IAsset, _encoding, callback) {\n await transaction?.attach(async () => {\n const uploadData = {\n ...chunk.metadata,\n stream: Readable.from(chunk.stream),\n buffer: chunk?.buffer,\n };\n\n const provider = strapi.config.get<{ provider: string }>('plugin::upload').provider;\n\n const fileId = fileEntitiesMapper?.[uploadData.id];\n if (!fileId) {\n return callback(new Error(`File ID not found for ID: ${uploadData.id}`));\n }\n\n try {\n await strapi.plugin('upload').provider.uploadStream(uploadData);\n\n // if we're not supposed to transfer the associated entities, stop here\n if (!restoreMediaEntitiesContent) {\n return callback();\n }\n\n // Files formats are stored within the parent file entity\n if (uploadData?.type) {\n const entry: IFile = await strapi.db.query('plugin::upload.file').findOne({\n where: { id: fileId },\n });\n if (!entry) {\n throw new Error('file not found');\n }\n const specificFormat = entry?.formats?.[uploadData.type];\n if (specificFormat) {\n specificFormat.url = uploadData.url;\n }\n await strapi.db.query('plugin::upload.file').update({\n where: { id: entry.id },\n data: {\n formats: entry.formats,\n provider,\n },\n });\n return callback();\n }\n\n const entry: IFile = await strapi.db.query('plugin::upload.file').findOne({\n where: { id: fileId },\n });\n if (!entry) {\n throw new Error('file not found');\n }\n entry.url = uploadData.url;\n await strapi.db.query('plugin::upload.file').update({\n where: { id: entry.id },\n data: {\n url: entry.url,\n provider,\n },\n });\n return callback();\n } catch (error) {\n return callback(new Error(`Error while uploading asset ${chunk.filename} ${error}`));\n }\n });\n },\n });\n }\n\n async createConfigurationWriteStream(): Promise<Writable> {\n assertValidStrapi(this.strapi, 'Not able to stream Configurations');\n this.#reportInfo('creating configuration write stream');\n const { strategy } = this.options;\n\n if (strategy === 'restore') {\n return restore.createConfigurationWriteStream(this.strapi, this.transaction);\n }\n\n throw new ProviderValidationError(`Invalid strategy ${strategy}`, {\n check: 'strategy',\n strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n async createLinksWriteStream(): Promise<Writable> {\n this.#reportInfo('creating links write stream');\n if (!this.strapi) {\n throw new Error('Not able to stream links. Strapi instance not found');\n }\n\n const { strategy } = this.options;\n const mapID = (uid: string, id: number): number | undefined => this.#entitiesMapper[uid]?.[id];\n\n if (strategy === 'restore') {\n return restore.createLinksWriteStream(mapID, this.strapi, this.transaction, this.onWarning);\n }\n\n throw new ProviderValidationError(`Invalid strategy ${strategy}`, {\n check: 'strategy',\n strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n}\n\nexport const createLocalStrapiDestinationProvider = (\n options: ILocalStrapiDestinationProviderOptions\n) => {\n return new LocalStrapiDestinationProvider(options);\n};\n"],"names":["VALID_CONFLICT_STRATEGIES","DEFAULT_CONFLICT_STRATEGY","LocalStrapiDestinationProvider","bootstrap","diagnostics","validateOptions","strapi","options","getStrapi","ProviderInitializationError","db","lifecycles","disable","transaction","utils","close","autoDestroy","assertValidStrapi","end","enable","undefined","destroy","rollback","reportInfo","beforeTransfer","Error","attach","trx","strategy","handleAssetsBackup","deleteAllAssets","deleteFromRestoreOptions","error","getMetadata","strapiVersion","config","get","createdAt","Date","toISOString","version","getSchemas","schemas","contentTypes","components","createEntitiesWriteStream","updateMappingTable","type","oldID","newID","entitiesMapper","Object","assign","restore","ProviderValidationError","check","validStrategies","createAssetsWriteStream","areAssetsIncluded","ProviderTransferError","removeAssetsBackup","bind","fileEntitiesMapper","restoreMediaEntitiesContent","isContentTypeIncluded","Writable","objectMode","final","next","write","chunk","_encoding","callback","uploadData","metadata","stream","Readable","from","buffer","provider","fileId","id","plugin","uploadStream","entry","query","findOne","where","specificFormat","formats","url","update","data","filename","createConfigurationWriteStream","createLinksWriteStream","mapID","uid","onWarning","constructor","name","assets","notIncluded","entities","include","includes","excluded","exclude","uploadsBackupDirectoryName","now","message","report","details","origin","kind","queryBuilder","select","transacting","file","delete","fileFormat","values","assetsDirectory","path","join","dirs","static","public","backupDirectory","fse","access","constants","W_OK","R_OK","F_OK","move","mkdir","outputFile","err","code","rm","recursive","force","createLocalStrapiDestinationProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;MAwBaA,yBAA4B,GAAA;AAAC,IAAA;;AACnC,MAAMC,4BAA4B;IAyBvC,YAEA,iBAAA,8BAAA,CAAA,cAAA,CAAA;;AAEC,MACD;AAoBA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA,EAIA,sBAWA,iBAAA,8BAAA,CAAA,wBAAA,CAAA,EAAA,WAAA,iBAAA,8BAAA,CAAA,aAAA,CAAA,EAsBA,gBAgBM,iBAAA,8BAAA,CAAA,kBAAA,CAAA,EAAA,yBAAA,iBAAA,8BAAA,CAAA,2BAAA,CAAA,EASA,qFA6GA,mBA2CA,iBAAA,8BAAA,CAAA,qBAAA,CAAA,EAAA,mBAAA,iBAAA,8BAAA,CAAA,qBAAA,CAAA;AA9PR,MAAMC,8BAAAA,CAAAA;IA4BJ,MAAMC,SAAAA,CAAUC,WAAiC,EAAiB;QAChE,+BAAA,CAAA,IAAI,EAAEA,YAAAA,CAAAA,CAAAA,YAAcA,CAAAA,GAAAA,WAAAA;QACpB,+BAAA,CAAA,IAAI,EAAEC,gBAAAA,CAAAA,CAAAA,gBAAAA,CAAAA,EAAAA;QACN,IAAI,CAACC,MAAM,GAAG,MAAM,IAAI,CAACC,OAAO,CAACC,SAAS,EAAA;AAC1C,QAAA,IAAI,CAAC,IAAI,CAACF,MAAM,EAAE;AAChB,YAAA,MAAM,IAAIG,2BAA4B,CAAA,+BAAA,CAAA;AACxC;AACA,QAAA,IAAI,CAACH,MAAM,CAACI,EAAE,CAACC,UAAU,CAACC,OAAO,EAAA;QACjC,IAAI,CAACC,WAAW,GAAGC,iBAAmC,CAAC,IAAI,CA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providers = require('../../../../../errors/providers.js');
7
+
8
+ const omitInvalidCreationAttributes = fp.omit([
9
+ 'id'
10
+ ]);
11
+ const restoreCoreStore = async (strapi, values)=>{
12
+ const data = omitInvalidCreationAttributes(values);
13
+ return strapi.db.query('strapi::core-store').create({
14
+ data: {
15
+ ...data,
16
+ value: JSON.stringify(data.value)
17
+ }
18
+ });
19
+ };
20
+ const restoreWebhooks = async (strapi, values)=>{
21
+ const data = omitInvalidCreationAttributes(values);
22
+ return strapi.db.query('strapi::webhook').create({
23
+ data
24
+ });
25
+ };
26
+ const restoreConfigs = async (strapi, config)=>{
27
+ if (config.type === 'core-store') {
28
+ return restoreCoreStore(strapi, config.value);
29
+ }
30
+ if (config.type === 'webhook') {
31
+ return restoreWebhooks(strapi, config.value);
32
+ }
33
+ };
34
+ const createConfigurationWriteStream = async (strapi, transaction)=>{
35
+ return new stream.Writable({
36
+ objectMode: true,
37
+ async write (config, _encoding, callback) {
38
+ await transaction?.attach(async ()=>{
39
+ try {
40
+ await restoreConfigs(strapi, config);
41
+ } catch (error) {
42
+ return callback(new providers.ProviderTransferError(`Failed to import ${chalk.yellowBright(config.type)} (${chalk.greenBright(config.value.id)}`));
43
+ }
44
+ callback();
45
+ });
46
+ }
47
+ });
48
+ };
49
+
50
+ exports.createConfigurationWriteStream = createConfigurationWriteStream;
51
+ exports.restoreConfigs = restoreConfigs;
52
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/configuration.ts"],"sourcesContent":["import { Writable } from 'stream';\nimport { omit } from 'lodash/fp';\nimport chalk from 'chalk';\nimport type { Core } from '@strapi/types';\nimport { ProviderTransferError } from '../../../../../errors/providers';\nimport { IConfiguration, Transaction } from '../../../../../../types';\n\nconst omitInvalidCreationAttributes = omit(['id']);\n\nconst restoreCoreStore = async <T extends { value: unknown }>(strapi: Core.Strapi, values: T) => {\n const data = omitInvalidCreationAttributes(values);\n return strapi.db.query('strapi::core-store').create({\n data: {\n ...data,\n value: JSON.stringify(data.value),\n },\n });\n};\n\nconst restoreWebhooks = async <T extends { value: unknown }>(strapi: Core.Strapi, values: T) => {\n const data = omitInvalidCreationAttributes(values);\n return strapi.db.query('strapi::webhook').create({ data });\n};\n\nexport const restoreConfigs = async (strapi: Core.Strapi, config: IConfiguration) => {\n if (config.type === 'core-store') {\n return restoreCoreStore(strapi, config.value as { value: unknown });\n }\n\n if (config.type === 'webhook') {\n return restoreWebhooks(strapi, config.value as { value: unknown });\n }\n};\n\nexport const createConfigurationWriteStream = async (\n strapi: Core.Strapi,\n transaction?: Transaction\n) => {\n return new Writable({\n objectMode: true,\n async write<T extends { id: number }>(\n config: IConfiguration<T>,\n _encoding: BufferEncoding,\n callback: (error?: Error | null) => void\n ) {\n await transaction?.attach(async () => {\n try {\n await restoreConfigs(strapi, config);\n } catch (error) {\n return callback(\n new ProviderTransferError(\n `Failed to import ${chalk.yellowBright(config.type)} (${chalk.greenBright(\n config.value.id\n )}`\n )\n );\n }\n callback();\n });\n },\n });\n};\n"],"names":["omitInvalidCreationAttributes","omit","restoreCoreStore","strapi","values","data","db","query","create","value","JSON","stringify","restoreWebhooks","restoreConfigs","config","type","createConfigurationWriteStream","transaction","Writable","objectMode","write","_encoding","callback","attach","error","ProviderTransferError","chalk","yellowBright","greenBright","id"],"mappings":";;;;;;;AAOA,MAAMA,gCAAgCC,OAAK,CAAA;AAAC,IAAA;AAAK,CAAA,CAAA;AAEjD,MAAMC,gBAAAA,GAAmB,OAAqCC,MAAqBC,EAAAA,MAAAA,GAAAA;AACjF,IAAA,MAAMC,OAAOL,6BAA8BI,CAAAA,MAAAA,CAAAA;AAC3C,IAAA,OAAOD,OAAOG,EAAE,CAACC,KAAK,CAAC,oBAAA,CAAA,CAAsBC,MAAM,CAAC;QAClDH,IAAM,EAAA;AACJ,YAAA,GAAGA,IAAI;AACPI,YAAAA,KAAAA,EAAOC,IAAKC,CAAAA,SAAS,C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QAAAA,EAAAA;AACF,aAAA,CAAA;AACF;AACF,KAAA,CAAA;AACF;;;;;"}
@@ -0,0 +1,49 @@
1
+ import { Writable } from 'stream';
2
+ import { omit } from 'lodash/fp';
3
+ import chalk from 'chalk';
4
+ import { ProviderTransferError } from '../../../../../errors/providers.mjs';
5
+
6
+ const omitInvalidCreationAttributes = omit([
7
+ 'id'
8
+ ]);
9
+ const restoreCoreStore = async (strapi, values)=>{
10
+ const data = omitInvalidCreationAttributes(values);
11
+ return strapi.db.query('strapi::core-store').create({
12
+ data: {
13
+ ...data,
14
+ value: JSON.stringify(data.value)
15
+ }
16
+ });
17
+ };
18
+ const restoreWebhooks = async (strapi, values)=>{
19
+ const data = omitInvalidCreationAttributes(values);
20
+ return strapi.db.query('strapi::webhook').create({
21
+ data
22
+ });
23
+ };
24
+ const restoreConfigs = async (strapi, config)=>{
25
+ if (config.type === 'core-store') {
26
+ return restoreCoreStore(strapi, config.value);
27
+ }
28
+ if (config.type === 'webhook') {
29
+ return restoreWebhooks(strapi, config.value);
30
+ }
31
+ };
32
+ const createConfigurationWriteStream = async (strapi, transaction)=>{
33
+ return new Writable({
34
+ objectMode: true,
35
+ async write (config, _encoding, callback) {
36
+ await transaction?.attach(async ()=>{
37
+ try {
38
+ await restoreConfigs(strapi, config);
39
+ } catch (error) {
40
+ return callback(new ProviderTransferError(`Failed to import ${chalk.yellowBright(config.type)} (${chalk.greenBright(config.value.id)}`));
41
+ }
42
+ callback();
43
+ });
44
+ }
45
+ });
46
+ };
47
+
48
+ export { createConfigurationWriteStream, restoreConfigs };
49
+ //# sourceMappingURL=configuration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.mjs","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/configuration.ts"],"sourcesContent":["import { Writable } from 'stream';\nimport { omit } from 'lodash/fp';\nimport chalk from 'chalk';\nimport type { Core } from '@strapi/types';\nimport { ProviderTransferError } from '../../../../../errors/providers';\nimport { IConfiguration, Transaction } from '../../../../../../types';\n\nconst omitInvalidCreationAttributes = omit(['id']);\n\nconst restoreCoreStore = async <T extends { value: unknown }>(strapi: Core.Strapi, values: T) => {\n const data = omitInvalidCreationAttributes(values);\n return strapi.db.query('strapi::core-store').create({\n data: {\n ...data,\n value: JSON.stringify(data.value),\n },\n });\n};\n\nconst restoreWebhooks = async <T extends { value: unknown }>(strapi: Core.Strapi, values: T) => {\n const data = omitInvalidCreationAttributes(values);\n return strapi.db.query('strapi::webhook').create({ data });\n};\n\nexport const restoreConfigs = async (strapi: Core.Strapi, config: IConfiguration) => {\n if (config.type === 'core-store') {\n return restoreCoreStore(strapi, config.value as { value: unknown });\n }\n\n if (config.type === 'webhook') {\n return restoreWebhooks(strapi, config.value as { value: unknown });\n }\n};\n\nexport const createConfigurationWriteStream = async (\n strapi: Core.Strapi,\n transaction?: Transaction\n) => {\n return new Writable({\n objectMode: true,\n async write<T extends { id: number }>(\n config: IConfiguration<T>,\n _encoding: BufferEncoding,\n callback: (error?: Error | null) => void\n ) {\n await transaction?.attach(async () => {\n try {\n await restoreConfigs(strapi, config);\n } catch (error) {\n return callback(\n new ProviderTransferError(\n `Failed to import ${chalk.yellowBright(config.type)} (${chalk.greenBright(\n config.value.id\n )}`\n )\n );\n }\n callback();\n });\n },\n });\n};\n"],"names":["omitInvalidCreationAttributes","omit","restoreCoreStore","strapi","values","data","db","query","create","value","JSON","stringify","restoreWebhooks","restoreConfigs","config","type","createConfigurationWriteStream","transaction","Writable","objectMode","write","_encoding","callback","attach","error","ProviderTransferError","chalk","yellowBright","greenBright","id"],"mappings":";;;;;AAOA,MAAMA,gCAAgCC,IAAK,CAAA;AAAC,IAAA;AAAK,CAAA,CAAA;AAEjD,MAAMC,gBAAAA,GAAmB,OAAqCC,MAAqBC,EAAAA,MAAAA,GAAAA;AACjF,IAAA,MAAMC,OAAOL,6BAA8BI,CAAAA,MAAAA,CAAAA;AAC3C,IAAA,OAAOD,OAAOG,EAAE,CAACC,KAAK,CAAC,oBAA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