@misofm/sdk 0.4.0 → 0.5.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.
- package/dist/catalog.d.ts +4 -17
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +46 -58
- package/dist/catalog.js.map +1 -1
- package/dist/cover.d.ts +10 -0
- package/dist/cover.d.ts.map +1 -1
- package/dist/cover.js +66 -19
- package/dist/cover.js.map +1 -1
- package/dist/credits.d.ts +10 -0
- package/dist/credits.d.ts.map +1 -1
- package/dist/credits.js +149 -39
- package/dist/credits.js.map +1 -1
- package/dist/drop.d.ts +7 -0
- package/dist/drop.d.ts.map +1 -1
- package/dist/drop.js +84 -34
- package/dist/drop.js.map +1 -1
- package/dist/pressing.d.ts.map +1 -1
- package/dist/pressing.js +59 -16
- package/dist/pressing.js.map +1 -1
- package/dist/read/artist.d.ts +1 -6
- package/dist/read/artist.d.ts.map +1 -1
- package/dist/read/artist.js +39 -22
- package/dist/read/artist.js.map +1 -1
- package/dist/read/catalog.d.ts +24 -3
- package/dist/read/catalog.d.ts.map +1 -1
- package/dist/read/catalog.js +190 -89
- package/dist/read/catalog.js.map +1 -1
- package/dist/read/index.d.ts +5 -3
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +2 -2
- package/dist/read/index.js.map +1 -1
- package/dist/read/types.d.ts +12 -1
- package/dist/read/types.d.ts.map +1 -1
- package/dist/read/works.d.ts +3 -2
- package/dist/read/works.d.ts.map +1 -1
- package/dist/read/works.js +158 -48
- package/dist/read/works.js.map +1 -1
- package/package.json +1 -1
- package/src/catalog.ts +71 -77
- package/src/cover.ts +107 -26
- package/src/credits.ts +353 -89
- package/src/drop.ts +150 -40
- package/src/pressing.ts +146 -36
- package/src/read/artist.ts +73 -34
- package/src/read/catalog.ts +324 -89
- package/src/read/index.ts +23 -2
- package/src/read/types.ts +16 -2
- package/src/read/works.ts +224 -59
package/src/read/artist.ts
CHANGED
|
@@ -9,19 +9,21 @@
|
|
|
9
9
|
// out from the browser (`lib/party-queries.ts`, plus a second identical fan-out in
|
|
10
10
|
// `PartyEditSheet`). Here they are one call, resolved once, cached once.
|
|
11
11
|
//
|
|
12
|
-
// `roles` and
|
|
13
|
-
// them, and leaving them out of the public read keeps the hot path to six.
|
|
12
|
+
// `roles`, `tags`, and the resolved featured release are opt-in via `include`.
|
|
14
13
|
|
|
15
14
|
import { resolveGenreNames } from "./genres.ts";
|
|
16
|
-
import {
|
|
15
|
+
import { getReleaseResources } from "./catalog.ts";
|
|
17
16
|
import { getDrop } from "../drop.ts";
|
|
18
|
-
import { getReleaseById } from "@misonetwork/sdk";
|
|
19
|
-
import { getReleaseCredits } from "../credits.ts";
|
|
20
17
|
import type { MisoClient } from "./client.ts";
|
|
21
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
ArtistProfile,
|
|
20
|
+
FeaturedRelease,
|
|
21
|
+
PartyMember,
|
|
22
|
+
PartySummary,
|
|
23
|
+
} from "./types.ts";
|
|
22
24
|
|
|
23
25
|
/** Optional sub-resources — read only when asked for. */
|
|
24
|
-
export type ArtistInclude = "roles" | "tags";
|
|
26
|
+
export type ArtistInclude = "roles" | "tags" | "featured";
|
|
25
27
|
|
|
26
28
|
export interface GetArtistOptions {
|
|
27
29
|
include?: readonly ArtistInclude[];
|
|
@@ -45,22 +47,30 @@ export async function getArtistProfile(
|
|
|
45
47
|
const include = new Set(options.include ?? []);
|
|
46
48
|
const { party } = client.sui;
|
|
47
49
|
|
|
48
|
-
const [profile, ctas, genreIds, links, roles, tags] =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
const [profile, ctas, genreIds, links, roles, tags, entity] =
|
|
51
|
+
await Promise.all([
|
|
52
|
+
party.getProfile(partyId).catch(() => null),
|
|
53
|
+
party.getCtas(partyId).catch(() => []),
|
|
54
|
+
party.getGenres(partyId).catch(() => [] as string[]),
|
|
55
|
+
party.getLinks(partyId).catch(() => []),
|
|
56
|
+
include.has("roles")
|
|
57
|
+
? party.getRoles(partyId).catch(() => [] as string[])
|
|
58
|
+
: Promise.resolve(undefined),
|
|
59
|
+
include.has("tags")
|
|
60
|
+
? party.getTags(partyId).catch(() => [] as string[])
|
|
61
|
+
: Promise.resolve(undefined),
|
|
62
|
+
party.getPartyById(partyId),
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
const [genres, members, featured] = await Promise.all([
|
|
62
66
|
resolveGenreNames(client, genreIds),
|
|
63
|
-
resolveMembers(
|
|
67
|
+
resolveMembers(
|
|
68
|
+
client,
|
|
69
|
+
entity.kind === "group" ? (entity.members ?? []) : [],
|
|
70
|
+
),
|
|
71
|
+
include.has("featured")
|
|
72
|
+
? resolveFeaturedRelease(client, partyId, entity.name).catch(() => null)
|
|
73
|
+
: Promise.resolve(undefined),
|
|
64
74
|
]);
|
|
65
75
|
|
|
66
76
|
return {
|
|
@@ -73,19 +83,29 @@ export async function getArtistProfile(
|
|
|
73
83
|
country: profile?.country ?? null,
|
|
74
84
|
languages: profile?.languages ?? [],
|
|
75
85
|
genres,
|
|
76
|
-
links: links.map((l) => ({
|
|
86
|
+
links: links.map((l) => ({
|
|
87
|
+
platform: l.platform,
|
|
88
|
+
value: l.value,
|
|
89
|
+
url: l.url,
|
|
90
|
+
})),
|
|
77
91
|
ctas: ctas.map((c) => ({ label: c.label, url: c.url })),
|
|
78
92
|
members,
|
|
79
93
|
...(roles !== undefined ? { roles } : {}),
|
|
80
94
|
...(tags !== undefined ? { tags } : {}),
|
|
95
|
+
...(featured !== undefined ? { featured } : {}),
|
|
81
96
|
avatarUrl: partyAvatarUrl(client.config.apiBaseUrl, entity.id),
|
|
82
97
|
};
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
/** Group members with names resolved. A member that fails to read is dropped. */
|
|
86
|
-
async function resolveMembers(
|
|
101
|
+
async function resolveMembers(
|
|
102
|
+
client: MisoClient,
|
|
103
|
+
memberIds: readonly string[],
|
|
104
|
+
): Promise<PartyMember[]> {
|
|
87
105
|
if (memberIds.length === 0) return [];
|
|
88
|
-
const parties = await client.sui.party
|
|
106
|
+
const parties = await client.sui.party
|
|
107
|
+
.getPartiesByIds([...memberIds])
|
|
108
|
+
.catch(() => ({}) as Record<string, undefined>);
|
|
89
109
|
return memberIds.flatMap((id) => {
|
|
90
110
|
const p = parties[id];
|
|
91
111
|
return p ? [{ id, name: p.name }] : [];
|
|
@@ -93,7 +113,10 @@ async function resolveMembers(client: MisoClient, memberIds: readonly string[]):
|
|
|
93
113
|
}
|
|
94
114
|
|
|
95
115
|
/** Name + kind for many parties at once. Ids that don't resolve are omitted. */
|
|
96
|
-
export async function getPartySummaries(
|
|
116
|
+
export async function getPartySummaries(
|
|
117
|
+
client: MisoClient,
|
|
118
|
+
ids: readonly string[],
|
|
119
|
+
): Promise<PartySummary[]> {
|
|
97
120
|
if (ids.length === 0) return [];
|
|
98
121
|
const parties = await client.sui.party.getPartiesByIds([...ids]);
|
|
99
122
|
return ids.flatMap((id) => {
|
|
@@ -107,30 +130,46 @@ export async function getPartySummaries(client: MisoClient, ids: readonly string
|
|
|
107
130
|
* `null` — a successful empty — when nothing is pinned or the pin is dangling
|
|
108
131
|
* (the pressing it named has since been superseded and destroyed).
|
|
109
132
|
*/
|
|
110
|
-
|
|
133
|
+
async function resolveFeaturedRelease(
|
|
134
|
+
client: MisoClient,
|
|
135
|
+
partyId: string,
|
|
136
|
+
fallbackArtist?: string,
|
|
137
|
+
): Promise<FeaturedRelease | null> {
|
|
111
138
|
const pressingId = await client.sui.party.getFeaturedDrop(partyId);
|
|
112
139
|
if (!pressingId) return null;
|
|
113
140
|
|
|
114
141
|
const pressing = await getDrop(client.protocol, pressingId);
|
|
115
142
|
if (!pressing) return null;
|
|
116
143
|
|
|
117
|
-
const [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
144
|
+
const [resources, entity] = await Promise.all([
|
|
145
|
+
getReleaseResources(client, pressing.releaseId, ["cover", "credits"]),
|
|
146
|
+
fallbackArtist === undefined
|
|
147
|
+
? client.sui.party.getPartyById(partyId)
|
|
148
|
+
: Promise.resolve(null),
|
|
122
149
|
]);
|
|
150
|
+
const { release, cover, credits } = resources;
|
|
123
151
|
|
|
124
152
|
// The artist line prefers the release's own PRIMARY credits and falls back to
|
|
125
153
|
// the party whose page this is — a release with no credits set still shows an
|
|
126
154
|
// artist, which is the behavior the featured card has always had.
|
|
127
|
-
const primary = (credits ?? [])
|
|
155
|
+
const primary = (credits ?? [])
|
|
156
|
+
.filter((c) => c.roles.includes("Primary"))
|
|
157
|
+
.map((c) => c.displayName);
|
|
128
158
|
|
|
129
159
|
return {
|
|
130
160
|
pressingId,
|
|
131
161
|
releaseId: pressing.releaseId,
|
|
132
162
|
title: release.title,
|
|
133
|
-
artist: primary.length
|
|
163
|
+
artist: primary.length
|
|
164
|
+
? primary.join(", ")
|
|
165
|
+
: (fallbackArtist ?? entity?.name ?? ""),
|
|
134
166
|
coverUrl: cover?.still.url ?? null,
|
|
135
167
|
};
|
|
136
168
|
}
|
|
169
|
+
|
|
170
|
+
export async function getFeaturedRelease(
|
|
171
|
+
client: MisoClient,
|
|
172
|
+
partyId: string,
|
|
173
|
+
): Promise<FeaturedRelease | null> {
|
|
174
|
+
return resolveFeaturedRelease(client, partyId);
|
|
175
|
+
}
|