@uploadista/client-core 0.0.20-beta.6 → 0.0.20-beta.8
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/dist/index.d.mts +909 -909
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/client/__tests__/flow-inputs.test.ts +43 -11
- package/src/client/create-uploadista-client.ts +27 -13
- package/src/index.ts +2 -2
- package/src/managers/__tests__/upload-manager.test.ts +557 -545
- package/src/testing/index.ts +14 -14
- package/src/testing/mock-service-container.ts +4 -5
- package/src/types/index.ts +2 -2
- package/src/upload/index.ts +1 -1
- package/src/utils/__tests__/flow-inputs-builder.test.ts +5 -8
- package/src/utils/__tests__/input-validation.test.ts +1 -1
- package/src/utils/flow-inputs-builder.ts +2 -1
- package/src/utils/index.ts +1 -1
package/src/testing/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
createMockServiceContainer,
|
|
3
|
+
MockAbortController,
|
|
4
|
+
MockAbortControllerFactory,
|
|
5
|
+
MockBase64Service,
|
|
6
|
+
MockChecksumService,
|
|
7
|
+
MockFileReaderService,
|
|
8
|
+
MockFingerprintService,
|
|
9
|
+
MockHttpClient,
|
|
10
|
+
type MockHttpResponseConfig,
|
|
11
|
+
MockIdGenerationService,
|
|
12
|
+
MockPlatformService,
|
|
13
|
+
MockStorageService,
|
|
14
|
+
MockWebSocket,
|
|
15
|
+
MockWebSocketFactory,
|
|
16
16
|
} from "./mock-service-container";
|
|
@@ -20,10 +20,7 @@ import type {
|
|
|
20
20
|
HttpResponse,
|
|
21
21
|
} from "../services/http-client";
|
|
22
22
|
import type { IdGenerationService } from "../services/id-generation-service";
|
|
23
|
-
import type {
|
|
24
|
-
PlatformService,
|
|
25
|
-
Timeout,
|
|
26
|
-
} from "../services/platform-service";
|
|
23
|
+
import type { PlatformService, Timeout } from "../services/platform-service";
|
|
27
24
|
import type { ServiceContainer } from "../services/service-container";
|
|
28
25
|
import type { StorageService } from "../services/storage-service";
|
|
29
26
|
import type {
|
|
@@ -121,7 +118,9 @@ export class MockHttpClient implements HttpClient {
|
|
|
121
118
|
|
|
122
119
|
// Simulate network delay if configured
|
|
123
120
|
if (config.delay) {
|
|
124
|
-
await new Promise<void>((resolve) =>
|
|
121
|
+
await new Promise<void>((resolve) =>
|
|
122
|
+
setTimeout(() => resolve(), config.delay ?? 0),
|
|
123
|
+
);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
// Create mock headers
|
package/src/types/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export * from "./chunk-metrics";
|
|
2
|
+
export * from "./flow-inputs";
|
|
2
3
|
export * from "./flow-result";
|
|
3
4
|
export * from "./flow-upload-config";
|
|
4
5
|
export * from "./flow-upload-item";
|
|
5
6
|
export * from "./flow-upload-options";
|
|
6
|
-
export * from "./flow-inputs";
|
|
7
7
|
export * from "./multi-flow-upload-options";
|
|
8
8
|
export * from "./multi-flow-upload-state";
|
|
9
9
|
export * from "./performance-insights";
|
|
10
10
|
export * from "./previous-upload";
|
|
11
|
-
export * from "./upload-options";
|
|
12
11
|
export * from "./upload-metrics";
|
|
12
|
+
export * from "./upload-options";
|
|
13
13
|
export * from "./upload-response";
|
|
14
14
|
export * from "./upload-result";
|
|
15
15
|
export * from "./upload-session-metrics";
|
package/src/upload/index.ts
CHANGED
|
@@ -38,7 +38,7 @@ describe("buildFlowInputs", () => {
|
|
|
38
38
|
|
|
39
39
|
it("handles File without name", () => {
|
|
40
40
|
const file = new File(["content"], "", { type: "text/plain" });
|
|
41
|
-
const result = buildFlowInputs({
|
|
41
|
+
const result = buildFlowInputs({ node: file }, storageId);
|
|
42
42
|
|
|
43
43
|
expect(result["node"]).toMatchObject({
|
|
44
44
|
metadata: {
|
|
@@ -49,7 +49,7 @@ describe("buildFlowInputs", () => {
|
|
|
49
49
|
|
|
50
50
|
it("handles File without type", () => {
|
|
51
51
|
const file = new File(["content"], "test.txt");
|
|
52
|
-
const result = buildFlowInputs({
|
|
52
|
+
const result = buildFlowInputs({ node: file }, storageId);
|
|
53
53
|
|
|
54
54
|
expect(result["node"]).toMatchObject({
|
|
55
55
|
metadata: {
|
|
@@ -148,10 +148,7 @@ describe("buildFlowInputs", () => {
|
|
|
148
148
|
it("handles two file inputs", () => {
|
|
149
149
|
const file1 = new File(["content1"], "file1.txt");
|
|
150
150
|
const file2 = new File(["content2"], "file2.txt");
|
|
151
|
-
const result = buildFlowInputs(
|
|
152
|
-
{ "node1": file1, "node2": file2 },
|
|
153
|
-
storageId,
|
|
154
|
-
);
|
|
151
|
+
const result = buildFlowInputs({ node1: file1, node2: file2 }, storageId);
|
|
155
152
|
|
|
156
153
|
expect(result["node1"]).toMatchObject({
|
|
157
154
|
operation: "init",
|
|
@@ -207,7 +204,7 @@ describe("buildFlowInputs", () => {
|
|
|
207
204
|
|
|
208
205
|
it("uses provided storageId for file operations", () => {
|
|
209
206
|
const file = new File(["content"], "test.txt");
|
|
210
|
-
const result = buildFlowInputs({
|
|
207
|
+
const result = buildFlowInputs({ node: file }, "custom-storage");
|
|
211
208
|
|
|
212
209
|
expect(result["node"]).toMatchObject({
|
|
213
210
|
storageId: "custom-storage",
|
|
@@ -216,7 +213,7 @@ describe("buildFlowInputs", () => {
|
|
|
216
213
|
|
|
217
214
|
it("uses provided storageId for URL operations", () => {
|
|
218
215
|
const url = "https://example.com/file.jpg";
|
|
219
|
-
const result = buildFlowInputs({
|
|
216
|
+
const result = buildFlowInputs({ node: url }, "custom-storage");
|
|
220
217
|
|
|
221
218
|
expect(result["node"]).toMatchObject({
|
|
222
219
|
storageId: "custom-storage",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inputTypeRegistry } from "@uploadista/core/flow";
|
|
2
1
|
import type { Flow } from "@uploadista/core/flow";
|
|
2
|
+
import { inputTypeRegistry } from "@uploadista/core/flow";
|
|
3
3
|
import { beforeAll, describe, expect, it } from "vitest";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { UploadistaError } from "../../error";
|
|
@@ -62,7 +62,8 @@ export function buildFlowInputs(
|
|
|
62
62
|
"type" in file && typeof file.type === "string"
|
|
63
63
|
? file.type
|
|
64
64
|
: "application/octet-stream",
|
|
65
|
-
size:
|
|
65
|
+
size:
|
|
66
|
+
"size" in file && typeof file.size === "number" ? file.size : 0,
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
flowInputs[nodeId] = {
|