@playdrop/playdrop-cli 0.7.15 → 0.7.16

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 (70) hide show
  1. package/config/client-meta.json +1 -1
  2. package/node_modules/@playdrop/ai-client/dist/index.js +461 -444
  3. package/node_modules/@playdrop/ai-client/package.json +1 -1
  4. package/node_modules/@playdrop/api-client/dist/client.js +903 -882
  5. package/node_modules/@playdrop/api-client/dist/core/errors.js +69 -45
  6. package/node_modules/@playdrop/api-client/dist/core/request.js +188 -159
  7. package/node_modules/@playdrop/api-client/dist/domains/admin.js +516 -491
  8. package/node_modules/@playdrop/api-client/dist/domains/ai.js +40 -14
  9. package/node_modules/@playdrop/api-client/dist/domains/apps.js +480 -462
  10. package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +439 -419
  11. package/node_modules/@playdrop/api-client/dist/domains/assets.js +696 -676
  12. package/node_modules/@playdrop/api-client/dist/domains/auth.js +346 -320
  13. package/node_modules/@playdrop/api-client/dist/domains/comments.js +124 -98
  14. package/node_modules/@playdrop/api-client/dist/domains/free-credits.js +91 -65
  15. package/node_modules/@playdrop/api-client/dist/domains/me.js +71 -45
  16. package/node_modules/@playdrop/api-client/dist/domains/payments.js +407 -386
  17. package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +144 -118
  18. package/node_modules/@playdrop/api-client/dist/domains/search.js +117 -104
  19. package/node_modules/@playdrop/api-client/dist/domains/tags.js +188 -162
  20. package/node_modules/@playdrop/api-client/dist/index.js +993 -552
  21. package/node_modules/@playdrop/api-client/package.json +1 -1
  22. package/node_modules/@playdrop/boxel-three/dist/src/animations.js +84 -62
  23. package/node_modules/@playdrop/boxel-three/dist/src/builders.js +341 -308
  24. package/node_modules/@playdrop/boxel-three/dist/src/context.js +55 -29
  25. package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +856 -858
  26. package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +267 -261
  27. package/node_modules/@playdrop/boxel-three/dist/src/index.js +64 -15
  28. package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +89 -63
  29. package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +81 -56
  30. package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +112 -86
  31. package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +45 -17
  32. package/node_modules/@playdrop/boxel-three/dist/src/scene.js +160 -136
  33. package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +582 -584
  34. package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +123 -97
  35. package/node_modules/@playdrop/boxel-three/dist/src/textures.js +207 -182
  36. package/node_modules/@playdrop/boxel-three/dist/src/types.js +15 -1
  37. package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +451 -425
  38. package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +109 -84
  39. package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +127 -106
  40. package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +73 -51
  41. package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +97 -79
  42. package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +29 -7
  43. package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +80 -60
  44. package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +41 -19
  45. package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +72 -50
  46. package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +84 -62
  47. package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +69 -47
  48. package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +129 -109
  49. package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +40 -18
  50. package/node_modules/@playdrop/boxel-three/package.json +1 -1
  51. package/node_modules/@playdrop/config/client-meta.json +1 -1
  52. package/node_modules/@playdrop/types/dist/api.js +289 -203
  53. package/node_modules/@playdrop/types/dist/app-capability-filters.js +112 -62
  54. package/node_modules/@playdrop/types/dist/app.js +91 -45
  55. package/node_modules/@playdrop/types/dist/asset-pack.js +37 -5
  56. package/node_modules/@playdrop/types/dist/asset-spec.js +170 -90
  57. package/node_modules/@playdrop/types/dist/asset.js +186 -108
  58. package/node_modules/@playdrop/types/dist/content-license.js +49 -15
  59. package/node_modules/@playdrop/types/dist/creator-public-image.js +60 -32
  60. package/node_modules/@playdrop/types/dist/ecs.js +102 -82
  61. package/node_modules/@playdrop/types/dist/engine-builtins.js +603 -573
  62. package/node_modules/@playdrop/types/dist/entity.js +63 -53
  63. package/node_modules/@playdrop/types/dist/graph.js +116 -80
  64. package/node_modules/@playdrop/types/dist/index.js +47 -20
  65. package/node_modules/@playdrop/types/dist/owned-assets.js +55 -33
  66. package/node_modules/@playdrop/types/dist/player-meta.js +151 -100
  67. package/node_modules/@playdrop/types/dist/realtime.js +27 -7
  68. package/node_modules/@playdrop/types/dist/version.js +182 -124
  69. package/node_modules/@playdrop/types/package.json +1 -1
  70. package/package.json +1 -1
