@wvdsh/sdk-js 1.3.4 → 1.3.5
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/dist/index.d.ts +6 -3
- package/dist/index.js +31 -13
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -416,6 +416,7 @@ declare class UGCManager extends WavedashManager {
|
|
|
416
416
|
constructor(sdk: WavedashSDK);
|
|
417
417
|
createUGCItem(ugcType: UGCType, title?: string, description?: string, visibility?: UGCVisibility, filePath?: string): Promise<GenericId<"userGeneratedContent">>;
|
|
418
418
|
updateUGCItem(ugcId: GenericId<"userGeneratedContent">, title?: string, description?: string, visibility?: UGCVisibility, filePath?: string): Promise<GenericId<"userGeneratedContent">>;
|
|
419
|
+
deleteUGCItem(ugcId: GenericId<"userGeneratedContent">): Promise<GenericId<"userGeneratedContent">>;
|
|
419
420
|
downloadUGCItem(ugcId: GenericId<"userGeneratedContent">, filePath: string): Promise<GenericId<"userGeneratedContent">>;
|
|
420
421
|
}
|
|
421
422
|
|
|
@@ -990,6 +991,11 @@ declare class WavedashSDK extends EventTarget {
|
|
|
990
991
|
* @returns ugcId
|
|
991
992
|
*/
|
|
992
993
|
updateUGCItem(ugcId: GenericId<"userGeneratedContent">, title?: string, description?: string, visibility?: UGCVisibility, filePath?: string): Promise<WavedashResponse<GenericId<"userGeneratedContent">>>;
|
|
994
|
+
/**
|
|
995
|
+
* Delete a UGC item: removes the row, the R2 object, and frees up the
|
|
996
|
+
* user's storage quota by the size of the deleted upload.
|
|
997
|
+
*/
|
|
998
|
+
deleteUGCItem(ugcId: GenericId<"userGeneratedContent">): Promise<WavedashResponse<GenericId<"userGeneratedContent">>>;
|
|
993
999
|
downloadUGCItem(ugcId: GenericId<"userGeneratedContent">, filePath: string): Promise<WavedashResponse<GenericId<"userGeneratedContent">>>;
|
|
994
1000
|
/**
|
|
995
1001
|
* Deletes a remote file from storage
|
|
@@ -1161,9 +1167,6 @@ declare class WavedashSDK extends EventTarget {
|
|
|
1161
1167
|
ensureGameplayJwt(): Promise<string>;
|
|
1162
1168
|
/**
|
|
1163
1169
|
* Tear down every manager. Called on the parent's `END_SESSION` signal
|
|
1164
|
-
* (committed leaves only — see GameRunnerComponent.svelte). Idempotent.
|
|
1165
|
-
* Each manager's `destroy()` defaults to a no-op; managers with ongoing
|
|
1166
|
-
* state (subscriptions, intervals, peer connections) override it.
|
|
1167
1170
|
*/
|
|
1168
1171
|
private destroy;
|
|
1169
1172
|
private setupSessionEndListeners;
|
package/dist/index.js
CHANGED
|
@@ -674,9 +674,19 @@ var FileSystemManager = class extends WavedashManager {
|
|
|
674
674
|
* @returns The path of the remote file that was deleted
|
|
675
675
|
*/
|
|
676
676
|
async deleteRemoteFile(filePath) {
|
|
677
|
-
|
|
678
|
-
|
|
677
|
+
const url = this.getRemoteStorageUrl(filePath);
|
|
678
|
+
const jwt = await this.sdk.ensureGameplayJwt();
|
|
679
|
+
const response = await fetch(url, {
|
|
680
|
+
method: "DELETE",
|
|
681
|
+
headers: {
|
|
682
|
+
Authorization: `Bearer ${jwt}`
|
|
683
|
+
}
|
|
679
684
|
});
|
|
685
|
+
if (!response.ok) {
|
|
686
|
+
const msg = `Failed to delete remote file ${filePath}: ${response.status} (${response.statusText})`;
|
|
687
|
+
this.sdk.logger.error(msg);
|
|
688
|
+
throw new Error(msg);
|
|
689
|
+
}
|
|
680
690
|
return filePath;
|
|
681
691
|
}
|
|
682
692
|
/**
|
|
@@ -942,10 +952,6 @@ var UGCManager = class extends WavedashManager {
|
|
|
942
952
|
uploadUrl,
|
|
943
953
|
filePath
|
|
944
954
|
);
|
|
945
|
-
await this.sdk.convexClient.mutation(
|
|
946
|
-
api3.sdk.userGeneratedContent.finishUGCUpload,
|
|
947
|
-
{ success, ugcId }
|
|
948
|
-
);
|
|
949
955
|
if (!success) {
|
|
950
956
|
throw new Error(`Failed to upload UGC item: ${filePath}`);
|
|
951
957
|
}
|
|
@@ -972,16 +978,19 @@ var UGCManager = class extends WavedashManager {
|
|
|
972
978
|
uploadUrl,
|
|
973
979
|
filePath
|
|
974
980
|
);
|
|
975
|
-
await this.sdk.convexClient.mutation(
|
|
976
|
-
api3.sdk.userGeneratedContent.finishUGCUpload,
|
|
977
|
-
{ success, ugcId }
|
|
978
|
-
);
|
|
979
981
|
if (!success) {
|
|
980
982
|
throw new Error(`Failed to upload UGC item: ${filePath}`);
|
|
981
983
|
}
|
|
982
984
|
}
|
|
983
985
|
return ugcId;
|
|
984
986
|
}
|
|
987
|
+
async deleteUGCItem(ugcId) {
|
|
988
|
+
await this.sdk.convexClient.mutation(
|
|
989
|
+
api3.sdk.userGeneratedContent.deleteUGCItem,
|
|
990
|
+
{ ugcId }
|
|
991
|
+
);
|
|
992
|
+
return ugcId;
|
|
993
|
+
}
|
|
985
994
|
async downloadUGCItem(ugcId, filePath) {
|
|
986
995
|
const downloadUrl = await this.sdk.convexClient.query(
|
|
987
996
|
api3.sdk.userGeneratedContent.getUGCItemDownloadUrl,
|
|
@@ -3719,6 +3728,18 @@ var WavedashSDK = class extends EventTarget {
|
|
|
3719
3728
|
filePath
|
|
3720
3729
|
);
|
|
3721
3730
|
}
|
|
3731
|
+
/**
|
|
3732
|
+
* Delete a UGC item: removes the row, the R2 object, and frees up the
|
|
3733
|
+
* user's storage quota by the size of the deleted upload.
|
|
3734
|
+
*/
|
|
3735
|
+
async deleteUGCItem(ugcId) {
|
|
3736
|
+
return this.apiCall(
|
|
3737
|
+
this.ugcManager,
|
|
3738
|
+
"deleteUGCItem",
|
|
3739
|
+
[["ugcId", vId("userGeneratedContent")]],
|
|
3740
|
+
ugcId
|
|
3741
|
+
);
|
|
3742
|
+
}
|
|
3722
3743
|
async downloadUGCItem(ugcId, filePath) {
|
|
3723
3744
|
return this.apiCall(
|
|
3724
3745
|
this.ugcManager,
|
|
@@ -4253,9 +4274,6 @@ var WavedashSDK = class extends EventTarget {
|
|
|
4253
4274
|
}
|
|
4254
4275
|
/**
|
|
4255
4276
|
* Tear down every manager. Called on the parent's `END_SESSION` signal
|
|
4256
|
-
* (committed leaves only — see GameRunnerComponent.svelte). Idempotent.
|
|
4257
|
-
* Each manager's `destroy()` defaults to a no-op; managers with ongoing
|
|
4258
|
-
* state (subscriptions, intervals, peer connections) override it.
|
|
4259
4277
|
*/
|
|
4260
4278
|
destroy() {
|
|
4261
4279
|
if (this.destroyed) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wvdsh/sdk-js",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Wavedash JavaScript SDK",
|
|
6
6
|
"main": "./dist/client.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript-eslint": "^8.52.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@wvdsh/api": "^0.1.
|
|
52
|
+
"@wvdsh/api": "^0.1.14",
|
|
53
53
|
"convex": "^1.34.0",
|
|
54
54
|
"lodash.debounce": "^4.0.8"
|
|
55
55
|
}
|