@distilled.cloud/mux 0.0.0 → 1.0.0-rc.22

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 +122 -4
  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 +82 -2
  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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,9 +1,127 @@
1
1
  # @distilled.cloud/mux
2
2
 
3
- 🐣 This package name has been claimed with [fledgling](https://github.com/dmno-dev/fledgling) for [https://github.com/alchemy-run/distilled](https://github.com/alchemy-run/distilled), and a real release will land here soon.
3
+ Effect-native [Mux](https://www.mux.com) SDK, generated from Mux's official
4
+ OpenAPI description, [`https://www.mux.com/api-spec.json`](https://www.mux.com/api-spec.json).
5
+ It covers every non-deprecated operation of the Mux API at `api.mux.com`:
6
+ 142 operations in four services.
4
7
 
5
- This is a placeholder — there is nothing to install yet.
8
+ | Import | Covers |
9
+ | --- | --- |
10
+ | `@distilled.cloud/mux/video` | assets, live streams, direct uploads, playback IDs and restrictions, DRM, transcription vocabularies, delivery usage |
11
+ | `@distilled.cloud/mux/data` | video views, errors, dimensions, metrics, subview metrics, engagement, monitoring, incidents, annotations, exports |
12
+ | `@distilled.cloud/mux/system` | whoami, signing keys, webhooks, usage exports |
13
+ | `@distilled.cloud/mux/robots` | AI jobs (summarize, chapters, captions, translation, moderation, …) and directives |
6
14
 
7
- ---
15
+ ## Installation
8
16
 
9
- Want to claim a name of your own? Run `npx fledgling add <name> --new --yes` — it reserves the name on npm and can set up token-less (OIDC trusted) publishing for when you are ready.
17
+ ```bash
18
+ npm install @distilled.cloud/mux effect
19
+ ```
20
+
21
+ ## Quick start
22
+
23
+ ```ts
24
+ import { Effect, Layer } from "effect";
25
+ import * as Stream from "effect/Stream";
26
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
27
+ import * as Mux from "@distilled.cloud/mux";
28
+ import * as System from "@distilled.cloud/mux/system";
29
+ import * as Video from "@distilled.cloud/mux/video";
30
+
31
+ const program = Effect.gen(function* () {
32
+ // Which environment the access token belongs to.
33
+ const { data: whoami } = yield* System.getWhoami({});
34
+
35
+ // One page...
36
+ const { data: page } = yield* Video.listAssets({ limit: 10 });
37
+
38
+ // ...or every asset, page by page.
39
+ const assets = yield* Video.listAssets
40
+ .items({ limit: 100 })
41
+ .pipe(Stream.take(25), Stream.runCollect);
42
+
43
+ // Typed failures: a deleted asset is a NotFound, a malformed ID a BadRequest.
44
+ const missing = yield* Video.getAsset({ ASSET_ID: "does-not-exist" }).pipe(
45
+ Effect.map(() => false),
46
+ Effect.catchTags({
47
+ NotFound: () => Effect.succeed(true),
48
+ BadRequest: () => Effect.succeed(true),
49
+ }),
50
+ );
51
+
52
+ return {
53
+ environment: whoami.environment_name,
54
+ firstPage: page.map((asset) => asset.id),
55
+ total: assets.length,
56
+ missing,
57
+ };
58
+ });
59
+
60
+ const MuxLive = Layer.mergeAll(FetchHttpClient.layer, Mux.CredentialsFromEnv);
61
+
62
+ program.pipe(Effect.provide(MuxLive), Effect.runPromise).then(console.log);
63
+ ```
64
+
65
+ ## Auth
66
+
67
+ `CredentialsFromEnv` reads the same variables as Mux's official SDKs:
68
+
69
+ - `MUX_TOKEN_ID` and `MUX_TOKEN_SECRET`: an
70
+ [Access Token](https://dashboard.mux.com/settings/access-tokens) sent as
71
+ HTTP Basic auth. Access tokens are scoped to one Mux environment.
72
+ - `MUX_AUTHORIZATION_TOKEN`: an OAuth token sent as `Authorization: Bearer`.
73
+ It wins when both are set.
74
+ - `MUX_BASE_URL` (optional): defaults to `https://api.mux.com`.
75
+
76
+ To pass credentials explicitly, use `Mux.fromAccessToken({ tokenId, tokenSecret })`
77
+ or `Mux.fromAuthorizationToken({ authorizationToken })`. Secrets are
78
+ `Redacted.Redacted<string>` values (`Redacted.make(...)` from `effect/Redacted`).
79
+
80
+ ## Responses
81
+
82
+ Responses keep Mux's wire shape: a resource arrives as `{ data: ... }`, a list
83
+ as `{ data: [...] }`. Member names stay snake_case, as in Mux's API reference.
84
+
85
+ Live-stream ingest credentials come back as `Redacted` values: `stream_key`,
86
+ `srt_passphrase`, a simulcast target's `stream_key` and SRT `url`, a direct
87
+ upload's signed `url`, a signing key's `private_key`, and a webhook's
88
+ `signing_secret`. Read them with
89
+ `Redacted.value`. Inputs take a plain string or a `Redacted`.
90
+
91
+ ## Pagination
92
+
93
+ Lists that take `page` are paginated: `.pages(input)` streams responses and
94
+ `.items(input)` streams the `data` entries. Like Mux's official SDKs, the
95
+ stream asks for `page`, `page + 1`, … and stops at the first empty page.
96
+
97
+ ## Errors
98
+
99
+ A failure maps by HTTP status onto `BadRequest`, `Unauthorized`, `Forbidden`,
100
+ `NotFound`, `Conflict`, `UnprocessableEntity`, `TooManyRequests` or a 5xx class.
101
+ Mux's `error.messages` become `message`, and the raw response (with
102
+ `error.type`, such as `invalid_parameters`) is on `body`. A malformed ID is a
103
+ `BadRequest`, not a `NotFound`: Mux answers `Failed to parse ID` with a 400.
104
+ `listUsageExports` also fails with `PreconditionFailed` while that period's
105
+ usage CSVs are still being generated. Any other status is an `UnknownMuxError`
106
+ whose `code` is Mux's `error.type`. For example, a route your plan does not
107
+ include answers 402 with code `payment_required`. With
108
+ `ResponseValidation.strict`, a response that does not match the schema is a
109
+ `MuxParseError`.
110
+
111
+ `listDrmConfigurations` returns `{ "data": {} }`, not an empty list, in an
112
+ environment without DRM. `.pages()` and `.items()` read that page as empty;
113
+ a direct call returns the body as sent (and `ResponseValidation.strict` fails
114
+ it), so check `Array.isArray(data)` before iterating it.
115
+
116
+ ## Not covered
117
+
118
+ - `image.mux.com` (thumbnails, animated GIFs, storyboards) and
119
+ `stream.mux.com` (HLS manifests, MP4 renditions, text tracks) are playback
120
+ URLs that answer images, video and VTT, not API calls. Build them from a
121
+ playback ID. Mux describes them in
122
+ [`full-combined-spec.json`](https://www.mux.com/full-combined-spec.json).
123
+ - Webhooks are events Mux sends to you. Their AsyncAPI description is
124
+ [`webhook-spec.json`](https://www.mux.com/webhook-spec.json).
125
+ - Deprecated operations are skipped, and each has a generated replacement:
126
+ Robots v0 is replaced by Robots, URL signing keys by System signing keys,
127
+ Real-Time by Monitoring, and Filters by Dimensions.
package/lib/.lazy.json ADDED
@@ -0,0 +1 @@
1
+ {"serviceDirs":["services"],"twins":[]}
@@ -0,0 +1,4 @@
1
+ import*as $0 from"./sdk.js";
2
+ import{api$lazyService as L}from"@distilled.cloud/core/_bundle/base";
3
+ const u=import.meta.url,N=[$0];
4
+ export const $L=(s,k,a,l,x)=>L(u,s,k,a===void 0?void 0:x?N.concat(x):N,a,l);
@@ -0,0 +1,2 @@
1
+ import{api$D as e,api$call as t,api$error as n,api$named as r,api$newError as i,api$op as a,api$opPaginated as o,category$withAlreadyExistsError as s,category$withAuthError as ee,category$withBadRequestError as te,category$withConflictError as ne,category$withParseError as re,config$Redacted as c,config$String as l,config$all as ie,config$option as u,config$withDefault as d,pagination$getItems as f,pagination$getPath as p,pagination$missingPaginationConfig as ae,retry$capped as oe,retry$jittered as se,retry$makeDefault as ce,retry$throttlingFactory as le,retry$throttlingOptions as m,retry$transientFactory as h,retry$transientOptions as g,schema_lite_typed$TaggedError as _,schema_lite_typed$Unknown as v,trait$Body as y,trait$FormDataFile as b,trait$Header as x,trait$Http as S,trait$HttpBody as C,trait$KeyDictionary as w,trait$Label as T,trait$Query as E,trait$ResponseCode as D,trait$UnionCases as O,trait$applyErrorMatchers as k,trait$bodySymbol as A,trait$errorMatchersSymbol as j,trait$formDataFileSymbol as M,trait$getErrorMatchers as N,trait$headerSymbol as P,trait$httpBodySymbol as F,trait$httpSymbol as I,trait$keyDictionarySymbol as L,trait$labelSymbol as R,trait$querySymbol as z,trait$responseCodeSymbol as B,trait$unionCasesSymbol as V}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as H,errors$BadGateway as U,errors$BadRequest as W,errors$ConfigError as G,errors$Conflict as ue,errors$DEFAULT_ERRORS as de,errors$Forbidden as fe,errors$GatewayTimeout as pe,errors$HTTP_STATUS_MAP as me,errors$InternalServerError as he,errors$Locked as ge,errors$NotFound as _e,errors$ServiceUnavailable as ve,errors$TooManyRequests as ye,errors$Unauthorized as K,errors$UnknownErrorFields as be,errors$UnprocessableEntity as xe,protocol_rest$RawResponse as Se,protocol_rest$RawResponseRoot as Ce,protocol_rest$SensitiveValue as we,protocol_rest$rawResponseRootSymbol as Te,protocol_rest$rawResponseSymbol as Ee,protocol_rest$restProtocol as De,protocol_rest$sensitiveValueSymbol as Oe,protocol_rest$unknownErrorProps as ke,schema_lite$Array as Ae,schema_lite$Boolean as je,schema_lite$NullOr as Me,schema_lite$Number as Ne,schema_lite$Record as Pe,schema_lite$String as Fe,schema_lite$Struct as Ie,schema_lite$TaggedError as Le,schema_lite$Union as Re,schema_lite$Unknown as ze,schema_lite$at as Be,schema_lite$optional as Ve,schema_lite$suspend as He}from"@distilled.cloud/core/_bundle/rest";import*as q from"effect/Context";import*as J from"effect/Effect";import*as Ue from"effect/encoding/Base64";import*as Y from"effect/Layer";import*as X from"effect/Option";import*as Z from"effect/Redacted";import*as We from"effect/Stream";const Q=`https://api.mux.com`;var Credentials=class extends (/*@__PURE__*/ q.Service()(`MuxCredentials`)){};const trimSlash=e=>e.replace(/\/+$/,``);const fromAccessToken=e=>Y.succeed(Credentials,J.succeed({auth:{_tag:`AccessToken`,tokenId:e.tokenId,tokenSecret:e.tokenSecret},apiBaseUrl:trimSlash(e.apiBaseUrl??`https://api.mux.com`)}));const fromAuthorizationToken=e=>Y.succeed(Credentials,J.succeed({auth:{_tag:`AuthorizationToken`,authorizationToken:e.authorizationToken},apiBaseUrl:trimSlash(e.apiBaseUrl??`https://api.mux.com`)}));const Ge=/*@__PURE__*/ ie({tokenId:/*@__PURE__*/ l(`MUX_TOKEN_ID`).pipe(u),tokenSecret:/*@__PURE__*/ c(`MUX_TOKEN_SECRET`).pipe(u),authorizationToken:/*@__PURE__*/ c(`MUX_AUTHORIZATION_TOKEN`).pipe(u),apiBaseUrl:/*@__PURE__*/ l(`MUX_BASE_URL`).pipe(/*@__PURE__*/ d(Q))});const $=`Mux credentials require MUX_TOKEN_ID and MUX_TOKEN_SECRET, or MUX_AUTHORIZATION_TOKEN`;const Ke=/*@__PURE__*/ Y.effect(Credentials,/*@__PURE__*/ J.map(/*@__PURE__*/ Ge.pipe(/*@__PURE__*/ J.mapError(e=>new G({message:`${$}: ${e.message}`})),/*@__PURE__*/ J.flatMap(({tokenId:e,tokenSecret:t,authorizationToken:n,apiBaseUrl:r})=>{const i=trimSlash(r);if(X.isSome(n))return J.succeed({auth:{_tag:`AuthorizationToken`,authorizationToken:n.value},apiBaseUrl:i});if(X.isSome(e)&&X.isSome(t))return J.succeed({auth:{_tag:`AccessToken`,tokenId:e.value,tokenSecret:t.value},apiBaseUrl:i});return J.fail(new G({message:$}))})),e=>J.succeed(e)));const authorizationHeader=e=>e._tag===`AuthorizationToken`?`Bearer ${Z.value(e.authorizationToken)}`:`Basic ${Ue.encode(`${e.tokenId}:${Z.value(e.tokenSecret)}`)}`;var UnknownMuxError=class extends (/*@__PURE__*/ _()(`UnknownMuxError`,be)){};var MuxParseError=class extends (/*@__PURE__*/ _()(`MuxParseError`,{body:v,cause:v}).pipe(re)){};const qe=H;const setPath=(e,[t,...n],r)=>{const i=typeof e===`object`&&e!==null?e:{};return{...i,[t]:n.length===0?r:setPath(i[t],n,r)}};const paginatePage=(e,t,n)=>{const r=n.inputToken;const i=n.items;if(!r||!i)return ae(`Mux page pagination requires inputToken and items`);const a=typeof t[r]===`number`?t[r]:1;return We.unfold({page:a,done:false},n=>J.gen(function*(){if(n.done)return void 0;const a=yield*e({...t,[r]:n.page});const o=p(a,i);const s=Array.isArray(o);return[s||o==null?a:setPath(a,i.split(`.`),[]),{page:n.page+1,done:!s||o.length===0}]}))};const isRecord=e=>typeof e===`object`&&e!==null;const str=e=>typeof e===`string`&&e!==``?e:void 0;const muxError=e=>{const t=isRecord(e)&&isRecord(e.error)?e.error:void 0;if(t===void 0)return void 0;const n=Array.isArray(t.messages)?t.messages.filter(e=>typeof e===`string`&&e!==``):[];const r=n.length>0?n.join(`; `):str(t.message);const i=str(t.type);return i===void 0&&r===void 0?void 0:{code:i,message:r}};const Je=/*@__PURE__*/ De({credentials:/*@__PURE__*/ J.flatten(Credentials),baseUrl:e=>e.apiBaseUrl,headers:e=>({Authorization:authorizationHeader(e.auth),Accept:`application/json`}),errorEnvelope:muxError,unknownError:e=>new UnknownMuxError(ke(e)),parseError:({body:e,cause:t})=>new MuxParseError({body:e,cause:t})});var Retry=class extends (/*@__PURE__*/ q.Service()(`MuxRetry`)){};const policy=e=>J.provide(Y.succeed(Retry,e));const Ye=/*@__PURE__*/ J.provide(/*@__PURE__*/ Y.succeed(Retry,{while:()=>false}));const Xe=ce;const Ze=se;const Qe=oe;const $e=m;const et=/*@__PURE__*/ policy(le);const tt=g;const nt=/*@__PURE__*/ policy(h);export{ne as Ca,Me as Fc,Ne as Gc,Pe as Hc,Fe as Jc,Ie as Kc,Le as Mc,Re as Oc,ze as Pc,Be as Rc,Ve as Wc,He as Xc,e as a,t as b,Credentials as credentials$Credentials,Ke as credentials$CredentialsFromEnv,Q as credentials$DEFAULT_API_BASE_URL,authorizationHeader as credentials$authorizationHeader,fromAccessToken as credentials$fromAccessToken,fromAuthorizationToken as credentials$fromAuthorizationToken,H as errors$API_ERRORS,U as errors$BadGateway,W as errors$BadRequest,G as errors$ConfigError,ue as errors$Conflict,de as errors$DEFAULT_ERRORS,fe as errors$Forbidden,pe as errors$GatewayTimeout,me as errors$HTTP_STATUS_MAP,he as errors$InternalServerError,ge as errors$Locked,MuxParseError as errors$MuxParseError,qe as errors$MuxServiceErrors,_e as errors$NotFound,ve as errors$ServiceUnavailable,ye as errors$TooManyRequests,K as errors$Unauthorized,UnknownMuxError as errors$UnknownMuxError,xe as errors$UnprocessableEntity,n as f,r as l,i as m,a as n,o,f as pagination$getItems,paginatePage as pagination$paginatePage,Je as protocol$MuxProtocol,Retry as retry$Retry,Qe as retry$capped,Ze as retry$jittered,Xe as retry$makeDefault,Ye as retry$none,policy as retry$policy,et as retry$throttling,$e as retry$throttlingOptions,nt as retry$transient,tt as retry$transientOptions,y as traits$Body,b as traits$FormDataFile,x as traits$Header,S as traits$Http,C as traits$HttpBody,w as traits$KeyDictionary,T as traits$Label,E as traits$Query,Se as traits$RawResponse,Ce as traits$RawResponseRoot,D as traits$ResponseCode,we as traits$SensitiveValue,O as traits$UnionCases,k as traits$applyErrorMatchers,A as traits$bodySymbol,j as traits$errorMatchersSymbol,M as traits$formDataFileSymbol,N as traits$getErrorMatchers,P as traits$headerSymbol,F as traits$httpBodySymbol,I as traits$httpSymbol,L as traits$keyDictionarySymbol,R as traits$labelSymbol,z as traits$querySymbol,Te as traits$rawResponseRootSymbol,Ee as traits$rawResponseSymbol,B as traits$responseCodeSymbol,Oe as traits$sensitiveValueSymbol,V as traits$unionCasesSymbol,Ae as wc,s as xa,je as xc,ee as ya,te as za};
2
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","names":["EffectConfig.option","Schema.Unknown","Category.withParseError","Retries.makeDefault","Retries.jittered","Retries.capped","Retries.throttlingOptions","Retries.throttlingFactory","Retries.transientOptions","Retries.transientFactory","D","call","error","named","newError","op","opPaginated","withAlreadyExistsError","withAuthError","withBadRequestError","withConflictError","withParseError","Redacted$3","String$2","all$1","option","withDefault","getItems","getPath","missingPaginationConfig","capped$1","jittered$1","makeDefault$1","throttlingFactory","throttlingOptions$1","transientFactory","transientOptions$1","TaggedError$1","Unknown$1","Body","FormDataFile","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","Locked","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnknownErrorFields","UnprocessableEntity","RawResponse","RawResponseRoot","SensitiveValue","rawResponseRootSymbol","rawResponseSymbol","restProtocol","sensitiveValueSymbol","unknownErrorProps","Array$1","Boolean","NullOr","Number","Record","String","Struct","TaggedError","Union","Unknown","at","optional","suspend","Context","Effect","Base64","Layer","Option","Redacted","Stream","DEFAULT_API_BASE_URL","url","config","envConfig","MISSING","CredentialsFromEnv","base","apiBaseUrl","authorizationToken","tokenId","tokenSecret","auth","MuxServiceErrors","head","rest","record","obj","value","inputToken","pagination","itemsPath","start","input","state","response","operation","items","isList","v","body","messages","m","message","code","MuxProtocol","creds","info","optionsOrFactory","none","makeDefault","jittered","capped","throttlingOptions","throttling","transientOptions","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/pagination.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"kmFA6BA,MAAa2G,EAAuB,sBAmBpC,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CAAC,gBAAgB,EAAA,AAAE,CAAC,EAEjG,MAAM,UAAa,GAAwBC,EAAI,QAAQ,OAAQ,EAAE,EAGjE,MAAa,gBAAmB,GAK9BL,EAAM,QACJ,YACAF,EAAO,QAAQ,CACb,KAAM,CAAE,KAAM,cAAe,Q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AAgB,CAAC,EAGlG,MAAaC,GAE+C,gBAAO,QACnD,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAOA,MAAaC,GAAuB/I,GAEpC,MAAagJ,GAAW/I,GACxB,MAAagJ,GAAS/I,GAGtB,MAAagJ,GAA6B/I,EAG1C,MAAagJ,GAE+C,qBAAO/I,EAAyB,EAG5F,MAAagJ,GAA4B/I,EAGzC,MAAagJ,GAE+C,qBAAO/I,CAAwB"}
@@ -0,0 +1,66 @@
1
+ import { ConfigError } from "@distilled.cloud/core/errors";
2
+ /**
3
+ * Mux credentials -- hand-written.
4
+ *
5
+ * The Mux API accepts the two schemes its OpenAPI document declares:
6
+ *
7
+ * - an Access Token: its ID and Secret sent as HTTP Basic auth
8
+ * (`accessToken`), created under Settings -> Access Tokens in the Mux
9
+ * dashboard, scoped to one environment;
10
+ * - an OAuth authorization token sent as `Authorization: Bearer`
11
+ * (`authorizationToken`).
12
+ *
13
+ * The environment variables are the ones Mux's official SDKs read
14
+ * (`MUX_TOKEN_ID`, `MUX_TOKEN_SECRET`, `MUX_AUTHORIZATION_TOKEN`,
15
+ * `MUX_BASE_URL`); like them, an authorization token wins when both are set.
16
+ *
17
+ * Following the core convention the `Credentials` service holds an *effect*
18
+ * resolving the current config, which the protocol runs per request on
19
+ * the calling fiber.
20
+ */
21
+ import * as Context from "effect/Context";
22
+ import * as Effect from "effect/Effect";
23
+ import * as Layer from "effect/Layer";
24
+ import * as Redacted from "effect/Redacted";
25
+ /** The Mux API origin (the document's only server). */
26
+ export declare const DEFAULT_API_BASE_URL = "https://api.mux.com";
27
+ export type Auth = {
28
+ readonly _tag: "AccessToken";
29
+ /** Access Token ID -- an identifier, sent as the Basic username. */
30
+ readonly tokenId: string;
31
+ readonly tokenSecret: Redacted.Redacted<string>;
32
+ } | {
33
+ readonly _tag: "AuthorizationToken";
34
+ readonly authorizationToken: Redacted.Redacted<string>;
35
+ };
36
+ export interface Config {
37
+ readonly auth: Auth;
38
+ readonly apiBaseUrl: string;
39
+ }
40
+ declare const Credentials_base: Context.ServiceClass<Credentials, "MuxCredentials", Effect.Effect<Config, never, never>>;
41
+ export declare class Credentials extends /*@__PURE__*/ Credentials_base {
42
+ }
43
+ /** Layer from an Access Token ID and Secret (HTTP Basic auth). */
44
+ export declare const fromAccessToken: (config: {
45
+ readonly tokenId: string;
46
+ readonly tokenSecret: Redacted.Redacted<string>;
47
+ readonly apiBaseUrl?: string;
48
+ }) => Layer.Layer<Credentials>;
49
+ /** Layer from an OAuth authorization token (`Authorization: Bearer`). */
50
+ export declare const fromAuthorizationToken: (config: {
51
+ readonly authorizationToken: Redacted.Redacted<string>;
52
+ readonly apiBaseUrl?: string;
53
+ }) => Layer.Layer<Credentials>;
54
+ /**
55
+ * Reads `MUX_TOKEN_ID` + `MUX_TOKEN_SECRET`, or `MUX_AUTHORIZATION_TOKEN`,
56
+ * and the optional `MUX_BASE_URL`, through Effect `Config` -- so it follows
57
+ * whatever `ConfigProvider` is installed (in a Worker, one built from `env`).
58
+ *
59
+ * Its configuration is read and checked once, when the layer is built: a
60
+ * problem there fails the layer with `ConfigError`.
61
+ */
62
+ export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError>;
63
+ /** The `Authorization` header value for a resolved config. */
64
+ export declare const authorizationHeader: (auth: Auth) => string;
65
+ export {};
66
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,uDAAuD;AACvD,eAAO,MAAM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C"}
@@ -0,0 +1 @@
1
+ export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL, credentials$authorizationHeader as authorizationHeader, credentials$fromAccessToken as fromAccessToken, credentials$fromAuthorizationToken as fromAuthorizationToken } from "./_bundle/sdk.js";
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Mux error types.
3
+ *
4
+ * Failures arrive as `{ "error": { "type": "not_found", "messages": [...] } }`
5
+ * and map by status onto the core classes re-exported here: `NotFound`,
6
+ * `BadRequest`, `Unauthorized`, `Forbidden`, `TooManyRequests` and the 5xx
7
+ * family, the last two retryable. Operations that declare a status get a
8
+ * generated class with the same `_tag` (and `PreconditionFailed` on
9
+ * `listUsageExports`), so `catchTag` works against either.
10
+ */
11
+ export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
12
+ export type { DefaultErrors } from "@distilled.cloud/core/errors";
13
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
14
+ declare const UnknownMuxError_base: Schema.TaggedErrorClass<"UnknownMuxError", {
15
+ status: import("effect/Schema").Number;
16
+ code: import("effect/Schema").optional<import("effect/Schema").String>;
17
+ message: import("effect/Schema").optional<import("effect/Schema").String>;
18
+ body: import("effect/Schema").Unknown;
19
+ }>;
20
+ /**
21
+ * A non-2xx, non-5xx status that neither the operation nor the core map
22
+ * covers. `code` is Mux's `error.type` (`invalid_parameters`,
23
+ * `precondition_failed`, ...) when the body carries one.
24
+ */
25
+ export declare class UnknownMuxError extends /*@__PURE__*/ UnknownMuxError_base {
26
+ }
27
+ declare const MuxParseError_base: Schema.TaggedErrorClass<"MuxParseError", {
28
+ readonly body: import("effect/Schema").Unknown;
29
+ readonly cause: import("effect/Schema").Unknown;
30
+ }> & (new (...args: any[]) => {
31
+ "@distilled.cloud/error/categories": {
32
+ ParseError: true;
33
+ };
34
+ });
35
+ /** A 2xx response that does not match the operation's output schema. */
36
+ export declare class MuxParseError extends /*@__PURE__*/ MuxParseError_base {
37
+ }
38
+ /**
39
+ * The errors declared on the Mux service: any operation can return them,
40
+ * and every generated operation lists them as its `serviceErrors`. Today that
41
+ * is each of core's status classes (401, 403, 404, 429, the 5xx ...).
42
+ */
43
+ export declare const MuxServiceErrors: readonly [typeof import("@distilled.cloud/core/errors").Unauthorized, typeof import("@distilled.cloud/core/errors").Forbidden, typeof import("@distilled.cloud/core/errors").NotFound, typeof import("@distilled.cloud/core/errors").BadRequest, typeof import("@distilled.cloud/core/errors").Conflict, typeof import("@distilled.cloud/core/errors").UnprocessableEntity, typeof import("@distilled.cloud/core/errors").TooManyRequests, typeof import("@distilled.cloud/core/errors").Locked, typeof import("@distilled.cloud/core/errors").InternalServerError, typeof import("@distilled.cloud/core/errors").BadGateway, typeof import("@distilled.cloud/core/errors").ServiceUnavailable, typeof import("@distilled.cloud/core/errors").GatewayTimeout];
44
+ export type MuxServiceError = InstanceType<(typeof MuxServiceErrors)[number]>;
45
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE;;;;GAIG;AACH,qBAAa,eACX,SAAQ,aAAa,CAAC,oBAGrB;CAAG;;;;;;;;;AAEN,wEAAwE;AACxE,qBAAa,aACX,SAAQ,aAAa,CAAC,kBAGU;CAAG;AAErC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,+tBAAa,CAAC;AAC3C,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
package/lib/errors.js ADDED
@@ -0,0 +1 @@
1
+ export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$Locked as Locked, errors$MuxParseError as MuxParseError, errors$MuxServiceErrors as MuxServiceErrors, errors$NotFound as NotFound, errors$ServiceUnavailable as ServiceUnavailable, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownMuxError as UnknownMuxError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
package/lib/index.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @distilled.cloud/mux -- Mux API SDK for Effect.
3
+ *
4
+ * `./services` is generated by `scripts/generate.ts` from the Smithy models
5
+ * that `scripts/convert.ts` converts from Mux's OpenAPI document
6
+ * (https://www.mux.com/api-spec.json), mirrored at
7
+ * `specs/spec-mirror-mux/specs/api-spec.json`. Everything else in this folder
8
+ * is hand-written.
9
+ *
10
+ * One module per API group, imported from its subpath: `video` (assets, live
11
+ * streams, uploads, playback), `data` (views, metrics, monitoring),
12
+ * `system` (signing keys, webhooks, usage) and `robots` (AI jobs).
13
+ *
14
+ * The image.mux.com and stream.mux.com playback URLs (thumbnails, HLS) are
15
+ * not API calls and are not modeled.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import * as Effect from "effect/Effect";
20
+ * import * as Layer from "effect/Layer";
21
+ * import * as FetchHttpClient from "effect/http/FetchHttpClient";
22
+ * import * as Mux from "@distilled.cloud/mux";
23
+ * import * as System from "@distilled.cloud/mux/system";
24
+ * import * as Video from "@distilled.cloud/mux/video";
25
+ *
26
+ * const program = Effect.gen(function* () {
27
+ * const { data: whoami } = yield* System.getWhoami({});
28
+ * const { data: assets } = yield* Video.listAssets({ limit: 5 });
29
+ * return { environment: whoami.environment_name, assets: assets.map((a) => a.id) };
30
+ * });
31
+ *
32
+ * program.pipe(
33
+ * Effect.provide(Layer.mergeAll(FetchHttpClient.layer, Mux.CredentialsFromEnv)),
34
+ * Effect.runPromise,
35
+ * );
36
+ * ```
37
+ */
38
+ export * from "./credentials.ts";
39
+ export * from "./errors.ts";
40
+ export * as T from "./traits.ts";
41
+ export { MuxProtocol, type MuxOpError, type MuxOpContext } from "./protocol.ts";
42
+ export { paginatePage } from "./pagination.ts";
43
+ export * as Retry from "./retry.ts";
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./credentials.js";
2
+ export * from "./errors.js";
3
+ export * as T from "./traits.js";
4
+ export { MuxProtocol } from "./protocol.js";
5
+ export { paginatePage } from "./pagination.js";
6
+ export * as Retry from "./retry.js";
@@ -0,0 +1,11 @@
1
+ import { type PaginationStrategy } from "@distilled.cloud/core/pagination";
2
+ export { getItems } from "@distilled.cloud/core/pagination";
3
+ /**
4
+ * Stream of pages: `page`, `page+1`, ... until a page has no items.
5
+ *
6
+ * A page whose items member is present but not an array has no items. Mux
7
+ * sends `{ "data": {} }` for an empty `listDrmConfigurations`; that page is
8
+ * emitted with `data: []` so `.items()` never yields the `{}` as an item.
9
+ */
10
+ export declare const paginatePage: PaginationStrategy;
11
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,kCAAkC,CAAC;AAe1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAQ5D;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,kBA4B1B,CAAC"}
@@ -0,0 +1 @@
1
+ export { pagination$getItems as getItems, pagination$paginatePage as paginatePage } from "./_bundle/sdk.js";
@@ -0,0 +1,19 @@
1
+ import type { ErrorOf } from "@distilled.cloud/core/protocol";
2
+ import type * as HttpClient from "effect/http/HttpClient";
3
+ import { Credentials } from "./credentials.ts";
4
+ import { MuxParseError, UnknownMuxError, type MuxServiceError } from "./errors.ts";
5
+ /**
6
+ * What every generated Mux operation fails with besides its own errors: the
7
+ * errors declared on the service, and the errors declared on the protocol.
8
+ * Nobody lists the protocol's: its type carries what its code fails with (a
9
+ * response that does not match its schema, a failed response nothing declares,
10
+ * core's REST errors, and what resolving the credentials fails with).
11
+ * Generated service files annotate operations with `API.OperationMethod<I, O,
12
+ * MuxOpError, MuxOpContext>` explicitly so the compiler never infers these
13
+ * back out of the schema generics.
14
+ */
15
+ export type MuxOpError = MuxServiceError | ErrorOf<typeof MuxProtocol>;
16
+ /** Context (requirements) shared by every generated Mux operation. */
17
+ export type MuxOpContext = Credentials | HttpClient.HttpClient;
18
+ export declare const MuxProtocol: import("@distilled.cloud/core/protocol").Protocol<MuxParseError | UnknownMuxError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
19
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAe9D,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAuB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvE,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAkB/D,eAAO,MAAM,WAAW,mKAWtB,CAAC"}
@@ -0,0 +1 @@
1
+ export { protocol$MuxProtocol as MuxProtocol } from "./_bundle/sdk.js";