@playdrop/playdrop-cli 0.3.4-build.1 → 0.3.5-build.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +60 -23
  2. package/config/client-meta.json +5 -5
  3. package/dist/apps/upload.js +5 -3
  4. package/dist/assets/model-artifacts.js +1 -1
  5. package/dist/catalogue.d.ts +6 -0
  6. package/dist/catalogue.js +38 -1
  7. package/dist/commandContext.d.ts +1 -0
  8. package/dist/commandContext.js +45 -15
  9. package/dist/commands/browse.d.ts +16 -0
  10. package/dist/commands/browse.js +370 -0
  11. package/dist/commands/build.js +4 -9
  12. package/dist/commands/capture.js +24 -24
  13. package/dist/commands/captureRemote.d.ts +11 -0
  14. package/dist/commands/captureRemote.js +90 -0
  15. package/dist/commands/comments.d.ts +14 -0
  16. package/dist/commands/comments.js +189 -0
  17. package/dist/commands/create.js +112 -72
  18. package/dist/commands/creations.d.ts +49 -0
  19. package/dist/commands/creations.js +657 -0
  20. package/dist/commands/credits.d.ts +10 -0
  21. package/dist/commands/credits.js +91 -0
  22. package/dist/commands/detail.d.ts +2 -2
  23. package/dist/commands/detail.js +148 -290
  24. package/dist/commands/dev.js +24 -24
  25. package/dist/commands/devShared.js +2 -2
  26. package/dist/commands/documentation.d.ts +4 -1
  27. package/dist/commands/documentation.js +79 -104
  28. package/dist/commands/feedback.d.ts +12 -9
  29. package/dist/commands/feedback.js +125 -257
  30. package/dist/commands/format.js +6 -13
  31. package/dist/commands/generation.d.ts +11 -0
  32. package/dist/commands/generation.js +204 -42
  33. package/dist/commands/gettingStarted.d.ts +1 -0
  34. package/dist/commands/gettingStarted.js +26 -0
  35. package/dist/commands/init.js +26 -24
  36. package/dist/commands/login.js +9 -8
  37. package/dist/commands/logout.js +2 -1
  38. package/dist/commands/notifications.d.ts +14 -0
  39. package/dist/commands/notifications.js +179 -0
  40. package/dist/commands/search.d.ts +13 -0
  41. package/dist/commands/search.js +198 -0
  42. package/dist/commands/upload.js +20 -17
  43. package/dist/commands/validate.js +15 -1
  44. package/dist/commands/versionsBrowse.d.ts +7 -0
  45. package/dist/commands/versionsBrowse.js +209 -0
  46. package/dist/commands/whoami.js +9 -8
  47. package/dist/errors.d.ts +9 -0
  48. package/dist/errors.js +52 -0
  49. package/dist/externalAssetPackValidation.d.ts +2 -0
  50. package/dist/externalAssetPackValidation.js +115 -0
  51. package/dist/http.js +1 -1
  52. package/dist/index.js +570 -630
  53. package/dist/messages.js +11 -11
  54. package/dist/output.d.ts +5 -0
  55. package/dist/output.js +45 -0
  56. package/dist/playwright.js +1 -1
  57. package/dist/refs.d.ts +18 -0
  58. package/dist/refs.js +105 -0
  59. package/node_modules/@playdrop/ai-client/dist/index.d.ts +42 -15
  60. package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +1 -1
  61. package/node_modules/@playdrop/ai-client/package.json +1 -0
  62. package/node_modules/@playdrop/api-client/dist/client.d.ts +39 -27
  63. package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
  64. package/node_modules/@playdrop/api-client/dist/client.js +280 -1669
  65. package/node_modules/@playdrop/api-client/dist/core/errors.d.ts +9 -0
  66. package/node_modules/@playdrop/api-client/dist/core/errors.d.ts.map +1 -0
  67. package/node_modules/@playdrop/api-client/dist/core/errors.js +46 -0
  68. package/node_modules/@playdrop/api-client/dist/core/request.d.ts +27 -0
  69. package/node_modules/@playdrop/api-client/dist/core/request.d.ts.map +1 -0
  70. package/node_modules/@playdrop/api-client/dist/core/request.js +122 -0
  71. package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts +75 -0
  72. package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts.map +1 -0
  73. package/node_modules/@playdrop/api-client/dist/domains/admin.js +282 -0
  74. package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts +22 -0
  75. package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts.map +1 -0
  76. package/node_modules/@playdrop/api-client/dist/domains/ai.js +15 -0
  77. package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +60 -0
  78. package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -0
  79. package/node_modules/@playdrop/api-client/dist/domains/apps.js +301 -0
  80. package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts +59 -0
  81. package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts.map +1 -0
  82. package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +297 -0
  83. package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +62 -0
  84. package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -0
  85. package/node_modules/@playdrop/api-client/dist/domains/assets.js +297 -0
  86. package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts +28 -0
  87. package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts.map +1 -0
  88. package/node_modules/@playdrop/api-client/dist/domains/auth.js +78 -0
  89. package/node_modules/@playdrop/api-client/dist/domains/comments.d.ts +29 -0
  90. package/node_modules/@playdrop/api-client/dist/domains/comments.d.ts.map +1 -0
  91. package/node_modules/@playdrop/api-client/dist/domains/comments.js +65 -0
  92. package/node_modules/@playdrop/api-client/dist/domains/me.d.ts +24 -0
  93. package/node_modules/@playdrop/api-client/dist/domains/me.d.ts.map +1 -0
  94. package/node_modules/@playdrop/api-client/dist/domains/me.js +35 -0
  95. package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts +37 -0
  96. package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts.map +1 -0
  97. package/node_modules/@playdrop/api-client/dist/domains/payments.js +148 -0
  98. package/node_modules/@playdrop/api-client/dist/domains/search.d.ts +27 -0
  99. package/node_modules/@playdrop/api-client/dist/domains/search.d.ts.map +1 -0
  100. package/node_modules/@playdrop/api-client/dist/domains/search.js +65 -0
  101. package/node_modules/@playdrop/api-client/dist/index.d.ts +33 -56
  102. package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
  103. package/node_modules/@playdrop/api-client/dist/index.js +103 -44
  104. package/node_modules/@playdrop/api-client/package.json +3 -2
  105. package/node_modules/@playdrop/boxel-core/package.json +1 -1
  106. package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +1 -1
  107. package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +1 -1
  108. package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +1 -1
  109. package/node_modules/@playdrop/boxel-three/package.json +2 -1
  110. package/node_modules/@playdrop/config/client-meta.json +5 -5
  111. package/node_modules/@playdrop/config/dist/src/constants.d.ts +5 -0
  112. package/node_modules/@playdrop/config/dist/src/constants.d.ts.map +1 -1
  113. package/node_modules/@playdrop/config/dist/src/constants.js +5 -1
  114. package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
  115. package/node_modules/@playdrop/config/package.json +1 -1
  116. package/node_modules/@playdrop/types/dist/api.d.ts +178 -17
  117. package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
  118. package/node_modules/@playdrop/types/dist/api.js +30 -1
  119. package/node_modules/@playdrop/types/dist/app.d.ts +0 -14
  120. package/node_modules/@playdrop/types/dist/app.d.ts.map +1 -1
  121. package/node_modules/@playdrop/types/dist/app.js +0 -10
  122. package/node_modules/@playdrop/types/dist/asset-pack.d.ts +11 -1
  123. package/node_modules/@playdrop/types/dist/asset-pack.d.ts.map +1 -1
  124. package/node_modules/@playdrop/types/dist/asset.d.ts +65 -0
  125. package/node_modules/@playdrop/types/dist/asset.d.ts.map +1 -1
  126. package/node_modules/@playdrop/types/dist/realtime.d.ts +26 -26
  127. package/node_modules/@playdrop/types/dist/realtime.d.ts.map +1 -1
  128. package/node_modules/@playdrop/types/dist/version.d.ts +5 -0
  129. package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
  130. package/package.json +2 -3
  131. package/bin/playdrop-cli +0 -2
  132. package/dist/commands/asset-packs.d.ts +0 -27
  133. package/dist/commands/asset-packs.js +0 -508
  134. package/dist/commands/assets.d.ts +0 -35
  135. package/dist/commands/assets.js +0 -668
  136. package/dist/commands/list.d.ts +0 -7
  137. package/dist/commands/list.js +0 -347
  138. package/dist/commands/migrateCatalogueV2.d.ts +0 -1
  139. package/dist/commands/migrateCatalogueV2.js +0 -142
  140. package/dist/commands/versions.d.ts +0 -17
  141. package/dist/commands/versions.js +0 -384
