@byte_fluffy/nexra-sdk 0.1.0-alpha.2 → 0.1.0-alpha.20

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.
@@ -10,28 +10,6 @@ interface CursorPage<T> {
10
10
 
11
11
  declare const BILLING_METRICS: readonly ["requests", "input_tokens", "cached_input_tokens", "cache_write_tokens", "cache_creation_5m_input_tokens", "cache_creation_1h_input_tokens", "cache_read_input_tokens", "output_tokens", "input_characters", "input_utf8_bytes", "input_images", "output_images", "input_audio_seconds", "output_audio_seconds", "input_video_seconds", "output_video_seconds", "provider_credits", "web_search_requests"];
12
12
  type BillingMetric = (typeof BILLING_METRICS)[number];
13
- declare const BILLING_EXPORT_DIMENSIONS: readonly ["resolution", "duration", "layer_decomposition", "with_audio", "has_input_video", "hd", "prompt_extend", "modality", "tier", "quality", "image_count", "input_token_tier", "input_modality", "service_tier", "inference_geo", "speed", "region_scope", "has_reference_image", "mode"];
14
- type UsageComponentEvidence = {
15
- source: "provider_native" | "request_derived" | "response_derived" | "tariff_equivalent" | "unknown";
16
- paths?: string[];
17
- calculation?: string;
18
- };
19
- interface MeteredUsageComponent {
20
- metric: BillingMetric;
21
- quantity: number;
22
- dimensions?: Record<string, JsonPrimitive>;
23
- evidence?: UsageComponentEvidence;
24
- }
25
- /**
26
- * Provider evidence is normalized into independent metered components instead
27
- * of one canonical model response. This keeps protocol conversion separate
28
- * from billing and allows one request to carry differently-dimensioned usage.
29
- */
30
- interface NormalizedUsageV1 {
31
- schemaVersion: 1;
32
- components: MeteredUsageComponent[];
33
- billingEvidenceComplete?: boolean;
34
- }
35
13
  interface MeteredPriceRate {
36
14
  metric: BillingMetric;
37
15
  unitSize: number;
@@ -46,42 +24,8 @@ interface MeteredPriceRuleV1 {
46
24
  rates: MeteredPriceRate[];
47
25
  }
48
26
  type PriceRule = MeteredPriceRuleV1;
49
- interface PriceEvaluationLine {
50
- evidence?: UsageComponentEvidence;
51
- metric: BillingMetric;
52
- quantity: number;
53
- unitSize: number;
54
- unitPrice: string;
55
- rounding: "proportional" | "ceil";
56
- includedQuantity: number;
57
- dimensions?: Record<string, JsonPrimitive>;
58
- amount: string;
59
- discountedAmount?: string;
60
- }
61
- /** Preserve frozen row order when distributing the eight-decimal remainder. */
62
- declare function allocateDiscountedPriceLines(lines: readonly PriceEvaluationLine[], saleAmount: string): PriceEvaluationLine[];
63
- interface PriceEvaluationIssue {
64
- code: "dimension_mismatch" | "ambiguous_rate" | "missing_usage";
65
- metric: BillingMetric;
66
- componentIndex: number;
67
- }
68
- interface PriceEvaluation {
69
- status: "rated" | "incomplete";
70
- amount: string;
71
- lines: PriceEvaluationLine[];
72
- issues: PriceEvaluationIssue[];
73
- }
74
- declare function validateNormalizedUsage(value: unknown): asserts value is NormalizedUsageV1;
75
- /**
76
- * Deterministically rates normalized usage without mutating wallets or billing
77
- * records. Amounts are rounded half-up to the database's eight-decimal money
78
- * scale per line; ceil rates round usage units before multiplying the price.
79
- */
80
- declare function evaluatePriceRule(ruleValue: unknown, usageValue: unknown): PriceEvaluation;
81
- declare function validatePriceRule(value: unknown): asserts value is PriceRule;
82
27
 
83
28
  type MeteringKind = "token" | "non_token" | "mixed";
84
- type UsageEvidenceStatus = "complete" | "partial" | "missing" | "invalid" | "not_expected";
85
29
  interface MeteringContract {
86
30
  schemaVersion: 1;
87
31
  kind: MeteringKind;
@@ -91,17 +35,6 @@ interface MeteringContract {
91
35
  whenFeature?: string;
92
36
  }>;
93
37
  }
94
- interface UsageEvidenceAssessment {
95
- kind: MeteringKind | "unknown";
96
- evidenceStatus: UsageEvidenceStatus;
97
- expectedMetrics: BillingMetric[];
98
- observedMetrics: BillingMetric[];
99
- missingMetrics: BillingMetric[];
100
- issues: string[];
101
- }
102
- declare function validateMeteringContract(value: unknown): asserts value is MeteringContract;
103
- /** Evidence completeness is independent of sale/cost prices and delivery success. */
104
- declare function assessUsageEvidence(contract: unknown, usage: unknown, features?: Readonly<Record<string, boolean>>): UsageEvidenceAssessment;
105
38
 
106
39
  type ModelModality = "language" | "embedding" | "reranker" | "image" | "video" | "audio" | "world" | "multimodal" | "other";
107
40
  interface ModelEndpointSummary {
@@ -121,6 +54,10 @@ interface ModelCapabilitySummary {
121
54
  /** User-facing input patterns such as text-to-video or image-to-image. */
122
55
  inputModes: string[];
123
56
  features: string[];
57
+ /** Maximum combined input and output context supported by the model. */
58
+ contextWindowTokens?: number;
59
+ /** Maximum generated output tokens supported by the model. */
60
+ maxOutputTokens?: number;
124
61
  }
125
62
  interface ModelDateVersion {
126
63
  id: string;
@@ -228,6 +165,15 @@ interface NexraModelOperation {
228
165
  outputSchema: JsonObject;
229
166
  metering: MeteringContract;
230
167
  }
168
+ /** Public native wire endpoint metadata. Provider routing and credentials stay private. */
169
+ interface NexraModelEndpointSpec {
170
+ endpointKey: string;
171
+ operation: string;
172
+ protocol: string;
173
+ method: string;
174
+ path: string;
175
+ capabilities: readonly string[];
176
+ }
231
177
  interface NexraModelSpec {
232
178
  id: string;
233
179
  contractVersion: number;
@@ -240,6 +186,7 @@ interface NexraModelSpec {
240
186
  aliases: readonly string[];
241
187
  capabilities: ModelCapabilitySummary;
242
188
  operations: readonly NexraModelOperation[];
189
+ endpoints: readonly NexraModelEndpointSpec[];
243
190
  }
244
191
  interface NexraModelSpecFilter {
245
192
  kind?: ModelModality;
@@ -253,11 +200,23 @@ interface NexraSalePrice {
253
200
  effectiveFrom: string;
254
201
  rule: PriceRule;
255
202
  }
203
+ interface NexraSalePriceList {
204
+ currency: NexraBillingCurrency;
205
+ prices: readonly NexraSalePrice[];
206
+ }
256
207
  interface CreateNexraQuoteRequest {
257
208
  modelId: string;
258
209
  operation: string;
259
210
  input: JsonObject;
260
211
  }
212
+ interface CreateNexraDisplayQuoteBatchRequest {
213
+ modelId: string;
214
+ operation: string;
215
+ entries: readonly Readonly<{
216
+ key: string;
217
+ input: JsonObject;
218
+ }>[];
219
+ }
261
220
  interface NexraQuote {
262
221
  quoteToken: string;
263
222
  modelId: string;
@@ -269,6 +228,32 @@ interface NexraQuote {
269
228
  accuracy: "exact" | "estimated";
270
229
  expiresAt: string;
271
230
  }
231
+ type NexraDisplayQuoteBatchEntry = Readonly<{
232
+ key: string;
233
+ amount: string;
234
+ maximumAmount: string;
235
+ accuracy: "exact" | "estimated";
236
+ }> | Readonly<{
237
+ key: string;
238
+ error: {
239
+ code: string;
240
+ message: string;
241
+ };
242
+ }>;
243
+ interface NexraDisplayQuoteBatch {
244
+ modelId: string;
245
+ contractVersion: number;
246
+ priceRevision: string;
247
+ pricingPolicyRevision: string;
248
+ quoteContextRevision: string;
249
+ currency: NexraBillingCurrency;
250
+ entries: readonly NexraDisplayQuoteBatchEntry[];
251
+ expiresAt: string;
252
+ }
253
+ interface NexraCatalogRevision {
254
+ revision: string;
255
+ changedAt: string;
256
+ }
272
257
  interface NexraSettlement {
273
258
  amount: string;
274
259
  currency: NexraBillingCurrency;
@@ -298,16 +283,36 @@ declare class HttpTransport {
298
283
  json<T>(path: string, init?: RequestInit, options?: RequestOptions): Promise<T>;
299
284
  response(path: string, init?: RequestInit, options?: RequestOptions): Promise<Response>;
300
285
  }
301
- declare function jsonBody(value: unknown): Pick<RequestInit, "body" | "headers">;
302
- declare function queryString(values: Record<string, string | number | undefined>): string;
303
- declare function sleep(milliseconds: number, signal?: AbortSignal | null): Promise<void>;
304
286
 
305
- declare class CatalogClient {
306
- private readonly transport;
307
- constructor(transport: HttpTransport);
308
- quote(request: CreateNexraQuoteRequest, signal?: AbortSignal): Promise<NexraQuote>;
309
- }
310
- declare function getModelSpec(modelId: string): NexraModelSpec | undefined;
311
- declare function listModelSpecs(filter?: NexraModelSpecFilter): readonly NexraModelSpec[];
287
+ /** Unified canvas vocabulary: resolution 1K/2K/4K, ratio X:X. */
288
+ type UnifiedMediaGeometry = {
289
+ resolution?: string;
290
+ ratio?: string;
291
+ quality?: string;
292
+ };
293
+ type MediaGeometryField = {
294
+ field: string;
295
+ nest?: string;
296
+ options: readonly string[];
297
+ default?: string;
298
+ optionLabels: Readonly<Record<string, string>>;
299
+ };
300
+ type MediaGeometryProjection = {
301
+ kind: "pixel-size" | "tier-size" | "resolution-ratio" | "ratio-only" | "none";
302
+ resolution?: MediaGeometryField;
303
+ ratio?: MediaGeometryField;
304
+ quality?: MediaGeometryField;
305
+ };
306
+ /** Schema → unified resolution/ratio/quality controls for app UIs. */
307
+ declare function projectMediaGeometry(inputSchema: JsonObject): MediaGeometryProjection;
308
+ /** Unified geometry → the model's native catalog fields (channel original params). */
309
+ declare function encodeMediaGeometry(inputSchema: JsonObject, geometry: UnifiedMediaGeometry): JsonObject;
310
+ /** Native catalog fields → unified resolution/ratio/quality. */
311
+ declare function decodeMediaGeometry(inputSchema: JsonObject, nativeInput: JsonObject): UnifiedMediaGeometry;
312
+ /**
313
+ * Rewrite a Task/quote body: unified keys become native catalog fields.
314
+ * Native size/ratio already present is left alone (existing callers keep working).
315
+ */
316
+ declare function applyMediaGeometry(inputSchema: JsonObject, input: JsonObject): JsonObject;
312
317
 
313
- export { type NormalizedUsageV1 as A, type BillingMetric as B, type CursorPage as C, type PriceEvaluationIssue as D, type PriceEvaluationLine as E, type FetchLike as F, type PriceRule as G, HttpTransport as H, type UsageEvidenceAssessment as I, type JsonObject as J, type UsageEvidenceStatus as K, allocateDiscountedPriceLines as L, type ModelSearchParams as M, type NexraSettlement as N, assessUsageEvidence as O, type PriceEvaluation as P, evaluatePriceRule as Q, getModelSpec as R, jsonBody as S, type TaskModelSummary as T, type UsageComponentEvidence as U, listModelSpecs as V, queryString as W, sleep as X, validateMeteringContract as Y, validateNormalizedUsage as Z, validatePriceRule as _, type JsonValue as a, type TaskModel as b, type ModelSchema as c, CatalogClient as d, type NexraClientOptions as e, BILLING_EXPORT_DIMENSIONS as f, BILLING_METRICS as g, type CreateNexraQuoteRequest as h, type JsonPrimitive as i, type MeteredPriceRate as j, type MeteredPriceRuleV1 as k, type MeteredUsageComponent as l, type MeteringContract as m, type MeteringKind as n, type ModelCapabilitySummary as o, type ModelDateVersion as p, type ModelEndpointSummary as q, type ModelModality as r, type ModelResourceList as s, type ModelResourceOption as t, type NexraBillingCurrency as u, type NexraModelOperation as v, type NexraModelSpec as w, type NexraModelSpecFilter as x, type NexraQuote as y, type NexraSalePrice as z };
318
+ export { type ModelModality as A, type ModelResourceList as B, type CreateNexraQuoteRequest as C, type ModelResourceOption as D, type NexraDisplayQuoteBatchEntry as E, type FetchLike as F, HttpTransport as H, type JsonValue as J, type MediaGeometryField as M, type NexraSalePriceList as N, type TaskModelSummary as T, type UnifiedMediaGeometry as U, type NexraQuote as a, type CreateNexraDisplayQuoteBatchRequest as b, type NexraDisplayQuoteBatch as c, type NexraCatalogRevision as d, type NexraModelSpec as e, type NexraModelSpecFilter as f, type MediaGeometryProjection as g, type NexraBillingCurrency as h, type NexraModelEndpointSpec as i, type NexraModelOperation as j, type NexraSalePrice as k, type NexraSettlement as l, applyMediaGeometry as m, decodeMediaGeometry as n, encodeMediaGeometry as o, projectMediaGeometry as p, type ModelSearchParams as q, type CursorPage as r, type TaskModel as s, type ModelSchema as t, type NexraClientOptions as u, type JsonObject as v, type JsonPrimitive as w, type ModelCapabilitySummary as x, type ModelDateVersion as y, type ModelEndpointSummary as z };
@@ -0,0 +1,343 @@
1
+ import { v as JsonObject, J as JsonValue, l as NexraSettlement, r as CursorPage, H as HttpTransport } from './media-geometry-Ckr1-Mh3.js';
2
+
3
+ declare const MEDIA_KINDS: readonly ["image", "video", "audio", "document", "archive", "other"];
4
+ type MediaKind = (typeof MEDIA_KINDS)[number];
5
+ type MediaAssetStatus = "pending" | "ready" | "failed" | "deleted";
6
+ interface MediaAsset {
7
+ id: string;
8
+ kind: MediaKind;
9
+ status: MediaAssetStatus;
10
+ source: "upload" | "generated" | "provider" | "imported";
11
+ name?: string;
12
+ mimeType?: string;
13
+ sizeBytes?: number;
14
+ width?: number;
15
+ height?: number;
16
+ durationMs?: number;
17
+ checksumSha256?: string;
18
+ url?: string;
19
+ downloadUrl?: string;
20
+ expiresAt?: string;
21
+ metadata?: JsonObject;
22
+ createdAt: string;
23
+ }
24
+ interface AssetReference {
25
+ assetId: string;
26
+ }
27
+ type AssetInput = AssetReference | Blob | File | MediaAsset | string | URL;
28
+ interface AssetUploadOptions {
29
+ kind?: MediaKind;
30
+ name?: string;
31
+ signal?: AbortSignal;
32
+ }
33
+ interface AssetImportRequest {
34
+ url: string;
35
+ kind?: MediaKind;
36
+ name?: string;
37
+ }
38
+ type AssetCertificationProvider = "seedance";
39
+ type AssetCertificationStatus = "processing" | "ready" | "failed";
40
+ interface AssetCertification {
41
+ assetId: string;
42
+ provider: AssetCertificationProvider;
43
+ status: AssetCertificationStatus;
44
+ providerAssetId?: string;
45
+ assetUri?: string;
46
+ groupId?: string;
47
+ library: "general" | "liveness";
48
+ error?: string;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ }
52
+ interface AssetCertificationRequest {
53
+ library?: "general" | "liveness";
54
+ }
55
+ interface AssetCertificationWaitOptions {
56
+ pollIntervalMs?: number;
57
+ timeoutMs?: number;
58
+ signal?: AbortSignal;
59
+ }
60
+
61
+ interface ApiErrorPayload {
62
+ error: {
63
+ code: string;
64
+ message: string;
65
+ category?: string;
66
+ retryable?: boolean;
67
+ requestId?: string;
68
+ details?: JsonObject;
69
+ };
70
+ }
71
+
72
+ declare const TASK_STATUSES: readonly ["queued", "running", "succeeded", "failed", "cancelling", "cancelled"];
73
+ type TaskStatus = (typeof TASK_STATUSES)[number];
74
+ type TerminalTaskStatus = "succeeded" | "failed" | "cancelled";
75
+ interface TaskProgress {
76
+ percent?: number;
77
+ stage?: string;
78
+ message?: string;
79
+ }
80
+ interface TaskError {
81
+ code: string;
82
+ message: string;
83
+ category?: string;
84
+ retryable?: boolean;
85
+ details?: JsonObject;
86
+ }
87
+ interface TaskUsage {
88
+ components: Array<{
89
+ name: string;
90
+ quantity: number;
91
+ unit: string;
92
+ }>;
93
+ metadata?: JsonObject;
94
+ }
95
+ interface TaskCost {
96
+ amount: string;
97
+ currency: string;
98
+ }
99
+ interface TaskTiming {
100
+ submittedAt: string;
101
+ providerSubmittedAt?: string;
102
+ providerCompletedAt?: string;
103
+ /** First public terminal response; background media may still be preparing. */
104
+ firstResponseAt?: string;
105
+ /** Background media ready response; absent while preparing or after persistence failure. */
106
+ secondResponseAt?: string;
107
+ storedAt?: string;
108
+ persistPolicy?: "terminal" | "background";
109
+ deliveryStatus?: "preparing" | "ready" | "failed";
110
+ preparationMs: number | null;
111
+ generationMs: number | null;
112
+ /** Background: elapsed persistence stage until assets are ready; terminal: measured transfer. Null when unfinished or unavailable. */
113
+ storageMs: number | null;
114
+ /** Start of in-progress background persistence, when a worker has claimed the output. */
115
+ storageStartedAt?: string;
116
+ /** Background persistence elapsed time from first response to durable asset readiness. */
117
+ persistMs?: number | null;
118
+ totalMs: number | null;
119
+ startSource: "client" | "server";
120
+ /** Server clock reading taken when this snapshot was built; lets clients anchor live timers to server time. */
121
+ observedAt?: string;
122
+ }
123
+ /** Repository/console read model. HTTP clients receive TaskReceipt or TaskResult. */
124
+ interface Task<TOutput = JsonValue> {
125
+ id: string;
126
+ /** Original platform request ID, shared with request history. */
127
+ requestId?: string;
128
+ /** Public Run ID, when this Task belongs to a shared-input run. */
129
+ runId?: string;
130
+ model: string;
131
+ operation: string;
132
+ schemaVersion: number;
133
+ /** Model request parameters; native-managed tasks retain the upstream field structure. */
134
+ input?: JsonObject;
135
+ status: TaskStatus;
136
+ /** Persistence policy frozen when the Task is created. Background is limited to video Tasks. */
137
+ persistPolicy?: "terminal" | "background";
138
+ /**
139
+ * Regional media availability. "preparing" means the task result is delivered
140
+ * with provider media URLs while Nexra persists them to its own object storage
141
+ * in the background; "ready" means persisted URLs; "failed" means background
142
+ * persistence exhausted its retries and the provider URLs have expired.
143
+ * Execution/billing remain terminal regardless of this value.
144
+ */
145
+ deliveryStatus?: "preparing" | "ready" | "failed";
146
+ progress?: TaskProgress;
147
+ /** Native-managed tasks preserve the final response shape and media URLs; catalog models may normalize model identifiers. */
148
+ output?: TOutput;
149
+ assets: MediaAsset[];
150
+ error?: TaskError;
151
+ usage?: TaskUsage;
152
+ cost?: TaskCost;
153
+ /** Customer billing state; absent on older servers. */
154
+ billingStatus?: "pending" | "succeeded" | "failed" | "refunded" | "unavailable";
155
+ /** Final customer sale settlement. Provider procurement cost is never exposed here. */
156
+ settlement?: NexraSettlement;
157
+ /**
158
+ * Caller-supplied business data, returned unchanged; never sent to the provider.
159
+ * The platform extracts the reserved string keys `callerUrl` (caller origin,
160
+ * https URL) and `endUserId` (opaque end-user identifier) into dedicated
161
+ * attribution columns for support diagnostics; their values are not validated
162
+ * beyond format checks and remain unchanged inside `metadata`.
163
+ */
164
+ metadata?: JsonObject;
165
+ timing?: TaskTiming;
166
+ /** Server-side Task record creation time (ISO 8601 UTC). */
167
+ createdAt: string;
168
+ /** Latest Task record update, not the generation completion time (ISO 8601 UTC). */
169
+ updatedAt: string;
170
+ /** First worker execution start; absent while queued or cancelled before execution. */
171
+ startedAt?: string;
172
+ /**
173
+ * Terminal succeeded/failed/cancelled time. Synchronously persisted tasks
174
+ * (default) reach succeeded only after required asset storage; background-
175
+ * persisted tasks are declared succeeded at result delivery while storage
176
+ * continues, signalled by `deliveryStatus` and the task timing second response.
177
+ */
178
+ completedAt?: string;
179
+ /** @deprecated Reserved; no Task expiry policy is currently enforced. Not a media URL expiry. */
180
+ expiresAt?: string;
181
+ }
182
+ /** POST /tasks returns acceptance only, including for idempotent replays. */
183
+ type TaskReceipt = Pick<Task, "id" | "status">;
184
+ /** Public Task result; platform diagnostics and business tags live in RequestDetails. */
185
+ type TaskResult<TOutput = JsonValue> = Pick<Task<TOutput>, "id" | "model" | "status"> & Partial<Pick<Task<TOutput>, "requestId" | "output" | "assets" | "error" | "persistPolicy" | "deliveryStatus" | "settlement">>;
186
+ /** Platform request details, used by both managed Tasks and native proxy requests. */
187
+ interface RequestDetails {
188
+ id: string;
189
+ requestId: string;
190
+ taskId: string | null;
191
+ method: string;
192
+ path: string;
193
+ protocol?: string;
194
+ accessMode?: string | null;
195
+ model: string | null;
196
+ operation: string | null;
197
+ status: string;
198
+ /** Linked Task lifecycle when this request accepted a Task; HTTP `status` stays accepted. */
199
+ taskStatus?: string | null;
200
+ persistPolicy?: "terminal" | "background";
201
+ deliveryStatus?: Task["deliveryStatus"];
202
+ httpStatus: number | null;
203
+ errorCode: string | null;
204
+ /** HTTP duration, never substituted with asynchronous task duration. */
205
+ durationMs: number | null;
206
+ timing?: TaskTiming;
207
+ cost?: TaskCost;
208
+ billingStatus?: Task["billingStatus"];
209
+ settlement?: NexraSettlement;
210
+ metadata?: JsonObject;
211
+ /** Caller-asserted origin extracted from metadata.callerUrl; diagnostics display only. */
212
+ callerUrl?: string | null;
213
+ /** Caller-asserted end-user identifier extracted from metadata.endUserId; diagnostics display only. */
214
+ endUserId?: string | null;
215
+ /** Name of the API key that authenticated this request; diagnostics display only. */
216
+ apiKeyName?: string | null;
217
+ /** Latest known execution update; omitted when not observed. */
218
+ updatedAt?: string;
219
+ runId?: string;
220
+ schemaVersion?: number;
221
+ createdAt?: string;
222
+ startedAt?: string;
223
+ completedAt?: string;
224
+ input: JsonObject | null;
225
+ /** Present only on single-request reads (`includeOutput`). */
226
+ output?: JsonValue | null;
227
+ /** Output media with durable TOS URLs; present only on `includeOutput`. */
228
+ assets?: MediaAsset[];
229
+ receivedAt: string;
230
+ finishedAt: string | null;
231
+ }
232
+ type TaskEventType = "state" | "progress" | "preview" | "log" | "usage" | "warning" | "result";
233
+ interface TaskEvent {
234
+ id: string;
235
+ taskId: string;
236
+ sequence: number;
237
+ type: TaskEventType;
238
+ status?: TaskStatus;
239
+ progress?: TaskProgress;
240
+ asset?: MediaAsset;
241
+ message?: string;
242
+ payload?: JsonObject;
243
+ occurredAt: string;
244
+ }
245
+ /** @deprecated Use CreateTaskRequest.callback_url. Kept for existing callers. */
246
+ interface TaskWebhookConfig {
247
+ url: string;
248
+ /** Shared HMAC secret used to verify Nexra callback signatures. */
249
+ secret: string;
250
+ events?: Array<"completed">;
251
+ }
252
+ interface CreateTaskRequest<TInput = Record<string, unknown>> {
253
+ /** @internal Console telemetry only: browser send time before uploads, not execution time. */
254
+ submittedAt?: string;
255
+ model: string;
256
+ input: TInput;
257
+ /** Signed Nexra quote used to lock this input to a sale-price revision. */
258
+ quoteToken?: string;
259
+ /** Optional business identifiers such as orderId, available in request details. Do not include secrets. */
260
+ metadata?: JsonObject;
261
+ /** Platform completion callback, independent of provider callback support. Never sent upstream. */
262
+ callback_url?: string;
263
+ /** @deprecated Use callback_url; do not supply both. */
264
+ webhook?: TaskWebhookConfig;
265
+ /** @deprecated Compatibility check only; the server resolves the current contract. */
266
+ schemaVersion?: number;
267
+ }
268
+ interface TaskListParams {
269
+ status?: TaskStatus;
270
+ model?: string;
271
+ limit?: number;
272
+ cursor?: string;
273
+ }
274
+ type TaskPage<TOutput = JsonValue> = CursorPage<Task<TOutput>>;
275
+ interface RunResult<TOutput = JsonValue> {
276
+ taskId: string;
277
+ output: TOutput;
278
+ assets: MediaAsset[];
279
+ usage?: TaskUsage;
280
+ cost?: TaskCost;
281
+ task: TaskResult<TOutput>;
282
+ }
283
+ declare function isTerminalTaskStatus(status: TaskStatus): status is TerminalTaskStatus;
284
+
285
+ declare class AssetsClient {
286
+ private readonly transport;
287
+ constructor(transport: HttpTransport);
288
+ upload(file: Blob, options?: AssetUploadOptions): Promise<MediaAsset>;
289
+ import(request: AssetImportRequest, signal?: AbortSignal): Promise<MediaAsset>;
290
+ get(assetId: string, signal?: AbortSignal): Promise<MediaAsset>;
291
+ certifyForSeedance(asset: MediaAsset | string, request?: AssetCertificationRequest, signal?: AbortSignal): Promise<AssetCertification>;
292
+ getSeedanceCertification(asset: MediaAsset | string, signal?: AbortSignal): Promise<AssetCertification>;
293
+ waitForSeedanceCertification(asset: MediaAsset | string, options?: AssetCertificationWaitOptions): Promise<AssetCertification>;
294
+ download(asset: MediaAsset | string, signal?: AbortSignal): Promise<Response>;
295
+ stream(asset: MediaAsset | string, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
296
+ }
297
+
298
+ interface CreateTaskOptions<TInput = Record<string, unknown>> {
299
+ input: TInput;
300
+ quoteToken?: string;
301
+ submittedAt?: string;
302
+ metadata?: JsonObject;
303
+ callback_url?: string;
304
+ /** @deprecated Use callback_url; do not supply both. */
305
+ webhook?: TaskWebhookConfig;
306
+ schemaVersion?: number;
307
+ idempotencyKey?: string;
308
+ signal?: AbortSignal;
309
+ }
310
+ interface WatchTaskOptions {
311
+ signal?: AbortSignal;
312
+ lastEventId?: string;
313
+ maxReconnects?: number;
314
+ }
315
+ interface WaitTaskOptions extends WatchTaskOptions {
316
+ timeoutMs?: number;
317
+ pollIntervalMs?: number;
318
+ onEvent?: (event: TaskEvent) => void | Promise<void>;
319
+ }
320
+ interface RunTaskOptions<TInput = Record<string, unknown>> extends CreateTaskOptions<TInput>, WaitTaskOptions {
321
+ cancelOnAbort?: boolean;
322
+ }
323
+ declare class TasksClient {
324
+ private readonly transport;
325
+ private readonly assets;
326
+ constructor(transport: HttpTransport, assets: AssetsClient);
327
+ create<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, options: CreateTaskOptions<TInput>): Promise<TaskReceipt>;
328
+ get<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskResult<TOutput>>;
329
+ list<TOutput = JsonValue>(params?: TaskListParams, signal?: AbortSignal): Promise<CursorPage<TaskResult<TOutput>>>;
330
+ cancel<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskReceipt>;
331
+ watch(taskId: string, options?: WatchTaskOptions): AsyncGenerator<TaskEvent>;
332
+ wait<TOutput = JsonValue>(taskId: string, options?: WaitTaskOptions): Promise<TaskResult<TOutput>>;
333
+ run<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, options: RunTaskOptions<TInput>): Promise<RunResult<TOutput>>;
334
+ }
335
+
336
+ interface VerifyWebhookOptions {
337
+ toleranceSeconds?: number;
338
+ now?: Date;
339
+ }
340
+ /** @deprecated Only verifies legacy signed webhooks, not callback_url notifications. */
341
+ declare function verifyWebhook(request: Request, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
342
+
343
+ export { AssetsClient as A, type TerminalTaskStatus as B, type CreateTaskOptions as C, type WatchTaskOptions as D, isTerminalTaskStatus as E, verifyWebhook as F, MEDIA_KINDS as M, type RunTaskOptions as R, TasksClient as T, type VerifyWebhookOptions as V, type WaitTaskOptions as W, type RunResult as a, type ApiErrorPayload as b, type TaskResult as c, type AssetImportRequest as d, type AssetInput as e, type AssetReference as f, type AssetUploadOptions as g, type CreateTaskRequest as h, type MediaAsset as i, type MediaAssetStatus as j, type MediaKind as k, type RequestDetails as l, TASK_STATUSES as m, type Task as n, type TaskCost as o, type TaskError as p, type TaskEvent as q, type TaskEventType as r, type TaskListParams as s, type TaskPage as t, type TaskProgress as u, type TaskReceipt as v, type TaskStatus as w, type TaskTiming as x, type TaskUsage as y, type TaskWebhookConfig as z };
@@ -0,0 +1,2 @@
1
+ export { b as ApiErrorPayload, d as AssetImportRequest, e as AssetInput, f as AssetReference, g as AssetUploadOptions, C as CreateTaskOptions, h as CreateTaskRequest, i as MediaAsset, j as MediaAssetStatus, k as MediaKind, l as RequestDetails, a as RunResult, R as RunTaskOptions, n as Task, o as TaskCost, p as TaskError, q as TaskEvent, r as TaskEventType, s as TaskListParams, t as TaskPage, u as TaskProgress, v as TaskReceipt, c as TaskResult, w as TaskStatus, x as TaskTiming, y as TaskUsage, z as TaskWebhookConfig, B as TerminalTaskStatus, V as VerifyWebhookOptions, W as WaitTaskOptions, D as WatchTaskOptions } from './types-CvKdgo7V.js';
2
+ export { b as CreateNexraDisplayQuoteBatchRequest, C as CreateNexraQuoteRequest, r as CursorPage, F as FetchLike, v as JsonObject, w as JsonPrimitive, J as JsonValue, M as MediaGeometryField, g as MediaGeometryProjection, x as ModelCapabilitySummary, y as ModelDateVersion, z as ModelEndpointSummary, A as ModelModality, B as ModelResourceList, D as ModelResourceOption, t as ModelSchema, q as ModelSearchParams, h as NexraBillingCurrency, d as NexraCatalogRevision, u as NexraClientOptions, c as NexraDisplayQuoteBatch, E as NexraDisplayQuoteBatchEntry, j as NexraModelOperation, e as NexraModelSpec, f as NexraModelSpecFilter, a as NexraQuote, k as NexraSalePrice, N as NexraSalePriceList, l as NexraSettlement, s as TaskModel, T as TaskModelSummary, U as UnifiedMediaGeometry } from './media-geometry-Ckr1-Mh3.js';
package/dist/types.js ADDED
File without changes
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@byte_fluffy/nexra-sdk",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.20",
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,10 @@
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"
27
35
  }
28
36
  },
29
37
  "publishConfig": {
@@ -32,12 +40,14 @@
32
40
  },
33
41
  "scripts": {
34
42
  "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",
43
+ "build": "bun run generate && tsup",
36
44
  "test": "vitest run --root ../.. packages/sdk/tests",
45
+ "verify:video-schema-drift": "bun scripts/verify-video-schema-drift.ts",
37
46
  "prepack": "bun run build"
38
47
  },
39
48
  "devDependencies": {
40
49
  "@nexra/contracts": "workspace:*",
50
+ "@nexra/models": "workspace:*",
41
51
  "tsup": "8.5.1",
42
52
  "typescript": "5.9.3"
43
53
  }