@@ -1,499 +1,524 @@
1
- import { buildBrowserCredentialsInit } from '../core/request.js';
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 admin_exports = {};
19
+ __export(admin_exports, {
20
+ buildAdminApiClientMethods: () => buildAdminApiClientMethods
21
+ });
22
+ module.exports = __toCommonJS(admin_exports);
23
+ var import_request = require("../core/request.js");
2
24
  function buildAdminPaymentsQueryString(options) {
3
- const params = new URLSearchParams();
4
- if (options?.provider) {
5
- params.set('provider', options.provider);
6
- }
7
- if (options?.status) {
8
- const statuses = Array.isArray(options.status) ? options.status : [options.status];
9
- params.set('status', statuses.join(','));
10
- }
11
- if (typeof options?.userId === 'number') {
12
- params.set('userId', String(options.userId));
13
- }
14
- if (options?.creditPackSku) {
15
- params.set('creditPackSku', options.creditPackSku);
16
- }
17
- if (options?.from) {
18
- params.set('from', options.from instanceof Date ? options.from.toISOString() : options.from);
19
- }
20
- if (options?.to) {
21
- params.set('to', options.to instanceof Date ? options.to.toISOString() : options.to);
22
- }
23
- if (typeof options?.limit === 'number') {
24
- params.set('limit', String(options.limit));
25
- }
26
- if (typeof options?.offset === 'number') {
27
- params.set('offset', String(options.offset));
28
- }
29
- return params.toString();
25
+ const params = new URLSearchParams();
26
+ if (options?.provider) {
27
+ params.set("provider", options.provider);
28
+ }
29
+ if (options?.status) {
30
+ const statuses = Array.isArray(options.status) ? options.status : [options.status];
31
+ params.set("status", statuses.join(","));
32
+ }
33
+ if (typeof options?.userId === "number") {
34
+ params.set("userId", String(options.userId));
35
+ }
36
+ if (options?.creditPackSku) {
37
+ params.set("creditPackSku", options.creditPackSku);
38
+ }
39
+ if (options?.from) {
40
+ params.set("from", options.from instanceof Date ? options.from.toISOString() : options.from);
41
+ }
42
+ if (options?.to) {
43
+ params.set("to", options.to instanceof Date ? options.to.toISOString() : options.to);
44
+ }
45
+ if (typeof options?.limit === "number") {
46
+ params.set("limit", String(options.limit));
47
+ }
48
+ if (typeof options?.offset === "number") {
49
+ params.set("offset", String(options.offset));
50
+ }
51
+ return params.toString();
30
52
  }
31
53
  function buildAdminAppVersionReviewsQueryString(options) {
32
- const params = new URLSearchParams();
33
- if (options?.state) {
34
- params.set('state', options.state);
35
- }
36
- if (typeof options?.limit === 'number') {
37
- params.set('limit', String(options.limit));
38
- }
39
- if (typeof options?.offset === 'number') {
40
- params.set('offset', String(options.offset));
41
- }
42
- return params.toString();
54
+ const params = new URLSearchParams();
55
+ if (options?.state) {
56
+ params.set("state", options.state);
57
+ }
58
+ if (typeof options?.limit === "number") {
59
+ params.set("limit", String(options.limit));
60
+ }
61
+ if (typeof options?.offset === "number") {
62
+ params.set("offset", String(options.offset));
63
+ }
64
+ return params.toString();
43
65
  }
