@strapi/data-transfer 5.61.0 → 5.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/directory/providers/destination/index.d.ts +1 -1
  2. package/dist/directory/providers/destination/index.d.ts.map +1 -1
  3. package/dist/directory/providers/destination/index.js +15 -31
  4. package/dist/directory/providers/destination/index.js.map +1 -1
  5. package/dist/directory/providers/destination/index.mjs +15 -31
  6. package/dist/directory/providers/destination/index.mjs.map +1 -1
  7. package/dist/directory/providers/destination/utils.d.ts +1 -2
  8. package/dist/directory/providers/destination/utils.d.ts.map +1 -1
  9. package/dist/directory/providers/destination/utils.js +7 -36
  10. package/dist/directory/providers/destination/utils.js.map +1 -1
  11. package/dist/directory/providers/destination/utils.mjs +7 -36
  12. package/dist/directory/providers/destination/utils.mjs.map +1 -1
  13. package/dist/directory/providers/source/index.d.ts.map +1 -1
  14. package/dist/directory/providers/source/index.js +7 -7
  15. package/dist/directory/providers/source/index.js.map +1 -1
  16. package/dist/directory/providers/source/index.mjs +7 -7
  17. package/dist/directory/providers/source/index.mjs.map +1 -1
  18. package/dist/engine/index.d.ts.map +1 -1
  19. package/dist/engine/index.js +45 -32
  20. package/dist/engine/index.js.map +1 -1
  21. package/dist/engine/index.mjs +43 -30
  22. package/dist/engine/index.mjs.map +1 -1
  23. package/dist/file/providers/destination/index.d.ts +1 -1
  24. package/dist/file/providers/destination/index.d.ts.map +1 -1
  25. package/dist/file/providers/destination/index.js +46 -48
  26. package/dist/file/providers/destination/index.js.map +1 -1
  27. package/dist/file/providers/destination/index.mjs +46 -48
  28. package/dist/file/providers/destination/index.mjs.map +1 -1
  29. package/dist/file/providers/destination/utils.d.ts +1 -2
  30. package/dist/file/providers/destination/utils.d.ts.map +1 -1
  31. package/dist/file/providers/destination/utils.js +28 -37
  32. package/dist/file/providers/destination/utils.js.map +1 -1
  33. package/dist/file/providers/destination/utils.mjs +28 -37
  34. package/dist/file/providers/destination/utils.mjs.map +1 -1
  35. package/dist/file/providers/source/index.d.ts +1 -1
  36. package/dist/file/providers/source/index.d.ts.map +1 -1
  37. package/dist/file/providers/source/index.js +85 -61
  38. package/dist/file/providers/source/index.js.map +1 -1
  39. package/dist/file/providers/source/index.mjs +84 -60
  40. package/dist/file/providers/source/index.mjs.map +1 -1
  41. package/dist/strapi/providers/local-source/configuration.d.ts.map +1 -1
  42. package/dist/strapi/providers/local-source/configuration.js +4 -3
  43. package/dist/strapi/providers/local-source/configuration.js.map +1 -1
  44. package/dist/strapi/providers/local-source/configuration.mjs +2 -1
  45. package/dist/strapi/providers/local-source/configuration.mjs.map +1 -1
  46. package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
  47. package/dist/strapi/providers/local-source/index.js +12 -2
  48. package/dist/strapi/providers/local-source/index.js.map +1 -1
  49. package/dist/strapi/providers/local-source/index.mjs +11 -1
  50. package/dist/strapi/providers/local-source/index.mjs.map +1 -1
  51. package/dist/strapi/remote/handlers/push.js +0 -1
  52. package/dist/strapi/remote/handlers/push.js.map +1 -1
  53. package/dist/strapi/remote/handlers/push.mjs +0 -1
  54. package/dist/strapi/remote/handlers/push.mjs.map +1 -1
  55. package/dist/utils/buffered-entry-writer.d.ts +21 -0
  56. package/dist/utils/buffered-entry-writer.d.ts.map +1 -0
  57. package/dist/utils/buffered-entry-writer.js +95 -0
  58. package/dist/utils/buffered-entry-writer.js.map +1 -0
  59. package/dist/utils/buffered-entry-writer.mjs +93 -0
  60. package/dist/utils/buffered-entry-writer.mjs.map +1 -0
  61. package/dist/utils/defer-writable.d.ts +11 -0
  62. package/dist/utils/defer-writable.d.ts.map +1 -0
  63. package/dist/utils/defer-writable.js +106 -0
  64. package/dist/utils/defer-writable.js.map +1 -0
  65. package/dist/utils/defer-writable.mjs +104 -0
  66. package/dist/utils/defer-writable.mjs.map +1 -0
  67. package/dist/utils/esm-deps.d.ts +16 -0
  68. package/dist/utils/esm-deps.d.ts.map +1 -0
  69. package/dist/utils/esm-deps.js +33 -0
  70. package/dist/utils/esm-deps.js.map +1 -0
  71. package/dist/utils/esm-deps.mjs +31 -0
  72. package/dist/utils/esm-deps.mjs.map +1 -0
  73. package/dist/utils/jsonl-write-stream.d.ts +13 -0
  74. package/dist/utils/jsonl-write-stream.d.ts.map +1 -0
  75. package/dist/utils/jsonl-write-stream.js +75 -0
  76. package/dist/utils/jsonl-write-stream.js.map +1 -0
  77. package/dist/utils/jsonl-write-stream.mjs +73 -0
  78. package/dist/utils/jsonl-write-stream.mjs.map +1 -0
  79. package/dist/utils/unknown-error.d.ts +7 -0
  80. package/dist/utils/unknown-error.d.ts.map +1 -0
  81. package/dist/utils/unknown-error.js +30 -0
  82. package/dist/utils/unknown-error.js.map +1 -0
  83. package/dist/utils/unknown-error.mjs +27 -0
  84. package/dist/utils/unknown-error.mjs.map +1 -0
  85. package/package.json +7 -10
