@byte_fluffy/nexra-sdk 0.1.0-alpha.8 → 0.1.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,97 +1,22 @@
1
1
  import {
2
- ADMIN_USER_ACTIVITY_KINDS,
3
- ADMIN_USER_ROLES,
4
- ADMIN_USER_STATUSES,
5
- BILLING_CURRENCY,
6
- BILLING_EXPORT_DIMENSIONS,
7
- BILLING_METRICS,
8
2
  CatalogClient,
9
3
  HttpTransport,
10
4
  MEDIA_KINDS,
11
- MONEY_STRING_PATTERN,
12
5
  NexraApiError,
13
6
  NexraTaskError,
14
7
  NexraWaitTimeoutError,
15
- SANDBOX_OPERATIONS,
16
8
  TASK_STATUSES,
17
- TOKEN_METRICS,
18
- USAGE_AMOUNT_KINDS,
19
- USAGE_ANOMALY_CATEGORIES,
20
- USAGE_FILTER_KINDS,
21
- USAGE_FILTER_SELECTION_LIMIT,
22
- USAGE_GROUP_BYS,
23
- USAGE_NORMALIZATION_STATUSES,
24
- USAGE_RATING_STATUSES,
25
- USAGE_SOURCES,
26
- WALLET_MAX_BALANCE_UNITS,
27
- adaptSandboxInput,
28
- allocateDiscountedPriceLines,
29
9
  applyMediaGeometry,
30
- assessUsageEvidence,
31
- availabilityBuckets,
32
- availabilityStats,
33
- classifyObservation,
34
- compareRatioDisplayOrder,
35
10
  decodeMediaGeometry,
36
- defaultProbeInterval,
37
- defaultProbeTimeout,
38
- encodeAdminUserCursor,
39
11
  encodeMediaGeometry,
40
- encodeUsageFilterCursor,
41
- encodeUsageKeysetCursor,
42
- encodeUsageSummaryCursor,
43
- evaluatePriceRule,
44
12
  getModelSpec,
45
- isMoneyString,
46
13
  isTerminalTaskStatus,
47
14
  jsonBody,
48
15
  listModelSpecs,
49
- modelInputDefaults,
50
- modelInputUi,
51
- modelUploadRegion,
52
- moneyFromUnits,
53
- moneyToUnits,
54
- multiplyMoney,
55
- normalizeModelParameterSchema,
56
- orderSchemaRatioProperties,
57
- orderedSchemaProperties,
58
- parseAdminUserCursor,
59
- parseUsageFilterCursor,
60
- parseUsageKeysetCursor,
61
- parseUsageSummaryCursor,
62
- probeCostExceeds,
63
16
  projectMediaGeometry,
64
17
  queryString,
65
- rateProbeUsage,
66
- ratioDisplayOrderKey,
67
- sandboxIdentity,
68
- sandboxInputSchema,
69
- sandboxModelModes,
70
- sandboxObject,
71
- sandboxOperations,
72
- sandboxProperties,
73
- sandboxSupports,
74
- sandboxVoiceKey,
75
- sleep,
76
- sortRatioDisplayOrder,
77
- taskReceipt,
78
- taskResult,
79
- uploadedMediaInput,
80
- uploadedMediaUrl,
81
- validateAdminUserApiKeyUpdate,
82
- validateAdminUserListQuery,
83
- validateAdminUserUpdate,
84
- validateAdminWalletRechargeInput,
85
- validateMeteringContract,
86
- validateNormalizedUsage,
87
- validatePriceRule,
88
- validateUsageAnomaliesQuery,
89
- validateUsageAnomalySummaryQuery,
90
- validateUsageDetailsQuery,
91
- validateUsageFilterOptionsQuery,
92
- validateUsageFilters,
93
- validateUsageSummaryQuery
94
- } from "./chunk-IUUMCS7F.js";
18
+ sleep
19
+ } from "./chunk-5E323R6I.js";
95
20
  import {
96
21
  ceilDecimal,
97
22
  multiplyDecimal
@@ -516,104 +441,25 @@ function timingSafeEqual(left, right) {
516
441
  return difference === 0;
517
442
  }
518
443
  export {
519
- ADMIN_USER_ACTIVITY_KINDS,
520
- ADMIN_USER_ROLES,
521
- ADMIN_USER_STATUSES,
522
444
  AssetsClient,
523
- BILLING_CURRENCY,
524
- BILLING_EXPORT_DIMENSIONS,
525
- BILLING_METRICS,
526
445
  CatalogClient,
527
- HttpTransport,
528
446
  MEDIA_KINDS,
529
- MONEY_STRING_PATTERN,
530
447
  ModelsClient,
531
448
  NexraApiError,
532
449
  NexraClient,
533
450
  NexraTaskError,
534
451
  NexraWaitTimeoutError,
535
- SANDBOX_OPERATIONS,
536
452
  TASK_STATUSES,
537
- TOKEN_METRICS,
538
453
  TasksClient,
539
- USAGE_AMOUNT_KINDS,
540
- USAGE_ANOMALY_CATEGORIES,
541
- USAGE_FILTER_KINDS,
542
- USAGE_FILTER_SELECTION_LIMIT,
543
- USAGE_GROUP_BYS,
544
- USAGE_NORMALIZATION_STATUSES,
545
- USAGE_RATING_STATUSES,
546
- USAGE_SOURCES,
547
- WALLET_MAX_BALANCE_UNITS,
548
- adaptSandboxInput,
549
- allocateDiscountedPriceLines,
550
454
  applyMediaGeometry,
551
- assessUsageEvidence,
552
- availabilityBuckets,
553
- availabilityStats,
554
455
  ceilDecimal,
555
- classifyObservation,
556
- compareRatioDisplayOrder,
557
456
  createNexra,
558
457
  decodeMediaGeometry,
559
- defaultProbeInterval,
560
- defaultProbeTimeout,
561
- encodeAdminUserCursor,
562
458
  encodeMediaGeometry,
563
- encodeUsageFilterCursor,
564
- encodeUsageKeysetCursor,
565
- encodeUsageSummaryCursor,
566
- evaluatePriceRule,
567
459
  getModelSpec,
568
- isMoneyString,
569
460
  isTerminalTaskStatus,
570
- jsonBody,
571
461
  listModelSpecs,
572
- modelInputDefaults,
573
- modelInputUi,
574
- modelUploadRegion,
575
- moneyFromUnits,
576
- moneyToUnits,
577
462
  multiplyDecimal,
578
- multiplyMoney,
579
- normalizeModelParameterSchema,
580
- orderSchemaRatioProperties,
581
- orderedSchemaProperties,
582
- parseAdminUserCursor,
583
- parseUsageFilterCursor,
584
- parseUsageKeysetCursor,
585
- parseUsageSummaryCursor,
586
- probeCostExceeds,
587
463
  projectMediaGeometry,
588
- queryString,
589
- rateProbeUsage,
590
- ratioDisplayOrderKey,
591
- sandboxIdentity,
592
- sandboxInputSchema,
593
- sandboxModelModes,
594
- sandboxObject,
595
- sandboxOperations,
596
- sandboxProperties,
597
- sandboxSupports,
598
- sandboxVoiceKey,
599
- sleep,
600
- sortRatioDisplayOrder,
601
- taskReceipt,
602
- taskResult,
603
- uploadedMediaInput,
604
- uploadedMediaUrl,
605
- validateAdminUserApiKeyUpdate,
606
- validateAdminUserListQuery,
607
- validateAdminUserUpdate,
608
- validateAdminWalletRechargeInput,
609
- validateMeteringContract,
610
- validateNormalizedUsage,
611
- validatePriceRule,
612
- validateUsageAnomaliesQuery,
613
- validateUsageAnomalySummaryQuery,
614
- validateUsageDetailsQuery,
615
- validateUsageFilterOptionsQuery,
616
- validateUsageFilters,
617
- validateUsageSummaryQuery,
618
464
  verifyWebhook
619
465
  };
@@ -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 {
@@ -350,9 +283,6 @@ declare class HttpTransport {
350
283
  json<T>(path: string, init?: RequestInit, options?: RequestOptions): Promise<T>;
351
284
  response(path: string, init?: RequestInit, options?: RequestOptions): Promise<Response>;
352
285
  }
353
- declare function jsonBody(value: unknown): Pick<RequestInit, "body" | "headers">;
354
- declare function queryString(values: Record<string, string | number | undefined>): string;
355
- declare function sleep(milliseconds: number, signal?: AbortSignal | null): Promise<void>;
356
286
 
357
287
  /** Unified canvas vocabulary: resolution 1K/2K/4K, ratio X:X. */
358
288
  type UnifiedMediaGeometry = {
@@ -385,15 +315,4 @@ declare function decodeMediaGeometry(inputSchema: JsonObject, nativeInput: JsonO
385
315
  */
386
316
  declare function applyMediaGeometry(inputSchema: JsonObject, input: JsonObject): JsonObject;
387
317
 
388
- declare class CatalogClient {
389
- private readonly transport;
390
- constructor(transport: HttpTransport);
391
- listPrices(signal?: AbortSignal): Promise<NexraSalePriceList>;
392
- quote(request: CreateNexraQuoteRequest, signal?: AbortSignal): Promise<NexraQuote>;
393
- quoteBatch(request: CreateNexraDisplayQuoteBatchRequest, signal?: AbortSignal): Promise<NexraDisplayQuoteBatch>;
394
- revision(signal?: AbortSignal): Promise<NexraCatalogRevision>;
395
- }
396
- declare function getModelSpec(modelId: string): NexraModelSpec | undefined;
397
- declare function listModelSpecs(filter?: NexraModelSpecFilter): readonly NexraModelSpec[];
398
-
399
- export { assessUsageEvidence as $, type NexraDisplayQuoteBatchEntry as A, type BillingMetric as B, type CursorPage as C, type NexraModelEndpointSpec as D, type NexraModelOperation as E, type FetchLike as F, type NexraModelSpec as G, HttpTransport as H, type NexraModelSpecFilter as I, type JsonObject as J, type NexraQuote as K, type NexraSalePrice as L, type ModelSchema as M, type NexraSettlement as N, type NexraSalePriceList as O, type NormalizedUsageV1 as P, type PriceEvaluation as Q, type PriceEvaluationIssue as R, type PriceEvaluationLine as S, type TaskModelSummary as T, type PriceRule as U, type UnifiedMediaGeometry as V, type UsageComponentEvidence as W, type UsageEvidenceAssessment as X, type UsageEvidenceStatus as Y, allocateDiscountedPriceLines as Z, applyMediaGeometry as _, type JsonValue as a, decodeMediaGeometry as a0, encodeMediaGeometry as a1, evaluatePriceRule as a2, getModelSpec as a3, jsonBody as a4, listModelSpecs as a5, projectMediaGeometry as a6, queryString as a7, sleep as a8, validateMeteringContract as a9, validateNormalizedUsage as aa, validatePriceRule as ab, type ModelSearchParams as b, type TaskModel as c, CatalogClient as d, type NexraClientOptions as e, BILLING_EXPORT_DIMENSIONS as f, BILLING_METRICS as g, type CreateNexraDisplayQuoteBatchRequest as h, type CreateNexraQuoteRequest as i, type JsonPrimitive as j, type MediaGeometryField as k, type MediaGeometryProjection as l, type MeteredPriceRate as m, type MeteredPriceRuleV1 as n, type MeteredUsageComponent as o, type MeteringContract as p, type MeteringKind as q, type ModelCapabilitySummary as r, type ModelDateVersion as s, type ModelEndpointSummary as t, type ModelModality as u, type ModelResourceList as v, type ModelResourceOption as w, type NexraBillingCurrency as x, type NexraCatalogRevision as y, type NexraDisplayQuoteBatch 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,280 @@
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
+
39
+ interface ApiErrorPayload {
40
+ error: {
41
+ code: string;
42
+ message: string;
43
+ category?: string;
44
+ retryable?: boolean;
45
+ requestId?: string;
46
+ details?: JsonObject;
47
+ };
48
+ }
49
+
50
+ declare const TASK_STATUSES: readonly ["queued", "running", "succeeded", "failed", "cancelling", "cancelled"];
51
+ type TaskStatus = (typeof TASK_STATUSES)[number];
52
+ type TerminalTaskStatus = "succeeded" | "failed" | "cancelled";
53
+ interface TaskProgress {
54
+ percent?: number;
55
+ stage?: string;
56
+ message?: string;
57
+ }
58
+ interface TaskError {
59
+ code: string;
60
+ message: string;
61
+ category?: string;
62
+ retryable?: boolean;
63
+ details?: JsonObject;
64
+ }
65
+ interface TaskUsage {
66
+ components: Array<{
67
+ name: string;
68
+ quantity: number;
69
+ unit: string;
70
+ }>;
71
+ metadata?: JsonObject;
72
+ }
73
+ interface TaskCost {
74
+ amount: string;
75
+ currency: string;
76
+ }
77
+ interface TaskTiming {
78
+ submittedAt: string;
79
+ providerSubmittedAt?: string;
80
+ providerCompletedAt?: string;
81
+ storedAt?: string;
82
+ preparationMs: number | null;
83
+ generationMs: number | null;
84
+ storageMs: number | null;
85
+ totalMs: number | null;
86
+ startSource: "client" | "server";
87
+ /** Server clock reading taken when this snapshot was built; lets clients anchor live timers to server time. */
88
+ observedAt?: string;
89
+ }
90
+ /** Repository/console read model. HTTP clients receive TaskReceipt or TaskResult. */
91
+ interface Task<TOutput = JsonValue> {
92
+ id: string;
93
+ /** Original platform request ID, shared with request history. */
94
+ requestId?: string;
95
+ /** Public Run ID, when this Task belongs to a shared-input run. */
96
+ runId?: string;
97
+ model: string;
98
+ operation: string;
99
+ schemaVersion: number;
100
+ /** Model request parameters; native-managed tasks retain the upstream field structure. */
101
+ input?: JsonObject;
102
+ status: TaskStatus;
103
+ /** Regional media availability; execution/billing remain terminal while replicas prepare. */
104
+ deliveryStatus?: "preparing" | "ready";
105
+ progress?: TaskProgress;
106
+ /** Native-managed tasks preserve the final response shape and media URLs; catalog models may normalize model identifiers. */
107
+ output?: TOutput;
108
+ assets: MediaAsset[];
109
+ error?: TaskError;
110
+ usage?: TaskUsage;
111
+ cost?: TaskCost;
112
+ /** Customer billing state; absent on older servers. */
113
+ billingStatus?: "pending" | "succeeded" | "failed" | "refunded" | "unavailable";
114
+ /** Final customer sale settlement. Provider procurement cost is never exposed here. */
115
+ settlement?: NexraSettlement;
116
+ /** Caller-supplied business data, returned unchanged; never sent to the provider. */
117
+ metadata?: JsonObject;
118
+ timing?: TaskTiming;
119
+ /** Server-side Task record creation time (ISO 8601 UTC). */
120
+ createdAt: string;
121
+ /** Latest Task record update, not the generation completion time (ISO 8601 UTC). */
122
+ updatedAt: string;
123
+ /** First worker execution start; absent while queued or cancelled before execution. */
124
+ startedAt?: string;
125
+ /** Terminal succeeded/failed/cancelled time; success follows required asset storage. */
126
+ completedAt?: string;
127
+ /** @deprecated Reserved; no Task expiry policy is currently enforced. Not a media URL expiry. */
128
+ expiresAt?: string;
129
+ }
130
+ /** POST /tasks returns acceptance only, including for idempotent replays. */
131
+ type TaskReceipt = Pick<Task, "id" | "status">;
132
+ /** Public Task result; platform diagnostics and business tags live in RequestDetails. */
133
+ type TaskResult<TOutput = JsonValue> = Pick<Task<TOutput>, "id" | "model" | "status"> & Partial<Pick<Task<TOutput>, "requestId" | "output" | "assets" | "error" | "deliveryStatus" | "settlement">>;
134
+ /** Platform request details, used by both managed Tasks and native proxy requests. */
135
+ interface RequestDetails {
136
+ id: string;
137
+ requestId: string;
138
+ taskId: string | null;
139
+ method: string;
140
+ path: string;
141
+ protocol?: string;
142
+ accessMode?: string | null;
143
+ model: string | null;
144
+ operation: string | null;
145
+ status: string;
146
+ /** Linked Task lifecycle when this request accepted a Task; HTTP `status` stays accepted. */
147
+ taskStatus?: string | null;
148
+ httpStatus: number | null;
149
+ errorCode: string | null;
150
+ /** HTTP duration, never substituted with asynchronous task duration. */
151
+ durationMs: number | null;
152
+ timing?: TaskTiming;
153
+ cost?: TaskCost;
154
+ billingStatus?: Task["billingStatus"];
155
+ settlement?: NexraSettlement;
156
+ metadata?: JsonObject;
157
+ /** Latest known execution update; omitted when not observed. */
158
+ updatedAt?: string;
159
+ runId?: string;
160
+ schemaVersion?: number;
161
+ createdAt?: string;
162
+ startedAt?: string;
163
+ completedAt?: string;
164
+ input: JsonObject | null;
165
+ /** Present only on single-request reads (`includeOutput`). */
166
+ output?: JsonValue | null;
167
+ /** Output media with durable TOS URLs; present only on `includeOutput`. */
168
+ assets?: MediaAsset[];
169
+ receivedAt: string;
170
+ finishedAt: string | null;
171
+ }
172
+ type TaskEventType = "state" | "progress" | "preview" | "log" | "usage" | "warning" | "result";
173
+ interface TaskEvent {
174
+ id: string;
175
+ taskId: string;
176
+ sequence: number;
177
+ type: TaskEventType;
178
+ status?: TaskStatus;
179
+ progress?: TaskProgress;
180
+ asset?: MediaAsset;
181
+ message?: string;
182
+ payload?: JsonObject;
183
+ occurredAt: string;
184
+ }
185
+ /** @deprecated Use CreateTaskRequest.callback_url. Kept for existing callers. */
186
+ interface TaskWebhookConfig {
187
+ url: string;
188
+ /** Shared HMAC secret used to verify Nexra callback signatures. */
189
+ secret: string;
190
+ events?: Array<"completed">;
191
+ }
192
+ interface CreateTaskRequest<TInput = Record<string, unknown>> {
193
+ /** @internal Console telemetry only: browser send time before uploads, not execution time. */
194
+ submittedAt?: string;
195
+ model: string;
196
+ input: TInput;
197
+ /** Signed Nexra quote used to lock this input to a sale-price revision. */
198
+ quoteToken?: string;
199
+ /** Optional business identifiers such as orderId, available in request details. Do not include secrets. */
200
+ metadata?: JsonObject;
201
+ /** Platform completion callback, independent of provider callback support. Never sent upstream. */
202
+ callback_url?: string;
203
+ /** @deprecated Use callback_url; do not supply both. */
204
+ webhook?: TaskWebhookConfig;
205
+ /** @deprecated Compatibility check only; the server resolves the current contract. */
206
+ schemaVersion?: number;
207
+ }
208
+ interface TaskListParams {
209
+ status?: TaskStatus;
210
+ model?: string;
211
+ limit?: number;
212
+ cursor?: string;
213
+ }
214
+ type TaskPage<TOutput = JsonValue> = CursorPage<Task<TOutput>>;
215
+ interface RunResult<TOutput = JsonValue> {
216
+ taskId: string;
217
+ output: TOutput;
218
+ assets: MediaAsset[];
219
+ usage?: TaskUsage;
220
+ cost?: TaskCost;
221
+ task: TaskResult<TOutput>;
222
+ }
223
+ declare function isTerminalTaskStatus(status: TaskStatus): status is TerminalTaskStatus;
224
+
225
+ declare class AssetsClient {
226
+ private readonly transport;
227
+ constructor(transport: HttpTransport);
228
+ upload(file: Blob, options?: AssetUploadOptions): Promise<MediaAsset>;
229
+ import(request: AssetImportRequest, signal?: AbortSignal): Promise<MediaAsset>;
230
+ get(assetId: string, signal?: AbortSignal): Promise<MediaAsset>;
231
+ download(asset: MediaAsset | string, signal?: AbortSignal): Promise<Response>;
232
+ stream(asset: MediaAsset | string, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
233
+ }
234
+
235
+ interface CreateTaskOptions<TInput = Record<string, unknown>> {
236
+ input: TInput;
237
+ quoteToken?: string;
238
+ submittedAt?: string;
239
+ metadata?: JsonObject;
240
+ callback_url?: string;
241
+ /** @deprecated Use callback_url; do not supply both. */
242
+ webhook?: TaskWebhookConfig;
243
+ schemaVersion?: number;
244
+ idempotencyKey?: string;
245
+ signal?: AbortSignal;
246
+ }
247
+ interface WatchTaskOptions {
248
+ signal?: AbortSignal;
249
+ lastEventId?: string;
250
+ maxReconnects?: number;
251
+ }
252
+ interface WaitTaskOptions extends WatchTaskOptions {
253
+ timeoutMs?: number;
254
+ pollIntervalMs?: number;
255
+ onEvent?: (event: TaskEvent) => void | Promise<void>;
256
+ }
257
+ interface RunTaskOptions<TInput = Record<string, unknown>> extends CreateTaskOptions<TInput>, WaitTaskOptions {
258
+ cancelOnAbort?: boolean;
259
+ }
260
+ declare class TasksClient {
261
+ private readonly transport;
262
+ private readonly assets;
263
+ constructor(transport: HttpTransport, assets: AssetsClient);
264
+ create<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, options: CreateTaskOptions<TInput>): Promise<TaskReceipt>;
265
+ get<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskResult<TOutput>>;
266
+ list<TOutput = JsonValue>(params?: TaskListParams, signal?: AbortSignal): Promise<CursorPage<TaskResult<TOutput>>>;
267
+ cancel<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskReceipt>;
268
+ watch(taskId: string, options?: WatchTaskOptions): AsyncGenerator<TaskEvent>;
269
+ wait<TOutput = JsonValue>(taskId: string, options?: WaitTaskOptions): Promise<TaskResult<TOutput>>;
270
+ run<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, options: RunTaskOptions<TInput>): Promise<RunResult<TOutput>>;
271
+ }
272
+
273
+ interface VerifyWebhookOptions {
274
+ toleranceSeconds?: number;
275
+ now?: Date;
276
+ }
277
+ /** @deprecated Only verifies legacy signed webhooks, not callback_url notifications. */
278
+ declare function verifyWebhook(request: Request, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
279
+
280
+ 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-CPMdhb6o.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.8",
3
+ "version": "0.1.0-alpha.9",
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": {