@misofm/api-client 0.4.0 → 0.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misofm/api-client",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Typed client and response contract for the Miso API read layer. The one definition of what a Miso read returns.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -95,6 +95,17 @@ describe("URL construction", () => {
95
95
  expect(calls[0]).toBe(`${BASE}/read/v1/pressings/0xp/preview`);
96
96
  });
97
97
 
98
+ test("passes the Listing currency to the pressing sale route", async () => {
99
+ const { fetch, calls } = stubFetch({ status: 404 });
100
+ await createMisoApiClient({ baseUrl: BASE, fetch }).getPressingSale(
101
+ "0xp",
102
+ "0x2::sui::SUI",
103
+ );
104
+ expect(calls[0]).toBe(
105
+ `${BASE}/read/v1/pressings/0xp/sale?currencyType=0x2%3A%3Asui%3A%3ASUI`,
106
+ );
107
+ });
108
+
98
109
  test("a custom prefix is honored (self-hosted / direct-to-service)", async () => {
99
110
  const { fetch, calls } = stubFetch({ body: balance });
100
111
  await createMisoApiClient({
package/src/client.ts CHANGED
@@ -30,6 +30,7 @@ import type {
30
30
  Ownership,
31
31
  PartySummary,
32
32
  PressingDetail,
33
+ SaleDetail,
33
34
  PurchaseReceipt,
34
35
  RecordAlbum,
35
36
  ReleaseDetail,
@@ -179,6 +180,19 @@ export function createMisoApiClient(options: MisoApiClientOptions) {
179
180
  { nullOn404: true },
180
181
  ),
181
182
 
183
+ /** One Pressing and its currency-specific Listing. */
184
+ getPressingSale: (
185
+ pressingId: string,
186
+ currencyType: string,
187
+ opts: { include?: readonly "trackCredits"[] } = {},
188
+ ): Promise<SaleDetail | null> =>
189
+ request(
190
+ s.saleDetailSchema,
191
+ `/pressings/${pressingId}/sale`,
192
+ { currencyType, include: opts.include?.join(",") },
193
+ { nullOn404: true },
194
+ ),
195
+
182
196
  /** A release with its cover, credits, and resolved tracklist. */
183
197
  getRelease: (
184
198
  releaseId: string,
@@ -313,6 +327,7 @@ export function cacheBuster(nowMs: number = Date.now()): string {
313
327
  export const READ_CACHE_CLASS = {
314
328
  getDiscover: "sale",
315
329
  getPressing: "sale",
330
+ getPressingSale: "sale",
316
331
  getPressingPreview: "sale",
317
332
  getRecordAlbum: "immutable",
318
333
  getReceipt: "immutable",
package/src/schemas.ts CHANGED
@@ -171,6 +171,16 @@ export const pressingDetailWireSchema = z.object({
171
171
  release: releaseDetailWireSchema,
172
172
  });
173
173
 
174
+ export const saleDetailSchema = z.object({
175
+ sale: saleViewSchema,
176
+ release: releaseDetailSchema,
177
+ });
178
+
179
+ export const saleDetailWireSchema = z.object({
180
+ sale: saleViewSchema,
181
+ release: releaseDetailWireSchema,
182
+ });
183
+
174
184
  export const discoverItemSchema = z.object({
175
185
  sale: saleViewSchema,
176
186
  releaseId: suiIdSchema,
@@ -367,6 +377,7 @@ export const recordSaleSchema = z.object({
367
377
  number: u64Schema,
368
378
  paid: u64Schema,
369
379
  price: priceSchema,
380
+ currencyType: z.string(),
370
381
  buyer: suiIdSchema,
371
382
  });
372
383
 
package/src/types.ts CHANGED
@@ -22,6 +22,7 @@ export type PressingView = z.infer<typeof s.pressingViewSchema>;
22
22
  export type ListingView = z.infer<typeof s.listingViewSchema>;
23
23
  export type SaleView = z.infer<typeof s.saleViewSchema>;
24
24
  export type PressingDetail = z.infer<typeof s.pressingDetailSchema>;
25
+ export type SaleDetail = z.infer<typeof s.saleDetailSchema>;
25
26
  export type DiscoverItem = z.infer<typeof s.discoverItemSchema>;
26
27
  export type DiscoverShelf = z.infer<typeof s.discoverShelfSchema>;
27
28
  export type RecordAlbum = z.infer<typeof s.recordAlbumSchema>;