@byte_fluffy/nexra-sdk 0.1.0-alpha.3 → 0.1.0-alpha.30

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.
@@ -0,0 +1,345 @@
1
+ import { c as AssetUploadOptions, d as MediaAsset, A as AssetImportRequest, g as AssetCertificationRequest, h as AssetCertification, i as AssetCertificationWaitOptions } from './assets-Cusrjj7_.js';
2
+ import { H as HttpTransport, v as NexraSettlement } from './media-geometry-DAVFGry1.js';
3
+ import { J as JsonValue, a as JsonObject, C as CursorPage } from './json-Cz0MkWQn.js';
4
+
5
+ type PublicUpstreamUnavailableReason = "no_response" | "not_retained" | "unsupported_capture" | "error_not_emitted" | "size_limit";
6
+ /** Network errors retain unknown codes from older or newer servers. */
7
+ type NexraError = {
8
+ code: string;
9
+ message: string;
10
+ param?: string;
11
+ };
12
+ type PublicErrorContext = {
13
+ nexraRequestId?: string;
14
+ nexraHttpStatus?: number;
15
+ };
16
+ type PublicErrorFields = PublicErrorContext & {
17
+ nexraError?: NexraError;
18
+ upstreamHttpStatus?: number;
19
+ upstreamRequestId?: string;
20
+ upstreamError?: JsonValue;
21
+ upstreamRedacted?: true;
22
+ upstreamTruncated?: true;
23
+ upstreamUnavailableReason?: PublicUpstreamUnavailableReason;
24
+ upstreamFormat?: "sse" | "decoded";
25
+ upstreamEvent?: string;
26
+ };
27
+ type PublicError = PublicErrorFields & {
28
+ nexraError: NexraError;
29
+ };
30
+ type ApiErrorPayload = PublicError;
31
+
32
+ declare class AssetsClient {
33
+ private readonly transport;
34
+ constructor(transport: HttpTransport);
35
+ upload(file: Blob, options?: AssetUploadOptions): Promise<MediaAsset>;
36
+ import(request: AssetImportRequest, signal?: AbortSignal): Promise<MediaAsset>;
37
+ get(assetId: string, signal?: AbortSignal): Promise<MediaAsset>;
38
+ certifyForSeedance(asset: MediaAsset | string, request?: AssetCertificationRequest, signal?: AbortSignal): Promise<AssetCertification>;
39
+ getSeedanceCertification(asset: MediaAsset | string, signal?: AbortSignal): Promise<AssetCertification>;
40
+ waitForSeedanceCertification(asset: MediaAsset | string, options?: AssetCertificationWaitOptions): Promise<AssetCertification>;
41
+ download(asset: MediaAsset | string, signal?: AbortSignal): Promise<Response>;
42
+ stream(asset: MediaAsset | string, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
43
+ }
44
+
45
+ interface CreateTaskOptions {
46
+ quoteToken?: string;
47
+ submittedAt?: string;
48
+ metadata?: JsonObject;
49
+ callback_url?: string;
50
+ /** @deprecated Use callback_url; do not supply both. */
51
+ webhook?: TaskWebhookConfig;
52
+ schemaVersion?: number;
53
+ idempotencyKey?: string;
54
+ signal?: AbortSignal;
55
+ }
56
+ interface WatchTaskOptions {
57
+ signal?: AbortSignal;
58
+ lastEventId?: string;
59
+ maxReconnects?: number;
60
+ }
61
+ interface WaitTaskOptions extends WatchTaskOptions {
62
+ timeoutMs?: number;
63
+ pollIntervalMs?: number;
64
+ onEvent?: (event: TaskEvent) => void | Promise<void>;
65
+ }
66
+ interface RunTaskOptions extends CreateTaskOptions, WaitTaskOptions {
67
+ cancelOnAbort?: boolean;
68
+ }
69
+ declare class TasksClient {
70
+ private readonly transport;
71
+ private readonly assets;
72
+ constructor(transport: HttpTransport, assets: AssetsClient);
73
+ create<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, input: TInput, options?: CreateTaskOptions): Promise<TaskReceipt>;
74
+ get<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskResult<TOutput>>;
75
+ list<TOutput = JsonValue>(params?: TaskListParams, signal?: AbortSignal): Promise<CursorPage<TaskResult<TOutput>>>;
76
+ cancel<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskReceipt>;
77
+ watch(taskId: string, options?: WatchTaskOptions): AsyncGenerator<TaskEvent>;
78
+ wait<TOutput = JsonValue>(taskId: string, options?: WaitTaskOptions): Promise<TaskResult<TOutput>>;
79
+ run<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, input: TInput, options?: RunTaskOptions): Promise<RunResult<TOutput>>;
80
+ }
81
+
82
+ interface VerifyWebhookOptions {
83
+ toleranceSeconds?: number;
84
+ now?: Date;
85
+ }
86
+ /** @deprecated Only verifies legacy signed webhooks, not callback_url notifications. */
87
+ declare function verifyWebhook(request: Request, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
88
+
89
+ type TaskPage<TOutput = JsonValue> = CursorPage<TaskResult<TOutput>>;
90
+
91
+ declare const TASK_STATUSES: readonly ["queued", "running", "succeeded", "failed", "cancelling", "cancelled"];
92
+ type TaskStatus = (typeof TASK_STATUSES)[number];
93
+ type TerminalTaskStatus = "succeeded" | "failed" | "cancelled";
94
+ interface TaskProgress {
95
+ percent?: number;
96
+ stage?: string;
97
+ message?: string;
98
+ }
99
+ type TaskError = NexraError;
100
+ interface TaskUsage {
101
+ components: Array<{
102
+ name: string;
103
+ quantity: number;
104
+ unit: string;
105
+ }>;
106
+ metadata?: JsonObject;
107
+ }
108
+ interface TaskCost {
109
+ amount: string;
110
+ currency: string;
111
+ }
112
+ interface TaskQueueSnapshot {
113
+ phase: "waiting_capacity" | "waiting_channel" | "dispatch_pending";
114
+ since: string;
115
+ deadlineAt?: string;
116
+ cancelable: boolean;
117
+ }
118
+ interface TaskTiming {
119
+ submittedAt: string;
120
+ providerSubmittedAt?: string;
121
+ providerCompletedAt?: string;
122
+ /** First public terminal response; background media may still be preparing. */
123
+ firstResponseAt?: string;
124
+ /** Background media ready response; absent while preparing or after persistence failure. */
125
+ secondResponseAt?: string;
126
+ storedAt?: string;
127
+ persistPolicy?: "terminal" | "background";
128
+ deliveryStatus?: "preparing" | "ready" | "failed";
129
+ preparationMs: number | null;
130
+ generationMs: number | null;
131
+ /** Background: elapsed persistence stage until assets are ready; terminal: measured transfer. Null when unfinished or unavailable. */
132
+ storageMs: number | null;
133
+ /** First-response time outside measured preparation/generation and any pre-response storage; not a separately instrumented stage. */
134
+ responseOverheadMs?: number | null;
135
+ /** Start of in-progress background persistence, when a worker has claimed the output. */
136
+ storageStartedAt?: string;
137
+ /** Background persistence elapsed time from first response to durable asset readiness. */
138
+ persistMs?: number | null;
139
+ totalMs: number | null;
140
+ /** Incident-only estimate of service readiness; actual public response remains in totalMs. */
141
+ correction?: {
142
+ incidentId: string;
143
+ outputReadyAt: string;
144
+ serviceReadyMs: number;
145
+ deploymentDelayMs: number;
146
+ };
147
+ startSource: "client" | "server";
148
+ /** Server clock reading taken when this snapshot was built; lets clients anchor live timers to server time. */
149
+ observedAt?: string;
150
+ }
151
+ /** Repository/console read model. HTTP clients receive TaskReceipt or TaskResult. */
152
+ interface Task<TOutput = JsonValue> extends PublicErrorFields {
153
+ id: string;
154
+ /** Original platform request ID, shared with request history. */
155
+ requestId?: string;
156
+ /** Public Run ID, when this Task belongs to a shared-input run. */
157
+ runId?: string;
158
+ model: string;
159
+ operation: string;
160
+ schemaVersion: number;
161
+ /** Model request parameters; native-managed tasks retain the upstream field structure. */
162
+ input?: JsonObject;
163
+ status: TaskStatus;
164
+ /** Present only while an asynchronous Task is queued. */
165
+ queue?: TaskQueueSnapshot;
166
+ /** Persistence policy frozen when the Task is created. Background is limited to video Tasks. */
167
+ persistPolicy?: "terminal" | "background";
168
+ /**
169
+ * Regional media availability. "preparing" means the task result is delivered
170
+ * with provider media URLs while Nexra persists them to its own object storage
171
+ * in the background; "ready" means persisted URLs; "failed" means background
172
+ * persistence exhausted its retries and the provider URLs have expired.
173
+ * Execution/billing remain terminal regardless of this value.
174
+ */
175
+ deliveryStatus?: "preparing" | "ready" | "failed";
176
+ progress?: TaskProgress;
177
+ /** Native-managed tasks preserve the final response shape and media URLs; catalog models may normalize model identifiers. */
178
+ output?: TOutput;
179
+ assets: MediaAsset[];
180
+ error?: PublicError;
181
+ usage?: TaskUsage;
182
+ cost?: TaskCost;
183
+ /** Customer billing state; absent on older servers. */
184
+ billingStatus?: "pending" | "succeeded" | "failed" | "refunded" | "unavailable";
185
+ /** Final customer sale settlement. Provider procurement cost is never exposed here. */
186
+ settlement?: NexraSettlement;
187
+ /**
188
+ * Caller-supplied business data, returned unchanged; never sent to the provider.
189
+ * The platform extracts the reserved string keys `callerUrl` (caller origin,
190
+ * https URL) and `endUserId` (opaque end-user identifier) into dedicated
191
+ * attribution columns for support diagnostics; their values are not validated
192
+ * beyond format checks and remain unchanged inside `metadata`.
193
+ */
194
+ metadata?: JsonObject;
195
+ timing?: TaskTiming;
196
+ /** Server-side Task record creation time (ISO 8601 UTC). */
197
+ createdAt: string;
198
+ /** Latest Task record update, not the generation completion time (ISO 8601 UTC). */
199
+ updatedAt: string;
200
+ /** First worker execution start; absent while queued or cancelled before execution. */
201
+ startedAt?: string;
202
+ /**
203
+ * Terminal succeeded/failed/cancelled time. Synchronously persisted tasks
204
+ * (default) reach succeeded only after required asset storage; background-
205
+ * persisted tasks are declared succeeded at result delivery while storage
206
+ * continues, signalled by `deliveryStatus` and the task timing second response.
207
+ */
208
+ completedAt?: string;
209
+ /** @deprecated Reserved; no Task expiry policy is currently enforced. Not a media URL expiry. */
210
+ expiresAt?: string;
211
+ }
212
+ /** POST /tasks returns acceptance only, including for idempotent replays. */
213
+ type TaskReceipt = Pick<Task, "id" | "status"> & PublicErrorContext;
214
+ /** Public Task result; platform diagnostics and business tags live in RequestDetails. */
215
+ type TaskResult<TOutput = JsonValue> = Pick<Task<TOutput>, "id" | "model" | "status"> & Partial<Pick<Task<TOutput>, "output" | "assets" | "persistPolicy" | "deliveryStatus" | "settlement" | "queue">> & PublicErrorFields;
216
+ /** Platform request details, used by both managed Tasks and native proxy requests. */
217
+ interface RequestDetails extends PublicErrorFields {
218
+ id: string;
219
+ nexraRequestId?: string;
220
+ taskId: string | null;
221
+ method: string;
222
+ path: string;
223
+ protocol?: string;
224
+ accessMode?: string | null;
225
+ model: string | null;
226
+ operation: string | null;
227
+ status: string;
228
+ /** Linked Task lifecycle when this request accepted a Task; HTTP `status` stays accepted. */
229
+ taskStatus?: string | null;
230
+ persistPolicy?: "terminal" | "background";
231
+ deliveryStatus?: Task["deliveryStatus"];
232
+ errorCode: string | null;
233
+ /** HTTP duration, never substituted with asynchronous task duration. */
234
+ durationMs: number | null;
235
+ timing?: TaskTiming;
236
+ cost?: TaskCost;
237
+ billingStatus?: Task["billingStatus"];
238
+ settlement?: NexraSettlement;
239
+ metadata?: JsonObject;
240
+ /** Caller-asserted origin extracted from metadata.callerUrl; diagnostics display only. */
241
+ callerUrl?: string | null;
242
+ /** Caller-asserted end-user identifier extracted from metadata.endUserId; diagnostics display only. */
243
+ endUserId?: string | null;
244
+ /** Name of the API key that authenticated this request; diagnostics display only. */
245
+ apiKeyName?: string | null;
246
+ /** Latest known execution update; omitted when not observed. */
247
+ updatedAt?: string;
248
+ runId?: string;
249
+ schemaVersion?: number;
250
+ createdAt?: string;
251
+ startedAt?: string;
252
+ completedAt?: string;
253
+ input: JsonObject | null;
254
+ /** Present only on single-request reads (`includeOutput`). */
255
+ output?: JsonValue | null;
256
+ /** Output media with durable TOS URLs; present only on `includeOutput`. */
257
+ assets?: MediaAsset[];
258
+ receivedAt: string;
259
+ finishedAt: string | null;
260
+ }
261
+ type TaskEventType = "state" | "progress" | "preview" | "log" | "usage" | "warning" | "result";
262
+ interface TaskEvent {
263
+ id: string;
264
+ taskId: string;
265
+ sequence: number;
266
+ type: TaskEventType;
267
+ status?: TaskStatus;
268
+ progress?: TaskProgress;
269
+ asset?: MediaAsset;
270
+ message?: string;
271
+ payload?: JsonObject;
272
+ occurredAt: string;
273
+ }
274
+ /** @deprecated Use CreateTaskRequest.callback_url. Kept for existing callers. */
275
+ type TaskWebhookConfig = JsonObject & Readonly<{
276
+ url: string;
277
+ /** Shared HMAC secret used to verify Nexra callback signatures. */
278
+ secret: string;
279
+ events?: Array<"completed">;
280
+ }>;
281
+ type CreateTaskControls = Readonly<{
282
+ /** @internal Console telemetry only: browser send time before uploads, not execution time. */
283
+ submittedAt?: string;
284
+ model: string;
285
+ /** Signed Nexra quote used to lock this input to a sale-price revision. */
286
+ quoteToken?: string;
287
+ /** Optional business identifiers such as orderId, available in request details. Do not include secrets. */
288
+ metadata?: JsonObject;
289
+ /** Platform completion callback, independent of provider callback support. Never sent upstream. */
290
+ callback_url?: string;
291
+ /** @deprecated Use callback_url; do not supply both. */
292
+ webhook?: TaskWebhookConfig;
293
+ /** @deprecated Compatibility check only; the server resolves the current contract. */
294
+ schemaVersion?: number;
295
+ }>;
296
+ /** Public Nexra Task request. Category parameters are top-level fields; `input`
297
+ * is deliberately not an envelope. Persistent Task records still retain their
298
+ * own `input` snapshot after the HTTP boundary separates control fields. */
299
+ type CreateTaskRequest<TInput extends JsonObject = JsonObject> = TInput & CreateTaskControls;
300
+ interface TaskListParams {
301
+ status?: TaskStatus;
302
+ model?: string;
303
+ limit?: number;
304
+ cursor?: string;
305
+ }
306
+ interface RunResult<TOutput = JsonValue> {
307
+ taskId: string;
308
+ output: TOutput;
309
+ assets: MediaAsset[];
310
+ usage?: TaskUsage;
311
+ cost?: TaskCost;
312
+ task: TaskResult<TOutput>;
313
+ }
314
+ declare function isTerminalTaskStatus(status: TaskStatus): status is TerminalTaskStatus;
315
+
316
+ type Voice = Readonly<{
317
+ id: string;
318
+ provider: "elevenlabs";
319
+ source: "design" | "clone";
320
+ sourceTaskId?: string;
321
+ previewId?: string;
322
+ name: string;
323
+ status: "processing" | "active" | "verification_required" | "failed" | "expired" | "deleted";
324
+ previewUrl?: string;
325
+ requiresVerification?: boolean;
326
+ createdAt: string;
327
+ expiresAt?: string;
328
+ }>;
329
+ type CreateVoiceRequest = Readonly<{
330
+ name: string;
331
+ source: Readonly<{
332
+ kind: "design";
333
+ taskId: string;
334
+ previewId: string;
335
+ }> | Readonly<{
336
+ kind: "clone";
337
+ samples: readonly string[];
338
+ }>;
339
+ }>;
340
+ type VoiceCreation = Readonly<{
341
+ taskId: string;
342
+ voice: Voice;
343
+ }>;
344
+
345
+ export { AssetsClient as A, verifyWebhook as B, type CreateVoiceRequest as C, type NexraError as N, type PublicErrorFields as P, type RunTaskOptions as R, TasksClient as T, type Voice as V, type WaitTaskOptions as W, type VoiceCreation as a, type RunResult as b, type TaskResult as c, type ApiErrorPayload as d, type CreateTaskOptions as e, type CreateTaskRequest as f, type PublicError as g, type PublicErrorContext as h, type RequestDetails as i, TASK_STATUSES as j, type TaskCost as k, type TaskError as l, type TaskEvent as m, type TaskEventType as n, type TaskListParams as o, type TaskPage as p, type TaskProgress as q, type TaskReceipt as r, type TaskStatus as s, type TaskTiming as t, type TaskUsage as u, type TaskWebhookConfig as v, type TerminalTaskStatus as w, type VerifyWebhookOptions as x, type WatchTaskOptions as y, isTerminalTaskStatus as z };
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@byte_fluffy/nexra-sdk",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.30",
4
4
  "type": "module",
5
+ "types": "./dist/index.d.ts",
5
6
  "sideEffects": false,
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
6
10
  "repository": {
7
11
  "type": "git",
8
12
  "url": "git+https://github.com/starrank-soft/nexra-monorepo.git",
@@ -24,6 +28,18 @@
24
28
  "./decimal": {
25
29
  "types": "./dist/decimal.d.ts",
26
30
  "import": "./dist/decimal.js"
31
+ },
32
+ "./types": {
33
+ "types": "./dist/types.d.ts",
34
+ "import": "./dist/types.js"
35
+ },
36
+ "./media": {
37
+ "types": "./dist/media.d.ts",
38
+ "import": "./dist/media.js"
39
+ },
40
+ "./language": {
41
+ "types": "./dist/language.d.ts",
42
+ "import": "./dist/language.js"
27
43
  }
28
44
  },
29
45
  "publishConfig": {
@@ -32,13 +48,34 @@
32
48
  },
33
49
  "scripts": {
34
50
  "generate": "bun scripts/generate-public-catalog.ts",
35
- "build": "bun run generate && tsup src/index.ts src/catalog.ts src/decimal.ts --format esm --dts --dts-resolve --clean --out-dir dist --target es2022 --platform browser",
51
+ "build": "bun run generate && tsup",
36
52
  "test": "vitest run --root ../.. packages/sdk/tests",
53
+ "verify:video-schema-drift": "bun scripts/verify-video-schema-drift.ts",
37
54
  "prepack": "bun run build"
38
55
  },
39
56
  "devDependencies": {
57
+ "@ai-sdk/anthropic": "4.0.30",
58
+ "@ai-sdk/google": "4.0.12",
59
+ "@ai-sdk/openai": "4.0.11",
60
+ "@ai-sdk/provider": "4.0.2",
61
+ "@ai-sdk/provider-utils": "5.0.21",
40
62
  "@nexra/contracts": "workspace:*",
63
+ "@nexra/models": "workspace:*",
41
64
  "tsup": "8.5.1",
42
65
  "typescript": "5.9.3"
66
+ },
67
+ "peerDependencies": {
68
+ "@ai-sdk/anthropic": "^4.0.30",
69
+ "@ai-sdk/google": "^4.0.12",
70
+ "@ai-sdk/openai": "^4.0.11",
71
+ "@ai-sdk/provider": "^4.0.2",
72
+ "@ai-sdk/provider-utils": "^5.0.21"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@ai-sdk/anthropic": { "optional": true },
76
+ "@ai-sdk/google": { "optional": true },
77
+ "@ai-sdk/openai": { "optional": true },
78
+ "@ai-sdk/provider": { "optional": true },
79
+ "@ai-sdk/provider-utils": { "optional": true }
43
80
  }
44
81
  }