@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.js ADDED
@@ -0,0 +1,804 @@
1
+ // src/errors.ts
2
+ var MAX_TEXT = 1024;
3
+ var MAX_DEPTH = 4;
4
+ var MAX_ITEMS = 20;
5
+ var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
6
+ "access_key_id",
7
+ "access_key_secret",
8
+ "authorization",
9
+ "client_secret",
10
+ "cookie",
11
+ "secret",
12
+ "security_token",
13
+ "token",
14
+ "url"
15
+ ]);
16
+ function safeDetails(value, depth = MAX_DEPTH) {
17
+ if (depth <= 0) return "<truncated>";
18
+ if (Array.isArray(value)) {
19
+ return value.slice(0, MAX_ITEMS).map((item) => safeDetails(item, depth - 1));
20
+ }
21
+ if (value !== null && typeof value === "object") {
22
+ const result = {};
23
+ for (const [key, child] of Object.entries(value).slice(0, MAX_ITEMS)) {
24
+ const name = key.slice(0, 128);
25
+ result[name] = SENSITIVE_KEYS.has(name.toLowerCase()) ? "**********" : safeDetails(child, depth - 1);
26
+ }
27
+ return result;
28
+ }
29
+ if (typeof value === "string") return value.slice(0, MAX_TEXT);
30
+ if (value === null || typeof value === "boolean" || typeof value === "number") return value;
31
+ return `<${typeof value}>`;
32
+ }
33
+ var text = (value, fallback) => (typeof value === "string" && value ? value : fallback).slice(0, MAX_TEXT);
34
+ function localized(value) {
35
+ if (value === null || typeof value !== "object") return null;
36
+ const { locale, message } = value;
37
+ if (typeof locale !== "string" || typeof message !== "string" || !message) return null;
38
+ return { locale: locale.slice(0, 64), message: message.slice(0, MAX_TEXT) };
39
+ }
40
+ var PointcosmError = class extends Error {
41
+ name = "PointcosmError";
42
+ };
43
+ var PointcosmApiError = class extends PointcosmError {
44
+ name = "PointcosmApiError";
45
+ statusCode;
46
+ code;
47
+ details;
48
+ requestId;
49
+ operationId;
50
+ localizedMessage;
51
+ constructor(init) {
52
+ super(text(init.message, "PointCosm API request failed"));
53
+ this.statusCode = init.statusCode;
54
+ this.code = text(init.code, "api_error");
55
+ const details = init.details;
56
+ this.details = details !== null && typeof details === "object" && !Array.isArray(details) ? safeDetails(details) : null;
57
+ this.requestId = init.requestId;
58
+ this.operationId = init.operationId;
59
+ this.localizedMessage = localized(init.localizedMessage);
60
+ }
61
+ };
62
+ var PointcosmAuthenticationError = class extends PointcosmApiError {
63
+ name = "PointcosmAuthenticationError";
64
+ };
65
+ var PointcosmAuthorizationError = class extends PointcosmApiError {
66
+ name = "PointcosmAuthorizationError";
67
+ };
68
+ var PointcosmValidationError = class extends PointcosmApiError {
69
+ name = "PointcosmValidationError";
70
+ };
71
+ var PointcosmRateLimitError = class extends PointcosmApiError {
72
+ name = "PointcosmRateLimitError";
73
+ };
74
+ var PointcosmServerError = class extends PointcosmApiError {
75
+ name = "PointcosmServerError";
76
+ };
77
+ var PointcosmTransportError = class extends PointcosmError {
78
+ name = "PointcosmTransportError";
79
+ operationId;
80
+ constructor(operationId, options) {
81
+ super(`transport failure for operation "${operationId}"`, options);
82
+ this.operationId = operationId;
83
+ }
84
+ };
85
+ var PointcosmTimeoutError = class extends PointcosmTransportError {
86
+ name = "PointcosmTimeoutError";
87
+ };
88
+ var PointcosmContractError = class extends PointcosmError {
89
+ name = "PointcosmContractError";
90
+ reason;
91
+ operationId;
92
+ statusCode;
93
+ requestId;
94
+ constructor(reason, operationId, statusCode = null, requestId = null) {
95
+ super(`contract failure reason="${reason}" operation="${operationId}" status=${statusCode}`);
96
+ this.reason = reason;
97
+ this.operationId = operationId;
98
+ this.statusCode = statusCode;
99
+ this.requestId = requestId;
100
+ }
101
+ };
102
+ var PointcosmConfigurationError = class extends PointcosmError {
103
+ name = "PointcosmConfigurationError";
104
+ };
105
+ function apiError(init) {
106
+ const status = init.statusCode;
107
+ const type = status === 401 ? PointcosmAuthenticationError : status === 403 ? PointcosmAuthorizationError : status === 422 ? PointcosmValidationError : status === 429 ? PointcosmRateLimitError : status >= 500 ? PointcosmServerError : PointcosmApiError;
108
+ return new type(init);
109
+ }
110
+
111
+ // src/internal/auth.ts
112
+ var OPERATION = "auth_tokens_issue";
113
+ var formEncode = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g, "+");
114
+ var TokenProvider = class {
115
+ #credentials;
116
+ #fetch;
117
+ #timeoutMs;
118
+ #now;
119
+ #token = null;
120
+ #pending = null;
121
+ constructor(credentials, fetchImpl, timeoutMs, now = () => performance.now()) {
122
+ this.#credentials = credentials;
123
+ this.#fetch = fetchImpl;
124
+ this.#timeoutMs = timeoutMs;
125
+ this.#now = now;
126
+ }
127
+ async get() {
128
+ const current = this.#token;
129
+ if (current && this.#now() < current.refreshAt) return current.value;
130
+ this.#pending ??= this.#issue().finally(() => {
131
+ this.#pending = null;
132
+ });
133
+ try {
134
+ return (await this.#pending).value;
135
+ } catch (error) {
136
+ if (error instanceof PointcosmError && current && this.#now() < current.expiresAt) {
137
+ return current.value;
138
+ }
139
+ throw error;
140
+ }
141
+ }
142
+ clear() {
143
+ this.#token = null;
144
+ }
145
+ async #issue() {
146
+ const { authBaseUrl, clientId, clientSecret, resource } = this.#credentials;
147
+ const obtainedAt = this.#now();
148
+ let response;
149
+ let payload;
150
+ try {
151
+ response = await this.#fetch(`${authBaseUrl}/api/oauth/token`, {
152
+ method: "POST",
153
+ headers: {
154
+ Authorization: `Basic ${btoa(`${formEncode(clientId)}:${formEncode(clientSecret)}`)}`,
155
+ Accept: "application/json",
156
+ "Content-Type": "application/x-www-form-urlencoded"
157
+ },
158
+ body: new URLSearchParams({ grant_type: "client_credentials", resource }).toString(),
159
+ redirect: "manual",
160
+ signal: AbortSignal.timeout(this.#timeoutMs)
161
+ });
162
+ payload = await response.json().catch(() => void 0);
163
+ } catch (error) {
164
+ if (error instanceof Error && error.name === "TimeoutError") {
165
+ throw new PointcosmTimeoutError(OPERATION);
166
+ }
167
+ throw new PointcosmTransportError(OPERATION);
168
+ }
169
+ const status = response.status;
170
+ if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
171
+ throw new PointcosmContractError("invalid-oauth-envelope", OPERATION, status);
172
+ }
173
+ const body = payload;
174
+ if (status !== 200) {
175
+ const type = status === 429 ? PointcosmRateLimitError : status >= 500 ? PointcosmServerError : PointcosmAuthenticationError;
176
+ throw new type({
177
+ statusCode: status,
178
+ code: body.error,
179
+ message: body.error_description,
180
+ details: null,
181
+ requestId: response.headers.get("x-request-id"),
182
+ operationId: OPERATION
183
+ });
184
+ }
185
+ const expiresIn = body.expires_in;
186
+ 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) {
187
+ throw new PointcosmContractError("invalid-oauth-token", OPERATION, status);
188
+ }
189
+ const expiresAt = obtainedAt + expiresIn * 1e3;
190
+ const margin = Math.min(60, Math.max(1, expiresIn * 0.1)) * 1e3;
191
+ this.#token = { value: body.access_token, expiresAt, refreshAt: expiresAt - margin };
192
+ return this.#token;
193
+ }
194
+ };
195
+
196
+ // src/generated/contract.ts
197
+ var CONTRACT = {
198
+ "revision": "5c16aa762ae0ada16aaaa021390ee1af0d6bd710",
199
+ "bundleRelease": "0.14.0",
200
+ "bundleSha256": "45937ba6295d8c6efd57af85ae6230fd7dbd124dac724c0e26a32c4d168c5bcc",
201
+ "customerSha256": "5db91d0b1a7ac4dc6eafe2df6b79fba31607bc54e108221987ea3bc0c3c66c4c",
202
+ "authSha256": "ff17917c6ccab2fcf1cb6c2ee0392c2efea6dfca567d084a6434836c36c489cf",
203
+ "operationCount": 37,
204
+ "generator": "openapi-typescript 7.13.0"
205
+ };
206
+ var OPERATIONS = {
207
+ billing_green_point_purchase_orders_list: { "method": "GET", "path": "/api/v1/payment/commerce-orders", "retry": true, "meta": true, "data": { "$ref": "PaymentOrderListData" } },
208
+ billing_green_points_account_retrieve: { "method": "GET", "path": "/api/v1/green-points/account", "retry": true, "meta": false, "data": { "$ref": "PublicGreenPointAccountOut" } },
209
+ billing_green_points_ledger_list: { "method": "GET", "path": "/api/v1/green-points/ledger", "retry": true, "meta": false, "data": { "$ref": "GreenPointCustomerLedgerPage" } },
210
+ storage_assets_admission_check: { "method": "GET", "path": "/api/v1/assets/{asset_id}/admission", "retry": true, "meta": false, "data": { "$ref": "AssetAdmissionOut" } },
211
+ storage_assets_complete_upload: { "method": "POST", "path": "/api/v1/assets/{id}/upload-complete", "retry": true, "meta": false, "data": { "$ref": "AssetCreateOut" } },
212
+ storage_assets_create: { "method": "POST", "path": "/api/v1/assets", "retry": false, "meta": false, "data": { "$ref": "AssetCreateOut" } },
213
+ storage_assets_create_credentials: { "method": "POST", "path": "/api/v1/assets/{id}/credentials", "retry": false, "meta": false, "data": { "$ref": "StorageCredentialsOut" } },
214
+ storage_assets_delete: { "method": "DELETE", "path": "/api/v1/assets/{id}", "retry": false, "meta": false, "data": null },
215
+ storage_assets_files_list: { "method": "GET", "path": "/api/v1/assets/{id}/files", "retry": true, "meta": false, "data": { "$ref": "AssetFileListOut" } },
216
+ storage_assets_list: { "method": "GET", "path": "/api/v1/assets", "retry": true, "meta": false, "data": { "$ref": "AssetListOut" } },
217
+ storage_assets_retrieve: { "method": "GET", "path": "/api/v1/assets/{id}", "retry": true, "meta": false, "data": { "$ref": "AssetDetailOut" } },
218
+ stream_config_get: { "method": "GET", "path": "/api/v1/stream-config", "retry": true, "meta": false, "data": { "$ref": "StreamConfigOut" } },
219
+ stream_models_list: { "method": "GET", "path": "/api/v1/stream-models", "retry": true, "meta": false, "data": { "$ref": "StreamModelPage" } },
220
+ stream_models_register: { "method": "POST", "path": "/api/v1/stream-models", "retry": true, "meta": false, "data": { "$ref": "StreamModelOut" } },
221
+ stream_models_revoke: { "method": "DELETE", "path": "/api/v1/stream-models/{model_id}", "retry": true, "meta": false, "data": null },
222
+ stream_sessions_create: { "method": "POST", "path": "/api/v1/stream-sessions", "retry": false, "meta": false, "data": { "$ref": "StreamSessionOut" } },
223
+ stream_sessions_get: { "method": "GET", "path": "/api/v1/stream-sessions/{session_id}", "retry": true, "meta": false, "data": { "$ref": "StreamSessionOut" } },
224
+ stream_sessions_guest_link: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/guest-link", "retry": false, "meta": false, "data": { "$ref": "StreamGuestLinkOut" } },
225
+ stream_sessions_host_link: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/host-link", "retry": false, "meta": false, "data": { "$ref": "StreamLinkOut" } },
226
+ stream_sessions_list: { "method": "GET", "path": "/api/v1/stream-sessions", "retry": true, "meta": false, "data": { "$ref": "StreamSessionPage" } },
227
+ stream_sessions_member_remove: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/members/{member_id}/remove", "retry": true, "meta": false, "data": null },
228
+ stream_sessions_members: { "method": "GET", "path": "/api/v1/stream-sessions/{session_id}/members", "retry": true, "meta": false, "data": { "$ref": "StreamMembersOut" } },
229
+ stream_sessions_stop: { "method": "POST", "path": "/api/v1/stream-sessions/{session_id}/stop", "retry": true, "meta": false, "data": { "$ref": "StreamSessionOut" } },
230
+ train_artifacts_create_download_url: { "method": "GET", "path": "/api/v1/tasks/{id}/artifacts/{artifact_id}/download", "retry": false, "meta": false, "data": { "$ref": "ArtifactDownloadOut" } },
231
+ train_artifacts_list: { "method": "GET", "path": "/api/v1/tasks/{id}/artifacts", "retry": true, "meta": false, "data": { "$ref": "ArtifactListOut" } },
232
+ train_products_list: { "method": "GET", "path": "/api/v1/products", "retry": true, "meta": false, "data": { "$ref": "PublicProductListOut" } },
233
+ train_products_retrieve: { "method": "GET", "path": "/api/v1/products/{id}", "retry": true, "meta": false, "data": { "$ref": "PublicProductOut" } },
234
+ train_tasks_cancel: { "method": "POST", "path": "/api/v1/tasks/{id}/cancel", "retry": false, "meta": false, "data": { "$ref": "TaskCancelOut" } },
235
+ train_tasks_create: { "method": "POST", "path": "/api/v1/tasks", "retry": false, "meta": false, "data": { "$ref": "TaskOut" } },
236
+ train_tasks_delete: { "method": "DELETE", "path": "/api/v1/tasks/{id}", "retry": false, "meta": false, "data": null },
237
+ train_tasks_finalization_get: { "method": "GET", "path": "/api/v1/tasks/{id}/finalization", "retry": true, "meta": false, "data": { "$ref": "CustomerFinalizationData" } },
238
+ train_tasks_list: { "method": "GET", "path": "/api/v1/tasks", "retry": true, "meta": false, "data": { "$ref": "TaskListOut" } },
239
+ train_tasks_retrieve: { "method": "GET", "path": "/api/v1/tasks/{id}", "retry": true, "meta": false, "data": { "$ref": "TaskDetailOut" } },
240
+ webhooks_configuration_disable: { "method": "DELETE", "path": "/api/v1/webhook", "retry": false, "meta": false, "data": { "$ref": "WebhookConfigurationOut" } },
241
+ webhooks_configuration_retrieve: { "method": "GET", "path": "/api/v1/webhook", "retry": true, "meta": false, "data": { "$ref": "WebhookConfigurationOut" } },
242
+ webhooks_configuration_update: { "method": "PUT", "path": "/api/v1/webhook", "retry": false, "meta": false, "data": { "$ref": "WebhookMutationOut" } },
243
+ webhooks_secret_rotate: { "method": "POST", "path": "/api/v1/webhook/rotate-secret", "retry": false, "meta": false, "data": { "$ref": "WebhookSecretRotationOut" } }
244
+ };
245
+ var SCHEMAS = {
246
+ AdmissionReasonOut: { "type": "object", "required": ["code", "message"], "properties": { "code": { "type": "string" }, "message": { "type": "string" } } },
247
+ ArtifactDownloadOut: { "type": "object", "required": ["url"], "properties": { "url": { "secret": true, "type": "string" } } },
248
+ 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" }] } } },
249
+ 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" } } },
250
+ 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" } } } },
251
+ AssetCreateOut: { "type": "object", "required": ["flow", "asset"], "properties": { "flow": { "$ref": "AssetUploadFlowOut" }, "asset": { "$ref": "AssetOut" }, "storage_credentials": { "anyOf": [{ "$ref": "StorageCredentialsOut" }, { "type": "null" }] } } },
252
+ 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" }] } } },
253
+ 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" } } },
254
+ 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" }] } } },
255
+ AssetListOut: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "AssetOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
256
+ 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" } } },
257
+ AssetSourceType: { "type": "string", "enum": ["platform_upload", "platform_copy", "netdisk", "datasource"] },
258
+ 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" }] } } },
259
+ CustomerFailureCode: { "type": "string", "enum": ["input_invalid", "input_source_unavailable", "insufficient_balance", "scheduling_failed", "preparation_failed", "training_failed", "runtime_exceeded", "output_failed", "platform_error"] },
260
+ 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" } } },
261
+ DiscountMoney: { "type": "object", "required": ["currency", "currency_exponent", "amount_minor"], "properties": { "currency": { "type": "string" }, "currency_exponent": { "type": "integer" }, "amount_minor": { "type": "integer" } } },
262
+ 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" }] } } },
263
+ GreenPointCustomerLedgerPage: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "GreenPointCustomerLedgerEntryOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
264
+ 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" } } },
265
+ 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" } } } } },
266
+ 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" }] } } },
267
+ Money: { "type": "object", "required": ["currency", "currency_exponent", "amount_minor"], "properties": { "currency": { "type": "string" }, "currency_exponent": { "type": "integer" }, "amount_minor": { "type": "integer" } } },
268
+ 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" }] } } },
269
+ PaymentOrderListData: { "type": "object", "required": ["items", "next_cursor"], "properties": { "items": { "type": "array", "items": { "$ref": "PaymentOrderListItem" } }, "next_cursor": { "anyOf": [{ "type": "string" }, { "type": "null" }] } } },
270
+ 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" }] } } },
271
+ 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" }] } } },
272
+ 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" }] } } },
273
+ 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" }] } } },
274
+ 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" } } } },
275
+ 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" } } },
276
+ 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" } } },
277
+ PublicProductListOut: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "PublicProductOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
278
+ 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" } } },
279
+ 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" }] } } },
280
+ 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" } } },
281
+ 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" } } } },
282
+ StreamGuestLinkOut: { "type": "object", "required": ["link", "password", "expires_at"], "properties": { "link": { "type": "string" }, "password": { "secret": true, "type": "string" }, "expires_at": { "type": "string" } } },
283
+ StreamLinkOut: { "type": "object", "required": ["link", "expires_at"], "properties": { "link": { "secret": true, "type": "string" }, "expires_at": { "type": "string" } } },
284
+ 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" } } },
285
+ StreamMembersOut: { "type": "object", "required": ["max_viewers", "members"], "properties": { "max_viewers": { "anyOf": [{ "type": "integer" }, { "type": "null" }] }, "members": { "type": "array", "items": { "$ref": "StreamMemberOut" } } } },
286
+ 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" } } },
287
+ StreamModelPage: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "StreamModelOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
288
+ 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" } } },
289
+ StreamSessionPage: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "StreamSessionOut" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
290
+ 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" } } },
291
+ 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" }] } } },
292
+ TaskAssetProjection: { "type": "object", "required": ["id", "name"], "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "deleted": { "type": "boolean" } } },
293
+ TaskCancelOut: { "type": "object", "required": ["task_id", "status", "outcome"], "properties": { "task_id": { "type": "string" }, "status": { "$ref": "TaskStatus" }, "outcome": { "type": "string", "enum": ["cancelled", "accepted", "already_requested"] } } },
294
+ 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" }] } } },
295
+ TaskFailureOut: { "type": "object", "required": ["code", "phase", "summary", "recommended_action"], "properties": { "code": { "$ref": "CustomerFailureCode" }, "phase": { "type": "string" }, "summary": { "type": "string" }, "recommended_action": { "type": "string" } } },
296
+ 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" }] } } },
297
+ 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" } } } },
298
+ 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" }] } } },
299
+ TaskListOut: { "type": "object", "required": ["items", "total", "offset", "limit"], "properties": { "items": { "type": "array", "items": { "$ref": "TaskListItem" } }, "total": { "type": "integer" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } } },
300
+ 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"] } } },
301
+ 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" } } },
302
+ 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" } } },
303
+ TaskProductProjection: { "type": "object", "required": ["id", "code", "name"], "properties": { "id": { "type": "string" }, "code": { "type": "string" }, "name": { "type": "string" } } },
304
+ 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" }] } } },
305
+ 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" } } },
306
+ TaskStatus: { "type": "string", "enum": ["queued", "dispatching", "running", "passed", "failed", "cancel_requested", "cancelled"] },
307
+ TaskSummaryOut: { "type": "object", "properties": { "status": { "anyOf": [{ "type": "string" }, { "type": "null" }] }, "duration_seconds": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
308
+ 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" }] } } },
309
+ WebhookMutationOut: { "type": "object", "required": ["configuration"], "properties": { "configuration": { "$ref": "WebhookConfigurationOut" }, "secret": { "anyOf": [{ "secret": true, "type": "string" }, { "type": "null" }] }, "secret_version": { "anyOf": [{ "type": "integer" }, { "type": "null" }] } } },
310
+ WebhookSecretRotationOut: { "type": "object", "required": ["configuration", "secret", "secret_version"], "properties": { "configuration": { "$ref": "WebhookConfigurationOut" }, "secret": { "secret": true, "type": "string" }, "secret_version": { "type": "integer" } } }
311
+ };
312
+
313
+ // src/secret.ts
314
+ var REDACTED = "[REDACTED]";
315
+ var Secret = class {
316
+ #value;
317
+ constructor(value) {
318
+ this.#value = value;
319
+ }
320
+ /** Return the raw value. Never log or persist the result. */
321
+ reveal() {
322
+ return this.#value;
323
+ }
324
+ toString() {
325
+ return REDACTED;
326
+ }
327
+ toJSON() {
328
+ return REDACTED;
329
+ }
330
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
331
+ return REDACTED;
332
+ }
333
+ };
334
+
335
+ // src/internal/decode.ts
336
+ var DecodeError = class extends Error {
337
+ };
338
+ var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
339
+ function matchesType(type, value) {
340
+ switch (type) {
341
+ case "null":
342
+ return value === null;
343
+ case "string":
344
+ return typeof value === "string";
345
+ case "boolean":
346
+ return typeof value === "boolean";
347
+ case "integer":
348
+ return Number.isInteger(value);
349
+ case "number":
350
+ return typeof value === "number" && Number.isFinite(value);
351
+ case "array":
352
+ return Array.isArray(value);
353
+ case "object":
354
+ return isObject(value);
355
+ default:
356
+ throw new DecodeError();
357
+ }
358
+ }
359
+ function decode(schema, value, schemas) {
360
+ if (schema.$ref !== void 0) {
361
+ const target = schemas[schema.$ref];
362
+ if (!target) throw new DecodeError();
363
+ return decode(target, value, schemas);
364
+ }
365
+ if (schema.anyOf) {
366
+ for (const branch of schema.anyOf) {
367
+ try {
368
+ return decode(branch, value, schemas);
369
+ } catch (error) {
370
+ if (!(error instanceof DecodeError)) throw error;
371
+ }
372
+ }
373
+ throw new DecodeError();
374
+ }
375
+ if (schema.type !== void 0 && !matchesType(schema.type, value)) throw new DecodeError();
376
+ if ("const" in schema && value !== schema.const) throw new DecodeError();
377
+ if (schema.enum && !schema.enum.includes(value)) throw new DecodeError();
378
+ if (Array.isArray(value)) {
379
+ const items = schema.items;
380
+ return items ? value.map((item) => decode(items, item, schemas)) : structuredClone(value);
381
+ }
382
+ if (isObject(value)) {
383
+ for (const name of schema.required ?? []) {
384
+ if (!(name in value)) throw new DecodeError();
385
+ }
386
+ const result = {};
387
+ for (const [name, child] of Object.entries(value)) {
388
+ const property = schema.properties?.[name] ?? schema.additionalProperties;
389
+ result[name] = property ? decode(property, child, schemas) : structuredClone(child);
390
+ }
391
+ return result;
392
+ }
393
+ return schema.secret && typeof value === "string" ? new Secret(value) : value;
394
+ }
395
+
396
+ // src/internal/transport.ts
397
+ var MAX_RESPONSE_CHARS = 1048576;
398
+ var RETRY_STATUSES = /* @__PURE__ */ new Set([429, 502, 503, 504]);
399
+ function retryAfterMs(value) {
400
+ if (!value) return null;
401
+ const seconds = Number(value);
402
+ const ms = Number.isNaN(seconds) ? Date.parse(value) - Date.now() : seconds * 1e3;
403
+ return Number.isFinite(ms) && ms >= 0 ? ms : null;
404
+ }
405
+ var sleep = (ms) => new Promise((done) => setTimeout(done, ms));
406
+ var Transport = class {
407
+ #options;
408
+ #closed = false;
409
+ constructor(options) {
410
+ this.#options = options;
411
+ }
412
+ close() {
413
+ this.#closed = true;
414
+ if (typeof this.#options.token !== "string") this.#options.token.clear();
415
+ }
416
+ async call(operationId, options = {}) {
417
+ if (this.#closed) throw new PointcosmConfigurationError("Pointcosm client is closed");
418
+ const operation = OPERATIONS[operationId];
419
+ const { baseUrl, token, retry, acceptLanguage } = this.#options;
420
+ const path = operation.path.replace(/\{(\w+)\}/g, (_, name) => {
421
+ const value = options.path?.[name];
422
+ if (!value) throw new PointcosmConfigurationError(`missing path parameter ${name}`);
423
+ return encodeURIComponent(value);
424
+ });
425
+ const query = new URLSearchParams();
426
+ for (const [name, value] of Object.entries(options.query ?? {})) {
427
+ if (value !== void 0 && value !== null) query.set(name, String(value));
428
+ }
429
+ const url = `${baseUrl}${path}${query.size ? `?${query}` : ""}`;
430
+ const started = performance.now();
431
+ for (let attempt = 1; ; attempt += 1) {
432
+ const headers = {
433
+ Authorization: `Bearer ${typeof token === "string" ? token : await token.get()}`,
434
+ Accept: "application/json"
435
+ };
436
+ if (acceptLanguage) headers["Accept-Language"] = acceptLanguage;
437
+ for (const [name, value] of Object.entries(options.headers ?? {})) {
438
+ if (value !== void 0) headers[name] = value;
439
+ }
440
+ if (options.body !== void 0) headers["Content-Type"] = "application/json";
441
+ let response;
442
+ let text2 = "";
443
+ let failure;
444
+ try {
445
+ response = await this.#options.fetch(url, {
446
+ method: operation.method,
447
+ headers,
448
+ redirect: "manual",
449
+ signal: AbortSignal.timeout(this.#options.timeoutMs),
450
+ ...options.body !== void 0 && { body: JSON.stringify(options.body) }
451
+ });
452
+ text2 = await response.text();
453
+ } catch (error) {
454
+ failure = error instanceof Error && error.name === "TimeoutError" ? new PointcosmTimeoutError(operationId) : new PointcosmTransportError(operationId);
455
+ }
456
+ const retryable = failure !== void 0 || RETRY_STATUSES.has(response.status);
457
+ if (operation.retry && retryable && attempt < retry.maxAttempts) {
458
+ const ceiling = Math.min(retry.maxDelayMs, retry.baseDelayMs * 2 ** (attempt - 1));
459
+ const delay = retryAfterMs(response?.headers.get("retry-after") ?? null) ?? Math.random() * ceiling;
460
+ if (delay <= retry.maxElapsedMs - (performance.now() - started)) {
461
+ await sleep(delay);
462
+ continue;
463
+ }
464
+ }
465
+ if (failure) throw failure;
466
+ return this.#decode(operationId, response, text2);
467
+ }
468
+ }
469
+ #decode(operationId, response, text2) {
470
+ const status = response.status;
471
+ const requestId = response.headers.get("x-request-id")?.slice(0, 1024) ?? null;
472
+ const contract = (reason) => new PointcosmContractError(reason, operationId, status, requestId);
473
+ if (text2.length > MAX_RESPONSE_CHARS) throw contract("response-too-large");
474
+ const mediaType = (response.headers.get("content-type") ?? "").split(";")[0].trim().toLowerCase();
475
+ if (mediaType !== "application/json" && !mediaType.endsWith("+json")) {
476
+ throw contract("unexpected-content-type");
477
+ }
478
+ let payload;
479
+ try {
480
+ payload = JSON.parse(text2);
481
+ } catch {
482
+ throw contract("invalid-json");
483
+ }
484
+ if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
485
+ throw contract("invalid-envelope");
486
+ }
487
+ const envelope = payload;
488
+ const operation = OPERATIONS[operationId];
489
+ if (typeof envelope.success !== "boolean" || !("data" in envelope) || !("error" in envelope)) {
490
+ throw contract("invalid-envelope");
491
+ }
492
+ if (!envelope.success) {
493
+ const error = envelope.error;
494
+ if (envelope.data !== null || error === null || typeof error !== "object") {
495
+ throw contract("contradictory-envelope");
496
+ }
497
+ const { code, message, details, localized_message } = error;
498
+ if (typeof code !== "string" || typeof message !== "string") throw contract("invalid-envelope");
499
+ throw apiError({
500
+ statusCode: status,
501
+ code,
502
+ message,
503
+ details,
504
+ requestId,
505
+ operationId,
506
+ localizedMessage: localized_message
507
+ });
508
+ }
509
+ if (envelope.error !== null || status < 200 || status >= 300) {
510
+ throw contract("contradictory-envelope");
511
+ }
512
+ if (operation.meta && (envelope.meta === null || typeof envelope.meta !== "object")) {
513
+ throw contract("invalid-envelope");
514
+ }
515
+ if (operation.data === null) {
516
+ if (envelope.data !== null) throw contract("invalid-data");
517
+ return void 0;
518
+ }
519
+ try {
520
+ return decode(operation.data, envelope.data, SCHEMAS);
521
+ } catch (error) {
522
+ if (error instanceof DecodeError) throw contract("invalid-data");
523
+ throw error;
524
+ }
525
+ }
526
+ };
527
+
528
+ // src/client.ts
529
+ var DEFAULT_RETRY = {
530
+ maxAttempts: 1,
531
+ baseDelayMs: 250,
532
+ maxDelayMs: 5e3,
533
+ maxElapsedMs: 3e4
534
+ };
535
+ function origin(value, name) {
536
+ let url;
537
+ try {
538
+ url = new URL(value);
539
+ } catch {
540
+ throw new PointcosmConfigurationError(`${name} must be an absolute URL`);
541
+ }
542
+ if (url.protocol !== "https:" && url.protocol !== "http:" || url.search || url.hash) {
543
+ throw new PointcosmConfigurationError(`${name} must be an http(s) URL without query or fragment`);
544
+ }
545
+ return value.replace(/\/+$/, "");
546
+ }
547
+ function required(value, name) {
548
+ if (typeof value !== "string" || !value) {
549
+ throw new PointcosmConfigurationError(`${name} is required`);
550
+ }
551
+ return value;
552
+ }
553
+ function transport(options, token) {
554
+ const retry = { ...DEFAULT_RETRY, ...options.retry };
555
+ const timeoutMs = options.timeoutMs ?? 3e4;
556
+ if (!Number.isInteger(retry.maxAttempts) || retry.maxAttempts < 1) {
557
+ throw new PointcosmConfigurationError("retry.maxAttempts must be an integer of at least 1");
558
+ }
559
+ if (retry.baseDelayMs < 0 || retry.maxDelayMs < retry.baseDelayMs || retry.maxElapsedMs <= 0) {
560
+ throw new PointcosmConfigurationError("retry delay bounds are invalid");
561
+ }
562
+ if (!(timeoutMs > 0)) throw new PointcosmConfigurationError("timeoutMs must be positive");
563
+ const fetchImpl = options.fetch ?? ((input, init) => fetch(input, init));
564
+ return new Transport({
565
+ baseUrl: origin(options.baseUrl, "baseUrl"),
566
+ token: token(fetchImpl, timeoutMs),
567
+ fetch: fetchImpl,
568
+ timeoutMs,
569
+ retry,
570
+ acceptLanguage: options.acceptLanguage
571
+ });
572
+ }
573
+ var TrainApi = class {
574
+ #t;
575
+ constructor(t) {
576
+ this.#t = t;
577
+ }
578
+ listProducts(params = {}) {
579
+ return this.#t.call("train_products_list", { query: { ...params } });
580
+ }
581
+ getProduct(productId) {
582
+ return this.#t.call("train_products_retrieve", { path: { id: productId } });
583
+ }
584
+ createTask(request) {
585
+ return this.#t.call("train_tasks_create", { body: request });
586
+ }
587
+ listTasks(params = {}) {
588
+ const { status, ...page } = params;
589
+ return this.#t.call("train_tasks_list", {
590
+ query: { ...page, status: status?.length ? status.join(",") : void 0 }
591
+ });
592
+ }
593
+ getTask(taskId) {
594
+ return this.#t.call("train_tasks_retrieve", { path: { id: taskId } });
595
+ }
596
+ getTaskFinalization(taskId) {
597
+ return this.#t.call("train_tasks_finalization_get", { path: { id: taskId } });
598
+ }
599
+ /** Cancel a task that has not started training. Never retried automatically. */
600
+ cancelTask(taskId) {
601
+ return this.#t.call("train_tasks_cancel", { path: { id: taskId } });
602
+ }
603
+ deleteTask(taskId) {
604
+ return this.#t.call("train_tasks_delete", { path: { id: taskId } });
605
+ }
606
+ listArtifacts(taskId, params = {}) {
607
+ return this.#t.call("train_artifacts_list", { path: { id: taskId }, query: { ...params } });
608
+ }
609
+ createArtifactDownloadUrl(taskId, artifactId) {
610
+ return this.#t.call("train_artifacts_create_download_url", {
611
+ path: { id: taskId, artifact_id: artifactId }
612
+ });
613
+ }
614
+ };
615
+ var StorageApi = class {
616
+ #t;
617
+ constructor(t) {
618
+ this.#t = t;
619
+ }
620
+ createAsset(request) {
621
+ return this.#t.call("storage_assets_create", { body: request });
622
+ }
623
+ listAssets(params = {}) {
624
+ return this.#t.call("storage_assets_list", { query: { ...params } });
625
+ }
626
+ createAssetCredentials(assetId) {
627
+ return this.#t.call("storage_assets_create_credentials", { path: { id: assetId } });
628
+ }
629
+ completeAssetUpload(assetId) {
630
+ return this.#t.call("storage_assets_complete_upload", { path: { id: assetId } });
631
+ }
632
+ getAsset(assetId) {
633
+ return this.#t.call("storage_assets_retrieve", { path: { id: assetId } });
634
+ }
635
+ listAssetFiles(assetId, params = {}) {
636
+ return this.#t.call("storage_assets_files_list", { path: { id: assetId }, query: { ...params } });
637
+ }
638
+ /** `admissible: false` is a normal return value, not an error. */
639
+ checkAssetAdmission(assetId, productId) {
640
+ return this.#t.call("storage_assets_admission_check", {
641
+ path: { asset_id: assetId },
642
+ query: { product_id: productId }
643
+ });
644
+ }
645
+ deleteAsset(assetId) {
646
+ return this.#t.call("storage_assets_delete", { path: { id: assetId } });
647
+ }
648
+ };
649
+ var WebhooksApi = class {
650
+ #t;
651
+ constructor(t) {
652
+ this.#t = t;
653
+ }
654
+ getConfiguration() {
655
+ return this.#t.call("webhooks_configuration_retrieve");
656
+ }
657
+ updateConfiguration(request) {
658
+ return this.#t.call("webhooks_configuration_update", { body: request });
659
+ }
660
+ disableConfiguration() {
661
+ return this.#t.call("webhooks_configuration_disable");
662
+ }
663
+ rotateSecret() {
664
+ return this.#t.call("webhooks_secret_rotate");
665
+ }
666
+ };
667
+ var BillingApi = class {
668
+ #t;
669
+ constructor(t) {
670
+ this.#t = t;
671
+ }
672
+ getGreenPointAccount() {
673
+ return this.#t.call("billing_green_points_account_retrieve");
674
+ }
675
+ listGreenPointLedger(params = {}) {
676
+ return this.#t.call("billing_green_points_ledger_list", { query: { ...params } });
677
+ }
678
+ listGreenPointPurchaseOrders(params = {}) {
679
+ return this.#t.call("billing_green_point_purchase_orders_list", { query: { ...params } });
680
+ }
681
+ };
682
+ var LiveCosmApi = class {
683
+ #t;
684
+ constructor(t) {
685
+ this.#t = t;
686
+ }
687
+ getConfig() {
688
+ return this.#t.call("stream_config_get");
689
+ }
690
+ listScenes(params = {}) {
691
+ return this.#t.call("stream_models_list", { query: { ...params } });
692
+ }
693
+ /**
694
+ * Register a training output as a scene. Take `asset_id` and `key` from an artifact whose
695
+ * `stream_registerable` is true, and `source` from the artifact list's `pipeline_code`.
696
+ */
697
+ registerScene(request) {
698
+ return this.#t.call("stream_models_register", { body: request });
699
+ }
700
+ revokeScene(sceneId) {
701
+ return this.#t.call("stream_models_revoke", { path: { model_id: sceneId } });
702
+ }
703
+ /**
704
+ * Buy and create a room. Spends green points and is never retried automatically. Pass the
705
+ * same `idempotencyKey` (16-128 characters of `[A-Za-z0-9_-]`) to repeat it without a
706
+ * second charge.
707
+ */
708
+ createRoom(request, options = {}) {
709
+ return this.#t.call("stream_sessions_create", {
710
+ body: request,
711
+ headers: { "Idempotency-Key": options.idempotencyKey }
712
+ });
713
+ }
714
+ listRooms(params = {}) {
715
+ return this.#t.call("stream_sessions_list", { query: { ...params } });
716
+ }
717
+ getRoom(roomId) {
718
+ return this.#t.call("stream_sessions_get", { path: { session_id: roomId } });
719
+ }
720
+ stopRoom(roomId) {
721
+ return this.#t.call("stream_sessions_stop", { path: { session_id: roomId } });
722
+ }
723
+ /** Set a new guest password; the previous one stops working. The password is returned once. */
724
+ createGuestLink(roomId, request = {}) {
725
+ return this.#t.call("stream_sessions_guest_link", {
726
+ path: { session_id: roomId },
727
+ body: request
728
+ });
729
+ }
730
+ /** The host link is returned only once. */
731
+ createHostLink(roomId) {
732
+ return this.#t.call("stream_sessions_host_link", { path: { session_id: roomId } });
733
+ }
734
+ listMembers(roomId) {
735
+ return this.#t.call("stream_sessions_members", { path: { session_id: roomId } });
736
+ }
737
+ removeMember(roomId, memberId) {
738
+ return this.#t.call("stream_sessions_member_remove", {
739
+ path: { session_id: roomId, member_id: memberId }
740
+ });
741
+ }
742
+ };
743
+ var Pointcosm = class _Pointcosm {
744
+ train;
745
+ storage;
746
+ webhooks;
747
+ billing;
748
+ /** @experimental Preview: may change in a minor release. */
749
+ livecosm;
750
+ #transport;
751
+ constructor(input) {
752
+ this.#transport = input instanceof Transport ? input : transport(input, () => required(input.accessToken, "accessToken"));
753
+ this.train = new TrainApi(this.#transport);
754
+ this.storage = new StorageApi(this.#transport);
755
+ this.webhooks = new WebhooksApi(this.#transport);
756
+ this.billing = new BillingApi(this.#transport);
757
+ this.livecosm = new LiveCosmApi(this.#transport);
758
+ }
759
+ /**
760
+ * Server-side only: exchange a client secret for short-lived tokens, cached in memory.
761
+ * Throws in browsers, where a client secret must never be present.
762
+ */
763
+ static fromClientCredentials(options) {
764
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
765
+ throw new PointcosmConfigurationError("client credentials are not allowed in browsers");
766
+ }
767
+ const credentials = {
768
+ authBaseUrl: origin(options.authBaseUrl, "authBaseUrl"),
769
+ clientId: required(options.clientId, "clientId"),
770
+ clientSecret: required(options.clientSecret, "clientSecret"),
771
+ resource: required(options.resource, "resource")
772
+ };
773
+ const built = transport(
774
+ options,
775
+ (fetchImpl, timeoutMs) => new TokenProvider(credentials, fetchImpl, timeoutMs)
776
+ );
777
+ return new _Pointcosm(built);
778
+ }
779
+ /** Drop cached tokens and reject further calls. */
780
+ close() {
781
+ this.#transport.close();
782
+ }
783
+ };
784
+ export {
785
+ BillingApi,
786
+ CONTRACT,
787
+ LiveCosmApi,
788
+ Pointcosm,
789
+ PointcosmApiError,
790
+ PointcosmAuthenticationError,
791
+ PointcosmAuthorizationError,
792
+ PointcosmConfigurationError,
793
+ PointcosmContractError,
794
+ PointcosmError,
795
+ PointcosmRateLimitError,
796
+ PointcosmServerError,
797
+ PointcosmTimeoutError,
798
+ PointcosmTransportError,
799
+ PointcosmValidationError,
800
+ Secret,
801
+ StorageApi,
802
+ TrainApi,
803
+ WebhooksApi
804
+ };