@playcademy/sandbox 0.4.2-beta.5 → 0.5.1-beta.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.
- package/dist/cli.js +45 -7
- package/dist/server.js +45 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1078,7 +1078,7 @@ var package_default;
|
|
|
1078
1078
|
var init_package = __esm(() => {
|
|
1079
1079
|
package_default = {
|
|
1080
1080
|
name: "@playcademy/sandbox",
|
|
1081
|
-
version: "0.
|
|
1081
|
+
version: "0.5.1-beta.1",
|
|
1082
1082
|
description: "Local development server for Playcademy game development",
|
|
1083
1083
|
type: "module",
|
|
1084
1084
|
exports: {
|
|
@@ -29043,8 +29043,8 @@ class BucketService {
|
|
|
29043
29043
|
const extensionIndex = fileName.lastIndexOf(".");
|
|
29044
29044
|
return extensionIndex > 0 ? fileName.slice(extensionIndex + 1).toLowerCase() : "(none)";
|
|
29045
29045
|
}
|
|
29046
|
-
getBucketName(slug
|
|
29047
|
-
return
|
|
29046
|
+
getBucketName(slug) {
|
|
29047
|
+
return getDeploymentId(slug, this.deps.sstStage);
|
|
29048
29048
|
}
|
|
29049
29049
|
async listFiles(slug, user, prefix) {
|
|
29050
29050
|
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
@@ -29090,6 +29090,19 @@ class BucketService {
|
|
|
29090
29090
|
});
|
|
29091
29091
|
return { key, size: body2.length };
|
|
29092
29092
|
}
|
|
29093
|
+
async initiateUpload(slug, key, contentType, user) {
|
|
29094
|
+
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
29095
|
+
const bucketName = this.getBucketName(game2.slug);
|
|
29096
|
+
const presignedUrl = await this.deps.storage.generatePresignedPutUrl(bucketName, key, contentType, 3600);
|
|
29097
|
+
setAttributes({
|
|
29098
|
+
"app.bucket.operation": "initiate_upload",
|
|
29099
|
+
"app.bucket.key_prefix": BucketService.getKeyPrefix(key),
|
|
29100
|
+
"app.bucket.file_extension": BucketService.getFileExtension(key),
|
|
29101
|
+
"app.bucket.content_type": contentType,
|
|
29102
|
+
"app.bucket.upload_kind": "presigned"
|
|
29103
|
+
});
|
|
29104
|
+
return { presignedUrl, key };
|
|
29105
|
+
}
|
|
29093
29106
|
async deleteFile(slug, key, user) {
|
|
29094
29107
|
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
29095
29108
|
const bucketName = this.getBucketName(game2.slug);
|
|
@@ -29102,9 +29115,9 @@ class BucketService {
|
|
|
29102
29115
|
}
|
|
29103
29116
|
}
|
|
29104
29117
|
var init_bucket_service = __esm(() => {
|
|
29105
|
-
init_src();
|
|
29106
29118
|
init_spans();
|
|
29107
29119
|
init_errors();
|
|
29120
|
+
init_deployment_util();
|
|
29108
29121
|
});
|
|
29109
29122
|
|
|
29110
29123
|
// ../api-core/src/services/database.service.ts
|
|
@@ -39198,6 +39211,7 @@ function createPlatformServices(deps) {
|
|
|
39198
39211
|
validateGameManagementAccess
|
|
39199
39212
|
} = deps;
|
|
39200
39213
|
const bucket = new BucketService({
|
|
39214
|
+
sstStage: config2.sstStage,
|
|
39201
39215
|
storage: r2Storage,
|
|
39202
39216
|
validateDeveloperAccessBySlug
|
|
39203
39217
|
});
|
|
@@ -95737,7 +95751,7 @@ function requireDeveloper(handler) {
|
|
|
95737
95751
|
throw ApiError.unauthorized("Valid session or bearer token required");
|
|
95738
95752
|
}
|
|
95739
95753
|
const isAdmin = ctx.user.role === "admin";
|
|
95740
|
-
const isApprovedDev = ctx.user.developerStatus === "approved";
|
|
95754
|
+
const isApprovedDev = ctx.user.role === "developer" && ctx.user.developerStatus === "approved";
|
|
95741
95755
|
if (!isAdmin && !isApprovedDev) {
|
|
95742
95756
|
throw ApiError.forbidden("Must be an approved developer");
|
|
95743
95757
|
}
|
|
@@ -95981,7 +95995,7 @@ var init_admin_controller = __esm(() => {
|
|
|
95981
95995
|
});
|
|
95982
95996
|
|
|
95983
95997
|
// ../api-core/src/controllers/bucket.controller.ts
|
|
95984
|
-
var listFiles, getFile, putFile, deleteFile, bucket;
|
|
95998
|
+
var listFiles, getFile, putFile, deleteFile, initiateUpload, bucket;
|
|
95985
95999
|
var init_bucket_controller = __esm(() => {
|
|
95986
96000
|
init_errors();
|
|
95987
96001
|
init_utils11();
|
|
@@ -96031,11 +96045,35 @@ var init_bucket_controller = __esm(() => {
|
|
|
96031
96045
|
await ctx.services.bucket.deleteFile(slug2, key, ctx.user);
|
|
96032
96046
|
return { success: true, key };
|
|
96033
96047
|
});
|
|
96048
|
+
initiateUpload = requireDeveloper(async (ctx) => {
|
|
96049
|
+
const slug2 = ctx.params.slug;
|
|
96050
|
+
if (!slug2) {
|
|
96051
|
+
throw ApiError.badRequest("Missing game slug");
|
|
96052
|
+
}
|
|
96053
|
+
let body2;
|
|
96054
|
+
try {
|
|
96055
|
+
const json4 = await ctx.request.json();
|
|
96056
|
+
if (!json4.key || typeof json4.key !== "string") {
|
|
96057
|
+
throw ApiError.badRequest('Missing or invalid "key"');
|
|
96058
|
+
}
|
|
96059
|
+
if (!json4.contentType || typeof json4.contentType !== "string") {
|
|
96060
|
+
throw ApiError.badRequest('Missing or invalid "contentType"');
|
|
96061
|
+
}
|
|
96062
|
+
body2 = { key: json4.key, contentType: json4.contentType };
|
|
96063
|
+
} catch (error2) {
|
|
96064
|
+
if (error2 instanceof ApiError) {
|
|
96065
|
+
throw error2;
|
|
96066
|
+
}
|
|
96067
|
+
throw ApiError.badRequest("Invalid JSON body");
|
|
96068
|
+
}
|
|
96069
|
+
return ctx.services.bucket.initiateUpload(slug2, body2.key, body2.contentType, ctx.user);
|
|
96070
|
+
});
|
|
96034
96071
|
bucket = defineControllerNames("bucket", {
|
|
96035
96072
|
listFiles,
|
|
96036
96073
|
getFile,
|
|
96037
96074
|
putFile,
|
|
96038
|
-
deleteFile
|
|
96075
|
+
deleteFile,
|
|
96076
|
+
initiateUpload
|
|
96039
96077
|
});
|
|
96040
96078
|
});
|
|
96041
96079
|
|
package/dist/server.js
CHANGED
|
@@ -1077,7 +1077,7 @@ var package_default;
|
|
|
1077
1077
|
var init_package = __esm(() => {
|
|
1078
1078
|
package_default = {
|
|
1079
1079
|
name: "@playcademy/sandbox",
|
|
1080
|
-
version: "0.
|
|
1080
|
+
version: "0.5.1-beta.1",
|
|
1081
1081
|
description: "Local development server for Playcademy game development",
|
|
1082
1082
|
type: "module",
|
|
1083
1083
|
exports: {
|
|
@@ -29042,8 +29042,8 @@ class BucketService {
|
|
|
29042
29042
|
const extensionIndex = fileName.lastIndexOf(".");
|
|
29043
29043
|
return extensionIndex > 0 ? fileName.slice(extensionIndex + 1).toLowerCase() : "(none)";
|
|
29044
29044
|
}
|
|
29045
|
-
getBucketName(slug
|
|
29046
|
-
return
|
|
29045
|
+
getBucketName(slug) {
|
|
29046
|
+
return getDeploymentId(slug, this.deps.sstStage);
|
|
29047
29047
|
}
|
|
29048
29048
|
async listFiles(slug, user, prefix) {
|
|
29049
29049
|
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
@@ -29089,6 +29089,19 @@ class BucketService {
|
|
|
29089
29089
|
});
|
|
29090
29090
|
return { key, size: body2.length };
|
|
29091
29091
|
}
|
|
29092
|
+
async initiateUpload(slug, key, contentType, user) {
|
|
29093
|
+
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
29094
|
+
const bucketName = this.getBucketName(game2.slug);
|
|
29095
|
+
const presignedUrl = await this.deps.storage.generatePresignedPutUrl(bucketName, key, contentType, 3600);
|
|
29096
|
+
setAttributes({
|
|
29097
|
+
"app.bucket.operation": "initiate_upload",
|
|
29098
|
+
"app.bucket.key_prefix": BucketService.getKeyPrefix(key),
|
|
29099
|
+
"app.bucket.file_extension": BucketService.getFileExtension(key),
|
|
29100
|
+
"app.bucket.content_type": contentType,
|
|
29101
|
+
"app.bucket.upload_kind": "presigned"
|
|
29102
|
+
});
|
|
29103
|
+
return { presignedUrl, key };
|
|
29104
|
+
}
|
|
29092
29105
|
async deleteFile(slug, key, user) {
|
|
29093
29106
|
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
29094
29107
|
const bucketName = this.getBucketName(game2.slug);
|
|
@@ -29101,9 +29114,9 @@ class BucketService {
|
|
|
29101
29114
|
}
|
|
29102
29115
|
}
|
|
29103
29116
|
var init_bucket_service = __esm(() => {
|
|
29104
|
-
init_src();
|
|
29105
29117
|
init_spans();
|
|
29106
29118
|
init_errors();
|
|
29119
|
+
init_deployment_util();
|
|
29107
29120
|
});
|
|
29108
29121
|
|
|
29109
29122
|
// ../api-core/src/services/database.service.ts
|
|
@@ -39197,6 +39210,7 @@ function createPlatformServices(deps) {
|
|
|
39197
39210
|
validateGameManagementAccess
|
|
39198
39211
|
} = deps;
|
|
39199
39212
|
const bucket = new BucketService({
|
|
39213
|
+
sstStage: config2.sstStage,
|
|
39200
39214
|
storage: r2Storage,
|
|
39201
39215
|
validateDeveloperAccessBySlug
|
|
39202
39216
|
});
|
|
@@ -95736,7 +95750,7 @@ function requireDeveloper(handler) {
|
|
|
95736
95750
|
throw ApiError.unauthorized("Valid session or bearer token required");
|
|
95737
95751
|
}
|
|
95738
95752
|
const isAdmin = ctx.user.role === "admin";
|
|
95739
|
-
const isApprovedDev = ctx.user.developerStatus === "approved";
|
|
95753
|
+
const isApprovedDev = ctx.user.role === "developer" && ctx.user.developerStatus === "approved";
|
|
95740
95754
|
if (!isAdmin && !isApprovedDev) {
|
|
95741
95755
|
throw ApiError.forbidden("Must be an approved developer");
|
|
95742
95756
|
}
|
|
@@ -95980,7 +95994,7 @@ var init_admin_controller = __esm(() => {
|
|
|
95980
95994
|
});
|
|
95981
95995
|
|
|
95982
95996
|
// ../api-core/src/controllers/bucket.controller.ts
|
|
95983
|
-
var listFiles, getFile, putFile, deleteFile, bucket;
|
|
95997
|
+
var listFiles, getFile, putFile, deleteFile, initiateUpload, bucket;
|
|
95984
95998
|
var init_bucket_controller = __esm(() => {
|
|
95985
95999
|
init_errors();
|
|
95986
96000
|
init_utils11();
|
|
@@ -96030,11 +96044,35 @@ var init_bucket_controller = __esm(() => {
|
|
|
96030
96044
|
await ctx.services.bucket.deleteFile(slug2, key, ctx.user);
|
|
96031
96045
|
return { success: true, key };
|
|
96032
96046
|
});
|
|
96047
|
+
initiateUpload = requireDeveloper(async (ctx) => {
|
|
96048
|
+
const slug2 = ctx.params.slug;
|
|
96049
|
+
if (!slug2) {
|
|
96050
|
+
throw ApiError.badRequest("Missing game slug");
|
|
96051
|
+
}
|
|
96052
|
+
let body2;
|
|
96053
|
+
try {
|
|
96054
|
+
const json4 = await ctx.request.json();
|
|
96055
|
+
if (!json4.key || typeof json4.key !== "string") {
|
|
96056
|
+
throw ApiError.badRequest('Missing or invalid "key"');
|
|
96057
|
+
}
|
|
96058
|
+
if (!json4.contentType || typeof json4.contentType !== "string") {
|
|
96059
|
+
throw ApiError.badRequest('Missing or invalid "contentType"');
|
|
96060
|
+
}
|
|
96061
|
+
body2 = { key: json4.key, contentType: json4.contentType };
|
|
96062
|
+
} catch (error2) {
|
|
96063
|
+
if (error2 instanceof ApiError) {
|
|
96064
|
+
throw error2;
|
|
96065
|
+
}
|
|
96066
|
+
throw ApiError.badRequest("Invalid JSON body");
|
|
96067
|
+
}
|
|
96068
|
+
return ctx.services.bucket.initiateUpload(slug2, body2.key, body2.contentType, ctx.user);
|
|
96069
|
+
});
|
|
96033
96070
|
bucket = defineControllerNames("bucket", {
|
|
96034
96071
|
listFiles,
|
|
96035
96072
|
getFile,
|
|
96036
96073
|
putFile,
|
|
96037
|
-
deleteFile
|
|
96074
|
+
deleteFile,
|
|
96075
|
+
initiateUpload
|
|
96038
96076
|
});
|
|
96039
96077
|
});
|
|
96040
96078
|
|