@distilled.cloud/mux 0.0.0-stage → 1.0.0-rc.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +126 -2
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/lazy.js +4 -0
  5. package/lib/_bundle/sdk.js +2 -0
  6. package/lib/_bundle/sdk.js.map +1 -0
  7. package/lib/credentials.d.ts +66 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +45 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +44 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +6 -0
  16. package/lib/pagination.d.ts +11 -0
  17. package/lib/pagination.d.ts.map +1 -0
  18. package/lib/pagination.js +1 -0
  19. package/lib/protocol.d.ts +19 -0
  20. package/lib/protocol.d.ts.map +1 -0
  21. package/lib/protocol.js +1 -0
  22. package/lib/retry.d.ts +54 -0
  23. package/lib/retry.d.ts.map +1 -0
  24. package/lib/retry.js +1 -0
  25. package/lib/services/data.d.ts +1347 -0
  26. package/lib/services/data.d.ts.map +1 -0
  27. package/lib/services/data.js +58 -0
  28. package/lib/services/data.js.map +1 -0
  29. package/lib/services/index.d.ts +5 -0
  30. package/lib/services/index.d.ts.map +1 -0
  31. package/lib/services/index.js +4 -0
  32. package/lib/services/robots.d.ts +2206 -0
  33. package/lib/services/robots.d.ts.map +1 -0
  34. package/lib/services/robots.js +75 -0
  35. package/lib/services/robots.js.map +1 -0
  36. package/lib/services/system.d.ts +263 -0
  37. package/lib/services/system.d.ts.map +1 -0
  38. package/lib/services/system.js +2 -0
  39. package/lib/services/system.js.map +1 -0
  40. package/lib/services/video.d.ts +1564 -0
  41. package/lib/services/video.d.ts.map +1 -0
  42. package/lib/services/video.js +100 -0
  43. package/lib/services/video.js.map +1 -0
  44. package/lib/services.lazy/data.js +3 -0
  45. package/lib/services.lazy/index.js +3 -0
  46. package/lib/services.lazy/robots.js +4 -0
  47. package/lib/services.lazy/system.js +1 -0
  48. package/lib/services.lazy/video.js +4 -0
  49. package/lib/traits.d.ts +7 -0
  50. package/lib/traits.d.ts.map +1 -0
  51. package/lib/traits.js +1 -0
  52. package/package.json +87 -3
  53. package/src/credentials.ts +142 -0
  54. package/src/errors.ts +59 -0
  55. package/src/index.ts +43 -0
  56. package/src/pagination.ts +63 -0
  57. package/src/protocol.ts +62 -0
  58. package/src/retry.ts +73 -0
  59. package/src/services/data.ts +3993 -0
  60. package/src/services/index.ts +5 -0
  61. package/src/services/robots.ts +4712 -0
  62. package/src/services/system.ts +752 -0
  63. package/src/services/video.ts +4291 -0
  64. package/src/traits.ts +40 -0
