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

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.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import { A as AssetsClient, T as TasksClient, R as RunTaskOptions, a as RunResult, b as ApiErrorPayload, c as TaskResult } from './types-CvKdgo7V.js';
2
- export { d as AssetImportRequest, e as AssetInput, f as AssetReference, g as AssetUploadOptions, C as CreateTaskOptions, h as CreateTaskRequest, M as MEDIA_KINDS, i as MediaAsset, j as MediaAssetStatus, k as MediaKind, l as RequestDetails, m as TASK_STATUSES, 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, w as TaskStatus, x as TaskTiming, y as TaskUsage, z as TaskWebhookConfig, B as TerminalTaskStatus, V as VerifyWebhookOptions, W as WaitTaskOptions, D as WatchTaskOptions, E as isTerminalTaskStatus, F as verifyWebhook } from './types-CvKdgo7V.js';
3
- import { H as HttpTransport, q as ModelSearchParams, r as CursorPage, T as TaskModelSummary, s as TaskModel, t as ModelSchema, u as NexraClientOptions, J as JsonValue } from './media-geometry-Ckr1-Mh3.js';
4
- export { b as CreateNexraDisplayQuoteBatchRequest, C as CreateNexraQuoteRequest, F as FetchLike, v as JsonObject, w as JsonPrimitive, M as MediaGeometryField, g as MediaGeometryProjection, x as ModelCapabilitySummary, y as ModelDateVersion, z as ModelEndpointSummary, A as ModelModality, B as ModelResourceList, D as ModelResourceOption, h as NexraBillingCurrency, d as NexraCatalogRevision, 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, U as UnifiedMediaGeometry, m as applyMediaGeometry, n as decodeMediaGeometry, o as encodeMediaGeometry, p as projectMediaGeometry } from './media-geometry-Ckr1-Mh3.js';
1
+ export { a as AssetImportRequest, b as AssetInput, A as AssetReference, c as AssetUploadOptions, M as MEDIA_KINDS, d as MediaAsset, e as MediaAssetStatus, f as MediaKind } from './assets-dUJMQNJD.js';
2
+ import { H as HttpTransport, q as ModelSearchParams, T as TaskModelSummary, r as TaskModel, s as ModelSchema, t as NexraClientOptions } from './media-geometry-Bo6ukeIQ.js';
3
+ export { b as CreateNexraDisplayQuoteBatchRequest, C as CreateNexraQuoteRequest, F as FetchLike, M as MediaGeometryField, g as MediaGeometryProjection, u as ModelCapabilitySummary, v as ModelDateVersion, w as ModelEndpointSummary, x as ModelModality, y as ModelResourceList, z as ModelResourceOption, h as NexraBillingCurrency, d as NexraCatalogRevision, c as NexraDisplayQuoteBatch, A as NexraDisplayQuoteBatchEntry, j as NexraModelOperation, e as NexraModelSpec, f as NexraModelSpecFilter, a as NexraQuote, k as NexraSalePrice, N as NexraSalePriceList, l as NexraSettlement, U as UnifiedMediaGeometry, m as applyMediaGeometry, n as decodeMediaGeometry, o as encodeMediaGeometry, p as projectMediaGeometry } from './media-geometry-Bo6ukeIQ.js';
4
+ import { C as CursorPage, a as JsonValue } from './json-Drjj1OKl.js';
5
+ export { J as JsonObject, b as JsonPrimitive } from './json-Drjj1OKl.js';
6
+ import { A as AssetsClient, T as TasksClient, R as RunTaskOptions, a as RunResult, b as ApiErrorPayload, c as TaskResult } from './types-DPLgTh8D.js';
7
+ export { C as CreateTaskOptions, d as CreateTaskRequest, e as RequestDetails, f as TASK_STATUSES, g as Task, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, V as VerifyWebhookOptions, W as WaitTaskOptions, u as WatchTaskOptions, v as isTerminalTaskStatus, w as verifyWebhook } from './types-DPLgTh8D.js';
5
8
  import { CatalogClient } from './catalog.js';
6
9
  export { getModelSpec, listModelSpecs } from './catalog.js';
7
10
  export { ceilDecimal, multiplyDecimal } from './decimal.js';
@@ -20,7 +23,7 @@ declare class NexraClient {
20
23
  readonly models: ModelsClient;
21
24
  readonly tasks: TasksClient;
22
25
  constructor(options?: NexraClientOptions);
23
- run<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, options: RunTaskOptions<TInput>): Promise<RunResult<TOutput>>;
26
+ run<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, input: TInput, options?: RunTaskOptions): Promise<RunResult<TOutput>>;
24
27
  }
