@misofm/api-client 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +171 -5
- package/dist/cache.d.ts +71 -0
- package/dist/cache.js +119 -0
- package/dist/client.d.ts +150 -0
- package/dist/client.js +265 -0
- package/dist/index.d.ts +6 -0
- package/{src/index.ts → dist/index.js} +3 -9
- package/dist/schemas.d.ts +1316 -0
- package/dist/schemas.js +353 -0
- package/{src/types.ts → dist/types.d.ts} +1 -13
- package/dist/types.js +6 -0
- package/package.json +26 -12
- package/src/cache.test.ts +0 -90
- package/src/cache.ts +0 -91
- package/src/client.test.ts +0 -284
- package/src/client.ts +0 -325
- package/src/schemas.ts +0 -384
package/src/schemas.ts
DELETED
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Miso Labs, Inc.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
//
|
|
4
|
-
// The response contract for every Miso read. This file is the SOURCE OF TRUTH:
|
|
5
|
-
//
|
|
6
|
-
// · @misofm/api-client infers its types from it
|
|
7
|
-
// · miso-read-service generates its OpenAPI document from it
|
|
8
|
-
// · a contract test in that service parses every handler's real output through
|
|
9
|
-
// it, so a change in @misofm/sdk/read that these schemas don't describe fails CI
|
|
10
|
-
// rather than reaching a client
|
|
11
|
-
//
|
|
12
|
-
// Schemas, not hand-written interfaces, precisely so that third clause is
|
|
13
|
-
// possible. The CLI and any future client read the same OpenAPI.
|
|
14
|
-
//
|
|
15
|
-
// SCALARS: every u64/u128 is a DECIMAL STRING (`u64Schema`), never a number.
|
|
16
|
-
// Prices, supply counts, and balances routinely exceed 2^53, and JSON has no
|
|
17
|
-
// integer type that holds them. Millisecond timestamps stay numbers — they are
|
|
18
|
-
// inside Number.MAX_SAFE_INTEGER and callers want to pass them to `new Date()`.
|
|
19
|
-
|
|
20
|
-
import { z } from "zod";
|
|
21
|
-
|
|
22
|
-
/** A u64/u128 in base units, as a decimal string. See the file header. */
|
|
23
|
-
export const u64Schema = z
|
|
24
|
-
.string()
|
|
25
|
-
.regex(/^\d+$/, "expected a decimal integer string");
|
|
26
|
-
|
|
27
|
-
/** A 0x-prefixed 32-byte Sui object id or address, in canonical form. */
|
|
28
|
-
export const suiIdSchema = z
|
|
29
|
-
.string()
|
|
30
|
-
.regex(/^0x[0-9a-fA-F]{1,64}$/, "expected a Sui object id");
|
|
31
|
-
|
|
32
|
-
// ── Shared ───────────────────────────────────────────────────────────────────
|
|
33
|
-
|
|
34
|
-
export const workStateSchema = z.union([
|
|
35
|
-
z.object({ type: z.literal("Initialized") }),
|
|
36
|
-
z.object({ type: z.literal("Published"), timestampMs: z.number().int() }),
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
export const coverImageSchema = z.object({
|
|
40
|
-
kind: z.enum(["blob", "quiltPatch"]),
|
|
41
|
-
/** Aggregator URL — the only field a renderer needs. */
|
|
42
|
-
url: z.string().url(),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export const coverSchema = z.object({
|
|
46
|
-
still: coverImageSchema,
|
|
47
|
-
animated: coverImageSchema.nullable(),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export const creditSchema = z.object({
|
|
51
|
-
partyId: suiIdSchema,
|
|
52
|
-
displayName: z.string(),
|
|
53
|
-
roles: z.array(z.string()),
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const trackViewSchema = z.object({
|
|
57
|
-
/** Display number — "1", or "1.2" (disc.track) on a multi-disc set. */
|
|
58
|
-
no: z.string(),
|
|
59
|
-
title: z.string(),
|
|
60
|
-
recordingId: suiIdSchema,
|
|
61
|
-
/** The composition underlying this track's recording. */
|
|
62
|
-
compositionId: suiIdSchema,
|
|
63
|
-
/** This track's share of the release's revenue, in basis points. */
|
|
64
|
-
splitBps: z.number().int().min(0).max(10_000),
|
|
65
|
-
disc: z.number().int().min(1),
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
/** A recording's work-role credits and recording billing positions. */
|
|
69
|
-
export const recordingCreditsSchema = z.object({
|
|
70
|
-
credits: z.array(creditSchema),
|
|
71
|
-
primaryArtistIds: z.array(suiIdSchema),
|
|
72
|
-
featuredArtistIds: z.array(suiIdSchema),
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
/** Per-track credits for a release. Composition writing and recording
|
|
76
|
-
* performance/production credits remain separate. */
|
|
77
|
-
const completeTrackCreditsSchema = z.object({
|
|
78
|
-
compositionCredits: z.array(creditSchema),
|
|
79
|
-
recordingCredits: recordingCreditsSchema,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
/** The HTTP wire accepts the complete shape and the deployed recording-only shape. */
|
|
83
|
-
export const trackCreditsWireSchema = z.union([
|
|
84
|
-
completeTrackCreditsSchema,
|
|
85
|
-
recordingCreditsSchema,
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
/** Clients always receive the complete shape, including during the rollout. */
|
|
89
|
-
export const trackCreditsSchema = trackCreditsWireSchema.transform((credits) =>
|
|
90
|
-
"recordingCredits" in credits
|
|
91
|
-
? credits
|
|
92
|
-
: { compositionCredits: [], recordingCredits: credits },
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
// ── Catalog ──────────────────────────────────────────────────────────────────
|
|
96
|
-
|
|
97
|
-
const releaseDetailBaseSchema = z.object({
|
|
98
|
-
id: suiIdSchema,
|
|
99
|
-
title: z.string(),
|
|
100
|
-
subtitle: z.string().nullable(),
|
|
101
|
-
/** Self-declared `release_kind`, or null when the extension is absent. */
|
|
102
|
-
kind: z.string().nullable(),
|
|
103
|
-
state: workStateSchema,
|
|
104
|
-
publishedAtMs: z.number().int().nullable(),
|
|
105
|
-
cover: coverSchema.nullable(),
|
|
106
|
-
credits: z.array(creditSchema),
|
|
107
|
-
/** The release's primary artists in chain order — its artist line. */
|
|
108
|
-
primaryArtists: z.array(z.string()),
|
|
109
|
-
discCount: z.number().int().min(0),
|
|
110
|
-
tracks: z.array(trackViewSchema),
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
/** Transform-free wire form used by OpenAPI generation. */
|
|
114
|
-
export const releaseDetailWireSchema = releaseDetailBaseSchema.extend({
|
|
115
|
-
trackCredits: z.record(suiIdSchema, trackCreditsWireSchema).optional(),
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
export const releaseDetailSchema = releaseDetailBaseSchema.extend({
|
|
119
|
-
/** Present only when requested via `include`. */
|
|
120
|
-
trackCredits: z.record(suiIdSchema, trackCreditsSchema).optional(),
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
export const priceSchema = z.object({
|
|
124
|
-
/** `fixed` — pay exactly this. `floor` — pay at least this. */
|
|
125
|
-
kind: z.enum(["fixed", "floor"]),
|
|
126
|
-
amount: u64Schema,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
export const currencySchema = z.object({
|
|
130
|
-
type: z.string().nullable(),
|
|
131
|
-
symbol: z.string(),
|
|
132
|
-
decimals: z.number().int().min(0).max(18),
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
export const pressingStateSchema = z.union([
|
|
136
|
-
z.object({
|
|
137
|
-
kind: z.literal("scheduled"),
|
|
138
|
-
startTimestampMs: z.number().int(),
|
|
139
|
-
}),
|
|
140
|
-
z.object({ kind: z.literal("active") }),
|
|
141
|
-
z.object({ kind: z.literal("paused") }),
|
|
142
|
-
]);
|
|
143
|
-
|
|
144
|
-
export const pressingViewSchema = z.object({
|
|
145
|
-
id: suiIdSchema,
|
|
146
|
-
releaseId: suiIdSchema,
|
|
147
|
-
state: pressingStateSchema,
|
|
148
|
-
/** Records pressed so far. The permanent run is intentionally uncapped. */
|
|
149
|
-
supply: u64Schema,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
export const listingViewSchema = z.object({
|
|
153
|
-
id: suiIdSchema,
|
|
154
|
-
pressingId: suiIdSchema,
|
|
155
|
-
releaseId: suiIdSchema,
|
|
156
|
-
price: priceSchema,
|
|
157
|
-
currency: currencySchema,
|
|
158
|
-
state: z.enum(["enabled", "disabled"]),
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
export const pressingDetailSchema = z.object({
|
|
162
|
-
pressing: pressingViewSchema,
|
|
163
|
-
release: releaseDetailSchema,
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
export const pressingDetailWireSchema = z.object({
|
|
167
|
-
pressing: pressingViewSchema,
|
|
168
|
-
release: releaseDetailWireSchema,
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
export const recordAlbumSchema = z.object({
|
|
172
|
-
recordId: suiIdSchema,
|
|
173
|
-
releaseId: suiIdSchema.nullable(),
|
|
174
|
-
/** Present only when requested via `include`. */
|
|
175
|
-
release: releaseDetailSchema.nullable().optional(),
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
export const recordAlbumWireSchema = z.object({
|
|
179
|
-
recordId: suiIdSchema,
|
|
180
|
-
releaseId: suiIdSchema.nullable(),
|
|
181
|
-
release: releaseDetailWireSchema.nullable().optional(),
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// ── Artist ───────────────────────────────────────────────────────────────────
|
|
185
|
-
|
|
186
|
-
export const partyMemberSchema = z.object({
|
|
187
|
-
id: suiIdSchema,
|
|
188
|
-
name: z.string(),
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Every external platform the party link extensions know how to build a URL for,
|
|
193
|
-
* spanning social, music, and professional payloads. Enumerated rather than left
|
|
194
|
-
* as `string` so a renderer's icon/label switch is exhaustive at compile time —
|
|
195
|
-
* adding a platform on-chain should break the UI that has no icon for it.
|
|
196
|
-
*/
|
|
197
|
-
export const platformKeySchema = z.enum([
|
|
198
|
-
// Social (party_social)
|
|
199
|
-
"x",
|
|
200
|
-
"instagram",
|
|
201
|
-
"threads",
|
|
202
|
-
"tiktok",
|
|
203
|
-
"youtube",
|
|
204
|
-
"discord",
|
|
205
|
-
"telegram",
|
|
206
|
-
"reddit",
|
|
207
|
-
"twitch",
|
|
208
|
-
"facebook",
|
|
209
|
-
// Music (party_music)
|
|
210
|
-
"spotify",
|
|
211
|
-
"bandcamp",
|
|
212
|
-
"soundcloud",
|
|
213
|
-
"appleMusic",
|
|
214
|
-
"deezer",
|
|
215
|
-
"tidal",
|
|
216
|
-
"amazonMusic",
|
|
217
|
-
"audiomack",
|
|
218
|
-
// Professional / industry (party_pro_link)
|
|
219
|
-
"website",
|
|
220
|
-
"bookingPage",
|
|
221
|
-
"managementPage",
|
|
222
|
-
"publisherPage",
|
|
223
|
-
"labelPage",
|
|
224
|
-
"epk",
|
|
225
|
-
"patreon",
|
|
226
|
-
"substack",
|
|
227
|
-
"kofi",
|
|
228
|
-
]);
|
|
229
|
-
|
|
230
|
-
export const partyLinkSchema = z.object({
|
|
231
|
-
platform: platformKeySchema,
|
|
232
|
-
/** The platform-native identifier stored on-chain (handle / id / subdomain / URL). */
|
|
233
|
-
value: z.string(),
|
|
234
|
-
/** The public profile URL, rebuilt client-side from `value`. */
|
|
235
|
-
url: z.string(),
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
export const partyCtaSchema = z.object({ label: z.string(), url: z.string() });
|
|
239
|
-
|
|
240
|
-
export const artistProfileSchema = z.object({
|
|
241
|
-
id: suiIdSchema,
|
|
242
|
-
kind: z.enum(["individual", "group"]),
|
|
243
|
-
name: z.string(),
|
|
244
|
-
createdAtMs: z.number().int(),
|
|
245
|
-
bioShort: z.string().nullable(),
|
|
246
|
-
bioLong: z.string().nullable(),
|
|
247
|
-
country: z.string().nullable(),
|
|
248
|
-
languages: z.array(z.string()),
|
|
249
|
-
/** Display names, already humanized from the on-chain HIP_HOP form. */
|
|
250
|
-
genres: z.array(z.string()),
|
|
251
|
-
links: z.array(partyLinkSchema),
|
|
252
|
-
ctas: z.array(partyCtaSchema),
|
|
253
|
-
members: z.array(partyMemberSchema),
|
|
254
|
-
/** Present only when requested via `include` — the owner-editor fields. */
|
|
255
|
-
roles: z.array(z.string()).optional(),
|
|
256
|
-
tags: z.array(z.string()).optional(),
|
|
257
|
-
avatarUrl: z.string().url(),
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
export const partySummarySchema = z.object({
|
|
261
|
-
id: suiIdSchema,
|
|
262
|
-
name: z.string(),
|
|
263
|
-
kind: z.enum(["individual", "group"]),
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
export const partySummariesSchema = z.array(partySummarySchema);
|
|
267
|
-
|
|
268
|
-
// ── Wallet-scoped ────────────────────────────────────────────────────────────
|
|
269
|
-
|
|
270
|
-
export const ownedRecordSchema = z.object({
|
|
271
|
-
id: suiIdSchema,
|
|
272
|
-
type: z.string(),
|
|
273
|
-
releaseId: suiIdSchema.nullable(),
|
|
274
|
-
/** This copy's number in its run. */
|
|
275
|
-
number: z.number().int().nullable(),
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
export const ownedRecordsSchema = z.array(ownedRecordSchema);
|
|
279
|
-
|
|
280
|
-
export const ownedPartySchema = z.object({
|
|
281
|
-
partyId: suiIdSchema,
|
|
282
|
-
capId: suiIdSchema,
|
|
283
|
-
name: z.string(),
|
|
284
|
-
kind: z.enum(["individual", "group"]),
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
export const ownedPartiesSchema = z.array(ownedPartySchema);
|
|
288
|
-
|
|
289
|
-
/** A group invitation awaiting action by a party the wallet administers. */
|
|
290
|
-
export const pendingMembershipSchema = z.object({
|
|
291
|
-
memberPartyId: suiIdSchema,
|
|
292
|
-
memberCapId: suiIdSchema,
|
|
293
|
-
groupId: suiIdSchema,
|
|
294
|
-
groupName: z.string(),
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
export const pendingMembershipsSchema = z.array(pendingMembershipSchema);
|
|
298
|
-
|
|
299
|
-
export const workKindSchema = z.enum(["composition", "recording", "release"]);
|
|
300
|
-
|
|
301
|
-
export const ownedWorkSchema = z.object({
|
|
302
|
-
/** The ADMIN CAP object id — the catalog's routing key. */
|
|
303
|
-
capId: suiIdSchema,
|
|
304
|
-
kind: workKindSchema,
|
|
305
|
-
workId: suiIdSchema,
|
|
306
|
-
title: z.string(),
|
|
307
|
-
state: z.string(),
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
export const ownedWorksSchema = z.array(ownedWorkSchema);
|
|
311
|
-
|
|
312
|
-
export const workDetailSchema = ownedWorkSchema.extend({
|
|
313
|
-
subtitle: z.string().optional(),
|
|
314
|
-
royaltyRateBps: z.number().int().min(0).max(10_000).optional(),
|
|
315
|
-
shareType: z.string().optional(),
|
|
316
|
-
discCount: z.number().int().min(0).optional(),
|
|
317
|
-
trackCount: z.number().int().min(0).optional(),
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
export const balanceSchema = z.object({
|
|
321
|
-
address: suiIdSchema,
|
|
322
|
-
coinType: z.string(),
|
|
323
|
-
/** Base units. Totals coin objects AND the address balance. */
|
|
324
|
-
balance: u64Schema,
|
|
325
|
-
decimals: z.number().int().min(0).max(18),
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
export const ownershipSchema = z.object({
|
|
329
|
-
address: suiIdSchema,
|
|
330
|
-
objectId: suiIdSchema,
|
|
331
|
-
isOwner: z.boolean(),
|
|
332
|
-
/** Party checks only — the derived PartyAdminCap id owner-gated writes need. */
|
|
333
|
-
capId: suiIdSchema.optional(),
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
// ── Receipts ─────────────────────────────────────────────────────────────────
|
|
337
|
-
|
|
338
|
-
export const recordSaleSchema = z.object({
|
|
339
|
-
listingId: suiIdSchema,
|
|
340
|
-
pressingId: suiIdSchema,
|
|
341
|
-
releaseId: suiIdSchema,
|
|
342
|
-
recordId: suiIdSchema,
|
|
343
|
-
number: u64Schema,
|
|
344
|
-
paid: u64Schema,
|
|
345
|
-
price: priceSchema,
|
|
346
|
-
currencyType: z.string(),
|
|
347
|
-
buyer: suiIdSchema,
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
export const trackRoyaltySchema = z.object({
|
|
351
|
-
no: z.string(),
|
|
352
|
-
title: z.string(),
|
|
353
|
-
recordingId: suiIdSchema,
|
|
354
|
-
splitBps: z.number().int().min(0).max(10_000),
|
|
355
|
-
amount: u64Schema,
|
|
356
|
-
/** Both null when the composition's royalty rate could not be resolved. */
|
|
357
|
-
composition: u64Schema.nullable(),
|
|
358
|
-
recording: u64Schema.nullable(),
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
export const purchaseReceiptSchema = z.object({
|
|
362
|
-
sale: recordSaleSchema,
|
|
363
|
-
detail: pressingDetailSchema,
|
|
364
|
-
/** The Listing price — differs from `sale.paid` on a floor-price overpay. */
|
|
365
|
-
price: u64Schema,
|
|
366
|
-
tracks: z.array(trackRoyaltySchema),
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
export const purchaseReceiptWireSchema = z.object({
|
|
370
|
-
sale: recordSaleSchema,
|
|
371
|
-
detail: pressingDetailWireSchema,
|
|
372
|
-
price: u64Schema,
|
|
373
|
-
tracks: z.array(trackRoyaltySchema),
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
// ── Errors ───────────────────────────────────────────────────────────────────
|
|
377
|
-
|
|
378
|
-
/** The envelope every non-2xx carries, matching miso-api's `apiError`. */
|
|
379
|
-
export const apiErrorSchema = z.object({
|
|
380
|
-
error: z.object({
|
|
381
|
-
code: z.string(),
|
|
382
|
-
message: z.string(),
|
|
383
|
-
}),
|
|
384
|
-
});
|