@transloadit/convex 0.0.1 → 0.0.3
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 +162 -79
- package/dist/client/index.d.ts +92 -63
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +57 -30
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +35 -15
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/apiUtils.d.ts +13 -4
- package/dist/component/apiUtils.d.ts.map +1 -1
- package/dist/component/apiUtils.js +22 -12
- package/dist/component/apiUtils.js.map +1 -1
- package/dist/component/lib.d.ts +69 -45
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +154 -77
- package/dist/component/lib.js.map +1 -1
- package/dist/component/schema.d.ts +9 -9
- package/dist/component/schema.js +3 -3
- package/dist/component/schema.js.map +1 -1
- package/dist/react/index.d.ts +23 -25
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +129 -88
- package/dist/react/index.js.map +1 -1
- package/dist/test/index.d.ts +65 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +8 -0
- package/dist/test/index.js.map +1 -0
- package/package.json +27 -15
- package/src/client/index.ts +72 -35
- package/src/client/types.ts +12 -11
- package/src/component/_generated/component.ts +44 -13
- package/src/component/apiUtils.test.ts +29 -0
- package/src/component/apiUtils.ts +52 -26
- package/src/component/lib.test.ts +73 -3
- package/src/component/lib.ts +220 -97
- package/src/component/schema.ts +3 -3
- package/src/react/index.tsx +193 -150
- package/src/test/index.ts +10 -0
|
@@ -8,9 +8,9 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
8
8
|
templateId?: string | undefined;
|
|
9
9
|
notifyUrl?: string | undefined;
|
|
10
10
|
numExpectedUploadFiles?: number | undefined;
|
|
11
|
-
fields?: any;
|
|
12
|
-
uploads?: any;
|
|
13
|
-
results?: any;
|
|
11
|
+
fields?: Record<string, any> | undefined;
|
|
12
|
+
uploads?: any[] | undefined;
|
|
13
|
+
results?: Record<string, any[]> | undefined;
|
|
14
14
|
error?: any;
|
|
15
15
|
raw?: any;
|
|
16
16
|
userId?: string | undefined;
|
|
@@ -25,23 +25,23 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
25
25
|
templateId: import("convex/values").VString<string | undefined, "optional">;
|
|
26
26
|
notifyUrl: import("convex/values").VString<string | undefined, "optional">;
|
|
27
27
|
numExpectedUploadFiles: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
28
|
-
fields: import("convex/values").VAny<any, "optional", string>;
|
|
29
|
-
uploads: import("convex/values").VAny<any, "
|
|
30
|
-
results: import("convex/values").VAny<any, "optional", string>;
|
|
28
|
+
fields: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
29
|
+
uploads: import("convex/values").VArray<any[] | undefined, import("convex/values").VAny<any, "required", string>, "optional">;
|
|
30
|
+
results: import("convex/values").VRecord<Record<string, any[]> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VArray<any[], import("convex/values").VAny<any, "required", string>, "required">, "optional", string>;
|
|
31
31
|
error: import("convex/values").VAny<any, "optional", string>;
|
|
32
32
|
raw: import("convex/values").VAny<any, "optional", string>;
|
|
33
33
|
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
34
34
|
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
35
35
|
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
36
|
-
}, "required", "assemblyId" | "status" | "ok" | "message" | "templateId" | "notifyUrl" | "numExpectedUploadFiles" | "fields" | "uploads" | "results" | "error" | "raw" | "userId" | "createdAt" | "updatedAt" | `fields.${string}` | `
|
|
36
|
+
}, "required", "assemblyId" | "status" | "ok" | "message" | "templateId" | "notifyUrl" | "numExpectedUploadFiles" | "fields" | "uploads" | "results" | "error" | "raw" | "userId" | "createdAt" | "updatedAt" | `fields.${string}` | `results.${string}` | `error.${string}` | `raw.${string}`>, {
|
|
37
37
|
by_assemblyId: ["assemblyId", "_creationTime"];
|
|
38
38
|
by_status: ["status", "_creationTime"];
|
|
39
39
|
by_userId: ["userId", "_creationTime"];
|
|
40
40
|
}, {}, {}>;
|
|
41
41
|
results: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
42
|
+
name?: string | undefined;
|
|
42
43
|
resultId?: string | undefined;
|
|
43
44
|
sslUrl?: string | undefined;
|
|
44
|
-
name?: string | undefined;
|
|
45
45
|
size?: number | undefined;
|
|
46
46
|
mime?: string | undefined;
|
|
47
47
|
assemblyId: string;
|
|
@@ -58,7 +58,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
58
58
|
mime: import("convex/values").VString<string | undefined, "optional">;
|
|
59
59
|
raw: import("convex/values").VAny<any, "required", string>;
|
|
60
60
|
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
61
|
-
}, "required", "assemblyId" | "raw" | "stepName" | "createdAt" | `raw.${string}` | "resultId" | "sslUrl" | "
|
|
61
|
+
}, "required", "assemblyId" | "raw" | "stepName" | "name" | "createdAt" | `raw.${string}` | "resultId" | "sslUrl" | "size" | "mime">, {
|
|
62
62
|
by_assemblyId: ["assemblyId", "_creationTime"];
|
|
63
63
|
by_assemblyId_and_step: ["assemblyId", "stepName", "_creationTime"];
|
|
64
64
|
}, {}, {}>;
|
package/dist/component/schema.js
CHANGED
|
@@ -16,9 +16,9 @@ export default defineSchema({
|
|
|
16
16
|
templateId: v.optional(v.string()),
|
|
17
17
|
notifyUrl: v.optional(v.string()),
|
|
18
18
|
numExpectedUploadFiles: v.optional(v.number()),
|
|
19
|
-
fields: v.optional(v.any()),
|
|
20
|
-
uploads: v.optional(v.any()),
|
|
21
|
-
results: v.optional(v.any()),
|
|
19
|
+
fields: v.optional(v.record(v.string(), v.any())),
|
|
20
|
+
uploads: v.optional(v.array(v.any())),
|
|
21
|
+
results: v.optional(v.record(v.string(), v.array(v.any()))),
|
|
22
22
|
error: v.optional(v.any()),
|
|
23
23
|
raw: v.optional(v.any()),
|
|
24
24
|
createdAt: v.number(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,mBAAmB;IACnB,iBAAiB;CACT,CAAC;AAIX,eAAe,YAAY,CAAC;IAC1B,UAAU,EAAE,WAAW,CAAC;QACtB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC9B,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACjC,sBAAsB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC9C,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;A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,CAAC,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC/B,CAAC;SACC,KAAK,CAAC,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC;SACtC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC;SAC9B,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,EAAE,WAAW,CAAC;QACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE;QACZ,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;SACC,KAAK,CAAC,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC;SACtC,KAAK,CAAC,wBAAwB,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;CAC/D,CAAC,CAAC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import type { FunctionReference } from "convex/server";
|
|
2
|
-
export type GenerateUploadParamsFn = FunctionReference<"action", "public", {
|
|
3
|
-
templateId?: string;
|
|
4
|
-
steps?: unknown;
|
|
5
|
-
fields?: unknown;
|
|
6
|
-
notifyUrl?: string;
|
|
7
|
-
numExpectedUploadFiles?: number;
|
|
8
|
-
expires?: string;
|
|
9
|
-
additionalParams?: unknown;
|
|
10
|
-
userId?: string;
|
|
11
|
-
}, {
|
|
12
|
-
params: string;
|
|
13
|
-
signature: string;
|
|
14
|
-
url: string;
|
|
15
|
-
}>;
|
|
16
2
|
export type CreateAssemblyFn = FunctionReference<"action", "public", {
|
|
17
3
|
templateId?: string;
|
|
18
4
|
steps?: unknown;
|
|
@@ -34,6 +20,14 @@ export type ListResultsFn = FunctionReference<"query", "public", {
|
|
|
34
20
|
stepName?: string;
|
|
35
21
|
limit?: number;
|
|
36
22
|
}, Array<unknown>>;
|
|
23
|
+
export type RefreshAssemblyFn = FunctionReference<"action", "public", {
|
|
24
|
+
assemblyId: string;
|
|
25
|
+
}, {
|
|
26
|
+
assemblyId: string;
|
|
27
|
+
ok?: string;
|
|
28
|
+
status?: string;
|
|
29
|
+
resultCount: number;
|
|
30
|
+
}>;
|
|
37
31
|
export interface UploadOptions {
|
|
38
32
|
templateId?: string;
|
|
39
33
|
steps?: Record<string, unknown>;
|
|
@@ -49,23 +43,23 @@ export interface UploadState {
|
|
|
49
43
|
progress: number;
|
|
50
44
|
error: Error | null;
|
|
51
45
|
}
|
|
52
|
-
export interface FormUploadOptions extends UploadOptions {
|
|
53
|
-
fileField?: string;
|
|
54
|
-
onProgress?: (progress: number) => void;
|
|
55
|
-
}
|
|
56
46
|
export interface TusUploadOptions extends UploadOptions {
|
|
57
47
|
metadata?: Record<string, string>;
|
|
48
|
+
fieldName?: string;
|
|
58
49
|
chunkSize?: number;
|
|
59
50
|
retryDelays?: number[];
|
|
51
|
+
onShouldRetry?: (error: unknown, retryAttempt: number) => boolean;
|
|
52
|
+
rateLimitRetryDelays?: number[];
|
|
53
|
+
overridePatchMethod?: boolean;
|
|
54
|
+
uploadDataDuringCreation?: boolean;
|
|
55
|
+
storeFingerprintForResuming?: boolean;
|
|
56
|
+
removeFingerprintOnSuccess?: boolean;
|
|
60
57
|
onProgress?: (progress: number) => void;
|
|
58
|
+
onAssemblyCreated?: (assembly: {
|
|
59
|
+
assemblyId: string;
|
|
60
|
+
data: Record<string, unknown>;
|
|
61
|
+
}) => void;
|
|
61
62
|
}
|
|
62
|
-
export declare function useTransloaditUpload(generateUploadParams: GenerateUploadParamsFn): {
|
|
63
|
-
upload: (file: File, options: FormUploadOptions) => Promise<Record<string, unknown>>;
|
|
64
|
-
reset: () => void;
|
|
65
|
-
isUploading: boolean;
|
|
66
|
-
progress: number;
|
|
67
|
-
error: Error | null;
|
|
68
|
-
};
|
|
69
63
|
export declare function useTransloaditTusUpload(createAssembly: CreateAssemblyFn): {
|
|
70
64
|
upload: (file: File, options: TusUploadOptions) => Promise<{
|
|
71
65
|
assemblyId: string;
|
|
@@ -77,6 +71,10 @@ export declare function useTransloaditTusUpload(createAssembly: CreateAssemblyFn
|
|
|
77
71
|
error: Error | null;
|
|
78
72
|
};
|
|
79
73
|
export declare function useAssemblyStatus(getStatus: GetAssemblyStatusFn, assemblyId: string): unknown;
|
|
74
|
+
export declare function useAssemblyStatusWithPolling(getStatus: GetAssemblyStatusFn, refreshAssembly: RefreshAssemblyFn, assemblyId: string, options?: {
|
|
75
|
+
pollIntervalMs?: number;
|
|
76
|
+
stopOnTerminal?: boolean;
|
|
77
|
+
}): unknown;
|
|
80
78
|
export declare function useTransloaditFiles(listResults: ListResultsFn, args: {
|
|
81
79
|
assemblyId: string;
|
|
82
80
|
stepName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE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BASvD,IAAI,WAAW,gBAAgB;oBApEhC,MAAM;cAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;EAwPpD;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,MAAM,WAGnB;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,mBAAmB,EAC9B,eAAe,EAAE,iBAAiB,EAClC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,WAgDhE;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,aAAa,EAC1B,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,yBAGhE"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,87 +1,6 @@
|
|
|
1
1
|
import { useAction, useQuery } from "convex/react";
|
|
2
|
-
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { Upload } from "tus-js-client";
|
|
4
|
-
async function uploadViaForm(file, params, options) {
|
|
5
|
-
const formData = new FormData();
|
|
6
|
-
formData.append("params", params.params);
|
|
7
|
-
formData.append("signature", params.signature);
|
|
8
|
-
formData.append(options.fileField ?? "file", file);
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
const xhr = new XMLHttpRequest();
|
|
11
|
-
xhr.open("POST", params.url, true);
|
|
12
|
-
xhr.upload.onprogress = (event) => {
|
|
13
|
-
if (!event.lengthComputable)
|
|
14
|
-
return;
|
|
15
|
-
const progress = Math.round((event.loaded / event.total) * 100);
|
|
16
|
-
options.onProgress?.(progress);
|
|
17
|
-
};
|
|
18
|
-
xhr.onload = () => {
|
|
19
|
-
try {
|
|
20
|
-
const response = JSON.parse(xhr.responseText);
|
|
21
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
22
|
-
resolve(response);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
reject(new Error(`Transloadit upload failed (${xhr.status}): ${JSON.stringify(response)}`));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
reject(error);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
xhr.onerror = () => {
|
|
33
|
-
reject(new Error("Transloadit upload failed"));
|
|
34
|
-
};
|
|
35
|
-
xhr.send(formData);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export function useTransloaditUpload(generateUploadParams) {
|
|
39
|
-
const generate = useAction(generateUploadParams);
|
|
40
|
-
const [state, setState] = useState({
|
|
41
|
-
isUploading: false,
|
|
42
|
-
progress: 0,
|
|
43
|
-
error: null,
|
|
44
|
-
});
|
|
45
|
-
const upload = useCallback(async (file, options) => {
|
|
46
|
-
setState({ isUploading: true, progress: 0, error: null });
|
|
47
|
-
try {
|
|
48
|
-
const params = await generate({
|
|
49
|
-
templateId: options.templateId,
|
|
50
|
-
steps: options.steps,
|
|
51
|
-
fields: options.fields,
|
|
52
|
-
notifyUrl: options.notifyUrl,
|
|
53
|
-
numExpectedUploadFiles: options.numExpectedUploadFiles,
|
|
54
|
-
expires: options.expires,
|
|
55
|
-
additionalParams: options.additionalParams,
|
|
56
|
-
userId: options.userId,
|
|
57
|
-
});
|
|
58
|
-
const response = await uploadViaForm(file, params, {
|
|
59
|
-
...options,
|
|
60
|
-
onProgress: (progress) => {
|
|
61
|
-
setState((prev) => ({ ...prev, progress }));
|
|
62
|
-
options.onProgress?.(progress);
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
setState({ isUploading: false, progress: 100, error: null });
|
|
66
|
-
return response;
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
const err = error instanceof Error ? error : new Error("Upload failed");
|
|
70
|
-
setState({ isUploading: false, progress: 0, error: err });
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
73
|
-
}, [generate]);
|
|
74
|
-
const reset = useCallback(() => {
|
|
75
|
-
setState({ isUploading: false, progress: 0, error: null });
|
|
76
|
-
}, []);
|
|
77
|
-
return useMemo(() => ({
|
|
78
|
-
upload,
|
|
79
|
-
reset,
|
|
80
|
-
isUploading: state.isUploading,
|
|
81
|
-
progress: state.progress,
|
|
82
|
-
error: state.error,
|
|
83
|
-
}), [state.error, state.isUploading, state.progress, upload, reset]);
|
|
84
|
-
}
|
|
85
4
|
export function useTransloaditTusUpload(createAssembly) {
|
|
86
5
|
const create = useAction(createAssembly);
|
|
87
6
|
const [state, setState] = useState({
|
|
@@ -103,23 +22,66 @@ export function useTransloaditTusUpload(createAssembly) {
|
|
|
103
22
|
userId: options.userId,
|
|
104
23
|
});
|
|
105
24
|
const data = assembly.data;
|
|
25
|
+
options.onAssemblyCreated?.(assembly);
|
|
106
26
|
const tusUrl = (typeof data.tus_url === "string" && data.tus_url) ||
|
|
107
27
|
(typeof data.tusUrl === "string" && data.tusUrl) ||
|
|
108
28
|
"";
|
|
109
29
|
if (!tusUrl) {
|
|
110
30
|
throw new Error("Transloadit response missing tus_url for resumable upload");
|
|
111
31
|
}
|
|
32
|
+
const assemblyUrl = (typeof data.assembly_ssl_url === "string" &&
|
|
33
|
+
data.assembly_ssl_url) ||
|
|
34
|
+
(typeof data.assembly_url === "string" && data.assembly_url) ||
|
|
35
|
+
(typeof data.assemblyUrl === "string" && data.assemblyUrl) ||
|
|
36
|
+
"";
|
|
37
|
+
if (!assemblyUrl) {
|
|
38
|
+
throw new Error("Transloadit response missing assembly_url for resumable upload");
|
|
39
|
+
}
|
|
112
40
|
const metadata = {
|
|
113
41
|
filename: file.name,
|
|
114
|
-
filetype: file.type,
|
|
115
42
|
...options.metadata,
|
|
116
43
|
};
|
|
117
|
-
|
|
118
|
-
|
|
44
|
+
if (file.type) {
|
|
45
|
+
metadata.filetype = file.type;
|
|
46
|
+
}
|
|
47
|
+
if (!metadata.fieldname) {
|
|
48
|
+
metadata.fieldname = options.fieldName ?? "file";
|
|
49
|
+
}
|
|
50
|
+
if (!metadata.assembly_url) {
|
|
51
|
+
metadata.assembly_url = assemblyUrl;
|
|
52
|
+
}
|
|
53
|
+
const getStatus = (error) => error.originalResponse?.getStatus &&
|
|
54
|
+
typeof error.originalResponse.getStatus === "function"
|
|
55
|
+
? error.originalResponse.getStatus()
|
|
56
|
+
: 0;
|
|
57
|
+
const retryDelays = options.retryDelays
|
|
58
|
+
? [...options.retryDelays]
|
|
59
|
+
: [1000, 5000, 15000, 30000];
|
|
60
|
+
const rateLimitRetryDelays = options.rateLimitRetryDelays
|
|
61
|
+
? [...options.rateLimitRetryDelays]
|
|
62
|
+
: [20_000, 40_000, 80_000];
|
|
63
|
+
const shouldRetry = (error) => {
|
|
64
|
+
const status = getStatus(error);
|
|
65
|
+
if (!status)
|
|
66
|
+
return true;
|
|
67
|
+
if (status === 409 || status === 423)
|
|
68
|
+
return true;
|
|
69
|
+
return status < 400 || status >= 500;
|
|
70
|
+
};
|
|
71
|
+
let uploadUrl = null;
|
|
72
|
+
let rateLimitAttempt = 0;
|
|
73
|
+
const runUpload = () => new Promise((resolve, reject) => {
|
|
74
|
+
let uploader;
|
|
75
|
+
const uploadOptions = {
|
|
119
76
|
endpoint: tusUrl,
|
|
120
77
|
metadata,
|
|
121
|
-
|
|
122
|
-
|
|
78
|
+
retryDelays,
|
|
79
|
+
uploadDataDuringCreation: options.uploadDataDuringCreation ?? false,
|
|
80
|
+
onUploadUrlAvailable: () => {
|
|
81
|
+
uploadUrl = uploader.url;
|
|
82
|
+
},
|
|
83
|
+
onShouldRetry: (error, retryAttempt) => options.onShouldRetry?.(error, retryAttempt) ??
|
|
84
|
+
shouldRetry(error),
|
|
123
85
|
onProgress: (bytesUploaded, bytesTotal) => {
|
|
124
86
|
const progress = Math.round((bytesUploaded / bytesTotal) * 100);
|
|
125
87
|
setState((prev) => ({ ...prev, progress }));
|
|
@@ -131,9 +93,44 @@ export function useTransloaditTusUpload(createAssembly) {
|
|
|
131
93
|
onSuccess: () => {
|
|
132
94
|
resolve();
|
|
133
95
|
},
|
|
134
|
-
}
|
|
96
|
+
};
|
|
97
|
+
if (options.chunkSize !== undefined) {
|
|
98
|
+
uploadOptions.chunkSize = options.chunkSize;
|
|
99
|
+
}
|
|
100
|
+
if (uploadUrl) {
|
|
101
|
+
uploadOptions.uploadUrl = uploadUrl;
|
|
102
|
+
}
|
|
103
|
+
if (options.overridePatchMethod !== undefined) {
|
|
104
|
+
uploadOptions.overridePatchMethod = options.overridePatchMethod;
|
|
105
|
+
}
|
|
106
|
+
if (options.storeFingerprintForResuming !== undefined) {
|
|
107
|
+
uploadOptions.storeFingerprintForResuming =
|
|
108
|
+
options.storeFingerprintForResuming;
|
|
109
|
+
}
|
|
110
|
+
if (options.removeFingerprintOnSuccess !== undefined) {
|
|
111
|
+
uploadOptions.removeFingerprintOnSuccess =
|
|
112
|
+
options.removeFingerprintOnSuccess;
|
|
113
|
+
}
|
|
114
|
+
uploader = new Upload(file, uploadOptions);
|
|
135
115
|
uploader.start();
|
|
136
116
|
});
|
|
117
|
+
while (true) {
|
|
118
|
+
try {
|
|
119
|
+
await runUpload();
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const status = getStatus(error);
|
|
124
|
+
if (status === 429 &&
|
|
125
|
+
rateLimitAttempt < rateLimitRetryDelays.length) {
|
|
126
|
+
const delay = rateLimitRetryDelays[rateLimitAttempt] ?? 0;
|
|
127
|
+
rateLimitAttempt += 1;
|
|
128
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
137
134
|
setState({ isUploading: false, progress: 100, error: null });
|
|
138
135
|
return assembly;
|
|
139
136
|
}
|
|
@@ -157,6 +154,50 @@ export function useTransloaditTusUpload(createAssembly) {
|
|
|
157
154
|
export function useAssemblyStatus(getStatus, assemblyId) {
|
|
158
155
|
return useQuery(getStatus, { assemblyId });
|
|
159
156
|
}
|
|
157
|
+
export function useAssemblyStatusWithPolling(getStatus, refreshAssembly, assemblyId, options) {
|
|
158
|
+
const status = useQuery(getStatus, { assemblyId });
|
|
159
|
+
const refresh = useAction(refreshAssembly);
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
if (!assemblyId)
|
|
162
|
+
return;
|
|
163
|
+
const intervalMs = options?.pollIntervalMs ?? 5000;
|
|
164
|
+
if (intervalMs <= 0)
|
|
165
|
+
return;
|
|
166
|
+
const isTerminal = () => {
|
|
167
|
+
if (!options?.stopOnTerminal)
|
|
168
|
+
return false;
|
|
169
|
+
if (!status || typeof status !== "object")
|
|
170
|
+
return false;
|
|
171
|
+
const ok = "ok" in status && typeof status.ok === "string" ? status.ok : "";
|
|
172
|
+
return (ok === "ASSEMBLY_COMPLETED" ||
|
|
173
|
+
ok === "ASSEMBLY_FAILED" ||
|
|
174
|
+
ok === "ASSEMBLY_CANCELED");
|
|
175
|
+
};
|
|
176
|
+
if (isTerminal())
|
|
177
|
+
return;
|
|
178
|
+
let cancelled = false;
|
|
179
|
+
const tick = async () => {
|
|
180
|
+
if (cancelled)
|
|
181
|
+
return;
|
|
182
|
+
await refresh({ assemblyId });
|
|
183
|
+
};
|
|
184
|
+
void tick();
|
|
185
|
+
const id = setInterval(() => {
|
|
186
|
+
void tick();
|
|
187
|
+
}, intervalMs);
|
|
188
|
+
return () => {
|
|
189
|
+
cancelled = true;
|
|
190
|
+
clearInterval(id);
|
|
191
|
+
};
|
|
192
|
+
}, [
|
|
193
|
+
assemblyId,
|
|
194
|
+
options?.pollIntervalMs,
|
|
195
|
+
options?.stopOnTerminal,
|
|
196
|
+
refresh,
|
|
197
|
+
status,
|
|
198
|
+
]);
|
|
199
|
+
return status;
|
|
200
|
+
}
|
|
160
201
|
export function useTransloaditFiles(listResults, args) {
|
|
161
202
|
return useQuery(listResults, args);
|
|
162
203
|
}
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AA0EvC,MAAM,UAAU,uBAAuB,CAAC,cAAgC;IACtE,MAAM,MAAM,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACzC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAc;QAC9C,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,WAAW,CACxB,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC9C,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC;gBAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5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AQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare const modules: Record<string, () => Promise<unknown>>;
|
|
2
|
+
export declare function createTransloaditTest(): import("convex-test").TestConvex<import("convex/server").SchemaDefinition<{
|
|
3
|
+
assemblies: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
4
|
+
status?: string | undefined;
|
|
5
|
+
ok?: string | undefined;
|
|
6
|
+
message?: string | undefined;
|
|
7
|
+
templateId?: string | undefined;
|
|
8
|
+
notifyUrl?: string | undefined;
|
|
9
|
+
numExpectedUploadFiles?: number | undefined;
|
|
10
|
+
fields?: Record<string, any> | undefined;
|
|
11
|
+
uploads?: any[] | undefined;
|
|
12
|
+
results?: Record<string, any[]> | undefined;
|
|
13
|
+
error?: any;
|
|
14
|
+
raw?: any;
|
|
15
|
+
userId?: string | undefined;
|
|
16
|
+
assemblyId: string;
|
|
17
|
+
createdAt: number;
|
|
18
|
+
updatedAt: number;
|
|
19
|
+
}, {
|
|
20
|
+
assemblyId: import("convex/values").VString<string, "required">;
|
|
21
|
+
status: import("convex/values").VString<string | undefined, "optional">;
|
|
22
|
+
ok: import("convex/values").VString<string | undefined, "optional">;
|
|
23
|
+
message: import("convex/values").VString<string | undefined, "optional">;
|
|
24
|
+
templateId: import("convex/values").VString<string | undefined, "optional">;
|
|
25
|
+
notifyUrl: import("convex/values").VString<string | undefined, "optional">;
|
|
26
|
+
numExpectedUploadFiles: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
27
|
+
fields: import("convex/values").VRecord<Record<string, any> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "optional", string>;
|
|
28
|
+
uploads: import("convex/values").VArray<any[] | undefined, import("convex/values").VAny<any, "required", string>, "optional">;
|
|
29
|
+
results: import("convex/values").VRecord<Record<string, any[]> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VArray<any[], import("convex/values").VAny<any, "required", string>, "required">, "optional", string>;
|
|
30
|
+
error: import("convex/values").VAny<any, "optional", string>;
|
|
31
|
+
raw: import("convex/values").VAny<any, "optional", string>;
|
|
32
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
33
|
+
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
34
|
+
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
35
|
+
}, "required", "assemblyId" | "status" | "ok" | "message" | "templateId" | "notifyUrl" | "numExpectedUploadFiles" | "fields" | "uploads" | "results" | "error" | "raw" | "userId" | "createdAt" | "updatedAt" | `fields.${string}` | `results.${string}` | `error.${string}` | `raw.${string}`>, {
|
|
36
|
+
by_assemblyId: ["assemblyId", "_creationTime"];
|
|
37
|
+
by_status: ["status", "_creationTime"];
|
|
38
|
+
by_userId: ["userId", "_creationTime"];
|
|
39
|
+
}, {}, {}>;
|
|
40
|
+
results: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
41
|
+
name?: string | undefined;
|
|
42
|
+
resultId?: string | undefined;
|
|
43
|
+
sslUrl?: string | undefined;
|
|
44
|
+
size?: number | undefined;
|
|
45
|
+
mime?: string | undefined;
|
|
46
|
+
assemblyId: string;
|
|
47
|
+
raw: any;
|
|
48
|
+
stepName: string;
|
|
49
|
+
createdAt: number;
|
|
50
|
+
}, {
|
|
51
|
+
assemblyId: import("convex/values").VString<string, "required">;
|
|
52
|
+
stepName: import("convex/values").VString<string, "required">;
|
|
53
|
+
resultId: import("convex/values").VString<string | undefined, "optional">;
|
|
54
|
+
sslUrl: import("convex/values").VString<string | undefined, "optional">;
|
|
55
|
+
name: import("convex/values").VString<string | undefined, "optional">;
|
|
56
|
+
size: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
57
|
+
mime: import("convex/values").VString<string | undefined, "optional">;
|
|
58
|
+
raw: import("convex/values").VAny<any, "required", string>;
|
|
59
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
60
|
+
}, "required", "assemblyId" | "raw" | "stepName" | "name" | "createdAt" | `raw.${string}` | "resultId" | "sslUrl" | "size" | "mime">, {
|
|
61
|
+
by_assemblyId: ["assemblyId", "_creationTime"];
|
|
62
|
+
by_assemblyId_and_step: ["assemblyId", "stepName", "_creationTime"];
|
|
63
|
+
}, {}, {}>;
|
|
64
|
+
}, boolean>>;
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,wCAA2C,CAAC;AAEhE,wBAAgB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAEpC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
import { convexTest } from "convex-test";
|
|
3
|
+
import schema from "../component/schema.js";
|
|
4
|
+
export const modules = import.meta.glob("../component/**/*.*s");
|
|
5
|
+
export function createTransloaditTest() {
|
|
6
|
+
return convexTest(schema, modules);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAEhE,MAAM,UAAU,qBAAqB;IACnC,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC"}
|