From 131eb529d619b7b1e45d78413f47b2df5bdc16d7 Mon Sep 17 00:00:00 2001 From: Devyash Saini Date: Tue, 27 Jan 2026 16:29:14 +0530 Subject: [PATCH] refactor(proto): move proto to a separate repo Signed-off-by: Devyash Saini --- .gitmodules | 3 ++ package.json | 4 +- proto | 1 + proto/auth/v1/auth.proto | 22 ---------- proto/buf.gen.yaml | 8 ---- proto/event/v1/event.proto | 73 ---------------------------------- proto/payment/v1/payment.proto | 16 -------- 7 files changed, 7 insertions(+), 120 deletions(-) create mode 100644 .gitmodules create mode 160000 proto delete mode 100644 proto/auth/v1/auth.proto delete mode 100644 proto/buf.gen.yaml delete mode 100644 proto/event/v1/event.proto delete mode 100644 proto/payment/v1/payment.proto diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5f61e0c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "proto"] + path = proto + url = https://github.com/ScrawnDotDev/.proto diff --git a/package.json b/package.json index 5657cfa..c5bc526 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "test:ui": "vitest --ui", "start": "bun run src/server.ts", "init_key": "bun run src/utils/generateInitialAPIKey.ts", - "format": "bunx prettier --write ." + "format": "bunx prettier --write .", + "proto:pull": "git submodule update --remote --merge proto", + "proto:push": "cd proto && git add . && git commit -s -m \"$1\" && git push && cd .." }, "devDependencies": { "@bufbuild/protoc-gen-connect-es": "^0.13.0", diff --git a/proto b/proto new file mode 160000 index 0000000..c6e9e9f --- /dev/null +++ b/proto @@ -0,0 +1 @@ +Subproject commit c6e9e9f93add4e8980698153557bc622528bdbc1 diff --git a/proto/auth/v1/auth.proto b/proto/auth/v1/auth.proto deleted file mode 100644 index 8df90eb..0000000 --- a/proto/auth/v1/auth.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -package auth.v1; - -service AuthService { - // CreateAPIKey creates a new API key for the authenticated user - rpc CreateAPIKey(CreateAPIKeyRequest) returns (CreateAPIKeyResponse) {} -} - -message CreateAPIKeyRequest { - string name = 1; - // expiresIn is the expiration time in seconds from now - int64 expiresIn = 2; -} - -message CreateAPIKeyResponse { - string apiKeyId = 1; - string apiKey = 2; - string name = 3; - string createdAt = 4; - string expiresAt = 5; -} diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml deleted file mode 100644 index e7ac595..0000000 --- a/proto/buf.gen.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: v1 -plugins: - - plugin: es - out: ../src/gen - opt: target=ts - - plugin: connect-es - out: ../src/gen - opt: target=ts diff --git a/proto/event/v1/event.proto b/proto/event/v1/event.proto deleted file mode 100644 index 68fb041..0000000 --- a/proto/event/v1/event.proto +++ /dev/null @@ -1,73 +0,0 @@ -syntax = "proto3"; - -package event.v1; - -service EventService { - // RegisterEvent registers an event as being done by a user - rpc RegisterEvent(RegisterEventRequest) returns (RegisterEventResponse) {} - - // StreamEvents streams events from client to server (e.g., AI token usage) - rpc StreamEvents(stream StreamEventRequest) returns (StreamEventResponse) {} -} - -enum EventType { - EVENT_TYPE_UNSPECIFIED = 0; - SDK_CALL = 1; - AI_TOKEN_USAGE = 2; -} - -enum SDKCallType { - SDKCallType_UNSPECIFIED = 0; - RAW = 1; - MIDDLEWARE_CALL = 2; -} - -message RegisterEventRequest { - EventType type = 1; - string userId = 2; - oneof data { - SDKCall sdkCall = 3; - } -} - -message SDKCall { - SDKCallType sdkCallType = 1; - - oneof debit { - float amount = 2; - string tag = 3; - } -} - -message RegisterEventResponse { - string random = 1; -} - -message StreamEventRequest { - EventType type = 1; - string userId = 2; - oneof data { - AITokenUsage aiTokenUsage = 4; - } -} - -message AITokenUsage { - string model = 1; - int32 inputTokens = 2; - int32 outputTokens = 3; - - oneof inputDebit { - float inputAmount = 4; - string inputTag = 5; - } - - oneof outputDebit { - float outputAmount = 6; - string outputTag = 7; - } -} - -message StreamEventResponse { - int32 eventsProcessed = 1; - string message = 2; -} diff --git a/proto/payment/v1/payment.proto b/proto/payment/v1/payment.proto deleted file mode 100644 index aa8b484..0000000 --- a/proto/payment/v1/payment.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package payment.v1; - -service PaymentService { - // CreateCheckoutLink creates a checkout link for the given user - rpc CreateCheckoutLink(CreateCheckoutLinkRequest) returns (CreateCheckoutLinkResponse) {} -} - -message CreateCheckoutLinkRequest { - string userId = 1; -} - -message CreateCheckoutLinkResponse { - string checkoutLink = 1; -}