From b3cb2c07a7b509bfcfc5d36339cf16dea4c995b1 Mon Sep 17 00:00:00 2001 From: Ianyourgod Date: Fri, 5 Apr 2024 14:36:33 -0500 Subject: [PATCH] some proto stuff --- api/v1/db/project.proto | 6 -- api/v1/db/protobufs/project.proto | 14 +++++ api/v1/db/protobufs/sprite.proto | 81 +++++++++++++++++++++++++ api/v1/routes/projects/uploadProject.js | 6 +- 4 files changed, 99 insertions(+), 8 deletions(-) delete mode 100644 api/v1/db/project.proto create mode 100644 api/v1/db/protobufs/project.proto create mode 100644 api/v1/db/protobufs/sprite.proto diff --git a/api/v1/db/project.proto b/api/v1/db/project.proto deleted file mode 100644 index c8ebe30..0000000 --- a/api/v1/db/project.proto +++ /dev/null @@ -1,6 +0,0 @@ -package project; -syntax = "proto3"; - -message Project { - // TODO :revolving_hearts: -} \ No newline at end of file diff --git a/api/v1/db/protobufs/project.proto b/api/v1/db/protobufs/project.proto new file mode 100644 index 0000000..4a383e0 --- /dev/null +++ b/api/v1/db/protobufs/project.proto @@ -0,0 +1,14 @@ +package project; +syntax = "proto3"; + +import "sprite.proto"; + +message Project { + repeated Sprite sprites = 1; + // monitors + // extension data + // extensions + string metaSemver = 5; + string metaVm = 6; + string agent = 7; +} \ No newline at end of file diff --git a/api/v1/db/protobufs/sprite.proto b/api/v1/db/protobufs/sprite.proto new file mode 100644 index 0000000..b618df1 --- /dev/null +++ b/api/v1/db/protobufs/sprite.proto @@ -0,0 +1,81 @@ +package Sprite; +syntax = "proto3"; + +message _varValue { + string name = 1; + string value = 2; +} + +message _listValue { + string name = 1; + repeated string value = 2; +} + +message block { + string opcode = 1; + string next = 2; + string parent = 3; + // map inputs = 4; + // map fields = 5; + bool shadow = 6; + bool topLevel = 7; +} + +message comment { + string blockId = 1; + float x = 2; + float y = 3; + int32 width = 4; + int32 height = 5; + bool minimized = 6; + string text = 7; +} + +message costume { + string name = 1; + int32 bitmapResolution = 2; + string dataFormat = 3; + string assetId = 4; + string md5ext = 5; + int32 rotationCenterX = 6; + int32 rotationCenterY = 7; +} + +message sound { + string name = 1; + string assetId = 2; + string dataFormat = 3; + int32 rate = 4; + int32 sampleCount = 5; + string md5ext = 6; +} + +message customVar { + string type = 1; + string id = 2; + string name = 3; + string value = 4; +} + +message Sprite { + string id = 1; + bool isStage = 2; + string name = 3; + map variables = 4; + map lists = 5; + map broadcasts = 6; + repeated customVar customVars = 7; + map blocks = 8; + map comments = 9; + int32 currentCostume = 10; + repeated costume costumes = 11; + repeated sound sounds = 12; + int32 volume = 13; + int32 layerOrder = 14; + int32 x = 15; + int32 y = 16; + int32 size = 17; + int32 direction = 18; // should be int 16 or smth but that dont exist for some reason + bool draggable = 19; + string rotationStyle = 20; +} \ No newline at end of file diff --git a/api/v1/routes/projects/uploadProject.js b/api/v1/routes/projects/uploadProject.js index c3d0820..c6c4957 100644 --- a/api/v1/routes/projects/uploadProject.js +++ b/api/v1/routes/projects/uploadProject.js @@ -7,7 +7,7 @@ module.exports = (app, utils) => { ]), async (req, res) => { const packet = req.body; - if (!await utils.UserManager.checkUser(packet.username, packet.password)) { + if (!await utils.UserManager.loginWithToken(packet.username, packet.password)) { return utils.error(res, 401, "Invalid credentials"); } @@ -34,6 +34,8 @@ module.exports = (app, utils) => { } // upload the project - // utils.UserManager.publishProject(); + utils.UserManager.publishProject( + jsonFile, + ); }); } \ No newline at end of file