@@ -0,0 +1,104 @@
1
+ import { Writable } from 'node:stream';
2
+ import { errorFromUnknown } from './unknown-error.mjs';
3
+
4
+ /**
5
+ * A Writable that can be handed back before its real destination exists.
6
+ * Writes wait until `open` resolves, and ending the stream waits until that destination ends.
7
+ * Destroy waits until that destination closes, so a flush it is already running finishes
8
+ * before a caller that waits for this stream, including rollback, continues.
9
+ * A failure in `open`, or an error from the destination, destroys this stream with that error.
10
+ */ const deferWritable = (open)=>{
11
+ let target;
12
+ // Writable does not call write() again until the previous callback runs, so at most one
13
+ // write can be waiting for the destination.
14
+ let pending;
15
+ const opening = Promise.resolve().then(open).then((destination)=>{
16
+ target = destination;
17
+ // Swallow a destroy error when this proxy is already destroyed. Otherwise an
18
+ // in-flight flush that fails while we are waiting for close becomes unhandled.
19
+ destination.on('error', (error)=>{
20
+ if (!proxy.destroyed) {
21
+ proxy.destroy(error);
22
+ }
23
+ });
24
+ if (proxy.destroyed) {
25
+ return;
26
+ }
27
+ if (pending) {
28
+ const { chunk, encoding, callback } = pending;
29
+ pending = undefined;
30
+ destination.write(chunk, encoding, callback);
31
+ }
32
+ }, (error)=>{
33
+ proxy.destroy(errorFromUnknown(error));
34
+ });
35
+ const proxy = new Writable({
36
+ objectMode: true,
37
+ write (chunk, encoding, callback) {
38
+ if (target) {
39
+ target.write(chunk, encoding, callback);
40
+ return;
41
+ }
42
+ pending = {
43
+ chunk,
44
+ encoding,
45
+ callback
46
+ };
47
+ },
48
+ final (callback) {
49
+ opening.then(()=>{
50
+ if (!target) {
51
+ callback(new Error('Write stream ended before it was ready'));
52
+ return;
53
+ }
54
+ target.end(callback);
55
+ }).catch((error)=>{
56
+ callback(errorFromUnknown(error));
57
+ });
58
+ },
59
+ destroy (error, callback) {
60
+ if (pending) {
61
+ const { callback: pendingCallback } = pending;
62
+ pending = undefined;
63
+ pendingCallback(error ?? new Error('Stream destroyed'));
64
+ }
65
+ let finished = false;
66
+ const finish = ()=>{
67
+ if (finished) {
68
+ return;
69
+ }
70
+ finished = true;
71
+ callback(error);
72
+ };
73
+ // Rollback starts only after pipeline() rejects, and pipeline() waits for this close.
74
+ // Waiting here keeps a destination flush that is already running ahead of that rollback.
75
+ const waitForClose = (stream)=>{
76
+ if (stream.closed) {
77
+ finish();
78
+ return;
79
+ }
80
+ stream.once('close', finish);
81
+ if (!stream.destroyed) {
82
+ stream.destroy(error ?? undefined);
83
+ }
84
+ };
85
+ if (target) {
86
+ waitForClose(target);
87
+ return;
88
+ }
89
+ opening.then(()=>{
90
+ if (target) {
91
+ waitForClose(target);
92
+ return;
93
+ }
94
+ finish();
95
+ }, ()=>{
96
+ finish();
97
+ });
98
+ }
99
+ });
100
+ return proxy;
101
+ };
102
+
103
+ export { deferWritable };
104
+ //# sourceMappingURL=defer-writable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defer-writable.mjs","sources":["../../src/utils/defer-writable.ts"],"sourcesContent":["import { Writable } from 'node:stream';\n\nimport { errorFromUnknown } from './unknown-error';\n\ntype WriteCallback = (error?: Error | null) => void;\n\ninterface PendingWrite {\n chunk: unknown;\n encoding: BufferEncoding;\n callback: WriteCallback;\n}\n\n/**\n * A Writable that can be handed back before its real destination exists.\n * Writes wait until `open` resolves, and ending the stream waits until that destination ends.\n * Destroy waits until that destination closes, so a flush it is already running finishes\n * before a caller that waits for this stream, including rollback, continues.\n * A failure in `open`, or an error from the destination, destroys this stream with that error.\n */\nconst deferWritable = (open: () => Promise<Writable>): Writable => {\n let target: Writable | undefined;\n // Writable does not call write() again until the previous callback runs, so at most one\n // write can be waiting for the destination.\n let pending: PendingWrite | undefined;\n\n const opening = Promise.resolve()\n .then(open)\n .then(\n (destination) => {\n target = destination;\n // Swallow a destroy error when this proxy is already destroyed. Otherwise an\n // in-flight flush that fails while we are waiting for close becomes unhandled.\n destination.on('error', (error: Error) => {\n if (!proxy.destroyed) {\n proxy.destroy(error);\n }\n });\n\n if (proxy.destroyed) {\n return;\n }\n\n if (pending) {\n const { chunk, encoding, callback } = pending;\n pending = undefined;\n destination.write(chunk, encoding, callback);\n }\n },\n (error: unknown) => {\n proxy.destroy(errorFromUnknown(error));\n }\n );\n\n const proxy = new Writable({\n objectMode: true,\n\n write(chunk, encoding, callback) {\n if (target) {\n target.write(chunk, encoding, callback);\n return;\n }\n\n pending = { chunk, encoding, callback };\n },\n\n final(callback) {\n opening\n .then(() => {\n if (!target) {\n callback(new Error('Write stream ended before it was ready'));\n return;\n }\n\n target.end(callback);\n })\n .catch((error: unknown) => {\n callback(errorFromUnknown(error));\n });\n },\n\n destroy(error, callback) {\n if (pending) {\n const { callback: pendingCallback } = pending;\n pending = undefined;\n pendingCallback(error ?? new Error('Stream destroyed'));\n }\n\n let finished = false;\n const finish = () => {\n if (finished) {\n return;\n }\n\n finished = true;\n callback(error);\n };\n\n // Rollback starts only after pipeline() rejects, and pipeline() waits for this close.\n // Waiting here keeps a destination flush that is already running ahead of that rollback.\n const waitForClose = (stream: Writable) => {\n if (stream.closed) {\n finish();\n return;\n }\n\n stream.once('close', finish);\n if (!stream.destroyed) {\n stream.destroy(error ?? undefined);\n }\n };\n\n if (target) {\n waitForClose(target);\n return;\n }\n\n opening.then(\n () => {\n if (target) {\n waitForClose(target);\n return;\n }\n\n finish();\n },\n () => {\n finish();\n }\n );\n },\n });\n\n return proxy;\n};\n\nexport { deferWritable };\n"],"names":["deferWritable","open","target","pending","opening","Promise","resolve","then","destination","on","error","proxy","destroyed","destroy","chunk","encoding","callback","undefined","write","errorFromUnknown","Writable","objectMode","final","Error","end","catch","pendingCallback","finished","finish","waitForClose","stream","closed","once"],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ type StreamChainModule = typeof import('stream-chain');
2
+ type JsonlParserStreamModule = typeof import('stream-chain/jsonl/parserStream.js');
3
+ type JsonlStringerStreamModule = typeof import('stream-chain/jsonl/stringerStream.js');
4
+ export interface StreamDeps {
5
+ chain: StreamChainModule['chainUnchecked'];
6
+ parser: JsonlParserStreamModule['parserStream'];
7
+ stringer: JsonlStringerStreamModule['stringerStream'];
8
+ }
9
+ /**
10
+ * Loads stream-chain via dynamic import (CJS-safe) and caches it.
11
+ * The package is ESM-only, so it cannot be loaded with require() on Node < 20.19 / 22.12
12
+ * or under Jest without --experimental-vm-modules.
13
+ */
14
+ export declare const loadStreamDeps: () => Promise<StreamDeps>;
15
+ export {};
16
+ //# sourceMappingURL=esm-deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esm-deps.d.ts","sourceRoot":"","sources":["../../src/utils/esm-deps.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG,cAAc,cAAc,CAAC,CAAC;AACvD,KAAK,uBAAuB,GAAG,cAAc,oCAAoC,CAAC,CAAC;AACnF,KAAK,yBAAyB,GAAG,cAAc,sCAAsC,CAAC,CAAC;AAEvF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC3C,MAAM,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAC;IAChD,QAAQ,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;CACvD;AAID;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,OAAO,CAAC,UAAU,CA0BnD,CAAC"}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ let cached;
4
+ /**
5
+ * Loads stream-chain via dynamic import (CJS-safe) and caches it.
6
+ * The package is ESM-only, so it cannot be loaded with require() on Node < 20.19 / 22.12
7
+ * or under Jest without --experimental-vm-modules.
8
+ */ const loadStreamDeps = ()=>{
9
+ if (cached !== undefined) {
10
+ return cached;
11
+ }
12
+ // Drop a rejected load so a later transfer can try again. A resolved load stays cached.
13
+ const pending = Promise.all([
14
+ import('stream-chain'),
15
+ // Extension is required: stream-chain's "./*" export does not resolve the extensionless subpath.
16
+ import('stream-chain/jsonl/parserStream.js'),
17
+ import('stream-chain/jsonl/stringerStream.js')
18
+ ]).then(([streamChain, jsonlParser, jsonlStringer])=>({
19
+ chain: streamChain.chainUnchecked,
20
+ parser: jsonlParser.parserStream,
21
+ stringer: jsonlStringer.stringerStream
22
+ })).catch((error)=>{
23
+ if (cached === pending) {
24
+ cached = undefined;
25
+ }
26
+ throw error;
27
+ });
28
+ cached = pending;
29
+ return pending;
30
+ };
31
+
32
+ exports.loadStreamDeps = loadStreamDeps;
33
+ //# sourceMappingURL=esm-deps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esm-deps.js","sources":["../../src/utils/esm-deps.ts"],"sourcesContent":["type StreamChainModule = typeof import('stream-chain');\ntype JsonlParserStreamModule = typeof import('stream-chain/jsonl/parserStream.js');\ntype JsonlStringerStreamModule = typeof import('stream-chain/jsonl/stringerStream.js');\n\nexport interface StreamDeps {\n chain: StreamChainModule['chainUnchecked'];\n parser: JsonlParserStreamModule['parserStream'];\n stringer: JsonlStringerStreamModule['stringerStream'];\n}\n\nlet cached: Promise<StreamDeps> | undefined;\n\n/**\n * Loads stream-chain via dynamic import (CJS-safe) and caches it.\n * The package is ESM-only, so it cannot be loaded with require() on Node < 20.19 / 22.12\n * or under Jest without --experimental-vm-modules.\n */\nexport const loadStreamDeps = (): Promise<StreamDeps> => {\n if (cached !== undefined) {\n return cached;\n }\n\n // Drop a rejected load so a later transfer can try again. A resolved load stays cached.\n const pending = Promise.all([\n import('stream-chain'),\n // Extension is required: stream-chain's \"./*\" export does not resolve the extensionless subpath.\n import('stream-chain/jsonl/parserStream.js'), // eslint-disable-line import/extensions\n import('stream-chain/jsonl/stringerStream.js'), // eslint-disable-line import/extensions\n ])\n .then(([streamChain, jsonlParser, jsonlStringer]) => ({\n chain: streamChain.chainUnchecked,\n parser: jsonlParser.parserStream,\n stringer: jsonlStringer.stringerStream,\n }))\n .catch((error: unknown) => {\n if (cached === pending) {\n cached = undefined;\n }\n throw error;\n });\n\n cached = pending;\n return pending;\n};\n"],"names":["cached","loadStreamDeps","undefined","pending","Promise","all","then","streamChain","jsonlParser","jsonlStringer","chain","chainUnchecked","parser","parserStream","stringer","stringerStream","catch","error"],"mappings":";;AAUA,IAAIA,MAAAA;AAEJ;;;;UAKaC,cAAAA,GAAiB,IAAA;AAC5B,IAAA,IAAID,WAAWE,SAAAA,EAAW;QACxB,OAAOF,MAAAA;AACT,IAAA;;IAGA,MAAMG,OAAAA,GAAUC,OAAAA,CAAQC,GAAG,CAAC;AAC1B,QAAA,OAAO,cAAA,CAAA;;AAEP,QAAA,OAAO,oCAAA,CAAA;AACP,QAAA,OAAO,sCAAA;KACR,CAAA,CACEC,IAAI,CAAC,CAAC,CAACC,aAAaC,WAAAA,EAAaC,aAAAA,CAAc,IAAM;AACpDC,YAAAA,KAAAA,EAAOH,YAAYI,cAAc;AACjCC,YAAAA,MAAAA,EAAQJ,YAAYK,YAAY;AAChCC,YAAAA,QAAAA,EAAUL,cAAcM;SAC1B,CAAA,CAAA,CACCC,KAAK,CAAC,CAACC,KAAAA,GAAAA;AACN,QAAA,IAAIjB,WAAWG,OAAAA,EAAS;YACtBH,MAAAA,GAASE,SAAAA;AACX,QAAA;QACA,MAAMe,KAAAA;AACR,IAAA,CAAA,CAAA;IAEFjB,MAAAA,GAASG,OAAAA;IACT,OAAOA,OAAAA;AACT;;;;"}
@@ -0,0 +1,31 @@
1
+ let cached;
2
+ /**
3
+ * Loads stream-chain via dynamic import (CJS-safe) and caches it.
4
+ * The package is ESM-only, so it cannot be loaded with require() on Node < 20.19 / 22.12
5
+ * or under Jest without --experimental-vm-modules.
6
+ */ const loadStreamDeps = ()=>{
7
+ if (cached !== undefined) {
8
+ return cached;
9
+ }
10
+ // Drop a rejected load so a later transfer can try again. A resolved load stays cached.
11
+ const pending = Promise.all([
12
+ import('stream-chain'),
13
+ // Extension is required: stream-chain's "./*" export does not resolve the extensionless subpath.
14
+ import('stream-chain/jsonl/parserStream.js'),
15
+ import('stream-chain/jsonl/stringerStream.js')
16
+ ]).then(([streamChain, jsonlParser, jsonlStringer])=>({
17
+ chain: streamChain.chainUnchecked,
18
+ parser: jsonlParser.parserStream,
19
+ stringer: jsonlStringer.stringerStream
20
+ })).catch((error)=>{
21
+ if (cached === pending) {
22
+ cached = undefined;
23
+ }
24
+ throw error;
25
+ });
26
+ cached = pending;
27
+ return pending;
28
+ };
29
+
30
+ export { loadStreamDeps };
31
+ //# sourceMappingURL=esm-deps.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esm-deps.mjs","sources":["../../src/utils/esm-deps.ts"],"sourcesContent":["type StreamChainModule = typeof import('stream-chain');\ntype JsonlParserStreamModule = typeof import('stream-chain/jsonl/parserStream.js');\ntype JsonlStringerStreamModule = typeof import('stream-chain/jsonl/stringerStream.js');\n\nexport interface StreamDeps {\n chain: StreamChainModule['chainUnchecked'];\n parser: JsonlParserStreamModule['parserStream'];\n stringer: JsonlStringerStreamModule['stringerStream'];\n}\n\nlet cached: Promise<StreamDeps> | undefined;\n\n/**\n * Loads stream-chain via dynamic import (CJS-safe) and caches it.\n * The package is ESM-only, so it cannot be loaded with require() on Node < 20.19 / 22.12\n * or under Jest without --experimental-vm-modules.\n */\nexport const loadStreamDeps = (): Promise<StreamDeps> => {\n if (cached !== undefined) {\n return cached;\n }\n\n // Drop a rejected load so a later transfer can try again. A resolved load stays cached.\n const pending = Promise.all([\n import('stream-chain'),\n // Extension is required: stream-chain's \"./*\" export does not resolve the extensionless subpath.\n import('stream-chain/jsonl/parserStream.js'), // eslint-disable-line import/extensions\n import('stream-chain/jsonl/stringerStream.js'), // eslint-disable-line import/extensions\n ])\n .then(([streamChain, jsonlParser, jsonlStringer]) => ({\n chain: streamChain.chainUnchecked,\n parser: jsonlParser.parserStream,\n stringer: jsonlStringer.stringerStream,\n }))\n .catch((error: unknown) => {\n if (cached === pending) {\n cached = undefined;\n }\n throw error;\n });\n\n cached = pending;\n return pending;\n};\n"],"names":["cached","loadStreamDeps","undefined","pending","Promise","all","then","streamChain","jsonlParser","jsonlStringer","chain","chainUnchecked","parser","parserStream","stringer","stringerStream","catch","error"],"mappings":"AAUA,IAAIA,MAAAA;AAEJ;;;;UAKaC,cAAAA,GAAiB,IAAA;AAC5B,IAAA,IAAID,WAAWE,SAAAA,EAAW;QACxB,OAAOF,MAAAA;AACT,IAAA;;IAGA,MAAMG,OAAAA,GAAUC,OAAAA,CAAQC,GAAG,CAAC;AAC1B,QAAA,OAAO,cAAA,CAAA;;AAEP,QAAA,OAAO,oCAAA,CAAA;AACP,QAAA,OAAO,sCAAA;KACR,CAAA,CACEC,IAAI,CAAC,CAAC,CAACC,aAAaC,WAAAA,EAAaC,aAAAA,CAAc,IAAM;AACpDC,YAAAA,KAAAA,EAAOH,YAAYI,cAAc;AACjCC,YAAAA,MAAAA,EAAQJ,YAAYK,YAAY;AAChCC,YAAAA,QAAAA,EAAUL,cAAcM;SAC1B,CAAA,CAAA,CACCC,KAAK,CAAC,CAACC,KAAAA,GAAAA;AACN,QAAA,IAAIjB,WAAWG,OAAAA,EAAS;YACtBH,MAAAA,GAASE,SAAAA;AACX,QAAA;QACA,MAAMe,KAAAA;AACR,IAAA,CAAA,CAAA;IAEFjB,MAAAA,GAASG,OAAAA;IACT,OAAOA,OAAAA;AACT;;;;"}
@@ -0,0 +1,13 @@
1
+ import { Writable } from 'node:stream';
2
+ /**
3
+ * Object-mode Writable that serializes each chunk as one JSONL line into `entryStream`.
4
+ *
5
+ * It finishes only once `entryStream` has finished and closed. Entry writers flush their last
6
+ * file when destroyed without an error. When destroyed with an error they discard the buffer that
7
+ * has not started flushing. This stream waits for a flush that is already running to finish
8
+ * before it closes, so a rollback that waits for this stream does not race that write.
9
+ * Any `entryStream` error, including one raised after the input ended, fails this stream.
10
+ */
11
+ declare const createJsonlWriteStream: (entryStream: Writable) => Writable;
12
+ export { createJsonlWriteStream };
13
+ //# sourceMappingURL=jsonl-write-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonl-write-stream.d.ts","sourceRoot":"","sources":["../../src/utils/jsonl-write-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC;;;;;;;;GAQG;AACH,QAAA,MAAM,sBAAsB,GAAI,aAAa,QAAQ,KAAG,QAkEvD,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ var node_stream = require('node:stream');
4
+ var promises = require('node:stream/promises');
5
+ var deferWritable = require('./defer-writable.js');
6
+ var esmDeps = require('./esm-deps.js');
7
+
8
+ /**
9
+ * Object-mode Writable that serializes each chunk as one JSONL line into `entryStream`.
10
+ *
11
+ * It finishes only once `entryStream` has finished and closed. Entry writers flush their last
12
+ * file when destroyed without an error. When destroyed with an error they discard the buffer that
13
+ * has not started flushing. This stream waits for a flush that is already running to finish
14
+ * before it closes, so a rollback that waits for this stream does not race that write.
15
+ * Any `entryStream` error, including one raised after the input ended, fails this stream.
16
+ */ const createJsonlWriteStream = (entryStream)=>{
17
+ return deferWritable.deferWritable(async ()=>{
18
+ const { stringer } = await esmDeps.loadStreamDeps();
19
+ const jsonl = stringer();
20
+ // Registered before pipeline() so the cause is known before pipeline destroys `jsonl`;
21
+ // otherwise the next write fails with ERR_STREAM_DESTROYED instead of the real error.
22
+ let entryError;
23
+ entryStream.once('error', (error)=>{
24
+ entryError = error;
25
+ });
26
+ const written = promises.pipeline(jsonl, entryStream);
27
+ const writer = new node_stream.Writable({
28
+ objectMode: true,
29
+ write (chunk, encoding, callback) {
30
+ if (entryError) {
31
+ callback(entryError);
32
+ return;
33
+ }
34
+ jsonl.write(chunk, encoding, (error)=>{
35
+ callback(error ? entryError ?? error : null);
36
+ });
37
+ },
38
+ final (callback) {
39
+ jsonl.end();
40
+ written.then(()=>callback(), callback);
41
+ },
42
+ destroy (error, callback) {
43
+ // Pass the error through. An error-free destroy flushes the entry buffer and would write
44
+ // a partial file while rollback deletes the export. Wait for the entry stream to close so
45
+ // a flush that is already running finishes before that rollback.
46
+ let finished = false;
47
+ const finish = ()=>{
48
+ if (finished) {
49
+ return;
50
+ }
51
+ finished = true;
52
+ callback(error);
53
+ };
54
+ if (!jsonl.destroyed) {
55
+ jsonl.destroy(error ?? undefined);
56
+ }
57
+ if (entryStream.closed) {
58
+ finish();
59
+ return;
60
+ }
61
+ entryStream.once('close', finish);
62
+ if (!entryStream.destroyed) {
63
+ entryStream.destroy(error ?? undefined);
64
+ }
65
+ }
66
+ });
67
+ written.catch((error)=>{
68
+ writer.destroy(error);
69
+ });
70
+ return writer;
71
+ });
72
+ };
73
+
74
+ exports.createJsonlWriteStream = createJsonlWriteStream;
75
+ //# sourceMappingURL=jsonl-write-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonl-write-stream.js","sources":["../../src/utils/jsonl-write-stream.ts"],"sourcesContent":["import { Writable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\n\nimport { deferWritable } from './defer-writable';\nimport { loadStreamDeps } from './esm-deps';\n\n/**\n * Object-mode Writable that serializes each chunk as one JSONL line into `entryStream`.\n *\n * It finishes only once `entryStream` has finished and closed. Entry writers flush their last\n * file when destroyed without an error. When destroyed with an error they discard the buffer that\n * has not started flushing. This stream waits for a flush that is already running to finish\n * before it closes, so a rollback that waits for this stream does not race that write.\n * Any `entryStream` error, including one raised after the input ended, fails this stream.\n */\nconst createJsonlWriteStream = (entryStream: Writable): Writable => {\n return deferWritable(async () => {\n const { stringer } = await loadStreamDeps();\n const jsonl = stringer();\n\n // Registered before pipeline() so the cause is known before pipeline destroys `jsonl`;\n // otherwise the next write fails with ERR_STREAM_DESTROYED instead of the real error.\n let entryError: Error | undefined;\n entryStream.once('error', (error: Error) => {\n entryError = error;\n });\n\n const written = pipeline(jsonl, entryStream);\n\n const writer = new Writable({\n objectMode: true,\n write(chunk, encoding, callback) {\n if (entryError) {\n callback(entryError);\n return;\n }\n\n jsonl.write(chunk, encoding, (error) => {\n callback(error ? (entryError ?? error) : null);\n });\n },\n final(callback) {\n jsonl.end();\n written.then(() => callback(), callback);\n },\n destroy(error, callback) {\n // Pass the error through. An error-free destroy flushes the entry buffer and would write\n // a partial file while rollback deletes the export. Wait for the entry stream to close so\n // a flush that is already running finishes before that rollback.\n let finished = false;\n const finish = () => {\n if (finished) {\n return;\n }\n\n finished = true;\n callback(error);\n };\n\n if (!jsonl.destroyed) {\n jsonl.destroy(error ?? undefined);\n }\n\n if (entryStream.closed) {\n finish();\n return;\n }\n\n entryStream.once('close', finish);\n if (!entryStream.destroyed) {\n entryStream.destroy(error ?? undefined);\n }\n },\n });\n\n written.catch((error: Error) => {\n writer.destroy(error);\n });\n\n return writer;\n });\n};\n\nexport { createJsonlWriteStream };\n"],"names":["createJsonlWriteStream","entryStream","deferWritable","stringer","loadStreamDeps","jsonl","entryError","once","error","written","pipeline","writer","Writable","objectMode","write","chunk","encoding","callback","final","end","then","destroy","finished","finish","destroyed","undefined","closed","catch"],"mappings":";;;;;;;AAMA;;;;;;;;IASA,MAAMA,yBAAyB,CAACC,WAAAA,GAAAA;AAC9B,IAAA,OAAOC,2BAAAA,CAAc,UAAA;AACnB,QAAA,MAAM,EAAEC,QAAQ,EAAE,GAAG,MAAMC,sBAAAA,EAAAA;AAC3B,QAAA,MAAMC,KAAAA,GAAQF,QAAAA,EAAAA;;;QAId,IAAIG,UAAAA;QACJL,WAAAA,CAAYM,IAAI,CAAC,OAAA,EAAS,CAACC,KAAAA,GAAAA;YACzBF,UAAAA,GAAaE,KAAAA;AACf,QAAA,CAAA,CAAA;QAEA,MAAMC,OAAAA,GAAUC,kBAASL,KAAAA,EAAOJ,WAAAA,CAAAA;QAEhC,MAAMU,MAAAA,GAAS,IAAIC,oBAAAA,CAAS;YAC1BC,UAAAA,EAAY,IAAA;AACZC,YAAAA,KAAAA,CAAAA,CAAMC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAA;AAC7B,gBAAA,IAAIX,UAAAA,EAAY;oBACdW,QAAAA,CAASX,UAAAA,CAAAA;AACT,oBAAA;AACF,gBAAA;AAEAD,gBAAAA,KAAAA,CAAMS,KAAK,CAACC,KAAAA,EAAOC,QAAAA,EAAU,CAACR,KAAAA,GAAAA;oBAC5BS,QAAAA,CAAST,KAAAA,GAASF,cAAcE,KAAAA,GAAS,IAAA,CAAA;AAC3C,gBAAA,CAAA,CAAA;AACF,YAAA,CAAA;AACAU,YAAAA,KAAAA,CAAAA,CAAMD,QAAQ,EAAA;AACZZ,gBAAAA,KAAAA,CAAMc,GAAG,EAAA;gBACTV,OAAAA,CAAQW,IAAI,CAAC,IAAMH,QAAAA,EAAAA,EAAYA,QAAAA,CAAAA;AACjC,YAAA,CAAA;YACAI,OAAAA,CAAAA,CAAQb,KAAK,EAAES,QAAQ,EAAA;;;;AAIrB,gBAAA,IAAIK,QAAAA,GAAW,KAAA;AACf,gBAAA,MAAMC,MAAAA,GAAS,IAAA;AACb,oBAAA,IAAID,QAAAA,EAAU;AACZ,wBAAA;AACF,oBAAA;oBAEAA,QAAAA,GAAW,IAAA;oBACXL,QAAAA,CAAST,KAAAA,CAAAA;AACX,gBAAA,CAAA;gBAEA,IAAI,CAACH,KAAAA,CAAMmB,SAAS,EAAE;oBACpBnB,KAAAA,CAAMgB,OAAO,CAACb,KAAAA,IAASiB,SAAAA,CAAAA;AACzB,gBAAA;gBAEA,IAAIxB,WAAAA,CAAYyB,MAAM,EAAE;AACtBH,oBAAAA,MAAAA,EAAAA;AACA,oBAAA;AACF,gBAAA;gBAEAtB,WAAAA,CAAYM,IAAI,CAAC,OAAA,EAASgB,MAAAA,CAAAA;gBAC1B,IAAI,CAACtB,WAAAA,CAAYuB,SAAS,EAAE;oBAC1BvB,WAAAA,CAAYoB,OAAO,CAACb,KAAAA,IAASiB,SAAAA,CAAAA;AAC/B,gBAAA;AACF,YAAA;AACF,SAAA,CAAA;QAEAhB,OAAAA,CAAQkB,KAAK,CAAC,CAACnB,KAAAA,GAAAA;AACbG,YAAAA,MAAAA,CAAOU,OAAO,CAACb,KAAAA,CAAAA;AACjB,QAAA,CAAA,CAAA;QAEA,OAAOG,MAAAA;AACT,IAAA,CAAA,CAAA;AACF;;;;"}
@@ -0,0 +1,73 @@
1
+ import { Writable } from 'node:stream';
2
+ import { pipeline } from 'node:stream/promises';
3
+ import { deferWritable } from './defer-writable.mjs';
4
+ import { loadStreamDeps } from './esm-deps.mjs';
5
+
6
+ /**
7
+ * Object-mode Writable that serializes each chunk as one JSONL line into `entryStream`.
8
+ *
9
+ * It finishes only once `entryStream` has finished and closed. Entry writers flush their last
10
+ * file when destroyed without an error. When destroyed with an error they discard the buffer that
11
+ * has not started flushing. This stream waits for a flush that is already running to finish
12
+ * before it closes, so a rollback that waits for this stream does not race that write.
13
+ * Any `entryStream` error, including one raised after the input ended, fails this stream.
14
+ */ const createJsonlWriteStream = (entryStream)=>{
15
+ return deferWritable(async ()=>{
16
+ const { stringer } = await loadStreamDeps();
17
+ const jsonl = stringer();
18
+ // Registered before pipeline() so the cause is known before pipeline destroys `jsonl`;
19
+ // otherwise the next write fails with ERR_STREAM_DESTROYED instead of the real error.
20
+ let entryError;
21
+ entryStream.once('error', (error)=>{
22
+ entryError = error;
23
+ });
24
+ const written = pipeline(jsonl, entryStream);
25
+ const writer = new Writable({
26
+ objectMode: true,
27
+ write (chunk, encoding, callback) {
28
+ if (entryError) {
29
+ callback(entryError);
30
+ return;
31
+ }
32
+ jsonl.write(chunk, encoding, (error)=>{
33
+ callback(error ? entryError ?? error : null);
34
+ });
35
+ },
36
+ final (callback) {
37
+ jsonl.end();
38
+ written.then(()=>callback(), callback);
39
+ },
40
+ destroy (error, callback) {
41
+ // Pass the error through. An error-free destroy flushes the entry buffer and would write
42
+ // a partial file while rollback deletes the export. Wait for the entry stream to close so
43
+ // a flush that is already running finishes before that rollback.
44
+ let finished = false;
45
+ const finish = ()=>{
46
+ if (finished) {
47
+ return;
48
+ }
49
+ finished = true;
50
+ callback(error);
51
+ };
52
+ if (!jsonl.destroyed) {
53
+ jsonl.destroy(error ?? undefined);
54
+ }
55
+ if (entryStream.closed) {
56
+ finish();
57
+ return;
58
+ }
59
+ entryStream.once('close', finish);
60
+ if (!entryStream.destroyed) {
61
+ entryStream.destroy(error ?? undefined);
62
+ }
63
+ }
64
+ });
65
+ written.catch((error)=>{
66
+ writer.destroy(error);
67
+ });
68
+ return writer;
69
+ });
70
+ };
71
+
72
+ export { createJsonlWriteStream };
73
+ //# sourceMappingURL=jsonl-write-stream.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonl-write-stream.mjs","sources":["../../src/utils/jsonl-write-stream.ts"],"sourcesContent":["import { Writable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\n\nimport { deferWritable } from './defer-writable';\nimport { loadStreamDeps } from './esm-deps';\n\n/**\n * Object-mode Writable that serializes each chunk as one JSONL line into `entryStream`.\n *\n * It finishes only once `entryStream` has finished and closed. Entry writers flush their last\n * file when destroyed without an error. When destroyed with an error they discard the buffer that\n * has not started flushing. This stream waits for a flush that is already running to finish\n * before it closes, so a rollback that waits for this stream does not race that write.\n * Any `entryStream` error, including one raised after the input ended, fails this stream.\n */\nconst createJsonlWriteStream = (entryStream: Writable): Writable => {\n return deferWritable(async () => {\n const { stringer } = await loadStreamDeps();\n const jsonl = stringer();\n\n // Registered before pipeline() so the cause is known before pipeline destroys `jsonl`;\n // otherwise the next write fails with ERR_STREAM_DESTROYED instead of the real error.\n let entryError: Error | undefined;\n entryStream.once('error', (error: Error) => {\n entryError = error;\n });\n\n const written = pipeline(jsonl, entryStream);\n\n const writer = new Writable({\n objectMode: true,\n write(chunk, encoding, callback) {\n if (entryError) {\n callback(entryError);\n return;\n }\n\n jsonl.write(chunk, encoding, (error) => {\n callback(error ? (entryError ?? error) : null);\n });\n },\n final(callback) {\n jsonl.end();\n written.then(() => callback(), callback);\n },\n destroy(error, callback) {\n // Pass the error through. An error-free destroy flushes the entry buffer and would write\n // a partial file while rollback deletes the export. Wait for the entry stream to close so\n // a flush that is already running finishes before that rollback.\n let finished = false;\n const finish = () => {\n if (finished) {\n return;\n }\n\n finished = true;\n callback(error);\n };\n\n if (!jsonl.destroyed) {\n jsonl.destroy(error ?? undefined);\n }\n\n if (entryStream.closed) {\n finish();\n return;\n }\n\n entryStream.once('close', finish);\n if (!entryStream.destroyed) {\n entryStream.destroy(error ?? undefined);\n }\n },\n });\n\n written.catch((error: Error) => {\n writer.destroy(error);\n });\n\n return writer;\n });\n};\n\nexport { createJsonlWriteStream };\n"],"names":["createJsonlWriteStream","entryStream","deferWritable","stringer","loadStreamDeps","jsonl","entryError","once","error","written","pipeline","writer","Writable","objectMode","write","chunk","encoding","callback","final","end","then","destroy","finished","finish","destroyed","undefined","closed","catch"],"mappings":";;;;;AAMA;;;;;;;;IASA,MAAMA,yBAAyB,CAACC,WAAAA,GAAAA;AAC9B,IAAA,OAAOC,aAAAA,CAAc,UAAA;AACnB,QAAA,MAAM,EAAEC,QAAQ,EAAE,GAAG,MAAMC,cAAAA,EAAAA;AAC3B,QAAA,MAAMC,KAAAA,GAAQF,QAAAA,EAAAA;;;QAId,IAAIG,UAAAA;QACJL,WAAAA,CAAYM,IAAI,CAAC,OAAA,EAAS,CAACC,KAAAA,GAAAA;YACzBF,UAAAA,GAAaE,KAAAA;AACf,QAAA,CAAA,CAAA;QAEA,MAAMC,OAAAA,GAAUC,SAASL,KAAAA,EAAOJ,WAAAA,CAAAA;QAEhC,MAAMU,MAAAA,GAAS,IAAIC,QAAAA,CAAS;YAC1BC,UAAAA,EAAY,IAAA;AACZC,YAAAA,KAAAA,CAAAA,CAAMC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAA;AAC7B,gBAAA,IAAIX,UAAAA,EAAY;oBACdW,QAAAA,CAASX,UAAAA,CAAAA;AACT,oBAAA;AACF,gBAAA;AAEAD,gBAAAA,KAAAA,CAAMS,KAAK,CAACC,KAAAA,EAAOC,QAAAA,EAAU,CAACR,KAAAA,GAAAA;oBAC5BS,QAAAA,CAAST,KAAAA,GAASF,cAAcE,KAAAA,GAAS,IAAA,CAAA;AAC3C,gBAAA,CAAA,CAAA;AACF,YAAA,CAAA;AACAU,YAAAA,KAAAA,CAAAA,CAAMD,QAAQ,EAAA;AACZZ,gBAAAA,KAAAA,CAAMc,GAAG,EAAA;gBACTV,OAAAA,CAAQW,IAAI,CAAC,IAAMH,QAAAA,EAAAA,EAAYA,QAAAA,CAAAA;AACjC,YAAA,CAAA;YACAI,OAAAA,CAAAA,CAAQb,KAAK,EAAES,QAAQ,EAAA;;;;AAIrB,gBAAA,IAAIK,QAAAA,GAAW,KAAA;AACf,gBAAA,MAAMC,MAAAA,GAAS,IAAA;AACb,oBAAA,IAAID,QAAAA,EAAU;AACZ,wBAAA;AACF,oBAAA;oBAEAA,QAAAA,GAAW,IAAA;oBACXL,QAAAA,CAAST,KAAAA,CAAAA;AACX,gBAAA,CAAA;gBAEA,IAAI,CAACH,KAAAA,CAAMmB,SAAS,EAAE;oBACpBnB,KAAAA,CAAMgB,OAAO,CAACb,KAAAA,IAASiB,SAAAA,CAAAA;AACzB,gBAAA;gBAEA,IAAIxB,WAAAA,CAAYyB,MAAM,EAAE;AACtBH,oBAAAA,MAAAA,EAAAA;AACA,oBAAA;AACF,gBAAA;gBAEAtB,WAAAA,CAAYM,IAAI,CAAC,OAAA,EAASgB,MAAAA,CAAAA;gBAC1B,IAAI,CAACtB,WAAAA,CAAYuB,SAAS,EAAE;oBAC1BvB,WAAAA,CAAYoB,OAAO,CAACb,KAAAA,IAASiB,SAAAA,CAAAA;AAC/B,gBAAA;AACF,YAAA;AACF,SAAA,CAAA;QAEAhB,OAAAA,CAAQkB,KAAK,CAAC,CAACnB,KAAAA,GAAAA;AACbG,YAAAA,MAAAA,CAAOU,OAAO,CAACb,KAAAA,CAAAA;AACjB,QAAA,CAAA,CAAA;QAEA,OAAOG,MAAAA;AACT,IAAA,CAAA,CAAA;AACF;;;;"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Preserve an Error. A string, or an object with a string `message`, becomes the message.
3
+ * Anything else becomes a generic Error, because stringifying an object yields "[object Object]".
4
+ */
5
+ export declare const errorFromUnknown: (error: unknown) => Error;
6
+ export declare const errorMessageFromUnknown: (error: unknown) => string;
7
+ //# sourceMappingURL=unknown-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown-error.d.ts","sourceRoot":"","sources":["../../src/utils/unknown-error.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,KAAG,KAMjD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,OAAO,OAAO,KAAG,MAMxD,CAAC"}
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ const messageFromUnknown = (error)=>{
4
+ if (typeof error === 'string') {
5
+ return error;
6
+ }
7
+ if (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string') {
8
+ return error.message;
9
+ }
10
+ return 'Unknown error';
11
+ };
12
+ /**
13
+ * Preserve an Error. A string, or an object with a string `message`, becomes the message.
14
+ * Anything else becomes a generic Error, because stringifying an object yields "[object Object]".
15
+ */ const errorFromUnknown = (error)=>{
16
+ if (error instanceof Error) {
17
+ return error;
18
+ }
19
+ return new Error(messageFromUnknown(error));
20
+ };
21
+ const errorMessageFromUnknown = (error)=>{
22
+ if (error instanceof Error) {
23
+ return error.message;
24
+ }
25
+ return messageFromUnknown(error);
26
+ };
27
+
28
+ exports.errorFromUnknown = errorFromUnknown;
29
+ exports.errorMessageFromUnknown = errorMessageFromUnknown;
30
+ //# sourceMappingURL=unknown-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown-error.js","sources":["../../src/utils/unknown-error.ts"],"sourcesContent":["const messageFromUnknown = (error: unknown): string => {\n if (typeof error === 'string') {\n return error;\n }\n\n if (\n typeof error === 'object' &&\n error !== null &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return 'Unknown error';\n};\n\n/**\n * Preserve an Error. A string, or an object with a string `message`, becomes the message.\n * Anything else becomes a generic Error, because stringifying an object yields \"[object Object]\".\n */\nexport const errorFromUnknown = (error: unknown): Error => {\n if (error instanceof Error) {\n return error;\n }\n\n return new Error(messageFromUnknown(error));\n};\n\nexport const errorMessageFromUnknown = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n\n return messageFromUnknown(error);\n};\n"],"names":["messageFromUnknown","error","message","errorFromUnknown","Error","errorMessageFromUnknown"],"mappings":";;AAAA,MAAMA,qBAAqB,CAACC,KAAAA,GAAAA;IAC1B,IAAI,OAAOA,UAAU,QAAA,EAAU;QAC7B,OAAOA,KAAAA;AACT,IAAA;IAEA,IACE,OAAOA,KAAAA,KAAU,QAAA,IACjBA,KAAAA,KAAU,IAAA,IACV,SAAA,IAAaA,KAAAA,IACb,OAAOA,KAAAA,CAAMC,OAAO,KAAK,QAAA,EACzB;AACA,QAAA,OAAOD,MAAMC,OAAO;AACtB,IAAA;IAEA,OAAO,eAAA;AACT,CAAA;AAEA;;;IAIO,MAAMC,gBAAAA,GAAmB,CAACF,KAAAA,GAAAA;AAC/B,IAAA,IAAIA,iBAAiBG,KAAAA,EAAO;QAC1B,OAAOH,KAAAA;AACT,IAAA;IAEA,OAAO,IAAIG,MAAMJ,kBAAAA,CAAmBC,KAAAA,CAAAA,CAAAA;AACtC;AAEO,MAAMI,0BAA0B,CAACJ,KAAAA,GAAAA;AACtC,IAAA,IAAIA,iBAAiBG,KAAAA,EAAO;AAC1B,QAAA,OAAOH,MAAMC,OAAO;AACtB,IAAA;AAEA,IAAA,OAAOF,kBAAAA,CAAmBC,KAAAA,CAAAA;AAC5B;;;;;"}
@@ -0,0 +1,27 @@
1
+ const messageFromUnknown = (error)=>{
2
+ if (typeof error === 'string') {
3
+ return error;
4
+ }
5
+ if (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string') {
6
+ return error.message;
7
+ }
8
+ return 'Unknown error';
9
+ };
10
+ /**
11
+ * Preserve an Error. A string, or an object with a string `message`, becomes the message.
12
+ * Anything else becomes a generic Error, because stringifying an object yields "[object Object]".
13
+ */ const errorFromUnknown = (error)=>{
14
+ if (error instanceof Error) {
15
+ return error;
16
+ }
17
+ return new Error(messageFromUnknown(error));
18
+ };
19
+ const errorMessageFromUnknown = (error)=>{
20
+ if (error instanceof Error) {
21
+ return error.message;
22
+ }
23
+ return messageFromUnknown(error);
24
+ };
25
+
26
+ export { errorFromUnknown, errorMessageFromUnknown };
27
+ //# sourceMappingURL=unknown-error.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown-error.mjs","sources":["../../src/utils/unknown-error.ts"],"sourcesContent":["const messageFromUnknown = (error: unknown): string => {\n if (typeof error === 'string') {\n return error;\n }\n\n if (\n typeof error === 'object' &&\n error !== null &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return 'Unknown error';\n};\n\n/**\n * Preserve an Error. A string, or an object with a string `message`, becomes the message.\n * Anything else becomes a generic Error, because stringifying an object yields \"[object Object]\".\n */\nexport const errorFromUnknown = (error: unknown): Error => {\n if (error instanceof Error) {\n return error;\n }\n\n return new Error(messageFromUnknown(error));\n};\n\nexport const errorMessageFromUnknown = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n\n return messageFromUnknown(error);\n};\n"],"names":["messageFromUnknown","error","message","errorFromUnknown","Error","errorMessageFromUnknown"],"mappings":"AAAA,MAAMA,qBAAqB,CAACC,KAAAA,GAAAA;IAC1B,IAAI,OAAOA,UAAU,QAAA,EAAU;QAC7B,OAAOA,KAAAA;AACT,IAAA;IAEA,IACE,OAAOA,KAAAA,KAAU,QAAA,IACjBA,KAAAA,KAAU,IAAA,IACV,SAAA,IAAaA,KAAAA,IACb,OAAOA,KAAAA,CAAMC,OAAO,KAAK,QAAA,EACzB;AACA,QAAA,OAAOD,MAAMC,OAAO;AACtB,IAAA;IAEA,OAAO,eAAA;AACT,CAAA;AAEA;;;IAIO,MAAMC,gBAAAA,GAAmB,CAACF,KAAAA,GAAAA;AAC/B,IAAA,IAAIA,iBAAiBG,KAAAA,EAAO;QAC1B,OAAOH,KAAAA;AACT,IAAA;IAEA,OAAO,IAAIG,MAAMJ,kBAAAA,CAAmBC,KAAAA,CAAAA,CAAAA;AACtC;AAEO,MAAMI,0BAA0B,CAACJ,KAAAA,GAAAA;AACtC,IAAA,IAAIA,iBAAiBG,KAAAA,EAAO;AAC1B,QAAA,OAAOH,MAAMC,OAAO;AACtB,IAAA;AAEA,IAAA,OAAOF,kBAAAA,CAAmBC,KAAAA,CAAAA;AAC5B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/data-transfer",
3
- "version": "5.61.0",
3
+ "version": "5.62.0",
4
4
  "description": "Data transfer capabilities for Strapi",
