@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,60 @@
1
+ import { Writable } from 'stream';
2
+ import { posix } from 'path';
3
+
4
+ /**
5
+ * Create a file path factory for a given path & prefix.
6
+ * Upon being called, the factory will return a file path for a given index
7
+ */ const createFilePathFactory = (type)=>(fileIndex = 0)=>{
8
+ // always write tar files with posix paths so we have a standard format for paths regardless of system
9
+ return posix.join(// "{type}" directory
10
+ type, // "${type}_XXXXX.jsonl" file
11
+ `${type}_${String(fileIndex).padStart(5, '0')}.jsonl`);
12
+ };
13
+ const createTarEntryStream = (archive, pathFactory, maxSize = 2.56e8)=>{
14
+ let fileIndex = 0;
15
+ let buffer = '';
16
+ const flush = async ()=>{
17
+ if (!buffer) {
18
+ return;
19
+ }
20
+ fileIndex += 1;
21
+ const name = pathFactory(fileIndex);
22
+ const size = buffer.length;
23
+ await new Promise((resolve, reject)=>{
24
+ archive.entry({
25
+ name,
26
+ size
27
+ }, buffer, (err)=>{
28
+ if (err) {
29
+ reject(err);
30
+ }
31
+ resolve();
32
+ });
33
+ });
34
+ buffer = '';
35
+ };
36
+ const push = (chunk)=>{
37
+ buffer += chunk;
38
+ };
39
+ return new Writable({
40
+ async destroy (err, callback) {
41
+ await flush();
42
+ callback(err);
43
+ },
44
+ async write (chunk, _encoding, callback) {
45
+ const size = chunk.length;
46
+ if (chunk.length > maxSize) {
47
+ callback(new Error(`payload too large: ${chunk.length}>${maxSize}`));
48
+ return;
49
+ }
50
+ if (buffer.length + size > maxSize) {
51
+ await flush();
52
+ }
53
+ push(chunk);
54
+ callback(null);
55
+ }
56
+ });
57
+ };
58
+
59
+ export { createFilePathFactory, createTarEntryStream };
60
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","sources":["../../../../src/file/providers/destination/utils.ts"],"sourcesContent":["import { Writable } from 'stream';\nimport { posix } from 'path';\nimport tar from 'tar-stream';\n\n/**\n * Create a file path factory for a given path & prefix.\n * Upon being called, the factory will return a file path for a given index\n */\nexport const createFilePathFactory =\n (type: string) =>\n (fileIndex = 0): string => {\n // always write tar files with posix paths so we have a standard format for paths regardless of system\n return posix.join(\n // \"{type}\" directory\n type,\n // \"${type}_XXXXX.jsonl\" file\n `${type}_${String(fileIndex).padStart(5, '0')}.jsonl`\n );\n };\n\nexport const createTarEntryStream = (\n archive: tar.Pack,\n pathFactory: (index?: number) => string,\n maxSize = 2.56e8\n) => {\n let fileIndex = 0;\n let buffer = '';\n\n const flush = async () => {\n if (!buffer) {\n return;\n }\n\n fileIndex += 1;\n const name = pathFactory(fileIndex);\n const size = buffer.length;\n\n await new Promise<void>((resolve, reject) => {\n archive.entry({ name, size }, buffer, (err) => {\n if (err) {\n reject(err);\n }\n\n resolve();\n });\n });\n\n buffer = '';\n };\n\n const push = (chunk: string | Buffer) => {\n buffer += chunk;\n };\n\n return new Writable({\n async destroy(err, callback) {\n await flush();\n callback(err);\n },\n\n async write(chunk, _encoding, callback) {\n const size = chunk.length;\n\n if (chunk.length > maxSize) {\n callback(new Error(`payload too large: ${chunk.length}>${maxSize}`));\n return;\n }\n\n if (buffer.length + size > maxSize) {\n await flush();\n }\n\n push(chunk);\n\n callback(null);\n },\n });\n};\n"],"names":["createFilePathFactory","type","fileIndex","posix","join","String","padStart","createTarEntryStream","archive","pathFactory","maxSize","buffer","flush","name","size","length","Promise","resolve","reject","entry","err","push","chunk","Writable","destroy","callback","write","_encoding","Error"],"mappings":";;;AAIA;;;AAGC,IACYA,MAAAA,qBAAAA,GACX,CAACC,IACD,GAAA,CAACC,YAAY,CAAC,GAAA;;QAEZ,OAAOC,KAAAA,CAAMC,IAAI;AAEfH,QAAAA,IAAAA;QAEA,CAAC,EAAEA,IAAK,CAAA,CAAC,EAAEI,MAAAA,CAAOH,SAAWI,CAAAA,CAAAA,QAAQ,CAAC,CAAA,EAAG,GAAK,CAAA,CAAA,MAAM,CAAC,CAAA;;MAI9CC,oBAAuB,GAAA,CAClCC,OACAC,EAAAA,WAAAA,EACAC,UAAU,MAAM,GAAA;AAEhB,IAAA,IAAIR,SAAY,GAAA,CAAA;AAChB,IAAA,IAAIS,MAAS,GAAA,EAAA;AAEb,IAAA,MAAMC,KAAQ,GAAA,UAAA;AACZ,QAAA,IAAI,CAACD,MAAQ,EAAA;AACX,YAAA;AACF;QAEAT,SAAa,IAAA,CAAA;AACb,QAAA,MAAMW,OAAOJ,WAAYP,CAAAA,SAAAA,CAAA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strict';
2
+
3
+ var index = require('./source/index.js');
4
+ var index$1 = require('./destination/index.js');
5
+
6
+
7
+
8
+ exports.createLocalFileSourceProvider = index.createLocalFileSourceProvider;
9
+ exports.createLocalFileDestinationProvider = index$1.createLocalFileDestinationProvider;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ export { createLocalFileSourceProvider } from './source/index.mjs';
2
+ export { createLocalFileDestinationProvider } from './destination/index.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,288 @@
1
+ 'use strict';
2
+
3
+ var zip = require('zlib');
4
+ var path = require('path');
5
+ var stream$1 = require('stream');
6
+ var fse = require('fs-extra');
7
+ var tar = require('tar');
8
+ var fp = require('lodash/fp');
9
+ var streamChain = require('stream-chain');
10
+ var Parser = require('stream-json/jsonl/Parser');
11
+ require('crypto');
12
+ var decrypt = require('../../../utils/encryption/decrypt.js');
13
+ var stream = require('../../../utils/stream.js');
14
+ var schema = require('../../../utils/schema.js');
15
+ require('events');
16
+ var providers = require('../../../errors/providers.js');
17
+ var utils = require('./utils.js');
18
+
19
+ function _class_private_field_loose_base(receiver, privateKey) {
20
+ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
21
+ throw new TypeError("attempted to use private field on non-instance");
22
+ }
23
+ return receiver;
24
+ }
25
+ var id = 0;
26
+ function _class_private_field_loose_key(name) {
27
+ return "__private_" + id++ + "_" + name;
28
+ }
29
+ /**
30
+ * Constant for the metadata file path
31
+ */ const METADATA_FILE_PATH = 'metadata.json';
32
+ const createLocalFileSourceProvider = (options)=>{
33
+ return new LocalFileSourceProvider(options);
34
+ };
35
+ var _metadata = /*#__PURE__*/ _class_private_field_loose_key("_metadata"), _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"), _reportInfo = /*#__PURE__*/ _class_private_field_loose_key("_reportInfo"), _loadMetadata = /*#__PURE__*/ _class_private_field_loose_key("_loadMetadata"), _loadAssetMetadata = /*#__PURE__*/ _class_private_field_loose_key("_loadAssetMetadata"), _getBackupStream = /*#__PURE__*/ _class_private_field_loose_key("_getBackupStream"), // `directory` must be posix formatted path
36
+ _streamJsonlDirectory = /*#__PURE__*/ _class_private_field_loose_key("_streamJsonlDirectory"), _parseJSONFile = /*#__PURE__*/ _class_private_field_loose_key("_parseJSONFile");
37
+ class LocalFileSourceProvider {
38
+ /**
39
+ * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
40
+ */ async bootstrap(diagnostics) {
41
+ _class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
42
+ const { path: filePath } = this.options.file;
43
+ try {
44
+ // Read the metadata to ensure the file can be parsed
45
+ await _class_private_field_loose_base(this, _loadMetadata)[_loadMetadata]();
46
+ // TODO: we might also need to read the schema.jsonl files & implements a custom stream-check
47
+ } catch (e) {
48
+ if (this.options?.encryption?.enabled) {
49
+ throw new providers.ProviderInitializationError(`Key is incorrect or the file '${filePath}' is not a valid Strapi data file.`);
50
+ }
51
+ throw new providers.ProviderInitializationError(`File '${filePath}' is not a valid Strapi data file.`);
52
+ }
53
+ if (!_class_private_field_loose_base(this, _metadata)[_metadata]) {
54
+ throw new providers.ProviderInitializationError('Could not load metadata from Strapi data file.');
55
+ }
56
+ }
57
+ async getMetadata() {
58
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting metadata');
59
+ if (!_class_private_field_loose_base(this, _metadata)[_metadata]) {
60
+ await _class_private_field_loose_base(this, _loadMetadata)[_loadMetadata]();
61
+ }
62
+ return _class_private_field_loose_base(this, _metadata)[_metadata] ?? null;
63
+ }
64
+ async getSchemas() {
65
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting schemas');
66
+ const schemaCollection = await stream.collect(this.createSchemasReadStream());
67
+ if (fp.isEmpty(schemaCollection)) {
68
+ throw new providers.ProviderInitializationError('Could not load schemas from Strapi data file.');
69
+ }
70
+ // Group schema by UID
71
+ const schemas = fp.keyBy('uid', schemaCollection);
72
+ // Transform to valid JSON
73
+ return schema.schemasToValidJSON(schemas);
74
+ }
75
+ createEntitiesReadStream() {
76
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities read stream');
77
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('entities');
78
+ }
79
+ createSchemasReadStream() {
80
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating schemas read stream');
81
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('schemas');
82
+ }
83
+ createLinksReadStream() {
84
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating links read stream');
85
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('links');
86
+ }
87
+ createConfigurationReadStream() {
88
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating configuration read stream');
89
+ // NOTE: TBD
90
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('configuration');
91
+ }
92
+ createAssetsReadStream() {
93
+ const inStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
94
+ const outStream = new stream$1.PassThrough({
95
+ objectMode: true
96
+ });
97
+ const loadAssetMetadata = _class_private_field_loose_base(this, _loadAssetMetadata)[_loadAssetMetadata].bind(this);
98
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating assets read stream');
99
+ stream$1.pipeline([
100
+ inStream,
101
+ new tar.Parse({
102
+ // find only files in the assets/uploads folder
103
+ filter (filePath, entry) {
104
+ if (entry.type !== 'File') {
105
+ return false;
106
+ }
107
+ return utils.isFilePathInDirname('assets/uploads', filePath);
108
+ },
109
+ async onentry (entry) {
110
+ const { path: filePath, size = 0 } = entry;
111
+ const normalizedPath = utils.unknownPathToPosix(filePath);
112
+ const file = path.basename(normalizedPath);
113
+ let metadata;
114
+ try {
115
+ metadata = await loadAssetMetadata(`assets/metadata/${file}.json`);
116
+ } catch (error) {
117
+ throw new Error(`Failed to read metadata for ${file}`);
118
+ }
119
+ const asset = {
120
+ metadata,
121
+ filename: file,
122
+ filepath: normalizedPath,
123
+ stats: {
124
+ size
125
+ },
126
+ stream: entry
127
+ };
128
+ outStream.write(asset);
129
+ }
130
+ })
131
+ ], ()=>outStream.end());
132
+ return outStream;
133
+ }
134
+ constructor(options){
135
+ Object.defineProperty(this, _reportInfo, {
136
+ value: reportInfo
137
+ });
138
+ Object.defineProperty(this, _loadMetadata, {
139
+ value: loadMetadata
140
+ });
141
+ Object.defineProperty(this, _loadAssetMetadata, {
142
+ value: loadAssetMetadata
143
+ });
144
+ Object.defineProperty(this, _getBackupStream, {
145
+ value: getBackupStream
146
+ });
147
+ Object.defineProperty(this, _streamJsonlDirectory, {
148
+ value: streamJsonlDirectory
149
+ });
150
+ // For collecting an entire JSON file then parsing it, not for streaming JSONL
151
+ Object.defineProperty(this, _parseJSONFile, {
152
+ value: parseJSONFile
153
+ });
154
+ Object.defineProperty(this, _metadata, {
155
+ writable: true,
156
+ value: void 0
157
+ });
158
+ Object.defineProperty(this, _diagnostics, {
159
+ writable: true,
160
+ value: void 0
161
+ });
162
+ this.type = 'source';
163
+ this.name = 'source::local-file';
164
+ this.options = options;
165
+ const { encryption } = this.options;
166
+ if (encryption.enabled && encryption.key === undefined) {
167
+ throw new Error('Missing encryption key');
168
+ }
169
+ }
170
+ }
171
+ function reportInfo(message) {
172
+ _class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
173
+ details: {
174
+ createdAt: new Date(),
175
+ message,
176
+ origin: 'file-source-provider'
177
+ },
178
+ kind: 'info'
179
+ });
180
+ }
181
+ async function loadMetadata() {
182
+ const backupStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
183
+ _class_private_field_loose_base(this, _metadata)[_metadata] = await _class_private_field_loose_base(this, _parseJSONFile)[_parseJSONFile](backupStream, METADATA_FILE_PATH);
184
+ }
185
+ async function loadAssetMetadata(path) {
186
+ const backupStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
187
+ return _class_private_field_loose_base(this, _parseJSONFile)[_parseJSONFile](backupStream, path);
188
+ }
189
+ function getBackupStream() {
190
+ const { file, encryption, compression } = this.options;
191
+ const streams = [];
192
+ try {
193
+ streams.push(fse.createReadStream(file.path));
194
+ } catch (e) {
195
+ throw new Error(`Could not read backup file path provided at "${this.options.file.path}"`);
196
+ }
197
+ if (encryption.enabled && encryption.key) {
198
+ streams.push(decrypt.createDecryptionCipher(encryption.key));
199
+ }
200
+ if (compression.enabled) {
201
+ streams.push(zip.createGunzip());
202
+ }
203
+ return streamChain.chain(streams);
204
+ }
205
+ function streamJsonlDirectory(directory) {
206
+ const inStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
207
+ const outStream = new stream$1.PassThrough({
208
+ objectMode: true
209
+ });
210
+ stream$1.pipeline([
211
+ inStream,
212
+ new tar.Parse({
213
+ filter (filePath, entry) {
214
+ if (entry.type !== 'File') {
215
+ return false;
216
+ }
217
+ return utils.isFilePathInDirname(directory, filePath);
218
+ },
219
+ async onentry (entry) {
220
+ const transforms = [
221
+ // JSONL parser to read the data chunks one by one (line by line)
222
+ Parser.parser({
223
+ checkErrors: true
224
+ }),
225
+ // The JSONL parser returns each line as key/value
226
+ (line)=>line.value
227
+ ];
228
+ const stream = entry.pipe(streamChain.chain(transforms));
229
+ try {
230
+ for await (const chunk of stream){
231
+ outStream.write(chunk);
232
+ }
233
+ } catch (e) {
234
+ outStream.destroy(new providers.ProviderTransferError(`Error parsing backup files from backup file ${entry.path}: ${e.message}`, {
235
+ details: {
236
+ error: e
237
+ }
238
+ }));
239
+ }
240
+ }
241
+ })
242
+ ], async ()=>{
243
+ // Manually send the 'end' event to the out stream
244
+ // once every entry has finished streaming its content
245
+ outStream.end();
246
+ });
247
+ return outStream;
248
+ }
249
+ async function parseJSONFile(fileStream, filePath) {
250
+ return new Promise((resolve, reject)=>{
251
+ stream$1.pipeline([
252
+ fileStream,
253
+ // Custom backup archive parsing
254
+ new tar.Parse({
255
+ /**
256
+ * Filter the parsed entries to only keep the one that matches the given filepath
257
+ */ filter (entryPath, entry) {
258
+ if (entry.type !== 'File') {
259
+ return false;
260
+ }
261
+ return utils.isPathEquivalent(entryPath, filePath);
262
+ },
263
+ async onentry (entry) {
264
+ // Collect all the content of the entry file
265
+ const content = await entry.collect();
266
+ try {
267
+ // Parse from buffer array to string to JSON
268
+ const parsedContent = JSON.parse(Buffer.concat(content).toString());
269
+ // Resolve the Promise with the parsed content
270
+ resolve(parsedContent);
271
+ } catch (e) {
272
+ reject(e);
273
+ } finally{
274
+ // Cleanup (close the stream associated to the entry)
275
+ entry.destroy();
276
+ }
277
+ }
278
+ })
279
+ ], ()=>{
280
+ // If the promise hasn't been resolved and we've parsed all
281
+ // the archive entries, then the file doesn't exist
282
+ reject(new Error(`File "${filePath}" not found`));
283
+ });
284
+ });
285
+ }
286
+
287
+ exports.createLocalFileSourceProvider = createLocalFileSourceProvider;
288
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/file/providers/source/index.ts"],"sourcesContent":["import type { Readable } from 'stream';\n\nimport zip from 'zlib';\nimport path from 'path';\nimport { pipeline, PassThrough } from 'stream';\nimport fs from 'fs-extra';\nimport tar from 'tar';\nimport { isEmpty, keyBy } from 'lodash/fp';\nimport { chain } from 'stream-chain';\nimport { parser } from 'stream-json/jsonl/Parser';\nimport type { Struct } from '@strapi/types';\n\nimport type { IAsset, IMetadata, ISourceProvider, ProviderType, IFile } from '../../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\n\nimport * as utils from '../../../utils';\nimport { ProviderInitializationError, ProviderTransferError } from '../../../errors/providers';\nimport { isFilePathInDirname, isPathEquivalent, unknownPathToPosix } from './utils';\n\ntype StreamItemArray = Parameters<typeof chain>[0];\n\n/**\n * Constant for the metadata file path\n */\nconst METADATA_FILE_PATH = 'metadata.json';\n\n/**\n * Provider options\n */\nexport interface ILocalFileSourceProviderOptions {\n file: {\n path: string; // the file to load\n };\n\n encryption: {\n enabled: boolean; // if the file is encrypted (and should be decrypted)\n key?: string; // the key to decrypt the file\n };\n\n compression: {\n enabled: boolean; // if the file is compressed (and should be decompressed)\n };\n}\n\nexport const createLocalFileSourceProvider = (options: ILocalFileSourceProviderOptions) => {\n return new LocalFileSourceProvider(options);\n};\n\nclass LocalFileSourceProvider implements ISourceProvider {\n type: ProviderType = 'source';\n\n name = 'source::local-file';\n\n options: ILocalFileSourceProviderOptions;\n\n #metadata?: IMetadata;\n\n #diagnostics?: IDiagnosticReporter;\n\n constructor(options: ILocalFileSourceProviderOptions) {\n this.options = options;\n\n const { encryption } = this.options;\n\n if (encryption.enabled && encryption.key === undefined) {\n throw new Error('Missing encryption key');\n }\n }\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'file-source-provider',\n },\n kind: 'info',\n });\n }\n\n /**\n * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.\n */\n async bootstrap(diagnostics: IDiagnosticReporter) {\n this.#diagnostics = diagnostics;\n const { path: filePath } = this.options.file;\n\n try {\n // Read the metadata to ensure the file can be parsed\n await this.#loadMetadata();\n // TODO: we might also need to read the schema.jsonl files & implements a custom stream-check\n } catch (e) {\n if (this.options?.encryption?.enabled) {\n throw new ProviderInitializationError(\n `Key is incorrect or the file '${filePath}' is not a valid Strapi data file.`\n );\n }\n throw new ProviderInitializationError(`File '${filePath}' is not a valid Strapi data file.`);\n }\n\n if (!this.#metadata) {\n throw new ProviderInitializationError('Could not load metadata from Strapi data file.');\n }\n }\n\n async #loadMetadata() {\n const backupStream = this.#getBackupStream();\n this.#metadata = await this.#parseJSONFile<IMetadata>(backupStream, METADATA_FILE_PATH);\n }\n\n async #loadAssetMetadata(path: string) {\n const backupStream = this.#getBackupStream();\n return this.#parseJSONFile<IFile>(backupStream, path);\n }\n\n async getMetadata() {\n this.#reportInfo('getting metadata');\n if (!this.#metadata) {\n await this.#loadMetadata();\n }\n\n return this.#metadata ?? null;\n }\n\n async getSchemas() {\n this.#reportInfo('getting schemas');\n const schemaCollection = await utils.stream.collect<Struct.Schema>(\n this.createSchemasReadStream()\n );\n\n if (isEmpty(schemaCollection)) {\n throw new ProviderInitializationError('Could not load schemas from Strapi data file.');\n }\n\n // Group schema by UID\n const schemas = keyBy('uid', schemaCollection);\n\n // Transform to valid JSON\n return utils.schema.schemasToValidJSON(schemas);\n }\n\n createEntitiesReadStream(): Readable {\n this.#reportInfo('creating entities read stream');\n return this.#streamJsonlDirectory('entities');\n }\n\n createSchemasReadStream(): Readable {\n this.#reportInfo('creating schemas read stream');\n return this.#streamJsonlDirectory('schemas');\n }\n\n createLinksReadStream(): Readable {\n this.#reportInfo('creating links read stream');\n return this.#streamJsonlDirectory('links');\n }\n\n createConfigurationReadStream(): Readable {\n this.#reportInfo('creating configuration read stream');\n // NOTE: TBD\n return this.#streamJsonlDirectory('configuration');\n }\n\n createAssetsReadStream(): Readable | Promise<Readable> {\n const inStream = this.#getBackupStream();\n const outStream = new PassThrough({ objectMode: true });\n const loadAssetMetadata = this.#loadAssetMetadata.bind(this);\n this.#reportInfo('creating assets read stream');\n\n pipeline(\n [\n inStream,\n new tar.Parse({\n // find only files in the assets/uploads folder\n filter(filePath, entry) {\n if (entry.type !== 'File') {\n return false;\n }\n return isFilePathInDirname('assets/uploads', filePath);\n },\n async onentry(entry) {\n const { path: filePath, size = 0 } = entry;\n const normalizedPath = unknownPathToPosix(filePath);\n const file = path.basename(normalizedPath);\n let metadata;\n try {\n metadata = await loadAssetMetadata(`assets/metadata/${file}.json`);\n } catch (error) {\n throw new Error(`Failed to read metadata for ${file}`);\n }\n const asset: IAsset = {\n metadata,\n filename: file,\n filepath: normalizedPath,\n stats: { size },\n stream: entry as unknown as Readable,\n };\n outStream.write(asset);\n },\n }),\n ],\n () => outStream.end()\n );\n\n return outStream;\n }\n\n #getBackupStream() {\n const { file, encryption, compression } = this.options;\n\n const streams: StreamItemArray = [];\n\n try {\n streams.push(fs.createReadStream(file.path));\n } catch (e) {\n throw new Error(`Could not read backup file path provided at \"${this.options.file.path}\"`);\n }\n\n if (encryption.enabled && encryption.key) {\n streams.push(utils.encryption.createDecryptionCipher(encryption.key));\n }\n\n if (compression.enabled) {\n streams.push(zip.createGunzip());\n }\n\n return chain(streams);\n }\n\n // `directory` must be posix formatted path\n #streamJsonlDirectory(directory: string) {\n const inStream = this.#getBackupStream();\n\n const outStream = new PassThrough({ objectMode: true });\n\n pipeline(\n [\n inStream,\n new tar.Parse({\n filter(filePath, entry) {\n if (entry.type !== 'File') {\n return false;\n }\n\n return isFilePathInDirname(directory, filePath);\n },\n\n async onentry(entry) {\n const transforms = [\n // JSONL parser to read the data chunks one by one (line by line)\n parser({\n checkErrors: true,\n }),\n // The JSONL parser returns each line as key/value\n (line: { key: string; value: object }) => line.value,\n ];\n\n const stream = entry.pipe(chain(transforms));\n\n try {\n for await (const chunk of stream) {\n outStream.write(chunk);\n }\n } catch (e: unknown) {\n outStream.destroy(\n new ProviderTransferError(\n `Error parsing backup files from backup file ${entry.path}: ${\n (e as Error).message\n }`,\n {\n details: {\n error: e,\n },\n }\n )\n );\n }\n },\n }),\n ],\n async () => {\n // Manually send the 'end' event to the out stream\n // once every entry has finished streaming its content\n outStream.end();\n }\n );\n\n return outStream;\n }\n\n // For collecting an entire JSON file then parsing it, not for streaming JSONL\n async #parseJSONFile<T extends object>(fileStream: Readable, filePath: string): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n pipeline(\n [\n fileStream,\n // Custom backup archive parsing\n new tar.Parse({\n /**\n * Filter the parsed entries to only keep the one that matches the given filepath\n */\n filter(entryPath, entry) {\n if (entry.type !== 'File') {\n return false;\n }\n\n return isPathEquivalent(entryPath, filePath);\n },\n\n async onentry(entry) {\n // Collect all the content of the entry file\n const content = await entry.collect();\n\n try {\n // Parse from buffer array to string to JSON\n const parsedContent = JSON.parse(Buffer.concat(content).toString());\n\n // Resolve the Promise with the parsed content\n resolve(parsedContent);\n } catch (e) {\n reject(e);\n } finally {\n // Cleanup (close the stream associated to the entry)\n entry.destroy();\n }\n },\n }),\n ],\n () => {\n // If the promise hasn't been resolved and we've parsed all\n // the archive entries, then the file doesn't exist\n reject(new Error(`File \"${filePath}\" not found`));\n }\n );\n });\n }\n}\n"],"names":["METADATA_FILE_PATH","createLocalFileSourceProvider","options","LocalFileSourceProvider","bootstrap","diagnostics","path","filePath","file","loadMetadata","e","encryption","enabled","ProviderInitializationError","metadata","getMetadata","reportInfo","getSchemas","schemaCollection","utils","createSchemasReadStream","isEmpty","schemas","keyBy","createEntitiesReadStream","streamJsonlDirectory","createLinksReadStream","createConfigurationReadStream","createAssetsReadStream","inStream","getBackupStream","outStream","PassThrough","objectMode","loadAssetMetadata","bind","pipeline","tar","Parse","filter","entry","type","isFilePathInDirname","onentry","size","normalizedPath","unknownPathToPosix","basename","error","Error","asset","filename","filepath","stats","stream","write","end","constructor","name","key","undefined","message","report","details","createdAt","Date","origin","kind","backupStream","parseJSONFile","compression","streams","push","fs","createReadStream","zip","createGunzip","chain","directory","transforms","parser","checkErrors","line","value","pipe","chunk","destroy","ProviderTransferError","fileStream","Promise","resolve","reject","entryPath","isPathEquivalent","content","collect","parsedContent","JSON","parse","Buffer","concat","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA;;AAEC,IACD,MAAMA,kBAAqB,GAAA,eAAA;AAoBpB,MAAMC,gCAAgC,CAACC,OAAAA,GAAAA;AAC5C,IAAA,OAAO,IAAIC,uBAAwBD,CAAAA,OAAAA,CAAAA;AACrC;AASE,IAAA,SAAA,iBAAA,8BAAA,CAAA,WAAA,CAAA,EAEA,YAYA,iBAAA,8BAAA,CAAA,c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