44
66
  async function buildAuthorizedHeaders(getClientHeaders, resolveToken) {
45
- const headers = new Headers();
46
- for (const [key, value] of Object.entries(getClientHeaders())) {
67
+ const headers = new Headers();
68
+ for (const [key, value] of Object.entries(getClientHeaders())) {
69
+ headers.set(key, value);
70
+ }
71
+ const token = await resolveToken();
72
+ if (token) {
73
+ headers.set("authorization", `Bearer ${token}`);
74
+ }
75
+ return headers;
76
+ }
77
+ function buildAdminApiClientMethods(input) {
78
+ const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders } = input;
79
+ return {
80
+ async fetchUsers() {
81
+ const response = await request({
82
+ method: "GET",
83
+ path: "/admin/users"
84
+ });
85
+ if (response.status !== 200) {
86
+ handleApiError(response, "fetch_users");
87
+ }
88
+ return response.body;
89
+ },
90
+ async createUser(userRequest) {
91
+ const response = await request({
92
+ method: "POST",
93
+ path: "/admin/users",
94
+ body: userRequest
95
+ });
96
+ if (response.status !== 201 && response.status !== 200) {
97
+ handleApiError(response, "create_user");
98
+ }
99
+ return response.body;
100
+ },
101
+ async batchCreateUsersFromCsv(formData) {
102
+ const base = resolveBaseUrl();
103
+ const headers = new Headers();
104
+ for (const [key, value] of Object.entries(getClientHeaders())) {
47
105
  headers.set(key, value);
106
+ }
107
+ const token = await resolveToken();
108
+ if (token) {
109
+ headers.set("authorization", `Bearer ${token}`);
110
+ }
111
+ const path = "/admin/users/batch-create";
112
+ const response = await fetchImpl(resolveUrl(base, path), {
113
+ method: "POST",
114
+ headers,
115
+ body: formData,
116
+ ...(0, import_request.buildBrowserCredentialsInit)(includeBrowserCredentials)
117
+ });
118
+ const parsed = await parseResponseBody(response);
119
+ const apiResponse = { status: response.status, body: parsed, headers: response.headers };
120
+ if (response.status !== 200 && response.status !== 201) {
121
+ handleApiError(apiResponse, "batch_create_users");
122
+ }
123
+ return parsed;
124
+ },
125
+ async fetchAdminUser(userId) {
126
+ const response = await request({
127
+ method: "GET",
128
+ path: `/admin/users/${encodeURIComponent(String(userId))}`
129
+ });
130
+ if (response.status !== 200) {
131
+ handleApiError(response, "fetch_admin_user");
132
+ }
133
+ return response.body;
134
+ },
135
+ async updateAdminUser(userId, updateRequest) {
136
+ const response = await request({
137
+ method: "PATCH",
138
+ path: `/admin/users/${encodeURIComponent(String(userId))}`,
139
+ body: updateRequest
140
+ });
141
+ if (response.status !== 200) {
142
+ handleApiError(response, "update_admin_user");
143
+ }
144
+ return response.body;
145
+ },
146
+ async deleteAdminUser(userId) {
147
+ const response = await request({
148
+ method: "DELETE",
149
+ path: `/admin/users/${encodeURIComponent(String(userId))}`
150
+ });
151
+ if (response.status !== 200) {
152
+ handleApiError(response, "delete_admin_user");
153
+ }
154
+ return response.body;
155
+ },
156
+ async fetchAdminApps() {
157
+ const response = await request({
158
+ method: "GET",
159
+ path: "/admin/apps"
160
+ });
161
+ if (response.status !== 200) {
162
+ handleApiError(response, "fetch_admin_apps");
163
+ }
164
+ return response.body;
165
+ },
166
+ async updateAdminApp(id, updateRequest) {
167
+ const response = await request({
168
+ method: "PATCH",
169
+ path: `/admin/apps/${encodeURIComponent(String(id))}`,
170
+ body: updateRequest
171
+ });
172
+ if (response.status !== 200) {
173
+ handleApiError(response, "update_admin_app");
174
+ }
175
+ return response.body;
176
+ },
177
+ async deleteAdminApp(id) {
178
+ const response = await request({
179
+ method: "DELETE",
180
+ path: `/admin/apps/${encodeURIComponent(String(id))}`
181
+ });
182
+ if (response.status !== 200) {
183
+ handleApiError(response, "delete_admin_app");
184
+ }
185
+ return response.body;
186
+ },
187
+ async fetchAdminGameCollections() {
188
+ const response = await request({
189
+ method: "GET",
190
+ path: "/admin/game-collections"
191
+ });
192
+ if (response.status !== 200) {
193
+ handleApiError(response, "fetch_admin_game_collections");
194
+ }
195
+ return response.body;
196
+ },
197
+ async createAdminGameCollection(requestBody) {
198
+ const response = await request({
199
+ method: "POST",
200
+ path: "/admin/game-collections",
201
+ body: requestBody
202
+ });
203
+ if (response.status !== 201 && response.status !== 200) {
204
+ handleApiError(response, "create_admin_game_collection");
205
+ }
206
+ return response.body;
207
+ },
208
+ async fetchAdminGameCollection(id) {
209
+ const response = await request({
210
+ method: "GET",
211
+ path: `/admin/game-collections/${encodeURIComponent(String(id))}`
212
+ });
213
+ if (response.status !== 200) {
214
+ handleApiError(response, "fetch_admin_game_collection");
215
+ }
216
+ return response.body;
217
+ },
218
+ async updateAdminGameCollection(id, requestBody) {
219
+ const response = await request({
220
+ method: "PATCH",
221
+ path: `/admin/game-collections/${encodeURIComponent(String(id))}`,
222
+ body: requestBody
223
+ });
224
+ if (response.status !== 200) {
225
+ handleApiError(response, "update_admin_game_collection");
226
+ }
227
+ return response.body;
228
+ },
229
+ async replaceAdminGameCollectionGames(id, requestBody) {
230
+ const response = await request({
231
+ method: "PUT",
232
+ path: `/admin/game-collections/${encodeURIComponent(String(id))}/games`,
233
+ body: requestBody
234
+ });
235
+ if (response.status !== 200) {
236
+ handleApiError(response, "replace_admin_game_collection_games");
237
+ }
238
+ return response.body;
239
+ },
240
+ async searchAdminGameCollectionCandidates(options) {
241
+ const params = new URLSearchParams();
242
+ params.set("q", options.q);
243
+ if (typeof options.limit === "number") {
244
+ params.set("limit", String(options.limit));
245
+ }
246
+ const response = await request({
247
+ method: "GET",
248
+ path: `/admin/game-collections/candidates?${params.toString()}`
249
+ });
250
+ if (response.status !== 200) {
251
+ handleApiError(response, "search_admin_game_collection_candidates");
252
+ }
253
+ return response.body;
254
+ },
255
+ async uploadAdminGameCollectionIcon(id, formData) {
256
+ const base = resolveBaseUrl();
257
+ const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
258
+ const path = `/admin/game-collections/${encodeURIComponent(String(id))}/icon`;
259
+ const response = await fetchImpl(resolveUrl(base, path), {
260
+ method: "POST",
261
+ headers,
262
+ body: formData,
263
+ ...(0, import_request.buildBrowserCredentialsInit)(includeBrowserCredentials)
264
+ });
265
+ const parsed = await parseResponseBody(response);
266
+ const apiResponse = { status: response.status, body: parsed, headers: response.headers };
267
+ if (response.status !== 200) {
268
+ handleApiError(apiResponse, "upload_admin_game_collection_icon");
269
+ }
270
+ return parsed;
271
+ },
272
+ async deleteAdminGameCollection(id) {
273
+ const response = await request({
274
+ method: "DELETE",
275
+ path: `/admin/game-collections/${encodeURIComponent(String(id))}`
276
+ });
277
+ if (response.status !== 200) {
278
+ handleApiError(response, "delete_admin_game_collection");
279
+ }
280
+ return response.body;
281
+ },
282
+ async fetchAdminAppVersionReviews(options) {
283
+ const query = buildAdminAppVersionReviewsQueryString(options);
284
+ const response = await request({
285
+ method: "GET",
286
+ path: "/admin/app-version-reviews" + (query ? `?${query}` : "")
287
+ });
288
+ if (response.status !== 200) {
289
+ handleApiError(response, "fetch_admin_app_version_reviews");
290
+ }
291
+ return response.body;
292
+ },
293
+ async claimNextAdminAppVersionReview() {
294
+ const response = await request({
295
+ method: "POST",
296
+ path: "/admin/app-version-reviews/claim-next"
297
+ });
298
+ if (response.status !== 200) {
299
+ handleApiError(response, "claim_next_admin_app_version_review");
300
+ }
301
+ return response.body;
302
+ },
303
+ async updateAdminAppVersionReview(versionId, requestBody) {
304
+ const response = await request({
305
+ method: "PATCH",
306
+ path: `/admin/app-version-reviews/${encodeURIComponent(String(versionId))}`,
307
+ body: requestBody
308
+ });
309
+ if (response.status !== 200) {
310
+ handleApiError(response, "update_admin_app_version_review");
311
+ }
312
+ return response.body;
313
+ },
314
+ async fetchAdminAppPlayerMeta(appId) {
315
+ const response = await request({
316
+ method: "GET",
317
+ path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta`
318
+ });
319
+ if (response.status !== 200) {
320
+ handleApiError(response, "fetch_admin_app_player_meta");
321
+ }
322
+ return response.body;
323
+ },
324
+ async fetchAdminAppPlayerMetaUser(appId, userId) {
325
+ const response = await request({
326
+ method: "GET",
327
+ path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/users/${encodeURIComponent(String(userId))}`
328
+ });
329
+ if (response.status !== 200) {
330
+ handleApiError(response, "fetch_admin_app_player_meta_user");
331
+ }
332
+ return response.body;
333
+ },
334
+ async retireAdminAchievement(appId, key) {
335
+ const response = await request({
336
+ method: "POST",
337
+ path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/achievements/${encodeURIComponent(key)}/retire`
338
+ });
339
+ if (response.status !== 200) {
340
+ handleApiError(response, "retire_admin_achievement");
341
+ }
342
+ return response.body;
343
+ },
344
+ async retireAdminLeaderboard(appId, key) {
345
+ const response = await request({
346
+ method: "POST",
347
+ path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/leaderboards/${encodeURIComponent(key)}/retire`
348
+ });
349
+ if (response.status !== 200) {
350
+ handleApiError(response, "retire_admin_leaderboard");
351
+ }
352
+ return response.body;
353
+ },
354
+ async mutateAdminAchievementState(appId, userId, key, body) {
355
+ const response = await request({
356
+ method: "POST",
357
+ path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/users/${encodeURIComponent(String(userId))}/achievements/${encodeURIComponent(key)}`,
358
+ body
359
+ });
360
+ if (response.status !== 200) {
361
+ handleApiError(response, "mutate_admin_achievement_state");
362
+ }
363
+ return response.body;
364
+ },
365
+ async mutateAdminLeaderboardScore(appId, userId, key, body) {
366
+ const response = await request({
367
+ method: "POST",
368
+ path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/users/${encodeURIComponent(String(userId))}/leaderboards/${encodeURIComponent(key)}`,
369
+ body
370
+ });
371
+ if (response.status !== 200) {
372
+ handleApiError(response, "mutate_admin_leaderboard_score");
373
+ }
374
+ return response.body;
375
+ },
376
+ async fetchAdminCreditPacks() {
377
+ const response = await request({
378
+ method: "GET",
379
+ path: "/admin/credit-packs"
380
+ });
381
+ if (response.status !== 200) {
382
+ handleApiError(response, "fetch_admin_credit_packs");
383
+ }
384
+ return response.body;
385
+ },
386
+ async createAdminCreditPack(body) {
387
+ const response = await request({
388
+ method: "POST",
389
+ path: "/admin/credit-packs",
390
+ body
391
+ });
392
+ if (response.status !== 201) {
393
+ handleApiError(response, "create_admin_credit_pack");
394
+ }
395
+ return response.body;
396
+ },
397
+ async updateAdminCreditPack(sku, body) {
398
+ const response = await request({
399
+ method: "PATCH",
400
+ path: `/admin/credit-packs/${encodeURIComponent(sku)}`,
401
+ body
402
+ });
403
+ if (response.status !== 200) {
404
+ handleApiError(response, "update_admin_credit_pack");
405
+ }
406
+ return response.body;
407
+ },
408
+ async deleteAdminCreditPack(sku) {
409
+ const response = await request({
410
+ method: "DELETE",
411
+ path: `/admin/credit-packs/${encodeURIComponent(sku)}`
412
+ });
413
+ if (response.status !== 200) {
414
+ handleApiError(response, "delete_admin_credit_pack");
415
+ }
416
+ return response.body;
417
+ },
418
+ async syncAdminCreditPacksStripe() {
419
+ const response = await request({
420
+ method: "POST",
421
+ path: "/admin/credit-packs/sync-stripe"
422
+ });
423
+ if (response.status !== 200) {
424
+ handleApiError(response, "sync_admin_credit_packs_stripe");
425
+ }
426
+ return response.body;
427
+ },
428
+ async fetchAdminPayments(options) {
429
+ const query = buildAdminPaymentsQueryString(options);
430
+ const path = query ? `/admin/payments?${query}` : "/admin/payments";
431
+ const response = await request({
432
+ method: "GET",
433
+ path
434
+ });
435
+ if (response.status !== 200) {
436
+ handleApiError(response, "fetch_admin_payments");
437
+ }
438
+ return response.body;
439
+ },
440
+ async fetchAdminPayment(paymentId) {
441
+ const response = await request({
442
+ method: "GET",
443
+ path: `/admin/payments/${encodeURIComponent(String(paymentId))}`
444
+ });
445
+ if (response.status !== 200) {
446
+ handleApiError(response, "fetch_admin_payment");
447
+ }
448
+ return response.body;
449
+ },
450
+ async refundAdminPayment(paymentId, body) {
451
+ const response = await request({
452
+ method: "POST",
453
+ path: `/admin/payments/${encodeURIComponent(String(paymentId))}/refund`,
454
+ body
455
+ });
456
+ if (response.status !== 200) {
457
+ handleApiError(response, "refund_admin_payment");
458
+ }
459
+ return response.body;
460
+ },
461
+ async reconcileAdminPayment(paymentId) {
462
+ const response = await request({
463
+ method: "POST",
464
+ path: `/admin/payments/${encodeURIComponent(String(paymentId))}/reconcile`
465
+ });
466
+ if (response.status !== 200) {
467
+ handleApiError(response, "reconcile_admin_payment");
468
+ }
469
+ return response.body;
470
+ },
471
+ async fetchAdminCreditTransactions(options) {
472
+ const params = new URLSearchParams();
473
+ if (options?.limit !== void 0) {
474
+ params.set("limit", String(options.limit));
475
+ }
476
+ if (options?.offset !== void 0) {
477
+ params.set("offset", String(options.offset));
478
+ }
479
+ const query = params.toString();
480
+ const path = query ? `/admin/credit-transactions?${query}` : "/admin/credit-transactions";
481
+ const response = await request({
482
+ method: "GET",
483
+ path
484
+ });
485
+ if (response.status !== 200) {
486
+ handleApiError(response, "fetch_admin_credit_transactions");
487
+ }
488
+ return response.body;
489
+ },
490
+ async fetchAdminAiGenerations(options) {
491
+ const params = new URLSearchParams();
492
+ if (options?.limit !== void 0) {
493
+ params.set("limit", String(options.limit));
494
+ }
495
+ if (options?.offset !== void 0) {
496
+ params.set("offset", String(options.offset));
497
+ }
498
+ const query = params.toString();
499
+ const path = query ? `/admin/ai-generations?${query}` : "/admin/ai-generations";
500
+ const response = await request({
501
+ method: "GET",
502
+ path
503
+ });
504
+ if (response.status !== 200) {
505
+ handleApiError(response, "fetch_admin_ai_generations");
506
+ }
507
+ return response.body;
508
+ },
509
+ async fetchAdminAiGeneration(id) {
510
+ const response = await request({
511
+ method: "GET",
512
+ path: `/admin/ai-generations/${id}`
513
+ });
514
+ if (response.status !== 200) {
515
+ handleApiError(response, "fetch_admin_ai_generation");
516
+ }
517
+ return response.body;
48
518
  }
49
- const token = await resolveToken();
50
- if (token) {
51
- headers.set('authorization', `Bearer ${token}`);
52
- }
53
- return headers;
54
- }
55
- // eslint-disable-next-line max-lines-per-function -- Admin client methods mirror the admin route surface in one place.
56
- export function buildAdminApiClientMethods(input) {
57
- const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, } = input;
58
- return {
59
- async fetchUsers() {
60
- const response = await request({
61
- method: 'GET',
62
- path: '/admin/users',
63
- });
64
- if (response.status !== 200) {
65
- handleApiError(response, 'fetch_users');
66
- }
67
- return response.body;
68
- },
69
- async createUser(userRequest) {
70
- const response = await request({
71
- method: 'POST',
72
- path: '/admin/users',
73
- body: userRequest,
74
- });
75
- if (response.status !== 201 && response.status !== 200) {
76
- handleApiError(response, 'create_user');
77
- }
78
- return response.body;
79
- },
80
- async batchCreateUsersFromCsv(formData) {
81
- const base = resolveBaseUrl();
82
- const headers = new Headers();
83
- for (const [key, value] of Object.entries(getClientHeaders())) {
84
- headers.set(key, value);
85
- }
86
- const token = await resolveToken();
87
- if (token) {
88
- headers.set('authorization', `Bearer ${token}`);
89
- }
90
- const path = '/admin/users/batch-create';
91
- const response = await fetchImpl(resolveUrl(base, path), {
92
- method: 'POST',
93
- headers,
94
- body: formData,
95
- ...buildBrowserCredentialsInit(includeBrowserCredentials),
96
- });
97
- const parsed = await parseResponseBody(response);
98
- const apiResponse = { status: response.status, body: parsed, headers: response.headers };
99
- if (response.status !== 200 && response.status !== 201) {
100
- handleApiError(apiResponse, 'batch_create_users');
101
- }
102
- return parsed;
103
- },
104
- async fetchAdminUser(userId) {
105
- const response = await request({
106
- method: 'GET',
107
- path: `/admin/users/${encodeURIComponent(String(userId))}`,
108
- });
109
- if (response.status !== 200) {
110
- handleApiError(response, 'fetch_admin_user');
111
- }
112
- return response.body;
113
- },
114
- async updateAdminUser(userId, updateRequest) {
115
- const response = await request({
116
- method: 'PATCH',
117
- path: `/admin/users/${encodeURIComponent(String(userId))}`,
118
- body: updateRequest,
119
- });
120
- if (response.status !== 200) {
121
- handleApiError(response, 'update_admin_user');
122
- }
123
- return response.body;
124
- },
125
- async deleteAdminUser(userId) {
126
- const response = await request({
127
- method: 'DELETE',
128
- path: `/admin/users/${encodeURIComponent(String(userId))}`,
129
- });
130
- if (response.status !== 200) {
131
- handleApiError(response, 'delete_admin_user');
132
- }
133
- return response.body;
134
- },
135
- async fetchAdminApps() {
136
- const response = await request({
137
- method: 'GET',
138
- path: '/admin/apps',
139
- });
140
- if (response.status !== 200) {
141
- handleApiError(response, 'fetch_admin_apps');
142
- }
143
- return response.body;
144
- },
145
- async updateAdminApp(id, updateRequest) {
146
- const response = await request({
147
- method: 'PATCH',
148
- path: `/admin/apps/${encodeURIComponent(String(id))}`,
149
- body: updateRequest,
150
- });
151
- if (response.status !== 200) {
152
- handleApiError(response, 'update_admin_app');
153
- }
154
- return response.body;
155
- },
156
- async deleteAdminApp(id) {
157
- const response = await request({
158
- method: 'DELETE',
159
- path: `/admin/apps/${encodeURIComponent(String(id))}`,
160
- });
161
- if (response.status !== 200) {
162
- handleApiError(response, 'delete_admin_app');
163
- }
164
- return response.body;
165
- },
166
- async fetchAdminGameCollections() {
167
- const response = await request({
168
- method: 'GET',
169
- path: '/admin/game-collections',
170
- });
171
- if (response.status !== 200) {
172
- handleApiError(response, 'fetch_admin_game_collections');
173
- }
174
- return response.body;
175
- },
176
- async createAdminGameCollection(requestBody) {
177
- const response = await request({
178
- method: 'POST',
179
- path: '/admin/game-collections',
180
- body: requestBody,
181
- });
182
- if (response.status !== 201 && response.status !== 200) {
183
- handleApiError(response, 'create_admin_game_collection');
184
- }
185
- return response.body;
186
- },
187
- async fetchAdminGameCollection(id) {
188
- const response = await request({
189
- method: 'GET',
190
- path: `/admin/game-collections/${encodeURIComponent(String(id))}`,
191
- });
192
- if (response.status !== 200) {
193
- handleApiError(response, 'fetch_admin_game_collection');
194
- }
195
- return response.body;
196
- },
197
- async updateAdminGameCollection(id, requestBody) {
198
- const response = await request({
199
- method: 'PATCH',
200
- path: `/admin/game-collections/${encodeURIComponent(String(id))}`,
201
- body: requestBody,
202
- });
203
- if (response.status !== 200) {
204
- handleApiError(response, 'update_admin_game_collection');
205
- }
206
- return response.body;
207
- },
208
- async replaceAdminGameCollectionGames(id, requestBody) {
209
- const response = await request({
210
- method: 'PUT',
211
- path: `/admin/game-collections/${encodeURIComponent(String(id))}/games`,
212
- body: requestBody,
213
- });
214
- if (response.status !== 200) {
215
- handleApiError(response, 'replace_admin_game_collection_games');
216
- }
217
- return response.body;
218
- },
219
- async searchAdminGameCollectionCandidates(options) {
220
- const params = new URLSearchParams();
221
- params.set('q', options.q);
222
- if (typeof options.limit === 'number') {
223
- params.set('limit', String(options.limit));
224
- }
225
- const response = await request({
226
- method: 'GET',
227
- path: `/admin/game-collections/candidates?${params.toString()}`,
228
- });
229
- if (response.status !== 200) {
230
- handleApiError(response, 'search_admin_game_collection_candidates');
231
- }
232
- return response.body;
233
- },
234
- async uploadAdminGameCollectionIcon(id, formData) {
235
- const base = resolveBaseUrl();
236
- const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
237
- const path = `/admin/game-collections/${encodeURIComponent(String(id))}/icon`;
238
- const response = await fetchImpl(resolveUrl(base, path), {
239
- method: 'POST',
240
- headers,
241
- body: formData,
242
- ...buildBrowserCredentialsInit(includeBrowserCredentials),
243
- });
244
- const parsed = await parseResponseBody(response);
245
- const apiResponse = { status: response.status, body: parsed, headers: response.headers };
246
- if (response.status !== 200) {
247
- handleApiError(apiResponse, 'upload_admin_game_collection_icon');
248
- }
249
- return parsed;
250
- },
251
- async deleteAdminGameCollection(id) {
252
- const response = await request({
253
- method: 'DELETE',
254
- path: `/admin/game-collections/${encodeURIComponent(String(id))}`,
255
- });
256
- if (response.status !== 200) {
257
- handleApiError(response, 'delete_admin_game_collection');
258
- }
259
- return response.body;
260
- },
261
- async fetchAdminAppVersionReviews(options) {
262
- const query = buildAdminAppVersionReviewsQueryString(options);
263
- const response = await request({
264
- method: 'GET',
265
- path: '/admin/app-version-reviews' + (query ? `?${query}` : ''),
266
- });
267
- if (response.status !== 200) {
268
- handleApiError(response, 'fetch_admin_app_version_reviews');
269
- }
270
- return response.body;
271
- },
272
- async claimNextAdminAppVersionReview() {
273
- const response = await request({
274
- method: 'POST',
275
- path: '/admin/app-version-reviews/claim-next',
276
- });
277
- if (response.status !== 200) {
278
- handleApiError(response, 'claim_next_admin_app_version_review');
279
- }
280
- return response.body;
281
- },
282
- async updateAdminAppVersionReview(versionId, requestBody) {
283
- const response = await request({
284
- method: 'PATCH',
285
- path: `/admin/app-version-reviews/${encodeURIComponent(String(versionId))}`,
286
- body: requestBody,
287
- });
288
- if (response.status !== 200) {
289
- handleApiError(response, 'update_admin_app_version_review');
290
- }
291
- return response.body;
292
- },
293
- async fetchAdminAppPlayerMeta(appId) {
294
- const response = await request({
295
- method: 'GET',
296
- path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta`,
297
- });
298
- if (response.status !== 200) {
299
- handleApiError(response, 'fetch_admin_app_player_meta');
300
- }
301
- return response.body;
302
- },
303
- async fetchAdminAppPlayerMetaUser(appId, userId) {
304
- const response = await request({
305
- method: 'GET',
306
- path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/users/${encodeURIComponent(String(userId))}`,
307
- });
308
- if (response.status !== 200) {
309
- handleApiError(response, 'fetch_admin_app_player_meta_user');
310
- }
311
- return response.body;
312
- },
313
- async retireAdminAchievement(appId, key) {
314
- const response = await request({
315
- method: 'POST',
316
- path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/achievements/${encodeURIComponent(key)}/retire`,
317
- });
318
- if (response.status !== 200) {
319
- handleApiError(response, 'retire_admin_achievement');
320
- }
321
- return response.body;
322
- },
323
- async retireAdminLeaderboard(appId, key) {
324
- const response = await request({
325
- method: 'POST',
326
- path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/leaderboards/${encodeURIComponent(key)}/retire`,
327
- });
328
- if (response.status !== 200) {
329
- handleApiError(response, 'retire_admin_leaderboard');
330
- }
331
- return response.body;
332
- },
333
- async mutateAdminAchievementState(appId, userId, key, body) {
334
- const response = await request({
335
- method: 'POST',
336
- path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/users/${encodeURIComponent(String(userId))}/achievements/${encodeURIComponent(key)}`,
337
- body,
338
- });
339
- if (response.status !== 200) {
340
- handleApiError(response, 'mutate_admin_achievement_state');
341
- }
342
- return response.body;
343
- },
344
- async mutateAdminLeaderboardScore(appId, userId, key, body) {
345
- const response = await request({
346
- method: 'POST',
347
- path: `/admin/apps/${encodeURIComponent(String(appId))}/player-meta/users/${encodeURIComponent(String(userId))}/leaderboards/${encodeURIComponent(key)}`,
348
- body,
349
- });
350
- if (response.status !== 200) {
351
- handleApiError(response, 'mutate_admin_leaderboard_score');
352
- }
353
- return response.body;
354
- },
355
- async fetchAdminCreditPacks() {
356
- const response = await request({
357
- method: 'GET',
358
- path: '/admin/credit-packs',
359
- });
360
- if (response.status !== 200) {
361
- handleApiError(response, 'fetch_admin_credit_packs');
362
- }
363
- return response.body;
364
- },
365
- async createAdminCreditPack(body) {
366
- const response = await request({
367
- method: 'POST',
368
- path: '/admin/credit-packs',
369
- body,
370
- });
371
- if (response.status !== 201) {
372
- handleApiError(response, 'create_admin_credit_pack');
373
- }
374
- return response.body;
375
- },
376
- async updateAdminCreditPack(sku, body) {
377
- const response = await request({
378
- method: 'PATCH',
379
- path: `/admin/credit-packs/${encodeURIComponent(sku)}`,
380
- body,
381
- });
382
- if (response.status !== 200) {
383
- handleApiError(response, 'update_admin_credit_pack');
384
- }
385
- return response.body;
386
- },
387
- async deleteAdminCreditPack(sku) {
388
- const response = await request({
389
- method: 'DELETE',
390
- path: `/admin/credit-packs/${encodeURIComponent(sku)}`,
391
- });
392
- if (response.status !== 200) {
393
- handleApiError(response, 'delete_admin_credit_pack');
394
- }
395
- return response.body;
396
- },
397
- async syncAdminCreditPacksStripe() {
398
- const response = await request({
399
- method: 'POST',
400
- path: '/admin/credit-packs/sync-stripe',
401
- });
402
- if (response.status !== 200) {
403
- handleApiError(response, 'sync_admin_credit_packs_stripe');
404
- }
405
- return response.body;
406
- },
407
- async fetchAdminPayments(options) {
408
- const query = buildAdminPaymentsQueryString(options);
409
- const path = query ? `/admin/payments?${query}` : '/admin/payments';
410
- const response = await request({
411
- method: 'GET',
412
- path,
413
- });
414
- if (response.status !== 200) {
415
- handleApiError(response, 'fetch_admin_payments');
416
- }
417
- return response.body;
418
- },
419
- async fetchAdminPayment(paymentId) {
420
- const response = await request({
421
- method: 'GET',
422
- path: `/admin/payments/${encodeURIComponent(String(paymentId))}`,
423
- });
424
- if (response.status !== 200) {
425
- handleApiError(response, 'fetch_admin_payment');
426
- }
427
- return response.body;
428
- },
429
- async refundAdminPayment(paymentId, body) {
430
- const response = await request({
431
- method: 'POST',
432
- path: `/admin/payments/${encodeURIComponent(String(paymentId))}/refund`,
433
- body,
434
- });
435
- if (response.status !== 200) {
436
- handleApiError(response, 'refund_admin_payment');
437
- }
438
- return response.body;
439
- },
440
- async reconcileAdminPayment(paymentId) {
441
- const response = await request({
442
- method: 'POST',
443
- path: `/admin/payments/${encodeURIComponent(String(paymentId))}/reconcile`,
444
- });
445
- if (response.status !== 200) {
446
- handleApiError(response, 'reconcile_admin_payment');
447
- }
448
- return response.body;
449
- },
450
- async fetchAdminCreditTransactions(options) {
451
- const params = new URLSearchParams();
452
- if (options?.limit !== undefined) {
453
- params.set('limit', String(options.limit));
454
- }
455
- if (options?.offset !== undefined) {
456
- params.set('offset', String(options.offset));
457
- }
458
- const query = params.toString();
459
- const path = query ? `/admin/credit-transactions?${query}` : '/admin/credit-transactions';
460
- const response = await request({
461
- method: 'GET',
462
- path,
463
- });
464
- if (response.status !== 200) {
465
- handleApiError(response, 'fetch_admin_credit_transactions');
466
- }
467
- return response.body;
468
- },
469
- async fetchAdminAiGenerations(options) {
470
- const params = new URLSearchParams();
471
- if (options?.limit !== undefined) {
472
- params.set('limit', String(options.limit));
473
- }
474
- if (options?.offset !== undefined) {
475
- params.set('offset', String(options.offset));
476
- }
477
- const query = params.toString();
478
- const path = query ? `/admin/ai-generations?${query}` : '/admin/ai-generations';
479
- const response = await request({
480
- method: 'GET',
481
- path,
482
- });
483
- if (response.status !== 200) {
484
- handleApiError(response, 'fetch_admin_ai_generations');
485
- }
486
- return response.body;
487
- },
488
- async fetchAdminAiGeneration(id) {
489
- const response = await request({
490
- method: 'GET',
491
- path: `/admin/ai-generations/${id}`,
492
- });
493
- if (response.status !== 200) {
494
- handleApiError(response, 'fetch_admin_ai_generation');
495
- }
496
- return response.body;
497
- },
498
- };
519
+ };
499
520
  }
521
+ // Annotate the CommonJS export names for ESM import in node:
522
+ 0 && (module.exports = {
523
+ buildAdminApiClientMethods
524
+ });