@playdrop/playdrop-cli 0.3.8-build.2 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/client-meta.json +5 -5
- package/dist/apps/build.js +45 -39
- package/dist/catalogue-utils.js +23 -18
- package/dist/catalogue.d.ts +0 -2
- package/dist/catalogue.js +54 -41
- package/dist/clientInfo.js +16 -2
- package/dist/commands/browse.js +66 -23
- package/dist/commands/capture.js +3 -2
- package/dist/commands/create.js +49 -46
- package/dist/commands/createRemixContent.js +29 -44
- package/dist/commands/creations.js +51 -13
- package/dist/commands/devServer.d.ts +1 -1
- package/dist/commands/devShared.js +1 -1
- package/dist/commands/generation.js +91 -74
- package/dist/commands/gettingStarted.js +1 -1
- package/dist/commands/search.js +29 -1
- package/dist/commands/upload-content.d.ts +70 -0
- package/dist/commands/upload-content.js +627 -0
- package/dist/commands/upload-graph.d.ts +23 -0
- package/dist/commands/upload-graph.js +108 -0
- package/dist/commands/upload.js +264 -543
- package/dist/http.d.ts +1 -1
- package/dist/playwright.d.ts +12 -4
- package/dist/proxyFetch.js +3 -2
- package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/ai-client/dist/index.js +74 -54
- package/node_modules/@playdrop/api-client/dist/client.d.ts +34 -14
- package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/client.js +6 -8
- package/node_modules/@playdrop/api-client/dist/core/errors.js +11 -11
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts +2 -0
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/core/request.js +10 -3
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts +12 -10
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/admin.js +33 -30
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +8 -1
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/apps.js +140 -124
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts +9 -5
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +151 -88
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +4 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.js +153 -112
- package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts +3 -1
- package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/auth.js +21 -0
- package/node_modules/@playdrop/api-client/dist/domains/me.d.ts +6 -2
- package/node_modules/@playdrop/api-client/dist/domains/me.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/me.js +13 -2
- package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/payments.js +10 -0
- package/node_modules/@playdrop/api-client/dist/index.d.ts +65 -24
- package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.js +38 -13
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js +2 -0
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js +95 -75
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.d.ts +2 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js +4 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.d.ts +5 -5
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/types.d.ts +25 -25
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js +2 -1
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js.map +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +5 -0
- package/node_modules/@playdrop/boxel-three/package.json +3 -3
- package/node_modules/@playdrop/config/client-meta.json +5 -5
- package/node_modules/@playdrop/config/dist/src/index.js +6 -6
- package/node_modules/@playdrop/config/dist/test/validateClientEnvironment.test.js +2 -2
- package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@playdrop/types/dist/api.d.ts +33 -8
- package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/api.js +16 -8
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts +107 -11
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset-pack.js +2 -0
- package/node_modules/@playdrop/types/dist/asset.d.ts +15 -0
- package/node_modules/@playdrop/types/dist/asset.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.js +1 -0
- package/node_modules/@playdrop/types/dist/ecs.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/ecs.js +10 -6
- package/node_modules/@playdrop/types/dist/entity.d.ts +5 -10
- package/node_modules/@playdrop/types/dist/entity.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/entity.js +40 -23
- package/node_modules/@playdrop/types/dist/graph.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/graph.js +13 -5
- package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/version.js +7 -3
- package/node_modules/@playdrop/vox-three/dist/src/vox.d.ts +1 -0
- package/node_modules/@playdrop/vox-three/dist/src/vox.js +15 -6
- package/node_modules/@playdrop/vox-three/dist/src/vox.js.map +1 -1
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js +16 -0
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js.map +1 -1
- package/node_modules/@playdrop/vox-three/package.json +3 -3
- package/package.json +1 -1
|
@@ -1,130 +1,192 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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}`;
|
|
6
|
+
}
|
|
7
|
+
async function buildAuthorizedHeaders(getClientHeaders, resolveToken) {
|
|
8
|
+
const headers = new Headers();
|
|
9
|
+
for (const [key, value] of Object.entries(getClientHeaders())) {
|
|
10
|
+
headers.set(key, value);
|
|
11
|
+
}
|
|
12
|
+
const token = await resolveToken();
|
|
13
|
+
if (token) {
|
|
14
|
+
headers.set('authorization', `Bearer ${token}`);
|
|
15
|
+
}
|
|
16
|
+
return headers;
|
|
17
|
+
}
|
|
18
|
+
function buildAssetPackSessionAssetUploadForm(options) {
|
|
19
|
+
if (!Array.isArray(options.files) || options.files.length === 0) {
|
|
20
|
+
throw new Error('missing_asset_files');
|
|
21
|
+
}
|
|
22
|
+
const form = new FormData();
|
|
23
|
+
for (const item of options.files) {
|
|
24
|
+
if (!item) {
|
|
25
|
+
throw new Error('missing_asset_upload_file');
|
|
26
|
+
}
|
|
27
|
+
const fieldName = typeof item.fieldName === 'string' && item.fieldName.trim().length > 0
|
|
28
|
+
? item.fieldName.trim()
|
|
29
|
+
: 'file';
|
|
30
|
+
if (typeof item.filename === 'string' && item.filename.trim().length > 0) {
|
|
31
|
+
form.append(fieldName, item.file, item.filename.trim());
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
form.append(fieldName, item.file);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return form;
|
|
38
|
+
}
|
|
39
|
+
function buildAssetPackSessionMediaUploadForm(options) {
|
|
40
|
+
if (!options?.file) {
|
|
41
|
+
throw new Error('missing_media_file');
|
|
42
|
+
}
|
|
43
|
+
const form = new FormData();
|
|
44
|
+
if (typeof options.filename === 'string' && options.filename.trim().length > 0) {
|
|
45
|
+
form.append('file', options.file, options.filename.trim());
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
form.append('file', options.file);
|
|
7
49
|
}
|
|
50
|
+
return form;
|
|
51
|
+
}
|
|
52
|
+
async function fetchAssetPackRelatedRequest(request, handleApiError, normalizeCreatorItemSlug, creatorUsername, packName) {
|
|
53
|
+
const response = await request({
|
|
54
|
+
method: 'GET',
|
|
55
|
+
path: buildPublicAssetPackPath(normalizeCreatorItemSlug, creatorUsername, packName, '/related'),
|
|
56
|
+
});
|
|
57
|
+
if (response.status !== 200) {
|
|
58
|
+
handleApiError(response, 'get_pack_related');
|
|
59
|
+
}
|
|
60
|
+
return response.body;
|
|
61
|
+
}
|
|
62
|
+
export function buildAssetPacksApiClientMethods(input) {
|
|
8
63
|
return {
|
|
9
|
-
|
|
64
|
+
...buildAssetPackUploadSessionMethods(input),
|
|
65
|
+
...buildAssetPackReadWriteMethods(input),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function buildAssetPackUploadSessionMethods(input) {
|
|
69
|
+
const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, buildCreatorAssetPackMutationPath, normalizeCreatorItemSlug, } = input;
|
|
70
|
+
return {
|
|
71
|
+
async initializeAssetPackUpload(creatorUsername, name, requestBody) {
|
|
10
72
|
const packName = typeof name === 'string' ? name.trim() : '';
|
|
11
73
|
if (!packName) {
|
|
12
74
|
throw new Error('invalid_pack_name');
|
|
13
75
|
}
|
|
14
76
|
const response = await request({
|
|
15
77
|
method: 'POST',
|
|
16
|
-
path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/
|
|
17
|
-
body,
|
|
78
|
+
path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions`,
|
|
79
|
+
body: requestBody,
|
|
18
80
|
});
|
|
19
|
-
if (response.status !==
|
|
20
|
-
handleApiError(response, '
|
|
81
|
+
if (response.status !== 200 && response.status !== 201) {
|
|
82
|
+
handleApiError(response, 'initialize_asset_pack_upload');
|
|
21
83
|
}
|
|
22
84
|
return response.body;
|
|
23
85
|
},
|
|
24
|
-
async
|
|
86
|
+
async uploadAssetPackSessionAsset(creatorUsername, name, sessionId, uploadKey, options) {
|
|
25
87
|
const packName = typeof name === 'string' ? name.trim() : '';
|
|
26
88
|
if (!packName) {
|
|
27
89
|
throw new Error('invalid_pack_name');
|
|
28
90
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const form = new FormData();
|
|
34
|
-
form.append('version', requestBody.version);
|
|
35
|
-
if (requestBody.visibility !== undefined) {
|
|
36
|
-
form.append('visibility', requestBody.visibility);
|
|
91
|
+
const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
|
|
92
|
+
const normalizedUploadKey = typeof uploadKey === 'string' ? uploadKey.trim() : '';
|
|
93
|
+
if (!normalizedSessionId) {
|
|
94
|
+
throw new Error('invalid_pack_upload_session_id');
|
|
37
95
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
96
|
+
if (!normalizedUploadKey) {
|
|
97
|
+
throw new Error('invalid_pack_upload_asset_key');
|
|
40
98
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
form
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
if (requestBody.previewAppVersionId !== undefined) {
|
|
57
|
-
form.append('previewAppVersionId', String(requestBody.previewAppVersionId));
|
|
58
|
-
}
|
|
59
|
-
if (requestBody.remixRef !== undefined) {
|
|
60
|
-
form.append('remixRef', requestBody.remixRef);
|
|
61
|
-
}
|
|
62
|
-
form.append('assets', JSON.stringify(requestBody.assets ?? []));
|
|
63
|
-
const relations = requestBody.relations;
|
|
64
|
-
if (Array.isArray(relations) && relations.length > 0) {
|
|
65
|
-
form.append('relations', JSON.stringify(relations));
|
|
66
|
-
}
|
|
67
|
-
if (options.icon) {
|
|
68
|
-
form.append('icon', options.icon);
|
|
69
|
-
}
|
|
70
|
-
if (options.heroPortrait) {
|
|
71
|
-
form.append('heroPortrait', options.heroPortrait);
|
|
72
|
-
}
|
|
73
|
-
if (options.heroLandscape) {
|
|
74
|
-
form.append('heroLandscape', options.heroLandscape);
|
|
75
|
-
}
|
|
76
|
-
if (options.screenshotsPortrait) {
|
|
77
|
-
for (const screenshot of options.screenshotsPortrait) {
|
|
78
|
-
form.append('screenshotsPortrait', screenshot);
|
|
79
|
-
}
|
|
99
|
+
const form = buildAssetPackSessionAssetUploadForm(options);
|
|
100
|
+
const base = resolveBaseUrl();
|
|
101
|
+
const path = `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/assets/${encodeURIComponent(normalizedUploadKey)}`;
|
|
102
|
+
const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
|
|
103
|
+
const response = await fetchImpl(resolveUrl(base, path), {
|
|
104
|
+
method: 'POST',
|
|
105
|
+
headers,
|
|
106
|
+
body: form,
|
|
107
|
+
...buildBrowserCredentialsInit(includeBrowserCredentials),
|
|
108
|
+
});
|
|
109
|
+
const parsed = await parseResponseBody(response);
|
|
110
|
+
const apiResponse = { status: response.status, body: parsed, headers: response.headers };
|
|
111
|
+
if (response.status !== 200 && response.status !== 201) {
|
|
112
|
+
handleApiError(apiResponse, 'upload_asset_pack_session_asset');
|
|
80
113
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
114
|
+
return parsed;
|
|
115
|
+
},
|
|
116
|
+
async uploadAssetPackSessionMedia(creatorUsername, name, sessionId, mediaKey, options) {
|
|
117
|
+
const packName = typeof name === 'string' ? name.trim() : '';
|
|
118
|
+
if (!packName) {
|
|
119
|
+
throw new Error('invalid_pack_name');
|
|
85
120
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
121
|
+
const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
|
|
122
|
+
const normalizedMediaKey = typeof mediaKey === 'string' ? mediaKey.trim() : '';
|
|
123
|
+
if (!normalizedSessionId) {
|
|
124
|
+
throw new Error('invalid_pack_upload_session_id');
|
|
90
125
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
form.append('videosLandscape', video);
|
|
94
|
-
}
|
|
126
|
+
if (!normalizedMediaKey) {
|
|
127
|
+
throw new Error('invalid_pack_upload_media_key');
|
|
95
128
|
}
|
|
96
|
-
const
|
|
129
|
+
const form = buildAssetPackSessionMediaUploadForm(options);
|
|
97
130
|
const base = resolveBaseUrl();
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
headers.set(key, value);
|
|
101
|
-
}
|
|
102
|
-
const token = await resolveToken();
|
|
103
|
-
if (token) {
|
|
104
|
-
headers.set('authorization', `Bearer ${token}`);
|
|
105
|
-
}
|
|
131
|
+
const path = `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/media/${encodeURIComponent(normalizedMediaKey)}`;
|
|
132
|
+
const headers = await buildAuthorizedHeaders(getClientHeaders, resolveToken);
|
|
106
133
|
const response = await fetchImpl(resolveUrl(base, path), {
|
|
107
134
|
method: 'POST',
|
|
108
135
|
headers,
|
|
109
136
|
body: form,
|
|
137
|
+
...buildBrowserCredentialsInit(includeBrowserCredentials),
|
|
110
138
|
});
|
|
111
139
|
const parsed = await parseResponseBody(response);
|
|
112
140
|
const apiResponse = { status: response.status, body: parsed, headers: response.headers };
|
|
113
|
-
if (response.status !==
|
|
114
|
-
handleApiError(apiResponse, '
|
|
141
|
+
if (response.status !== 200 && response.status !== 201) {
|
|
142
|
+
handleApiError(apiResponse, 'upload_asset_pack_session_media');
|
|
115
143
|
}
|
|
116
144
|
return parsed;
|
|
117
145
|
},
|
|
118
|
-
async
|
|
146
|
+
async finalizeAssetPackUpload(creatorUsername, name, sessionId) {
|
|
147
|
+
const packName = typeof name === 'string' ? name.trim() : '';
|
|
148
|
+
if (!packName) {
|
|
149
|
+
throw new Error('invalid_pack_name');
|
|
150
|
+
}
|
|
151
|
+
const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
|
|
152
|
+
if (!normalizedSessionId) {
|
|
153
|
+
throw new Error('invalid_pack_upload_session_id');
|
|
154
|
+
}
|
|
119
155
|
const response = await request({
|
|
120
|
-
method: '
|
|
121
|
-
path:
|
|
156
|
+
method: 'POST',
|
|
157
|
+
path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/finalize`,
|
|
158
|
+
});
|
|
159
|
+
if (response.status !== 200 && response.status !== 201) {
|
|
160
|
+
handleApiError(response, 'finalize_asset_pack_upload');
|
|
161
|
+
}
|
|
162
|
+
return response.body;
|
|
163
|
+
},
|
|
164
|
+
async abortAssetPackUpload(creatorUsername, name, sessionId) {
|
|
165
|
+
const packName = typeof name === 'string' ? name.trim() : '';
|
|
166
|
+
if (!packName) {
|
|
167
|
+
throw new Error('invalid_pack_name');
|
|
168
|
+
}
|
|
169
|
+
const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
|
|
170
|
+
if (!normalizedSessionId) {
|
|
171
|
+
throw new Error('invalid_pack_upload_session_id');
|
|
172
|
+
}
|
|
173
|
+
const response = await request({
|
|
174
|
+
method: 'POST',
|
|
175
|
+
path: `${buildCreatorAssetPackMutationPath(creatorUsername, packName)}/upload-sessions/${encodeURIComponent(normalizedSessionId)}/abort`,
|
|
122
176
|
});
|
|
123
177
|
if (response.status !== 200) {
|
|
124
|
-
handleApiError(response, '
|
|
178
|
+
handleApiError(response, 'abort_asset_pack_upload');
|
|
125
179
|
}
|
|
126
180
|
return response.body;
|
|
127
181
|
},
|
|
182
|
+
async fetchAssetPackRelated(creatorUsername, packName) {
|
|
183
|
+
return fetchAssetPackRelatedRequest(request, handleApiError, normalizeCreatorItemSlug, creatorUsername, packName);
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function buildAssetPackReadWriteMethods(input) {
|
|
188
|
+
const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, buildCreatorAssetPackMutationPath, normalizeSemverInput, parseContentDispositionFilename, } = input;
|
|
189
|
+
return {
|
|
128
190
|
async listAssetPacks(options = {}) {
|
|
129
191
|
const params = new URLSearchParams();
|
|
130
192
|
if (typeof options.limit === 'number') {
|
|
@@ -206,6 +268,7 @@ export function buildAssetPacksApiClientMethods(input) {
|
|
|
206
268
|
const response = await fetchImpl(resolveUrl(base, path), {
|
|
207
269
|
method: 'GET',
|
|
208
270
|
headers,
|
|
271
|
+
...buildBrowserCredentialsInit(includeBrowserCredentials),
|
|
209
272
|
});
|
|
210
273
|
if (!response.ok) {
|
|
211
274
|
const parsed = await parseResponseBody(response);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AssetCategoriesResponse, AssetCategory, AssetDetailResponse, AssetListResponse, AssetSourceBundleResponse, AssetVersionsListResponse, ContentRemixRelationsResponse, CreateAssetVersionResponse, DeleteAssetResponse, DeleteAssetVersionResponse, UpdateAssetRequest, UpdateAssetResponse, UpdateAssetVersionRequest, UpdateAssetVersionResponse } from '@playdrop/types';
|
|
1
|
+
import type { AssetBrowseKind, AssetCategoriesResponse, AssetCategory, AssetDetailResponse, AssetListResponse, AssetSourceBundleResponse, AssetVersionsListResponse, ContentRemixRelationsResponse, CreateAssetVersionResponse, DeleteAssetResponse, DeleteAssetVersionResponse, UpdateAssetRequest, UpdateAssetResponse, UpdateAssetVersionRequest, UpdateAssetVersionResponse } from '@playdrop/types';
|
|
2
2
|
import type { UploadAssetVersionOptions } from '../client.js';
|
|
3
3
|
type ApiResponseLike<T> = {
|
|
4
4
|
status: number;
|
|
@@ -18,6 +18,7 @@ export declare function buildAssetsApiClientMethods(input: {
|
|
|
18
18
|
request: RequestExecutor;
|
|
19
19
|
handleApiError: ErrorHandler;
|
|
20
20
|
fetchImpl: typeof fetch;
|
|
21
|
+
includeBrowserCredentials: boolean;
|
|
21
22
|
resolveBaseUrl: () => string;
|
|
22
23
|
resolveUrl: (base: string, path: string) => string;
|
|
23
24
|
parseResponseBody: ParseResponseBody;
|
|
@@ -36,12 +37,14 @@ export declare function buildAssetsApiClientMethods(input: {
|
|
|
36
37
|
offset?: number;
|
|
37
38
|
category?: AssetCategory;
|
|
38
39
|
subcategory?: string;
|
|
40
|
+
kind?: AssetBrowseKind;
|
|
39
41
|
}): Promise<AssetListResponse>;
|
|
40
42
|
listAssetsForCreator(creatorUsername: string, options?: {
|
|
41
43
|
limit?: number;
|
|
42
44
|
offset?: number;
|
|
43
45
|
category?: AssetCategory;
|
|
44
46
|
subcategory?: string;
|
|
47
|
+
kind?: AssetBrowseKind;
|
|
45
48
|
}): Promise<AssetListResponse>;
|
|
46
49
|
fetchAssetBySlug(creatorUsername: string, assetName: string): Promise<AssetDetailResponse>;
|
|
47
50
|
listAssetVersions(creatorUsername: string, assetName: string, options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/domains/assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EAEzB,yBAAyB,EACzB,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/domains/assets.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,128 +1,164 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { buildBrowserCredentialsInit } from '../core/request.js';
|
|
2
|
+
async function buildAuthorizedHeaders(getClientHeaders, resolveToken) {
|
|
3
|
+
const headers = new Headers();
|
|
4
|
+
for (const [key, value] of Object.entries(getClientHeaders())) {
|
|
5
|
+
headers.set(key, value);
|
|
6
|
+
}
|
|
7
|
+
const token = await resolveToken();
|
|
8
|
+
if (token) {
|
|
9
|
+
headers.set('authorization', `Bearer ${token}`);
|
|
10
|
+
}
|
|
11
|
+
return headers;
|
|
12
|
+
}
|
|
13
|
+
function buildPublicAssetPath(normalizeCreatorItemSlug, creatorUsername, assetName, suffix = '') {
|
|
14
|
+
const creator = normalizeCreatorItemSlug(creatorUsername, 'creator');
|
|
15
|
+
const name = normalizeCreatorItemSlug(assetName, 'name');
|
|
16
|
+
return `/assets/${encodeURIComponent(creator)}/${encodeURIComponent(name)}${suffix}`;
|
|
17
|
+
}
|
|
18
|
+
function buildAssetVersionUploadForm(options) {
|
|
19
|
+
if (!Array.isArray(options.files) || options.files.length === 0) {
|
|
20
|
+
throw new Error('missing_asset_files');
|
|
21
|
+
}
|
|
22
|
+
const form = new FormData();
|
|
23
|
+
form.set('category', options.category);
|
|
24
|
+
form.set('subcategory', options.subcategory);
|
|
25
|
+
form.set('format', options.format);
|
|
26
|
+
appendAssetVersionOptionalFields(form, options);
|
|
27
|
+
appendAssetVersionFiles(form, options);
|
|
28
|
+
return form;
|
|
29
|
+
}
|
|
30
|
+
function appendAssetVersionOptionalFields(form, options) {
|
|
31
|
+
if (options.visibility)
|
|
32
|
+
form.set('visibility', options.visibility);
|
|
33
|
+
if (options.sourceKind)
|
|
34
|
+
form.set('sourceKind', options.sourceKind);
|
|
35
|
+
if (typeof options.sourceAppVersionId === 'number') {
|
|
36
|
+
form.set('sourceAppVersionId', String(options.sourceAppVersionId));
|
|
37
|
+
}
|
|
38
|
+
if (typeof options.sourceGenerationId === 'string' && options.sourceGenerationId.trim().length > 0) {
|
|
39
|
+
form.set('sourceGenerationId', options.sourceGenerationId.trim());
|
|
40
|
+
}
|
|
41
|
+
if (typeof options.remixRef === 'string' && options.remixRef.trim().length > 0) {
|
|
42
|
+
form.set('remixRef', options.remixRef.trim());
|
|
43
|
+
}
|
|
44
|
+
if (typeof options.shopListed === 'boolean') {
|
|
45
|
+
form.set('shopListed', options.shopListed ? 'true' : 'false');
|
|
46
|
+
}
|
|
47
|
+
if (typeof options.shopPriceCredits === 'number') {
|
|
48
|
+
form.set('shopPriceCredits', String(options.shopPriceCredits));
|
|
49
|
+
}
|
|
50
|
+
if (typeof options.displayName === 'string' && options.displayName.trim().length > 0) {
|
|
51
|
+
form.set('displayName', options.displayName.trim());
|
|
52
|
+
}
|
|
53
|
+
if (typeof options.description === 'string') {
|
|
54
|
+
form.set('description', options.description);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function appendAssetVersionFiles(form, options) {
|
|
58
|
+
for (const item of options.files) {
|
|
59
|
+
if (!item) {
|
|
60
|
+
throw new Error('missing_asset_upload_file');
|
|
61
|
+
}
|
|
62
|
+
const fieldName = typeof item.fieldName === 'string' && item.fieldName.trim().length > 0
|
|
63
|
+
? item.fieldName.trim()
|
|
64
|
+
: 'file';
|
|
65
|
+
if (typeof item.filename === 'string' && item.filename.trim().length > 0) {
|
|
66
|
+
form.append(fieldName, item.file, item.filename.trim());
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
form.append(fieldName, item.file);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function fetchAssetRelatedRequest(request, handleApiError, normalizeCreatorItemSlug, creatorUsername, assetName) {
|
|
74
|
+
const response = await request({
|
|
75
|
+
method: 'GET',
|
|
76
|
+
path: buildPublicAssetPath(normalizeCreatorItemSlug, creatorUsername, assetName, '/related'),
|
|
77
|
+
});
|
|
78
|
+
if (response.status !== 200) {
|
|
79
|
+
handleApiError(response, 'get_asset_related');
|
|
80
|
+
}
|
|
81
|
+
return response.body;
|
|
82
|
+
}
|
|
83
|
+
async function listAssetsRequest(request, handleApiError, options = {}) {
|
|
84
|
+
const params = new URLSearchParams();
|
|
85
|
+
if (typeof options.limit === 'number')
|
|
86
|
+
params.set('limit', String(options.limit));
|
|
87
|
+
if (typeof options.offset === 'number')
|
|
88
|
+
params.set('offset', String(options.offset));
|
|
89
|
+
if (typeof options.category === 'string' && options.category.trim().length > 0) {
|
|
90
|
+
params.set('category', options.category.trim());
|
|
91
|
+
}
|
|
92
|
+
if (typeof options.subcategory === 'string' && options.subcategory.trim().length > 0) {
|
|
93
|
+
params.set('subcategory', options.subcategory.trim());
|
|
94
|
+
}
|
|
95
|
+
if (typeof options.kind === 'string' && options.kind.trim().length > 0) {
|
|
96
|
+
params.set('kind', options.kind.trim());
|
|
97
|
+
}
|
|
98
|
+
const query = params.toString();
|
|
99
|
+
const path = `/assets${query ? `?${query}` : ''}`;
|
|
100
|
+
const response = await request({ method: 'GET', path });
|
|
101
|
+
if (response.status !== 200) {
|
|
102
|
+
handleApiError(response, 'list_assets');
|
|
7
103
|
}
|
|
104
|
+
return response.body;
|
|
105
|
+
}
|
|
106
|
+
async function listAssetCategoriesRequest(request, handleApiError) {
|
|
107
|
+
const response = await request({
|
|
108
|
+
method: 'GET',
|
|
109
|
+
path: '/asset-categories',
|
|
110
|
+
});
|
|
111
|
+
if (response.status !== 200) {
|
|
112
|
+
handleApiError(response, 'list_asset_categories');
|
|
113
|
+
}
|
|
114
|
+
return response.body;
|
|
115
|
+
}
|
|
116
|
+
async function createAssetVersionRequest(input, creatorUsername, assetName, options) {
|
|
117
|
+
const form = buildAssetVersionUploadForm(options);
|
|
118
|
+
const base = input.resolveBaseUrl();
|
|
119
|
+
const path = `${input.buildCreatorAssetMutationPath(creatorUsername, assetName)}/versions`;
|
|
120
|
+
const headers = await buildAuthorizedHeaders(input.getClientHeaders, input.resolveToken);
|
|
121
|
+
const response = await input.fetchImpl(input.resolveUrl(base, path), {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
headers,
|
|
124
|
+
body: form,
|
|
125
|
+
...buildBrowserCredentialsInit(input.includeBrowserCredentials),
|
|
126
|
+
});
|
|
127
|
+
const parsed = await input.parseResponseBody(response);
|
|
128
|
+
const apiResponse = { status: response.status, body: parsed, headers: response.headers };
|
|
129
|
+
if (response.status !== 201 && response.status !== 200) {
|
|
130
|
+
input.handleApiError(apiResponse, 'create_asset_version');
|
|
131
|
+
}
|
|
132
|
+
return parsed;
|
|
133
|
+
}
|
|
134
|
+
export function buildAssetsApiClientMethods(input) {
|
|
135
|
+
const { request, handleApiError, fetchImpl, includeBrowserCredentials, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, buildCreatorAssetMutationPath, normalizeCreatorItemSlug, normalizeAssetRevisionInput, parseContentDispositionFilename, } = input;
|
|
8
136
|
return {
|
|
9
137
|
async createAssetVersion(creatorUsername, name, options) {
|
|
10
138
|
const assetName = typeof name === 'string' ? name.trim() : '';
|
|
11
139
|
if (!assetName) {
|
|
12
140
|
throw new Error('invalid_asset_name');
|
|
13
141
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
form.set('sourceKind', options.sourceKind);
|
|
26
|
-
}
|
|
27
|
-
if (typeof options.sourceAppVersionId === 'number') {
|
|
28
|
-
form.set('sourceAppVersionId', String(options.sourceAppVersionId));
|
|
29
|
-
}
|
|
30
|
-
if (typeof options.sourceGenerationId === 'string' && options.sourceGenerationId.trim().length > 0) {
|
|
31
|
-
form.set('sourceGenerationId', options.sourceGenerationId.trim());
|
|
32
|
-
}
|
|
33
|
-
if (typeof options.remixRef === 'string' && options.remixRef.trim().length > 0) {
|
|
34
|
-
form.set('remixRef', options.remixRef.trim());
|
|
35
|
-
}
|
|
36
|
-
if (typeof options.shopListed === 'boolean') {
|
|
37
|
-
form.set('shopListed', options.shopListed ? 'true' : 'false');
|
|
38
|
-
}
|
|
39
|
-
if (typeof options.shopPriceCredits === 'number') {
|
|
40
|
-
form.set('shopPriceCredits', String(options.shopPriceCredits));
|
|
41
|
-
}
|
|
42
|
-
if (typeof options.displayName === 'string' && options.displayName.trim().length > 0) {
|
|
43
|
-
form.set('displayName', options.displayName.trim());
|
|
44
|
-
}
|
|
45
|
-
if (typeof options.description === 'string') {
|
|
46
|
-
form.set('description', options.description);
|
|
47
|
-
}
|
|
48
|
-
for (let index = 0; index < options.files.length; index++) {
|
|
49
|
-
const item = options.files[index];
|
|
50
|
-
const fieldName = typeof item.fieldName === 'string' && item.fieldName.trim().length > 0
|
|
51
|
-
? item.fieldName.trim()
|
|
52
|
-
: 'file';
|
|
53
|
-
if (typeof item.filename === 'string' && item.filename.trim().length > 0) {
|
|
54
|
-
form.append(fieldName, item.file, item.filename.trim());
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
form.append(fieldName, item.file);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const base = resolveBaseUrl();
|
|
61
|
-
const headers = new Headers();
|
|
62
|
-
for (const [key, value] of Object.entries(getClientHeaders())) {
|
|
63
|
-
headers.set(key, value);
|
|
64
|
-
}
|
|
65
|
-
const token = await resolveToken();
|
|
66
|
-
if (token) {
|
|
67
|
-
headers.set('authorization', `Bearer ${token}`);
|
|
68
|
-
}
|
|
69
|
-
const path = `${buildCreatorAssetMutationPath(creatorUsername, assetName)}/versions`;
|
|
70
|
-
const response = await fetchImpl(resolveUrl(base, path), {
|
|
71
|
-
method: 'POST',
|
|
72
|
-
headers,
|
|
73
|
-
body: form,
|
|
74
|
-
});
|
|
75
|
-
const parsed = await parseResponseBody(response);
|
|
76
|
-
const apiResponse = { status: response.status, body: parsed, headers: response.headers };
|
|
77
|
-
if (response.status !== 201 && response.status !== 200) {
|
|
78
|
-
handleApiError(apiResponse, 'create_asset_version');
|
|
79
|
-
}
|
|
80
|
-
return parsed;
|
|
142
|
+
return createAssetVersionRequest({
|
|
143
|
+
fetchImpl,
|
|
144
|
+
includeBrowserCredentials,
|
|
145
|
+
resolveBaseUrl,
|
|
146
|
+
resolveUrl,
|
|
147
|
+
parseResponseBody,
|
|
148
|
+
resolveToken,
|
|
149
|
+
getClientHeaders,
|
|
150
|
+
buildCreatorAssetMutationPath,
|
|
151
|
+
handleApiError,
|
|
152
|
+
}, creatorUsername, assetName, options);
|
|
81
153
|
},
|
|
82
154
|
async fetchAssetRelated(creatorUsername, assetName) {
|
|
83
|
-
|
|
84
|
-
method: 'GET',
|
|
85
|
-
path: buildPublicAssetPath(creatorUsername, assetName, '/related'),
|
|
86
|
-
});
|
|
87
|
-
if (response.status !== 200) {
|
|
88
|
-
handleApiError(response, 'get_asset_related');
|
|
89
|
-
}
|
|
90
|
-
return response.body;
|
|
155
|
+
return fetchAssetRelatedRequest(request, handleApiError, normalizeCreatorItemSlug, creatorUsername, assetName);
|
|
91
156
|
},
|
|
92
157
|
async listAssetCategories() {
|
|
93
|
-
|
|
94
|
-
method: 'GET',
|
|
95
|
-
path: '/asset-categories',
|
|
96
|
-
});
|
|
97
|
-
if (response.status !== 200) {
|
|
98
|
-
handleApiError(response, 'list_asset_categories');
|
|
99
|
-
}
|
|
100
|
-
return response.body;
|
|
158
|
+
return listAssetCategoriesRequest(request, handleApiError);
|
|
101
159
|
},
|
|
102
160
|
async listAssets(options = {}) {
|
|
103
|
-
|
|
104
|
-
if (typeof options.limit === 'number') {
|
|
105
|
-
params.set('limit', String(options.limit));
|
|
106
|
-
}
|
|
107
|
-
if (typeof options.offset === 'number') {
|
|
108
|
-
params.set('offset', String(options.offset));
|
|
109
|
-
}
|
|
110
|
-
if (typeof options.category === 'string' && options.category.trim().length > 0) {
|
|
111
|
-
params.set('category', options.category.trim());
|
|
112
|
-
}
|
|
113
|
-
if (typeof options.subcategory === 'string' && options.subcategory.trim().length > 0) {
|
|
114
|
-
params.set('subcategory', options.subcategory.trim());
|
|
115
|
-
}
|
|
116
|
-
const query = params.toString();
|
|
117
|
-
const path = `/assets${query ? `?${query}` : ''}`;
|
|
118
|
-
const response = await request({
|
|
119
|
-
method: 'GET',
|
|
120
|
-
path,
|
|
121
|
-
});
|
|
122
|
-
if (response.status !== 200) {
|
|
123
|
-
handleApiError(response, 'list_assets');
|
|
124
|
-
}
|
|
125
|
-
return response.body;
|
|
161
|
+
return listAssetsRequest(request, handleApiError, options);
|
|
126
162
|
},
|
|
127
163
|
async listAssetsForCreator(creatorUsername, options = {}) {
|
|
128
164
|
const params = new URLSearchParams();
|
|
@@ -138,6 +174,9 @@ export function buildAssetsApiClientMethods(input) {
|
|
|
138
174
|
if (typeof options.subcategory === 'string' && options.subcategory.trim().length > 0) {
|
|
139
175
|
params.set('subcategory', options.subcategory.trim());
|
|
140
176
|
}
|
|
177
|
+
if (typeof options.kind === 'string' && options.kind.trim().length > 0) {
|
|
178
|
+
params.set('kind', options.kind.trim());
|
|
179
|
+
}
|
|
141
180
|
const query = params.toString();
|
|
142
181
|
const path = `/creators/${encodeURIComponent(creatorUsername)}/assets${query ? `?${query}` : ''}`;
|
|
143
182
|
const response = await request({
|
|
@@ -264,6 +303,7 @@ export function buildAssetsApiClientMethods(input) {
|
|
|
264
303
|
const response = await fetchImpl(resolveUrl(base, path), {
|
|
265
304
|
method: 'GET',
|
|
266
305
|
headers,
|
|
306
|
+
...buildBrowserCredentialsInit(includeBrowserCredentials),
|
|
267
307
|
});
|
|
268
308
|
if (!response.ok) {
|
|
269
309
|
const parsed = await parseResponseBody(response);
|
|
@@ -291,6 +331,7 @@ export function buildAssetsApiClientMethods(input) {
|
|
|
291
331
|
const response = await fetchImpl(resolveUrl(base, path), {
|
|
292
332
|
method: 'GET',
|
|
293
333
|
headers,
|
|
334
|
+
...buildBrowserCredentialsInit(includeBrowserCredentials),
|
|
294
335
|
});
|
|
295
336
|
if (!response.ok) {
|
|
296
337
|
const parsed = await parseResponseBody(response);
|