@uploadista/core 0.0.13-beta.5 → 0.0.14

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 (132) hide show
  1. package/README.md +1 -1
  2. package/dist/{checksum-P9C2JlRk.mjs → checksum-BaO9w1gC.mjs} +2 -2
  3. package/dist/{checksum-P9C2JlRk.mjs.map → checksum-BaO9w1gC.mjs.map} +1 -1
  4. package/dist/{checksum-jmKtZ9W8.cjs → checksum-DXCv7Avr.cjs} +1 -1
  5. package/dist/errors/index.cjs +1 -1
  6. package/dist/errors/index.d.cts +2 -2
  7. package/dist/errors/index.d.mts +2 -2
  8. package/dist/errors/index.mjs +1 -1
  9. package/dist/flow/index.cjs +1 -1
  10. package/dist/flow/index.d.cts +6 -6
  11. package/dist/flow/index.d.mts +6 -6
  12. package/dist/flow/index.mjs +1 -1
  13. package/dist/flow-DhuIQwjv.mjs +2 -0
  14. package/dist/flow-DhuIQwjv.mjs.map +1 -0
  15. package/dist/flow-s_AlC4r5.cjs +1 -0
  16. package/dist/{index-BPBI84iT.d.mts → index-3jSHmGwH.d.mts} +2 -2
  17. package/dist/{index-BPBI84iT.d.mts.map → index-3jSHmGwH.d.mts.map} +1 -1
  18. package/dist/{index-CrZopnP9.d.cts → index-5K4oXy67.d.cts} +1065 -426
  19. package/dist/index-5K4oXy67.d.cts.map +1 -0
  20. package/dist/{index-DHt7Ht_J.d.mts → index-BB1v4Ynz.d.mts} +1114 -295
  21. package/dist/index-BB1v4Ynz.d.mts.map +1 -0
  22. package/dist/{index-BteFEg-c.d.mts → index-Bu5i-gcV.d.mts} +2 -2
  23. package/dist/{index-DubOIur4.d.cts.map → index-Bu5i-gcV.d.mts.map} +1 -1
  24. package/dist/{index-DMfADSSJ.d.cts → index-CHGBYDtr.d.cts} +2 -2
  25. package/dist/{index-DMfADSSJ.d.cts.map → index-CHGBYDtr.d.cts.map} +1 -1
  26. package/dist/{index-DubOIur4.d.cts → index-T6MZvUlM.d.cts} +2 -2
  27. package/dist/{index-BteFEg-c.d.mts.map → index-T6MZvUlM.d.cts.map} +1 -1
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.cts +6 -6
  30. package/dist/index.d.mts +6 -6
  31. package/dist/index.mjs +1 -1
  32. package/dist/{stream-limiter-D9rrsvAT.cjs → stream-limiter-BcTJAjs-.cjs} +1 -1
  33. package/dist/{stream-limiter-DFtRZczp.mjs → stream-limiter-D1-sVS5i.mjs} +2 -2
  34. package/dist/{stream-limiter-DFtRZczp.mjs.map → stream-limiter-D1-sVS5i.mjs.map} +1 -1
  35. package/dist/streams/index.cjs +1 -1
  36. package/dist/streams/index.d.cts +2 -2
  37. package/dist/streams/index.d.mts +2 -2
  38. package/dist/streams/index.mjs +1 -1
  39. package/dist/testing/index.cjs +1 -0
  40. package/dist/testing/index.d.cts +110 -0
  41. package/dist/testing/index.d.cts.map +1 -0
  42. package/dist/testing/index.d.mts +110 -0
  43. package/dist/testing/index.d.mts.map +1 -0
  44. package/dist/testing/index.mjs +2 -0
  45. package/dist/testing/index.mjs.map +1 -0
  46. package/dist/types/index.cjs +1 -1
  47. package/dist/types/index.d.cts +5 -5
  48. package/dist/types/index.d.mts +5 -5
  49. package/dist/types/index.mjs +1 -1
  50. package/dist/types-B-EckCWW.cjs +1 -0
  51. package/dist/types-CO-R4pFG.mjs +2 -0
  52. package/dist/types-CO-R4pFG.mjs.map +1 -0
  53. package/dist/upload/index.cjs +1 -1
  54. package/dist/upload/index.d.cts +5 -5
  55. package/dist/upload/index.d.mts +5 -5
  56. package/dist/upload/index.mjs +1 -1
  57. package/dist/{upload-D-eiOIVG.cjs → upload-BwXGQQ26.cjs} +1 -1
  58. package/dist/upload-C_Ew1NMF.mjs +2 -0
  59. package/dist/{upload-DJTptYqV.mjs.map → upload-C_Ew1NMF.mjs.map} +1 -1
  60. package/dist/{uploadista-error-B-n8Kfyh.cjs → uploadista-error-Blmj3lpk.cjs} +5 -1
  61. package/dist/{uploadista-error-CBkvsyZ3.d.mts → uploadista-error-Cpn3uBLO.d.mts} +2 -2
  62. package/dist/uploadista-error-Cpn3uBLO.d.mts.map +1 -0
  63. package/dist/{uploadista-error-9yLWP7TC.d.cts → uploadista-error-DgdQnozn.d.cts} +2 -2
  64. package/dist/uploadista-error-DgdQnozn.d.cts.map +1 -0
  65. package/dist/{uploadista-error-nZ_q-EZy.mjs → uploadista-error-DhNBioWq.mjs} +5 -1
  66. package/dist/uploadista-error-DhNBioWq.mjs.map +1 -0
  67. package/dist/utils/index.cjs +1 -1
  68. package/dist/utils/index.d.cts +2 -2
  69. package/dist/utils/index.d.mts +2 -2
  70. package/dist/utils/index.mjs +1 -1
  71. package/dist/{utils-BicUw_lt.mjs → utils-7gziergl.mjs} +2 -2
  72. package/dist/{utils-BicUw_lt.mjs.map → utils-7gziergl.mjs.map} +1 -1
  73. package/dist/{utils-_StwBtxT.cjs → utils-C_STf6Wl.cjs} +1 -1
  74. package/package.json +14 -6
  75. package/src/errors/uploadista-error.ts +21 -1
  76. package/src/flow/event.ts +28 -4
  77. package/src/flow/flow-server.ts +43 -12
  78. package/src/flow/flow.ts +92 -13
  79. package/src/flow/index.ts +7 -0
  80. package/src/flow/node-types/index.ts +85 -0
  81. package/src/flow/node.ts +49 -7
  82. package/src/flow/nodes/input-node.ts +2 -0
  83. package/src/flow/nodes/storage-node.ts +2 -0
  84. package/src/flow/nodes/transform-node.ts +23 -2
  85. package/src/flow/plugins/credential-provider.ts +1 -1
  86. package/src/flow/plugins/image-ai-plugin.ts +1 -1
  87. package/src/flow/plugins/image-plugin.ts +1 -1
  88. package/src/flow/plugins/video-plugin.ts +1 -1
  89. package/src/flow/plugins/zip-plugin.ts +1 -1
  90. package/src/flow/type-guards.ts +293 -0
  91. package/src/flow/type-registry.ts +345 -0
  92. package/src/flow/types/flow-job.ts +22 -6
  93. package/src/flow/types/flow-types.ts +152 -3
  94. package/src/flow/types/type-utils.ts +14 -3
  95. package/src/testing/index.ts +14 -0
  96. package/src/testing/mock-image-ai-plugin.ts +33 -0
  97. package/src/testing/mock-image-plugin.ts +56 -0
  98. package/src/testing/mock-upload-server.ts +176 -0
  99. package/src/testing/mock-video-plugin.ts +94 -0
  100. package/src/testing/mock-zip-plugin.ts +41 -0
  101. package/src/types/data-store.ts +1 -1
  102. package/{src/errors/__tests__ → tests/errors}/uploadista-error.test.ts +23 -19
  103. package/{src → tests}/flow/edge.test.ts +1 -1
  104. package/tests/flow/flow.test.ts +853 -0
  105. package/tests/flow/node.test.ts +757 -0
  106. package/tests/flow/type-system.test.ts +799 -0
  107. package/{src → tests}/streams/stream-limiter.test.ts +2 -2
  108. package/tests/types/typed-event-emitter.test.ts +282 -0
  109. package/{src → tests}/utils/debounce.test.ts +1 -1
  110. package/{src → tests}/utils/once.test.ts +1 -1
  111. package/tests/utils/test-layers.ts +183 -0
  112. package/{src → tests}/utils/throttle.test.ts +1 -1
  113. package/tsdown.config.ts +1 -0
  114. package/type-tests/flow.test-d.ts +93 -0
  115. package/type-tests/type-utils.test-d.ts +104 -51
  116. package/vitest.config.ts +19 -1
  117. package/dist/flow-DkTE3siV.cjs +0 -1
  118. package/dist/flow-IgE8hj7H.mjs +0 -2
  119. package/dist/flow-IgE8hj7H.mjs.map +0 -1
  120. package/dist/index-CrZopnP9.d.cts.map +0 -1
  121. package/dist/index-DHt7Ht_J.d.mts.map +0 -1
  122. package/dist/types-DGZ892my.mjs +0 -2
  123. package/dist/types-DGZ892my.mjs.map +0 -1
  124. package/dist/types-f08UsX4E.cjs +0 -1
  125. package/dist/upload-DJTptYqV.mjs +0 -2
  126. package/dist/uploadista-error-9yLWP7TC.d.cts.map +0 -1
  127. package/dist/uploadista-error-CBkvsyZ3.d.mts.map +0 -1
  128. package/dist/uploadista-error-nZ_q-EZy.mjs.map +0 -1
  129. /package/dist/{errors-C0zLx77t.mjs → errors-DEFjN-xn.mjs} +0 -0
  130. /package/dist/{index-BtBZHVmz.d.cts → index-C-svZlpj.d.mts} +0 -0
  131. /package/dist/{index-DEHBdV_z.d.mts → index-_wQ5ClJU.d.cts} +0 -0
  132. /package/dist/{streams-CJKKIAwy.mjs → streams-DPU17bYp.mjs} +0 -0