5
5
  "keywords": [
6
6
  "strapi",
@@ -54,9 +54,9 @@
54
54
  "watch": "run -T rollup -c -w"
55
55
  },
56
56
  "dependencies": {
57
- "@strapi/logger": "5.61.0",
58
- "@strapi/types": "5.61.0",
59
- "@strapi/utils": "5.61.0",
57
+ "@strapi/logger": "5.62.0",
58
+ "@strapi/types": "5.62.0",
59
+ "@strapi/utils": "5.62.0",
60
60
  "chalk": "4.1.2",
61
61
  "cli-table3": "0.6.5",
62
62
  "commander": "8.3.0",
@@ -67,14 +67,13 @@
67
67
  "ora": "5.4.1",
68
68
  "resolve-cwd": "3.0.0",
69
69
  "semver": "7.7.4",
70
- "stream-chain": "2.2.5",
71
- "stream-json": "1.9.1",
70
+ "stream-chain": "4.2.6",
72
71
  "tar": "7.5.22",
73
72
  "tar-stream": "2.2.0",
74
73
  "ws": "8.21.2"
75
74
  },
76
75
  "devDependencies": {
77
- "@strapi/database": "5.61.0",
76
+ "@strapi/database": "5.62.0",
78
77
  "@types/fs-extra": "11.0.4",
79
78
  "@types/jest": "29.5.2",
80
79
  "@types/koa": "2.15.2",
@@ -82,8 +81,6 @@
82
81
  "@types/mime-types": "2.1.1",
83
82
  "@types/node": "22.20.0",
84
83
  "@types/semver": "7.5.0",
85
- "@types/stream-chain": "2.0.1",
86
- "@types/stream-json": "1.7.8",
87
84
  "@types/tar-stream": "2.2.2",
88
85
  "@types/ws": "^8.18.1",
89
86
  "jest": "29.6.0",
@@ -92,7 +89,7 @@
92
89
  "rimraf": "6.1.3",
93
90
  "typescript": "5.9.3",
94
91
  "vitest": "catalog:",
95
- "vitest-config": "5.61.0"
92
+ "vitest-config": "5.62.0"
96
93
  },
97
94
  "engines": {
98
95
  "node": ">=22.0.0 <=26.x.x",