@misofm/musicos 0.2.0 → 0.3.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.
Files changed (50) hide show
  1. package/README.md +90 -13
  2. package/dist/client.d.ts +27 -26
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +58 -51
  5. package/dist/client.js.map +1 -1
  6. package/dist/deployments.d.ts +9 -0
  7. package/dist/deployments.d.ts.map +1 -1
  8. package/dist/deployments.js +14 -0
  9. package/dist/deployments.js.map +1 -1
  10. package/dist/errors.d.ts +10 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +17 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/events.d.ts +6 -1
  15. package/dist/events.d.ts.map +1 -1
  16. package/dist/events.js +0 -5
  17. package/dist/events.js.map +1 -1
  18. package/dist/execute.d.ts +1 -48
  19. package/dist/execute.d.ts.map +1 -1
  20. package/dist/execute.js +5 -106
  21. package/dist/execute.js.map +1 -1
  22. package/dist/internal.d.ts +45 -6
  23. package/dist/internal.d.ts.map +1 -1
  24. package/dist/internal.js.map +1 -1
  25. package/dist/queries.d.ts +38 -62
  26. package/dist/queries.d.ts.map +1 -1
  27. package/dist/queries.js +240 -266
  28. package/dist/queries.js.map +1 -1
  29. package/dist/transactions.d.ts +2 -1
  30. package/dist/transactions.d.ts.map +1 -1
  31. package/dist/transactions.js.map +1 -1
  32. package/dist/types.d.ts +129 -79
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js +169 -1
  35. package/dist/types.js.map +1 -1
  36. package/dist/view.d.ts +3 -2
  37. package/dist/view.d.ts.map +1 -1
  38. package/dist/view.js +19 -6
  39. package/dist/view.js.map +1 -1
  40. package/package.json +8 -1
  41. package/src/client.ts +78 -98
  42. package/src/deployments.ts +15 -0
  43. package/src/errors.ts +30 -0
  44. package/src/events.ts +1 -1
  45. package/src/execute.ts +5 -133
  46. package/src/internal.ts +17 -23
  47. package/src/queries.ts +386 -424
  48. package/src/transactions.ts +2 -1
  49. package/src/types.ts +59 -48
  50. package/src/view.ts +23 -9
package/src/internal.ts CHANGED
@@ -6,20 +6,14 @@
6
6
  // Mappers from the generated BCS-parse output (snake_case, with @mysten/bcs
7
7
  // conventions: enums as `{ $kind, [Variant]: payload }`, tuples as arrays,
8
8
  // VecMap as `{ contents: [{ key, value }] }`, u64/u256 as strings, Address as
9
- // hex) into the public camelCase domain types in `./types`. These are the
10
- // single boundary between codegen output and the public API, so when the
11
- // generated shapes change, type errors surface here.
9
+ // hex) into the camelCase constructor-input shape of the public `Schema.Class`
10
+ // domain types in `./types`. These mappers return plain objects, not schema
11
+ // instances `queries.ts` runs the mapped output through `decodeBcs` (which
12
+ // calls `Schema.decodeUnknownEffect`) to validate and construct the actual
13
+ // class instance. This is the single boundary between codegen output and the
14
+ // public API, so when the generated shapes change, type errors surface here.
12
15
  //
13
16
 
14
- import type {
15
- BPS,
16
- Composition,
17
- Recording,
18
- Release as ReleaseType,
19
- Track,
20
- TrackState,
21
- } from "./types.ts";
22
-
23
17
  // === Mappers ===
24
18
 
25
19
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -28,7 +22,7 @@ type Parsed = any;
28
22
  // === Primitives ===
29
23
 
30
24
  /** `BPS` is a Move tuple struct `(u16)`, parsed as `[number]`. */
31
- export function mapBps(d: Parsed): BPS {
25
+ export function mapBps(d: Parsed): { value: number } {
32
26
  return { value: Number(Array.isArray(d) ? d[0] : d) };
33
27
  }
34
28
 
@@ -42,37 +36,37 @@ export function mapState(
42
36
 
43
37
  // === Objects ===
44
38
 
45
- export function mapComposition(id: string, d: Parsed): Composition {
39
+ export function mapComposition(id: string, d: Parsed) {
46
40
  return {
47
41
  id,
48
42
  state: mapState(d.state),
49
- title: d.title,
43
+ title: d.title as string,
50
44
  royaltyRate: mapBps(d.royalty_rate),
51
45
  };
52
46
  }
53
47
 
54
- export function mapRecording(id: string, d: Parsed): Recording {
48
+ export function mapRecording(id: string, d: Parsed) {
55
49
  return {
56
50
  id,
57
51
  state: mapState(d.state),
58
- compositionId: d.composition_id,
52
+ compositionId: d.composition_id as string,
59
53
  };
60
54
  }
61
55
 
62
- export function mapTrack(d: Parsed): Track {
56
+ export function mapTrack(d: Parsed) {
63
57
  return {
64
- state: (d.state?.$kind ?? "Unassigned") as TrackState,
65
- compositionId: d.composition_id,
66
- recordingId: d.recording_id,
58
+ state: (d.state?.$kind ?? "Unassigned") as "Unassigned" | "Assigned",
59
+ compositionId: d.composition_id as string,
60
+ recordingId: d.recording_id as string,
67
61
  splitBps: mapBps(d.split_bps),
68
62
  };
69
63
  }
70
64
 
71
- export function mapRelease(id: string, d: Parsed): ReleaseType {
65
+ export function mapRelease(id: string, d: Parsed) {
72
66
  return {
73
67
  id,
74
68
  state: mapState(d.state),
75
- title: d.title,
69
+ title: d.title as string,
76
70
  tracks: (d.tracks ?? []).map(mapTrack),
77
71
  };
78
72
  }