25
28
  declare function createNexra(options?: NexraClientOptions): NexraClient;
26
29
 
package/dist/index.js CHANGED
@@ -1,27 +1,30 @@
1
1
  import {
2
2
  CatalogClient,
3
3
  HttpTransport,
4
- MEDIA_KINDS,
5
4
  NexraApiError,
6
5
  NexraTaskError,
7
6
  NexraWaitTimeoutError,
8
- TASK_STATUSES,
9
7
  applyMediaGeometry,
10
8
  applyNoWatermark,
11
9
  decodeMediaGeometry,
12
10
  encodeMediaGeometry,
13
11
  getModelSpec,
14
- isTerminalTaskStatus,
15
12
  jsonBody,
16
13
  listModelSpecs,
17
14
  projectMediaGeometry,
18
15
  queryString,
19
16
  sleep
20
- } from "./chunk-PAVF5LNU.js";
17
+ } from "./chunk-WU62FGYW.js";
21
18
  import {
22
19
  ceilDecimal,
23
20
  multiplyDecimal
24
21
  } from "./chunk-FCH5IQP5.js";
22
+ import {
23
+ MEDIA_KINDS,
24
+ TASK_STATUSES,
25
+ createTaskRequest,
26
+ isTerminalTaskStatus
27
+ } from "./chunk-TA3YGQQY.js";
25
28
 
26
29
  // src/assets.ts