@@ -1,508 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.listAssetPackVersionsByKey = listAssetPackVersionsByKey;
7
- exports.downloadSource = downloadSource;
8
- exports.updateAssetPackByKey = updateAssetPackByKey;
9
- exports.setCurrentAssetPackVersion = setCurrentAssetPackVersion;
10
- exports.publishAssetPackVersion = publishAssetPackVersion;
11
- exports.unpublishAssetPackVersion = unpublishAssetPackVersion;
12
- exports.deleteAssetPackVersionByKey = deleteAssetPackVersionByKey;
13
- exports.deleteAssetPackByKey = deleteAssetPackByKey;
14
- const types_1 = require("@playdrop/types");
15
- const promises_1 = require("node:fs/promises");
16
- const node_path_1 = __importDefault(require("node:path"));
17
- const commandContext_1 = require("../commandContext");
18
- const messages_1 = require("../messages");
19
- const http_1 = require("../http");
20
- function isNetworkError(error) {
21
- if (!error || typeof error !== 'object') {
22
- return false;
23
- }
24
- const candidate = error;
25
- if (candidate instanceof TypeError) {
26
- return true;
27
- }
28
- const code = typeof candidate.code === 'string' ? candidate.code : undefined;
29
- if (code === 'ECONNREFUSED' || code === 'ENOTFOUND') {
30
- return true;
31
- }
32
- const cause = candidate.cause;
33
- if (cause && typeof cause === 'object' && typeof cause.code === 'string') {
34
- const nestedCode = cause.code;
35
- return nestedCode === 'ECONNREFUSED' || nestedCode === 'ENOTFOUND';
36
- }
37
- return false;
38
- }
39
- function parseFormat(raw) {
40
- if (!raw || raw.trim().length === 0) {
41
- return 'text';
42
- }
43
- const normalized = raw.trim().toLowerCase();
44
- if (normalized === 'text' || normalized === 'json') {
45
- return normalized;
46
- }
47
- return null;
48
- }
49
- function sanitizeSegment(value, label) {
50
- const cleaned = value.trim();
51
- if (!cleaned.length) {
52
- throw new Error(`invalid_${label}`);
53
- }
54
- if (cleaned.includes('..') || cleaned.includes('\\')) {
55
- throw new Error(`invalid_${label}`);
56
- }
57
- return cleaned;
58
- }
59
- function sanitizeFilename(value) {
60
- const cleaned = value
61
- .trim()
62
- .replace(/[\\/]+/g, '-')
63
- .replace(/[^A-Za-z0-9._-]+/g, '-')
64
- .replace(/^-+/, '')
65
- .replace(/-+$/, '');
66
- return cleaned.length > 0 ? cleaned : 'file';
67
- }
68
- function isSemver(value) {
69
- return /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value.trim());
70
- }
71
- function parsePackKey(raw) {
72
- const trimmed = raw.trim();
73
- if (!trimmed.length) {
74
- throw new Error('missing_pack_key');
75
- }
76
- const withoutPrefix = trimmed.startsWith('pack:') ? trimmed.slice('pack:'.length) : trimmed;
77
- const [base, versionPart] = withoutPrefix.split('@');
78
- const segments = base.split('/').map((segment) => segment.trim()).filter(Boolean);
79
- let creatorFromKey = null;
80
- let packName = '';
81
- if (segments.length === 1) {
82
- packName = segments[0];
83
- }
84
- else if (segments.length === 2) {
85
- creatorFromKey = segments[0];
86
- packName = segments[1];
87
- }
88
- else if (segments.length === 3 &&
89
- (segments[1].toLowerCase() === 'pack' || segments[1].toLowerCase() === 'packs' || segments[1].toLowerCase() === 'asset-pack' || segments[1].toLowerCase() === 'asset-packs')) {
90
- creatorFromKey = segments[0];
91
- packName = segments[2];
92
- }
93
- else {
94
- throw new Error('invalid_pack_key');
95
- }
96
- const parsed = {
97
- creatorFromKey: creatorFromKey ? sanitizeSegment(creatorFromKey, 'creator') : null,
98
- packName: sanitizeSegment(packName, 'pack_name'),
99
- };
100
- if (versionPart && versionPart.trim().length > 0) {
101
- const versionFromKey = versionPart.trim();
102
- if (!isSemver(versionFromKey)) {
103
- throw new Error('invalid_version');
104
- }
105
- parsed.versionFromKey = versionFromKey;
106
- }
107
- return parsed;
108
- }
109
- async function fetchCurrentUsername(client) {
110
- const response = await client.me();
111
- const username = response?.user?.username;
112
- if (typeof username === 'string' && username.trim().length > 0) {
113
- return username.trim();
114
- }
115
- return null;
116
- }
117
- async function resolvePackTarget(client, packRefOrKey, explicitCreator) {
118
- let parsed;
119
- try {
120
- parsed = parsePackKey(packRefOrKey);
121
- }
122
- catch (error) {
123
- return {
124
- error: `Invalid pack key: ${typeof error?.message === 'string' ? error.message : 'invalid_pack_key'}.`,
125
- };
126
- }
127
- let creatorUsername = null;
128
- const explicit = typeof explicitCreator === 'string' ? explicitCreator.trim() : '';
129
- if (explicit) {
130
- if (explicit.toLowerCase() === 'me') {
131
- creatorUsername = await fetchCurrentUsername(client);
132
- }
133
- else {
134
- creatorUsername = explicit;
135
- }
136
- }
137
- if (parsed.creatorFromKey) {
138
- if (creatorUsername && creatorUsername.toLowerCase() !== parsed.creatorFromKey.toLowerCase()) {
139
- return {
140
- error: `Creator mismatch between key "${parsed.creatorFromKey}" and --creator "${creatorUsername}".`,
141
- };
142
- }
143
- creatorUsername = parsed.creatorFromKey;
144
- }
145
- if (!creatorUsername) {
146
- creatorUsername = await fetchCurrentUsername(client);
147
- }
148
- if (!creatorUsername) {
149
- return { error: 'Could not determine creator username. Run "playdrop-cli login" or pass --creator.' };
150
- }
151
- return {
152
- creatorUsername,
153
- packName: parsed.packName,
154
- versionFromKey: parsed.versionFromKey,
155
- };
156
- }
157
- function printPackUsageError(error, command) {
158
- (0, messages_1.printErrorWithHelp)(error, [
159
- 'Use creator/name, creator/pack/name, or pack:creator/name.',
160
- 'Add --creator <username> when key does not include creator.',
161
- ], { command });
162
- process.exitCode = 1;
163
- }
164
- function formatDate(isoDate) {
165
- try {
166
- const date = new Date(isoDate);
167
- return date.toLocaleDateString('en-US', {
168
- year: 'numeric',
169
- month: 'short',
170
- day: 'numeric',
171
- hour: '2-digit',
172
- minute: '2-digit',
173
- });
174
- }
175
- catch {
176
- return isoDate;
177
- }
178
- }
179
- async function resolveOutputPath(out, fallbackFilename) {
180
- if (!out || out.trim().length === 0) {
181
- const root = node_path_1.default.resolve(process.cwd(), 'downloads');
182
- await (0, promises_1.mkdir)(root, { recursive: true });
183
- return node_path_1.default.join(root, fallbackFilename);
184
- }
185
- const trimmed = out.trim();
186
- const resolved = node_path_1.default.resolve(trimmed);
187
- try {
188
- const stats = await (0, promises_1.stat)(resolved);
189
- if (stats.isDirectory()) {
190
- return node_path_1.default.join(resolved, fallbackFilename);
191
- }
192
- return resolved;
193
- }
194
- catch {
195
- const looksLikeDirectory = trimmed.endsWith('/') || trimmed.endsWith('\\') || node_path_1.default.extname(trimmed) === '';
196
- if (looksLikeDirectory) {
197
- await (0, promises_1.mkdir)(resolved, { recursive: true });
198
- return node_path_1.default.join(resolved, fallbackFilename);
199
- }
200
- return resolved;
201
- }
202
- }
203
- function handlePackCommandError(error, command, actionLabel, apiErrorFormatter) {
204
- if (error instanceof http_1.CLIUnsupportedClientError) {
205
- return true;
206
- }
207
- if (error instanceof types_1.UnsupportedClientError) {
208
- (0, http_1.handleUnsupportedError)(error, actionLabel);
209
- return true;
210
- }
211
- if (error instanceof types_1.ApiError) {
212
- const message = apiErrorFormatter ? apiErrorFormatter(error) : `${actionLabel} failed (status ${error.status}): ${error.message}`;
213
- (0, messages_1.printErrorWithHelp)(message, ['Retry in a moment.'], { command });
214
- process.exitCode = 1;
215
- return true;
216
- }
217
- if (isNetworkError(error)) {
218
- (0, messages_1.printNetworkIssue)('Could not reach the Playdrop API.', command);
219
- process.exitCode = 1;
220
- return true;
221
- }
222
- return false;
223
- }
224
- async function listAssetPackVersionsByKey(packRefOrKey, options = {}) {
225
- const format = parseFormat(options.format);
226
- if (!format) {
227
- (0, messages_1.printErrorWithHelp)('The --format value is invalid.', ['Use --format text or --format json.'], {
228
- command: 'asset-packs versions list',
229
- });
230
- process.exitCode = 1;
231
- return;
232
- }
233
- await (0, commandContext_1.withEnvironment)('asset-packs versions list', 'Listing asset pack versions', async ({ client }) => {
234
- try {
235
- const target = await resolvePackTarget(client, packRefOrKey, options.creator);
236
- if ('error' in target) {
237
- printPackUsageError(target.error, 'asset-packs versions list');
238
- return;
239
- }
240
- const versions = [];
241
- const limit = 100;
242
- let offset = 0;
243
- while (true) {
244
- const response = await client.listAssetPackVersions(target.creatorUsername, target.packName, { limit, offset });
245
- versions.push(...response.versions);
246
- const hasMore = response.pagination ? Boolean(response.pagination.hasMore) : response.versions.length === limit;
247
- if (!hasMore) {
248
- break;
249
- }
250
- offset += limit;
251
- }
252
- if (format === 'json') {
253
- console.log(JSON.stringify({ versions }, null, 2));
254
- return;
255
- }
256
- if (versions.length === 0) {
257
- console.log(`No versions found for pack "${target.creatorUsername}/${target.packName}".`);
258
- return;
259
- }
260
- const detail = await client.fetchAssetPackBySlug(target.creatorUsername, target.packName);
261
- const currentVersion = detail.pack.currentVersion?.version ?? null;
262
- console.log(`Versions for ${target.creatorUsername}/${target.packName}:\n`);
263
- for (const version of versions) {
264
- const current = currentVersion === version.version ? ' [CURRENT]' : '';
265
- const visibility = version.visibility === 'PRIVATE' ? ' [PRIVATE]' : '';
266
- console.log(` ${version.version}${current}${visibility} (${formatDate(version.createdAt)})`);
267
- }
268
- }
269
- catch (error) {
270
- const handled = handlePackCommandError(error, 'asset-packs versions list', 'List asset pack versions', (apiError) => {
271
- if (apiError.status === 404) {
272
- return 'Asset pack not found.';
273
- }
274
- return `Request failed (status ${apiError.status}): ${apiError.message}`;
275
- });
276
- if (!handled) {
277
- throw error;
278
- }
279
- }
280
- });
281
- }
282
- async function downloadSource(packRefOrKey, options = {}) {
283
- const explicitVersion = typeof options.version === 'string' && options.version.trim().length > 0
284
- ? options.version.trim()
285
- : undefined;
286
- if (explicitVersion && !isSemver(explicitVersion)) {
287
- (0, messages_1.printErrorWithHelp)('The --version value is invalid.', ['Use semantic version values like 1.0.0.'], {
288
- command: 'asset-packs download-source',
289
- });
290
- process.exitCode = 1;
291
- return;
292
- }
293
- await (0, commandContext_1.withEnvironment)('asset-packs download-source', 'Downloading asset pack source bundle', async ({ client }) => {
294
- try {
295
- const target = await resolvePackTarget(client, packRefOrKey, options.creator);
296
- if ('error' in target) {
297
- printPackUsageError(target.error, 'asset-packs download-source');
298
- return;
299
- }
300
- if (explicitVersion && target.versionFromKey && explicitVersion !== target.versionFromKey) {
301
- (0, messages_1.printErrorWithHelp)(`Version mismatch between key "${target.versionFromKey}" and --version "${explicitVersion}".`, ['Use one version value only, either in the key or via --version.'], { command: 'asset-packs download-source' });
302
- process.exitCode = 1;
303
- return;
304
- }
305
- let resolvedVersion = explicitVersion || target.versionFromKey || null;
306
- if (!resolvedVersion) {
307
- const detail = await client.fetchAssetPackBySlug(target.creatorUsername, target.packName);
308
- resolvedVersion = detail.pack.currentVersion?.version ?? null;
309
- }
310
- if (!resolvedVersion) {
311
- (0, messages_1.printErrorWithHelp)('No version could be resolved for this pack.', ['Pass --version <x.y.z> or set a current version on the pack first.'], { command: 'asset-packs download-source' });
312
- process.exitCode = 1;
313
- return;
314
- }
315
- const source = await client.downloadAssetPackSource(target.creatorUsername, target.packName, resolvedVersion);
316
- const fallbackFilename = `${sanitizeFilename(target.packName)}-${resolvedVersion}-source.zip`;
317
- const selectedFilename = sanitizeFilename(source.metadata.filename || fallbackFilename);
318
- const outputPath = await resolveOutputPath(options.out, selectedFilename);
319
- const buffer = Buffer.from(await source.blob.arrayBuffer());
320
- await (0, promises_1.writeFile)(outputPath, buffer);
321
- const size = source.metadata.sizeBytes || buffer.length;
322
- console.log(`Downloaded source bundle to ${outputPath} (${size} bytes).`);
323
- }
324
- catch (error) {
325
- const handled = handlePackCommandError(error, 'asset-packs download-source', 'Download asset pack source', (apiError) => {
326
- if (apiError.status === 404) {
327
- return 'Asset pack or version not found.';
328
- }
329
- return `Request failed (status ${apiError.status}): ${apiError.message}`;
330
- });
331
- if (!handled) {
332
- throw error;
333
- }
334
- }
335
- });
336
- }
337
- async function updateAssetPackByKey(packRefOrKey, options = {}) {
338
- const request = {};
339
- if (typeof options.name === 'string' && options.name.trim().length > 0) {
340
- request.name = options.name.trim();
341
- }
342
- if (typeof options.displayName === 'string' && options.displayName.trim().length > 0) {
343
- request.displayName = options.displayName.trim();
344
- }
345
- if (options.clearDescription) {
346
- request.description = null;
347
- }
348
- else if (typeof options.description === 'string') {
349
- request.description = options.description;
350
- }
351
- if (options.clearPreviewAppVersionId) {
352
- request.previewAppVersionId = null;
353
- }
354
- else if (typeof options.previewAppVersionId === 'string' && options.previewAppVersionId.trim().length > 0) {
355
- const parsed = Number.parseInt(options.previewAppVersionId.trim(), 10);
356
- if (!Number.isInteger(parsed) || parsed <= 0) {
357
- (0, messages_1.printErrorWithHelp)('The --preview-app-version-id value is invalid.', ['Use a positive integer value.'], { command: 'asset-packs update' });
358
- process.exitCode = 1;
359
- return;
360
- }
361
- request.previewAppVersionId = parsed;
362
- }
363
- if (Object.keys(request).length === 0) {
364
- (0, messages_1.printErrorWithHelp)('No updates provided.', ['Use --name, --display-name, --description, --clear-description, --preview-app-version-id, or --clear-preview-app-version-id.'], { command: 'asset-packs update' });
365
- process.exitCode = 1;
366
- return;
367
- }
368
- await (0, commandContext_1.withEnvironment)('asset-packs update', 'Updating asset pack metadata', async ({ client }) => {
369
- try {
370
- const target = await resolvePackTarget(client, packRefOrKey, options.creator);
371
- if ('error' in target) {
372
- printPackUsageError(target.error, 'asset-packs update');
373
- return;
374
- }
375
- const response = await client.updateAssetPack(target.packName, request, {
376
- creatorUsername: target.creatorUsername,
377
- });
378
- console.log(`Updated pack ${response.pack.creatorUsername}/${response.pack.name}.`);
379
- }
380
- catch (error) {
381
- const handled = handlePackCommandError(error, 'asset-packs update', 'Update asset pack', (apiError) => {
382
- if (apiError.status === 404) {
383
- return 'Asset pack not found.';
384
- }
385
- if (apiError.status === 409) {
386
- return 'Asset pack name is already in use.';
387
- }
388
- return `Request failed (status ${apiError.status}): ${apiError.message}`;
389
- });
390
- if (!handled) {
391
- throw error;
392
- }
393
- }
394
- });
395
- }
396
- async function updateAssetPackVersionByKey(command, actionLabel, packRefOrKey, version, options, request) {
397
- const trimmedVersion = version.trim();
398
- if (!trimmedVersion) {
399
- (0, messages_1.printErrorWithHelp)('Version is required.', ['Use semantic version values like 1.0.0.'], { command });
400
- process.exitCode = 1;
401
- return;
402
- }
403
- await (0, commandContext_1.withEnvironment)(command, actionLabel, async ({ client }) => {
404
- try {
405
- const target = await resolvePackTarget(client, packRefOrKey, options.creator);
406
- if ('error' in target) {
407
- printPackUsageError(target.error, command);
408
- return;
409
- }
410
- const response = await client.updateAssetPackVersion(target.packName, trimmedVersion, request, {
411
- creatorUsername: target.creatorUsername,
412
- });
413
- console.log(`Updated ${target.creatorUsername}/${target.packName} ${response.version.version}.`);
414
- }
415
- catch (error) {
416
- const handled = handlePackCommandError(error, command, actionLabel, (apiError) => {
417
- if (apiError.status === 404) {
418
- return 'Asset pack or version not found.';
419
- }
420
- if (apiError.status === 400) {
421
- return `Validation failed: ${apiError.message}`;
422
- }
423
- return `Request failed (status ${apiError.status}): ${apiError.message}`;
424
- });
425
- if (!handled) {
426
- throw error;
427
- }
428
- }
429
- });
430
- }
431
- async function setCurrentAssetPackVersion(packRefOrKey, version, options = {}) {
432
- await updateAssetPackVersionByKey('asset-packs versions set-current', 'Setting current asset pack version', packRefOrKey, version, options, { setAsCurrent: true });
433
- }
434
- async function publishAssetPackVersion(packRefOrKey, version, options = {}) {
435
- await updateAssetPackVersionByKey('asset-packs versions publish', 'Publishing asset pack version', packRefOrKey, version, options, { visibility: 'PUBLIC' });
436
- }
437
- async function unpublishAssetPackVersion(packRefOrKey, version, options = {}) {
438
- await updateAssetPackVersionByKey('asset-packs versions unpublish', 'Unpublishing asset pack version', packRefOrKey, version, options, { visibility: 'PRIVATE' });
439
- }
440
- async function deleteAssetPackVersionByKey(packRefOrKey, version, options = {}) {
441
- const trimmedVersion = version.trim();
442
- if (!trimmedVersion) {
443
- (0, messages_1.printErrorWithHelp)('Version is required.', ['Use semantic version values like 1.0.0.'], {
444
- command: 'asset-packs versions delete',
445
- });
446
- process.exitCode = 1;
447
- return;
448
- }
449
- await (0, commandContext_1.withEnvironment)('asset-packs versions delete', 'Deleting asset pack version', async ({ client }) => {
450
- try {
451
- const target = await resolvePackTarget(client, packRefOrKey, options.creator);
452
- if ('error' in target) {
453
- printPackUsageError(target.error, 'asset-packs versions delete');
454
- return;
455
- }
456
- await client.deleteAssetPackVersion(target.packName, trimmedVersion, {
457
- creatorUsername: target.creatorUsername,
458
- });
459
- console.log(`Deleted ${target.creatorUsername}/${target.packName}@${trimmedVersion}.`);
460
- }
461
- catch (error) {
462
- const handled = handlePackCommandError(error, 'asset-packs versions delete', 'Delete asset pack version', (apiError) => {
463
- if (apiError.status === 404) {
464
- return 'Asset pack or version not found.';
465
- }
466
- if (apiError.status === 400) {
467
- return `Cannot delete version: ${apiError.message}`;
468
- }
469
- if (apiError.status === 409) {
470
- return `Cannot delete referenced version: ${apiError.message}`;
471
- }
472
- return `Request failed (status ${apiError.status}): ${apiError.message}`;
473
- });
474
- if (!handled) {
475
- throw error;
476
- }
477
- }
478
- });
479
- }
480
- async function deleteAssetPackByKey(packRefOrKey, options = {}) {
481
- await (0, commandContext_1.withEnvironment)('asset-packs delete', 'Deleting asset pack', async ({ client }) => {
482
- try {
483
- const target = await resolvePackTarget(client, packRefOrKey, options.creator);
484
- if ('error' in target) {
485
- printPackUsageError(target.error, 'asset-packs delete');
486
- return;
487
- }
488
- await client.deleteAssetPack(target.packName, {
489
- creatorUsername: target.creatorUsername,
490
- });
491
- console.log(`Deleted pack ${target.creatorUsername}/${target.packName}.`);
492
- }
493
- catch (error) {
494
- const handled = handlePackCommandError(error, 'asset-packs delete', 'Delete asset pack', (apiError) => {
495
- if (apiError.status === 404) {
496
- return 'Asset pack not found.';
497
- }
498
- if (apiError.status === 409) {
499
- return `Cannot delete referenced pack: ${apiError.message}`;
500
- }
501
- return `Request failed (status ${apiError.status}): ${apiError.message}`;
502
- });
503
- if (!handled) {
504
- throw error;
505
- }
506
- }
507
- });
508
- }
@@ -1,35 +0,0 @@
1
- type ClassesOptions = {
2
- format?: string;
3
- };
4
- type AssetMutationOptions = {
5
- creator?: string;
6
- };
7
- type AssetUpdateOptions = AssetMutationOptions & {
8
- name?: string;
9
- displayName?: string;
10
- description?: string;
11
- clearDescription?: boolean;
12
- };
13
- type AssetVersionsListOptions = AssetMutationOptions & {
14
- format?: string;
15
- };
16
- type AssetDownloadFileOptions = {
17
- revision?: string;
18
- role?: string;
19
- out?: string;
20
- };
21
- type AssetDownloadSourceOptions = {
22
- revision?: string;
23
- out?: string;
24
- };
25
- export declare function listCategories(options?: ClassesOptions): Promise<void>;
26
- export declare function listAssetVersionsByKey(assetRefOrKey: string, options?: AssetVersionsListOptions): Promise<void>;
27
- export declare function updateAssetByKey(assetRefOrKey: string, options?: AssetUpdateOptions): Promise<void>;
28
- export declare function setCurrentAssetVersion(assetRefOrKey: string, revisionRaw: string, options?: AssetMutationOptions): Promise<void>;
29
- export declare function publishAssetVersion(assetRefOrKey: string, revisionRaw: string, options?: AssetMutationOptions): Promise<void>;
30
- export declare function unpublishAssetVersion(assetRefOrKey: string, revisionRaw: string, options?: AssetMutationOptions): Promise<void>;
31
- export declare function deleteAssetVersionByKey(assetRefOrKey: string, revisionRaw: string, options?: AssetMutationOptions): Promise<void>;
32
- export declare function deleteAssetByKey(assetRefOrKey: string, options?: AssetMutationOptions): Promise<void>;
33
- export declare function downloadFile(assetRefOrKey: string, options?: AssetDownloadFileOptions): Promise<void>;
34
- export declare function downloadSource(assetRefOrKey: string, options?: AssetDownloadSourceOptions): Promise<void>;
35
- export {};