@pointcosm/sdk 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,849 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ BillingApi: () => BillingApi,
24
+ CONTRACT: () => CONTRACT,
25
+ LiveCosmApi: () => LiveCosmApi,
26
+ Pointcosm: () => Pointcosm,
27
+ PointcosmApiError: () => PointcosmApiError,
28
+ PointcosmAuthenticationError: () => PointcosmAuthenticationError,
29
+ PointcosmAuthorizationError: () => PointcosmAuthorizationError,
30
+ PointcosmConfigurationError: () => PointcosmConfigurationError,
31
+ PointcosmContractError: () => PointcosmContractError,
32
+ PointcosmError: () => PointcosmError,
33
+ PointcosmRateLimitError: () => PointcosmRateLimitError,
34
+ PointcosmServerError: () => PointcosmServerError,
35
+ PointcosmTimeoutError: () => PointcosmTimeoutError,
36
+ PointcosmTransportError: () => PointcosmTransportError,
37
+ PointcosmValidationError: () => PointcosmValidationError,
38
+ Secret: () => Secret,
39
+ StorageApi: () => StorageApi,
40
+ TrainApi: () => TrainApi,
41
+ WebhooksApi: () => WebhooksApi
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
44
+
45
+ // src/errors.ts
46
+ var MAX_TEXT = 1024;
47
+ var MAX_DEPTH = 4;
48
+ var MAX_ITEMS = 20;
49
+ var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
50
+ "access_key_id",
51
+ "access_key_secret",
52
+ "authorization",
53
+ "client_secret",
54
+ "cookie",
55
+ "secret",
56
+ "security_token",
57
+ "token",
58
+ "url"
59
+ ]);
60
+ function safeDetails(value, depth = MAX_DEPTH) {
61
+ if (depth <= 0) return "<truncated>";
62
+ if (Array.isArray(value)) {
63
+ return value.slice(0, MAX_ITEMS).map((item) => safeDetails(item, depth - 1));
64
+ }
65
+ if (value !== null && typeof value === "object") {
66
+ const result = {};
67
+ for (const [key, child] of Object.entries(value).slice(0, MAX_ITEMS)) {
68
+ const name = key.slice(0, 128);
69
+ result[name] = SENSITIVE_KEYS.has(name.toLowerCase()) ? "**********" : safeDetails(child, depth - 1);
70
+ }
71
+ return result;
72
+ }
73
+ if (typeof value === "string") return value.slice(0, MAX_TEXT);
74
+ if (value === null || typeof value === "boolean" || typeof value === "number") return value;
75
+ return `<${typeof value}>`;
76
+ }
77
+ var text = (value, fallback) => (typeof value === "string" && value ? value : fallback).slice(0, MAX_TEXT);
78
+ function localized(value) {
79
+ if (value === null || typeof value !== "object") return null;
80
+ const { locale, message } = value;
81
+ if (typeof locale !== "string" || typeof message !== "string" || !message) return null;
82
+ return { locale: locale.slice(0, 64), message: message.slice(0, MAX_TEXT) };
83
+ }
84
+ var PointcosmError = class extends Error {
85
+ name = "PointcosmError";
86
+ };
87
+ var PointcosmApiError = class extends PointcosmError {
88
+ name = "PointcosmApiError";
89
+ statusCode;
90
+ code;
91
+ details;
92
+ requestId;
93
+ operationId;
94
+ localizedMessage;
95
+ constructor(init) {
96
+ super(text(init.message, "PointCosm API request failed"));
97
+ this.statusCode = init.statusCode;
98
+ this.code = text(init.code, "api_error");
99
+ const details = init.details;
100
+ this.details = details !== null && typeof details === "object" && !Array.isArray(details) ? safeDetails(details) : null;
101
+ this.requestId = init.requestId;
102
+ this.operationId = init.operationId;
103
+ this.localizedMessage = localized(init.localizedMessage);
104
+ }
105
+ };
106
+ var PointcosmAuthenticationError = class extends PointcosmApiError {
107
+ name = "PointcosmAuthenticationError";
108
+ };
109
+ var PointcosmAuthorizationError = class extends PointcosmApiError {
110
+ name = "PointcosmAuthorizationError";
111
+ };
112
+ var PointcosmValidationError = class extends PointcosmApiError {
113
+ name = "PointcosmValidationError";
114
+ };
115
+ var PointcosmRateLimitError = class extends PointcosmApiError {
116
+ name = "PointcosmRateLimitError";
117
+ };
118
+ var PointcosmServerError = class extends PointcosmApiError {
119
+ name = "PointcosmServerError";
120
+ };
121
+ var PointcosmTransportError = class extends PointcosmError {
122
+ name = "PointcosmTransportError";
123
+ operationId;
124
+ constructor(operationId, options) {
125
+ super(`transport failure for operation "${operationId}"`, options);
126
+ this.operationId = operationId;
127
+ }
128
+ };
129
+ var PointcosmTimeoutError = class extends PointcosmTransportError {
130
+ name = "PointcosmTimeoutError";
131
+ };
132
+ var PointcosmContractError = class extends PointcosmError {
133
+ name = "PointcosmContractError";
134
+ reason;
135
+ operationId;
136
+ statusCode;
137
+ requestId;
138
+ constructor(reason, operationId, statusCode = null, requestId = null) {
139
+ super(`contract failure reason="${reason}" operation="${operationId}" status=${statusCode}`);
140
+ this.reason = reason;
141
+ this.operationId = operationId;
142
+ this.statusCode = statusCode;
143
+ this.requestId = requestId;
144
+ }
145
+ };
146
+ var PointcosmConfigurationError = class extends PointcosmError {
147
+ name = "PointcosmConfigurationError";
148
+ };
149
+ function apiError(init) {
150
+ const status = init.statusCode;
151
+ const type = status === 401 ? PointcosmAuthenticationError : status === 403 ? PointcosmAuthorizationError : status === 422 ? PointcosmValidationError : status === 429 ? PointcosmRateLimitError : status >= 500 ? PointcosmServerError : PointcosmApiError;
152
+ return new type(init);
153
+ }
154
+
155
+ // src/internal/auth.ts
156
+ var OPERATION = "auth_tokens_issue";
157
+ var formEncode = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g, "+");
158
+ var TokenProvider = class {
159
+ #credentials;
160
+ #fetch;
161
+ #timeoutMs;
162
+ #now;
163
+ #token = null;
164
+ #pending = null;
165
+ constructor(credentials, fetchImpl, timeoutMs, now = () => performance.now()) {
166
+ this.#credentials = credentials;
167
+ this.#fetch = fetchImpl;
168
+ this.#timeoutMs = timeoutMs;
169
+ this.#now = now;
170
+ }
171
+ async get() {
172
+ const current = this.#token;
173
+ if (current && this.#now() < current.refreshAt) return current.value;
174
+ this.#pending ??= this.#issue().finally(() => {
175
+ this.#pending = null;
176
+ });
177
+ try {
178
+ return (await this.#pending).value;
179
+ } catch (error) {
180
+ if (error instanceof PointcosmError && current && this.#now() < current.expiresAt) {
181
+ return current.value;
182
+ }
183
+ throw error;
184
+ }
185
+ }
186
+ clear() {
187
+ this.#token = null;
188
+ }
189
+ async #issue() {
190
+ const { authBaseUrl, clientId, clientSecret, resource } = this.#credentials;
191
+ const obtainedAt = this.#now();
192
+ let response;
193
+ let payload;
194
+ try {
195
+ response = await this.#fetch(`${authBaseUrl}/api/oauth/token`, {
196
+ method: "POST",
197
+ headers: {
198
+ Authorization: `Basic ${btoa(`${formEncode(clientId)}:${formEncode(clientSecret)}`)}`,
199
+ Accept: "application/json",
200
+ "Content-Type": "application/x-www-form-urlencoded"
201
+ },
202
+ body: new URLSearchParams({ grant_type: "client_credentials", resource }).toString(),
203
+ redirect: "manual",
204
+ signal: AbortSignal.timeout(this.#timeoutMs)
205
+ });
206
+ payload = await response.json().catch(() => void 0);
207
+ } catch (error) {
208
+ if (error instanceof Error && error.name === "TimeoutError") {
209
+ throw new PointcosmTimeoutError(OPERATION);
210
+ }
211
+ throw new PointcosmTransportError(OPERATION);
212
+ }
213
+ const status = response.status;
214
+ if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
215
+ throw new PointcosmContractError("invalid-oauth-envelope", OPERATION, status);
216
+ }
217
+ const body = payload;
218
+ if (status !== 200) {
219
+ const type = status === 429 ? PointcosmRateLimitError : status >= 500 ? PointcosmServerError : PointcosmAuthenticationError;
220
+ throw new type({
221
+ statusCode: status,
222
+ code: body.error,
223
+ message: body.error_description,
224
+ details: null,
225
+ requestId: response.headers.get("x-request-id"),
226
+ operationId: OPERATION
227
+ });
228
+ }
229
+ const expiresIn = body.expires_in;
230
+ if (typeof body.access_token !== "string" || !body.access_token || body.token_type !== "Bearer" || typeof expiresIn !== "number" || !Number.isInteger(expiresIn) || expiresIn <= 0 || "refresh_token" in body || "refresh_expires_in" in body) {
231
+ throw new PointcosmContractError("invalid-oauth-token", OPERATION, status);
232
+ }
233
+ const expiresAt = obtainedAt + expiresIn * 1e3;
234
+ const margin = Math.min(60, Math.max(1, expiresIn * 0.1)) * 1e3;
235
+ this.#token = { value: body.access_token, expiresAt, refreshAt: expiresAt - margin };
236
+ return this.#token;
237
+ }
238
+ };
239
+
240
+ // src/generated/contract.ts
241
+ var CONTRACT = {
242
+ "revision": "5c16aa762ae0ada16aaaa021390ee1af0d6bd710",
243
+ "bundleRelease": "0.14.0",
244
+ "bundleSha256": "45937ba6295d8c6efd57af85ae6230fd7dbd124dac724c0e26a32c4d168c5bcc",
245
+ "customerSha256": "5db91d0b1a7ac4dc6eafe2df6b79fba31607bc54e108221987ea3bc0c3c66c4c",
246
+ "authSha256": "ff17917c6ccab2fcf1cb6c2ee0392c2efea6dfca567d084a6434836c36c489cf",
247
+ "operationCount": 37,
248
+ "generator": "openapi-typescript 7.13.0"
249
+ };
250
+ var OPERATIONS = {
251
+ billing_green_point_purchase_orders_list: { "method": "GET", "path": "/api/v1/payment/commerce-orders", "retry": true, "meta": true, "data": { "$ref": "PaymentOrderListData" } },
252
+ billing_green_points_account_retrieve: { "method": "GET", "path": "/api/v1/green-points/account", "retry": true, "meta": false, "data": { "$ref": "PublicGreenPointAccountOut" } },
253
+ billing_green_points_ledger_list: { "method": "GET", "path": "/api/v1/green-points/ledger", "retry": true, "meta": false, "data": { "$ref": "GreenPointCustomerLedgerPage" } },
254
+ storage_assets_admission_check: { "method": "GET", "path": "/api/v1/assets/{asset_id}/admission", "retry": true, "meta": false, "data": { "$ref": "AssetAdmissionOut" } },
255
+ storage_assets_complete_upload: { "method": "POST", "path": "/api/v1/assets/{id}/upload-complete", "retry": true, "meta": false, "data": { "$ref": "AssetCreateOut" } },
256
+ storage_assets_create: { "method": "POST", "path": "/api/v1/assets", "retry": false, "meta": false, "data": { "$ref": "AssetCreateOut" } },
257
+ storage_assets_create_credentials: { "method": "POST", "path": "/api/v1/assets/{id}/credentials", "retry": false, "meta": false, "data": { "$ref": "StorageCredentialsOut" } },
258
+ storage_assets_delete: { "method": "DELETE", "path": "/api/v1/assets/{id}", "retry": false, "meta": false, "data": null },
259
+ storage_assets_files_list: { "method": "GET", "path": "/api/v1/assets/{id}/files", "retry": true, "meta": false, "data": { "$ref": "AssetFileListOut" } },
260
+ storage_assets_list: { "method": "GET", "path": "/api/v1/assets", "retry": true, "meta": false, "data": { "$ref": "AssetListOut" } },
261
+ storage_assets_retrieve: { "method": "GET", "path": "/api/v1/assets/{id}", "retry": true, "meta": false, "data": { "$ref": "AssetDetailOut" } },
262
+ stream_config_get: { "method": "GET", "path": "/api/v1/stream-config", "retry": true, "meta": false, "data": { "$ref": "StreamConfigOut" } },
263
+ stream_models_list: { "method": "GET", "path": "/api/v1/stream-models", "retry": true, "meta": false, "data": { "$ref": "StreamModelPage" } },
264
+ stream_models_register: { "method": "POST", "path": "/api/v1/stream-models", "retry": true, "meta": false, "data": { "$ref": "StreamModelOut" } },
265
+ stream_models_revoke: { "method": "DELETE", "path": "/api/v1/stream-models/{model_id}", "retry": true, "meta": false, "data": null },
266
+ stream_sessions_create: { "method": "POST", "path": "/api/v1/stream-sessions", "retry": false, "meta": false, "data": { "$ref": "StreamSessionOut" } },
267
+ stream_sessions_get: { "method": "GET", "path": "/api/v1/stream-sessions/{session_id}", "retry": true, "meta": false, "data": { "$ref": "StreamSessionOut" } },
268
+ stream_sessions_guest_link: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/guest-link", "retry": false, "meta": false, "data": { "$ref": "StreamGuestLinkOut" } },
269
+ stream_sessions_host_link: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/host-link", "retry": false, "meta": false, "data": { "$ref": "StreamLinkOut" } },
270
+ stream_sessions_list: { "method": "GET", "path": "/api/v1/stream-sessions", "retry": true, "meta": false, "data": { "$ref": "StreamSessionPage" } },
271
+ stream_sessions_member_remove: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/members/{member_id}/remove", "retry": true, "meta": false, "data": null },
272
+ stream_sessions_members: { "method": "GET", "path": "/api/v1/stream-sessions/{session_id}/members", "retry": true, "meta": false, "data": { "$ref": "StreamMembersOut" } },
273
+ stream_sessions_stop: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/stop", "retry": true, "meta": false, "data": { "$ref": "StreamSessionOut" } },
274
+ train_artifacts_create_download_url: { "method": "GET", "path": "/api/v1/tasks/{id}/artifacts/{artifact_id}/download", "retry": false, "meta": false, "data": { "$ref": "ArtifactDownloadOut" } },
275
+ train_artifacts_list: { "method": "GET", "path": "/api/v1/tasks/{id}/artifacts", "retry": true, "meta": false, "data": { "$ref": "ArtifactListOut" } },
276
+ train_products_list: { "method": "GET", "path": "/api/v1/products", "retry": true, "meta": false, "data": { "$ref": "PublicProductListOut" } },
277
+ train_products_retrieve: { "method": "GET", "path": "/api/v1/products/{id}", "retry": true, "meta": false, "data": { "$ref": "PublicProductOut" } },
278
+ train_tasks_cancel: { "method": "POST", "path": "/api/v1/tasks/{id}/cancel", "retry": false, "meta": false, "data": { "$ref": "TaskCancelOut" } },
279
+ train_tasks_create: { "method": "POST", "path": "/api/v1/tasks", "retry": false, "meta": false, "data": { "$ref": "TaskOut" } },
280
+ train_tasks_delete: { "method": "DELETE", "path": "/api/v1/tasks/{id}", "retry": false, "meta": false, "data": null },
281
+ train_tasks_finalization_get: { "method": "GET", "path": "/api/v1/tasks/{id}/finalization", "retry": true, "meta": false, "data": { "$ref": "CustomerFinalizationData" } },
282
+ train_tasks_list: { "method": "GET", "path": "/api/v1/tasks", "retry": true, "meta": false, "data": { "$ref": "TaskListOut" } },
283
+ train_tasks_retrieve: { "method": "GET", "path": "/api/v1/tasks/{id}", "retry": true, "meta": false, "data": { "$ref": "TaskDetailOut" } },
284
+ webhooks_configuration_disable: { "method": "DELETE", "path": "/api/v1/webhook", "retry": false, "meta": false, "data": { "$ref": "WebhookConfigurationOut" } },
285
+ webhooks_configuration_retrieve: { "method": "GET", "path": "/api/v1/webhook", "retry": true, "meta": false, "data": { "$ref": "WebhookConfigurationOut" } },
286
+ webhooks_configuration_update: { "method": "PUT", "path": "/api/v1/webhook", "retry": false, "meta": false, "data": { "$ref": "WebhookMutationOut" } },
287
+ webhooks_secret_rotate: { "method": "POST", "path": "/api/v1/webhook/rotate-secret", "retry": false, "meta": false, "data": { "$ref": "WebhookSecretRotationOut" } }
288
+ };
289
+ var SCHEMAS = {
290
+ AdmissionReasonOut: { "type": "object", "required": ["code", "message"], "properties": { "code": { "type": "string" }, "message": { "type": "string" } } },
291
+ ArtifactDownloadOut: { "type": "object", "required": ["url"], "properties": { "url": { "secret": true, "type": "string" } } },
292
+ ArtifactListOut: { "type": "object", "required": ["items", "total", "offset", "limit", "task_id"], "properties": { "items": { "type": "array", "items": { "$ref": "ArtifactOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" }, "task_id": { "type": "string" }, "pipeline_code": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
293
+ ArtifactOut: { "type": "object", "required": ["artifact_id", "kind", "name", "size_bytes", "download_url", "download_count", "max_downloads", "stream_registerable"], "properties": { "artifact_id": { "type": "string" }, "kind": { "type": "string", "const": "file" }, "name": { "type": "string" }, "size_bytes": { "type": "integer" }, "download_url": { "type": "string" }, "download_count": { "type": "integer" }, "max_downloads": { "type": "integer" }, "asset_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "key": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "stream_registerable": { "type": "boolean" } } },
294
+ AssetAdmissionOut: { "type": "object", "required": ["asset_id", "product_id", "admissible", "policy_digest"], "properties": { "asset_id": { "type": "string" }, "product_id": { "type": "string" }, "admissible": { "type": "boolean" }, "input_digest": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "policy_digest": { "type": "string" }, "reasons": { "type": "array", "items": { "$ref": "AdmissionReasonOut" } } } },
295
+ AssetCreateOut: { "type": "object", "required": ["flow", "asset"], "properties": { "flow": { "$ref": "AssetUploadFlowOut" }, "asset": { "$ref": "AssetOut" }, "storage_credentials": { "anyOf": [{ "$ref": "StorageCredentialsOut" }, { "type": "null" }] } } },
296
+ AssetDetailOut: { "type": "object", "required": ["id", "name", "source_type", "asset_type", "status", "upload_mode", "created_at", "flow"], "properties": { "extension_stats": { "anyOf": [{ "type": "object", "additionalProperties": { "type": "object", "additionalProperties": { "type": "integer" } } }, { "type": "null" }] }, "validation_strength": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "digest_verification": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "id": { "type": "string" }, "upload_flow_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "name": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "source_type": { "anyOf": [{ "$ref": "AssetSourceType" }, { "type": "null" }] }, "asset_type": { "anyOf": [{ "type": "string", "enum": ["images", "video", "mixed"] }, { "type": "null" }] }, "status": { "type": "string", "enum": ["pending", "validating", "ready", "invalid", "failed", "expired"] }, "upload_mode": { "type": "string", "enum": ["direct_upload", "oss_copy", "netdisk", "datasource"] }, "object_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "image_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "video_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "logical_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "duration_seconds": { "anyOf": [{ "type": "number" }, { "type": "null" }] }, "timelapse_video_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "error_code": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "error_message": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "ready_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "retention_until": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "created_at": { "type": "string" }, "flow": { "anyOf": [{ "$ref": "AssetUploadFlowOut" }, { "type": "null" }] } } },
297
+ AssetFileListOut: { "type": "object", "required": ["items", "total", "offset", "limit", "files_available"], "properties": { "items": { "type": "array", "items": { "$ref": "AssetFileOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" }, "files_available": { "type": "boolean" } } },
298
+ AssetFileOut: { "type": "object", "required": ["path", "size_bytes", "media_type", "duration_seconds", "video_track_count", "lens_track_count", "frame_count", "timelapse_interval_ms"], "properties": { "path": { "type": "string" }, "size_bytes": { "type": "integer" }, "media_type": { "type": "string", "enum": ["image", "video", "other"] }, "duration_seconds": { "anyOf": [{ "type": "number" }, { "type": "null" }] }, "video_track_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "lens_track_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "frame_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "timelapse_interval_ms": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
299
+ AssetListOut: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "AssetOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
300
+ AssetOut: { "type": "object", "required": ["id", "name", "source_type", "asset_type", "status", "upload_mode", "created_at"], "properties": { "extension_stats": { "anyOf": [{ "type": "object", "additionalProperties": { "type": "object", "additionalProperties": { "type": "integer" } } }, { "type": "null" }] }, "validation_strength": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "digest_verification": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "id": { "type": "string" }, "upload_flow_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "name": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "source_type": { "anyOf": [{ "$ref": "AssetSourceType" }, { "type": "null" }] }, "asset_type": { "anyOf": [{ "type": "string", "enum": ["images", "video", "mixed"] }, { "type": "null" }] }, "status": { "type": "string", "enum": ["pending", "validating", "ready", "invalid", "failed", "expired"] }, "upload_mode": { "type": "string", "enum": ["direct_upload", "oss_copy", "netdisk", "datasource"] }, "object_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "image_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "video_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "logical_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "duration_seconds": { "anyOf": [{ "type": "number" }, { "type": "null" }] }, "timelapse_video_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "error_code": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "error_message": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "ready_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "retention_until": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "created_at": { "type": "string" } } },
301
+ AssetSourceType: { "type": "string", "enum": ["platform_upload", "platform_copy", "netdisk", "datasource"] },
302
+ AssetUploadFlowOut: { "type": "object", "required": ["id", "asset_id", "product_id", "input_mode", "input_limits", "status", "limits", "error_code", "error_message", "completed_at"], "properties": { "id": { "type": "string" }, "asset_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "product_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "auto_train": { "type": "boolean" }, "auto_train_task_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "auto_train_error_code": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "input_mode": { "anyOf": [{ "type": "string", "enum": ["images", "video", "mixed"] }, { "type": "null" }] }, "input_limits": { "anyOf": [{ "type": "object", "additionalProperties": { "$ref": "ProductUploadInputLimit" } }, { "type": "null" }] }, "status": { "type": "string", "enum": ["preparing", "uploading", "ingesting", "validating", "completed", "failed"] }, "processing_status": { "anyOf": [{ "type": "string", "enum": ["queued", "running"] }, { "type": "null" }] }, "limits": { "$ref": "InputLimitsOut" }, "error_code": { "anyOf": [{ "type": "string", "enum": ["validation_failed_state", "validation_failed_type", "validation_failed_path", "validation_failed_count", "validation_failed_size", "validation_failed_integrity", "validation_failed_duration", "SOURCE_AUTHORIZATION_INVALID", "SOURCE_CONTENT_CHANGED", "SOURCE_DISABLED", "SOURCE_UNAVAILABLE", "SOURCE_CONTRACT_INVALID", "SOURCE_ACCESS_DENIED", "SOURCE_DATASET_NOT_FOUND", "NETDISK_BINDING_NOT_FOUND", "UPLOAD_LIMIT_EXCEEDED", "ASSET_RETIRED", "asset_ingestion_failed", "asset_storage_finalization_timeout"] }, { "type": "null" }] }, "error_message": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "completed_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
303
+ CustomerFailureCode: { "type": "string", "enum": ["input_invalid", "input_source_unavailable", "insufficient_balance", "scheduling_failed", "preparation_failed", "training_failed", "runtime_exceeded", "output_failed", "platform_error"] },
304
+ CustomerFinalizationData: { "type": "object", "required": ["mode", "stage", "task_status", "handoff_accepted", "output_files", "system_logs", "files_pending", "updated_at"], "properties": { "mode": { "type": "string", "enum": ["agent_handoff", "not_started"] }, "stage": { "type": "string", "enum": ["waiting_worker", "uploading", "verifying", "finished", "interrupted", "not_supported"] }, "task_status": { "$ref": "TaskStatus" }, "handoff_accepted": { "type": "boolean" }, "output_files": { "$ref": "OutputFilesView" }, "system_logs": { "$ref": "SystemLogsView" }, "files_pending": { "type": "boolean" }, "updated_at": { "type": "string" } } },
305
+ DiscountMoney: { "type": "object", "required": ["currency", "currency_exponent", "amount_minor"], "properties": { "currency": { "type": "string" }, "currency_exponent": { "type": "integer" }, "amount_minor": { "type": "integer" } } },
306
+ GreenPointCustomerLedgerEntryOut: { "type": "object", "required": ["id", "entry_type", "available_delta", "reserved_delta", "available_balance_after", "reserved_balance_after", "points", "business_type", "description", "created_at", "commerce_order_id", "order_no"], "properties": { "id": { "type": "string" }, "entry_type": { "type": "string" }, "available_delta": { "type": "integer" }, "reserved_delta": { "type": "integer" }, "available_balance_after": { "type": "integer" }, "reserved_balance_after": { "type": "integer" }, "points": { "type": "integer" }, "business_type": { "type": "string" }, "task_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "description": { "type": "string" }, "created_at": { "type": "string" }, "commerce_order_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "order_no": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
307
+ GreenPointCustomerLedgerPage: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "GreenPointCustomerLedgerEntryOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
308
+ GreenPointFulfillmentParameters: { "type": "object", "required": ["paid_green_points", "promotional_green_points", "schema_version"], "properties": { "paid_green_points": { "type": "integer" }, "promotional_green_points": { "type": "integer" }, "schema_version": { "type": "string", "const": "train-v1" } } },
309
+ InputComposition: { "type": "object", "required": ["root_files_only", "required_any_extensions", "exclusive_extension_groups"], "properties": { "root_files_only": { "type": "boolean" }, "required_any_extensions": { "type": "array", "items": { "type": "string" } }, "exclusive_extension_groups": { "type": "array", "items": { "type": "array", "items": { "type": "string" } } } } },
310
+ InputLimitsOut: { "type": "object", "required": ["allowed_extensions", "max_file_count", "max_total_bytes"], "properties": { "allowed_extensions": { "type": "array", "items": { "type": "string" } }, "max_file_count": { "type": "integer" }, "max_total_bytes": { "type": "integer" }, "max_single_file_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "min_total_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "input_composition": { "anyOf": [{ "$ref": "InputComposition" }, { "type": "null" }] } } },
311
+ Money: { "type": "object", "required": ["currency", "currency_exponent", "amount_minor"], "properties": { "currency": { "type": "string" }, "currency_exponent": { "type": "integer" }, "amount_minor": { "type": "integer" } } },
312
+ OutputFilesView: { "type": "object", "required": ["state", "reason_code", "file_count"], "properties": { "state": { "type": "string", "enum": ["pending", "uploading", "server_finalizing", "ready", "failed", "timed_out", "revoked", "not_supported"] }, "reason_code": { "anyOf": [{ "type": "string", "enum": ["invalid_file", "upload_failed", "delivery_timed_out", "authorization_revoked", "protocol_error", "delivery_unavailable"] }, { "type": "null" }] }, "file_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
313
+ PaymentOrderListData: { "type": "object", "required": ["items", "next_cursor"], "properties": { "items": { "type": "array", "items": { "$ref": "PaymentOrderListItem" } }, "next_cursor": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
314
+ PaymentOrderListItem: { "type": "object", "required": ["commerce_order_id", "order_no", "commercial_status", "collection_status", "fulfillment_status", "exception_collection_status", "refund_status", "money", "subtotal_money", "fulfillment", "expires_at", "created_at", "committed_at", "canceled_at", "expired_at", "fulfilled_at", "refunded_at"], "properties": { "commerce_order_id": { "type": "string" }, "order_no": { "type": "string" }, "commercial_status": { "type": "string", "enum": ["open", "committed", "canceled", "expired"] }, "collection_status": { "type": "string", "enum": ["unpaid", "requires_action", "processing", "paid"] }, "fulfillment_status": { "type": "string", "enum": ["not_requested", "pending", "applied", "rejected", "manual_review"] }, "exception_collection_status": { "type": "string", "enum": ["none", "detected"] }, "refund_status": { "type": "string", "enum": ["not_requested", "pending", "fully_refunded", "manual_review"] }, "money": { "$ref": "Money" }, "subtotal_money": { "anyOf": [{ "$ref": "Money" }, { "type": "null" }] }, "adjustments": { "type": "array", "items": { "anyOf": [{ "$ref": "SubscriptionUpgradeAdjustment" }, { "$ref": "PromotionCodeAdjustment" }] } }, "fulfillment": { "$ref": "ProductFulfillmentProjection" }, "expires_at": { "type": "string" }, "created_at": { "type": "string" }, "committed_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "canceled_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "expired_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "fulfilled_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "refunded_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
315
+ ProductFulfillmentProjection: { "type": "object", "required": ["product_fulfillment_id", "fulfillment_event_id", "status", "quantity", "provider_reason_code", "parameters"], "properties": { "product_fulfillment_id": { "type": "string" }, "fulfillment_event_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "status": { "type": "string", "enum": ["not_requested", "pending", "applied", "rejected", "manual_review"] }, "quantity": { "type": "integer" }, "provider_reason_code": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "parameters": { "anyOf": [{ "$ref": "GreenPointFulfillmentParameters" }, { "type": "null" }] } } },
316
+ ProductGreenPointPriceOut: { "type": "object", "required": ["available", "input_type"], "properties": { "available": { "type": "boolean" }, "input_type": { "type": "string", "enum": ["images", "video"] }, "pricing_mode": { "anyOf": [{ "type": "string", "enum": ["per_image", "per_minute"] }, { "type": "null" }] }, "unit_points": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "description": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "code": { "anyOf": [{ "type": "string", "const": "green_point_price_unavailable" }, { "type": "null" }] }, "reason": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
317
+ ProductInputLimitOut: { "type": "object", "required": ["description", "max_file_count", "max_total_bytes", "allowed_extensions"], "properties": { "description": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "min_file_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "max_file_count": { "type": "integer" }, "max_total_bytes": { "type": "integer" }, "max_duration_seconds": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "max_single_file_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "allowed_extensions": { "type": "array", "items": { "type": "string" } }, "single_extension": { "type": "boolean" }, "reject_timelapse": { "type": "boolean" }, "required_lens_tracks": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
318
+ ProductUploadInputLimit: { "type": "object", "required": ["description", "max_file_count", "max_total_bytes", "allowed_extensions"], "properties": { "description": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "min_file_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "max_file_count": { "type": "integer" }, "max_total_bytes": { "type": "integer" }, "max_single_file_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "max_duration_seconds": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "allowed_extensions": { "type": "array", "items": { "type": "string" } } } },
319
+ PromotionCodeAdjustment: { "type": "object", "required": ["type", "discount_type", "discount_basis_points", "money", "code_display_mask"], "properties": { "type": { "type": "string", "const": "PROMOTION_CODE" }, "discount_type": { "type": "string", "enum": ["amount_off", "percent_off"] }, "discount_basis_points": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "money": { "$ref": "DiscountMoney" }, "code_display_mask": { "type": "string" } } },
320
+ PublicGreenPointAccountOut: { "type": "object", "required": ["available_points", "reserved_points", "total_points", "status", "updated_at"], "properties": { "available_points": { "type": "integer" }, "reserved_points": { "type": "integer" }, "total_points": { "type": "integer" }, "status": { "type": "string", "const": "active" }, "updated_at": { "type": "string" } } },
321
+ PublicProductListOut: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "PublicProductOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
322
+ PublicProductOut: { "type": "object", "required": ["id", "code", "name", "input_mode", "allow_mixed_upload", "supported_input_types", "input_limits", "limits", "green_point_prices", "sort_order"], "properties": { "id": { "type": "string" }, "code": { "type": "string" }, "name": { "type": "string" }, "description": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "input_mode": { "type": "string", "enum": ["images", "video", "mixed"] }, "allow_mixed_upload": { "type": "boolean" }, "required_extensions": { "type": "array", "items": { "type": "string" } }, "supported_input_types": { "type": "array", "items": { "type": "string", "enum": ["images", "video"] } }, "input_limits": { "type": "object", "additionalProperties": { "$ref": "ProductInputLimitOut" } }, "limits": { "$ref": "InputLimitsOut" }, "green_point_prices": { "type": "object", "additionalProperties": { "$ref": "ProductGreenPointPriceOut" } }, "sort_order": { "type": "integer" } } },
323
+ SafeTransferProgress: { "type": "object", "required": ["direction", "purpose", "status", "attempt", "started_at", "started_at_quality", "last_updated_at", "last_updated_at_quality"], "properties": { "direction": { "type": "string", "enum": ["input", "output"] }, "purpose": { "type": "string", "enum": ["task_input", "task_output"] }, "status": { "type": "string", "enum": ["active", "completed", "failed"] }, "attempt": { "type": "integer" }, "started_at": { "type": "string" }, "started_at_quality": { "type": "string", "enum": ["exact", "receipt_fallback"] }, "last_updated_at": { "type": "string" }, "last_updated_at_quality": { "type": "string", "enum": ["exact", "receipt_fallback"] }, "finished_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "finished_at_quality": { "anyOf": [{ "type": "string", "enum": ["exact", "receipt_fallback"] }, { "type": "null" }] }, "completed_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "total_bytes": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "completed_objects": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "total_objects": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
324
+ StorageCredentialsOut: { "type": "object", "required": ["provider_id", "bucket", "region", "endpoint", "upload_prefix", "access_key_id", "access_key_secret", "expires_at"], "properties": { "type": { "type": "string" }, "provider_id": { "type": "string" }, "bucket": { "type": "string" }, "region": { "type": "string" }, "endpoint": { "secret": true, "type": "string" }, "upload_prefix": { "secret": true, "type": "string" }, "access_key_id": { "secret": true, "type": "string" }, "access_key_secret": { "secret": true, "type": "string" }, "security_token": { "anyOf": [{ "secret": true, "type": "string" }, { "type": "null" }] }, "expires_at": { "type": "string" } } },
325
+ StreamConfigOut: { "type": "object", "required": ["hourly_points", "viewer_hourly_points", "min_duration_hours", "max_duration_hours", "max_viewers", "sources"], "properties": { "hourly_points": { "type": "integer" }, "viewer_hourly_points": { "type": "integer" }, "min_duration_hours": { "type": "integer" }, "max_duration_hours": { "type": "integer" }, "max_viewers": { "type": "integer" }, "sources": { "type": "array", "items": { "type": "string" } } } },
326
+ StreamGuestLinkOut: { "type": "object", "required": ["link", "password", "expires_at"], "properties": { "link": { "type": "string" }, "password": { "secret": true, "type": "string" }, "expires_at": { "type": "string" } } },
327
+ StreamLinkOut: { "type": "object", "required": ["link", "expires_at"], "properties": { "link": { "secret": true, "type": "string" }, "expires_at": { "type": "string" } } },
328
+ StreamMemberOut: { "type": "object", "required": ["id", "name", "is_host", "online", "seated", "controlling", "joined_at"], "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "is_host": { "type": "boolean" }, "online": { "type": "boolean" }, "seated": { "type": "boolean" }, "controlling": { "type": "boolean" }, "joined_at": { "type": "string" } } },
329
+ StreamMembersOut: { "type": "object", "required": ["max_viewers", "members"], "properties": { "max_viewers": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "members": { "type": "array", "items": { "$ref": "StreamMemberOut" } } } },
330
+ StreamModelOut: { "type": "object", "required": ["id", "asset_id", "key", "format", "source", "name", "registered_at"], "properties": { "id": { "type": "string" }, "asset_id": { "type": "string" }, "key": { "type": "string" }, "format": { "type": "string" }, "source": { "type": "string", "enum": ["PP5", "PP6", "PP7", "PP9", "ply:z", "ply:-z", "ply:y", "ply:-y"] }, "name": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "registered_at": { "type": "string" } } },
331
+ StreamModelPage: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "StreamModelOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
332
+ StreamSessionOut: { "type": "object", "required": ["id", "model_id", "model_name", "status", "preparing_hint", "duration_hours", "hourly_points", "viewer_hourly_points", "prepaid_points", "viewer_seconds", "billing_started_at", "expires_at", "billing_ended_at", "end_reason", "max_viewers", "created_at"], "properties": { "id": { "type": "string" }, "model_id": { "type": "string" }, "model_name": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "status": { "type": "string", "enum": ["preparing", "ready", "stopping", "stopped", "failed"] }, "preparing_hint": { "anyOf": [{ "type": "string", "const": "first_conversion" }, { "type": "null" }] }, "duration_hours": { "type": "integer" }, "hourly_points": { "type": "integer" }, "viewer_hourly_points": { "type": "integer" }, "prepaid_points": { "type": "integer" }, "settled_points": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "billed_seconds": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "viewer_seconds": { "type": "integer" }, "billing_started_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "expires_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "billing_ended_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "end_reason": { "anyOf": [{ "type": "string", "enum": ["customer_stopped", "expired", "prepare_timeout", "busy", "source_unreadable", "convert_failed", "link_down", "machine_failed", "no_viewers", "failed"] }, { "type": "null" }] }, "max_viewers": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "viewers": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "created_at": { "type": "string" } } },
333
+ StreamSessionPage: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "StreamSessionOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
334
+ SubscriptionUpgradeAdjustment: { "type": "object", "required": ["type", "money", "source_subscription_id"], "properties": { "type": { "type": "string", "const": "SUBSCRIPTION_UPGRADE_CREDIT" }, "money": { "$ref": "DiscountMoney" }, "source_subscription_id": { "type": "string" } } },
335
+ SystemLogsView: { "type": "object", "required": ["summary", "completeness", "expected_count", "verified_count", "failed_count"], "properties": { "summary": { "type": "string", "enum": ["pending", "confirmed", "invalid", "unavailable", "not_supported"] }, "completeness": { "type": "string", "enum": ["pending", "complete", "partial", "unavailable", "not_supported"] }, "expected_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "verified_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "failed_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
336
+ TaskAssetProjection: { "type": "object", "required": ["id", "name"], "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "deleted": { "type": "boolean" } } },
337
+ TaskCancelOut: { "type": "object", "required": ["task_id", "status", "outcome"], "properties": { "task_id": { "type": "string" }, "status": { "$ref": "TaskStatus" }, "outcome": { "type": "string", "enum": ["cancelled", "accepted", "already_requested"] } } },
338
+ TaskDetailOut: { "type": "object", "required": ["id", "code", "status", "product_id", "asset_id", "input_validation_status", "created_at", "green_point_charge", "progress"], "properties": { "id": { "type": "string" }, "code": { "type": "string" }, "name": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "import_source": { "anyOf": [{ "type": "string", "const": "engineapi" }, { "type": "null" }] }, "status": { "$ref": "TaskStatus" }, "product_id": { "type": "string" }, "asset_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "input_validation_status": { "type": "string", "enum": ["pending", "passed", "failed"] }, "input_validation_error_code": { "anyOf": [{ "type": "string", "enum": ["input_invalid", "input_source_unavailable", "platform_error"] }, { "type": "null" }] }, "input_validation_error_message": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "created_at": { "type": "string" }, "green_point_charge": { "anyOf": [{ "$ref": "TaskGreenPointChargeOut" }, { "type": "null" }] }, "progress": { "$ref": "TaskProgress" }, "product": { "anyOf": [{ "$ref": "TaskProductProjection" }, { "type": "null" }] }, "asset": { "anyOf": [{ "$ref": "TaskAssetProjection" }, { "type": "null" }] }, "started_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "finished_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "training_started_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "training_finished_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "summary": { "anyOf": [{ "$ref": "TaskSummaryOut" }, { "type": "null" }] }, "failure": { "anyOf": [{ "$ref": "TaskFailureOut" }, { "type": "null" }] } } },
339
+ TaskFailureOut: { "type": "object", "required": ["code", "phase", "summary", "recommended_action"], "properties": { "code": { "$ref": "CustomerFailureCode" }, "phase": { "type": "string" }, "summary": { "type": "string" }, "recommended_action": { "type": "string" } } },
340
+ TaskGreenPointChargeComponentOut: { "type": "object", "required": ["input_type", "pricing_mode", "unit_count", "unit_points", "quoted_points", "price_description"], "properties": { "input_type": { "type": "string", "enum": ["images", "video"] }, "pricing_mode": { "type": "string", "enum": ["per_image", "per_minute"] }, "unit_count": { "type": "integer" }, "unit_points": { "type": "string" }, "quoted_points": { "type": "integer" }, "price_description": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
341
+ TaskGreenPointChargeOut: { "type": "object", "required": ["status", "input_type", "pricing_mode", "unit_count", "unit_points", "quoted_points", "price_description", "components"], "properties": { "status": { "type": "string", "enum": ["reserved", "consumed", "released"] }, "input_type": { "anyOf": [{ "type": "string", "enum": ["images", "video"] }, { "type": "null" }] }, "pricing_mode": { "anyOf": [{ "type": "string", "enum": ["per_image", "per_minute"] }, { "type": "null" }] }, "unit_count": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "unit_points": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "quoted_points": { "type": "integer" }, "price_description": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "components": { "type": "array", "items": { "$ref": "TaskGreenPointChargeComponentOut" } } } },
342
+ TaskListItem: { "type": "object", "required": ["id", "code", "status", "product_id", "asset_id", "input_validation_status", "created_at", "green_point_charge", "progress"], "properties": { "id": { "type": "string" }, "code": { "type": "string" }, "name": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "import_source": { "anyOf": [{ "type": "string", "const": "engineapi" }, { "type": "null" }] }, "status": { "$ref": "TaskStatus" }, "product_id": { "type": "string" }, "asset_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "input_validation_status": { "type": "string", "enum": ["pending", "passed", "failed"] }, "input_validation_error_code": { "anyOf": [{ "type": "string", "enum": ["input_invalid", "input_source_unavailable", "platform_error"] }, { "type": "null" }] }, "input_validation_error_message": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "created_at": { "type": "string" }, "green_point_charge": { "anyOf": [{ "$ref": "TaskGreenPointChargeOut" }, { "type": "null" }] }, "progress": { "$ref": "TaskProgress" }, "product": { "anyOf": [{ "$ref": "TaskProductProjection" }, { "type": "null" }] }, "asset": { "anyOf": [{ "$ref": "TaskAssetProjection" }, { "type": "null" }] }, "started_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "finished_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "training_started_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "training_finished_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
343
+ TaskListOut: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "TaskListItem" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
344
+ TaskMilestoneTiming: { "type": "object", "required": ["milestone", "milestone_ordinal", "lifecycle_status", "timing_completeness", "start_time_quality", "finish_time_quality"], "properties": { "milestone": { "type": "string", "enum": ["preparing", "downloading_input", "organizing_media", "building_training_data", "training_model", "uploading_output", "finalizing"] }, "milestone_ordinal": { "type": "integer" }, "lifecycle_status": { "type": "string", "enum": ["pending", "active", "completed", "interrupted"] }, "timing_completeness": { "type": "string", "enum": ["unavailable", "partial", "complete"] }, "started_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "finished_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "start_time_quality": { "type": "string", "enum": ["unavailable", "exact", "receipt_fallback", "server_authoritative"] }, "finish_time_quality": { "type": "string", "enum": ["unavailable", "exact", "receipt_fallback", "server_authoritative"] } } },
345
+ TaskOut: { "type": "object", "required": ["id", "code", "status", "product_id", "asset_id", "input_validation_status", "created_at", "green_point_charge", "progress"], "properties": { "id": { "type": "string" }, "code": { "type": "string" }, "name": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "import_source": { "anyOf": [{ "type": "string", "const": "engineapi" }, { "type": "null" }] }, "status": { "$ref": "TaskStatus" }, "product_id": { "type": "string" }, "asset_id": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "input_validation_status": { "type": "string", "enum": ["pending", "passed", "failed"] }, "input_validation_error_code": { "anyOf": [{ "type": "string", "enum": ["input_invalid", "input_source_unavailable", "platform_error"] }, { "type": "null" }] }, "input_validation_error_message": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "created_at": { "type": "string" }, "green_point_charge": { "anyOf": [{ "$ref": "TaskGreenPointChargeOut" }, { "type": "null" }] }, "progress": { "$ref": "TaskProgress" } } },
346
+ TaskPreprocessProgress: { "type": "object", "required": ["availability", "quality_level", "quality_message"], "properties": { "availability": { "type": "string", "enum": ["unavailable", "provisional", "final"] }, "success_rate_percent": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "quality_level": { "type": "string", "enum": ["low", "medium", "high", "unknown"] }, "quality_message": { "type": "string" } } },
347
+ TaskProductProjection: { "type": "object", "required": ["id", "code", "name"], "properties": { "id": { "type": "string" }, "code": { "type": "string" }, "name": { "type": "string" } } },
348
+ TaskProgress: { "type": "object", "required": ["current_milestone", "milestone_ordinal", "activity_status", "observation_status", "preprocess", "milestones"], "properties": { "current_milestone": { "type": "string", "enum": ["preparing", "downloading_input", "organizing_media", "building_training_data", "training_model", "uploading_output", "finalizing"] }, "milestone_ordinal": { "type": "integer" }, "activity_status": { "type": "string", "enum": ["normal", "syncing_runtime_result", "update_delayed", "unmapped"] }, "observation_status": { "type": "string", "enum": ["unavailable", "fresh", "stale", "not_applicable"] }, "last_observed_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "observed_elapsed_seconds": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "transfer": { "anyOf": [{ "$ref": "SafeTransferProgress" }, { "type": "null" }] }, "preprocess": { "$ref": "TaskPreprocessProgress" }, "milestones": { "type": "array", "items": { "$ref": "TaskMilestoneTiming" } }, "waiting": { "anyOf": [{ "$ref": "TaskProgressWaiting" }, { "type": "null" }] } } },
349
+ TaskProgressWaiting: { "type": "object", "required": ["reason", "summary", "capacity_tight"], "properties": { "reason": { "type": "string", "enum": ["queued", "preprocessing_input", "waiting_capacity", "provisioning", "preparing_environment", "downloading_input"] }, "summary": { "type": "string" }, "capacity_tight": { "type": "boolean" } } },
350
+ TaskStatus: { "type": "string", "enum": ["queued", "dispatching", "running", "passed", "failed", "cancel_requested", "cancelled"] },
351
+ TaskSummaryOut: { "type": "object", "properties": { "status": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "duration_seconds": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
352
+ WebhookConfigurationOut: { "type": "object", "required": ["id", "url", "enabled", "config_version", "current_secret_version", "created_at", "updated_at"], "properties": { "id": { "type": "string" }, "url": { "secret": true, "type": "string" }, "enabled": { "type": "boolean" }, "config_version": { "type": "integer" }, "current_secret_version": { "type": "integer" }, "created_at": { "type": "string" }, "updated_at": { "type": "string" }, "disabled_at": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
353
+ WebhookMutationOut: { "type": "object", "required": ["configuration"], "properties": { "configuration": { "$ref": "WebhookConfigurationOut" }, "secret": { "anyOf": [{ "secret": true, "type": "string" }, { "type": "null" }] }, "secret_version": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
354
+ WebhookSecretRotationOut: { "type": "object", "required": ["configuration", "secret", "secret_version"], "properties": { "configuration": { "$ref": "WebhookConfigurationOut" }, "secret": { "secret": true, "type": "string" }, "secret_version": { "type": "integer" } } }
355
+ };
356
+
357
+ // src/secret.ts
358
+ var REDACTED = "[REDACTED]";
359
+ var Secret = class {
360
+ #value;
361
+ constructor(value) {
362
+ this.#value = value;
363
+ }
364
+ /** Return the raw value. Never log or persist the result. */
365
+ reveal() {
366
+ return this.#value;
367
+ }
368
+ toString() {
369
+ return REDACTED;
370
+ }
371
+ toJSON() {
372
+ return REDACTED;
373
+ }
374
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
375
+ return REDACTED;
376
+ }
377
+ };
378
+
379
+ // src/internal/decode.ts
380
+ var DecodeError = class extends Error {
381
+ };
382
+ var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
383
+ function matchesType(type, value) {
384
+ switch (type) {
385
+ case "null":
386
+ return value === null;
387
+ case "string":
388
+ return typeof value === "string";
389
+ case "boolean":
390
+ return typeof value === "boolean";
391
+ case "integer":
392
+ return Number.isInteger(value);
393
+ case "number":
394
+ return typeof value === "number" && Number.isFinite(value);
395
+ case "array":
396
+ return Array.isArray(value);
397
+ case "object":
398
+ return isObject(value);
399
+ default:
400
+ throw new DecodeError();
401
+ }
402
+ }
403
+ function decode(schema, value, schemas) {
404
+ if (schema.$ref !== void 0) {
405
+ const target = schemas[schema.$ref];
406
+ if (!target) throw new DecodeError();
407
+ return decode(target, value, schemas);
408
+ }
409
+ if (schema.anyOf) {
410
+ for (const branch of schema.anyOf) {
411
+ try {
412
+ return decode(branch, value, schemas);
413
+ } catch (error) {
414
+ if (!(error instanceof DecodeError)) throw error;
415
+ }
416
+ }
417
+ throw new DecodeError();
418
+ }
419
+ if (schema.type !== void 0 && !matchesType(schema.type, value)) throw new DecodeError();
420
+ if ("const" in schema && value !== schema.const) throw new DecodeError();
421
+ if (schema.enum && !schema.enum.includes(value)) throw new DecodeError();
422
+ if (Array.isArray(value)) {
423
+ const items = schema.items;
424
+ return items ? value.map((item) => decode(items, item, schemas)) : structuredClone(value);
425
+ }
426
+ if (isObject(value)) {
427
+ for (const name of schema.required ?? []) {
428
+ if (!(name in value)) throw new DecodeError();
429
+ }
430
+ const result = {};
431
+ for (const [name, child] of Object.entries(value)) {
432
+ const property = schema.properties?.[name] ?? schema.additionalProperties;
433
+ result[name] = property ? decode(property, child, schemas) : structuredClone(child);
434
+ }
435
+ return result;
436
+ }
437
+ return schema.secret && typeof value === "string" ? new Secret(value) : value;
438
+ }
439
+
440
+ // src/internal/transport.ts
441
+ var MAX_RESPONSE_CHARS = 1048576;
442
+ var RETRY_STATUSES = /* @__PURE__ */ new Set([429, 502, 503, 504]);
443
+ function retryAfterMs(value) {
444
+ if (!value) return null;
445
+ const seconds = Number(value);
446
+ const ms = Number.isNaN(seconds) ? Date.parse(value) - Date.now() : seconds * 1e3;
447
+ return Number.isFinite(ms) && ms >= 0 ? ms : null;
448
+ }
449
+ var sleep = (ms) => new Promise((done) => setTimeout(done, ms));
450
+ var Transport = class {
451
+ #options;
452
+ #closed = false;
453
+ constructor(options) {
454
+ this.#options = options;
455
+ }
456
+ close() {
457
+ this.#closed = true;
458
+ if (typeof this.#options.token !== "string") this.#options.token.clear();
459
+ }
460
+ async call(operationId, options = {}) {
461
+ if (this.#closed) throw new PointcosmConfigurationError("Pointcosm client is closed");
462
+ const operation = OPERATIONS[operationId];
463
+ const { baseUrl, token, retry, acceptLanguage } = this.#options;
464
+ const path = operation.path.replace(/\{(\w+)\}/g, (_, name) => {
465
+ const value = options.path?.[name];
466
+ if (!value) throw new PointcosmConfigurationError(`missing path parameter ${name}`);
467
+ return encodeURIComponent(value);
468
+ });
469
+ const query = new URLSearchParams();
470
+ for (const [name, value] of Object.entries(options.query ?? {})) {
471
+ if (value !== void 0 && value !== null) query.set(name, String(value));
472
+ }
473
+ const url = `${baseUrl}${path}${query.size ? `?${query}` : ""}`;
474
+ const started = performance.now();
475
+ for (let attempt = 1; ; attempt += 1) {
476
+ const headers = {
477
+ Authorization: `Bearer ${typeof token === "string" ? token : await token.get()}`,
478
+ Accept: "application/json"
479
+ };
480
+ if (acceptLanguage) headers["Accept-Language"] = acceptLanguage;
481
+ for (const [name, value] of Object.entries(options.headers ?? {})) {
482
+ if (value !== void 0) headers[name] = value;
483
+ }
484
+ if (options.body !== void 0) headers["Content-Type"] = "application/json";
485
+ let response;
486
+ let text2 = "";
487
+ let failure;
488
+ try {
489
+ response = await this.#options.fetch(url, {
490
+ method: operation.method,
491
+ headers,
492
+ redirect: "manual",
493
+ signal: AbortSignal.timeout(this.#options.timeoutMs),
494
+ ...options.body !== void 0 && { body: JSON.stringify(options.body) }
495
+ });
496
+ text2 = await response.text();
497
+ } catch (error) {
498
+ failure = error instanceof Error && error.name === "TimeoutError" ? new PointcosmTimeoutError(operationId) : new PointcosmTransportError(operationId);
499
+ }
500
+ const retryable = failure !== void 0 || RETRY_STATUSES.has(response.status);
501
+ if (operation.retry && retryable && attempt < retry.maxAttempts) {
502
+ const ceiling = Math.min(retry.maxDelayMs, retry.baseDelayMs * 2 ** (attempt - 1));
503
+ const delay = retryAfterMs(response?.headers.get("retry-after") ?? null) ?? Math.random() * ceiling;
504
+ if (delay <= retry.maxElapsedMs - (performance.now() - started)) {
505
+ await sleep(delay);
506
+ continue;
507
+ }
508
+ }
509
+ if (failure) throw failure;
510
+ return this.#decode(operationId, response, text2);
511
+ }
512
+ }
513
+ #decode(operationId, response, text2) {
514
+ const status = response.status;
515
+ const requestId = response.headers.get("x-request-id")?.slice(0, 1024) ?? null;
516
+ const contract = (reason) => new PointcosmContractError(reason, operationId, status, requestId);
517
+ if (text2.length > MAX_RESPONSE_CHARS) throw contract("response-too-large");
518
+ const mediaType = (response.headers.get("content-type") ?? "").split(";")[0].trim().toLowerCase();
519
+ if (mediaType !== "application/json" && !mediaType.endsWith("+json")) {
520
+ throw contract("unexpected-content-type");
521
+ }
522
+ let payload;
523
+ try {
524
+ payload = JSON.parse(text2);
525
+ } catch {
526
+ throw contract("invalid-json");
527
+ }
528
+ if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
529
+ throw contract("invalid-envelope");
530
+ }
531
+ const envelope = payload;
532
+ const operation = OPERATIONS[operationId];
533
+ if (typeof envelope.success !== "boolean" || !("data" in envelope) || !("error" in envelope)) {
534
+ throw contract("invalid-envelope");
535
+ }
536
+ if (!envelope.success) {
537
+ const error = envelope.error;
538
+ if (envelope.data !== null || error === null || typeof error !== "object") {
539
+ throw contract("contradictory-envelope");
540
+ }
541
+ const { code, message, details, localized_message } = error;
542
+ if (typeof code !== "string" || typeof message !== "string") throw contract("invalid-envelope");
543
+ throw apiError({
544
+ statusCode: status,
545
+ code,
546
+ message,
547
+ details,
548
+ requestId,
549
+ operationId,
550
+ localizedMessage: localized_message
551
+ });
552
+ }
553
+ if (envelope.error !== null || status < 200 || status >= 300) {
554
+ throw contract("contradictory-envelope");
555
+ }
556
+ if (operation.meta && (envelope.meta === null || typeof envelope.meta !== "object")) {
557
+ throw contract("invalid-envelope");
558
+ }
559
+ if (operation.data === null) {
560
+ if (envelope.data !== null) throw contract("invalid-data");
561
+ return void 0;
562
+ }
563
+ try {
564
+ return decode(operation.data, envelope.data, SCHEMAS);
565
+ } catch (error) {
566
+ if (error instanceof DecodeError) throw contract("invalid-data");
567
+ throw error;
568
+ }
569
+ }
570
+ };
571
+
572
+ // src/client.ts
573
+ var DEFAULT_RETRY = {
574
+ maxAttempts: 1,
575
+ baseDelayMs: 250,
576
+ maxDelayMs: 5e3,
577
+ maxElapsedMs: 3e4
578
+ };
579
+ function origin(value, name) {
580
+ let url;
581
+ try {
582
+ url = new URL(value);
583
+ } catch {
584
+ throw new PointcosmConfigurationError(`${name} must be an absolute URL`);
585
+ }
586
+ if (url.protocol !== "https:" && url.protocol !== "http:" || url.search || url.hash) {
587
+ throw new PointcosmConfigurationError(`${name} must be an http(s) URL without query or fragment`);
588
+ }
589
+ return value.replace(/\/+$/, "");
590
+ }
591
+ function required(value, name) {
592
+ if (typeof value !== "string" || !value) {
593
+ throw new PointcosmConfigurationError(`${name} is required`);
594
+ }
595
+ return value;
596
+ }
597
+ function transport(options, token) {
598
+ const retry = { ...DEFAULT_RETRY, ...options.retry };
599
+ const timeoutMs = options.timeoutMs ?? 3e4;
600
+ if (!Number.isInteger(retry.maxAttempts) || retry.maxAttempts < 1) {
601
+ throw new PointcosmConfigurationError("retry.maxAttempts must be an integer of at least 1");
602
+ }
603
+ if (retry.baseDelayMs < 0 || retry.maxDelayMs < retry.baseDelayMs || retry.maxElapsedMs <= 0) {
604
+ throw new PointcosmConfigurationError("retry delay bounds are invalid");
605
+ }
606
+ if (!(timeoutMs > 0)) throw new PointcosmConfigurationError("timeoutMs must be positive");
607
+ const fetchImpl = options.fetch ?? ((input, init) => fetch(input, init));
608
+ return new Transport({
609
+ baseUrl: origin(options.baseUrl, "baseUrl"),
610
+ token: token(fetchImpl, timeoutMs),
611
+ fetch: fetchImpl,
612
+ timeoutMs,
613
+ retry,
614
+ acceptLanguage: options.acceptLanguage
615
+ });
616
+ }
617
+ var TrainApi = class {
618
+ #t;
619
+ constructor(t) {
620
+ this.#t = t;
621
+ }
622
+ listProducts(params = {}) {
623
+ return this.#t.call("train_products_list", { query: { ...params } });
624
+ }
625
+ getProduct(productId) {
626
+ return this.#t.call("train_products_retrieve", { path: { id: productId } });
627
+ }
628
+ createTask(request) {
629
+ return this.#t.call("train_tasks_create", { body: request });
630
+ }
631
+ listTasks(params = {}) {
632
+ const { status, ...page } = params;
633
+ return this.#t.call("train_tasks_list", {
634
+ query: { ...page, status: status?.length ? status.join(",") : void 0 }
635
+ });
636
+ }
637
+ getTask(taskId) {
638
+ return this.#t.call("train_tasks_retrieve", { path: { id: taskId } });
639
+ }
640
+ getTaskFinalization(taskId) {
641
+ return this.#t.call("train_tasks_finalization_get", { path: { id: taskId } });
642
+ }
643
+ /** Cancel a task that has not started training. Never retried automatically. */
644
+ cancelTask(taskId) {
645
+ return this.#t.call("train_tasks_cancel", { path: { id: taskId } });
646
+ }
647
+ deleteTask(taskId) {
648
+ return this.#t.call("train_tasks_delete", { path: { id: taskId } });
649
+ }
650
+ listArtifacts(taskId, params = {}) {
651
+ return this.#t.call("train_artifacts_list", { path: { id: taskId }, query: { ...params } });
652
+ }
653
+ createArtifactDownloadUrl(taskId, artifactId) {
654
+ return this.#t.call("train_artifacts_create_download_url", {
655
+ path: { id: taskId, artifact_id: artifactId }
656
+ });
657
+ }
658
+ };
659
+ var StorageApi = class {
660
+ #t;
661
+ constructor(t) {
662
+ this.#t = t;
663
+ }
664
+ createAsset(request) {
665
+ return this.#t.call("storage_assets_create", { body: request });
666
+ }
667
+ listAssets(params = {}) {
668
+ return this.#t.call("storage_assets_list", { query: { ...params } });
669
+ }
670
+ createAssetCredentials(assetId) {
671
+ return this.#t.call("storage_assets_create_credentials", { path: { id: assetId } });
672
+ }
673
+ completeAssetUpload(assetId) {
674
+ return this.#t.call("storage_assets_complete_upload", { path: { id: assetId } });
675
+ }
676
+ getAsset(assetId) {
677
+ return this.#t.call("storage_assets_retrieve", { path: { id: assetId } });
678
+ }
679
+ listAssetFiles(assetId, params = {}) {
680
+ return this.#t.call("storage_assets_files_list", { path: { id: assetId }, query: { ...params } });
681
+ }
682
+ /** `admissible: false` is a normal return value, not an error. */
683
+ checkAssetAdmission(assetId, productId) {
684
+ return this.#t.call("storage_assets_admission_check", {
685
+ path: { asset_id: assetId },
686
+ query: { product_id: productId }
687
+ });
688
+ }
689
+ deleteAsset(assetId) {
690
+ return this.#t.call("storage_assets_delete", { path: { id: assetId } });
691
+ }
692
+ };
693
+ var WebhooksApi = class {
694
+ #t;
695
+ constructor(t) {
696
+ this.#t = t;
697
+ }
698
+ getConfiguration() {
699
+ return this.#t.call("webhooks_configuration_retrieve");
700
+ }
701
+ updateConfiguration(request) {
702
+ return this.#t.call("webhooks_configuration_update", { body: request });
703
+ }
704
+ disableConfiguration() {
705
+ return this.#t.call("webhooks_configuration_disable");
706
+ }
707
+ rotateSecret() {
708
+ return this.#t.call("webhooks_secret_rotate");
709
+ }
710
+ };
711
+ var BillingApi = class {
712
+ #t;
713
+ constructor(t) {
714
+ this.#t = t;
715
+ }
716
+ getGreenPointAccount() {
717
+ return this.#t.call("billing_green_points_account_retrieve");
718
+ }
719
+ listGreenPointLedger(params = {}) {
720
+ return this.#t.call("billing_green_points_ledger_list", { query: { ...params } });
721
+ }
722
+ listGreenPointPurchaseOrders(params = {}) {
723
+ return this.#t.call("billing_green_point_purchase_orders_list", { query: { ...params } });
724
+ }
725
+ };
726
+ var LiveCosmApi = class {
727
+ #t;
728
+ constructor(t) {
729
+ this.#t = t;
730
+ }
731
+ getConfig() {
732
+ return this.#t.call("stream_config_get");
733
+ }
734
+ listScenes(params = {}) {
735
+ return this.#t.call("stream_models_list", { query: { ...params } });
736
+ }
737
+ /**
738
+ * Register a training output as a scene. Take `asset_id` and `key` from an artifact whose
739
+ * `stream_registerable` is true, and `source` from the artifact list's `pipeline_code`.
740
+ */
741
+ registerScene(request) {
742
+ return this.#t.call("stream_models_register", { body: request });
743
+ }
744
+ revokeScene(sceneId) {
745
+ return this.#t.call("stream_models_revoke", { path: { model_id: sceneId } });
746
+ }
747
+ /**
748
+ * Buy and create a room. Spends green points and is never retried automatically. Pass the
749
+ * same `idempotencyKey` (16-128 characters of `[A-Za-z0-9_-]`) to repeat it without a
750
+ * second charge.
751
+ */
752
+ createRoom(request, options = {}) {
753
+ return this.#t.call("stream_sessions_create", {
754
+ body: request,
755
+ headers: { "Idempotency-Key": options.idempotencyKey }
756
+ });
757
+ }
758
+ listRooms(params = {}) {
759
+ return this.#t.call("stream_sessions_list", { query: { ...params } });
760
+ }
761
+ getRoom(roomId) {
762
+ return this.#t.call("stream_sessions_get", { path: { session_id: roomId } });
763
+ }
764
+ stopRoom(roomId) {
765
+ return this.#t.call("stream_sessions_stop", { path: { session_id: roomId } });
766
+ }
767
+ /** Set a new guest password; the previous one stops working. The password is returned once. */
768
+ createGuestLink(roomId, request = {}) {
769
+ return this.#t.call("stream_sessions_guest_link", {
770
+ path: { session_id: roomId },
771
+ body: request
772
+ });
773
+ }
774
+ /** The host link is returned only once. */
775
+ createHostLink(roomId) {
776
+ return this.#t.call("stream_sessions_host_link", { path: { session_id: roomId } });
777
+ }
778
+ listMembers(roomId) {
779
+ return this.#t.call("stream_sessions_members", { path: { session_id: roomId } });
780
+ }
781
+ removeMember(roomId, memberId) {
782
+ return this.#t.call("stream_sessions_member_remove", {
783
+ path: { session_id: roomId, member_id: memberId }
784
+ });
785
+ }
786
+ };
787
+ var Pointcosm = class _Pointcosm {
788
+ train;
789
+ storage;
790
+ webhooks;
791
+ billing;
792
+ /** @experimental Preview: may change in a minor release. */
793
+ livecosm;
794
+ #transport;
795
+ constructor(input) {
796
+ this.#transport = input instanceof Transport ? input : transport(input, () => required(input.accessToken, "accessToken"));
797
+ this.train = new TrainApi(this.#transport);
798
+ this.storage = new StorageApi(this.#transport);
799
+ this.webhooks = new WebhooksApi(this.#transport);
800
+ this.billing = new BillingApi(this.#transport);
801
+ this.livecosm = new LiveCosmApi(this.#transport);
802
+ }
803
+ /**
804
+ * Server-side only: exchange a client secret for short-lived tokens, cached in memory.
805
+ * Throws in browsers, where a client secret must never be present.
806
+ */
807
+ static fromClientCredentials(options) {
808
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
809
+ throw new PointcosmConfigurationError("client credentials are not allowed in browsers");
810
+ }
811
+ const credentials = {
812
+ authBaseUrl: origin(options.authBaseUrl, "authBaseUrl"),
813
+ clientId: required(options.clientId, "clientId"),
814
+ clientSecret: required(options.clientSecret, "clientSecret"),
815
+ resource: required(options.resource, "resource")
816
+ };
817
+ const built = transport(
818
+ options,
819
+ (fetchImpl, timeoutMs) => new TokenProvider(credentials, fetchImpl, timeoutMs)
820
+ );
821
+ return new _Pointcosm(built);
822
+ }
823
+ /** Drop cached tokens and reject further calls. */
824
+ close() {
825
+ this.#transport.close();
826
+ }
827
+ };
828
+ // Annotate the CommonJS export names for ESM import in node:
829
+ 0 && (module.exports = {
830
+ BillingApi,
831
+ CONTRACT,
832
+ LiveCosmApi,
833
+ Pointcosm,
834
+ PointcosmApiError,
835
+ PointcosmAuthenticationError,
836
+ PointcosmAuthorizationError,
837
+ PointcosmConfigurationError,
838
+ PointcosmContractError,
839
+ PointcosmError,
840
+ PointcosmRateLimitError,
841
+ PointcosmServerError,
842
+ PointcosmTimeoutError,
843
+ PointcosmTransportError,
844
+ PointcosmValidationError,
845
+ Secret,
846
+ StorageApi,
847
+ TrainApi,
848
+ WebhooksApi
849
+ });