27
30
  var AssetsClient = class {
@@ -279,20 +282,18 @@ var TasksClient = class {
279
282
  }
280
283
  transport;
281
284
  assets;
282
- async create(model, options) {
285
+ async create(model, input, options = {}) {
283
286
  const schema = getModelSpec(model)?.operations[0]?.inputSchema;
284
- const mapped = schema && options.input && typeof options.input === "object" && !Array.isArray(options.input) ? applyNoWatermark(schema, applyMediaGeometry(schema, options.input)) : options.input;
285
- const input = await normalizeTaskInput(mapped, this.assets, options.signal);
286
- const body = {
287
- model,
288
- input,
287
+ const mapped = schema && input && typeof input === "object" && !Array.isArray(input) ? applyNoWatermark(schema, applyMediaGeometry(schema, input)) : input;
288
+ const normalizedInput = await normalizeTaskInput(mapped, this.assets, options.signal);
289
+ const body = createTaskRequest(model, normalizedInput, {
289
290
  quoteToken: options.quoteToken,
290
291
  submittedAt: options.submittedAt,
291
292
  metadata: options.metadata,
292
293
  callback_url: options.callback_url,
293
294
  webhook: options.webhook,
294
295
  schemaVersion: options.schemaVersion
295
- };
296
+ });
296
297
  const idempotencyKey = options.idempotencyKey ?? crypto.randomUUID();
297
298
  return this.transport.json(
298
299
  "/tasks",
@@ -398,8 +399,8 @@ var TasksClient = class {
398
399
  if (timeout) clearTimeout(timeout);
399
400
  }
400
401
  }
401
- async run(model, options) {
402
- const task = await this.create(model, options);
402
+ async run(model, input, options = {}) {
403
+ const task = await this.create(model, input, options);
403
404
  let completed;
404
405
  try {
405
406
  completed = await this.wait(task.id, options);
@@ -440,8 +441,8 @@ var NexraClient = class {
440
441
  this.models = new ModelsClient(transport);
441
442
  this.tasks = new TasksClient(transport, this.assets);
442
443
  }
443
- run(model, options) {
444
- return this.tasks.run(model, options);
444
+ run(model, input, options = {}) {
445
+ return this.tasks.run(model, input, options);
445
446
  }
446
447
  };
447
448
  function createNexra(options = {}) {
@@ -0,0 +1,11 @@
1
+ type JsonPrimitive = boolean | number | string | null;
2
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
3
+ interface JsonObject {
4
+ [key: string]: JsonValue;
5
+ }
6
+ interface CursorPage<T> {
7
+ data: T[];
8
+ nextCursor?: string;
9
+ }
10
+
11
+ export type { CursorPage as C, JsonObject as J, JsonValue as a, JsonPrimitive as b };
@@ -1,12 +1,4 @@
1
- type JsonPrimitive = boolean | number | string | null;
2
- type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
3
- interface JsonObject {
4
- [key: string]: JsonValue;
5
- }
6
- interface CursorPage<T> {
7
- data: T[];
8
- nextCursor?: string;
9
- }
1
+ import { b as JsonPrimitive, J as JsonObject, a as JsonValue } from './json-Drjj1OKl.js';
10
2
 
11
3
  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
4
  type BillingMetric = (typeof BILLING_METRICS)[number];
@@ -37,6 +29,27 @@ interface MeteringContract {
37
29
  }
38
30
 
39
31
  type ModelModality = "language" | "embedding" | "reranker" | "image" | "video" | "audio" | "world" | "multimodal" | "other";
32
+ /** A concrete operation of a code-owned endpoint contract, shared by API and UI. */
33
+ type ModelHttpOperation = Readonly<{
34
+ key: string;
35
+ kind: "request" | "create" | "query" | "cancel" | "delete" | "stream" | "generate" | "edit";
36
+ httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
37
+ pathTemplate: string;
38
+ schemaProjection: "request" | "bearer-request" | "managed-task-create" | "managed-task-query" | "managed-task-cancel" | "native-task-create" | "native-task-query" | "native-task-delete";
39
+ responseStatus?: number;
40
+ idempotencyKey?: boolean;
41
+ queryParameters?: Readonly<JsonObject>;
42
+ headerParameters?: Readonly<JsonObject>;
43
+ pathParameters?: Readonly<JsonObject>;
44
+ /** Operation-specific body; binary fields describe multipart file parts. */
45
+ bodyParameters?: Readonly<JsonObject>;
46
+ responseBody?: Readonly<JsonObject>;
47
+ requestBody?: Readonly<{
48
+ properties: readonly string[];
49
+ required: readonly string[];
50
+ oneOfRequired?: readonly (readonly string[])[];
51
+ }>;
52
+ }>;
40
53
  interface ModelEndpointSummary {
41
54
  key: string;
42
55
  label: string;
@@ -47,6 +60,8 @@ interface ModelEndpointSummary {
47
60
  capabilities: string[];
48
61
  /** Task execution of this native endpoint, not a second model parameter definition. */
49
62
  sourceEndpointKey?: string | null;
63
+ documentationUrl?: string;
64
+ httpOperations?: readonly ModelHttpOperation[];
50
65
  }
51
66
  interface ModelCapabilitySummary {
52
67
  inputModalities: string[];
@@ -118,6 +133,8 @@ interface TaskModel extends TaskModelSummary {
118
133
  interface ModelSchema {
119
134
  model: string;
120
135
  version: number;
136
+ /** Contract owner for the returned schema. Defaults to nexra for older servers. */
137
+ contract?: "nexra" | "native";
121
138
  dialect: "https://json-schema.org/draft/2020-12/schema" | string;
122
139
  inputSchema: JsonObject;
123
140
  outputSchema: JsonObject;
@@ -284,7 +301,7 @@ declare class HttpTransport {
284
301
  response(path: string, init?: RequestInit, options?: RequestOptions): Promise<Response>;
285
302
  }
286
303
 
287
- /** Unified canvas vocabulary: resolution 1K/2K/4K, ratio X:X. */
304
+ /** UI-friendly view of Nexra's canonical geometry fields. */
288
305
  type UnifiedMediaGeometry = {
289
306
  resolution?: string;
290
307
  ratio?: string;
@@ -292,27 +309,23 @@ type UnifiedMediaGeometry = {
292
309
  };
293
310
  type MediaGeometryField = {
294
311
  field: string;
295
- nest?: string;
296
312
  options: readonly string[];
297
313
  default?: string;
298
314
  optionLabels: Readonly<Record<string, string>>;
299
315
  };
300
316
  type MediaGeometryProjection = {
301
- kind: "pixel-size" | "tier-size" | "resolution-ratio" | "ratio-only" | "none";
317
+ kind: "resolution-ratio" | "ratio-only" | "none";
302
318
  resolution?: MediaGeometryField;
303
319
  ratio?: MediaGeometryField;
304
320
  quality?: MediaGeometryField;
305
321
  };
306
- /** Schema → unified resolution/ratio/quality controls for app UIs. */
322
+ /** Read controls from the Nexra contract. It never exposes provider-native size fields. */
307
323
  declare function projectMediaGeometry(inputSchema: JsonObject): MediaGeometryProjection;
308
- /** Unified geometry → the model's native catalog fields (channel original params). */
324
+ /** UI geometry aliases → canonical Nexra request fields. */
309
325
  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
- */
326
+ /** Canonical Nexra request fields → UI geometry aliases. */
327
+ declare function decodeMediaGeometry(_inputSchema: JsonObject, input: JsonObject): UnifiedMediaGeometry;
328
+ /** Normalize the SDK convenience alias `ratio` without producing Native fields. */
316
329
  declare function applyMediaGeometry(inputSchema: JsonObject, input: JsonObject): JsonObject;
317
330
 
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 };
331
+ export { type NexraDisplayQuoteBatchEntry as A, type CreateNexraQuoteRequest as C, type FetchLike as F, HttpTransport as H, 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 TaskModel as r, type ModelSchema as s, type NexraClientOptions as t, type ModelCapabilitySummary as u, type ModelDateVersion as v, type ModelEndpointSummary as w, type ModelModality as x, type ModelResourceList as y, type ModelResourceOption as z };
@@ -0,0 +1,200 @@
1
+ import { A as AssetReference } from './assets-dUJMQNJD.js';
2
+ import { J as JsonObject } from './json-Drjj1OKl.js';
3
+
4
+ declare const NEXRA_MEDIA_API_VERSION: 1;
5
+ /** Catalog-level generation taxonomy. Text keeps its native endpoint protocols. */
6
+ declare const NEXRA_GENERATION_OPERATIONS: readonly ["text.generate", "image.generate", "video.generate", "audio.generate", "image.upscale", "video.upscale"];
7
+ type NexraGenerationOperation = (typeof NEXRA_GENERATION_OPERATIONS)[number];
8
+ declare const NEXRA_MEDIA_OPERATIONS: readonly ["image.generate", "video.generate", "audio.generate", "image.upscale", "video.upscale"];
9
+ type NexraMediaOperation = (typeof NEXRA_MEDIA_OPERATIONS)[number];
10
+ declare const NEXRA_PUBLISHED_MEDIA_OPERATIONS: readonly ["image.generate", "video.generate", "audio.generate", "image.upscale"];
11
+ type NexraPublishedMediaOperation = (typeof NEXRA_PUBLISHED_MEDIA_OPERATIONS)[number];
12
+ declare const NEXRA_MEDIA_FEATURES: readonly ["text-to-image", "image-to-image", "image-reference", "image-edit", "image-inpaint", "image-control", "text-to-video", "first-frame", "first-last-frame", "image-to-video", "video-to-video", "audio-to-video", "avatar-video", "reference-image", "reference-video", "reference-audio", "omni-reference", "tts", "music", "sfx", "voice-reference", "scale-factor", "target-resolution"];
13
+ type NexraMediaFeature = (typeof NEXRA_MEDIA_FEATURES)[number];
14
+ /** JSON wire locator. SDK-only Blob/File support is normalized into one of these forms. */
15
+ type NexraMediaSource = string | AssetReference;
16
+ type NexraTextRole = "prompt" | "negative_prompt" | "script" | "lyrics";
17
+ type NexraImageRole = "source" | "reference" | "first_frame" | "last_frame" | "mask" | "control" | "subject" | "background";
18
+ type NexraVideoRole = "source" | "reference" | "edit" | "extend";
19
+ type NexraAudioRole = "source" | "reference" | "voice_reference";
20
+ type NexraTextContentPart = Readonly<{
21
+ type: "text";
22
+ text: string;
23
+ role?: NexraTextRole;
24
+ }>;
25
+ type NexraImageContentPart = Readonly<{
26
+ type: "image";
27
+ source: NexraMediaSource;
28
+ role?: NexraImageRole;
29
+ /** Stable prompt reference name for models that address media as `@name`. */
30
+ name?: string;
31
+ }>;
32
+ type NexraVideoContentPart = Readonly<{
33
+ type: "video";
34
+ source: NexraMediaSource;
35
+ role?: NexraVideoRole;
36
+ }>;
37
+ type NexraAudioContentPart = Readonly<{
38
+ type: "audio";
39
+ source: NexraMediaSource;
40
+ role?: NexraAudioRole;
41
+ }>;
42
+ type NexraMediaContentPart = NexraTextContentPart | NexraImageContentPart | NexraVideoContentPart | NexraAudioContentPart;
43
+ type NexraDraftContentPart = Readonly<{
44
+ type: "draft_task";
45
+ draft_task: Readonly<{
46
+ id: string;
47
+ }>;
48
+ }>;
49
+ type NexraImageGenerateInput = Readonly<{
50
+ content: readonly (NexraTextContentPart | NexraImageContentPart)[];
51
+ aspect_ratio?: string;
52
+ resolution?: string;
53
+ quality?: string;
54
+ count?: number;
55
+ output_format?: string;
56
+ seed?: number;
57
+ }>;
58
+ type NexraVideoGenerateInput = Readonly<{
59
+ content: readonly (NexraMediaContentPart | NexraDraftContentPart)[];
60
+ draft?: boolean;
61
+ /** Optional preset or cloned voice used by talking-avatar video models. */
62
+ voice?: string;
63
+ aspect_ratio?: string;
64
+ resolution?: string;
65
+ quality?: string;
66
+ duration?: number;
67
+ generate_audio?: boolean;
68
+ output_format?: string;
69
+ seed?: number;
70
+ }>;
71
+ type NexraAudioGenerateInput = Readonly<{
72
+ content: readonly (NexraTextContentPart | NexraAudioContentPart)[];
73
+ voice?: string;
74
+ language?: string;
75
+ duration?: number;
76
+ output_format?: string;
77
+ sample_rate?: number;
78
+ speed?: number;
79
+ volume?: number;
80
+ pitch?: number;
81
+ emotion?: string;
82
+ instrumental?: boolean;
83
+ loop?: boolean;
84
+ prompt_influence?: number;
85
+ seed?: number;
86
+ }>;
87
+ type NexraImageUpscaleInput = Readonly<{
88
+ content: readonly [NexraImageContentPart];
89
+ scale?: number;
90
+ resolution?: string;
91
+ output_format?: string;
92
+ preserve_details?: boolean;
93
+ }>;
94
+ type NexraVideoUpscaleInput = Readonly<{
95
+ content: readonly [NexraVideoContentPart];
96
+ scale?: number;
97
+ resolution?: string;
98
+ output_format?: string;
99
+ preserve_details?: boolean;
100
+ }>;
101
+ type NexraMediaInputByOperation = Readonly<{
102
+ "image.generate": NexraImageGenerateInput;
103
+ "video.generate": NexraVideoGenerateInput;
104
+ "audio.generate": NexraAudioGenerateInput;
105
+ "image.upscale": NexraImageUpscaleInput;
106
+ "video.upscale": NexraVideoUpscaleInput;
107
+ }>;
108
+ type NexraMediaKind = "image" | "video" | "audio";
109
+ type NexraMediaInputSlot = Readonly<{
110
+ mediaKind: NexraMediaKind;
111
+ role: string;
112
+ min?: number;
113
+ max: number;
114
+ maxBytes?: number;
115
+ minDurationSeconds?: number;
116
+ maxDurationSeconds?: number;
117
+ }>;
118
+ type NexraMediaInputMode = Readonly<{
119
+ id: string;
120
+ slots: readonly NexraMediaInputSlot[];
121
+ }>;
122
+ type NexraMediaParameterValue = string | number | boolean;
123
+ type NexraMediaParameter = Readonly<{
124
+ key: string;
125
+ label?: string;
126
+ }> & (Readonly<{
127
+ kind: "enum";
128
+ options: readonly NexraMediaParameterValue[];
129
+ default: NexraMediaParameterValue;
130
+ allowCustom?: boolean;
131
+ }> | Readonly<{
132
+ kind: "range";
133
+ min: number;
134
+ max: number;
135
+ step: number;
136
+ default: number;
137
+ autoValue?: number;
138
+ unit?: string;
139
+ }> | Readonly<{
140
+ kind: "toggle";
141
+ default: boolean;
142
+ }> | Readonly<{
143
+ kind: "resource";
144
+ resource: "voice";
145
+ default?: string;
146
+ allowCustom?: boolean;
147
+ }>);
148
+ type NexraMediaParameterConstraint = Readonly<{
149
+ when: Readonly<Record<string, NexraMediaParameterValue | readonly NexraMediaParameterValue[]>>;
150
+ parameter: string;
151
+ allowedValues?: readonly NexraMediaParameterValue[];
152
+ fixedValue?: NexraMediaParameterValue;
153
+ disabled?: boolean;
154
+ }>;
155
+ type NexraMediaOperationDefinition = Readonly<{
156
+ operation: NexraMediaOperation;
157
+ status: "active" | "hold";
158
+ outputKind: NexraMediaKind;
159
+ features: readonly NexraMediaFeature[];
160
+ parameterKeys: readonly string[];
161
+ }>;
162
+ declare const NEXRA_MEDIA_OPERATION_DEFINITIONS: readonly [{
163
+ readonly operation: "image.generate";
164
+ readonly status: "active";
165
+ readonly outputKind: "image";
166
+ readonly features: readonly ["text-to-image", "image-to-image", "image-reference", "image-edit", "image-inpaint", "image-control"];
167
+ readonly parameterKeys: readonly ["aspect_ratio", "resolution", "quality", "count", "output_format", "seed"];
168
+ }, {
169
+ readonly operation: "video.generate";
170
+ readonly status: "active";
171
+ readonly outputKind: "video";
172
+ readonly features: readonly ["text-to-video", "first-frame", "first-last-frame", "image-to-video", "video-to-video", "audio-to-video", "avatar-video", "reference-image", "reference-video", "reference-audio", "omni-reference"];
173
+ readonly parameterKeys: readonly ["voice", "aspect_ratio", "resolution", "quality", "duration", "generate_audio", "output_format", "seed"];
174
+ }, {
175
+ readonly operation: "audio.generate";
176
+ readonly status: "active";
177
+ readonly outputKind: "audio";
178
+ readonly features: readonly ["tts", "music", "sfx", "voice-reference"];
179
+ readonly parameterKeys: readonly ["voice", "language", "duration", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion", "instrumental", "loop", "prompt_influence", "seed"];
180
+ }, {
181
+ readonly operation: "image.upscale";
182
+ readonly status: "active";
183
+ readonly outputKind: "image";
184
+ readonly features: readonly ["scale-factor", "target-resolution"];
185
+ readonly parameterKeys: readonly ["scale", "resolution", "output_format", "preserve_details"];
186
+ }, {
187
+ readonly operation: "video.upscale";
188
+ readonly status: "hold";
189
+ readonly outputKind: "video";
190
+ readonly features: readonly ["scale-factor", "target-resolution"];
191
+ readonly parameterKeys: readonly ["scale", "resolution", "output_format", "preserve_details"];
192
+ }];
193
+ declare const NEXRA_MEDIA_INPUT_SCHEMAS: Readonly<Record<NexraPublishedMediaOperation, JsonObject>>;
194
+ declare function nexraMediaInputSchema(operation: NexraMediaOperation): JsonObject | undefined;
195
+ declare function isNexraMediaInput(value: unknown): value is JsonObject;
196
+ declare function nexraMediaOperationForMode(mode: string): NexraPublishedMediaOperation | undefined;
197
+ /** Narrow the shared category vocabulary for one Experience Center input mode. */
198
+ declare function nexraMediaInputSchemaForMode(mode: string): JsonObject | undefined;
199
+
200
+ export { NEXRA_GENERATION_OPERATIONS, NEXRA_MEDIA_API_VERSION, NEXRA_MEDIA_FEATURES, NEXRA_MEDIA_INPUT_SCHEMAS, NEXRA_MEDIA_OPERATIONS, NEXRA_MEDIA_OPERATION_DEFINITIONS, NEXRA_PUBLISHED_MEDIA_OPERATIONS, type NexraAudioContentPart, type NexraAudioGenerateInput, type NexraGenerationOperation, type NexraImageContentPart, type NexraImageGenerateInput, type NexraImageUpscaleInput, type NexraMediaContentPart, type NexraMediaFeature, type NexraMediaInputByOperation, type NexraMediaInputMode, type NexraMediaInputSlot, type NexraMediaKind, type NexraMediaOperation, type NexraMediaOperationDefinition, type NexraMediaParameter, type NexraMediaParameterConstraint, type NexraMediaSource, type NexraPublishedMediaOperation, type NexraTextContentPart, type NexraVideoContentPart, type NexraVideoGenerateInput, type NexraVideoUpscaleInput, isNexraMediaInput, nexraMediaInputSchema, nexraMediaInputSchemaForMode, nexraMediaOperationForMode };
package/dist/media.js ADDED
@@ -0,0 +1,26 @@
1
+ import {
2
+ NEXRA_GENERATION_OPERATIONS,
3
+ NEXRA_MEDIA_API_VERSION,
4
+ NEXRA_MEDIA_FEATURES,
5
+ NEXRA_MEDIA_INPUT_SCHEMAS,
6
+ NEXRA_MEDIA_OPERATIONS,
7
+ NEXRA_MEDIA_OPERATION_DEFINITIONS,
8
+ NEXRA_PUBLISHED_MEDIA_OPERATIONS,
9
+ isNexraMediaInput,
10
+ nexraMediaInputSchema,
11
+ nexraMediaInputSchemaForMode,
12
+ nexraMediaOperationForMode
13
+ } from "./chunk-TA3YGQQY.js";
14
+ export {
15
+ NEXRA_GENERATION_OPERATIONS,
16
+ NEXRA_MEDIA_API_VERSION,
17
+ NEXRA_MEDIA_FEATURES,
18
+ NEXRA_MEDIA_INPUT_SCHEMAS,
19
+ NEXRA_MEDIA_OPERATIONS,
20
+ NEXRA_MEDIA_OPERATION_DEFINITIONS,
21
+ NEXRA_PUBLISHED_MEDIA_OPERATIONS,
22
+ isNexraMediaInput,
23
+ nexraMediaInputSchema,
24
+ nexraMediaInputSchemaForMode,
25
+ nexraMediaOperationForMode
26
+ };
@@ -1,62 +1,6 @@
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
- }
1
+ import { d as MediaAsset, c as AssetUploadOptions, a as AssetImportRequest, g as AssetCertificationRequest, h as AssetCertification, i as AssetCertificationWaitOptions } from './assets-dUJMQNJD.js';
2
+ import { l as NexraSettlement, H as HttpTransport } from './media-geometry-Bo6ukeIQ.js';
3
+ import { J as JsonObject, a as JsonValue, C as CursorPage } from './json-Drjj1OKl.js';
60
4
 
61
5
  interface ApiErrorPayload {
62
6
  error: {
@@ -243,17 +187,16 @@ interface TaskEvent {
243
187
  occurredAt: string;
244
188
  }
245
189
  /** @deprecated Use CreateTaskRequest.callback_url. Kept for existing callers. */
246
- interface TaskWebhookConfig {
190
+ type TaskWebhookConfig = JsonObject & Readonly<{
247
191
  url: string;
248
192
  /** Shared HMAC secret used to verify Nexra callback signatures. */
249
193
  secret: string;
250
194
  events?: Array<"completed">;
251
- }
252
- interface CreateTaskRequest<TInput = Record<string, unknown>> {
195
+ }>;
196
+ type CreateTaskControls = Readonly<{
253
197
  /** @internal Console telemetry only: browser send time before uploads, not execution time. */
254
198
  submittedAt?: string;
255
199
  model: string;
256
- input: TInput;
257
200
  /** Signed Nexra quote used to lock this input to a sale-price revision. */
258
201
  quoteToken?: string;
259
202
  /** Optional business identifiers such as orderId, available in request details. Do not include secrets. */
@@ -264,7 +207,11 @@ interface CreateTaskRequest<TInput = Record<string, unknown>> {
264
207
  webhook?: TaskWebhookConfig;
265
208
  /** @deprecated Compatibility check only; the server resolves the current contract. */
266
209
  schemaVersion?: number;
267
- }
210
+ }>;
211
+ /** Public Nexra Task request. Category parameters are top-level fields; `input`
212
+ * is deliberately not an envelope. Persistent Task records still retain their
213
+ * own `input` snapshot after the HTTP boundary separates control fields. */
214
+ type CreateTaskRequest<TInput extends JsonObject = JsonObject> = TInput & CreateTaskControls;
268
215
  interface TaskListParams {
269
216
  status?: TaskStatus;
270
217
  model?: string;
@@ -295,8 +242,7 @@ declare class AssetsClient {
295
242
  stream(asset: MediaAsset | string, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
296
243
  }
297
244
 
298
- interface CreateTaskOptions<TInput = Record<string, unknown>> {
299
- input: TInput;
245
+ interface CreateTaskOptions {
300
246
  quoteToken?: string;
301
247
  submittedAt?: string;
302
248
  metadata?: JsonObject;
@@ -317,20 +263,20 @@ interface WaitTaskOptions extends WatchTaskOptions {
317
263
  pollIntervalMs?: number;
318
264
  onEvent?: (event: TaskEvent) => void | Promise<void>;
319
265
  }
320
- interface RunTaskOptions<TInput = Record<string, unknown>> extends CreateTaskOptions<TInput>, WaitTaskOptions {
266
+ interface RunTaskOptions extends CreateTaskOptions, WaitTaskOptions {
321
267
  cancelOnAbort?: boolean;
322
268
  }
323
269
  declare class TasksClient {
324
270
  private readonly transport;
325
271
  private readonly assets;
326
272
  constructor(transport: HttpTransport, assets: AssetsClient);
327
- create<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, options: CreateTaskOptions<TInput>): Promise<TaskReceipt>;
273
+ create<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, input: TInput, options?: CreateTaskOptions): Promise<TaskReceipt>;
328
274
  get<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskResult<TOutput>>;
329
275
  list<TOutput = JsonValue>(params?: TaskListParams, signal?: AbortSignal): Promise<CursorPage<TaskResult<TOutput>>>;
330
276
  cancel<TOutput = JsonValue>(taskId: string, signal?: AbortSignal): Promise<TaskReceipt>;
331
277
  watch(taskId: string, options?: WatchTaskOptions): AsyncGenerator<TaskEvent>;
332
278
  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>>;
279
+ run<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, input: TInput, options?: RunTaskOptions): Promise<RunResult<TOutput>>;
334
280
  }
335
281
 
336
282
  interface VerifyWebhookOptions {
@@ -340,4 +286,4 @@ interface VerifyWebhookOptions {
340
286
  /** @deprecated Only verifies legacy signed webhooks, not callback_url notifications. */
341
287
  declare function verifyWebhook(request: Request, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
342
288
 
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 };
289
+ export { AssetsClient as A, type CreateTaskOptions as C, 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 CreateTaskRequest as d, type RequestDetails as e, TASK_STATUSES as f, type Task as g, type TaskCost as h, type TaskError as i, type TaskEvent as j, type TaskEventType as k, type TaskListParams as l, type TaskPage as m, type TaskProgress as n, type TaskReceipt as o, type TaskStatus as p, type TaskTiming as q, type TaskUsage as r, type TaskWebhookConfig as s, type TerminalTaskStatus as t, type WatchTaskOptions as u, isTerminalTaskStatus as v, verifyWebhook as w };
package/dist/types.d.ts CHANGED
@@ -1,2 +1,4 @@
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';
1
+ export { a as AssetImportRequest, b as AssetInput, A as AssetReference, c as AssetUploadOptions, d as MediaAsset, e as MediaAssetStatus, f as MediaKind } from './assets-dUJMQNJD.js';
2
+ export { b as CreateNexraDisplayQuoteBatchRequest, C as CreateNexraQuoteRequest, F as FetchLike, M as MediaGeometryField, g as MediaGeometryProjection, u as ModelCapabilitySummary, v as ModelDateVersion, w as ModelEndpointSummary, x as ModelModality, y as ModelResourceList, z as ModelResourceOption, s as ModelSchema, q as ModelSearchParams, h as NexraBillingCurrency, d as NexraCatalogRevision, t as NexraClientOptions, c as NexraDisplayQuoteBatch, A as NexraDisplayQuoteBatchEntry, j as NexraModelOperation, e as NexraModelSpec, f as NexraModelSpecFilter, a as NexraQuote, k as NexraSalePrice, N as NexraSalePriceList, l as NexraSettlement, r as TaskModel, T as TaskModelSummary, U as UnifiedMediaGeometry } from './media-geometry-Bo6ukeIQ.js';
3
+ export { C as CursorPage, J as JsonObject, b as JsonPrimitive, a as JsonValue } from './json-Drjj1OKl.js';
4
+ export { b as ApiErrorPayload, C as CreateTaskOptions, d as CreateTaskRequest, e as RequestDetails, a as RunResult, R as RunTaskOptions, g as Task, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, c as TaskResult, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, V as VerifyWebhookOptions, W as WaitTaskOptions, u as WatchTaskOptions } from './types-DPLgTh8D.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byte_fluffy/nexra-sdk",
3
- "version": "0.1.0-alpha.20",
3
+ "version": "0.1.0-alpha.21",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "sideEffects": false,
@@ -32,6 +32,10 @@
32
32
  "./types": {
33
33
  "types": "./dist/types.d.ts",
34
34
  "import": "./dist/types.js"
35
+ },
36
+ "./media": {
37
+ "types": "./dist/media.d.ts",
38
+ "import": "./dist/media.js"
35
39
  }
36
40
  },
37
41
  "publishConfig": {