@playdrop/playdrop-cli 0.12.2 → 0.12.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.
@@ -36,17 +36,6 @@ function readCliPackageVersion() {
36
36
  if (cachedCliPackageVersion) {
37
37
  return cachedCliPackageVersion;
38
38
  }
39
- const candidateMetaPaths = [
40
- path_1.default.resolve(__dirname, '..', 'config', 'client-meta.json'),
41
- path_1.default.resolve(__dirname, '..', '..', '..', 'config', 'client-meta.json'),
42
- ];
43
- for (const candidatePath of candidateMetaPaths) {
44
- const clientMetaVersion = readVersionFromJson(candidatePath, 'version');
45
- if (clientMetaVersion) {
46
- cachedCliPackageVersion = clientMetaVersion;
47
- return clientMetaVersion;
48
- }
49
- }
50
39
  const packageJsonPath = path_1.default.resolve(__dirname, '..', 'package.json');
51
40
  const version = readVersionFromJson(packageJsonPath, 'version');
52
41
  if (!version) {
@@ -1,3 +1,4 @@
1
+ import type { Readable } from 'stream';
1
2
  import { resetOpenBrowserForTests, setOpenBrowserForTests } from '../browser';
2
3
  export { resetOpenBrowserForTests, setOpenBrowserForTests, };
3
4
  type LoginOptions = {
@@ -5,6 +6,17 @@ type LoginOptions = {
5
6
  password?: string;
6
7
  key?: string;
7
8
  handoffToken?: string;
9
+ handoffTokenStdin?: boolean;
8
10
  json?: boolean;
9
11
  };
10
- export declare function login(env: string, options?: LoginOptions): Promise<void>;
12
+ type LoginRuntime = {
13
+ stdin?: Readable;
14
+ };
15
+ export declare const HANDOFF_TOKEN_STDIN_MAX_BYTES: number;
16
+ type HandoffTokenStdinErrorCode = 'empty' | 'too_large' | 'read_failed';
17
+ export declare class HandoffTokenStdinError extends Error {
18
+ readonly code: HandoffTokenStdinErrorCode;
19
+ constructor(code: HandoffTokenStdinErrorCode);
20
+ }
21
+ export declare function readHandoffTokenFromStdin(input?: Readable): Promise<string>;
22
+ export declare function login(env: string, options?: LoginOptions, runtime?: LoginRuntime): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setOpenBrowserForTests = exports.resetOpenBrowserForTests = void 0;
3
+ exports.HandoffTokenStdinError = exports.HANDOFF_TOKEN_STDIN_MAX_BYTES = exports.setOpenBrowserForTests = exports.resetOpenBrowserForTests = void 0;
4
+ exports.readHandoffTokenFromStdin = readHandoffTokenFromStdin;
4
5
  exports.login = login;
5
6
  const types_1 = require("@playdrop/types");
6
7
  const config_1 = require("../config");
@@ -12,6 +13,40 @@ Object.defineProperty(exports, "resetOpenBrowserForTests", { enumerable: true, g
12
13
  Object.defineProperty(exports, "setOpenBrowserForTests", { enumerable: true, get: function () { return browser_1.setOpenBrowserForTests; } });
13
14
  const output_1 = require("../output");
14
15
  const messages_1 = require("../messages");
16
+ exports.HANDOFF_TOKEN_STDIN_MAX_BYTES = 8 * 1024;
17
+ class HandoffTokenStdinError extends Error {
18
+ constructor(code) {
19
+ super(`handoff_token_stdin_${code}`);
20
+ this.name = 'HandoffTokenStdinError';
21
+ this.code = code;
22
+ }
23
+ }
24
+ exports.HandoffTokenStdinError = HandoffTokenStdinError;
25
+ async function readHandoffTokenFromStdin(input = process.stdin) {
26
+ const chunks = [];
27
+ let byteCount = 0;
28
+ try {
29
+ for await (const chunk of input) {
30
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
31
+ byteCount += buffer.byteLength;
32
+ if (byteCount > exports.HANDOFF_TOKEN_STDIN_MAX_BYTES) {
33
+ throw new HandoffTokenStdinError('too_large');
34
+ }
35
+ chunks.push(buffer);
36
+ }
37
+ }
38
+ catch (error) {
39
+ if (error instanceof HandoffTokenStdinError) {
40
+ throw error;
41
+ }
42
+ throw new HandoffTokenStdinError('read_failed');
43
+ }
44
+ const token = Buffer.concat(chunks, byteCount).toString('utf8').trim();
45
+ if (!token) {
46
+ throw new HandoffTokenStdinError('empty');
47
+ }
48
+ return token;
49
+ }
15
50
  function sleep(ms) {
16
51
  return new Promise((resolve) => setTimeout(resolve, ms));
17
52
  }
@@ -193,7 +228,7 @@ async function loginInBrowser(env, baseUrl, options = {}) {
193
228
  ], { command: 'login' });
194
229
  process.exitCode = 1;
195
230
  }
196
- async function login(env, options = {}) {
231
+ async function login(env, options = {}, runtime = {}) {
197
232
  const envConfig = (0, environment_1.resolveEnvironmentConfig)(env);
198
233
  if (!envConfig) {
199
234
  const choices = (0, environment_1.formatEnvironmentList)();
@@ -207,12 +242,16 @@ async function login(env, options = {}) {
207
242
  const username = options.username?.trim();
208
243
  const password = options.password;
209
244
  const apiKey = options.key?.trim();
210
- const handoffToken = options.handoffToken?.trim();
245
+ const argvHandoffToken = options.handoffToken?.trim();
246
+ const hasApiKeyArgument = options.key !== undefined;
247
+ const hasHandoffTokenArgument = options.handoffToken !== undefined;
248
+ const readsHandoffTokenFromStdin = options.handoffTokenStdin === true;
211
249
  const hasDirectCredentials = Boolean(username || password);
212
250
  const explicitLoginMethods = [
213
- apiKey ? 'key' : null,
251
+ hasApiKeyArgument ? 'key' : null,
214
252
  hasDirectCredentials ? 'credentials' : null,
215
- handoffToken ? 'handoff' : null,
253
+ hasHandoffTokenArgument ? 'handoff' : null,
254
+ readsHandoffTokenFromStdin ? 'handoff-stdin' : null,
216
255
  ].filter(Boolean);
217
256
  if (explicitLoginMethods.length > 1) {
218
257
  (0, messages_1.printErrorWithHelp)('Choose exactly one login method.', [
@@ -220,6 +259,7 @@ async function login(env, options = {}) {
220
259
  'Use "--username" with "--password" for direct login.',
221
260
  'Use "--key" by itself for API key login.',
222
261
  'Use "--handoff-token" by itself for native app handoff login.',
262
+ 'Use "--handoff-token-stdin" by itself to read a native app handoff token from stdin.',
223
263
  ], { command: 'login' });
224
264
  process.exitCode = 1;
225
265
  return;
@@ -232,6 +272,33 @@ async function login(env, options = {}) {
232
272
  process.exitCode = 1;
233
273
  return;
234
274
  }
275
+ if (hasApiKeyArgument && !apiKey) {
276
+ (0, messages_1.printErrorWithHelp)('The API key cannot be empty.', ['Provide a non-empty value to "--key".'], { command: 'login' });
277
+ process.exitCode = 1;
278
+ return;
279
+ }
280
+ if (hasHandoffTokenArgument && !argvHandoffToken) {
281
+ (0, messages_1.printErrorWithHelp)('The native app handoff token cannot be empty.', ['Request a fresh handoff token from the PlayDrop app and retry.'], { command: 'login' });
282
+ process.exitCode = 1;
283
+ return;
284
+ }
285
+ let handoffToken = argvHandoffToken;
286
+ if (readsHandoffTokenFromStdin) {
287
+ try {
288
+ handoffToken = await readHandoffTokenFromStdin(runtime.stdin ?? process.stdin);
289
+ }
290
+ catch (error) {
291
+ const inputError = error instanceof HandoffTokenStdinError ? error : null;
292
+ const message = inputError?.code === 'too_large'
293
+ ? `Native app handoff input exceeded the ${exports.HANDOFF_TOKEN_STDIN_MAX_BYTES}-byte limit.`
294
+ : inputError?.code === 'empty'
295
+ ? 'Native app handoff input was empty.'
296
+ : 'Could not read native app handoff input from stdin.';
297
+ (0, messages_1.printErrorWithHelp)(message, ['Request a fresh handoff token from the PlayDrop app and retry.'], { command: 'login' });
298
+ process.exitCode = 1;
299
+ return;
300
+ }
301
+ }
235
302
  try {
236
303
  if (apiKey) {
237
304
  await loginWithKey(env, envConfig.apiBase, apiKey, { json: options.json });
package/dist/index.js CHANGED
@@ -120,6 +120,7 @@ function registerLoginCommand(parent) {
120
120
  .option('--password <password>', 'Password for direct login')
121
121
  .option('--key <apiKey>', 'API key for direct login')
122
122
  .option('--handoff-token <token>', 'Native app handoff token for direct login')
123
+ .option('--handoff-token-stdin', 'Read a native app handoff token from stdin')
123
124
  .option('--json', 'Output JSON')
124
125
  .action(async (opts) => {
125
126
  await (0, login_1.login)(opts.env, {
@@ -127,6 +128,7 @@ function registerLoginCommand(parent) {
127
128
  password: opts.password,
128
129
  key: opts.key,
129
130
  handoffToken: opts.handoffToken,
131
+ handoffTokenStdin: opts.handoffTokenStdin,
130
132
  json: opts.json,
131
133
  });
132
134
  });
@@ -0,0 +1,46 @@
1
+ import type { CreateGameIdeaRequest, CreateGameIdeaResponse, GameIdeaDetailResponse, GameIdeaStatusResponse, GameIdeasListRequest, GameIdeasListResponse, RemixCandidatesResponse, ShipGameIdeaRequest, ShipGameIdeaResponse, StartGameIdeaRequest, StartGameIdeaResponse, UpdateGameIdeaRequest, UpdateGameIdeaResponse } from '@playdrop/types';
2
+ type ApiResponseLike<T> = {
3
+ status: number;
4
+ body: T;
5
+ headers: Headers;
6
+ };
7
+ type RequestExecutor = <T>(input: {
8
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
9
+ path: string;
10
+ body?: unknown;
11
+ headers?: Record<string, string>;
12
+ signal?: AbortSignal;
13
+ }) => Promise<ApiResponseLike<T>>;
14
+ type ErrorHandler = (response: ApiResponseLike<unknown>, defaultMessage: string) => never;
15
+ type ParseResponseBody = <T>(response: Response) => Promise<T>;
16
+ export type CreateGameIdeaOptions = {
17
+ payload: CreateGameIdeaRequest;
18
+ image?: File | Blob;
19
+ filename?: string;
20
+ };
21
+ export declare function buildGameIdeasApiClientMethods(input: {
22
+ request: RequestExecutor;
23
+ handleApiError: ErrorHandler;
24
+ fetchImpl: typeof fetch;
25
+ includeBrowserCredentials: boolean;
26
+ resolveBaseUrl: () => string;
27
+ resolveUrl: (base: string, path: string) => string;
28
+ parseResponseBody: ParseResponseBody;
29
+ resolveToken: () => Promise<string | null>;
30
+ getClientHeaders: () => Record<string, string>;
31
+ }): {
32
+ createGameIdea(options: CreateGameIdeaOptions): Promise<CreateGameIdeaResponse>;
33
+ listGameIdeas(options?: GameIdeasListRequest): Promise<GameIdeasListResponse>;
34
+ getGameIdea(idOrSlug: string): Promise<GameIdeaDetailResponse>;
35
+ getGameIdeaStatus(idOrSlug: string): Promise<GameIdeaStatusResponse>;
36
+ updateGameIdea(idOrSlug: string, body: UpdateGameIdeaRequest): Promise<UpdateGameIdeaResponse>;
37
+ startGameIdea(idOrSlug: string, body?: StartGameIdeaRequest): Promise<StartGameIdeaResponse>;
38
+ shipGameIdea(idOrSlug: string, body: ShipGameIdeaRequest): Promise<ShipGameIdeaResponse>;
39
+ fetchRemixCandidates(options?: {
40
+ q?: string;
41
+ limit?: number;
42
+ offset?: number;
43
+ }): Promise<RemixCandidatesResponse>;
44
+ };
45
+ export {};
46
+ //# sourceMappingURL=game-ideas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-ideas.d.ts","sourceRoot":"","sources":["../../src/domains/game-ideas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAGzB,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE;IAChC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAElC,KAAK,YAAY,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,KAAK,KAAK,CAAC;AAE1F,KAAK,iBAAiB,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAqCF,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,YAAY,CAAC;IAC7B,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,yBAAyB,EAAE,OAAO,CAAC;IACnC,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACnD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,gBAAgB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD;4BAciC,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;4BAyBxD,oBAAoB,GAAQ,OAAO,CAAC,qBAAqB,CAAC;0BAiB3D,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;gCAYlC,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;6BAY3C,MAAM,QAAQ,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;4BAatE,MAAM,SAAQ,oBAAoB,GAAQ,OAAO,CAAC,qBAAqB,CAAC;2BAczE,MAAM,QAAQ,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;mCAiB1D;QAAE,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAQ,OAAO,CAAC,uBAAuB,CAAC;EAiB9H"}
@@ -0,0 +1,177 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var game_ideas_exports = {};
19
+ __export(game_ideas_exports, {
20
+ buildGameIdeasApiClientMethods: () => buildGameIdeasApiClientMethods
21
+ });
22
+ module.exports = __toCommonJS(game_ideas_exports);
23
+ var import_request = require("../core/request.js");
24
+ async function buildAuthorizedHeaders(input) {
25
+ const headers = new Headers();
26
+ for (const [key, value] of Object.entries(input.getClientHeaders())) {
27
+ headers.set(key, value);
28
+ }
29
+ const token = await input.resolveToken();
30
+ if (token) {
31
+ headers.set("authorization", `Bearer ${token}`);
32
+ }
33
+ return headers;
34
+ }
35
+ function appendPaginationParams(params, options) {
36
+ if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
37
+ params.set("limit", String(options.limit));
38
+ }
39
+ if (typeof options.offset === "number" && Number.isFinite(options.offset)) {
40
+ params.set("offset", String(options.offset));
41
+ }
42
+ }
43
+ function normalizeIdOrSlug(value) {
44
+ const normalized = typeof value === "string" ? value.trim() : "";
45
+ if (!normalized) {
46
+ throw new Error("invalid_game_idea_ref");
47
+ }
48
+ return normalized;
49
+ }
50
+ function buildGameIdeasApiClientMethods(input) {
51
+ const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders } = input;
52
+ return {
53
+ async createGameIdea(options) {
54
+ const form = new FormData();
55
+ form.set("payload", JSON.stringify(options.payload));
56
+ if (options.image) {
57
+ form.set("image", options.image, options.filename ?? "game-idea-image.png");
58
+ }
59
+ const headers = await buildAuthorizedHeaders({ getClientHeaders, resolveToken });
60
+ const response = await fetchImpl(resolveUrl(resolveBaseUrl(), "/me/game-ideas"), {
61
+ method: "POST",
62
+ headers,
63
+ body: form,
64
+ ...(0, import_request.buildBrowserCredentialsInit)(includeBrowserCredentials)
65
+ });
66
+ const body = await parseResponseBody(response);
67
+ const apiResponse = {
68
+ status: response.status,
69
+ body,
70
+ headers: response.headers
71
+ };
72
+ if (response.status !== 201) {
73
+ handleApiError(apiResponse, "create_game_idea");
74
+ }
75
+ return body;
76
+ },
77
+ async listGameIdeas(options = {}) {
78
+ const params = new URLSearchParams();
79
+ if (typeof options.state === "string" && options.state.trim().length > 0) {
80
+ params.set("state", options.state.trim().toLowerCase());
81
+ }
82
+ appendPaginationParams(params, options);
83
+ const query = params.toString();
84
+ const response = await request({
85
+ method: "GET",
86
+ path: "/me/game-ideas" + (query ? `?${query}` : "")
87
+ });
88
+ if (response.status !== 200) {
89
+ handleApiError(response, "list_game_ideas");
90
+ }
91
+ return response.body;
92
+ },
93
+ async getGameIdea(idOrSlug) {
94
+ const ref = normalizeIdOrSlug(idOrSlug);
95
+ const response = await request({
96
+ method: "GET",
97
+ path: `/me/game-ideas/${encodeURIComponent(ref)}`
98
+ });
99
+ if (response.status !== 200) {
100
+ handleApiError(response, "get_game_idea");
101
+ }
102
+ return response.body;
103
+ },
104
+ async getGameIdeaStatus(idOrSlug) {
105
+ const ref = normalizeIdOrSlug(idOrSlug);
106
+ const response = await request({
107
+ method: "GET",
108
+ path: `/me/game-ideas/${encodeURIComponent(ref)}/status`
109
+ });
110
+ if (response.status !== 200) {
111
+ handleApiError(response, "get_game_idea_status");
112
+ }
113
+ return response.body;
114
+ },
115
+ async updateGameIdea(idOrSlug, body) {
116
+ const ref = normalizeIdOrSlug(idOrSlug);
117
+ const response = await request({
118
+ method: "PATCH",
119
+ path: `/me/game-ideas/${encodeURIComponent(ref)}`,
120
+ body
121
+ });
122
+ if (response.status !== 200) {
123
+ handleApiError(response, "update_game_idea");
124
+ }
125
+ return response.body;
126
+ },
127
+ async startGameIdea(idOrSlug, body = {}) {
128
+ const ref = normalizeIdOrSlug(idOrSlug);
129
+ const appRef = typeof body.app === "string" ? body.app.trim() : "";
130
+ const response = await request({
131
+ method: "POST",
132
+ path: `/me/game-ideas/${encodeURIComponent(ref)}/start`,
133
+ ...appRef ? { body: { app: appRef } } : {}
134
+ });
135
+ if (response.status !== 200) {
136
+ handleApiError(response, "start_game_idea");
137
+ }
138
+ return response.body;
139
+ },
140
+ async shipGameIdea(idOrSlug, body) {
141
+ const ref = normalizeIdOrSlug(idOrSlug);
142
+ const appRef = typeof body?.app === "string" ? body.app.trim() : "";
143
+ if (!appRef) {
144
+ throw new Error("invalid_app_ref");
145
+ }
146
+ const response = await request({
147
+ method: "POST",
148
+ path: `/me/game-ideas/${encodeURIComponent(ref)}/ship`,
149
+ body: { app: appRef }
150
+ });
151
+ if (response.status !== 200) {
152
+ handleApiError(response, "ship_game_idea");
153
+ }
154
+ return response.body;
155
+ },
156
+ async fetchRemixCandidates(options = {}) {
157
+ const params = new URLSearchParams();
158
+ if (typeof options.q === "string" && options.q.trim().length > 0) {
159
+ params.set("q", options.q.trim());
160
+ }
161
+ appendPaginationParams(params, options);
162
+ const query = params.toString();
163
+ const response = await request({
164
+ method: "GET",
165
+ path: "/game-ideas/remix-candidates" + (query ? `?${query}` : "")
166
+ });
167
+ if (response.status !== 200) {
168
+ handleApiError(response, "fetch_remix_candidates");
169
+ }
170
+ return response.body;
171
+ }
172
+ };
173
+ }
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ buildGameIdeasApiClientMethods
177
+ });
@@ -0,0 +1,27 @@
1
+ import type { MusicConciergeActivitiesRequest, MusicConciergeActivitiesResponse, MusicConciergeCreateSongGenerationRequest, MusicConciergePlaylistsRequest, MusicConciergePlaylistsResponse, MusicConciergeRefinementsRequest, MusicConciergeRefinementsResponse, MusicConciergeSongGenerationResponse, MusicConciergeSongGenerationStatusResponse, MusicConciergeSongsRequest, MusicConciergeSongsResponse } from '@playdrop/types';
2
+ type ApiResponseLike<T> = {
3
+ status: number;
4
+ body: T;
5
+ headers: Headers;
6
+ };
7
+ type RequestExecutor = <T>(input: {
8
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
9
+ path: string;
10
+ body?: unknown;
11
+ headers?: Record<string, string>;
12
+ signal?: AbortSignal;
13
+ }) => Promise<ApiResponseLike<T>>;
14
+ type ErrorHandler = (response: ApiResponseLike<unknown>, defaultMessage: string) => never;
15
+ export declare function buildMusicApiClientMethods(input: {
16
+ request: RequestExecutor;
17
+ handleApiError: ErrorHandler;
18
+ }): {
19
+ generateMusicConciergeActivities(body: MusicConciergeActivitiesRequest): Promise<MusicConciergeActivitiesResponse>;
20
+ generateMusicConciergeRefinements(body: MusicConciergeRefinementsRequest): Promise<MusicConciergeRefinementsResponse>;
21
+ generateMusicConciergePlaylists(body: MusicConciergePlaylistsRequest): Promise<MusicConciergePlaylistsResponse>;
22
+ generateMusicConciergeSongs(body: MusicConciergeSongsRequest): Promise<MusicConciergeSongsResponse>;
23
+ createMusicConciergeSongGeneration(body: MusicConciergeCreateSongGenerationRequest): Promise<MusicConciergeSongGenerationResponse>;
24
+ fetchMusicConciergeSongGeneration(jobId: string): Promise<MusicConciergeSongGenerationStatusResponse>;
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=music.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"music.d.ts","sourceRoot":"","sources":["../../src/domains/music.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,gCAAgC,EAChC,yCAAyC,EACzC,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,EAChC,iCAAiC,EACjC,oCAAoC,EACpC,0CAA0C,EAC1C,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AAEzB,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE;IAChC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAElC,KAAK,YAAY,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,KAAK,KAAK,CAAC;AAE1F,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,YAAY,CAAC;CAC9B;2CAKW,+BAA+B,GACpC,OAAO,CAAC,gCAAgC,CAAC;4CAapC,gCAAgC,GACrC,OAAO,CAAC,iCAAiC,CAAC;0CAarC,8BAA8B,GACnC,OAAO,CAAC,+BAA+B,CAAC;sCAanC,0BAA0B,GAC/B,OAAO,CAAC,2BAA2B,CAAC;6CAa/B,yCAAyC,GAC9C,OAAO,CAAC,oCAAoC,CAAC;6CAavC,MAAM,GACZ,OAAO,CAAC,0CAA0C,CAAC;EAWzD"}
@@ -0,0 +1,96 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var music_exports = {};
19
+ __export(music_exports, {
20
+ buildMusicApiClientMethods: () => buildMusicApiClientMethods
21
+ });
22
+ module.exports = __toCommonJS(music_exports);
23
+ function buildMusicApiClientMethods(input) {
24
+ const { request, handleApiError } = input;
25
+ return {
26
+ async generateMusicConciergeActivities(body) {
27
+ const response = await request({
28
+ method: "POST",
29
+ path: "/v1/music/concierge/activities",
30
+ body
31
+ });
32
+ if (response.status !== 200) {
33
+ handleApiError(response, "generate_music_concierge_activities");
34
+ }
35
+ return response.body;
36
+ },
37
+ async generateMusicConciergeRefinements(body) {
38
+ const response = await request({
39
+ method: "POST",
40
+ path: "/v1/music/concierge/refinements",
41
+ body
42
+ });
43
+ if (response.status !== 200) {
44
+ handleApiError(response, "generate_music_concierge_refinements");
45
+ }
46
+ return response.body;
47
+ },
48
+ async generateMusicConciergePlaylists(body) {
49
+ const response = await request({
50
+ method: "POST",
51
+ path: "/v1/music/concierge/playlists",
52
+ body
53
+ });
54
+ if (response.status !== 200) {
55
+ handleApiError(response, "generate_music_concierge_playlists");
56
+ }
57
+ return response.body;
58
+ },
59
+ async generateMusicConciergeSongs(body) {
60
+ const response = await request({
61
+ method: "POST",
62
+ path: "/v1/music/concierge/songs",
63
+ body
64
+ });
65
+ if (response.status !== 200) {
66
+ handleApiError(response, "generate_music_concierge_songs");
67
+ }
68
+ return response.body;
69
+ },
70
+ async createMusicConciergeSongGeneration(body) {
71
+ const response = await request({
72
+ method: "POST",
73
+ path: "/v1/music/concierge/generations",
74
+ body
75
+ });
76
+ if (response.status !== 200) {
77
+ handleApiError(response, "create_music_concierge_song_generation");
78
+ }
79
+ return response.body;
80
+ },
81
+ async fetchMusicConciergeSongGeneration(jobId) {
82
+ const response = await request({
83
+ method: "GET",
84
+ path: `/v1/music/concierge/generations/${encodeURIComponent(jobId)}`
85
+ });
86
+ if (response.status !== 200) {
87
+ handleApiError(response, "fetch_music_concierge_song_generation");
88
+ }
89
+ return response.body;
90
+ }
91
+ };
92
+ }
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ buildMusicApiClientMethods
96
+ });