@liqhtworks/sophon-sdk 0.1.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.
- package/.github/workflows/publish.yml +56 -0
- package/.openapi-generator/FILES +73 -0
- package/.openapi-generator/VERSION +1 -0
- package/.openapi-generator-ignore +23 -0
- package/LICENSE +12 -0
- package/README.md +164 -0
- package/dist/apis/DownloadsApi.d.ts +63 -0
- package/dist/apis/DownloadsApi.js +58 -0
- package/dist/apis/HealthApi.d.ts +92 -0
- package/dist/apis/HealthApi.js +85 -0
- package/dist/apis/JobsApi.d.ts +225 -0
- package/dist/apis/JobsApi.js +245 -0
- package/dist/apis/UploadsApi.d.ts +228 -0
- package/dist/apis/UploadsApi.js +255 -0
- package/dist/apis/WebhooksApi.d.ts +138 -0
- package/dist/apis/WebhooksApi.js +152 -0
- package/dist/apis/index.d.ts +5 -0
- package/dist/apis/index.js +23 -0
- package/dist/esm/apis/DownloadsApi.d.ts +63 -0
- package/dist/esm/apis/DownloadsApi.js +54 -0
- package/dist/esm/apis/HealthApi.d.ts +92 -0
- package/dist/esm/apis/HealthApi.js +81 -0
- package/dist/esm/apis/JobsApi.d.ts +225 -0
- package/dist/esm/apis/JobsApi.js +241 -0
- package/dist/esm/apis/UploadsApi.d.ts +228 -0
- package/dist/esm/apis/UploadsApi.js +251 -0
- package/dist/esm/apis/WebhooksApi.d.ts +138 -0
- package/dist/esm/apis/WebhooksApi.js +148 -0
- package/dist/esm/apis/index.d.ts +5 -0
- package/dist/esm/apis/index.js +7 -0
- package/dist/esm/helpers/index.d.ts +3 -0
- package/dist/esm/helpers/index.js +3 -0
- package/dist/esm/helpers/jobs.d.ts +48 -0
- package/dist/esm/helpers/jobs.js +61 -0
- package/dist/esm/helpers/uploads.d.ts +71 -0
- package/dist/esm/helpers/uploads.js +146 -0
- package/dist/esm/helpers/webhooks.d.ts +23 -0
- package/dist/esm/helpers/webhooks.js +84 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/models/CompleteUploadResponse.d.ts +57 -0
- package/dist/esm/models/CompleteUploadResponse.js +63 -0
- package/dist/esm/models/CreateJobOutputOptions.d.ts +55 -0
- package/dist/esm/models/CreateJobOutputOptions.js +46 -0
- package/dist/esm/models/CreateJobRequest.d.ts +61 -0
- package/dist/esm/models/CreateJobRequest.js +56 -0
- package/dist/esm/models/CreateUploadRequest.d.ts +44 -0
- package/dist/esm/models/CreateUploadRequest.js +51 -0
- package/dist/esm/models/CreateUploadResponse.d.ts +52 -0
- package/dist/esm/models/CreateUploadResponse.js +55 -0
- package/dist/esm/models/CreateWebhookRequest.d.ts +40 -0
- package/dist/esm/models/CreateWebhookRequest.js +45 -0
- package/dist/esm/models/ErrorBody.d.ts +72 -0
- package/dist/esm/models/ErrorBody.js +74 -0
- package/dist/esm/models/ErrorEnvelope.d.ts +33 -0
- package/dist/esm/models/ErrorEnvelope.js +44 -0
- package/dist/esm/models/JobOutputInfo.d.ts +95 -0
- package/dist/esm/models/JobOutputInfo.js +72 -0
- package/dist/esm/models/JobProfile.d.ts +49 -0
- package/dist/esm/models/JobProfile.js +69 -0
- package/dist/esm/models/JobProgress.d.ts +75 -0
- package/dist/esm/models/JobProgress.js +60 -0
- package/dist/esm/models/JobResponse.d.ts +134 -0
- package/dist/esm/models/JobResponse.js +94 -0
- package/dist/esm/models/JobSourceInfo.d.ts +62 -0
- package/dist/esm/models/JobSourceInfo.js +53 -0
- package/dist/esm/models/JobSourceType.d.ts +24 -0
- package/dist/esm/models/JobSourceType.js +44 -0
- package/dist/esm/models/JobStatus.d.ts +31 -0
- package/dist/esm/models/JobStatus.js +51 -0
- package/dist/esm/models/ListJobsResponse.d.ts +45 -0
- package/dist/esm/models/ListJobsResponse.js +50 -0
- package/dist/esm/models/OutputContainer.d.ts +27 -0
- package/dist/esm/models/OutputContainer.js +47 -0
- package/dist/esm/models/ReadyResponse.d.ts +38 -0
- package/dist/esm/models/ReadyResponse.js +45 -0
- package/dist/esm/models/UploadJobSource.d.ts +39 -0
- package/dist/esm/models/UploadJobSource.js +48 -0
- package/dist/esm/models/UploadPartResponse.d.ts +38 -0
- package/dist/esm/models/UploadPartResponse.js +47 -0
- package/dist/esm/models/UploadStatusResponse.d.ts +96 -0
- package/dist/esm/models/UploadStatusResponse.js +80 -0
- package/dist/esm/models/WebhookDeliveryPayload.d.ts +85 -0
- package/dist/esm/models/WebhookDeliveryPayload.js +83 -0
- package/dist/esm/models/WebhookListItem.d.ts +50 -0
- package/dist/esm/models/WebhookListItem.js +55 -0
- package/dist/esm/models/WebhookListResponse.d.ts +33 -0
- package/dist/esm/models/WebhookListResponse.js +44 -0
- package/dist/esm/models/WebhookResponse.d.ts +58 -0
- package/dist/esm/models/WebhookResponse.js +59 -0
- package/dist/esm/models/index.d.ts +25 -0
- package/dist/esm/models/index.js +27 -0
- package/dist/esm/runtime.d.ts +184 -0
- package/dist/esm/runtime.js +348 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/jobs.d.ts +48 -0
- package/dist/helpers/jobs.js +67 -0
- package/dist/helpers/uploads.d.ts +71 -0
- package/dist/helpers/uploads.js +149 -0
- package/dist/helpers/webhooks.d.ts +23 -0
- package/dist/helpers/webhooks.js +89 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +22 -0
- package/dist/models/CompleteUploadResponse.d.ts +57 -0
- package/dist/models/CompleteUploadResponse.js +71 -0
- package/dist/models/CreateJobOutputOptions.d.ts +55 -0
- package/dist/models/CreateJobOutputOptions.js +53 -0
- package/dist/models/CreateJobRequest.d.ts +61 -0
- package/dist/models/CreateJobRequest.js +63 -0
- package/dist/models/CreateUploadRequest.d.ts +44 -0
- package/dist/models/CreateUploadRequest.js +58 -0
- package/dist/models/CreateUploadResponse.d.ts +52 -0
- package/dist/models/CreateUploadResponse.js +62 -0
- package/dist/models/CreateWebhookRequest.d.ts +40 -0
- package/dist/models/CreateWebhookRequest.js +52 -0
- package/dist/models/ErrorBody.d.ts +72 -0
- package/dist/models/ErrorBody.js +82 -0
- package/dist/models/ErrorEnvelope.d.ts +33 -0
- package/dist/models/ErrorEnvelope.js +51 -0
- package/dist/models/JobOutputInfo.d.ts +95 -0
- package/dist/models/JobOutputInfo.js +80 -0
- package/dist/models/JobProfile.d.ts +49 -0
- package/dist/models/JobProfile.js +77 -0
- package/dist/models/JobProgress.d.ts +75 -0
- package/dist/models/JobProgress.js +67 -0
- package/dist/models/JobResponse.d.ts +134 -0
- package/dist/models/JobResponse.js +101 -0
- package/dist/models/JobSourceInfo.d.ts +62 -0
- package/dist/models/JobSourceInfo.js +60 -0
- package/dist/models/JobSourceType.d.ts +24 -0
- package/dist/models/JobSourceType.js +52 -0
- package/dist/models/JobStatus.d.ts +31 -0
- package/dist/models/JobStatus.js +59 -0
- package/dist/models/ListJobsResponse.d.ts +45 -0
- package/dist/models/ListJobsResponse.js +57 -0
- package/dist/models/OutputContainer.d.ts +27 -0
- package/dist/models/OutputContainer.js +55 -0
- package/dist/models/ReadyResponse.d.ts +38 -0
- package/dist/models/ReadyResponse.js +52 -0
- package/dist/models/UploadJobSource.d.ts +39 -0
- package/dist/models/UploadJobSource.js +55 -0
- package/dist/models/UploadPartResponse.d.ts +38 -0
- package/dist/models/UploadPartResponse.js +54 -0
- package/dist/models/UploadStatusResponse.d.ts +96 -0
- package/dist/models/UploadStatusResponse.js +88 -0
- package/dist/models/WebhookDeliveryPayload.d.ts +85 -0
- package/dist/models/WebhookDeliveryPayload.js +91 -0
- package/dist/models/WebhookListItem.d.ts +50 -0
- package/dist/models/WebhookListItem.js +62 -0
- package/dist/models/WebhookListResponse.d.ts +33 -0
- package/dist/models/WebhookListResponse.js +51 -0
- package/dist/models/WebhookResponse.d.ts +58 -0
- package/dist/models/WebhookResponse.js +66 -0
- package/dist/models/index.d.ts +25 -0
- package/dist/models/index.js +43 -0
- package/dist/runtime.d.ts +184 -0
- package/dist/runtime.js +364 -0
- package/docs/CompleteUploadResponse.md +40 -0
- package/docs/CreateJobOutputOptions.md +39 -0
- package/docs/CreateJobRequest.md +42 -0
- package/docs/CreateUploadRequest.md +38 -0
- package/docs/CreateUploadResponse.md +40 -0
- package/docs/CreateWebhookRequest.md +36 -0
- package/docs/DownloadsApi.md +78 -0
- package/docs/ErrorBody.md +40 -0
- package/docs/ErrorEnvelope.md +34 -0
- package/docs/HealthApi.md +129 -0
- package/docs/JobOutputInfo.md +50 -0
- package/docs/JobProfile.md +33 -0
- package/docs/JobProgress.md +48 -0
- package/docs/JobResponse.md +62 -0
- package/docs/JobSourceInfo.md +44 -0
- package/docs/JobSourceType.md +33 -0
- package/docs/JobStatus.md +33 -0
- package/docs/JobsApi.md +407 -0
- package/docs/ListJobsResponse.md +38 -0
- package/docs/OutputContainer.md +33 -0
- package/docs/ReadyResponse.md +36 -0
- package/docs/UploadJobSource.md +37 -0
- package/docs/UploadPartResponse.md +36 -0
- package/docs/UploadStatusResponse.md +50 -0
- package/docs/UploadsApi.md +415 -0
- package/docs/WebhookDeliveryPayload.md +45 -0
- package/docs/WebhookEventsApi.md +91 -0
- package/docs/WebhookListItem.md +40 -0
- package/docs/WebhookListResponse.md +34 -0
- package/docs/WebhookResponse.md +42 -0
- package/docs/WebhooksApi.md +235 -0
- package/package.json +24 -0
- package/src/apis/DownloadsApi.ts +114 -0
- package/src/apis/HealthApi.ts +160 -0
- package/src/apis/JobsApi.ts +491 -0
- package/src/apis/UploadsApi.ts +522 -0
- package/src/apis/WebhooksApi.ts +298 -0
- package/src/apis/index.ts +7 -0
- package/src/helpers/index.ts +3 -0
- package/src/helpers/jobs.ts +112 -0
- package/src/helpers/uploads.ts +243 -0
- package/src/helpers/webhooks.ts +134 -0
- package/src/index.ts +7 -0
- package/src/models/CompleteUploadResponse.ts +102 -0
- package/src/models/CreateJobOutputOptions.ts +101 -0
- package/src/models/CreateJobRequest.ts +123 -0
- package/src/models/CreateUploadRequest.ts +84 -0
- package/src/models/CreateUploadResponse.ts +95 -0
- package/src/models/CreateWebhookRequest.ts +76 -0
- package/src/models/ErrorBody.ts +116 -0
- package/src/models/ErrorEnvelope.ts +74 -0
- package/src/models/JobOutputInfo.ts +149 -0
- package/src/models/JobProfile.ts +76 -0
- package/src/models/JobProgress.ts +133 -0
- package/src/models/JobResponse.ts +236 -0
- package/src/models/JobSourceInfo.ts +106 -0
- package/src/models/JobSourceType.ts +51 -0
- package/src/models/JobStatus.ts +58 -0
- package/src/models/ListJobsResponse.ts +91 -0
- package/src/models/OutputContainer.ts +54 -0
- package/src/models/ReadyResponse.ts +74 -0
- package/src/models/UploadJobSource.ts +85 -0
- package/src/models/UploadPartResponse.ts +75 -0
- package/src/models/UploadStatusResponse.ts +153 -0
- package/src/models/WebhookDeliveryPayload.ts +134 -0
- package/src/models/WebhookListItem.ts +93 -0
- package/src/models/WebhookListResponse.ts +74 -0
- package/src/models/WebhookResponse.ts +104 -0
- package/src/models/index.ts +27 -0
- package/src/runtime.ts +450 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Upload orchestration on top of the generated UploadsApi.
|
|
3
|
+
//
|
|
4
|
+
// The generated SDK exposes createUpload / uploadPart / completeUpload as
|
|
5
|
+
// separate calls; this wrapper handles chunk slicing, bounded concurrency,
|
|
6
|
+
// per-part retry, resume against existing sessions, and progress reporting.
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.uploadFile = uploadFile;
|
|
9
|
+
async function uploadFile(params) {
|
|
10
|
+
const { api, source, fileName, mimeType, uploadId: resumeId, concurrency = 4, retries = 3, retryBaseMs = 500, idempotencyKey = randomIdempotencyKey(), onProgress, signal, } = params;
|
|
11
|
+
if (concurrency < 1)
|
|
12
|
+
throw new RangeError("concurrency must be >= 1");
|
|
13
|
+
if (retries < 0)
|
|
14
|
+
throw new RangeError("retries must be >= 0");
|
|
15
|
+
let uploadId;
|
|
16
|
+
let chunkSize;
|
|
17
|
+
let totalChunks;
|
|
18
|
+
let alreadyReceived = new Set();
|
|
19
|
+
if (resumeId) {
|
|
20
|
+
const status = await api.getUpload({ id: resumeId });
|
|
21
|
+
uploadId = status.id;
|
|
22
|
+
totalChunks = status.total_chunks;
|
|
23
|
+
alreadyReceived = new Set(status.received_chunks);
|
|
24
|
+
// Derive chunk size from file size / totalChunks. Last chunk may be smaller;
|
|
25
|
+
// we only need the head size to slice, so use ceil.
|
|
26
|
+
chunkSize = Math.ceil(source.size / totalChunks);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const session = await api.createUpload({
|
|
30
|
+
createUploadRequest: {
|
|
31
|
+
file_name: fileName,
|
|
32
|
+
file_size: source.size,
|
|
33
|
+
mime_type: mimeType,
|
|
34
|
+
},
|
|
35
|
+
idempotencyKey,
|
|
36
|
+
});
|
|
37
|
+
uploadId = session.id;
|
|
38
|
+
chunkSize = session.chunk_size;
|
|
39
|
+
totalChunks = session.total_chunks;
|
|
40
|
+
}
|
|
41
|
+
const progress = {
|
|
42
|
+
bytesUploaded: 0,
|
|
43
|
+
bytesTotal: source.size,
|
|
44
|
+
partsDone: 0,
|
|
45
|
+
partsTotal: totalChunks,
|
|
46
|
+
};
|
|
47
|
+
// Seed progress from any resumed parts so callers see accurate counts.
|
|
48
|
+
for (const part of alreadyReceived) {
|
|
49
|
+
progress.partsDone += 1;
|
|
50
|
+
progress.bytesUploaded += partBytes(source.size, chunkSize, totalChunks, part);
|
|
51
|
+
}
|
|
52
|
+
onProgress?.({ ...progress });
|
|
53
|
+
const pending = [];
|
|
54
|
+
for (let i = 0; i < totalChunks; i++) {
|
|
55
|
+
if (!alreadyReceived.has(i))
|
|
56
|
+
pending.push(i);
|
|
57
|
+
}
|
|
58
|
+
let nextIdx = 0;
|
|
59
|
+
const workers = [];
|
|
60
|
+
for (let w = 0; w < Math.min(concurrency, pending.length); w++) {
|
|
61
|
+
workers.push((async () => {
|
|
62
|
+
while (true) {
|
|
63
|
+
if (signal?.aborted)
|
|
64
|
+
throw new DOMException("Aborted", "AbortError");
|
|
65
|
+
const idx = nextIdx++;
|
|
66
|
+
if (idx >= pending.length)
|
|
67
|
+
return;
|
|
68
|
+
const partNumber = pending[idx];
|
|
69
|
+
const start = partNumber * chunkSize;
|
|
70
|
+
const end = Math.min(start + chunkSize, source.size);
|
|
71
|
+
const chunk = source.slice(start, end, "application/octet-stream");
|
|
72
|
+
await withRetry(() => api.uploadPart({ id: uploadId, partNumber, body: chunk }), retries, retryBaseMs, signal);
|
|
73
|
+
progress.partsDone += 1;
|
|
74
|
+
progress.bytesUploaded += chunk.size;
|
|
75
|
+
onProgress?.({ ...progress });
|
|
76
|
+
}
|
|
77
|
+
})());
|
|
78
|
+
}
|
|
79
|
+
await Promise.all(workers);
|
|
80
|
+
const done = await api.completeUpload({ id: uploadId, idempotencyKey });
|
|
81
|
+
return { uploadId: done.id, sha256: done.sha256, bytes: done.bytes };
|
|
82
|
+
}
|
|
83
|
+
function partBytes(total, chunkSize, totalChunks, part) {
|
|
84
|
+
if (part < totalChunks - 1)
|
|
85
|
+
return chunkSize;
|
|
86
|
+
return total - chunkSize * (totalChunks - 1);
|
|
87
|
+
}
|
|
88
|
+
async function withRetry(fn, retries, baseMs, signal) {
|
|
89
|
+
let attempt = 0;
|
|
90
|
+
// One initial try + `retries` follow-ups.
|
|
91
|
+
while (true) {
|
|
92
|
+
try {
|
|
93
|
+
return await fn();
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (signal?.aborted)
|
|
97
|
+
throw err;
|
|
98
|
+
if (attempt >= retries || !isRetryable(err))
|
|
99
|
+
throw err;
|
|
100
|
+
const delay = baseMs * 2 ** attempt + Math.floor(Math.random() * baseMs);
|
|
101
|
+
await sleep(delay, signal);
|
|
102
|
+
attempt += 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function isRetryable(err) {
|
|
107
|
+
if (err instanceof TypeError)
|
|
108
|
+
return true; // network-level fetch errors
|
|
109
|
+
const maybeResponse = err.response;
|
|
110
|
+
const status = maybeResponse?.status;
|
|
111
|
+
if (typeof status !== "number")
|
|
112
|
+
return false;
|
|
113
|
+
return status === 408 || status === 429 || (status >= 500 && status < 600);
|
|
114
|
+
}
|
|
115
|
+
function sleep(ms, signal) {
|
|
116
|
+
return new Promise((resolve, reject) => {
|
|
117
|
+
const t = setTimeout(() => {
|
|
118
|
+
signal?.removeEventListener("abort", onAbort);
|
|
119
|
+
resolve();
|
|
120
|
+
}, ms);
|
|
121
|
+
const onAbort = () => {
|
|
122
|
+
clearTimeout(t);
|
|
123
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
124
|
+
};
|
|
125
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function randomIdempotencyKey() {
|
|
129
|
+
// Single capture of the global `crypto` object so the TS narrowing from
|
|
130
|
+
// one `in` check doesn't bleed into the next branch.
|
|
131
|
+
const c = typeof crypto !== "undefined"
|
|
132
|
+
? crypto
|
|
133
|
+
: undefined;
|
|
134
|
+
if (c?.randomUUID)
|
|
135
|
+
return c.randomUUID();
|
|
136
|
+
// Fallback for very old runtimes without crypto.randomUUID. Web Crypto's
|
|
137
|
+
// getRandomValues has been in Node since 15 and all evergreen browsers, so
|
|
138
|
+
// this almost never runs — but we avoid Math.random so idempotency keys
|
|
139
|
+
// stay uncorrelated across callers even on ancient targets.
|
|
140
|
+
if (c?.getRandomValues) {
|
|
141
|
+
const bytes = new Uint8Array(16);
|
|
142
|
+
c.getRandomValues(bytes);
|
|
143
|
+
let hex = "";
|
|
144
|
+
for (const b of bytes)
|
|
145
|
+
hex += b.toString(16).padStart(2, "0");
|
|
146
|
+
return `idem_${hex}`;
|
|
147
|
+
}
|
|
148
|
+
throw new Error("crypto API unavailable; pass an explicit idempotencyKey to uploadFile");
|
|
149
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface VerifyWebhookSignatureParams {
|
|
2
|
+
/** Raw HTTP body exactly as received, before any JSON parsing. */
|
|
3
|
+
rawBody: string | Uint8Array;
|
|
4
|
+
/** Value of `X-Turbo-Signature-256`, e.g. `"sha256=abc..."`. */
|
|
5
|
+
signatureHeader: string | null | undefined;
|
|
6
|
+
/** Value of `X-Turbo-Timestamp`. */
|
|
7
|
+
timestampHeader: string | null | undefined;
|
|
8
|
+
/** Webhook secret returned by `POST /v1/webhooks`. */
|
|
9
|
+
secret: string;
|
|
10
|
+
/** Maximum acceptable clock skew in ms. Default 5 min. Set 0 to disable. */
|
|
11
|
+
replayWindowMs?: number;
|
|
12
|
+
/** Override "now" for deterministic tests. */
|
|
13
|
+
now?: () => number;
|
|
14
|
+
}
|
|
15
|
+
export declare class WebhookSignatureError extends Error {
|
|
16
|
+
readonly reason: "missing_signature" | "missing_timestamp" | "invalid_timestamp" | "replay_window_exceeded" | "bad_prefix" | "bad_signature_encoding" | "signature_mismatch";
|
|
17
|
+
constructor(reason: WebhookSignatureError["reason"], message?: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Throws `WebhookSignatureError` if the delivery is not authentic. Returns
|
|
21
|
+
* a resolved promise on success.
|
|
22
|
+
*/
|
|
23
|
+
export declare function verifyWebhookSignature(params: VerifyWebhookSignatureParams): Promise<void>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Webhook signature verification for inbound terminal-job deliveries.
|
|
3
|
+
//
|
|
4
|
+
// SOPHON signs each delivery with HMAC-SHA256 over `"{timestamp}.{raw_body}"`
|
|
5
|
+
// using the per-webhook secret. The hex digest is sent as
|
|
6
|
+
// `X-Turbo-Signature-256: sha256=<hex>`.
|
|
7
|
+
//
|
|
8
|
+
// Isomorphic: uses the Web Crypto API (`crypto.subtle`), available globally in
|
|
9
|
+
// Node 18+ and modern browsers. No Node-specific imports.
|
|
10
|
+
//
|
|
11
|
+
// Consumers call `verifyWebhookSignature` with the RAW request body (string or
|
|
12
|
+
// Uint8Array — NOT a parsed JSON object), the signature header, the timestamp
|
|
13
|
+
// header, and the webhook secret. The helper does a constant-time comparison
|
|
14
|
+
// and enforces a replay window by default.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.WebhookSignatureError = void 0;
|
|
17
|
+
exports.verifyWebhookSignature = verifyWebhookSignature;
|
|
18
|
+
class WebhookSignatureError extends Error {
|
|
19
|
+
reason;
|
|
20
|
+
constructor(reason, message) {
|
|
21
|
+
super(message ?? reason);
|
|
22
|
+
this.name = "WebhookSignatureError";
|
|
23
|
+
this.reason = reason;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.WebhookSignatureError = WebhookSignatureError;
|
|
27
|
+
/**
|
|
28
|
+
* Throws `WebhookSignatureError` if the delivery is not authentic. Returns
|
|
29
|
+
* a resolved promise on success.
|
|
30
|
+
*/
|
|
31
|
+
async function verifyWebhookSignature(params) {
|
|
32
|
+
const { rawBody, signatureHeader, timestampHeader, secret, replayWindowMs = 5 * 60 * 1000, now = Date.now, } = params;
|
|
33
|
+
if (!signatureHeader)
|
|
34
|
+
throw new WebhookSignatureError("missing_signature");
|
|
35
|
+
if (!timestampHeader)
|
|
36
|
+
throw new WebhookSignatureError("missing_timestamp");
|
|
37
|
+
const deliveredTs = Date.parse(timestampHeader);
|
|
38
|
+
if (Number.isNaN(deliveredTs)) {
|
|
39
|
+
throw new WebhookSignatureError("invalid_timestamp");
|
|
40
|
+
}
|
|
41
|
+
if (replayWindowMs > 0) {
|
|
42
|
+
const drift = Math.abs(now() - deliveredTs);
|
|
43
|
+
if (drift > replayWindowMs) {
|
|
44
|
+
throw new WebhookSignatureError("replay_window_exceeded");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!signatureHeader.startsWith("sha256=")) {
|
|
48
|
+
throw new WebhookSignatureError("bad_prefix");
|
|
49
|
+
}
|
|
50
|
+
const deliveredHex = signatureHeader.slice("sha256=".length).trim();
|
|
51
|
+
const delivered = hexToBytes(deliveredHex);
|
|
52
|
+
if (!delivered) {
|
|
53
|
+
throw new WebhookSignatureError("bad_signature_encoding");
|
|
54
|
+
}
|
|
55
|
+
const bodyBytes = typeof rawBody === "string" ? new TextEncoder().encode(rawBody) : rawBody;
|
|
56
|
+
const payload = concatBytes(new TextEncoder().encode(`${timestampHeader}.`), bodyBytes);
|
|
57
|
+
const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
58
|
+
const expected = new Uint8Array(
|
|
59
|
+
// TS 5.7+ tightened BufferSource to require ArrayBufferView<ArrayBuffer>;
|
|
60
|
+
// our concatenated Uint8Array is backed by an ArrayBuffer at runtime.
|
|
61
|
+
await crypto.subtle.sign("HMAC", key, payload));
|
|
62
|
+
if (!constantTimeEqual(delivered, expected)) {
|
|
63
|
+
throw new WebhookSignatureError("signature_mismatch");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function hexToBytes(hex) {
|
|
67
|
+
if (hex.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(hex))
|
|
68
|
+
return null;
|
|
69
|
+
const out = new Uint8Array(hex.length / 2);
|
|
70
|
+
for (let i = 0; i < out.length; i++) {
|
|
71
|
+
out[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
function concatBytes(a, b) {
|
|
76
|
+
const out = new Uint8Array(a.length + b.length);
|
|
77
|
+
out.set(a, 0);
|
|
78
|
+
out.set(b, a.length);
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
function constantTimeEqual(a, b) {
|
|
82
|
+
if (a.length !== b.length)
|
|
83
|
+
return false;
|
|
84
|
+
let diff = 0;
|
|
85
|
+
for (let i = 0; i < a.length; i++) {
|
|
86
|
+
diff |= (a[i] ?? 0) ^ (b[i] ?? 0);
|
|
87
|
+
}
|
|
88
|
+
return diff === 0;
|
|
89
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/* tslint:disable */
|
|
18
|
+
/* eslint-disable */
|
|
19
|
+
__exportStar(require("./runtime"), exports);
|
|
20
|
+
__exportStar(require("./apis/index"), exports);
|
|
21
|
+
__exportStar(require("./models/index"), exports);
|
|
22
|
+
__exportStar(require("./helpers/index"), exports);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SOPHON Encoding API
|
|
3
|
+
* REST API for submitting, monitoring, and retrieving SOPHON encoding jobs. Authentication is via Bearer API key or session cookie. All POST endpoints require an Idempotency-Key header. List endpoints use opaque cursor-based pagination.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @export
|
|
15
|
+
* @interface CompleteUploadResponse
|
|
16
|
+
*/
|
|
17
|
+
export interface CompleteUploadResponse {
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @memberof CompleteUploadResponse
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {CompleteUploadResponseStatusEnum}
|
|
27
|
+
* @memberof CompleteUploadResponse
|
|
28
|
+
*/
|
|
29
|
+
status: CompleteUploadResponseStatusEnum;
|
|
30
|
+
/**
|
|
31
|
+
* SHA-256 hex digest of the assembled file.
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @memberof CompleteUploadResponse
|
|
34
|
+
*/
|
|
35
|
+
sha256: string;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {number}
|
|
39
|
+
* @memberof CompleteUploadResponse
|
|
40
|
+
*/
|
|
41
|
+
bytes: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @export
|
|
45
|
+
* @enum {string}
|
|
46
|
+
*/
|
|
47
|
+
export declare enum CompleteUploadResponseStatusEnum {
|
|
48
|
+
COMPLETED = "completed"
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if a given object implements the CompleteUploadResponse interface.
|
|
52
|
+
*/
|
|
53
|
+
export declare function instanceOfCompleteUploadResponse(value: object): value is CompleteUploadResponse;
|
|
54
|
+
export declare function CompleteUploadResponseFromJSON(json: any): CompleteUploadResponse;
|
|
55
|
+
export declare function CompleteUploadResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CompleteUploadResponse;
|
|
56
|
+
export declare function CompleteUploadResponseToJSON(json: any): CompleteUploadResponse;
|
|
57
|
+
export declare function CompleteUploadResponseToJSONTyped(value?: CompleteUploadResponse | null, ignoreDiscriminator?: boolean): any;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* SOPHON Encoding API
|
|
6
|
+
* REST API for submitting, monitoring, and retrieving SOPHON encoding jobs. Authentication is via Bearer API key or session cookie. All POST endpoints require an Idempotency-Key header. List endpoints use opaque cursor-based pagination.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CompleteUploadResponseStatusEnum = void 0;
|
|
17
|
+
exports.instanceOfCompleteUploadResponse = instanceOfCompleteUploadResponse;
|
|
18
|
+
exports.CompleteUploadResponseFromJSON = CompleteUploadResponseFromJSON;
|
|
19
|
+
exports.CompleteUploadResponseFromJSONTyped = CompleteUploadResponseFromJSONTyped;
|
|
20
|
+
exports.CompleteUploadResponseToJSON = CompleteUploadResponseToJSON;
|
|
21
|
+
exports.CompleteUploadResponseToJSONTyped = CompleteUploadResponseToJSONTyped;
|
|
22
|
+
/**
|
|
23
|
+
* @export
|
|
24
|
+
* @enum {string}
|
|
25
|
+
*/
|
|
26
|
+
var CompleteUploadResponseStatusEnum;
|
|
27
|
+
(function (CompleteUploadResponseStatusEnum) {
|
|
28
|
+
CompleteUploadResponseStatusEnum["COMPLETED"] = "completed";
|
|
29
|
+
})(CompleteUploadResponseStatusEnum || (exports.CompleteUploadResponseStatusEnum = CompleteUploadResponseStatusEnum = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Check if a given object implements the CompleteUploadResponse interface.
|
|
32
|
+
*/
|
|
33
|
+
function instanceOfCompleteUploadResponse(value) {
|
|
34
|
+
if (!('id' in value) || value['id'] === undefined)
|
|
35
|
+
return false;
|
|
36
|
+
if (!('status' in value) || value['status'] === undefined)
|
|
37
|
+
return false;
|
|
38
|
+
if (!('sha256' in value) || value['sha256'] === undefined)
|
|
39
|
+
return false;
|
|
40
|
+
if (!('bytes' in value) || value['bytes'] === undefined)
|
|
41
|
+
return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
function CompleteUploadResponseFromJSON(json) {
|
|
45
|
+
return CompleteUploadResponseFromJSONTyped(json, false);
|
|
46
|
+
}
|
|
47
|
+
function CompleteUploadResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
48
|
+
if (json == null) {
|
|
49
|
+
return json;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
'id': json['id'],
|
|
53
|
+
'status': json['status'],
|
|
54
|
+
'sha256': json['sha256'],
|
|
55
|
+
'bytes': json['bytes'],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function CompleteUploadResponseToJSON(json) {
|
|
59
|
+
return CompleteUploadResponseToJSONTyped(json, false);
|
|
60
|
+
}
|
|
61
|
+
function CompleteUploadResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
62
|
+
if (value == null) {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
'id': value['id'],
|
|
67
|
+
'status': value['status'],
|
|
68
|
+
'sha256': value['sha256'],
|
|
69
|
+
'bytes': value['bytes'],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SOPHON Encoding API
|
|
3
|
+
* REST API for submitting, monitoring, and retrieving SOPHON encoding jobs. Authentication is via Bearer API key or session cookie. All POST endpoints require an Idempotency-Key header. List endpoints use opaque cursor-based pagination.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { OutputContainer } from './OutputContainer';
|
|
13
|
+
/**
|
|
14
|
+
* Optional output shaping knobs for a new job.
|
|
15
|
+
* @export
|
|
16
|
+
* @interface CreateJobOutputOptions
|
|
17
|
+
*/
|
|
18
|
+
export interface CreateJobOutputOptions {
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {OutputContainer}
|
|
22
|
+
* @memberof CreateJobOutputOptions
|
|
23
|
+
*/
|
|
24
|
+
container?: OutputContainer;
|
|
25
|
+
/**
|
|
26
|
+
* When true, audio is included in the output. MKV preserves
|
|
27
|
+
* source audio streams unchanged. MP4 preserves broadly compatible
|
|
28
|
+
* source audio codecs when possible, and may normalize
|
|
29
|
+
* incompatible codecs to AAC for playback compatibility.
|
|
30
|
+
* When false, the output is video only.
|
|
31
|
+
*
|
|
32
|
+
* @type {boolean}
|
|
33
|
+
* @memberof CreateJobOutputOptions
|
|
34
|
+
*/
|
|
35
|
+
audio?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Target output height in pixels. When set, output is scaled down
|
|
38
|
+
* (aspect ratio preserved, width derived from source, both dims
|
|
39
|
+
* rounded to even). If absent or larger than source height, output
|
|
40
|
+
* uses source dimensions. Billing tier is determined by the actual
|
|
41
|
+
* encoded output, not by this requested value.
|
|
42
|
+
*
|
|
43
|
+
* @type {number}
|
|
44
|
+
* @memberof CreateJobOutputOptions
|
|
45
|
+
*/
|
|
46
|
+
target_height?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if a given object implements the CreateJobOutputOptions interface.
|
|
50
|
+
*/
|
|
51
|
+
export declare function instanceOfCreateJobOutputOptions(value: object): value is CreateJobOutputOptions;
|
|
52
|
+
export declare function CreateJobOutputOptionsFromJSON(json: any): CreateJobOutputOptions;
|
|
53
|
+
export declare function CreateJobOutputOptionsFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateJobOutputOptions;
|
|
54
|
+
export declare function CreateJobOutputOptionsToJSON(json: any): CreateJobOutputOptions;
|
|
55
|
+
export declare function CreateJobOutputOptionsToJSONTyped(value?: CreateJobOutputOptions | null, ignoreDiscriminator?: boolean): any;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* SOPHON Encoding API
|
|
6
|
+
* REST API for submitting, monitoring, and retrieving SOPHON encoding jobs. Authentication is via Bearer API key or session cookie. All POST endpoints require an Idempotency-Key header. List endpoints use opaque cursor-based pagination.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.instanceOfCreateJobOutputOptions = instanceOfCreateJobOutputOptions;
|
|
17
|
+
exports.CreateJobOutputOptionsFromJSON = CreateJobOutputOptionsFromJSON;
|
|
18
|
+
exports.CreateJobOutputOptionsFromJSONTyped = CreateJobOutputOptionsFromJSONTyped;
|
|
19
|
+
exports.CreateJobOutputOptionsToJSON = CreateJobOutputOptionsToJSON;
|
|
20
|
+
exports.CreateJobOutputOptionsToJSONTyped = CreateJobOutputOptionsToJSONTyped;
|
|
21
|
+
const OutputContainer_1 = require("./OutputContainer");
|
|
22
|
+
/**
|
|
23
|
+
* Check if a given object implements the CreateJobOutputOptions interface.
|
|
24
|
+
*/
|
|
25
|
+
function instanceOfCreateJobOutputOptions(value) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
function CreateJobOutputOptionsFromJSON(json) {
|
|
29
|
+
return CreateJobOutputOptionsFromJSONTyped(json, false);
|
|
30
|
+
}
|
|
31
|
+
function CreateJobOutputOptionsFromJSONTyped(json, ignoreDiscriminator) {
|
|
32
|
+
if (json == null) {
|
|
33
|
+
return json;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
'container': json['container'] == null ? undefined : (0, OutputContainer_1.OutputContainerFromJSON)(json['container']),
|
|
37
|
+
'audio': json['audio'] == null ? undefined : json['audio'],
|
|
38
|
+
'target_height': json['target_height'] == null ? undefined : json['target_height'],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function CreateJobOutputOptionsToJSON(json) {
|
|
42
|
+
return CreateJobOutputOptionsToJSONTyped(json, false);
|
|
43
|
+
}
|
|
44
|
+
function CreateJobOutputOptionsToJSONTyped(value, ignoreDiscriminator = false) {
|
|
45
|
+
if (value == null) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
'container': (0, OutputContainer_1.OutputContainerToJSON)(value['container']),
|
|
50
|
+
'audio': value['audio'],
|
|
51
|
+
'target_height': value['target_height'],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SOPHON Encoding API
|
|
3
|
+
* REST API for submitting, monitoring, and retrieving SOPHON encoding jobs. Authentication is via Bearer API key or session cookie. All POST endpoints require an Idempotency-Key header. List endpoints use opaque cursor-based pagination.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { CreateJobOutputOptions } from './CreateJobOutputOptions';
|
|
13
|
+
import type { JobProfile } from './JobProfile';
|
|
14
|
+
import type { UploadJobSource } from './UploadJobSource';
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
* @interface CreateJobRequest
|
|
19
|
+
*/
|
|
20
|
+
export interface CreateJobRequest {
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @type {UploadJobSource}
|
|
24
|
+
* @memberof CreateJobRequest
|
|
25
|
+
*/
|
|
26
|
+
source: UploadJobSource;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @type {JobProfile}
|
|
30
|
+
* @memberof CreateJobRequest
|
|
31
|
+
*/
|
|
32
|
+
profile: JobProfile;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @type {CreateJobOutputOptions}
|
|
36
|
+
* @memberof CreateJobRequest
|
|
37
|
+
*/
|
|
38
|
+
output?: CreateJobOutputOptions;
|
|
39
|
+
/**
|
|
40
|
+
* IDs of registered webhook endpoints to notify on job state changes.
|
|
41
|
+
* @type {Array<string>}
|
|
42
|
+
* @memberof CreateJobRequest
|
|
43
|
+
*/
|
|
44
|
+
webhook_ids?: Array<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Arbitrary key-value metadata attached to the job. Max 16 KiB serialized.
|
|
47
|
+
* @type {{ [key: string]: any; }}
|
|
48
|
+
* @memberof CreateJobRequest
|
|
49
|
+
*/
|
|
50
|
+
metadata?: {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if a given object implements the CreateJobRequest interface.
|
|
56
|
+
*/
|
|
57
|
+
export declare function instanceOfCreateJobRequest(value: object): value is CreateJobRequest;
|
|
58
|
+
export declare function CreateJobRequestFromJSON(json: any): CreateJobRequest;
|
|
59
|
+
export declare function CreateJobRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateJobRequest;
|
|
60
|
+
export declare function CreateJobRequestToJSON(json: any): CreateJobRequest;
|
|
61
|
+
export declare function CreateJobRequestToJSONTyped(value?: CreateJobRequest | null, ignoreDiscriminator?: boolean): any;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* SOPHON Encoding API
|
|
6
|
+
* REST API for submitting, monitoring, and retrieving SOPHON encoding jobs. Authentication is via Bearer API key or session cookie. All POST endpoints require an Idempotency-Key header. List endpoints use opaque cursor-based pagination.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.instanceOfCreateJobRequest = instanceOfCreateJobRequest;
|
|
17
|
+
exports.CreateJobRequestFromJSON = CreateJobRequestFromJSON;
|
|
18
|
+
exports.CreateJobRequestFromJSONTyped = CreateJobRequestFromJSONTyped;
|
|
19
|
+
exports.CreateJobRequestToJSON = CreateJobRequestToJSON;
|
|
20
|
+
exports.CreateJobRequestToJSONTyped = CreateJobRequestToJSONTyped;
|
|
21
|
+
const CreateJobOutputOptions_1 = require("./CreateJobOutputOptions");
|
|
22
|
+
const JobProfile_1 = require("./JobProfile");
|
|
23
|
+
const UploadJobSource_1 = require("./UploadJobSource");
|
|
24
|
+
/**
|
|
25
|
+
* Check if a given object implements the CreateJobRequest interface.
|
|
26
|
+
*/
|
|
27
|
+
function instanceOfCreateJobRequest(value) {
|
|
28
|
+
if (!('source' in value) || value['source'] === undefined)
|
|
29
|
+
return false;
|
|
30
|
+
if (!('profile' in value) || value['profile'] === undefined)
|
|
31
|
+
return false;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function CreateJobRequestFromJSON(json) {
|
|
35
|
+
return CreateJobRequestFromJSONTyped(json, false);
|
|
36
|
+
}
|
|
37
|
+
function CreateJobRequestFromJSONTyped(json, ignoreDiscriminator) {
|
|
38
|
+
if (json == null) {
|
|
39
|
+
return json;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
'source': (0, UploadJobSource_1.UploadJobSourceFromJSON)(json['source']),
|
|
43
|
+
'profile': (0, JobProfile_1.JobProfileFromJSON)(json['profile']),
|
|
44
|
+
'output': json['output'] == null ? undefined : (0, CreateJobOutputOptions_1.CreateJobOutputOptionsFromJSON)(json['output']),
|
|
45
|
+
'webhook_ids': json['webhook_ids'] == null ? undefined : json['webhook_ids'],
|
|
46
|
+
'metadata': json['metadata'] == null ? undefined : json['metadata'],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function CreateJobRequestToJSON(json) {
|
|
50
|
+
return CreateJobRequestToJSONTyped(json, false);
|
|
51
|
+
}
|
|
52
|
+
function CreateJobRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
53
|
+
if (value == null) {
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
'source': (0, UploadJobSource_1.UploadJobSourceToJSON)(value['source']),
|
|
58
|
+
'profile': (0, JobProfile_1.JobProfileToJSON)(value['profile']),
|
|
59
|
+
'output': (0, CreateJobOutputOptions_1.CreateJobOutputOptionsToJSON)(value['output']),
|
|
60
|
+
'webhook_ids': value['webhook_ids'],
|
|
61
|
+
'metadata': value['metadata'],
|
|
62
|
+
};
|
|
63
|
+
}
|