aegis-api 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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +229 -2
  3. package/dist/client.d.ts +22 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +37 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/errors.d.ts +18 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +16 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/generated/schema.d.ts +3650 -0
  12. package/dist/generated/schema.d.ts.map +1 -0
  13. package/dist/generated/schema.js +6 -0
  14. package/dist/generated/schema.js.map +1 -0
  15. package/dist/http.d.ts +25 -0
  16. package/dist/http.d.ts.map +1 -0
  17. package/dist/http.js +108 -0
  18. package/dist/http.js.map +1 -0
  19. package/dist/index.d.ts +26 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +6 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/resources/base.d.ts +9 -0
  24. package/dist/resources/base.d.ts.map +1 -0
  25. package/dist/resources/base.js +11 -0
  26. package/dist/resources/base.js.map +1 -0
  27. package/dist/resources/bible.d.ts +47 -0
  28. package/dist/resources/bible.d.ts.map +1 -0
  29. package/dist/resources/bible.js +36 -0
  30. package/dist/resources/bible.js.map +1 -0
  31. package/dist/resources/binary.d.ts +18 -0
  32. package/dist/resources/binary.d.ts.map +1 -0
  33. package/dist/resources/binary.js +12 -0
  34. package/dist/resources/binary.js.map +1 -0
  35. package/dist/resources/fun.d.ts +18 -0
  36. package/dist/resources/fun.d.ts.map +1 -0
  37. package/dist/resources/fun.js +8 -0
  38. package/dist/resources/fun.js.map +1 -0
  39. package/dist/resources/general.d.ts +19 -0
  40. package/dist/resources/general.d.ts.map +1 -0
  41. package/dist/resources/general.js +8 -0
  42. package/dist/resources/general.js.map +1 -0
  43. package/dist/resources/holidays.d.ts +29 -0
  44. package/dist/resources/holidays.d.ts.map +1 -0
  45. package/dist/resources/holidays.js +12 -0
  46. package/dist/resources/holidays.js.map +1 -0
  47. package/dist/resources/index.d.ts +12 -0
  48. package/dist/resources/index.d.ts.map +1 -0
  49. package/dist/resources/index.js +12 -0
  50. package/dist/resources/index.js.map +1 -0
  51. package/dist/resources/jobs.d.ts +28 -0
  52. package/dist/resources/jobs.d.ts.map +1 -0
  53. package/dist/resources/jobs.js +12 -0
  54. package/dist/resources/jobs.js.map +1 -0
  55. package/dist/resources/minecraft.d.ts +27 -0
  56. package/dist/resources/minecraft.d.ts.map +1 -0
  57. package/dist/resources/minecraft.js +16 -0
  58. package/dist/resources/minecraft.js.map +1 -0
  59. package/dist/resources/music/index.d.ts +3 -0
  60. package/dist/resources/music/index.d.ts.map +1 -0
  61. package/dist/resources/music/index.js +3 -0
  62. package/dist/resources/music/index.js.map +1 -0
  63. package/dist/resources/music/music-events.d.ts +43 -0
  64. package/dist/resources/music/music-events.d.ts.map +1 -0
  65. package/dist/resources/music/music-events.js +8 -0
  66. package/dist/resources/music/music-events.js.map +1 -0
  67. package/dist/resources/music/music.d.ts +106 -0
  68. package/dist/resources/music/music.d.ts.map +1 -0
  69. package/dist/resources/music/music.js +106 -0
  70. package/dist/resources/music/music.js.map +1 -0
  71. package/dist/resources/roblox.d.ts +43 -0
  72. package/dist/resources/roblox.d.ts.map +1 -0
  73. package/dist/resources/roblox.js +12 -0
  74. package/dist/resources/roblox.js.map +1 -0
  75. package/dist/resources/translation.d.ts +26 -0
  76. package/dist/resources/translation.d.ts.map +1 -0
  77. package/dist/resources/translation.js +16 -0
  78. package/dist/resources/translation.js.map +1 -0
  79. package/dist/socket.d.ts +36 -0
  80. package/dist/socket.d.ts.map +1 -0
  81. package/dist/socket.js +139 -0
  82. package/dist/socket.js.map +1 -0
  83. package/dist/types.d.ts +65 -0
  84. package/dist/types.d.ts.map +1 -0
  85. package/dist/types.js +2 -0
  86. package/dist/types.js.map +1 -0
  87. package/package.json +51 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mubi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,230 @@
