@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.
- package/README.md +1 -1
- package/dist/{checksum-P9C2JlRk.mjs → checksum-BaO9w1gC.mjs} +2 -2
- package/dist/{checksum-P9C2JlRk.mjs.map → checksum-BaO9w1gC.mjs.map} +1 -1
- package/dist/{checksum-jmKtZ9W8.cjs → checksum-DXCv7Avr.cjs} +1 -1
- package/dist/errors/index.cjs +1 -1
- package/dist/errors/index.d.cts +2 -2
- package/dist/errors/index.d.mts +2 -2
- package/dist/errors/index.mjs +1 -1
- package/dist/flow/index.cjs +1 -1
- package/dist/flow/index.d.cts +6 -6
- package/dist/flow/index.d.mts +6 -6
- package/dist/flow/index.mjs +1 -1
- package/dist/flow-DhuIQwjv.mjs +2 -0
- package/dist/flow-DhuIQwjv.mjs.map +1 -0
- package/dist/flow-s_AlC4r5.cjs +1 -0
- package/dist/{index-BPBI84iT.d.mts → index-3jSHmGwH.d.mts} +2 -2
- package/dist/{index-BPBI84iT.d.mts.map → index-3jSHmGwH.d.mts.map} +1 -1
- package/dist/{index-CrZopnP9.d.cts → index-5K4oXy67.d.cts} +1065 -426
- package/dist/index-5K4oXy67.d.cts.map +1 -0
- package/dist/{index-DHt7Ht_J.d.mts → index-BB1v4Ynz.d.mts} +1114 -295
- package/dist/index-BB1v4Ynz.d.mts.map +1 -0
- package/dist/{index-BteFEg-c.d.mts → index-Bu5i-gcV.d.mts} +2 -2
- package/dist/{index-DubOIur4.d.cts.map → index-Bu5i-gcV.d.mts.map} +1 -1
- package/dist/{index-DMfADSSJ.d.cts → index-CHGBYDtr.d.cts} +2 -2
- package/dist/{index-DMfADSSJ.d.cts.map → index-CHGBYDtr.d.cts.map} +1 -1
- package/dist/{index-DubOIur4.d.cts → index-T6MZvUlM.d.cts} +2 -2
- package/dist/{index-BteFEg-c.d.mts.map → index-T6MZvUlM.d.cts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +1 -1
- package/dist/{stream-limiter-D9rrsvAT.cjs → stream-limiter-BcTJAjs-.cjs} +1 -1
- package/dist/{stream-limiter-DFtRZczp.mjs → stream-limiter-D1-sVS5i.mjs} +2 -2
- package/dist/{stream-limiter-DFtRZczp.mjs.map → stream-limiter-D1-sVS5i.mjs.map} +1 -1
- package/dist/streams/index.cjs +1 -1
- package/dist/streams/index.d.cts +2 -2
- package/dist/streams/index.d.mts +2 -2
- package/dist/streams/index.mjs +1 -1
- package/dist/testing/index.cjs +1 -0
- package/dist/testing/index.d.cts +110 -0
- package/dist/testing/index.d.cts.map +1 -0
- package/dist/testing/index.d.mts +110 -0
- package/dist/testing/index.d.mts.map +1 -0
- package/dist/testing/index.mjs +2 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +5 -5
- package/dist/types/index.d.mts +5 -5
- package/dist/types/index.mjs +1 -1
- package/dist/types-B-EckCWW.cjs +1 -0
- package/dist/types-CO-R4pFG.mjs +2 -0
- package/dist/types-CO-R4pFG.mjs.map +1 -0
- package/dist/upload/index.cjs +1 -1
- package/dist/upload/index.d.cts +5 -5
- package/dist/upload/index.d.mts +5 -5
- package/dist/upload/index.mjs +1 -1
- package/dist/{upload-D-eiOIVG.cjs → upload-BwXGQQ26.cjs} +1 -1
- package/dist/upload-C_Ew1NMF.mjs +2 -0
- package/dist/{upload-DJTptYqV.mjs.map → upload-C_Ew1NMF.mjs.map} +1 -1
- package/dist/{uploadista-error-B-n8Kfyh.cjs → uploadista-error-Blmj3lpk.cjs} +5 -1
- package/dist/{uploadista-error-CBkvsyZ3.d.mts → uploadista-error-Cpn3uBLO.d.mts} +2 -2
- package/dist/uploadista-error-Cpn3uBLO.d.mts.map +1 -0
- package/dist/{uploadista-error-9yLWP7TC.d.cts → uploadista-error-DgdQnozn.d.cts} +2 -2
- package/dist/uploadista-error-DgdQnozn.d.cts.map +1 -0
- package/dist/{uploadista-error-nZ_q-EZy.mjs → uploadista-error-DhNBioWq.mjs} +5 -1
- package/dist/uploadista-error-DhNBioWq.mjs.map +1 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/{utils-BicUw_lt.mjs → utils-7gziergl.mjs} +2 -2
- package/dist/{utils-BicUw_lt.mjs.map → utils-7gziergl.mjs.map} +1 -1
- package/dist/{utils-_StwBtxT.cjs → utils-C_STf6Wl.cjs} +1 -1
- package/package.json +14 -6
- package/src/errors/uploadista-error.ts +21 -1
- package/src/flow/event.ts +28 -4
- package/src/flow/flow-server.ts +43 -12
- package/src/flow/flow.ts +92 -13
- package/src/flow/index.ts +7 -0
- package/src/flow/node-types/index.ts +85 -0
- package/src/flow/node.ts +49 -7
- package/src/flow/nodes/input-node.ts +2 -0
- package/src/flow/nodes/storage-node.ts +2 -0
- package/src/flow/nodes/transform-node.ts +23 -2
- package/src/flow/plugins/credential-provider.ts +1 -1
- package/src/flow/plugins/image-ai-plugin.ts +1 -1
- package/src/flow/plugins/image-plugin.ts +1 -1
- package/src/flow/plugins/video-plugin.ts +1 -1
- package/src/flow/plugins/zip-plugin.ts +1 -1
- package/src/flow/type-guards.ts +293 -0
- package/src/flow/type-registry.ts +345 -0
- package/src/flow/types/flow-job.ts +22 -6
- package/src/flow/types/flow-types.ts +152 -3
- package/src/flow/types/type-utils.ts +14 -3
- package/src/testing/index.ts +14 -0
- package/src/testing/mock-image-ai-plugin.ts +33 -0
- package/src/testing/mock-image-plugin.ts +56 -0
- package/src/testing/mock-upload-server.ts +176 -0
- package/src/testing/mock-video-plugin.ts +94 -0
- package/src/testing/mock-zip-plugin.ts +41 -0
- package/src/types/data-store.ts +1 -1
- package/{src/errors/__tests__ → tests/errors}/uploadista-error.test.ts +23 -19
- package/{src → tests}/flow/edge.test.ts +1 -1
- package/tests/flow/flow.test.ts +853 -0
- package/tests/flow/node.test.ts +757 -0
- package/tests/flow/type-system.test.ts +799 -0
- package/{src → tests}/streams/stream-limiter.test.ts +2 -2
- package/tests/types/typed-event-emitter.test.ts +282 -0
- package/{src → tests}/utils/debounce.test.ts +1 -1
- package/{src → tests}/utils/once.test.ts +1 -1
- package/tests/utils/test-layers.ts +183 -0
- package/{src → tests}/utils/throttle.test.ts +1 -1
- package/tsdown.config.ts +1 -0
- package/type-tests/flow.test-d.ts +93 -0
- package/type-tests/type-utils.test-d.ts +104 -51
- package/vitest.config.ts +19 -1
- package/dist/flow-DkTE3siV.cjs +0 -1
- package/dist/flow-IgE8hj7H.mjs +0 -2
- package/dist/flow-IgE8hj7H.mjs.map +0 -1
- package/dist/index-CrZopnP9.d.cts.map +0 -1
- package/dist/index-DHt7Ht_J.d.mts.map +0 -1
- package/dist/types-DGZ892my.mjs +0 -2
- package/dist/types-DGZ892my.mjs.map +0 -1
- package/dist/types-f08UsX4E.cjs +0 -1
- package/dist/upload-DJTptYqV.mjs +0 -2
- package/dist/uploadista-error-9yLWP7TC.d.cts.map +0 -1
- package/dist/uploadista-error-CBkvsyZ3.d.mts.map +0 -1
- package/dist/uploadista-error-nZ_q-EZy.mjs.map +0 -1
- /package/dist/{errors-C0zLx77t.mjs → errors-DEFjN-xn.mjs} +0 -0
- /package/dist/{index-BtBZHVmz.d.cts → index-C-svZlpj.d.mts} +0 -0
- /package/dist/{index-DEHBdV_z.d.mts → index-_wQ5ClJU.d.cts} +0 -0
- /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
|
+
);
|
package/src/types/data-store.ts
CHANGED
|
@@ -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 "
|
|
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
|
|
177
|
+
const effect = error.toEffect();
|
|
179
178
|
|
|
180
|
-
|
|
181
|
-
|
|
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
|
|
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(
|
|
223
|
-
expect(
|
|
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
|
|
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(
|
|
234
|
-
expect(
|
|
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
|
|
246
|
-
|
|
247
|
-
expect(
|
|
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
|
});
|