refactor(data-access): move tag/saved-reply/custom-field logic onto repository pattern - #1050
Open
realcodesiman wants to merge 2 commits into
Open
refactor(data-access): move tag/saved-reply/custom-field logic onto repository pattern#1050realcodesiman wants to merge 2 commits into
realcodesiman wants to merge 2 commits into
Conversation
…epository pattern Introduces dedicated tag and saved-reply repositories under packages/database/src/repositories, hashes workspace tokens (new tokenHash column + index), and centralizes the owner quota/trial gate into authorize-workspace-access.ts shared by server actions and oRPC auth. Relocates the affected business- logic tests from apps/builder/__tests__ into package-level __tests__ per repository convention.
…itory migration Splits the oRPC router so the public OpenAPI handler only ever serves publicRouter (workspace-token / channel-token auth) while session-authed procedures move to a private router on /rpc — a procedure missing from publicRouter now 404s instead of silently answering to a session cookie. Renames schemas/ -> schema/ and api/authenticated.ts -> api/private.ts across features for naming consistency with the new boundary, adds a custom-field repository and api-contract package, and continues moving tag/saved-reply/custom-field logic onto the repository pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tagandsaved-replyrepositories underpackages/database/src/repositories, moving direct query logic out of the business services.Workspace.tokenHashcolumn + index and hashes workspace tokens instead of comparing raw values.apps/builder/src/lib/workspace/authorize-workspace-access.ts, shared by server actions and oRPC session/workspace-token auth.apps/builder/__tests__into package-level__tests__(tag, saved-reply, custom-field, flow, flow-version) per repository test-placement convention, and adds new repository-level tests underpackages/database/__tests__.Changes
packages/database/src/repositories/{tag,saved-reply}/— new repositoriespackages/database/drizzle/20260828025915_create_workspace_token_hash/— new migration (additive:tokenHashcolumn + index), not yet appliedapps/builder/src/lib/workspace/authorize-workspace-access.ts— new shared owner-access gateapps/builder/src/middlewares/{auth,workspace-token-auth}.ts,apps/builder/src/orpc.ts— wired to the new gatepackages/business/src/{tag,saved-reply,custom-field,flow,flow-version,workspace}/service.ts— updated to use repositoriesapps/builder/__tests__/*→packages/business/**/__tests__/*; newpackages/database/__tests__/{tag,saved-reply}-repository.test.tsTest plan
pnpm lint(ultracite) — passed via pre-commit hookpnpm --filter builder check-types/ workspace-wide typecheck — passed via pre-commit hook (58/58 tasks)pnpm --filter @chatbotx.io/database db:migrate— not run; migration SQL is additive-only and awaiting explicit approval per project migration-safety rule