1
- # Temporary Holding Version
1
+ # aegis.js
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/AegisAPI/aegis.js/actions/workflows/ci.yml/badge.svg)](https://github.com/AegisAPI/aegis.js/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/aegis.js)](https://www.npmjs.com/package/aegis.js)
5
+
6
+ The official TypeScript client for the [Aegis](https://aegi.run) API: music, images, games and utilities for a Discord bot, so you do not have to build any of it yourself.
7
+
8
+ Every route, parameter, body and response is typed from the API's OpenAPI document. Successful responses arrive already unwrapped, and anything the API rejects arrives as an `AegisError`.
9
+
10
+ - Typed methods for all 38 `/v1` routes.
11
+ - Zero runtime dependencies.
12
+ - ESM only, ships type declarations.
13
+ - A typed WebSocket client for the music events.
14
+
15
+ ## Install
16
+
17
+ ```sh
18
+ npm install @aegis-api/aegis.js
19
+ ```
20
+
21
+ Needs a runtime with a global `fetch` (Node 18+). The event socket also needs a global `WebSocket` (Node 22+), unless you supply your own.
22
+
23
+ ## Quick start
24
+
25
+ ```ts
26
+ import { Aegis } from 'aegis-api'
27
+
28
+ const aegis = new Aegis({ apiKey: process.env.AEGIS_API_KEY })
29
+
30
+ // Play whatever the query finds, joining the caller's channel.
31
+ const { track, position } = await aegis.music.play(guildId, {
32
+ query: 'lofi hip hop',
33
+ channelId: voiceChannelId,
34
+ })
35
+
36
+ // Search first, then play exactly what was picked.
37
+ const found = await aegis.music.search({ query: 'rick astley', limit: 5 })
38
+ const chosen = found.results[0]!
39
+ await aegis.music.play(guildId, { track: { encoded: chosen.encoded } })
40
+
41
+ // Read the player: what is playing, where playback is, and the queue.
42
+ const state = await aegis.music.queue(guildId)
43
+ console.log(state.current?.title, state.volume, state.loop)
44
+ ```
45
+
46
+ ## API key
47
+
48
+ Create a key on [aegi.run](https://aegi.run) and pass it as `apiKey`. It is sent as `Authorization: Bearer <key>` on every request, and as a header on the event socket handshake.
49
+
50
+ `apiKey` and `baseUrl` cannot both be omitted. Constructing a client with neither throws right away instead of failing on the first call.
51
+
52
+ ## Options
53
+
54
+ Every option goes to the constructor.
55
+
56
+ | Option | Type | Default | Notes |
57
+ | -------------- | --------------------------------- | ---------------------- | ------------------------------------------------------ |
58
+ | `apiKey` | `string` | `undefined` | Sent as a bearer token. |
59
+ | `baseUrl` | `string` | `https://api.aegi.run` | Trailing slashes are trimmed. |
60
+ | `timeoutMs` | `number` | `30000` | Per request, via `AbortSignal.timeout`. |
61
+ | `fetch` | `typeof globalThis.fetch` | `globalThis.fetch` | Inject your own for tests, proxies or instrumentation. |
62
+ | `userAgent` | `string` | `aegis.js` | |
63
+ | `createSocket` | `(url, headers) => WebSocketLike` | global `WebSocket` | Inject a socket implementation. |
64
+
65
+ ## Resources
66
+
67
+ Resources hang off the client, grouped the way the API groups them.
68
+
69
+ - `aegis.music`: `search` `play` `pause` `resume` `skip` `stop` `queue` `clearQueue` `volume` `setVolume` `mute` `unmute` `seek` `shuffle` `restart` `loop` `setLoop` `removeFromQueue` `moveInQueue`
70
+ - `aegis.minecraft`: `info` `textures` `render`
71
+ - `aegis.jobs`: `get` `wait`
72
+ - `aegis.bible`: `languages` `types` `translations` `books` `chapter` `search` `verses` `data`
73
+ - `aegis.binary`: `encode` `decode`
74
+ - `aegis.translation`: `translate` `detect` `languages`
75
+ - `aegis.roblox`: `user` `game`
76
+ - `aegis.holidays`: `next` `year`
77
+ - `aegis.fun`: `roleplay`
78
+ - `aegis.general`: `status`
79
+
80
+ A few of them in full:
81
+
82
+ ```ts
83
+ await aegis.music.setVolume(guildId, { volume: 40, muted: true }) // 100 is default, 200 the highest
84
+ await aegis.music.seek(guildId, { position: 30_000 })
85
+ await aegis.music.setLoop(guildId, { mode: 'queue' }) // 'off' | 'track' | 'queue'
86
+ await aegis.music.moveInQueue(guildId, 3, { to: 0 })
87
+
88
+ await aegis.translation.translate({ text: 'hello', to: 'pt' })
89
+ await aegis.bible.verses('bbe', { refs: 'John 3:16' })
90
+ await aegis.holidays.next('BR')
91
+ await aegis.roblox.game(107778070777162)
92
+ await aegis.binary.encode({ text: 'hello' })
93
+ await aegis.fun.roleplay({ type: 'hug' })
94
+ ```
95
+
96
+ ### Jobs
97
+
98
+ Routes that queue work answer with a job instead of a result. Renders are the common case.
99
+
100
+ ```ts
101
+ const queued = await aegis.minecraft.render('Notch', {
102
+ render: 'wave',
103
+ scale: 4,
104
+ })
105
+
106
+ // Poll it...
107
+ const job = await aegis.jobs.get(queued.jobId)
108
+
109
+ // ...or hold the request open until it reaches a final state.
110
+ const finished = await aegis.jobs.wait(queued.jobId, { timeout: 60 })
111
+ if (finished.status === 'completed') console.log(finished.result)
112
+ ```
113
+
114
+ ## Events
115
+
116
+ `aegis.music` also exposes the event socket, typed per event name.
117
+
118
+ ```ts
119
+ const off = aegis.music.on('trackStarted', (event) => {
120
+ console.log(`${event.track.title} in ${event.guildId}`)
121
+ })
122
+
123
+ aegis.music.once('trackEnded', (event) => console.log(event.reason))
124
+
125
+ off() // the return value unsubscribes
126
+ ```
127
+
128
+ | Event | Payload |
129
+ | -------------- | --------------------------------------------------------- |
130
+ | `trackStarted` | `botId` `guildId` `track` |
131
+ | `trackEnded` | `botId` `guildId` `reason` |
132
+ | `queueEmptied` | `botId` `guildId` |
133
+ | `playerClosed` | `botId` `guildId` `reason` (`'idle'` or `'disconnected'`) |
134
+ | `botStopped` | `botId` `reason` |
135
+
136
+ `MUSIC_EVENTS` lists the same names as a runtime value.
137
+
138
+ How the socket behaves:
139
+
140
+ - It opens on the first listener and closes when the last one unsubscribes, so a bot that never listens never holds a connection.
141
+ - It reconnects 5 seconds after an unexpected close, as long as someone is still listening.
142
+ - `ready` and `ping` frames, and events nobody subscribed to, are ignored.
143
+ - A listener that throws is logged; the others still run.
144
+
145
+ `aegis.music.listening` reports whether the socket is open. `aegis.music.disconnect()` closes it for good.
146
+
147
+ ## Errors
148
+
149
+ Every non-2xx answer, and any request that never left the machine, throws an `AegisError`.
150
+
151
+ ```ts
152
+ import { AegisError } from 'aegis-api'
153
+
154
+ try {
155
+ await aegis.music.play(guildId, { query: 'lofi' })
156
+ } catch (error) {
157
+ if (error instanceof AegisError) {
158
+ error.status // 403
159
+ error.code // 'forbidden'
160
+ error.requestId // quote this when asking for help
161
+ error.body // the parsed error envelope
162
+ }
163
+ }
164
+ ```
165
+
166
+ ## Any route, by path
167
+
168
+ Routes without a named method are still reachable, and still typed.
169
+
170
+ ```ts
171
+ const status = await aegis.request('get', '/v1/status')
172
+ // ^? the exact shape the API documents
173
+
174
+ await aegis.request('post', '/v1/music/guilds/{guildId}/play', {
175
+ params: { guildId },
176
+ body: { query: 'lofi' },
177
+ })
178
+
179
+ // @ts-expect-error /v1/status takes no query
180
+ await aegis.request('get', '/v1/status', { query: { a: 1 } })
181
+
182
+ // @ts-expect-error /v1/status has no patch
183
+ await aegis.request('patch', '/v1/status')
184
+ ```
185
+
186
+ ## Types
187
+
188
+ The response shapes are re-exported under readable names, so you rarely need to reach into the schema namespace.
189
+
190
+ ```ts
191
+ import type {
192
+ Job,
193
+ PlayerState,
194
+ PlayResult,
195
+ Track,
196
+ components,
197
+ PathKey,
198
+ Paths,
199
+ RequestOptions,
200
+ Result,
201
+ } from 'aegis-api'
202
+ ```
203
+
204
+ `components` is the whole OpenAPI `components` namespace, so any schema in the document is reachable from there.
205
+
206
+ ## Development
207
+
208
+ ```sh
209
+ git clone https://github.com/AegisAPI/aegis.js
210
+ cd aegis.js
211
+ bun install
212
+
213
+ bun test # unit tests
214
+ bun run typecheck # tsc --noEmit
215
+ bun run build # emit dist/ with type declarations
216
+ bun run format # prettier
217
+ bun run schema:build # regenerate src/generated/schema.ts from the live spec
218
+ ```
219
+
220
+ `schema:build` rewrites the generated types from `https://api.aegi.run/openapi.json`, so route types follow the API rather than this repository. After regenerating, run typecheck: a path or field the API renamed shows up there first.
221
+
222
+ CI runs typecheck, tests, build and the format check on every push and pull request.
223
+
224
+ ## Contributing
225
+
226
+ Keep a pull request focused on one thing, and leave `bun run typecheck`, `bun test` and `bun run format:check` green.
227
+
228
+ ## License
229
+
230
+ [MIT](./LICENSE) © 2026 Mubi
@@ -0,0 +1,22 @@
1
+ import { Http, type HttpOptions } from './http.js';
2
+ import { BibleResource, BinaryResource, FunResource, GeneralResource, HolidaysResource, JobsResource, MinecraftResource, MusicResource, RobloxResource, TranslationResource } from './resources/index.js';
3
+ import type { HttpMethod, MethodOf, PathKey, RequestOptions, Result } from './types.js';
4
+ export interface AegisOptions extends HttpOptions {
5
+ }
6
+ export declare class Aegis {
7
+ readonly http: Http;
8
+ readonly music: MusicResource;
9
+ readonly minecraft: MinecraftResource;
10
+ readonly jobs: JobsResource;
11
+ readonly bible: BibleResource;
12
+ readonly binary: BinaryResource;
13
+ readonly translation: TranslationResource;
14
+ readonly roblox: RobloxResource;
15
+ readonly holidays: HolidaysResource;
16
+ readonly fun: FunResource;
17
+ readonly general: GeneralResource;
18
+ constructor(options?: AegisOptions);
19
+ /** Escape hatch for the routes without a named method yet. */
20
+ request<P extends PathKey, M extends HttpMethod>(method: M & MethodOf<NoInfer<P>>, path: P, options?: RequestOptions<P, M>): Promise<Result<P, M>>;
21
+ }
22
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAoB,MAAM,WAAW,CAAA;AACpE,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,OAAO,EACP,cAAc,EACd,MAAM,EACP,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,YAAa,SAAQ,WAAW;CAAG;AAEpD,qBAAa,KAAK;IAChB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAA;IACrC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAA;IACzC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACnC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;gBAErB,OAAO,GAAE,YAAiB;IAqBtC,8DAA8D;IAC9D,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,UAAU,EAC7C,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAChC,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAKzB"}
package/dist/client.js ADDED
@@ -0,0 +1,37 @@
1
+ import { AegisError } from './errors.js';
2
+ import { Http } from './http.js';
3
+ import { BibleResource, BinaryResource, FunResource, GeneralResource, HolidaysResource, JobsResource, MinecraftResource, MusicResource, RobloxResource, TranslationResource, } from './resources/index.js';
4
+ export class Aegis {
5
+ http;
6
+ music;
7
+ minecraft;
8
+ jobs;
9
+ bible;
10
+ binary;
11
+ translation;
12
+ roblox;
13
+ holidays;
14
+ fun;
15
+ general;
16
+ constructor(options = {}) {
17
+ if (options.baseUrl === undefined && options.apiKey === undefined) {
18
+ throw new AegisError('Aegis needs an apiKey, or at least an explicit baseUrl.', { status: 0, code: 'bad_request' });
19
+ }
20
+ this.http = new Http(options);
21
+ this.music = new MusicResource(this.http, options);
22
+ this.minecraft = new MinecraftResource(this.http);
23
+ this.jobs = new JobsResource(this.http);
24
+ this.bible = new BibleResource(this.http);
25
+ this.binary = new BinaryResource(this.http);
26
+ this.translation = new TranslationResource(this.http);
27
+ this.roblox = new RobloxResource(this.http);
28
+ this.holidays = new HolidaysResource(this.http);
29
+ this.fun = new FunResource(this.http);
30
+ this.general = new GeneralResource(this.http);
31
+ }
32
+ /** Escape hatch for the routes without a named method yet. */
33
+ request(method, path, options) {
34
+ return this.http.send(method, path, options);
35
+ }
36
+ }
37
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,IAAI,EAAsC,MAAM,WAAW,CAAA;AACpE,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAW7B,MAAM,OAAO,KAAK;IACP,IAAI,CAAM;IACV,KAAK,CAAe;IACpB,SAAS,CAAmB;IAC5B,IAAI,CAAc;IAClB,KAAK,CAAe;IACpB,MAAM,CAAgB;IACtB,WAAW,CAAqB;IAChC,MAAM,CAAgB;IACtB,QAAQ,CAAkB;IAC1B,GAAG,CAAa;IAChB,OAAO,CAAiB;IAEjC,YAAY,UAAwB,EAAE;QACpC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAClE,MAAM,IAAI,UAAU,CAClB,yDAAyD,EACzD,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CACnC,CAAA;QACH,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAClD,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3C,IAAI,CAAC,WAAW,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/C,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IAED,8DAA8D;IAC9D,OAAO,CACL,MAAgC,EAChC,IAAO,EACP,OAA8B;QAE9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,OAAsB,CAEzD,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ import type { components } from './generated/schema.js';
2
+ export type ApiErrorCode = components['schemas']['ErrorResponse']['error']['code'];
3
+ export type ErrorResponse = components['schemas']['ErrorResponse'];
4
+ export interface AegisErrorOptions {
5
+ status: number;
6
+ code: ApiErrorCode | string;
7
+ requestId?: string;
8
+ body?: unknown;
9
+ }
10
+ /** Thrown for any non-2xx answer, and for a request that never left the box. */
11
+ export declare class AegisError extends Error {
12
+ readonly status: number;
13
+ readonly code: ApiErrorCode | string;
14
+ readonly requestId: string | undefined;
15
+ readonly body: unknown;
16
+ constructor(message: string, options: AegisErrorOptions);
17
+ }
18
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,MAAM,YAAY,GACtB,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAA;AAElE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,YAAY,GAAG,MAAM,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,gFAAgF;AAChF,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAAA;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;CAQxD"}
package/dist/errors.js ADDED
@@ -0,0 +1,16 @@
1
+ /** Thrown for any non-2xx answer, and for a request that never left the box. */
2
+ export class AegisError extends Error {
3
+ status;
4
+ code;
5
+ requestId;
6
+ body;
7
+ constructor(message, options) {
8
+ super(message);
9
+ this.name = 'AegisError';
10
+ this.status = options.status;
11
+ this.code = options.code;
12
+ this.requestId = options.requestId;
13
+ this.body = options.body;
14
+ }
15
+ }
16
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAcA,gFAAgF;AAChF,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,MAAM,CAAQ;IACd,IAAI,CAAuB;IAC3B,SAAS,CAAoB;IAC7B,IAAI,CAAS;IAEtB,YAAY,OAAe,EAAE,OAA0B;QACrD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAC1B,CAAC;CACF"}