@@ -0,0 +1,752 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ import * as C from "@distilled.cloud/core/category";
3
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-mux/specs/api-spec.json). Do not edit.
4
+ import * as S from "@distilled.cloud/core/schema-lite";
5
+ import * as __L from "@distilled.cloud/core/schema-lite";
6
+ import type * as Redacted from "effect/Redacted";
7
+ import { MuxServiceErrors } from "../errors.ts";
8
+ import { paginatePage } from "../pagination.ts";
9
+ import { MuxProtocol, type MuxOpError, type MuxOpContext } from "../protocol.ts";
10
+ import * as Retry from "../retry.ts";
11
+ import * as T from "../traits.ts";
12
+ // Schema table, filled on first reach (see __S at the end).
13
+ const __s: any[] = [];
14
+
15
+ export type { MuxOpError, MuxOpContext };
16
+
17
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
18
+ const TELEMETRY = {
19
+ system: "mux-api",
20
+ responseHeaders: [
21
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
22
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
23
+ ],
24
+ prefix: "Mux",
25
+ service: "MuxSystem",
26
+ labels: "mux",
27
+ propagate: "w3c",
28
+ } as const;
29
+
30
+ export class BadRequest
31
+ extends /*@__PURE__*/ T.applyErrorMatchers(
32
+ /*@__PURE__*/ S.TaggedError<BadRequest>()("BadRequest", {
33
+ code: S.Number,
34
+ message: S.String,
35
+ body: /*@__PURE__*/ S.optional(
36
+ /*@__PURE__*/ S.Union([
37
+ /*@__PURE__*/ S.suspend(() => __S(9, __c1, 1)),
38
+ /*@__PURE__*/ S.suspend(() => __S(9, __c1, 1)),
39
+ S.String,
40
+ ]),
41
+ ),
42
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
43
+ }).pipe(C.withBadRequestError),
44
+ [{ status: 400 }],
45
+ )
46
+ {
47
+ declare readonly body?: SystemErrorResponse | UnauthorizedResponse | string;
48
+ }
49
+
50
+ export class Forbidden
51
+ extends /*@__PURE__*/ T.applyErrorMatchers(
52
+ /*@__PURE__*/ S.TaggedError<Forbidden>()("Forbidden", {
53
+ code: S.Number,
54
+ message: S.String,
55
+ body: /*@__PURE__*/ S.optional(
56
+ /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(9, __c1, 1)), S.String]),
57
+ ),
58
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
59
+ }).pipe(C.withAuthError),
60
+ [{ status: 403 }],
61
+ )
62
+ {
63
+ declare readonly body?: UnauthorizedResponse | string;
64
+ }
65
+
66
+ export class NotFound
67
+ extends /*@__PURE__*/ T.applyErrorMatchers(
68
+ /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
69
+ code: S.Number,
70
+ message: S.String,
71
+ body: /*@__PURE__*/ S.optional(
72
+ /*@__PURE__*/ S.Union([
73
+ /*@__PURE__*/ S.suspend(() => __S(9, __c1, 1)),
74
+ /*@__PURE__*/ S.suspend(() => __S(9, __c1, 1)),
75
+ S.String,
76
+ ]),
77
+ ),
78
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
79
+ }).pipe(C.withBadRequestError),
80
+ [{ status: 404 }],
81
+ )
82
+ {
83
+ declare readonly body?: SystemErrorResponse | UnauthorizedResponse | string;
84
+ }
85
+
86
+ export class PreconditionFailed
87
+ extends /*@__PURE__*/ T.applyErrorMatchers(
88
+ /*@__PURE__*/ S.TaggedError<PreconditionFailed>()("PreconditionFailed", {
89
+ code: S.Number,
90
+ message: S.String,
91
+ body: /*@__PURE__*/ S.optional(
92
+ /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(9, __c1, 1)), S.String]),
93
+ ),
94
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
95
+ }),
96
+ [{ status: 412 }],
97
+ )
98
+ {
99
+ declare readonly body?: UnauthorizedResponse | string;
100
+ }
101
+
102
+ export class WebhookAddressInUse
103
+ extends /*@__PURE__*/ T.applyErrorMatchers(
104
+ /*@__PURE__*/ S.TaggedError<WebhookAddressInUse>()("WebhookAddressInUse", {
105
+ message: S.String,
106
+ body: /*@__PURE__*/ S.optional(
107
+ /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(9, __c1, 1)), S.String]),
108
+ ),
109
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
110
+ }).pipe(C.withBadRequestError, C.withAlreadyExistsError),
111
+ [{ status: 400, message: { includes: "webhook with this address already exists" } }],
112
+ )
113
+ {
114
+ declare readonly body?: SystemErrorResponse | string;
115
+ }
116
+
117
+ export interface CreateSigningKeyRequest {}
118
+ export interface SigningKey {
119
+ /** Unique identifier for the Signing Key. */
120
+ id: string;
121
+ /** Time at which the object was created. Measured in seconds since the Unix epoch. */
122
+ created_at: string;
123
+ /** A Base64 encoded private key that can be used with the RS256 algorithm when creating a [JWT](https://jwt.io/). **Note that this value is only returned once when creating a URL signing key.** */
124
+ private_key?: string | Redacted.Redacted<string> | undefined;
125
+ }
126
+ export interface SigningKeyResponse {
127
+ data: SigningKey;
128
+ }
129
+ export interface CreateWebhookRequest {
130
+ /** The URL where Mux should send webhook notifications. Must be unique among the environment's webhooks. */
131
+ address: string;
132
+ }
133
+ export interface Webhook {
134
+ /** Unique identifier for the webhook. */
135
+ id: string;
136
+ /** The URL where Mux sends webhook notifications. */
137
+ address: string;
138
+ /** Whether Mux attempts to deliver notifications to this webhook. */
139
+ enabled: boolean;
140
+ /** Time at which the webhook was created, as an ISO 8601 UTC datetime. */
141
+ created_at: string;
142
+ /** Secret used to verify that webhook payloads were sent by Mux. **Note that this value is only returned once when creating a webhook.** */
143
+ signing_secret?: string | Redacted.Redacted<string> | undefined;
144
+ }
145
+ export interface WebhookResponse {
146
+ data: Webhook;
147
+ }
148
+ export interface DeleteSigningKeyRequest {
149
+ /** The ID of the signing key. */
150
+ SIGNING_KEY_ID: string;
151
+ }
152
+ export interface DeleteSigningKeyResponse {}
153
+ export interface DeleteWebhookRequest {
154
+ /** The ID of the webhook. */
155
+ WEBHOOK_ID: string;
156
+ }
157
+ export interface DeleteWebhookResponse {}
158
+ export interface GetSigningKeyRequest {
159
+ /** The ID of the signing key. */
160
+ SIGNING_KEY_ID: string;
161
+ }
162
+ export interface GetWebhookRequest {
163
+ /** The ID of the webhook. */
164
+ WEBHOOK_ID: string;
165
+ }
166
+ export interface GetWhoamiRequest {}
167
+ export type WhoAmIResponseDataPermissionsList = Array<string>;
168
+ export interface WhoAmIResponseData {
169
+ permissions: WhoAmIResponseDataPermissionsList;
170
+ organization_name: string;
171
+ organization_id: string;
172
+ environment_type: string;
173
+ environment_name: string;
174
+ environment_id: string;
175
+ access_token_name: string;
176
+ }
177
+ export interface WhoAmIResponse {
178
+ data: WhoAmIResponseData;
179
+ total_row_count?: number | null | undefined;
180
+ }
181
+ export interface ListSigningKeysRequest {
182
+ /** Number of items to include in the response */
183
+ limit?: number | undefined;
184
+ /** Offset by this many pages, of the size of `limit` */
185
+ page?: number | undefined;
186
+ }
187
+ export type ListSigningKeysResponseDataList = Array<SigningKey>;
188
+ export interface ListSigningKeysResponse {
189
+ data: ListSigningKeysResponseDataList;
190
+ }
191
+ export type ListUsageExportsRequestTimeframeList = Array<string>;
192
+ export interface ListUsageExportsRequest {
193
+ /** Number of items to include in the response */
194
+ limit?: number | undefined;
195
+ /** Offset by this many pages, of the size of `limit` */
196
+ page?: number | undefined;
197
+ /** Timeframe window to limit results by. Must be provided as an array query string parameter (e.g. timeframe[]=). Accepted formats are... * array of epoch timestamps e.g. `timeframe[]=1498867200&timeframe[]=1498953600` * duration string e.g. `timeframe[]=24:hours or timeframe[]=7:days` */
198
+ timeframe__?: ListUsageExportsRequestTimeframeList | undefined;
199
+ /** Lifetime in seconds for the pre-signed download URL. */
200
+ download_url_ttl?: number | undefined;
201
+ }
202
+ export interface UsageExport {
203
+ /** The calendar date this CSV covers, in `YYYY-MM-DD` format. */
204
+ date: string;
205
+ /** Uncompressed size of the CSV file in bytes. May be `null` if the size is unavailable. */
206
+ file_size: number | null;
207
+ /** A pre-signed URL to download the CSV. Valid until `download_url_expires_at`. */
208
+ download_url: string;
209
+ /** Unix timestamp (seconds since epoch) at which `download_url` expires. */
210
+ download_url_expires_at: number;
211
+ }
212
+ export type ListUsageExportsResponseDataList = Array<UsageExport>;
213
+ export interface UsageExportsMeta {
214
+ /** Current page number (1-based). */
215
+ page: number;
216
+ /** Total number of pages. */
217
+ pages: number;
218
+ /** Maximum number of items per page. */
219
+ limit: number;
220
+ /** Total number of available export files matching the query. */
221
+ total: number;
222
+ }
223
+ export interface ListUsageExportsResponse {
224
+ data: ListUsageExportsResponseDataList;
225
+ meta: UsageExportsMeta;
226
+ }
227
+ export interface ListWebhooksRequest {
228
+ /** Number of items to include in the response */
229
+ limit?: number | undefined;
230
+ /** Offset by this many pages, of the size of `limit` */
231
+ page?: number | undefined;
232
+ }
233
+ export type ListWebhooksResponseDataList = Array<Webhook>;
234
+ export interface ListWebhooksResponse {
235
+ data: ListWebhooksResponseDataList;
236
+ /** Total number of webhooks in the environment (not the number of items on this page). */
237
+ total_row_count?: number | undefined;
238
+ /** The current page number. */
239
+ page?: number | undefined;
240
+ /** The maximum number of items per page. */
241
+ limit?: number | undefined;
242
+ }
243
+ export interface UpdateWebhookRequest {
244
+ /** The ID of the webhook. */
245
+ WEBHOOK_ID: string;
246
+ /** The URL where Mux should send webhook notifications. Must be unique among the environment's webhooks. */
247
+ address?: string | undefined;
248
+ /** Whether Mux attempts to deliver notifications to this webhook. */
249
+ enabled?: boolean | undefined;
250
+ }
251
+ /** Friendly messages of errors encountered */
252
+ export type SystemErrorResponseErrorMessagesList = Array<string>;
253
+ export interface SystemErrorResponseError {
254
+ /** The type of the error */
255
+ type: string;
256
+ /** Friendly messages of errors encountered */
257
+ messages: SystemErrorResponseErrorMessagesList;
258
+ }
259
+ export interface SystemErrorResponse {
260
+ error: SystemErrorResponseError;
261
+ }
262
+ /** Friendly messages of errors encountered */
263
+ export type UnauthorizedResponseErrorMessagesList = Array<string>;
264
+ export interface UnauthorizedResponseError {
265
+ /** The type of the error */
266
+ type: string;
267
+ /** Friendly messages of errors encountered */
268
+ messages: UnauthorizedResponseErrorMessagesList;
269
+ }
270
+ export interface UnauthorizedResponse {
271
+ error: UnauthorizedResponseError;
272
+ }
273
+ export type CreateSigningKeyError = MuxOpError;
274
+ /** Create a signing key Creates a new signing key pair. When creating a new signing key, the API will generate a 2048-bit RSA key-pair and return the private key and a generated key-id; the public key will be stored at Mux to validate signed tokens. */
275
+ export const createSigningKey: API.OperationMethod<
276
+ CreateSigningKeyRequest,
277
+ SigningKeyResponse,
278
+ CreateSigningKeyError,
279
+ MuxOpContext
280
+ > = /*@__PURE__*/ API.make(() => ({
281
+ input: __S(64, __c8, 0) as any as S.Schema<CreateSigningKeyRequest>,
282
+ output: __S(72, __c9, 0) as any as S.Schema<SigningKeyResponse>,
283
+ errors: [],
284
+ serviceErrors: MuxServiceErrors,
285
+ protocol: MuxProtocol,
286
+ retry: Retry.Retry,
287
+ telemetry: TELEMETRY,
288
+ span: "CreateSigningKey",
289
+ }));
290
+
291
+ export type CreateWebhookError = BadRequest | WebhookAddressInUse | MuxOpError;
292
+ /** Create a webhook Creates a new webhook for the current environment. New webhooks start out enabled. The `address` must be unique among the environment's webhooks. **The `signing_secret` is only returned in this response and cannot be retrieved again.** Store it securely and use it to verify that webhook payloads were sent by Mux. */
293
+ export const createWebhook: API.OperationMethod<
294
+ CreateWebhookRequest,
295
+ WebhookResponse,
296
+ CreateWebhookError,
297
+ MuxOpContext
298
+ > = /*@__PURE__*/ API.make(() => ({
299
+ input: __S(88, __c11, 0) as any as S.Schema<CreateWebhookRequest>,
300
+ output: __S(104, __c13, 0) as any as S.Schema<WebhookResponse>,
301
+ errors: [BadRequest, WebhookAddressInUse],
302
+ serviceErrors: MuxServiceErrors,
303
+ protocol: MuxProtocol,
304
+ retry: Retry.Retry,
305
+ telemetry: TELEMETRY,
306
+ span: "CreateWebhook",
307
+ }));
308
+
309
+ export type DeleteSigningKeyError = MuxOpError;
310
+ /** Delete a signing key Deletes an existing signing key. Use with caution, as this will invalidate any existing signatures and no JWTs can be signed using the key again. */
311
+ export const deleteSigningKey: API.OperationMethod<
312
+ DeleteSigningKeyRequest,
313
+ DeleteSigningKeyResponse,
314
+ DeleteSigningKeyError,
315
+ MuxOpContext
316
+ > = /*@__PURE__*/ API.make(() => ({
317
+ input: __S(112, __c14, 0) as any as S.Schema<DeleteSigningKeyRequest>,
318
+ output: __S(120, __c15, 0) as any as S.Schema<DeleteSigningKeyResponse>,
319
+ errors: [],
320
+ serviceErrors: MuxServiceErrors,
321
+ protocol: MuxProtocol,
322
+ retry: Retry.Retry,
323
+ telemetry: TELEMETRY,
324
+ span: "DeleteSigningKey",
325
+ }));
326
+
327
+ export type DeleteWebhookError = NotFound | MuxOpError;
328
+ /** Delete a webhook Deletes an existing webhook. Mux will no longer send event notifications to the configured address, the webhook no longer appears in list or retrieve responses, and its address becomes available for use by a new webhook (which will have a new ID and signing secret). */
329
+ export const deleteWebhook: API.OperationMethod<
330
+ DeleteWebhookRequest,
331
+ DeleteWebhookResponse,
332
+ DeleteWebhookError,
333
+ MuxOpContext
334
+ > = /*@__PURE__*/ API.make(() => ({
335
+ input: __S(128, __c16, 0) as any as S.Schema<DeleteWebhookRequest>,
336
+ output: __S(120, __c15, 0) as any as S.Schema<DeleteWebhookResponse>,
337
+ errors: [NotFound],
338
+ serviceErrors: MuxServiceErrors,
339
+ protocol: MuxProtocol,
340
+ retry: Retry.Retry,
341
+ telemetry: TELEMETRY,
342
+ span: "DeleteWebhook",
343
+ }));
344
+
345
+ export type GetSigningKeyError = MuxOpError;
346
+ /** Retrieve a signing key Retrieves the details of a signing key that has previously been created. Supply the unique signing key ID that was returned from your previous request, and Mux will return the corresponding signing key information. **The private key is not returned in this response.** */
347
+ export const getSigningKey: API.OperationMethod<
348
+ GetSigningKeyRequest,
349
+ SigningKeyResponse,
350
+ GetSigningKeyError,
351
+ MuxOpContext
352
+ > = /*@__PURE__*/ API.make(() => ({
353
+ input: __S(136, __c17, 0) as any as S.Schema<GetSigningKeyRequest>,
354
+ output: __S(72, __c9, 0) as any as S.Schema<SigningKeyResponse>,
355
+ errors: [],
356
+ serviceErrors: MuxServiceErrors,
357
+ protocol: MuxProtocol,
358
+ retry: Retry.Retry,
359
+ telemetry: TELEMETRY,
360
+ span: "GetSigningKey",
361
+ }));
362
+
363
+ export type GetWebhookError = NotFound | MuxOpError;
364
+ /** Retrieve a webhook Retrieves the details of a webhook that has previously been created. The `signing_secret` is not included; it is only returned once, when the webhook is created. */
365
+ export const getWebhook: API.OperationMethod<
366
+ GetWebhookRequest,
367
+ WebhookResponse,
368
+ GetWebhookError,
369
+ MuxOpContext
370
+ > = /*@__PURE__*/ API.make(() => ({
371
+ input: __S(16, __c2, 0) as any as S.Schema<GetWebhookRequest>,
372
+ output: __S(104, __c13, 0) as any as S.Schema<WebhookResponse>,
373
+ errors: [NotFound],
374
+ serviceErrors: MuxServiceErrors,
375
+ protocol: MuxProtocol,
376
+ retry: Retry.Retry,
377
+ telemetry: TELEMETRY,
378
+ span: "GetWebhook",
379
+ }));
380
+
381
+ export type GetWhoamiError = MuxOpError;
382
+ /** Retrieve information about your current access token. Retrieve information about your current access token, including organization, environment, and permissions. Note that this can only be access with an access token, and _all_ access tokens can access this route, regardless of what permissions they have assigned. */
383
+ export const getWhoami: API.OperationMethod<
384
+ GetWhoamiRequest,
385
+ WhoAmIResponse,
386
+ GetWhoamiError,
387
+ MuxOpContext
388
+ > = /*@__PURE__*/ API.make(() => ({
389
+ input: __S(24, __c3, 0) as any as S.Schema<GetWhoamiRequest>,
390
+ output: __S(26, __c3, 2) as any as S.Schema<WhoAmIResponse>,
391
+ errors: [],
392
+ serviceErrors: MuxServiceErrors,
393
+ protocol: MuxProtocol,
394
+ retry: Retry.Retry,
395
+ telemetry: TELEMETRY,
396
+ span: "GetWhoami",
397
+ }));
398
+
399
+ export type ListSigningKeysError = MuxOpError;
400
+ /** List signing keys Returns a list of signing keys. */
401
+ export const listSigningKeys: API.PaginatedOperationMethod<
402
+ ListSigningKeysRequest,
403
+ ListSigningKeysResponse,
404
+ ListSigningKeysError,
405
+ MuxOpContext,
406
+ SigningKey
407
+ > = /*@__PURE__*/ API.makePaginated(
408
+ () => ({
409
+ input: __S(32, __c4, 0) as any as S.Schema<ListSigningKeysRequest>,
410
+ output: __S(34, __c4, 2) as any as S.Schema<ListSigningKeysResponse>,
411
+ errors: [],
412
+ serviceErrors: MuxServiceErrors,
413
+ protocol: MuxProtocol,
414
+ retry: Retry.Retry,
415
+ telemetry: TELEMETRY,
416
+ span: "ListSigningKeys",
417
+ pagination: { mode: "page", inputToken: "page", items: "data", pageSize: "limit" } as const,
418
+ }),
419
+ paginatePage,
420
+ ) as any;
421
+
422
+ export type ListUsageExportsError =
423
+ | BadRequest
424
+ | Forbidden
425
+ | NotFound
426
+ | PreconditionFailed
427
+ | MuxOpError;
428
+ /** List usage export CSVs Lists available billing usage exports for your organization along with pre-signed download URLs, sorted newest first. CSVs are available for dates between 400 days ago and yesterday. */
429
+ export const listUsageExports: API.PaginatedOperationMethod<
430
+ ListUsageExportsRequest,
431
+ ListUsageExportsResponse,
432
+ ListUsageExportsError,
433
+ MuxOpContext,
434
+ UsageExport
435
+ > = /*@__PURE__*/ API.makePaginated(
436
+ () => ({
437
+ input: __S(40, __c5, 0) as any as S.Schema<ListUsageExportsRequest>,
438
+ output: __S(44, __c5, 4) as any as S.Schema<ListUsageExportsResponse>,
439
+ errors: [BadRequest, Forbidden, NotFound, PreconditionFailed],
440
+ serviceErrors: MuxServiceErrors,
441
+ protocol: MuxProtocol,
442
+ retry: Retry.Retry,
443
+ telemetry: TELEMETRY,
444
+ span: "ListUsageExports",
445
+ pagination: { mode: "page", inputToken: "page", items: "data", pageSize: "limit" } as const,
446
+ }),
447
+ paginatePage,
448
+ ) as any;
449
+
450
+ export type ListWebhooksError = BadRequest | MuxOpError;
451
+ /** List webhooks Returns a list of webhooks configured for the current environment, sorted by creation time with the most recently created first. The `signing_secret` is not included; it is only returned once, when a webhook is created. */
452
+ export const listWebhooks: API.PaginatedOperationMethod<
453
+ ListWebhooksRequest,
454
+ ListWebhooksResponse,
455
+ ListWebhooksError,
456
+ MuxOpContext,
457
+ Webhook
458
+ > = /*@__PURE__*/ API.makePaginated(
459
+ () => ({
460
+ input: __S(48, __c6, 0) as any as S.Schema<ListWebhooksRequest>,
461
+ output: __S(50, __c6, 2) as any as S.Schema<ListWebhooksResponse>,
462
+ errors: [BadRequest],
463
+ serviceErrors: MuxServiceErrors,
464
+ protocol: MuxProtocol,
465
+ retry: Retry.Retry,
466
+ telemetry: TELEMETRY,
467
+ span: "ListWebhooks",
468
+ pagination: { mode: "page", inputToken: "page", items: "data", pageSize: "limit" } as const,
469
+ }),
470
+ paginatePage,
471
+ ) as any;
472
+
473
+ export type UpdateWebhookError = BadRequest | NotFound | WebhookAddressInUse | MuxOpError;
474
+ /** Update a webhook Updates the address and/or enabled status of an existing webhook. Omitted fields are left unchanged; at least one of `address` or `enabled` must be provided. The new `address` must be unique among the environment's webhooks. */
475
+ export const updateWebhook: API.OperationMethod<
476
+ UpdateWebhookRequest,
477
+ WebhookResponse,
478
+ UpdateWebhookError,
479
+ MuxOpContext
480
+ > = /*@__PURE__*/ API.make(() => ({
481
+ input: __S(56, __c7, 0) as any as S.Schema<UpdateWebhookRequest>,
482
+ output: __S(104, __c13, 0) as any as S.Schema<WebhookResponse>,
483
+ errors: [BadRequest, NotFound, WebhookAddressInUse],
484
+ serviceErrors: MuxServiceErrors,
485
+ protocol: MuxProtocol,
486
+ retry: Retry.Retry,
487
+ telemetry: TELEMETRY,
488
+ span: "UpdateWebhook",
489
+ }));
490
+
491
+ // Schema builders: each runs one schema initializer, on that schema's first use.
492
+ function __c0(j: number): any {
493
+ switch (j) {
494
+ case 0:
495
+ return S.Array(S.String);
496
+ }
497
+ }
498
+ function __c1(j: number): any {
499
+ switch (j) {
500
+ case 0:
501
+ return S.suspend(() =>
502
+ S.Struct({
503
+ type: S.String,
504
+ messages: __S(0, __c0, 0),
505
+ }),
506
+ ).annotate({ identifier: "SystemErrorResponseError" });
507
+ case 1:
508
+ return S.suspend(() =>
509
+ S.Struct({
510
+ error: __S(8, __c1, 0),
511
+ }),
512
+ ).annotate({ identifier: "SystemErrorResponse" });
513
+ }
514
+ }
515
+ function __c2(j: number): any {
516
+ switch (j) {
517
+ case 0:
518
+ return S.suspend(() =>
519
+ S.Struct({
520
+ WEBHOOK_ID: S.String.pipe(T.Label()),
521
+ }).pipe(T.Http({ method: "GET", uri: "/system/v1/webhooks/{WEBHOOK_ID}", code: 200 })),
522
+ ).annotate({ identifier: "GetWebhookRequest" });
523
+ }
524
+ }
525
+ function __c3(j: number): any {
526
+ switch (j) {
527
+ case 0:
528
+ return S.suspend(() =>
529
+ S.Struct({}).pipe(T.Http({ method: "GET", uri: "/system/v1/whoami", code: 200 })),
530
+ ).annotate({ identifier: "GetWhoamiRequest" });
531
+ case 1:
532
+ return S.suspend(() =>
533
+ S.Struct({
534
+ permissions: __S(0, __c0, 0),
535
+ organization_name: S.String,
536
+ organization_id: S.String,
537
+ environment_type: S.String,
538
+ environment_name: S.String,
539
+ environment_id: S.String,
540
+ access_token_name: S.String,
541
+ }),
542
+ ).annotate({ identifier: "WhoAmIResponseData" });
543
+ case 2:
544
+ return S.suspend(() =>
545
+ S.Struct({
546
+ data: __S(25, __c3, 1),
547
+ total_row_count: S.optional(S.NullOr(S.Number)),
548
+ }),
549
+ ).annotate({ identifier: "WhoAmIResponse" });
550
+ }
551
+ }
552
+ function __c4(j: number): any {
553
+ switch (j) {
554
+ case 0:
555
+ return S.suspend(() =>
556
+ S.Struct({
557
+ limit: S.optional(S.Number.pipe(T.Query())),
558
+ page: S.optional(S.Number.pipe(T.Query())),
559
+ }).pipe(T.Http({ method: "GET", uri: "/system/v1/signing-keys", code: 200 })),
560
+ ).annotate({ identifier: "ListSigningKeysRequest" });
561
+ case 1:
562
+ return S.Array(__S(80, __c10, 0));
563
+ case 2:
564
+ return S.suspend(() =>
565
+ S.Struct({
566
+ data: __S(33, __c4, 1),
567
+ }),
568
+ ).annotate({ identifier: "ListSigningKeysResponse" });
569
+ }
570
+ }
571
+ function __c5(j: number): any {
572
+ switch (j) {
573
+ case 0:
574
+ return S.suspend(() =>
575
+ S.Struct({
576
+ limit: S.optional(S.Number.pipe(T.Query())),
577
+ page: S.optional(S.Number.pipe(T.Query())),
578
+ timeframe__: S.optional(__S(0, __c0, 0).pipe(T.Query("timeframe[]"))),
579
+ download_url_ttl: S.optional(S.Number.pipe(T.Query())),
580
+ }).pipe(T.Http({ method: "GET", uri: "/system/v1/usage/exports", code: 200 })),
581
+ ).annotate({ identifier: "ListUsageExportsRequest" });
582
+ case 1:
583
+ return S.suspend(() =>
584
+ S.Struct({
585
+ date: S.String,
586
+ file_size: S.NullOr(S.Number),
587
+ download_url: S.String,
588
+ download_url_expires_at: S.Number,
589
+ }),
590
+ ).annotate({ identifier: "UsageExport" });
591
+ case 2:
592
+ return S.Array(__S(41, __c5, 1));
593
+ case 3:
594
+ return S.suspend(() =>
595
+ S.Struct({
596
+ page: S.Number,
597
+ pages: S.Number,
598
+ limit: S.Number,
599
+ total: S.Number,
600
+ }),
601
+ ).annotate({ identifier: "UsageExportsMeta" });
602
+ case 4:
603
+ return S.suspend(() =>
604
+ S.Struct({
605
+ data: __S(42, __c5, 2),
606
+ meta: __S(43, __c5, 3),
607
+ }),
608
+ ).annotate({ identifier: "ListUsageExportsResponse" });
609
+ }
610
+ }
611
+ function __c6(j: number): any {
612
+ switch (j) {
613
+ case 0:
614
+ return S.suspend(() =>
615
+ S.Struct({
616
+ limit: S.optional(S.Number.pipe(T.Query())),
617
+ page: S.optional(S.Number.pipe(T.Query())),
618
+ }).pipe(T.Http({ method: "GET", uri: "/system/v1/webhooks", code: 200 })),
619
+ ).annotate({ identifier: "ListWebhooksRequest" });
620
+ case 1:
621
+ return S.Array(__S(96, __c12, 0));
622
+ case 2:
623
+ return S.suspend(() =>
624
+ S.Struct({
625
+ data: __S(49, __c6, 1),
626
+ total_row_count: S.optional(S.Number),
627
+ page: S.optional(S.Number),
628
+ limit: S.optional(S.Number),
629
+ }),
630
+ ).annotate({ identifier: "ListWebhooksResponse" });
631
+ }
632
+ }
633
+ function __c7(j: number): any {
634
+ switch (j) {
635
+ case 0:
636
+ return S.suspend(() =>
637
+ S.Struct({
638
+ WEBHOOK_ID: S.String.pipe(T.Label()),
639
+ address: S.optional(S.String),
640
+ enabled: S.optional(S.Boolean),
641
+ }).pipe(T.Http({ method: "PATCH", uri: "/system/v1/webhooks/{WEBHOOK_ID}", code: 200 })),
642
+ ).annotate({ identifier: "UpdateWebhookRequest" });
643
+ }
644
+ }
645
+ function __c8(j: number): any {
646
+ switch (j) {
647
+ case 0:
648
+ return S.suspend(() =>
649
+ S.Struct({}).pipe(T.Http({ method: "POST", uri: "/system/v1/signing-keys", code: 200 })),
650
+ ).annotate({ identifier: "CreateSigningKeyRequest" });
651
+ }
652
+ }
653
+ function __c9(j: number): any {
654
+ switch (j) {
655
+ case 0:
656
+ return S.suspend(() =>
657
+ S.Struct({
658
+ data: __S(80, __c10, 0),
659
+ }),
660
+ ).annotate({ identifier: "SigningKeyResponse" });
661
+ }
662
+ }
663
+ function __c10(j: number): any {
664
+ switch (j) {
665
+ case 0:
666
+ return S.suspend(() =>
667
+ S.Struct({
668
+ id: S.String,
669
+ created_at: S.String,
670
+ private_key: S.optional(S.String.pipe(T.SensitiveValue({}))),
671
+ }),
672
+ ).annotate({ identifier: "SigningKey" });
673
+ }
674
+ }
675
+ function __c11(j: number): any {
676
+ switch (j) {
677
+ case 0:
678
+ return S.suspend(() =>
679
+ S.Struct({
680
+ address: S.String,
681
+ }).pipe(T.Http({ method: "POST", uri: "/system/v1/webhooks", code: 200 })),
682
+ ).annotate({ identifier: "CreateWebhookRequest" });
683
+ }
684
+ }
685
+ function __c12(j: number): any {
686
+ switch (j) {
687
+ case 0:
688
+ return S.suspend(() =>
689
+ S.Struct({
690
+ id: S.String,
691
+ address: S.String,
692
+ enabled: S.Boolean,
693
+ created_at: S.String,
694
+ signing_secret: S.optional(S.String.pipe(T.SensitiveValue({}))),
695
+ }),
696
+ ).annotate({ identifier: "Webhook" });
697
+ }
698
+ }
699
+ function __c13(j: number): any {
700
+ switch (j) {
701
+ case 0:
702
+ return S.suspend(() =>
703
+ S.Struct({
704
+ data: __S(96, __c12, 0),
705
+ }),
706
+ ).annotate({ identifier: "WebhookResponse" });
707
+ }
708
+ }
709
+ function __c14(j: number): any {
710
+ switch (j) {
711
+ case 0:
712
+ return S.suspend(() =>
713
+ S.Struct({
714
+ SIGNING_KEY_ID: S.String.pipe(T.Label()),
715
+ }).pipe(
716
+ T.Http({ method: "DELETE", uri: "/system/v1/signing-keys/{SIGNING_KEY_ID}", code: 200 }),
717
+ ),
718
+ ).annotate({ identifier: "DeleteSigningKeyRequest" });
719
+ }
720
+ }
721
+ function __c15(j: number): any {
722
+ switch (j) {
723
+ case 0:
724
+ return S.suspend(() => S.Struct({})).annotate({ identifier: "DeleteSigningKeyResponse" });
725
+ }
726
+ }
727
+ function __c16(j: number): any {
728
+ switch (j) {
729
+ case 0:
730
+ return S.suspend(() =>
731
+ S.Struct({
732
+ WEBHOOK_ID: S.String.pipe(T.Label()),
733
+ }).pipe(T.Http({ method: "DELETE", uri: "/system/v1/webhooks/{WEBHOOK_ID}", code: 200 })),
734
+ ).annotate({ identifier: "DeleteWebhookRequest" });
735
+ }
736
+ }
737
+ function __c17(j: number): any {
738
+ switch (j) {
739
+ case 0:
740
+ return S.suspend(() =>
741
+ S.Struct({
742
+ SIGNING_KEY_ID: S.String.pipe(T.Label()),
743
+ }).pipe(
744
+ T.Http({ method: "GET", uri: "/system/v1/signing-keys/{SIGNING_KEY_ID}", code: 200 }),
745
+ ),
746
+ ).annotate({ identifier: "GetSigningKeyRequest" });
747
+ }
748
+ }
749
+ // Schema table: entry i is schema j of builder f, made on first reach.
750
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
751
+ return (__s[i] ??= __L.at(f, j));
752
+ }