@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,441 +1,461 @@
1
- import { buildBrowserCredentialsInit } from '../core/request.js';
2
- function buildPublicAssetPackPath(normalizeCreatorItemSlug, creatorUsername, packName, suffix = '') {
3
- const creator = normalizeCreatorItemSlug(creatorUsername, 'creator');
4
- const name = normalizeCreatorItemSlug(packName, 'name');
5
- return `/asset-packs/${encodeURIComponent(creator)}/${encodeURIComponent(name)}${suffix}`;
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 asset_packs_exports = {};
19
+ __export(asset_packs_exports, {
20
+ buildAssetPacksApiClientMethods: () => buildAssetPacksApiClientMethods
21
+ });
22
+ module.exports = __toCommonJS(asset_packs_exports);
23
+ var import_request = require("../core/request.js");
24
+ function buildPublicAssetPackPath(normalizeCreatorItemSlug, creatorUsername, packName, suffix = "") {
25
+ const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
26
+ const name = normalizeCreatorItemSlug(packName, "name");
27
+ return `/asset-packs/${encodeURIComponent(creator)}/${encodeURIComponent(name)}${suffix}`;
6
28
  }
7
29
  function appendNormalizedTagParams(params, tags) {
8
- if (!Array.isArray(tags)) {
9
- return;
30
+ if (!Array.isArray(tags)) {
31
+ return;
32
+ }
33
+ for (const tag of tags) {
34
+ if (typeof tag !== "string") {
35
+ continue;
10
36
  }
11
- for (const tag of tags) {
12
- if (typeof tag !== 'string') {
13
- continue;
14
- }
15
- const normalized = tag.trim();
16
- if (normalized.length > 0) {
17
- params.append('tag', normalized);
18
- }
37
+ const normalized = tag.trim();
38
+ if (normalized.length > 0) {
39
+ params.append("tag", normalized);
19
40
  }
41
+ }
20
42
  }
21
43
  function buildAssetPackVersionPath(normalizeCreatorItemSlug, normalizeSemverInput, creatorUsername, packName, version, suffix) {
22
- const creator = normalizeCreatorItemSlug(creatorUsername, 'creator');
23
- const name = normalizeCreatorItemSlug(packName, 'name');
24
- const normalizedVersion = normalizeSemverInput(version);
25
- return `/asset-packs/${encodeURIComponent(creator)}/${encodeURIComponent(name)}/versions/${encodeURIComponent(normalizedVersion)}${suffix}`;
44
+ const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
45
+ const name = normalizeCreatorItemSlug(packName, "name");
46
+ const normalizedVersion = normalizeSemverInput(version);
47
+ return `/asset-packs/${encodeURIComponent(creator)}/${encodeURIComponent(name)}/versions/${encodeURIComponent(normalizedVersion)}${suffix}`;
26
48
  }
27
49
  async function buildAuthorizedHeaders(getClientHeaders, resolveToken) {
28
- const headers = new Headers();
29
- for (const [key, value] of Object.entries(getClientHeaders())) {
30
- headers.set(key, value);
31
- }
32
- const token = await resolveToken();
33
- if (token) {
34
- headers.set('authorization', `Bearer ${token}`);
35
- }
36
- return headers;
50
+ const headers = new Headers();
51
+ for (const [key, value] of Object.entries(getClientHeaders())) {
52
+ headers.set(key, value);
53
+ }
54
+ const token = await resolveToken();
55
+ if (token) {
56
+ headers.set("authorization", `Bearer ${token}`);
57
+ }
58
+ return headers;
37
59
  }
38
60
  function buildAssetPackSessionAssetUploadForm(options) {
39
- if (!Array.isArray(options.files) || options.files.length === 0) {
40
- throw new Error('missing_asset_files');
61
+ if (!Array.isArray(options.files) || options.files.length === 0) {
62
+ throw new Error("missing_asset_files");
63
+ }
64
+ const form = new FormData();
65
+ for (const item of options.files) {
66
+ if (!item) {
67
+ throw new Error("missing_asset_upload_file");
41
68
  }
42
- const form = new FormData();
43
- for (const item of options.files) {
44
- if (!item) {
45
- throw new Error('missing_asset_upload_file');
46
- }
47
- const fieldName = typeof item.fieldName === 'string' && item.fieldName.trim().length > 0
48
- ? item.fieldName.trim()
49
- : 'file';
50
- if (typeof item.filename === 'string' && item.filename.trim().length > 0) {
51
- form.append(fieldName, item.file, item.filename.trim());
52
- }
53
- else {
54
- form.append(fieldName, item.file);
55
- }
69
+ const fieldName = typeof item.fieldName === "string" && item.fieldName.trim().length > 0 ? item.fieldName.trim() : "file";
70
+ if (typeof item.filename === "string" && item.filename.trim().length > 0) {
71
+ form.append(fieldName, item.file, item.filename.trim());
72
+ } else {
73
+ form.append(fieldName, item.file);
56
74
  }
57
- return form;
75
+ }
76
+ return form;
58
77
  }
59
78
  function buildAssetPackSessionMediaUploadForm(options) {
60
- if (!options?.file) {
61
- throw new Error('missing_media_file');
62
- }
63
- const form = new FormData();
64
- if (typeof options.filename === 'string' && options.filename.trim().length > 0) {
65
- form.append('file', options.file, options.filename.trim());
66
- }
67
- else {
68
- form.append('file', options.file);
69
- }
70
- return form;
79
+ if (!options?.file) {
80
+ throw new Error("missing_media_file");
81
+ }
82
+ const form = new FormData();
83
+ if (typeof options.filename === "string" && options.filename.trim().length > 0) {
84
+ form.append("file", options.file, options.filename.trim());
85
+ } else {
86
+ form.append("file", options.file);
87
+ }
88
+ return form;
71
89
  }
72
90
  async function fetchAssetPackRelatedRequest(request, handleApiError, normalizeCreatorItemSlug, creatorUsername, packName) {
73
- const response = await request({
74
- method: 'GET',
75
- path: buildPublicAssetPackPath(normalizeCreatorItemSlug, creatorUsername, packName, '/related'),
76
- });
77
- if (response.status !== 200) {
78
- handleApiError(response, 'get_pack_related');
79
- }
80
- return response.body;
91
+ const response = await request({
92
+ method: "GET",
93
+ path: buildPublicAssetPackPath(normalizeCreatorItemSlug, creatorUsername, packName, "/related")
94
+ });
95
+ if (response.status !== 200) {
96
+ handleApiError(response, "get_pack_related");
97
+ }
98
+ return response.body;
81
99
  }
82
- export function buildAssetPacksApiClientMethods(input) {
83
- return {
84
- ...buildAssetPackUploadSessionMethods(input),
85
- ...buildAssetPackReadWriteMethods(input),
86
- };
100
+ function buildAssetPacksApiClientMethods(input) {
101
+ return {
102
+ ...buildAssetPackUploadSessionMethods(input),
103
+ ...buildAssetPackReadWriteMethods(input)
104
+ };
87
105
  }
88
106
  function buildAssetPackUploadSessionMethods(input) {
89
- const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, buildCreatorAssetPackMutationPath, normalizeCreatorItemSlug, } = input;
90
- return {
91
- async initializeAssetPackUpload(creatorUsername, name, requestBody) {
92
- const packName = typeof name === 'string' ? name.trim() : '';
93
- if (!packName) {
94
- throw new Error('invalid_pack_name');
95
- }
96
- const response = await request({
97
- method: 'POST',
98
- path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions`,
99
- body: requestBody,
100
- });
101
- if (response.status !== 200 && response.status !== 201) {
102
- handleApiError(response, 'initialize_asset_pack_upload');
103
- }
104
- return response.body;
105
- },
106
- async uploadAssetPackSessionAsset(creatorUsername, name, sessionId, uploadKey, options) {
107
- const packName = typeof name === 'string' ? name.trim() : '';
108
- if (!packName) {
109
- throw new Error('invalid_pack_name');
110
- }
111
- const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
112
- const normalizedUploadKey = typeof uploadKey === 'string' ? uploadKey.trim() : '';
113
- if (!normalizedSessionId) {
114
- throw new Error('invalid_pack_upload_session_id');
115
- }
116
- if (!normalizedUploadKey) {
117
- throw new Error('invalid_pack_upload_asset_key');
118
- }
119
- const form = buildAssetPackSessionAssetUploadForm(options);
120
- const base = resolveBaseUrl();
121
- const path = `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/assets/${encodeURIComponent(normalizedUploadKey)}`;
122
- const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
123
- const response = await fetchImpl(resolveUrl(base, path), {
124
- method: 'POST',
125
- headers,
126
- body: form,
127
- ...buildBrowserCredentialsInit(includeBrowserCredentials),
128
- });
129
- const parsed = await parseResponseBody(response);
130
- const apiResponse = { status: response.status, body: parsed, headers: response.headers };
131
- if (response.status !== 200 && response.status !== 201) {
132
- handleApiError(apiResponse, 'upload_asset_pack_session_asset');
133
- }
134
- return parsed;
135
- },
136
- async uploadAssetPackSessionMedia(creatorUsername, name, sessionId, mediaKey, options) {
137
- const packName = typeof name === 'string' ? name.trim() : '';
138
- if (!packName) {
139
- throw new Error('invalid_pack_name');
140
- }
141
- const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
142
- const normalizedMediaKey = typeof mediaKey === 'string' ? mediaKey.trim() : '';
143
- if (!normalizedSessionId) {
144
- throw new Error('invalid_pack_upload_session_id');
145
- }
146
- if (!normalizedMediaKey) {
147
- throw new Error('invalid_pack_upload_media_key');
148
- }
149
- const form = buildAssetPackSessionMediaUploadForm(options);
150
- const base = resolveBaseUrl();
151
- const path = `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/media/${encodeURIComponent(normalizedMediaKey)}`;
152
- const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
153
- const response = await fetchImpl(resolveUrl(base, path), {
154
- method: 'POST',
155
- headers,
156
- body: form,
157
- ...buildBrowserCredentialsInit(includeBrowserCredentials),
158
- });
159
- const parsed = await parseResponseBody(response);
160
- const apiResponse = { status: response.status, body: parsed, headers: response.headers };
161
- if (response.status !== 200 && response.status !== 201) {
162
- handleApiError(apiResponse, 'upload_asset_pack_session_media');
163
- }
164
- return parsed;
165
- },
166
- async finalizeAssetPackUpload(creatorUsername, name, sessionId) {
167
- const packName = typeof name === 'string' ? name.trim() : '';
168
- if (!packName) {
169
- throw new Error('invalid_pack_name');
170
- }
171
- const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
172
- if (!normalizedSessionId) {
173
- throw new Error('invalid_pack_upload_session_id');
174
- }
175
- const response = await request({
176
- method: 'POST',
177
- path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/finalize`,
178
- });
179
- if (response.status !== 200 && response.status !== 201) {
180
- handleApiError(response, 'finalize_asset_pack_upload');
181
- }
182
- return response.body;
183
- },
184
- async abortAssetPackUpload(creatorUsername, name, sessionId) {
185
- const packName = typeof name === 'string' ? name.trim() : '';
186
- if (!packName) {
187
- throw new Error('invalid_pack_name');
188
- }
189
- const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
190
- if (!normalizedSessionId) {
191
- throw new Error('invalid_pack_upload_session_id');
192
- }
193
- const response = await request({
194
- method: 'POST',
195
- path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/abort`,
196
- });
197
- if (response.status !== 200) {
198
- handleApiError(response, 'abort_asset_pack_upload');
199
- }
200
- return response.body;
201
- },
202
- async fetchAssetPackRelated(creatorUsername, packName) {
203
- return fetchAssetPackRelatedRequest(request, handleApiError, normalizeCreatorItemSlug, creatorUsername, packName);
204
- },
205
- };
107
+ const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, buildCreatorAssetPackMutationPath, normalizeCreatorItemSlug } = input;
108
+ return {
109
+ async initializeAssetPackUpload(creatorUsername, name, requestBody) {
110
+ const packName = typeof name === "string" ? name.trim() : "";
111
+ if (!packName) {
112
+ throw new Error("invalid_pack_name");
113
+ }
114
+ const response = await request({
115
+ method: "POST",
116
+ path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions`,
117
+ body: requestBody
118
+ });
119
+ if (response.status !== 200 && response.status !== 201) {
120
+ handleApiError(response, "initialize_asset_pack_upload");
121
+ }
122
+ return response.body;
123
+ },
124
+ async uploadAssetPackSessionAsset(creatorUsername, name, sessionId, uploadKey, options) {
125
+ const packName = typeof name === "string" ? name.trim() : "";
126
+ if (!packName) {
127
+ throw new Error("invalid_pack_name");
128
+ }
129
+ const normalizedSessionId = typeof sessionId === "string" ? sessionId.trim() : "";
130
+ const normalizedUploadKey = typeof uploadKey === "string" ? uploadKey.trim() : "";
131
+ if (!normalizedSessionId) {
132
+ throw new Error("invalid_pack_upload_session_id");
133
+ }
134
+ if (!normalizedUploadKey) {
135
+ throw new Error("invalid_pack_upload_asset_key");
136
+ }
137
+ const form = buildAssetPackSessionAssetUploadForm(options);
138
+ const base = resolveBaseUrl();
139
+ const path = `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/assets/${encodeURIComponent(normalizedUploadKey)}`;
140
+ const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
141
+ const response = await fetchImpl(resolveUrl(base, path), {
142
+ method: "POST",
143
+ headers,
144
+ body: form,
145
+ ...(0, import_request.buildBrowserCredentialsInit)(includeBrowserCredentials)
146
+ });
147
+ const parsed = await parseResponseBody(response);
148
+ const apiResponse = { status: response.status, body: parsed, headers: response.headers };
149
+ if (response.status !== 200 && response.status !== 201) {
150
+ handleApiError(apiResponse, "upload_asset_pack_session_asset");
151
+ }
152
+ return parsed;
153
+ },
154
+ async uploadAssetPackSessionMedia(creatorUsername, name, sessionId, mediaKey, options) {
155
+ const packName = typeof name === "string" ? name.trim() : "";
156
+ if (!packName) {
157
+ throw new Error("invalid_pack_name");
158
+ }
159
+ const normalizedSessionId = typeof sessionId === "string" ? sessionId.trim() : "";
160
+ const normalizedMediaKey = typeof mediaKey === "string" ? mediaKey.trim() : "";
161
+ if (!normalizedSessionId) {
162
+ throw new Error("invalid_pack_upload_session_id");
163
+ }
164
+ if (!normalizedMediaKey) {
165
+ throw new Error("invalid_pack_upload_media_key");
166
+ }
167
+ const form = buildAssetPackSessionMediaUploadForm(options);
168
+ const base = resolveBaseUrl();
169
+ const path = `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/media/${encodeURIComponent(normalizedMediaKey)}`;
170
+ const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
171
+ const response = await fetchImpl(resolveUrl(base, path), {
172
+ method: "POST",
173
+ headers,
174
+ body: form,
175
+ ...(0, import_request.buildBrowserCredentialsInit)(includeBrowserCredentials)
176
+ });
177
+ const parsed = await parseResponseBody(response);
178
+ const apiResponse = { status: response.status, body: parsed, headers: response.headers };
179
+ if (response.status !== 200 && response.status !== 201) {
180
+ handleApiError(apiResponse, "upload_asset_pack_session_media");
181
+ }
182
+ return parsed;
183
+ },
184
+ async finalizeAssetPackUpload(creatorUsername, name, sessionId) {
185
+ const packName = typeof name === "string" ? name.trim() : "";
186
+ if (!packName) {
187
+ throw new Error("invalid_pack_name");
188
+ }
189
+ const normalizedSessionId = typeof sessionId === "string" ? sessionId.trim() : "";
190
+ if (!normalizedSessionId) {
191
+ throw new Error("invalid_pack_upload_session_id");
192
+ }
193
+ const response = await request({
194
+ method: "POST",
195
+ path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/finalize`
196
+ });
197
+ if (response.status !== 200 && response.status !== 201) {
198
+ handleApiError(response, "finalize_asset_pack_upload");
199
+ }
200
+ return response.body;
201
+ },
202
+ async abortAssetPackUpload(creatorUsername, name, sessionId) {
203
+ const packName = typeof name === "string" ? name.trim() : "";
204
+ if (!packName) {
205
+ throw new Error("invalid_pack_name");
206
+ }
207
+ const normalizedSessionId = typeof sessionId === "string" ? sessionId.trim() : "";
208
+ if (!normalizedSessionId) {
209
+ throw new Error("invalid_pack_upload_session_id");
210
+ }
211
+ const response = await request({
212
+ method: "POST",
213
+ path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/abort`
214
+ });
215
+ if (response.status !== 200) {
216
+ handleApiError(response, "abort_asset_pack_upload");
217
+ }
218
+ return response.body;
219
+ },
220
+ async fetchAssetPackRelated(creatorUsername, packName) {
221
+ return fetchAssetPackRelatedRequest(request, handleApiError, normalizeCreatorItemSlug, creatorUsername, packName);
222
+ }
223
+ };
206
224
  }
207
225
  function buildAssetPackReadWriteMethods(input) {
208
- const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, buildCreatorAssetPackMutationPath, normalizeCreatorItemSlug, normalizeSemverInput, parseContentDispositionFilename, } = input;
209
- return {
210
- async listAssetPacks(options = {}) {
211
- const params = new URLSearchParams();
212
- if (typeof options.limit === 'number') {
213
- params.set('limit', String(options.limit));
214
- }
215
- if (typeof options.offset === 'number') {
216
- params.set('offset', String(options.offset));
217
- }
218
- if (typeof options.containsCategory === 'string' && options.containsCategory.trim().length > 0) {
219
- params.set('containsCategory', options.containsCategory.trim());
220
- }
221
- if (typeof options.containsSubcategory === 'string' && options.containsSubcategory.trim().length > 0) {
222
- params.set('containsSubcategory', options.containsSubcategory.trim());
223
- }
224
- appendNormalizedTagParams(params, options.tags);
225
- const query = params.toString();
226
- const path = `/asset-packs${query ? `?${query}` : ''}`;
227
- const response = await request({
228
- method: 'GET',
229
- path,
230
- });
231
- if (response.status !== 200) {
232
- handleApiError(response, 'list_asset_packs');
233
- }
234
- return response.body;
235
- },
236
- async listAssetPacksForCreator(creatorUsername, options = {}) {
237
- const params = new URLSearchParams();
238
- if (typeof options.limit === 'number') {
239
- params.set('limit', String(options.limit));
240
- }
241
- if (typeof options.offset === 'number') {
242
- params.set('offset', String(options.offset));
243
- }
244
- if (typeof options.containsCategory === 'string' && options.containsCategory.trim().length > 0) {
245
- params.set('containsCategory', options.containsCategory.trim());
246
- }
247
- if (typeof options.containsSubcategory === 'string' && options.containsSubcategory.trim().length > 0) {
248
- params.set('containsSubcategory', options.containsSubcategory.trim());
249
- }
250
- appendNormalizedTagParams(params, options.tags);
251
- const query = params.toString();
252
- const path = `/creators/${encodeURIComponent(creatorUsername)}/asset-packs${query ? `?${query}` : ''}`;
253
- const response = await request({
254
- method: 'GET',
255
- path,
256
- });
257
- if (response.status !== 200) {
258
- handleApiError(response, 'list_asset_packs_for_creator');
259
- }
260
- return response.body;
261
- },
262
- async fetchAssetPackBySlug(creatorUsername, packName) {
263
- const path = `/asset-packs/${encodeURIComponent(creatorUsername)}/${encodeURIComponent(packName)}`;
264
- const response = await request({
265
- method: 'GET',
266
- path,
267
- });
268
- if (response.status !== 200) {
269
- handleApiError(response, 'fetch_asset_pack_by_slug');
270
- }
271
- return response.body;
272
- },
273
- async downloadAssetPackSource(creatorUsername, packName, version) {
274
- const creator = typeof creatorUsername === 'string' ? creatorUsername.trim() : '';
275
- const name = typeof packName === 'string' ? packName.trim() : '';
276
- if (!creator || !name) {
277
- throw new Error('invalid_pack_key');
278
- }
279
- const normalizedVersion = normalizeSemverInput(version);
280
- const path = buildAssetPackVersionPath(normalizeCreatorItemSlug, normalizeSemverInput, creator, name, normalizedVersion, '/source');
281
- const base = resolveBaseUrl();
282
- const headers = new Headers();
283
- for (const [key, value] of Object.entries(getClientHeaders())) {
284
- headers.set(key, value);
285
- }
286
- const token = await resolveToken();
287
- if (token) {
288
- headers.set('authorization', `Bearer ${token}`);
289
- }
290
- const response = await fetchImpl(resolveUrl(base, path), {
291
- method: 'GET',
292
- headers,
293
- ...buildBrowserCredentialsInit(includeBrowserCredentials),
294
- });
295
- if (!response.ok) {
296
- const parsed = await parseResponseBody(response);
297
- handleApiError({ status: response.status, body: parsed, headers: response.headers }, 'download_asset_pack_source');
298
- }
299
- const blob = await response.blob();
300
- const filename = parseContentDispositionFilename(response.headers.get('content-disposition'))
301
- ?? `${name}-${normalizedVersion}-source.zip`;
302
- const headerSize = response.headers.get('content-length');
303
- const parsedSize = headerSize ? Number.parseInt(headerSize, 10) : Number.NaN;
304
- const checksumHeader = response.headers.get('x-pack-source-checksum');
305
- return {
306
- blob,
307
- metadata: {
308
- filename,
309
- sizeBytes: Number.isFinite(parsedSize) && parsedSize >= 0 ? parsedSize : blob.size,
310
- checksum: checksumHeader ?? null,
311
- },
312
- };
313
- },
314
- async downloadAssetPack(creatorUsername, packName, version) {
315
- const creator = typeof creatorUsername === 'string' ? creatorUsername.trim() : '';
316
- const name = typeof packName === 'string' ? packName.trim() : '';
317
- if (!creator || !name) {
318
- throw new Error('invalid_pack_key');
319
- }
320
- const normalizedVersion = normalizeSemverInput(version);
321
- const path = buildAssetPackVersionPath(normalizeCreatorItemSlug, normalizeSemverInput, creator, name, normalizedVersion, '/download');
322
- const base = resolveBaseUrl();
323
- const headers = new Headers();
324
- for (const [key, value] of Object.entries(getClientHeaders())) {
325
- headers.set(key, value);
326
- }
327
- const token = await resolveToken();
328
- if (token) {
329
- headers.set('authorization', `Bearer ${token}`);
330
- }
331
- const response = await fetchImpl(resolveUrl(base, path), {
332
- method: 'GET',
333
- headers,
334
- ...buildBrowserCredentialsInit(includeBrowserCredentials),
335
- });
336
- if (!response.ok) {
337
- const parsed = await parseResponseBody(response);
338
- handleApiError({ status: response.status, body: parsed, headers: response.headers }, 'download_asset_pack');
339
- }
340
- const blob = await response.blob();
341
- const filename = parseContentDispositionFilename(response.headers.get('content-disposition'))
342
- ?? `${name}-${normalizedVersion}.zip`;
343
- const headerSize = response.headers.get('content-length');
344
- const parsedSize = headerSize ? Number.parseInt(headerSize, 10) : Number.NaN;
345
- const checksumHeader = response.headers.get('x-pack-source-checksum');
346
- return {
347
- blob,
348
- metadata: {
349
- filename,
350
- sizeBytes: Number.isFinite(parsedSize) && parsedSize >= 0 ? parsedSize : blob.size,
351
- checksum: checksumHeader ?? null,
352
- },
353
- };
354
- },
355
- async listAssetPackVersions(creatorUsername, packName, options = {}) {
356
- const params = new URLSearchParams();
357
- if (typeof options.limit === 'number') {
358
- params.set('limit', String(options.limit));
359
- }
360
- if (typeof options.offset === 'number') {
361
- params.set('offset', String(options.offset));
362
- }
363
- const query = params.toString();
364
- const path = `/asset-packs/${encodeURIComponent(creatorUsername)}/${encodeURIComponent(packName)}/versions${query ? `?${query}` : ''}`;
365
- const response = await request({
366
- method: 'GET',
367
- path,
368
- });
369
- if (response.status !== 200) {
370
- handleApiError(response, 'list_asset_pack_versions');
371
- }
372
- return response.body;
373
- },
374
- async updateAssetPack(creatorUsername, name, requestBody) {
375
- const packName = typeof name === 'string' ? name.trim() : '';
376
- if (!packName) {
377
- throw new Error('invalid_pack_name');
378
- }
379
- const response = await request({
380
- method: 'PATCH',
381
- path: buildCreatorAssetPackMutationPath(creatorUsername, packName),
382
- body: requestBody,
383
- });
384
- if (response.status !== 200) {
385
- handleApiError(response, 'update_asset_pack');
386
- }
387
- return response.body;
388
- },
389
- async updateAssetPackVersion(creatorUsername, name, version, requestBody) {
390
- const packName = typeof name === 'string' ? name.trim() : '';
391
- const versionValue = typeof version === 'string' ? version.trim() : '';
392
- if (!packName) {
393
- throw new Error('invalid_pack_name');
394
- }
395
- if (!versionValue) {
396
- throw new Error('invalid_pack_version');
397
- }
398
- const response = await request({
399
- method: 'PATCH',
400
- path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/versions/${encodeURIComponent(versionValue)}`,
401
- body: requestBody,
402
- });
403
- if (response.status !== 200) {
404
- handleApiError(response, 'update_asset_pack_version');
405
- }
406
- return response.body;
407
- },
408
- async deleteAssetPackVersion(creatorUsername, name, version) {
409
- const packName = typeof name === 'string' ? name.trim() : '';
410
- const versionValue = typeof version === 'string' ? version.trim() : '';
411
- if (!packName) {
412
- throw new Error('invalid_pack_name');
413
- }
414
- if (!versionValue) {
415
- throw new Error('invalid_pack_version');
416
- }
417
- const response = await request({
418
- method: 'DELETE',
419
- path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/versions/${encodeURIComponent(versionValue)}`,
420
- });
421
- if (response.status !== 200) {
422
- handleApiError(response, 'delete_asset_pack_version');
423
- }
424
- return response.body;
425
- },
426
- async deleteAssetPack(creatorUsername, name) {
427
- const packName = typeof name === 'string' ? name.trim() : '';
428
- if (!packName) {
429
- throw new Error('invalid_pack_name');
430
- }
431
- const response = await request({
432
- method: 'DELETE',
433
- path: buildCreatorAssetPackMutationPath(creatorUsername, packName),
434
- });
435
- if (response.status !== 200) {
436
- handleApiError(response, 'delete_asset_pack');
437
- }
438
- return response.body;
439
- },
440
- };
226
+ const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, buildCreatorAssetPackMutationPath, normalizeCreatorItemSlug, normalizeSemverInput, parseContentDispositionFilename } = input;
227
+ return {
228
+ async listAssetPacks(options = {}) {
229
+ const params = new URLSearchParams();
230
+ if (typeof options.limit === "number") {
231
+ params.set("limit", String(options.limit));
232
+ }
233
+ if (typeof options.offset === "number") {
234
+ params.set("offset", String(options.offset));
235
+ }
236
+ if (typeof options.containsCategory === "string" && options.containsCategory.trim().length > 0) {
237
+ params.set("containsCategory", options.containsCategory.trim());
238
+ }
239
+ if (typeof options.containsSubcategory === "string" && options.containsSubcategory.trim().length > 0) {
240
+ params.set("containsSubcategory", options.containsSubcategory.trim());
241
+ }
242
+ appendNormalizedTagParams(params, options.tags);
243
+ const query = params.toString();
244
+ const path = `/asset-packs${query ? `?${query}` : ""}`;
245
+ const response = await request({
246
+ method: "GET",
247
+ path
248
+ });
249
+ if (response.status !== 200) {
250
+ handleApiError(response, "list_asset_packs");
251
+ }
252
+ return response.body;
253
+ },
254
+ async listAssetPacksForCreator(creatorUsername, options = {}) {
255
+ const params = new URLSearchParams();
256
+ if (typeof options.limit === "number") {
257
+ params.set("limit", String(options.limit));
258
+ }
259
+ if (typeof options.offset === "number") {
260
+ params.set("offset", String(options.offset));
261
+ }
262
+ if (typeof options.containsCategory === "string" && options.containsCategory.trim().length > 0) {
263
+ params.set("containsCategory", options.containsCategory.trim());
264
+ }
265
+ if (typeof options.containsSubcategory === "string" && options.containsSubcategory.trim().length > 0) {
266
+ params.set("containsSubcategory", options.containsSubcategory.trim());
267
+ }
268
+ appendNormalizedTagParams(params, options.tags);
269
+ const query = params.toString();
270
+ const path = `/creators/${encodeURIComponent(creatorUsername)}/asset-packs${query ? `?${query}` : ""}`;
271
+ const response = await request({
272
+ method: "GET",
273
+ path
274
+ });
275
+ if (response.status !== 200) {
276
+ handleApiError(response, "list_asset_packs_for_creator");
277
+ }
278
+ return response.body;
279
+ },
280
+ async fetchAssetPackBySlug(creatorUsername, packName) {
281
+ const path = `/asset-packs/${encodeURIComponent(creatorUsername)}/${encodeURIComponent(packName)}`;
282
+ const response = await request({
283
+ method: "GET",
284
+ path
285
+ });
286
+ if (response.status !== 200) {
287
+ handleApiError(response, "fetch_asset_pack_by_slug");
288
+ }
289
+ return response.body;
290
+ },
291
+ async downloadAssetPackSource(creatorUsername, packName, version) {
292
+ const creator = typeof creatorUsername === "string" ? creatorUsername.trim() : "";
293
+ const name = typeof packName === "string" ? packName.trim() : "";
294
+ if (!creator || !name) {
295
+ throw new Error("invalid_pack_key");
296
+ }
297
+ const normalizedVersion = normalizeSemverInput(version);
298
+ const path = buildAssetPackVersionPath(normalizeCreatorItemSlug, normalizeSemverInput, creator, name, normalizedVersion, "/source");
299
+ const base = resolveBaseUrl();
300
+ const headers = new Headers();
301
+ for (const [key, value] of Object.entries(getClientHeaders())) {
302
+ headers.set(key, value);
303
+ }
304
+ const token = await resolveToken();
305
+ if (token) {
306
+ headers.set("authorization", `Bearer ${token}`);
307
+ }
308
+ const response = await fetchImpl(resolveUrl(base, path), {
309
+ method: "GET",
310
+ headers,
311
+ ...(0, import_request.buildBrowserCredentialsInit)(includeBrowserCredentials)
312
+ });
313
+ if (!response.ok) {
314
+ const parsed = await parseResponseBody(response);
315
+ handleApiError({ status: response.status, body: parsed, headers: response.headers }, "download_asset_pack_source");
316
+ }
317
+ const blob = await response.blob();
318
+ const filename = parseContentDispositionFilename(response.headers.get("content-disposition")) ?? `${name}-${normalizedVersion}-source.zip`;
319
+ const headerSize = response.headers.get("content-length");
320
+ const parsedSize = headerSize ? Number.parseInt(headerSize, 10) : Number.NaN;
321
+ const checksumHeader = response.headers.get("x-pack-source-checksum");
322
+ return {
323
+ blob,
324
+ metadata: {
325
+ filename,
326
+ sizeBytes: Number.isFinite(parsedSize) && parsedSize >= 0 ? parsedSize : blob.size,
327
+ checksum: checksumHeader ?? null
328
+ }
329
+ };
330
+ },
331
+ async downloadAssetPack(creatorUsername, packName, version) {
332
+ const creator = typeof creatorUsername === "string" ? creatorUsername.trim() : "";
333
+ const name = typeof packName === "string" ? packName.trim() : "";
334
+ if (!creator || !name) {
335
+ throw new Error("invalid_pack_key");
336
+ }
337
+ const normalizedVersion = normalizeSemverInput(version);
338
+ const path = buildAssetPackVersionPath(normalizeCreatorItemSlug, normalizeSemverInput, creator, name, normalizedVersion, "/download");
339
+ const base = resolveBaseUrl();
340
+ const headers = new Headers();
341
+ for (const [key, value] of Object.entries(getClientHeaders())) {
342
+ headers.set(key, value);
343
+ }
344
+ const token = await resolveToken();
345
+ if (token) {
346
+ headers.set("authorization", `Bearer ${token}`);
347
+ }
348
+ const response = await fetchImpl(resolveUrl(base, path), {
349
+ method: "GET",
350
+ headers,
351
+ ...(0, import_request.buildBrowserCredentialsInit)(includeBrowserCredentials)
352
+ });
353
+ if (!response.ok) {
354
+ const parsed = await parseResponseBody(response);
355
+ handleApiError({ status: response.status, body: parsed, headers: response.headers }, "download_asset_pack");
356
+ }
357
+ const blob = await response.blob();
358
+ const filename = parseContentDispositionFilename(response.headers.get("content-disposition")) ?? `${name}-${normalizedVersion}.zip`;
359
+ const headerSize = response.headers.get("content-length");
360
+ const parsedSize = headerSize ? Number.parseInt(headerSize, 10) : Number.NaN;
361
+ const checksumHeader = response.headers.get("x-pack-source-checksum");
362
+ return {
363
+ blob,
364
+ metadata: {
365
+ filename,
366
+ sizeBytes: Number.isFinite(parsedSize) && parsedSize >= 0 ? parsedSize : blob.size,
367
+ checksum: checksumHeader ?? null
368
+ }
369
+ };
370
+ },
371
+ async listAssetPackVersions(creatorUsername, packName, options = {}) {
372
+ const params = new URLSearchParams();
373
+ if (typeof options.limit === "number") {
374
+ params.set("limit", String(options.limit));
375
+ }
376
+ if (typeof options.offset === "number") {
377
+ params.set("offset", String(options.offset));
378
+ }
379
+ const query = params.toString();
380
+ const path = `/asset-packs/${encodeURIComponent(creatorUsername)}/${encodeURIComponent(packName)}/versions${query ? `?${query}` : ""}`;
381
+ const response = await request({
382
+ method: "GET",
383
+ path
384
+ });
385
+ if (response.status !== 200) {
386
+ handleApiError(response, "list_asset_pack_versions");
387
+ }
388
+ return response.body;
389
+ },
390
+ async updateAssetPack(creatorUsername, name, requestBody) {
391
+ const packName = typeof name === "string" ? name.trim() : "";
392
+ if (!packName) {
393
+ throw new Error("invalid_pack_name");
394
+ }
395
+ const response = await request({
396
+ method: "PATCH",
397
+ path: buildCreatorAssetPackMutationPath(creatorUsername, packName),
398
+ body: requestBody
399
+ });
400
+ if (response.status !== 200) {
401
+ handleApiError(response, "update_asset_pack");
402
+ }
403
+ return response.body;
404
+ },
405
+ async updateAssetPackVersion(creatorUsername, name, version, requestBody) {
406
+ const packName = typeof name === "string" ? name.trim() : "";
407
+ const versionValue = typeof version === "string" ? version.trim() : "";
408
+ if (!packName) {
409
+ throw new Error("invalid_pack_name");
410
+ }
411
+ if (!versionValue) {
412
+ throw new Error("invalid_pack_version");
413
+ }
414
+ const response = await request({
415
+ method: "PATCH",
416
+ path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/versions/${encodeURIComponent(versionValue)}`,
417
+ body: requestBody
418
+ });
419
+ if (response.status !== 200) {
420
+ handleApiError(response, "update_asset_pack_version");
421
+ }
422
+ return response.body;
423
+ },
424
+ async deleteAssetPackVersion(creatorUsername, name, version) {
425
+ const packName = typeof name === "string" ? name.trim() : "";
426
+ const versionValue = typeof version === "string" ? version.trim() : "";
427
+ if (!packName) {
428
+ throw new Error("invalid_pack_name");
429
+ }
430
+ if (!versionValue) {
431
+ throw new Error("invalid_pack_version");
432
+ }
433
+ const response = await request({
434
+ method: "DELETE",
435
+ path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/versions/${encodeURIComponent(versionValue)}`
436
+ });
437
+ if (response.status !== 200) {
438
+ handleApiError(response, "delete_asset_pack_version");
439
+ }
440
+ return response.body;
441
+ },
442
+ async deleteAssetPack(creatorUsername, name) {
443
+ const packName = typeof name === "string" ? name.trim() : "";
444
+ if (!packName) {
445
+ throw new Error("invalid_pack_name");
446
+ }
447
+ const response = await request({
448
+ method: "DELETE",
449
+ path: buildCreatorAssetPackMutationPath(creatorUsername, packName)
450
+ });
451
+ if (response.status !== 200) {
452
+ handleApiError(response, "delete_asset_pack");
453
+ }
454
+ return response.body;
455
+ }
456
+ };
441
457
  }
458
+ // Annotate the CommonJS export names for ESM import in node:
459
+ 0 && (module.exports = {
460
+ buildAssetPacksApiClientMethods
461
+ });