@@ -0,0 +1,41 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { ZipPlugin } from "../flow";
3
+
4
+ /**
5
+ * Mock ZipPlugin implementation for testing.
6
+ *
7
+ * Provides a simple in-memory implementation that creates mock zip data
8
+ * by serializing file metadata as JSON.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { TestZipPlugin } from "@uploadista/core/testing";
13
+ *
14
+ * const program = Effect.gen(function* () {
15
+ * const zipPlugin = yield* ZipPlugin;
16
+ * const zipData = yield* zipPlugin.zip(inputs, options);
17
+ * return zipData;
18
+ * }).pipe(Effect.provide(TestZipPlugin));
19
+ * ```
20
+ */
21
+ export const TestZipPlugin = Layer.succeed(
22
+ ZipPlugin,
23
+ ZipPlugin.of({
24
+ zip: (inputs, options) =>
25
+ Effect.gen(function* () {
26
+ // Create mock zip data
27
+ const files = inputs.map((input) => ({
28
+ id: input.id,
29
+ size: input.data.byteLength,
30
+ }));
31
+
32
+ const zipContent = JSON.stringify({
33
+ zipName: options.zipName,
34
+ includeMetadata: options.includeMetadata,
35
+ files,
36
+ });
37
+
38
+ return new TextEncoder().encode(zipContent);
39
+ }),
40
+ }),
41
+ );
@@ -158,7 +158,7 @@ export type DataStore<TData = unknown> = {
158
158
  onProgress?: (chunkSize: number) => void;
159
159
  },
