diff --git a/apps/web/src/app/w/[workspaceId]/settings/page.tsx b/apps/web/src/app/w/[workspaceId]/settings/page.tsx index beb2695..b67ca66 100644 --- a/apps/web/src/app/w/[workspaceId]/settings/page.tsx +++ b/apps/web/src/app/w/[workspaceId]/settings/page.tsx @@ -60,7 +60,7 @@ export default async function WorkspaceSettingsPage({ params }: PageProps<"/w/[w {data && github.ok && docRepos.length > 0 && (

Docs folders

-

Empty shows the whole repo. Enter a folder, such as docs, to show only that folder.

+

Each repo shows its docs folder. Enter another folder, or leave it empty to show the whole repo.

({ nodeId: r.repoNodeId, fullName: r.fullName, path: r.path, branch: r.branch, defaultBranch: r.defaultBranch }))} diff --git a/apps/web/src/app/w/[workspaceId]/settings/settings-panels.tsx b/apps/web/src/app/w/[workspaceId]/settings/settings-panels.tsx index a17eabc..bf39cdd 100644 --- a/apps/web/src/app/w/[workspaceId]/settings/settings-panels.tsx +++ b/apps/web/src/app/w/[workspaceId]/settings/settings-panels.tsx @@ -234,7 +234,7 @@ export function VisibilityPanel(props: { workspaceId: string; hideLabel: string; setHideFolder(e.target.value)} />

- From the top of each repo (or its docs folder, if one is set): “internal” hides internal/. Read Only members never see these files. Empty hides nothing. + Inside each repo's docs folder: “internal” hides docs/internal/. Read Only members never see these files. Empty hides nothing.

diff --git a/docs/INDEX.md b/docs/INDEX.md index 5a64306..b3d7d95 100644 --- a/docs/INDEX.md +++ b/docs/INDEX.md @@ -46,7 +46,8 @@ | 035 | [Docs cache: tree by folder oid, text by blob sha](decisions/035-docs-cache.md) | | 036 | [Doc writes: one signed commit, conflict check, pull request fallback](decisions/036-doc-writes.md) | | 037 | ["Rich text" is a live preview over the source, not WYSIWYG](decisions/037-rich-text-view.md) | -| 038 | [Docs show each repo's whole tree, loaded automatically](decisions/038-whole-repo-tree.md) | +| 038 | [Docs show each repo's whole tree, loaded automatically](decisions/038-whole-repo-tree.md) (default superseded by 039) | +| 039 | [Each repo shows its docs/ folder by default](decisions/039-docs-folder-default.md) | ## Features @@ -61,4 +62,4 @@ | [features/speed.md](features/speed.md) | Client store, /sync with ETag, optimistic edits, side panel, measured budgets. | | [features/keyboard.md](features/keyboard.md) | Shared keymap, command menu, pickers, bulk edit with undo, shortcut sheet. | | [features/shell.md](features/shell.md) | Workspace layout and sidebar, grouped virtualized list, dense cards, write-path line, dark mode. | -| [features/docs.md](features/docs.md) | Repo trees (whole repo by default), rich-text editor, frontmatter panel, images, commits, PR fallback, conflicts, presence. | +| [features/docs.md](features/docs.md) | Repo folders with each docs/ tree, rich-text editor, frontmatter panel, images, commits, PR fallback, conflicts, presence. | diff --git a/docs/STATE.md b/docs/STATE.md index 9748886..e340312 100644 --- a/docs/STATE.md +++ b/docs/STATE.md @@ -20,8 +20,8 @@ Last updated: 2026-11-19 ## In Progress -Docs show each repo's whole tree, loaded automatically (decision 038): `feature/docs-repo-tree`, PR -open, waiting for the owner's merge. Production runs PR #16 (deployed 2026-11-19). +Docs show each repo's `docs/` folder by default (decision 039): `feature/docs-default-folder`, PR open, +waiting for the owner's merge. Production runs PR #17 (whole repo by default, deployed 2026-11-19). First Cloudflare deploy (blocked on the owner's account steps, above). diff --git a/docs/decisions/038-whole-repo-tree.md b/docs/decisions/038-whole-repo-tree.md index d43a362..26084ac 100644 --- a/docs/decisions/038-whole-repo-tree.md +++ b/docs/decisions/038-whole-repo-tree.md @@ -2,7 +2,8 @@ Date: 2026-11-19 · Status: Accepted (owner: "I want the repos to have folders. Then I want to see the regular structure that's in the repo itself.") · Supersedes the "files outside the folder are not -shown" part of 011, and the default folder in 035 +shown" part of 011, and the default folder in 035 · **Default superseded by 039** (docs/ again; the +whole repo stays an option) ## Context Phase 4 showed only each repo's `docs/` folder, and a repo that had not synced yet waited for a diff --git a/docs/decisions/039-docs-folder-default.md b/docs/decisions/039-docs-folder-default.md new file mode 100644 index 0000000..d2589ff --- /dev/null +++ b/docs/decisions/039-docs-folder-default.md @@ -0,0 +1,26 @@ +# 039 — Each repo shows its docs/ folder by default + +Date: 2026-11-19 · Status: Accepted (owner: "show only docs by default.") · Supersedes the default in 038 + +## Context +Decision 038 made the whole repo the default root. The owner wants only each repo's `docs/` folder +shown and the rest of the files hidden. + +## Decision +- **A newly linked repo shows `docs/`.** The tree keeps 038's shape: the repo is the top folder, with + `docs/`'s own folders inside it. Files outside `docs/` are not in the tree, the API, or reachable + by URL (`isDocVisible`). +- **"Whole repo" stays an option per repo.** An Admin clears the folder in Settings → Docs folders. + Any other folder also works. +- **Migration 0007** moves rows on the 0006 default (`""`) back to `docs`. Production had no linked + repos, so no one had chosen the whole repo on purpose. +- Everything else in 038 stays: automatic loading, relinking keeps settings, images go to `assets/` + next to the doc. The hide folder counts from the docs folder again (`internal` hides + `docs/internal/`). + +## Alternatives considered +- **Markdown files only in the tree:** offered; not chosen. Every file under `docs/` shows, images + included. + +## Consequences +- A repo without a `docs/` folder shows "Nothing on this branch yet. Create a doc to start it." diff --git a/docs/features/docs.md b/docs/features/docs.md index 63db908..6a811b1 100644 --- a/docs/features/docs.md +++ b/docs/features/docs.md @@ -1,11 +1,11 @@ # Docs on web — tree, rich-text editor, commits -Shipped 2026-11-19 (Phase 4, PR #16; whole-repo trees in `feature/docs-repo-tree`). Decisions 008, 011, 012, 035, 036, 037, 038. +Shipped 2026-11-19 (Phase 4, PR #16; whole-repo trees in `feature/docs-repo-tree`). Decisions 008, 011, 012, 035, 036, 037, 038, 039. ## What it does -- **Docs** in the workspace sidebar shows each linked repo as a folder holding the repo's own - structure: every tracked file (decision 038). An Admin can narrow a repo to one folder and pick - its branch in Settings → Docs folders. Markdown files open in the editor; images and other files +- **Docs** in the workspace sidebar shows each linked repo as a folder holding its `docs/` folder's + own structure (decisions 038, 039). Files outside `docs/` are hidden. An Admin can pick another + folder, or the whole repo (empty), and the branch in Settings → Docs folders. Markdown files open in the editor; images and other files open through an access-checked proxy. Repos load on their own, with no button. - The editor opens in **Rich text**: formatted text with markdown marks hidden off the cursor's line (decision 037). **Markdown** shows the plain source. A toolbar and ⌘B / ⌘I / ⌘S format and @@ -61,7 +61,8 @@ against `gh_doc_files`. Text is fetched on first open and cached by blob sha. `workspace_repos.docs_path`, `.docs_branch`; `workspaces.hide_folder`, `.review_bot_doc_edits`; `gh_doc_roots`, `gh_doc_files`, `gh_doc_blobs` (cache, rebuilt from GitHub); `doc_pending_prs`; `doc_presence` (45-second heartbeat rows). Migration `0005_docs.sql`, additive only. -`0006_docs_whole_repo.sql` moves rows on the old `docs` default to `""` (the whole repo). +`0006_docs_whole_repo.sql` moved rows to `""` (whole repo); `0007_docs_default_folder.sql` moves them +back to `docs` (decision 039). Linking writes `docs` for new repos. ## External services GitHub App permissions already in the manifest: Contents (rw), Pull requests (rw). Webhooks diff --git a/packages/core/src/docs/paths.ts b/packages/core/src/docs/paths.ts index 9d4f5af..2a9e0bd 100644 --- a/packages/core/src/docs/paths.ts +++ b/packages/core/src/docs/paths.ts @@ -6,6 +6,8 @@ export const MAX_PATH_LENGTH = 400; /** The whole repo (decision 038). A root is "" or a folder path. */ export const REPO_ROOT = ""; +/** What a newly linked repo shows (decision 039). */ +export const DEFAULT_DOCS_ROOT = "docs"; // Control characters and backslashes never appear in a path we accept. const BAD_CHARS = /[\u0000-\u001f\u007f\\]/; diff --git a/packages/db/migrations/0007_docs_default_folder.sql b/packages/db/migrations/0007_docs_default_folder.sql new file mode 100644 index 0000000..b01b313 --- /dev/null +++ b/packages/db/migrations/0007_docs_default_folder.sql @@ -0,0 +1,3 @@ +-- Decision 039: newly linked repos show docs/ by default. Rows on the 0006 default ("" = whole repo) +-- go back to docs; production had no linked repos when 0006 ran, so no one chose "" on purpose. +UPDATE `workspace_repos` SET `docs_path` = 'docs' WHERE `docs_path` = ''; diff --git a/packages/db/migrations/meta/0007_snapshot.json b/packages/db/migrations/meta/0007_snapshot.json new file mode 100644 index 0000000..d881cac --- /dev/null +++ b/packages/db/migrations/meta/0007_snapshot.json @@ -0,0 +1,2499 @@ +{ + "id": "b8af1321-27df-4cf1-b7c7-59bf4394e8fc", + "prevId": "e58b49f0-d9f0-408a-a168-003bac08b040", + "version": "6", + "dialect": "sqlite", + "tables": { + "account_owners": { + "name": "account_owners", + "columns": { + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "account_owners_user_id_idx": { + "name": "account_owners_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "account_owners_account_id_accounts_id_fk": { + "name": "account_owners_account_id_accounts_id_fk", + "tableFrom": "account_owners", + "columnsFrom": [ + "account_id" + ], + "tableTo": "accounts", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + }, + "account_owners_user_id_users_id_fk": { + "name": "account_owners_user_id_users_id_fk", + "tableFrom": "account_owners", + "columnsFrom": [ + "user_id" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": { + "account_owners_account_id_user_id_pk": { + "columns": [ + "account_id", + "user_id" + ], + "name": "account_owners_account_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "accounts": { + "name": "accounts", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "audit_log": { + "name": "audit_log", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "via": { + "name": "via", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repo_node_id": { + "name": "repo_node_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "commit_sha": { + "name": "commit_sha", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "audit_log_workspace_at_idx": { + "name": "audit_log_workspace_at_idx", + "columns": [ + "workspace_id", + "at" + ], + "isUnique": false + }, + "audit_log_user_at_idx": { + "name": "audit_log_user_at_idx", + "columns": [ + "user_id", + "at" + ], + "isUnique": false + }, + "audit_log_target_idx": { + "name": "audit_log_target_idx", + "columns": [ + "target" + ], + "isUnique": false + } + }, + "foreignKeys": { + "audit_log_user_id_users_id_fk": { + "name": "audit_log_user_id_users_id_fk", + "tableFrom": "audit_log", + "columnsFrom": [ + "user_id" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "set null" + }, + "audit_log_workspace_id_workspaces_id_fk": { + "name": "audit_log_workspace_id_workspaces_id_fk", + "tableFrom": "audit_log", + "columnsFrom": [ + "workspace_id" + ], + "tableTo": "workspaces", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "set null" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "audit_log_via_ck": { + "name": "audit_log_via_ck", + "value": "\"audit_log\".\"via\" IN ('user', 'app', 'local')" + } + } + }, + "auth_identities": { + "name": "auth_identities", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "auth_identities_user_id_idx": { + "name": "auth_identities_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "auth_identities_provider_account_uq": { + "name": "auth_identities_provider_account_uq", + "columns": [ + "provider_id", + "account_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "auth_identities_user_id_users_id_fk": { + "name": "auth_identities_user_id_users_id_fk", + "tableFrom": "auth_identities", + "columnsFrom": [ + "user_id" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "doc_pending_prs": { + "name": "doc_pending_prs", + "columns": { + "repo_node_id": { + "name": "repo_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_branch": { + "name": "base_branch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "head_branch": { + "name": "head_branch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pr_number": { + "name": "pr_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pr_url": { + "name": "pr_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "doc_pending_prs_pr_idx": { + "name": "doc_pending_prs_pr_idx", + "columns": [ + "repo_node_id", + "pr_number" + ], + "isUnique": false + } + }, + "foreignKeys": { + "doc_pending_prs_created_by_users_id_fk": { + "name": "doc_pending_prs_created_by_users_id_fk", + "tableFrom": "doc_pending_prs", + "columnsFrom": [ + "created_by" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "set null" + } + }, + "compositePrimaryKeys": { + "doc_pending_prs_repo_node_id_base_branch_path_pk": { + "columns": [ + "repo_node_id", + "base_branch", + "path" + ], + "name": "doc_pending_prs_repo_node_id_base_branch_path_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "doc_presence": { + "name": "doc_presence", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repo_node_id": { + "name": "repo_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "doc_presence_workspace_id_workspaces_id_fk": { + "name": "doc_presence_workspace_id_workspaces_id_fk", + "tableFrom": "doc_presence", + "columnsFrom": [ + "workspace_id" + ], + "tableTo": "workspaces", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + }, + "doc_presence_user_id_users_id_fk": { + "name": "doc_presence_user_id_users_id_fk", + "tableFrom": "doc_presence", + "columnsFrom": [ + "user_id" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": { + "doc_presence_workspace_id_repo_node_id_path_user_id_pk": { + "columns": [ + "workspace_id", + "repo_node_id", + "path", + "user_id" + ], + "name": "doc_presence_workspace_id_repo_node_id_path_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_doc_blobs": { + "name": "gh_doc_blobs", + "columns": { + "sha": { + "name": "sha", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_doc_files": { + "name": "gh_doc_files", + "columns": { + "root_id": { + "name": "root_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blob_sha": { + "name": "blob_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "gh_doc_files_blob_idx": { + "name": "gh_doc_files_blob_idx", + "columns": [ + "blob_sha" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "gh_doc_files_root_id_path_pk": { + "columns": [ + "root_id", + "path" + ], + "name": "gh_doc_files_root_id_path_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_doc_roots": { + "name": "gh_doc_roots", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "repo_node_id": { + "name": "repo_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "head_oid": { + "name": "head_oid", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tree_oid": { + "name": "tree_oid", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "truncated": { + "name": "truncated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "synced_at": { + "name": "synced_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "gh_doc_roots_repo_idx": { + "name": "gh_doc_roots_repo_idx", + "columns": [ + "repo_node_id", + "branch" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_issue_links": { + "name": "gh_issue_links", + "columns": { + "issue_node_id": { + "name": "issue_node_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "parent_node_id": { + "name": "parent_node_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "blocked_by": { + "name": "blocked_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "synced_at": { + "name": "synced_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "gh_issue_links_parent_idx": { + "name": "gh_issue_links_parent_idx", + "columns": [ + "parent_node_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_issues": { + "name": "gh_issues", + "columns": { + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "repo_node_id": { + "name": "repo_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state_reason": { + "name": "state_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "labels": { + "name": "labels", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "assignees": { + "name": "assignees", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "author_login": { + "name": "author_login", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "issue_type": { + "name": "issue_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "html_url": { + "name": "html_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at_gh": { + "name": "created_at_gh", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "closed_at_gh": { + "name": "closed_at_gh", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "github_updated_at": { + "name": "github_updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted": { + "name": "deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "synced_at": { + "name": "synced_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "gh_issues_repo_number_uq": { + "name": "gh_issues_repo_number_uq", + "columns": [ + "repo_node_id", + "number" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_project_fields": { + "name": "gh_project_fields", + "columns": { + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_node_id": { + "name": "project_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data_type": { + "name": "data_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "synced_at": { + "name": "synced_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "gh_project_fields_project_idx": { + "name": "gh_project_fields_project_idx", + "columns": [ + "project_node_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_project_items": { + "name": "gh_project_items", + "columns": { + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "project_node_id": { + "name": "project_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content_node_id": { + "name": "content_node_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "draft_title": { + "name": "draft_title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "draft_body": { + "name": "draft_body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "field_values": { + "name": "field_values", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "archived": { + "name": "archived", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "github_updated_at": { + "name": "github_updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted": { + "name": "deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "synced_at": { + "name": "synced_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "gh_project_items_project_idx": { + "name": "gh_project_items_project_idx", + "columns": [ + "project_node_id" + ], + "isUnique": false + }, + "gh_project_items_content_idx": { + "name": "gh_project_items_content_idx", + "columns": [ + "content_node_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_projects": { + "name": "gh_projects", + "columns": { + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "installation_id": { + "name": "installation_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_login": { + "name": "owner_login", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "closed": { + "name": "closed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "available": { + "name": "available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "synced_at": { + "name": "synced_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_repos": { + "name": "gh_repos", + "columns": { + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "github_id": { + "name": "github_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "installation_id": { + "name": "installation_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "full_name": { + "name": "full_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "private": { + "name": "private", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "default_branch": { + "name": "default_branch", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived": { + "name": "archived", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "html_url": { + "name": "html_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "available": { + "name": "available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "synced_at": { + "name": "synced_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "gh_repos_github_id_unique": { + "name": "gh_repos_github_id_unique", + "columns": [ + "github_id" + ], + "isUnique": true + }, + "gh_repos_installation_idx": { + "name": "gh_repos_installation_idx", + "columns": [ + "installation_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "gh_sync_targets": { + "name": "gh_sync_targets", + "columns": { + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "node_id": { + "name": "node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "installation_id": { + "name": "installation_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locator": { + "name": "locator", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_full_sync_at": { + "name": "last_full_sync_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sweep_started_at": { + "name": "sweep_started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sweep_cursor": { + "name": "sweep_cursor", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "gh_sync_targets_kind_node_id_pk": { + "columns": [ + "kind", + "node_id" + ], + "name": "gh_sync_targets_kind_node_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": { + "gh_sync_targets_kind_ck": { + "name": "gh_sync_targets_kind_ck", + "value": "\"gh_sync_targets\".\"kind\" IN ('repo', 'project')" + } + } + }, + "github_app": { + "name": "github_app", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "app_id": { + "name": "app_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "webhook_secret": { + "name": "webhook_secret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "html_url": { + "name": "html_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_login": { + "name": "owner_login", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "github_app_singleton_ck": { + "name": "github_app_singleton_ck", + "value": "\"github_app\".\"id\" = 1" + } + } + }, + "github_installation_tokens": { + "name": "github_installation_tokens", + "columns": { + "installation_id": { + "name": "installation_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "github_installations": { + "name": "github_installations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_login": { + "name": "account_login", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_type": { + "name": "account_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repository_selection": { + "name": "repository_selection", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "suspended_at": { + "name": "suspended_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "github_manifest_states": { + "name": "github_manifest_states", + "columns": { + "state_hash": { + "name": "state_hash", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "used_at": { + "name": "used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "github_manifest_states_user_id_users_id_fk": { + "name": "github_manifest_states_user_id_users_id_fk", + "tableFrom": "github_manifest_states", + "columnsFrom": [ + "user_id" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "github_webhook_deliveries": { + "name": "github_webhook_deliveries", + "columns": { + "delivery_id": { + "name": "delivery_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "event": { + "name": "event", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "installation_id": { + "name": "installation_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "instance_settings": { + "name": "instance_settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "invites": { + "name": "invites", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "accepted_by": { + "name": "accepted_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "invites_token_hash_unique": { + "name": "invites_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + }, + "invites_workspace_id_idx": { + "name": "invites_workspace_id_idx", + "columns": [ + "workspace_id" + ], + "isUnique": false + }, + "invites_email_idx": { + "name": "invites_email_idx", + "columns": [ + "email" + ], + "isUnique": false + } + }, + "foreignKeys": { + "invites_workspace_id_workspaces_id_fk": { + "name": "invites_workspace_id_workspaces_id_fk", + "tableFrom": "invites", + "columnsFrom": [ + "workspace_id" + ], + "tableTo": "workspaces", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + }, + "invites_invited_by_users_id_fk": { + "name": "invites_invited_by_users_id_fk", + "tableFrom": "invites", + "columnsFrom": [ + "invited_by" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "set null" + }, + "invites_accepted_by_users_id_fk": { + "name": "invites_accepted_by_users_id_fk", + "tableFrom": "invites", + "columnsFrom": [ + "accepted_by" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "set null" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "invites_role_ck": { + "name": "invites_role_ck", + "value": "\"invites\".\"role\" IN ('owner', 'admin', 'member', 'read_only')" + }, + "invites_email_lower_ck": { + "name": "invites_email_lower_ck", + "value": "\"invites\".\"email\" = lower(\"invites\".\"email\")" + } + } + }, + "rate_limits": { + "name": "rate_limits", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_request": { + "name": "last_request", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "rate_limits_key_unique": { + "name": "rate_limits_key_unique", + "columns": [ + "key" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sessions": { + "name": "sessions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "sessions_token_unique": { + "name": "sessions_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "sessions_user_id_idx": { + "name": "sessions_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "columnsFrom": [ + "user_id" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sync_leases": { + "name": "sync_leases", + "columns": { + "name": { + "name": "name", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "holder": { + "name": "holder", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "verifications": { + "name": "verifications", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "verifications_identifier_idx": { + "name": "verifications_identifier_idx", + "columns": [ + "identifier" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "workspace_github": { + "name": "workspace_github", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "installation_id": { + "name": "installation_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_node_id": { + "name": "project_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kanban_field_id": { + "name": "kanban_field_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "start_field_id": { + "name": "start_field_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_field_id": { + "name": "target_field_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "iteration_field_id": { + "name": "iteration_field_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "linked_by": { + "name": "linked_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "linked_at": { + "name": "linked_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "workspace_github_workspace_id_workspaces_id_fk": { + "name": "workspace_github_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_github", + "columnsFrom": [ + "workspace_id" + ], + "tableTo": "workspaces", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + }, + "workspace_github_linked_by_users_id_fk": { + "name": "workspace_github_linked_by_users_id_fk", + "tableFrom": "workspace_github", + "columnsFrom": [ + "linked_by" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "set null" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "workspace_members": { + "name": "workspace_members", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "workspace_members_user_id_idx": { + "name": "workspace_members_user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "workspace_members_workspace_id_workspaces_id_fk": { + "name": "workspace_members_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_members", + "columnsFrom": [ + "workspace_id" + ], + "tableTo": "workspaces", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + }, + "workspace_members_user_id_users_id_fk": { + "name": "workspace_members_user_id_users_id_fk", + "tableFrom": "workspace_members", + "columnsFrom": [ + "user_id" + ], + "tableTo": "users", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "columns": [ + "workspace_id", + "user_id" + ], + "name": "workspace_members_workspace_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": { + "workspace_members_role_ck": { + "name": "workspace_members_role_ck", + "value": "\"workspace_members\".\"role\" IN ('owner', 'admin', 'member', 'read_only')" + } + } + }, + "workspace_repos": { + "name": "workspace_repos", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repo_node_id": { + "name": "repo_node_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "docs_path": { + "name": "docs_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'docs'" + }, + "docs_branch": { + "name": "docs_branch", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "workspace_repos_repo_idx": { + "name": "workspace_repos_repo_idx", + "columns": [ + "repo_node_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "workspace_repos_workspace_id_workspaces_id_fk": { + "name": "workspace_repos_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_repos", + "columnsFrom": [ + "workspace_id" + ], + "tableTo": "workspaces", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": { + "workspace_repos_workspace_id_repo_node_id_pk": { + "columns": [ + "workspace_id", + "repo_node_id" + ], + "name": "workspace_repos_workspace_id_repo_node_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "workspaces": { + "name": "workspaces", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "read_only_can_comment": { + "name": "read_only_can_comment", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "show_drafts_to_read_only": { + "name": "show_drafts_to_read_only", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "hide_label": { + "name": "hide_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hide_folder": { + "name": "hide_folder", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "review_bot_doc_edits": { + "name": "review_bot_doc_edits", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch() * 1000)" + } + }, + "indexes": { + "workspaces_account_id_idx": { + "name": "workspaces_account_id_idx", + "columns": [ + "account_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "workspaces_account_id_accounts_id_fk": { + "name": "workspaces_account_id_accounts_id_fk", + "tableFrom": "workspaces", + "columnsFrom": [ + "account_id" + ], + "tableTo": "accounts", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index a9e7329..6f4d15d 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -50,6 +50,13 @@ "when": 1795121091907, "tag": "0006_docs_whole_repo", "breakpoints": true + }, + { + "idx": 7, + "version": "6", + "when": 1795125653695, + "tag": "0007_docs_default_folder", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index 9c44c19..4730adb 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -409,10 +409,7 @@ export const workspaceRepos = sqliteTable( .notNull() .references(() => workspaces.id, { onDelete: "cascade" }), repoNodeId: text("repo_node_id").notNull(), - /** - * The repo's docs root for this workspace: "" = the whole repo (decision 038). Linking writes - * "" explicitly; the SQL default stays "docs" because SQLite cannot change a default in place. - */ + /** The repo's docs root for this workspace: "docs" by default, "" = the whole repo (038, 039). */ docsPath: text("docs_path").notNull().default("docs"), /** The branch docs are read from and committed to; null = the repo's default branch. */ docsBranch: text("docs_branch"), diff --git a/packages/server/src/services/docs.ts b/packages/server/src/services/docs.ts index 10e7430..61b712b 100644 --- a/packages/server/src/services/docs.ts +++ b/packages/server/src/services/docs.ts @@ -14,7 +14,7 @@ import { isMarkdownPath, normalizeDocPath, normalizeRoot, - REPO_ROOT, + DEFAULT_DOCS_ROOT, relativeToRoot, textToBytes, } from "@gitwork/core"; @@ -80,7 +80,7 @@ export async function workspaceDocRepos(db: Db, workspaceId: string): Promise { const branch = r.docsBranch ?? r.repoDefault ?? "main"; - const path = normalizeRoot(r.docsPath) ?? REPO_ROOT; + const path = normalizeRoot(r.docsPath) ?? DEFAULT_DOCS_ROOT; return { id: docRootId(r.repoNodeId, branch, path), repoNodeId: r.repoNodeId, @@ -113,7 +113,7 @@ export async function allDocRoots(db: Db, repoNodeId?: string): Promise(); for (const r of rows) { const branch = r.docsBranch ?? r.repoDefault ?? "main"; - const path = normalizeRoot(r.docsPath) ?? REPO_ROOT; + const path = normalizeRoot(r.docsPath) ?? DEFAULT_DOCS_ROOT; const id = docRootId(r.repoNodeId, branch, path); seen.set(id, { id, repoNodeId: r.repoNodeId, fullName: r.fullName, branch, path, installationId: r.installationId }); } diff --git a/packages/server/src/services/link.ts b/packages/server/src/services/link.ts index 0789d58..6505799 100644 --- a/packages/server/src/services/link.ts +++ b/packages/server/src/services/link.ts @@ -3,6 +3,7 @@ * boundary: the App's installation token can read every org that installed it, so every choice is * re-checked here with the linking user's OWN GitHub token. Nothing from the client is trusted. */ +import { DEFAULT_DOCS_ROOT } from "@gitwork/core"; import { type Db, ghProjectFields, @@ -180,7 +181,7 @@ export async function linkWorkspace(deps: GitHubServiceDeps, access: WorkspaceAc } const [previous] = await db.select().from(workspaceGithub).where(eq(workspaceGithub.workspaceId, access.workspace.id)); - // A repo that stays linked keeps its docs root and branch; a new one shows the whole repo (038). + // A repo that stays linked keeps its docs root and branch; a new one shows docs/ (decision 039). const keptDocs = new Map( (await db.select().from(workspaceRepos).where(eq(workspaceRepos.workspaceId, access.workspace.id))).map((r) => [r.repoNodeId, r]), ); @@ -206,7 +207,7 @@ export async function linkWorkspace(deps: GitHubServiceDeps, access: WorkspaceAc repoIds.map((repoNodeId) => ({ workspaceId, repoNodeId, - docsPath: keptDocs.get(repoNodeId)?.docsPath ?? "", + docsPath: keptDocs.get(repoNodeId)?.docsPath ?? DEFAULT_DOCS_ROOT, docsBranch: keptDocs.get(repoNodeId)?.docsBranch ?? null, })), ), diff --git a/packages/server/test/api-docs.test.ts b/packages/server/test/api-docs.test.ts index 8a26694..e5c99f6 100644 --- a/packages/server/test/api-docs.test.ts +++ b/packages/server/test/api-docs.test.ts @@ -43,7 +43,7 @@ describe.each(drivers)("/api/v1 docs on $name", (driver: TestDriver) => { deps = { database, auth: { ...auth.auth, api: api2 } as never, email: auth.email, baseURL: BASE_URL, github: { app: APP, client: w.client } }; for (const user of ["jane", "max", "rita"]) cookies[user] = await signIn(auth.auth, auth.email, `${user}@example.com`); expect((await api("PUT", "/github", { as: "jane", body: { installationId: 99, projectNodeId: IDS.board, repoNodeIds: [IDS.site] } })).status).toBe(200); - expect((await api("PATCH", "/settings", { as: "jane", body: { hideFolder: "docs/internal" } })).status).toBe(204); + expect((await api("PATCH", "/settings", { as: "jane", body: { hideFolder: "internal" } })).status).toBe(204); }); it("returns 401 without a session", async () => { diff --git a/packages/server/test/docs.test.ts b/packages/server/test/docs.test.ts index 04d032d..17892d3 100644 --- a/packages/server/test/docs.test.ts +++ b/packages/server/test/docs.test.ts @@ -73,8 +73,7 @@ describe.each(drivers)("docs on $name", (driver: TestDriver) => { "docs/bad.md": new Uint8Array([0x23, 0x20, 0xff, 0x0a]), }); await linkWorkspace(w.deps, await w.access("jane"), { installationId: 99, projectNodeId: IDS.board, repoNodeIds: [IDS.site] }); - // These tests cover a repo narrowed to its docs/ folder; "whole repo" below covers the default. - await setDocsConfig(w.deps, await w.access("jane"), { repoNodeId: IDS.site, docsPath: "docs" }); + // A newly linked repo shows docs/ (decision 039); "whole repo" below covers the option. await updateWorkspaceSettings(w.db, await w.access("owner"), { hideFolder: "Internal" }); w.fake.writes = []; }); @@ -376,7 +375,7 @@ describe.each(drivers)("docs on $name", (driver: TestDriver) => { }); }); - describe("whole repo (the default, decision 038)", () => { + describe("whole repo (an option per repo, decision 038)", () => { beforeEach(async () => { await setDocsConfig(w.deps, await w.access("jane"), { repoNodeId: IDS.site, docsPath: "" }); await updateWorkspaceSettings(w.db, await w.access("owner"), { hideFolder: "docs/internal" }); @@ -403,13 +402,12 @@ describe.each(drivers)("docs on $name", (driver: TestDriver) => { await rejects(createDoc(writer("max"), await w.access("max"), { repoNodeId: IDS.site, path: ".git/x.md" }), 404); }); - it("keeps a repo's docs settings when the workspace links again, and new repos get the whole repo", async () => { - await setDocsConfig(w.deps, await w.access("jane"), { repoNodeId: IDS.site, docsPath: "docs", docsBranch: "main" }); + it("keeps a repo's docs settings when the workspace links again, and new repos get docs/", async () => { await linkWorkspace(w.deps, await w.access("jane"), { installationId: 99, projectNodeId: IDS.board, repoNodeIds: [IDS.site, IDS.internal] }); const repos = await listDocs(w.db, await w.access("max")); expect(repos.repos.map((r) => [r.fullName, r.root]).sort()).toEqual([ - ["acme/internal", ""], - ["acme/site", "docs"], + ["acme/internal", "docs"], + ["acme/site", ""], ]); }); });