160
160
  ) => Effect.Effect<number, UploadistaError>;
161
- readonly deleteExpired?: Effect.Effect<number, UploadistaError>;
161
+ readonly deleteExpired?: () => Effect.Effect<number, UploadistaError>;
162
162
  readonly getCapabilities: () => DataStoreCapabilities;
163
163
  readonly validateUploadStrategy: (
164
164
  strategy: UploadStrategy,
@@ -1,4 +1,4 @@
1
- import { Effect } from "effect";
1
+ import { Effect, Exit } from "effect";
2
2
  import { describe, expect, it } from "vitest";
3
3
  import {
4
4
  ERROR_CATALOG,
@@ -6,7 +6,7 @@ import {
6
6
  isUploadistaError,
7
7
  UploadistaError,
8
8
  type UploadistaErrorCode,
9
- } from "../uploadista-error";
9
+ } from "../../src/errors";
10
10
 
11
11
  describe("ERROR_CATALOG", () => {
12
12
  it("should contain all error codes with status and body", () => {
@@ -76,7 +76,6 @@ describe("UploadistaError", () => {
76
76
  expect(error.status).toBe(404);
77
77
  expect(error.status_code).toBe(404); // legacy alias
78
78
  expect(error.body).toBe("File not found");
79
- expect(error.message).toBe("File not found");
80
79
  expect(error.details).toEqual({ fileId: "123" });
81
80
  expect((error as { cause?: unknown }).cause).toBeInstanceOf(Error);
82
81
  });
@@ -173,12 +172,14 @@ describe("UploadistaError", () => {
173
172
  });
174
173
 
175
174
  describe("toFailure", () => {
176
- it("should convert error to failure result", () => {
175
+ it("should convert error to failure result", async () => {
177
176
  const error = UploadistaError.fromCode("FILE_NOT_FOUND");
178
- const result = error.toEffect();
177
+ const effect = error.toEffect();
179
178
 
180
- expect(Effect.isFailure(result)).toBe(true);
181
- expect(Effect.isSuccess(result)).toBe(false);
179
+ const result = await Effect.runPromiseExit(effect);
180
+
181
+ expect(Exit.isFailure(result)).toBe(true);
182
+ expect(Exit.isSuccess(result)).toBe(false);
182
183
  });
183
184
  });
184
185
  });
@@ -216,25 +217,27 @@ describe("isUploadistaError", () => {
216
217
  });
217
218
 
218
219
  describe("httpFailure", () => {
219
- it("should create failure result from error code", () => {
220
- const result = httpFailure("FILE_NOT_FOUND");
220
+ it("should create failure result from error code", async () => {
221
+ const effect = httpFailure("FILE_NOT_FOUND");
222
+ const result = await Effect.runPromiseExit(effect);
221
223
 
222
- expect(Effect.isFailure(result)).toBe(true);
223
- expect(Effect.isSuccess(result)).toBe(false);
224
+ expect(Exit.isFailure(result)).toBe(true);
225
+ expect(Exit.isSuccess(result)).toBe(false);
224
226
  });
225
227
 
226
- it("should allow overriding error properties", () => {
227
- const result = httpFailure("UNKNOWN_ERROR", {
228
+ it("should allow overriding error properties", async () => {
229
+ const effect = httpFailure("UNKNOWN_ERROR", {
228
230
  status: 503,
229
231
  body: "Service unavailable",
230
232
  details: { retryAfter: 60 },
231
233
  });
234
+ const result = await Effect.runPromiseExit(effect);
232
235
 
233
- expect(Effect.isFailure(result)).toBe(true);
234
- expect(Effect.isSuccess(result)).toBe(false);
236
+ expect(Exit.isFailure(result)).toBe(true);
237
+ expect(Exit.isSuccess(result)).toBe(false);
235
238
  });
236
239
 
237
- it("should work with all error codes", () => {
240
+ it("should work with all error codes", async () => {
238
241
  const errorCodes: UploadistaErrorCode[] = [
239
242
  "MISSING_OFFSET",
240
243
  "FLOW_NODE_ERROR",
@@ -242,9 +245,10 @@ describe("httpFailure", () => {
242
245
  ];
243
246
 
244
247
  for (const code of errorCodes) {
245
- const result = httpFailure(code);
246
- expect(Effect.isFailure(result)).toBe(true);
247
- expect(Effect.isSuccess(result)).toBe(false);
248
+ const effect = httpFailure(code);
249
+ const result = await Effect.runPromiseExit(effect);
250
+ expect(Exit.isFailure(result)).toBe(true);
251
+ expect(Exit.isSuccess(result)).toBe(false);
248
252
  }
249
253
  });
250
254
  });
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { createFlowEdge, type FlowEdge } from "./edge";
2
+ import { createFlowEdge, type FlowEdge } from "../../src/flow/edge";
3
3
 
4
4
  describe("FlowEdge", () => {
5
5
  describe("createFlowEdge", () => {