@wirecat/cli-core 0.753.0 → 1.0.0
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/CHANGELOG.md +239 -0
- package/README.md +9 -6
- package/THIRD_PARTY_NOTICES +4 -0
- package/dist/analysis/settings.d.ts +3 -1
- package/dist/analysis/settings.js +2 -1
- package/dist/attachments/extract.d.ts +1 -1
- package/dist/attachments/extract.js +1 -1
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/background/deliver.d.ts +3 -0
- package/dist/background/deliver.js +3 -0
- package/dist/background/lock.d.ts +1 -1
- package/dist/background/lock.js +1 -1
- package/dist/background/schedules.d.ts +13 -3
- package/dist/background/schedules.js +13 -3
- package/dist/background/when.d.ts +19 -5
- package/dist/background/when.js +17 -5
- package/dist/calendar/cli/answers.d.ts +1 -0
- package/dist/calendar/cli/answers.js +1 -0
- package/dist/calendar/cli/index.js +3 -1
- package/dist/calendar/feeds.d.ts +2 -0
- package/dist/calendar/feeds.js +10 -1
- package/dist/calendar/source.d.ts +5 -0
- package/dist/calendar/sync.d.ts +7 -1
- package/dist/calendar/sync.js +37 -7
- package/dist/calendar/testing/memory.js +7 -2
- package/dist/calendar/testing/sync-contract.js +2 -1
- package/dist/cli/account-rename.d.ts +3 -0
- package/dist/cli/account-rename.js +2 -1
- package/dist/cli/after-dashes.d.ts +1 -0
- package/dist/cli/after-dashes.js +1 -0
- package/dist/cli/agent-evaluation.d.ts +8 -1
- package/dist/cli/agent-evaluation.js +4 -1
- package/dist/cli/app-doctor-command.d.ts +1 -0
- package/dist/cli/app-doctor-command.js +1 -0
- package/dist/cli/ask-before-write.d.ts +1 -0
- package/dist/cli/ask-before-write.js +1 -0
- package/dist/cli/author.d.ts +1 -1
- package/dist/cli/author.js +1 -1
- package/dist/cli/base-stages-command.d.ts +2 -0
- package/dist/cli/base-stages-command.js +1 -0
- package/dist/cli/bot/api-http.d.ts +9 -3
- package/dist/cli/bot/api-http.js +7 -3
- package/dist/cli/bot/api-input.d.ts +8 -2
- package/dist/cli/bot/api-input.js +9 -3
- package/dist/cli/bot/api-rpc.d.ts +3 -1
- package/dist/cli/bot/api-rpc.js +2 -1
- package/dist/cli/bot/api.d.ts +1 -1
- package/dist/cli/bot/api.js +7 -1
- package/dist/cli/bot/context.d.ts +3 -2
- package/dist/cli/bot/context.js +1 -1
- package/dist/cli/bot/copy.d.ts +1 -0
- package/dist/cli/bot/messages.d.ts +5 -2
- package/dist/cli/bot/messages.js +5 -2
- package/dist/cli/bot/port.d.ts +10 -6
- package/dist/cli/bot/port.js +1 -1
- package/dist/cli/bot/registry.d.ts +6 -3
- package/dist/cli/bot/registry.js +6 -3
- package/dist/cli/bot/updates.d.ts +2 -1
- package/dist/cli/bot/updates.js +2 -1
- package/dist/cli/call-stats-command.d.ts +3 -0
- package/dist/cli/call-stats-command.js +1 -0
- package/dist/cli/command-contract.d.ts +3 -0
- package/dist/cli/command-contract.js +2 -0
- package/dist/cli/command-runs.d.ts +3 -1
- package/dist/cli/command-runs.js +2 -1
- package/dist/cli/commander-internals.d.ts +16 -0
- package/dist/cli/commander-internals.js +17 -0
- package/dist/cli/commands-command.d.ts +1 -0
- package/dist/cli/commands-command.js +3 -1
- package/dist/cli/compact.d.ts +13 -8
- package/dist/cli/compact.js +9 -6
- package/dist/cli/config-command.d.ts +3 -3
- package/dist/cli/config-command.js +4 -4
- package/dist/cli/config-issues.d.ts +7 -3
- package/dist/cli/config-issues.js +7 -3
- package/dist/cli/config-keys.d.ts +4 -1
- package/dist/cli/config-keys.js +4 -1
- package/dist/cli/context.d.ts +6 -2
- package/dist/cli/context.js +5 -1
- package/dist/cli/contract-evidence.d.ts +1 -0
- package/dist/cli/contract-evidence.js +1 -0
- package/dist/cli/csv.d.ts +3 -2
- package/dist/cli/csv.js +3 -2
- package/dist/cli/default-config.d.ts +2 -0
- package/dist/cli/default-config.js +2 -0
- package/dist/cli/doctor-reports-command.d.ts +5 -1
- package/dist/cli/doctor-reports-command.js +4 -1
- package/dist/cli/documents/catalog.js +2 -1
- package/dist/cli/documents/file-conflicts.js +2 -1
- package/dist/cli/documents/file-edit.js +5 -4
- package/dist/cli/documents/file-mirrors.js +4 -3
- package/dist/cli/documents/file-update.js +2 -1
- package/dist/cli/documents/folders.js +2 -1
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/early-refusal.d.ts +4 -4
- package/dist/cli/early-refusal.js +4 -4
- package/dist/cli/effects.d.ts +41 -11
- package/dist/cli/effects.js +48 -13
- package/dist/cli/entry.d.ts +4 -1
- package/dist/cli/entry.js +4 -1
- package/dist/cli/envelope.d.ts +14 -4
- package/dist/cli/envelope.js +14 -4
- package/dist/cli/execution.d.ts +1 -0
- package/dist/cli/execution.js +1 -0
- package/dist/cli/findings-input.d.ts +10 -2
- package/dist/cli/findings-input.js +10 -2
- package/dist/cli/first-run.d.ts +9 -2
- package/dist/cli/first-run.js +7 -1
- package/dist/cli/group-lock.d.ts +6 -0
- package/dist/cli/group-lock.js +5 -0
- package/dist/cli/guide.d.ts +5 -2
- package/dist/cli/guide.js +8 -4
- package/dist/cli/help/command-help.d.ts +12 -4
- package/dist/cli/help/command-help.js +13 -6
- package/dist/cli/help/first-screen.d.ts +2 -0
- package/dist/cli/help/first-screen.js +2 -0
- package/dist/cli/help/sections.d.ts +1 -0
- package/dist/cli/help/sections.js +1 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/input-policy.d.ts +3 -0
- package/dist/cli/input-policy.js +3 -0
- package/dist/cli/json-fields.d.ts +1 -0
- package/dist/cli/json-fields.js +1 -0
- package/dist/cli/list-query.d.ts +11 -5
- package/dist/cli/list-query.js +11 -5
- package/dist/cli/listings.d.ts +13 -5
- package/dist/cli/listings.js +12 -5
- package/dist/cli/local-times.d.ts +3 -2
- package/dist/cli/local-times.js +2 -1
- package/dist/cli/mcp-server-command.d.ts +4 -1
- package/dist/cli/mcp-server-command.js +2 -0
- package/dist/cli/meeting-batch.d.ts +2 -1
- package/dist/cli/meeting-batch.js +2 -1
- package/dist/cli/meeting-evidence-answer.d.ts +2 -2
- package/dist/cli/meeting-evidence-answer.js +2 -2
- package/dist/cli/meeting-meaning-command.d.ts +5 -0
- package/dist/cli/meeting-meaning-command.js +2 -0
- package/dist/cli/meeting-passage-text.d.ts +1 -0
- package/dist/cli/meeting-passage-text.js +1 -0
- package/dist/cli/meeting-preparation-answer.d.ts +1 -0
- package/dist/cli/meeting-preparation-answer.js +1 -0
- package/dist/cli/meeting-preparation-read.d.ts +2 -0
- package/dist/cli/meeting-preparation-read.js +2 -0
- package/dist/cli/meeting-project-candidates-read.d.ts +1 -0
- package/dist/cli/meeting-project-candidates-read.js +1 -0
- package/dist/cli/meeting-results.d.ts +4 -1
- package/dist/cli/meeting-results.js +4 -1
- package/dist/cli/meeting-series-inventory-read.d.ts +2 -0
- package/dist/cli/meeting-series-inventory-read.js +1 -0
- package/dist/cli/meeting-tags-command.d.ts +2 -0
- package/dist/cli/meeting-tags-command.js +1 -0
- package/dist/cli/messenger/admin-folders-command.js +2 -1
- package/dist/cli/messenger/admin-moderation-command.d.ts +1 -1
- package/dist/cli/messenger/admin-moderation-command.js +1 -1
- package/dist/cli/messenger/ask.d.ts +1 -1
- package/dist/cli/messenger/ask.js +1 -1
- package/dist/cli/messenger/context.d.ts +2 -1
- package/dist/cli/messenger/context.js +1 -0
- package/dist/cli/messenger/doctor-command.d.ts +2 -1
- package/dist/cli/messenger/doctor-command.js +2 -1
- package/dist/cli/messenger/inbox.d.ts +2 -2
- package/dist/cli/messenger/inbox.js +2 -2
- package/dist/cli/messenger/lacks.d.ts +1 -0
- package/dist/cli/messenger/lacks.js +5 -3
- package/dist/cli/messenger/mcp-command.d.ts +8 -3
- package/dist/cli/messenger/mcp-command.js +6 -2
- package/dist/cli/messenger/message-items.d.ts +3 -1
- package/dist/cli/messenger/message-items.js +1 -0
- package/dist/cli/messenger/messages-delete-command.d.ts +1 -1
- package/dist/cli/messenger/messages-delete-command.js +1 -1
- package/dist/cli/messenger/report.d.ts +4 -1
- package/dist/cli/messenger/report.js +2 -0
- package/dist/cli/messenger/search-answers.d.ts +10 -4
- package/dist/cli/messenger/search-answers.js +6 -2
- package/dist/cli/messenger/searches-command.d.ts +4 -1
- package/dist/cli/messenger/searches-command.js +4 -1
- package/dist/cli/messenger/serve-command.d.ts +1 -1
- package/dist/cli/messenger/serve-command.js +1 -1
- package/dist/cli/messenger/serve-members.d.ts +4 -1
- package/dist/cli/messenger/serve-members.js +3 -1
- package/dist/cli/messenger/serve-outdated.d.ts +8 -3
- package/dist/cli/messenger/serve-outdated.js +8 -3
- package/dist/cli/messenger/serve-relay.d.ts +1 -1
- package/dist/cli/messenger/serve-relay.js +1 -1
- package/dist/cli/messenger/serve-stems.d.ts +4 -0
- package/dist/cli/messenger/serve-stems.js +3 -0
- package/dist/cli/messenger/server-command.d.ts +1 -1
- package/dist/cli/messenger/server-command.js +1 -1
- package/dist/cli/messenger/store-maintenance-command.d.ts +1 -0
- package/dist/cli/messenger/store-maintenance-command.js +9 -4
- package/dist/cli/messenger/stored.d.ts +2 -0
- package/dist/cli/messenger/stored.js +1 -0
- package/dist/cli/messenger/tasks-command.d.ts +1 -0
- package/dist/cli/messenger/tasks-command.js +1 -0
- package/dist/cli/model-catalogue-command.d.ts +1 -0
- package/dist/cli/model-catalogue-command.js +1 -0
- package/dist/cli/oauth-session.d.ts +14 -4
- package/dist/cli/oauth-session.js +9 -2
- package/dist/cli/option-hints.js +3 -4
- package/dist/cli/paging.d.ts +1 -0
- package/dist/cli/paging.js +1 -0
- package/dist/cli/path-options.d.ts +37 -0
- package/dist/cli/path-options.js +85 -0
- package/dist/cli/permission-keys.d.ts +10 -4
- package/dist/cli/permission-keys.js +9 -3
- package/dist/cli/profile.d.ts +5 -1
- package/dist/cli/profile.js +5 -1
- package/dist/cli/program.js +3 -0
- package/dist/cli/project-evidence.d.ts +9 -1
- package/dist/cli/project-evidence.js +8 -1
- package/dist/cli/project-status-rows.d.ts +2 -1
- package/dist/cli/project-status-rows.js +2 -1
- package/dist/cli/project-status.d.ts +12 -4
- package/dist/cli/project-status.js +10 -4
- package/dist/cli/provider-refs.d.ts +1 -1
- package/dist/cli/provider-refs.js +1 -1
- package/dist/cli/relay-route.js +5 -14
- package/dist/cli/result-fields.d.ts +2 -0
- package/dist/cli/result-fields.js +2 -0
- package/dist/cli/schedule/harnesses.d.ts +10 -5
- package/dist/cli/schedule/harnesses.js +9 -5
- package/dist/cli/schedule/schedule-command.d.ts +16 -6
- package/dist/cli/schedule/schedule-command.js +11 -4
- package/dist/cli/search-left-out.d.ts +5 -1
- package/dist/cli/search-left-out.js +3 -1
- package/dist/cli/service-api-call.d.ts +1 -1
- package/dist/cli/service-api-manifest.d.ts +9 -2
- package/dist/cli/service-api-manifest.js +5 -1
- package/dist/cli/service-api.d.ts +5 -2
- package/dist/cli/service-api.js +7 -2
- package/dist/cli/settings.d.ts +9 -3
- package/dist/cli/settings.js +7 -2
- package/dist/cli/setup-answers.d.ts +3 -0
- package/dist/cli/setup-answers.js +1 -0
- package/dist/cli/shadowed-options.d.ts +1 -1
- package/dist/cli/shadowed-options.js +1 -1
- package/dist/cli/shared-command-exports.d.ts +22 -0
- package/dist/cli/shared-command-exports.js +22 -0
- package/dist/cli/steps.d.ts +5 -1
- package/dist/cli/steps.js +5 -1
- package/dist/cli/store-info.d.ts +2 -0
- package/dist/cli/store-info.js +1 -0
- package/dist/cli/store-recover.d.ts +9 -3
- package/dist/cli/store-recover.js +7 -3
- package/dist/cli/store-settings.d.ts +7 -2
- package/dist/cli/store-settings.js +7 -2
- package/dist/cli/templates-command.d.ts +1 -0
- package/dist/cli/unknown-profile.d.ts +1 -1
- package/dist/cli/unknown-profile.js +1 -1
- package/dist/content/cli/index.js +3 -1
- package/dist/content/sync.d.ts +2 -0
- package/dist/content/sync.js +8 -3
- package/dist/content/testing/sync-contract.js +6 -2
- package/dist/content/writer.d.ts +1 -1
- package/dist/content/writer.js +1 -1
- package/dist/context/evidence.d.ts +4 -0
- package/dist/crm/cli/files.d.ts +1 -1
- package/dist/crm/cli/files.js +3 -2
- package/dist/crm/cli/index.d.ts +1 -1
- package/dist/crm/cli/index.js +5 -4
- package/dist/crm/cli/records.d.ts +1 -1
- package/dist/crm/cli/records.js +1 -1
- package/dist/crm/digest.d.ts +1 -1
- package/dist/crm/foreign-contacts.d.ts +2 -2
- package/dist/crm/foreign-contacts.js +2 -2
- package/dist/crm/manifest/map.d.ts +5 -2
- package/dist/crm/manifest/map.js +14 -2
- package/dist/crm/manifest/paths.d.ts +1 -1
- package/dist/crm/source.d.ts +2 -2
- package/dist/crm/sync.d.ts +6 -2
- package/dist/crm/sync.js +16 -6
- package/dist/crm/testing/manifest-fake.d.ts +2 -1
- package/dist/crm/testing/manifest-fake.js +1 -1
- package/dist/crm/testing/sync-contract.js +7 -2
- package/dist/crm/viewer.d.ts +2 -2
- package/dist/crm/viewer.js +2 -2
- package/dist/crm/writes.d.ts +2 -2
- package/dist/crm/writes.js +1 -1
- package/dist/domain/addresses.d.ts +7 -3
- package/dist/domain/addresses.js +7 -3
- package/dist/domain/business.d.ts +21 -4
- package/dist/domain/business.js +11 -4
- package/dist/domain/categories.d.ts +1 -1
- package/dist/domain/categories.js +1 -1
- package/dist/domain/config-repair.d.ts +1 -1
- package/dist/domain/config-repair.js +1 -1
- package/dist/domain/counters.d.ts +4 -0
- package/dist/domain/counters.js +2 -0
- package/dist/domain/crm.d.ts +18 -7
- package/dist/domain/crm.js +11 -4
- package/dist/domain/deals.d.ts +6 -3
- package/dist/domain/deals.js +4 -3
- package/dist/domain/display-names.d.ts +3 -1
- package/dist/domain/display-names.js +2 -0
- package/dist/domain/finance.d.ts +8 -2
- package/dist/domain/finance.js +4 -2
- package/dist/domain/formatting.d.ts +1 -0
- package/dist/domain/knowledge.d.ts +6 -1
- package/dist/domain/knowledge.js +6 -1
- package/dist/domain/links.d.ts +14 -2
- package/dist/domain/links.js +11 -2
- package/dist/domain/locator.d.ts +4 -1
- package/dist/domain/locator.js +3 -1
- package/dist/domain/markdown.d.ts +1 -0
- package/dist/domain/markdown.js +1 -0
- package/dist/domain/models.d.ts +38 -15
- package/dist/domain/models.js +6 -3
- package/dist/domain/money.d.ts +14 -4
- package/dist/domain/money.js +10 -3
- package/dist/domain/orders.d.ts +4 -1
- package/dist/domain/orders.js +2 -1
- package/dist/domain/organization-sectors.d.ts +10 -0
- package/dist/domain/organization-sectors.generated.d.ts +11 -0
- package/dist/domain/organization-sectors.generated.js +14 -0
- package/dist/domain/organization-sectors.js +9 -0
- package/dist/domain/person-kinds.d.ts +4 -2
- package/dist/domain/person-kinds.js +1 -0
- package/dist/domain/phones.d.ts +2 -0
- package/dist/domain/phones.js +1 -0
- package/dist/domain/polls.d.ts +1 -0
- package/dist/domain/polls.js +1 -0
- package/dist/domain/providers.d.ts +22 -7
- package/dist/domain/providers.js +22 -7
- package/dist/domain/rankings-graph.d.ts +2 -0
- package/dist/domain/rankings-options.d.ts +5 -0
- package/dist/domain/rankings-options.js +1 -0
- package/dist/domain/record-types.d.ts +5 -1
- package/dist/domain/record-types.js +1 -0
- package/dist/domain/records-table.d.ts +18 -3
- package/dist/domain/records-table.js +11 -2
- package/dist/domain/records.d.ts +18 -2
- package/dist/domain/records.js +8 -1
- package/dist/domain/ref-summaries.d.ts +22 -5
- package/dist/domain/ref-summaries.js +9 -2
- package/dist/domain/references.d.ts +4 -2
- package/dist/domain/references.js +3 -2
- package/dist/domain/relation-role-labels.d.ts +5 -1
- package/dist/domain/relation-role-labels.js +4 -1
- package/dist/domain/relations.d.ts +32 -8
- package/dist/domain/relations.js +28 -8
- package/dist/domain/send-time.d.ts +1 -2
- package/dist/domain/send-time.js +1 -2
- package/dist/domain/tag-consolidation.d.ts +5 -0
- package/dist/domain/tag-redirects.d.ts +4 -1
- package/dist/domain/tag-redirects.js +1 -1
- package/dist/domain/tags.d.ts +2 -0
- package/dist/domain/tags.js +1 -0
- package/dist/domain/vcard.d.ts +4 -1
- package/dist/domain/vcard.js +2 -1
- package/dist/entities/business-context.d.ts +10 -4
- package/dist/entities/business-context.js +10 -4
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/knowledge-lists.d.ts +4 -0
- package/dist/entities/knowledge-lists.js +5 -0
- package/dist/entities/list-results.d.ts +1 -0
- package/dist/entities/list-results.js +1 -0
- package/dist/entities/listings.d.ts +12 -5
- package/dist/entities/listings.js +12 -5
- package/dist/entities/note.d.ts +1 -0
- package/dist/entities/note.js +1 -0
- package/dist/entities/store-records.d.ts +1 -0
- package/dist/entities/store-records.js +1 -0
- package/dist/errors/failures.d.ts +3 -1
- package/dist/errors/failures.js +3 -1
- package/dist/errors/reasons.d.ts +1 -0
- package/dist/errors/reasons.js +17 -41
- package/dist/errors/store-reasons.d.ts +5 -0
- package/dist/errors/store-reasons.js +62 -0
- package/dist/http/link-fetch.d.ts +1 -0
- package/dist/http/link-fetch.js +1 -0
- package/dist/http/public-url.d.ts +6 -2
- package/dist/http/public-url.js +6 -2
- package/dist/kit/contract.d.ts +1 -1
- package/dist/kit/contract.js +1 -1
- package/dist/kit/fake.d.ts +2 -1
- package/dist/kit/fake.js +1 -0
- package/dist/kit/run-scope.js +2 -1
- package/dist/kit/search-recipes.d.ts +2 -0
- package/dist/kit/search-recipes.js +1 -0
- package/dist/kit/seed.d.ts +3 -2
- package/dist/kit/seed.js +3 -2
- package/dist/mail/findings.d.ts +1 -1
- package/dist/mail/findings.js +1 -1
- package/dist/mail/score.d.ts +2 -0
- package/dist/mail/score.js +9 -2
- package/dist/mail/sync.js +18 -9
- package/dist/mcp/agent.d.ts +4 -1
- package/dist/mcp/agent.js +2 -1
- package/dist/mcp/all-profiles.d.ts +12 -4
- package/dist/mcp/all-profiles.js +10 -3
- package/dist/mcp/bot/instructions.d.ts +4 -1
- package/dist/mcp/bot/instructions.js +4 -1
- package/dist/mcp/caller.d.ts +1 -0
- package/dist/mcp/caller.js +1 -0
- package/dist/mcp/http/oauth.d.ts +2 -1
- package/dist/mcp/http/oauth.js +2 -1
- package/dist/mcp/http/serve.d.ts +4 -1
- package/dist/mcp/http/serve.js +3 -1
- package/dist/mcp/http/state.d.ts +1 -1
- package/dist/mcp/http/state.js +1 -1
- package/dist/mcp/meeting-preparation.d.ts +5 -1
- package/dist/mcp/meeting-preparation.js +5 -1
- package/dist/mcp/meeting-project-candidates.d.ts +2 -0
- package/dist/mcp/meeting-project-candidates.js +2 -0
- package/dist/mcp/meeting-series-inventory.d.ts +2 -0
- package/dist/mcp/meeting-series-inventory.js +2 -0
- package/dist/mcp/prompts.d.ts +1 -0
- package/dist/mcp/prompts.js +1 -0
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/session.d.ts +2 -2
- package/dist/mcp/session.js +2 -2
- package/dist/mcp/surface.d.ts +3 -2
- package/dist/mcp/surface.js +2 -1
- package/dist/meetings/cli/query-options.js +3 -2
- package/dist/meetings/event-store.d.ts +7 -2
- package/dist/meetings/findings-rules.d.ts +2 -0
- package/dist/meetings/findings.d.ts +5 -0
- package/dist/meetings/mcp/agent-text.d.ts +12 -4
- package/dist/meetings/mcp/agent-text.js +12 -4
- package/dist/meetings/mcp/index.d.ts +24 -24
- package/dist/meetings/payment.d.ts +15 -3
- package/dist/meetings/payment.js +14 -3
- package/dist/meetings/read-store.d.ts +8 -0
- package/dist/meetings/reference.d.ts +3 -0
- package/dist/meetings/reference.js +3 -0
- package/dist/meetings/result-items.d.ts +1 -0
- package/dist/meetings/result-items.js +1 -0
- package/dist/meetings/transcript-store.d.ts +0 -1
- package/dist/moderation/check.d.ts +3 -1
- package/dist/moderation/check.js +2 -0
- package/dist/moderation/rules.d.ts +5 -2
- package/dist/moderation/rules.js +5 -3
- package/dist/ports/app.d.ts +1 -0
- package/dist/ports/app.js +1 -0
- package/dist/ports/messenger.d.ts +55 -27
- package/dist/ports/traits.d.ts +4 -1
- package/dist/ports/wirecat-tools.d.ts +1 -1
- package/dist/ports/wirecat-tools.js +1 -1
- package/dist/readers/engine.d.ts +2 -2
- package/dist/readers/engine.js +2 -2
- package/dist/render/messages.d.ts +7 -1
- package/dist/render/messages.js +6 -1
- package/dist/replies/dry-run.d.ts +1 -0
- package/dist/replies/dry-run.js +1 -0
- package/dist/replies/rendering.d.ts +2 -0
- package/dist/replies/rendering.js +1 -0
- package/dist/replies/rules.d.ts +1 -2
- package/dist/replies/rules.js +1 -2
- package/dist/replies/serve.d.ts +8 -2
- package/dist/replies/serve.js +6 -1
- package/dist/replies/state.d.ts +1 -0
- package/dist/replies/state.js +1 -0
- package/dist/resolve.d.ts +5 -1
- package/dist/resolve.js +5 -1
- package/dist/runs/events.d.ts +3 -2
- package/dist/runs/events.js +2 -1
- package/dist/runs/log-events.d.ts +4 -1
- package/dist/runs/log-events.js +4 -1
- package/dist/runs/provider-log.d.ts +9 -1
- package/dist/runs/provider-log.js +8 -1
- package/dist/runs/recording.d.ts +9 -1
- package/dist/runs/recording.js +7 -1
- package/dist/runs/run-context.d.ts +1 -0
- package/dist/runs/run-context.js +1 -0
- package/dist/runs/run.d.ts +1 -0
- package/dist/runs/run.js +1 -0
- package/dist/runs/scope.d.ts +1 -0
- package/dist/runs/scope.js +1 -0
- package/dist/search/languages.d.ts +4 -1
- package/dist/search/languages.js +4 -1
- package/dist/search/question-plan.d.ts +3 -3
- package/dist/search/question-plan.js +3 -3
- package/dist/search/service-query.d.ts +7 -2
- package/dist/search/service-query.js +2 -0
- package/dist/sends/buttons.d.ts +7 -3
- package/dist/sends/buttons.js +6 -3
- package/dist/sends/flood.d.ts +3 -1
- package/dist/sends/flood.js +3 -1
- package/dist/sends/guard.d.ts +1 -0
- package/dist/sends/guard.js +1 -0
- package/dist/sends/guarded.d.ts +4 -1
- package/dist/sends/guarded.js +4 -1
- package/dist/sends/journal.d.ts +2 -2
- package/dist/sends/pace.d.ts +6 -1
- package/dist/sends/pace.js +5 -1
- package/dist/sends/permissions.d.ts +14 -9
- package/dist/sends/permissions.js +13 -8
- package/dist/sends/polls.d.ts +6 -3
- package/dist/sends/polls.js +6 -3
- package/dist/sends/recipients.d.ts +1 -0
- package/dist/sends/recipients.js +1 -0
- package/dist/sends/send-as.d.ts +1 -1
- package/dist/sends/send-as.js +1 -1
- package/dist/sends/upload.d.ts +6 -2
- package/dist/sends/upload.js +6 -2
- package/dist/services/business-context.d.ts +2 -2
- package/dist/services/business-context.js +1 -1
- package/dist/services/deal-context.d.ts +1 -1
- package/dist/services/documents/ports.d.ts +0 -2
- package/dist/services/embeddings.d.ts +3 -3
- package/dist/services/inbox.d.ts +6 -2
- package/dist/services/inbox.js +5 -1
- package/dist/services/index.d.ts +0 -1
- package/dist/services/index.js +0 -1
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/moderation.d.ts +1 -1
- package/dist/services/moment.d.ts +1 -0
- package/dist/services/moment.js +1 -0
- package/dist/services/organization-context.d.ts +1 -1
- package/dist/services/people.d.ts +2 -2
- package/dist/services/people.js +1 -1
- package/dist/services/person-business.d.ts +1 -1
- package/dist/services/questions.d.ts +1 -0
- package/dist/services/questions.js +1 -0
- package/dist/services/search-all-rank.d.ts +44 -0
- package/dist/services/search-all-rank.js +112 -0
- package/dist/services/search-all-tracker.d.ts +58 -0
- package/dist/services/search-all-tracker.js +155 -0
- package/dist/services/search-all.d.ts +2 -9
- package/dist/services/search-all.js +19 -200
- package/dist/services/task-rules.d.ts +1 -0
- package/dist/services/task-rules.js +1 -0
- package/dist/services/tasks.d.ts +2 -0
- package/dist/services/tasks.js +2 -0
- package/dist/services/tracker-meaning.js +1 -1
- package/dist/setup/document.d.ts +20 -4
- package/dist/setup/document.js +20 -4
- package/dist/setup/plain.d.ts +1 -0
- package/dist/setup/plain.js +1 -0
- package/dist/speech/hearing.d.ts +1 -1
- package/dist/speech/hearing.js +1 -1
- package/dist/speech/models.d.ts +1 -1
- package/dist/sqlite-runtime.d.ts +2 -0
- package/dist/sqlite-runtime.js +2 -0
- package/dist/store/account-store.d.ts +3 -2
- package/dist/store/accounts.d.ts +1 -0
- package/dist/store/areas.d.ts +41 -0
- package/dist/store/areas.js +17 -0
- package/dist/store/attachments.d.ts +2 -0
- package/dist/store/conversations.d.ts +1 -0
- package/dist/store/counters.d.ts +2 -0
- package/dist/store/damage.d.ts +4 -1
- package/dist/store/damage.js +2 -1
- package/dist/store/decision-requests.d.ts +10 -3
- package/dist/store/decision-requests.js +9 -3
- package/dist/store/decisions.d.ts +5 -1
- package/dist/store/decisions.js +4 -1
- package/dist/store/document-transfer/index.d.ts +2 -0
- package/dist/store/document-transfer/index.js +2 -0
- package/dist/store/document-transfer/model.d.ts +3 -0
- package/dist/store/driver.d.ts +2 -0
- package/dist/store/driver.js +1 -0
- package/dist/store/evidence-findings.d.ts +10 -2
- package/dist/store/evidence-findings.js +2 -0
- package/dist/store/health.d.ts +4 -1
- package/dist/store/health.js +2 -1
- package/dist/store/identity-links.d.ts +13 -4
- package/dist/store/identity-links.js +4 -1
- package/dist/store/identity-splits.d.ts +2 -1
- package/dist/store/identity-splits.js +1 -0
- package/dist/store/index.d.ts +2 -1
- package/dist/store/knowledge-query.d.ts +3 -0
- package/dist/store/knowledge-query.js +3 -0
- package/dist/store/mail-findings.d.ts +4 -1
- package/dist/store/mail-findings.js +1 -0
- package/dist/store/marks.d.ts +20 -3
- package/dist/store/marks.js +12 -1
- package/dist/store/meeting-findings.d.ts +2 -0
- package/dist/store/mentions.d.ts +2 -0
- package/dist/store/message-store.d.ts +219 -0
- package/dist/store/message-store.js +1 -0
- package/dist/store/messages.d.ts +1 -0
- package/dist/store/migrations.d.ts +8 -0
- package/dist/store/migrations.js +59 -6
- package/dist/store/open.d.ts +1 -1
- package/dist/store/open.js +1 -1
- package/dist/store/people.d.ts +27 -5
- package/dist/store/people.js +15 -1
- package/dist/store/project-transfer/manifest.d.ts +3 -1
- package/dist/store/project-transfer/manifest.js +3 -1
- package/dist/store/project-transfer/plan.d.ts +3 -1
- package/dist/store/project-transfer/plan.js +1 -1
- package/dist/store/project-transfer/preview.d.ts +2 -0
- package/dist/store/project-transfer/preview.js +1 -0
- package/dist/store/project-transfer/schema.d.ts +1 -0
- package/dist/store/project-transfer/snapshot-model.d.ts +4 -0
- package/dist/store/project-transfer/snapshot-model.js +3 -0
- package/dist/store/project-transfer/snapshot-plan.d.ts +2 -1
- package/dist/store/project-transfer/snapshot-plan.js +1 -1
- package/dist/store/project-transfer/snapshot.d.ts +3 -1
- package/dist/store/project-transfer/snapshot.js +1 -1
- package/dist/store/project-transfer/store.d.ts +4 -1
- package/dist/store/providers.d.ts +1 -0
- package/dist/store/providers.js +1 -0
- package/dist/store/public.d.ts +40 -0
- package/dist/store/public.js +30 -0
- package/dist/store/queries.d.ts +1 -1
- package/dist/store/repair.d.ts +2 -2
- package/dist/store/repair.js +2 -2
- package/dist/store/roster.d.ts +1 -0
- package/dist/store/search-index.d.ts +1 -0
- package/dist/store/searches.d.ts +1 -0
- package/dist/store/source-review.d.ts +13 -6
- package/dist/store/source-review.js +2 -1
- package/dist/store/sqlite/calendar.js +7 -2
- package/dist/store/sqlite/completeness.d.ts +1 -1
- package/dist/store/sqlite/completeness.js +1 -1
- package/dist/store/sqlite/conversations.d.ts +1 -1
- package/dist/store/sqlite/conversations.js +1 -1
- package/dist/store/sqlite/copy-viewer.d.ts +1 -1
- package/dist/store/sqlite/crm-activities.d.ts +1 -1
- package/dist/store/sqlite/crm-activity-chunks.d.ts +3 -2
- package/dist/store/sqlite/crm-activity-chunks.js +3 -2
- package/dist/store/sqlite/crm-changes.d.ts +1 -1
- package/dist/store/sqlite/crm-files.d.ts +1 -1
- package/dist/store/sqlite/crm-settings.d.ts +1 -1
- package/dist/store/sqlite/crm-settings.js +1 -1
- package/dist/store/sqlite/crm.d.ts +2 -2
- package/dist/store/sqlite/domain-organizations.d.ts +33 -0
- package/dist/store/sqlite/domain-organizations.js +230 -0
- package/dist/store/sqlite/drizzle/core.d.ts +1 -1
- package/dist/store/sqlite/drizzle/core.js +36 -0
- package/dist/store/sqlite/drizzle/core.js.map +4 -4
- package/dist/store/sqlite/identity-link-rows.d.ts +1 -1
- package/dist/store/sqlite/identity-link-rows.js +1 -1
- package/dist/store/sqlite/knowledge.d.ts +2 -9
- package/dist/store/sqlite/manifest.js +107 -0
- package/dist/store/sqlite/meeting-documents.js +0 -6
- package/dist/store/sqlite/messages.d.ts +1 -1
- package/dist/store/sqlite/messages.js +1 -1
- package/dist/store/sqlite/migrations.generated.js +673 -0
- package/dist/store/sqlite/name-traces.d.ts +1 -1
- package/dist/store/sqlite/name-traces.js +1 -1
- package/dist/store/sqlite/organization-categories.d.ts +1 -1
- package/dist/store/sqlite/organization-categories.js +1 -1
- package/dist/store/sqlite/organizations.d.ts +12 -1
- package/dist/store/sqlite/organizations.js +9 -1
- package/dist/store/sqlite/people-list.d.ts +6 -1
- package/dist/store/sqlite/people-list.js +66 -14
- package/dist/store/sqlite/person-links.d.ts +2 -2
- package/dist/store/sqlite/person-links.js +3 -3
- package/dist/store/sqlite/person-match-scan.d.ts +5 -5
- package/dist/store/sqlite/person-match-scan.js +28 -18
- package/dist/store/sqlite/pipeline-period.d.ts +1 -1
- package/dist/store/sqlite/pipeline-period.js +1 -1
- package/dist/store/sqlite/rebuild.d.ts +52 -0
- package/dist/store/sqlite/rebuild.js +176 -0
- package/dist/store/sqlite/relation-list.d.ts +1 -1
- package/dist/store/sqlite/rollback-copy.d.ts +7 -3
- package/dist/store/sqlite/rollback-copy.js +43 -6
- package/dist/store/sqlite/schema/canonical-tags.js +1 -1
- package/dist/store/sqlite/schema/decision-requests.js +1 -1
- package/dist/store/sqlite/schema/document-changes.js +1 -1
- package/dist/store/sqlite/schema/link-revisions.js +6 -3
- package/dist/store/sqlite/schema/links.js +3 -2
- package/dist/store/sqlite/schema/sender-bots.d.ts +288 -0
- package/dist/store/sqlite/schema/sender-bots.js +22 -0
- package/dist/store/sqlite/schema/tag-consolidations.js +5 -2
- package/dist/store/sqlite/schema/templates.js +1 -1
- package/dist/store/sqlite/schema.d.ts +1 -0
- package/dist/store/sqlite/schema.js +245 -108
- package/dist/store/sqlite/sender-bots.d.ts +43 -0
- package/dist/store/sqlite/sender-bots.js +189 -0
- package/dist/store/sqlite/sender-signals.d.ts +5 -2
- package/dist/store/sqlite/sender-signals.js +6 -6
- package/dist/store/sqlite/tracker.d.ts +11 -9
- package/dist/store/sqlite/tracker.js +27 -12
- package/dist/store/sqlite/vectors.d.ts +1 -1
- package/dist/store/sqlite/vectors.js +1 -1
- package/dist/store/sqlite/version-73.d.ts +12 -0
- package/dist/store/sqlite/version-73.js +114 -0
- package/dist/store/sqlite/work-tasks.js +2 -0
- package/dist/store/sqlite-warning.d.ts +1 -1
- package/dist/store/sqlite-warning.js +1 -1
- package/dist/store/store.d.ts +2 -176
- package/dist/store/store.js +1 -1
- package/dist/store/sync.d.ts +1 -0
- package/dist/store/types.d.ts +5 -3
- package/dist/store/vectors.d.ts +2 -0
- package/dist/tasks/model.d.ts +7 -1
- package/dist/tasks/model.js +6 -1
- package/dist/tasks/priority.d.ts +11 -2
- package/dist/tasks/priority.js +10 -2
- package/dist/terminal/qr.d.ts +1 -0
- package/dist/terminal/qr.js +1 -0
- package/dist/tracker/cli/index.d.ts +1 -1
- package/dist/tracker/cli/index.js +86 -25
- package/dist/tracker/manifest/manifest.d.ts +1 -1
- package/dist/tracker/manifest/manifest.js +1 -1
- package/dist/tracker/sync.d.ts +2 -0
- package/dist/tracker/sync.js +55 -25
- package/dist/tracker/testing/manifest-fake.d.ts +2 -1
- package/dist/tracker/writes.d.ts +28 -0
- package/dist/tracker/writes.js +141 -19
- package/dist/update/index.d.ts +5 -1
- package/dist/update/index.js +4 -1
- package/package.json +29 -9
- package/parity.json +4 -1
- package/dist/services/search-all-deprecated.d.ts +0 -40
- package/dist/services/search-all-deprecated.js +0 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { blob, desc, index, integer, primaryKey, real, sql, sqliteTable, text, unique, uniqueIndex, } from "./drizzle/core.js";
|
|
1
|
+
import { blob, check, desc, index, integer, primaryKey, real, sql, sqliteTable, text, unique, uniqueIndex, } from "./drizzle/core.js";
|
|
2
2
|
import { canonicalTags } from "./schema/canonical-tags.js";
|
|
3
3
|
/**
|
|
4
4
|
* The store's base tables — what `drizzle-kit generate` diffs against. Every column is explained in
|
|
@@ -7,7 +7,7 @@ import { canonicalTags } from "./schema/canonical-tags.js";
|
|
|
7
7
|
* modelled by Drizzle and live in hand-written SQL.
|
|
8
8
|
*/
|
|
9
9
|
export const accounts = sqliteTable("accounts", {
|
|
10
|
-
id: integer("id").primaryKey(),
|
|
10
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
11
11
|
provider: text("provider").notNull(),
|
|
12
12
|
externalId: text("external_id").notNull(),
|
|
13
13
|
name: text("name"),
|
|
@@ -20,6 +20,7 @@ export const accounts = sqliteTable("accounts", {
|
|
|
20
20
|
}, (table) => [
|
|
21
21
|
unique().on(table.provider, table.externalId),
|
|
22
22
|
index("accounts_by_organization_id").on(table.organizationId),
|
|
23
|
+
check("accounts_settings_json", sql `"settings" IS NULL OR json_valid("settings")`),
|
|
23
24
|
]);
|
|
24
25
|
/** Per account, what a sync remembers between runs: a delta marker, when a list was last complete. */
|
|
25
26
|
export const syncCursors = sqliteTable("sync_cursors", {
|
|
@@ -50,7 +51,7 @@ export const fetchLeases = sqliteTable("fetch_leases", {
|
|
|
50
51
|
expiresAt: integer("expires_at").notNull(),
|
|
51
52
|
}, (table) => [primaryKey({ columns: [table.chatId, table.anchor] })]);
|
|
52
53
|
export const botUpdates = sqliteTable("bot_updates", {
|
|
53
|
-
id: integer("id").primaryKey(),
|
|
54
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
54
55
|
accountId: integer("account_id")
|
|
55
56
|
.notNull()
|
|
56
57
|
.references(() => accounts.id),
|
|
@@ -65,9 +66,10 @@ export const botUpdates = sqliteTable("bot_updates", {
|
|
|
65
66
|
}, (table) => [
|
|
66
67
|
unique().on(table.accountId, table.externalId),
|
|
67
68
|
index("bot_updates_by_account_id_received_at_desc").on(table.accountId, desc(table.receivedAt)),
|
|
69
|
+
check("bot_updates_payload_json", sql `"payload" IS NULL OR json_valid("payload")`),
|
|
68
70
|
]);
|
|
69
71
|
export const syncs = sqliteTable("syncs", {
|
|
70
|
-
id: integer("id").primaryKey(),
|
|
72
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
71
73
|
accountId: integer("account_id")
|
|
72
74
|
.notNull()
|
|
73
75
|
.references(() => accounts.id),
|
|
@@ -79,9 +81,12 @@ export const syncs = sqliteTable("syncs", {
|
|
|
79
81
|
error: text("error"),
|
|
80
82
|
createdAt: integer("created_at").notNull(),
|
|
81
83
|
updatedAt: integer("updated_at").notNull(),
|
|
82
|
-
}, (table) => [
|
|
84
|
+
}, (table) => [
|
|
85
|
+
index("syncs_by_account_id").on(table.accountId),
|
|
86
|
+
check("syncs_counts_json", sql `"counts" IS NULL OR json_valid("counts")`),
|
|
87
|
+
]);
|
|
83
88
|
export const persons = sqliteTable("persons", {
|
|
84
|
-
id: integer("id").primaryKey(),
|
|
89
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
85
90
|
name: text("name"),
|
|
86
91
|
owner: integer("owner").notNull().default(0),
|
|
87
92
|
createdAt: integer("created_at").notNull(),
|
|
@@ -96,7 +101,7 @@ export const persons = sqliteTable("persons", {
|
|
|
96
101
|
index("persons_kind_to_work_out").on(table.id).where(sql `kind IS NULL`),
|
|
97
102
|
]);
|
|
98
103
|
export const identities = sqliteTable("identities", {
|
|
99
|
-
id: integer("id").primaryKey(),
|
|
104
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
100
105
|
provider: text("provider").notNull(),
|
|
101
106
|
externalId: text("external_id").notNull(),
|
|
102
107
|
username: text("username"),
|
|
@@ -114,6 +119,7 @@ export const identities = sqliteTable("identities", {
|
|
|
114
119
|
unique().on(table.provider, table.externalId),
|
|
115
120
|
index("identities_by_email").on(table.email).where(sql `email IS NOT NULL`),
|
|
116
121
|
index("identities_name_to_fold").on(table.id).where(sql `name IS NOT NULL AND name_folded IS NULL`),
|
|
122
|
+
check("identities_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
117
123
|
]);
|
|
118
124
|
export const identityLinks = sqliteTable("identity_links", {
|
|
119
125
|
identityId: integer("identity_id")
|
|
@@ -130,7 +136,7 @@ export const identityLinks = sqliteTable("identity_links", {
|
|
|
130
136
|
updatedAt: integer("updated_at").notNull(),
|
|
131
137
|
}, (table) => [index("identity_links_by_person_id").on(table.personId)]);
|
|
132
138
|
export const identityLinkEvents = sqliteTable("identity_link_events", {
|
|
133
|
-
id: integer("id").primaryKey(),
|
|
139
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
134
140
|
identityId: integer("identity_id")
|
|
135
141
|
.notNull()
|
|
136
142
|
.references(() => identities.id),
|
|
@@ -148,7 +154,7 @@ export const identityLinkEvents = sqliteTable("identity_link_events", {
|
|
|
148
154
|
]);
|
|
149
155
|
/** Each profile a person was seen with, a row when it differs from the one before; `identities` holds the latest. */
|
|
150
156
|
export const identityRevisions = sqliteTable("identity_revisions", {
|
|
151
|
-
id: integer("id").primaryKey(),
|
|
157
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
152
158
|
identityId: integer("identity_id")
|
|
153
159
|
.notNull()
|
|
154
160
|
.references(() => identities.id),
|
|
@@ -157,7 +163,10 @@ export const identityRevisions = sqliteTable("identity_revisions", {
|
|
|
157
163
|
description: text("description"),
|
|
158
164
|
marks: text("marks"),
|
|
159
165
|
createdAt: integer("created_at").notNull(),
|
|
160
|
-
}, (table) => [
|
|
166
|
+
}, (table) => [
|
|
167
|
+
index("identity_revisions_by_identity").on(table.identityId, table.createdAt),
|
|
168
|
+
check("identity_revisions_marks_json", sql `"marks" IS NULL OR json_valid("marks")`),
|
|
169
|
+
]);
|
|
161
170
|
export const accountIdentities = sqliteTable("account_identities", {
|
|
162
171
|
accountId: integer("account_id")
|
|
163
172
|
.notNull()
|
|
@@ -184,7 +193,7 @@ export const accountIdentities = sqliteTable("account_identities", {
|
|
|
184
193
|
index("account_identities_in_address_book").on(table.identityId).where(sql `address_book = 1`),
|
|
185
194
|
]);
|
|
186
195
|
export const aliases = sqliteTable("aliases", {
|
|
187
|
-
id: integer("id").primaryKey(),
|
|
196
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
188
197
|
aliasableType: text("aliasable_type").notNull(),
|
|
189
198
|
aliasableId: integer("aliasable_id").notNull(),
|
|
190
199
|
accountId: integer("account_id").references(() => accounts.id),
|
|
@@ -205,7 +214,7 @@ export const aliases = sqliteTable("aliases", {
|
|
|
205
214
|
index("aliases_by_account_id").on(table.accountId),
|
|
206
215
|
]);
|
|
207
216
|
export const organizations = sqliteTable("organizations", {
|
|
208
|
-
id: integer("id").primaryKey(),
|
|
217
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
209
218
|
kind: text("kind").notNull(),
|
|
210
219
|
name: text("name").notNull(),
|
|
211
220
|
scope: text("scope").notNull().default("personal"),
|
|
@@ -213,10 +222,10 @@ export const organizations = sqliteTable("organizations", {
|
|
|
213
222
|
createdAt: integer("created_at").notNull(),
|
|
214
223
|
updatedAt: integer("updated_at").notNull(),
|
|
215
224
|
deletedAt: integer("deleted_at"),
|
|
216
|
-
});
|
|
225
|
+
}, () => [check("organizations_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`)]);
|
|
217
226
|
/** An address as a record of its own: a `place` mention once confirmed, found again by its folded form. */
|
|
218
227
|
export const places = sqliteTable("places", {
|
|
219
|
-
id: integer("id").primaryKey(),
|
|
228
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
220
229
|
address: text("address").notNull(),
|
|
221
230
|
folded: text("folded").notNull().unique(),
|
|
222
231
|
author: text("author").notNull(),
|
|
@@ -225,7 +234,7 @@ export const places = sqliteTable("places", {
|
|
|
225
234
|
});
|
|
226
235
|
/** An identity an organization owns; apart from `identity_links`, so one identity can be someone's and an organization's. */
|
|
227
236
|
export const organizationIdentities = sqliteTable("organization_identities", {
|
|
228
|
-
id: integer("id").primaryKey(),
|
|
237
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
229
238
|
identityId: integer("identity_id")
|
|
230
239
|
.notNull()
|
|
231
240
|
.references(() => identities.id),
|
|
@@ -241,7 +250,7 @@ export const organizationIdentities = sqliteTable("organization_identities", {
|
|
|
241
250
|
index("organization_identities_by_organization_id").on(table.organizationId),
|
|
242
251
|
]);
|
|
243
252
|
export const bots = sqliteTable("bots", {
|
|
244
|
-
id: integer("id").primaryKey(),
|
|
253
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
245
254
|
name: text("name").notNull().unique(),
|
|
246
255
|
kind: text("kind").notNull(),
|
|
247
256
|
description: text("description"),
|
|
@@ -253,9 +262,13 @@ export const bots = sqliteTable("bots", {
|
|
|
253
262
|
metadata: text("metadata"),
|
|
254
263
|
createdAt: integer("created_at").notNull(),
|
|
255
264
|
updatedAt: integer("updated_at").notNull(),
|
|
256
|
-
}, (table) => [
|
|
265
|
+
}, (table) => [
|
|
266
|
+
index("bots_by_owner_person_id").on(table.ownerPersonId),
|
|
267
|
+
check("bots_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
268
|
+
]);
|
|
269
|
+
export { senderBotMoves, senderBots } from "./schema/sender-bots.js";
|
|
257
270
|
export const chats = sqliteTable("chats", {
|
|
258
|
-
id: integer("id").primaryKey(),
|
|
271
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
259
272
|
accountId: integer("account_id")
|
|
260
273
|
.notNull()
|
|
261
274
|
.references(() => accounts.id),
|
|
@@ -291,6 +304,7 @@ export const chats = sqliteTable("chats", {
|
|
|
291
304
|
index("chats_by_recency").on(table.accountId, desc(table.lastMessageAt)),
|
|
292
305
|
index("chats_title_to_fold").on(table.id).where(sql `title IS NOT NULL AND title_folded IS NULL`),
|
|
293
306
|
index("chats_by_parent_chat_id").on(table.parentChatId),
|
|
307
|
+
check("chats_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
294
308
|
]);
|
|
295
309
|
/** Who is in a chat, as the account last saw it: a list replaces the chat's membership whole. */
|
|
296
310
|
export const chatMembers = sqliteTable("chat_members", {
|
|
@@ -310,7 +324,7 @@ export const chatMembers = sqliteTable("chat_members", {
|
|
|
310
324
|
* row. `left_at` is set only from a list read whole: a cut list says nothing about who is missing.
|
|
311
325
|
*/
|
|
312
326
|
export const memberStays = sqliteTable("member_stays", {
|
|
313
|
-
id: integer("id").primaryKey(),
|
|
327
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
314
328
|
chatId: integer("chat_id")
|
|
315
329
|
.notNull()
|
|
316
330
|
.references(() => chats.id),
|
|
@@ -342,7 +356,7 @@ export const memberCounts = sqliteTable("member_counts", {
|
|
|
342
356
|
createdAt: integer("created_at").notNull(),
|
|
343
357
|
}, (table) => [primaryKey({ columns: [table.chatId, table.date] })]);
|
|
344
358
|
export const messages = sqliteTable("messages", {
|
|
345
|
-
id: integer("id").primaryKey(),
|
|
359
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
346
360
|
chatId: integer("chat_id")
|
|
347
361
|
.notNull()
|
|
348
362
|
.references(() => chats.id),
|
|
@@ -385,11 +399,19 @@ export const messages = sqliteTable("messages", {
|
|
|
385
399
|
index("messages_by_account").on(table.accountId, table.externalId),
|
|
386
400
|
// Empty once the backfill is done, so every open can ask "anything left?" without reading the table.
|
|
387
401
|
index("messages_to_normalize").on(table.id).where(sql `normalized_text IS NULL AND deleted_at IS NULL`),
|
|
402
|
+
index("messages_by_chat_id_thread_external_id")
|
|
403
|
+
.on(table.chatId, table.threadExternalId)
|
|
404
|
+
.where(sql `thread_root_id IS NULL AND thread_external_id IS NOT NULL`),
|
|
388
405
|
index("messages_by_sender_identity_id").on(table.senderIdentityId),
|
|
389
406
|
index("messages_by_thread_root_id").on(table.threadRootId),
|
|
407
|
+
check("messages_reply_to_json", sql `"reply_to" IS NULL OR json_valid("reply_to")`),
|
|
408
|
+
check("messages_forward_json", sql `"forward" IS NULL OR json_valid("forward")`),
|
|
409
|
+
check("messages_reactions_json", sql `"reactions" IS NULL OR json_valid("reactions")`),
|
|
410
|
+
check("messages_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
411
|
+
check("messages_mentions_json", sql `"mentions" IS NULL OR json_valid("mentions")`),
|
|
390
412
|
]);
|
|
391
413
|
export const messageRevisions = sqliteTable("message_revisions", {
|
|
392
|
-
id: integer("id").primaryKey(),
|
|
414
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
393
415
|
messageId: integer("message_id")
|
|
394
416
|
.notNull()
|
|
395
417
|
.references(() => messages.id),
|
|
@@ -403,7 +425,7 @@ export const messageRevisions = sqliteTable("message_revisions", {
|
|
|
403
425
|
*/
|
|
404
426
|
/** Each candidate for "the earlier message this one answers", and where it came from. */
|
|
405
427
|
export const messageLinks = sqliteTable("message_links", {
|
|
406
|
-
id: integer("id").primaryKey(),
|
|
428
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
407
429
|
/** The message's chat, kept here so a rebuild finds and drops an old build without reading `messages`. */
|
|
408
430
|
chatId: integer("chat_id")
|
|
409
431
|
.notNull()
|
|
@@ -444,7 +466,7 @@ export const messageCounterObservations = sqliteTable("message_counter_observati
|
|
|
444
466
|
* holds it, and `message_id` is set once it does. Derived — it can be heard again.
|
|
445
467
|
*/
|
|
446
468
|
export const messageTranscripts = sqliteTable("message_transcripts", {
|
|
447
|
-
id: integer("id").primaryKey(),
|
|
469
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
448
470
|
messageId: integer("message_id").references(() => messages.id),
|
|
449
471
|
chatId: integer("chat_id")
|
|
450
472
|
.notNull()
|
|
@@ -468,7 +490,7 @@ export const messageStemsPending = sqliteTable("message_stems_pending", {
|
|
|
468
490
|
* chat and external id: a vote can arrive before the poll's message is stored.
|
|
469
491
|
*/
|
|
470
492
|
export const pollVotes = sqliteTable("poll_votes", {
|
|
471
|
-
id: integer("id").primaryKey(),
|
|
493
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
472
494
|
chatId: integer("chat_id")
|
|
473
495
|
.notNull()
|
|
474
496
|
.references(() => chats.id),
|
|
@@ -483,6 +505,7 @@ export const pollVotes = sqliteTable("poll_votes", {
|
|
|
483
505
|
}, (table) => [
|
|
484
506
|
unique().on(table.chatId, table.messageExternalId, table.identityId),
|
|
485
507
|
index("poll_votes_by_identity_id").on(table.identityId),
|
|
508
|
+
check("poll_votes_answers_json", sql `"answers" IS NULL OR json_valid("answers")`),
|
|
486
509
|
]);
|
|
487
510
|
export { linkRevisions } from "./schema/link-revisions.js";
|
|
488
511
|
/**
|
|
@@ -490,7 +513,7 @@ export { linkRevisions } from "./schema/link-revisions.js";
|
|
|
490
513
|
* keys: an older build purges chats without knowing this table, and a trigger drops a purged chat's rows instead.
|
|
491
514
|
*/
|
|
492
515
|
export const chatRevisions = sqliteTable("chat_revisions", {
|
|
493
|
-
id: integer("id").primaryKey(),
|
|
516
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
494
517
|
chatId: integer("chat_id").notNull(),
|
|
495
518
|
accountId: integer("account_id").notNull(),
|
|
496
519
|
field: text("field").notNull(),
|
|
@@ -506,13 +529,13 @@ export const chatRevisions = sqliteTable("chat_revisions", {
|
|
|
506
529
|
]);
|
|
507
530
|
/** The source and time the `chat_revisions` trigger records, set by the store inside its write and gone by commit. */
|
|
508
531
|
export const chatRevisionSource = sqliteTable("chat_revision_source", {
|
|
509
|
-
id: integer("id").primaryKey(),
|
|
532
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
510
533
|
source: text("source").notNull(),
|
|
511
534
|
at: integer("at").notNull(),
|
|
512
535
|
});
|
|
513
536
|
/** Changes to who is in a chat, and to its title, for a messenger whose history is pushed to the store. */
|
|
514
537
|
export const chatEvents = sqliteTable("chat_events", {
|
|
515
|
-
id: integer("id").primaryKey(),
|
|
538
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
516
539
|
chatId: integer("chat_id")
|
|
517
540
|
.notNull()
|
|
518
541
|
.references(() => chats.id),
|
|
@@ -544,7 +567,7 @@ export const chatEventPeople = sqliteTable("chat_event_people", {
|
|
|
544
567
|
* derives `messages.reactions` from them. Keyed by chat and external id: a reaction can arrive before its message.
|
|
545
568
|
*/
|
|
546
569
|
export const messageReactions = sqliteTable("message_reactions", {
|
|
547
|
-
id: integer("id").primaryKey(),
|
|
570
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
548
571
|
chatId: integer("chat_id")
|
|
549
572
|
.notNull()
|
|
550
573
|
.references(() => chats.id),
|
|
@@ -563,7 +586,7 @@ export const messageReactions = sqliteTable("message_reactions", {
|
|
|
563
586
|
]);
|
|
564
587
|
/** One read of a chat's member list. Retention reads presence at a checkpoint from these, not from stays. */
|
|
565
588
|
export const memberObservations = sqliteTable("member_observations", {
|
|
566
|
-
id: integer("id").primaryKey(),
|
|
589
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
567
590
|
chatId: integer("chat_id")
|
|
568
591
|
.notNull()
|
|
569
592
|
.references(() => chats.id),
|
|
@@ -593,7 +616,7 @@ export const memberObservationMembers = sqliteTable("member_observation_members"
|
|
|
593
616
|
index("member_observation_members_by_identity_id").on(table.identityId),
|
|
594
617
|
]);
|
|
595
618
|
export const emailThreads = sqliteTable("email_threads", {
|
|
596
|
-
id: integer("id").primaryKey(),
|
|
619
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
597
620
|
accountId: integer("account_id")
|
|
598
621
|
.notNull()
|
|
599
622
|
.references(() => accounts.id),
|
|
@@ -609,9 +632,10 @@ export const emailThreads = sqliteTable("email_threads", {
|
|
|
609
632
|
}, (table) => [
|
|
610
633
|
unique().on(table.accountId, table.externalId),
|
|
611
634
|
index("email_threads_subject_to_fold").on(table.id).where(sql `subject IS NOT NULL AND subject_folded IS NULL`),
|
|
635
|
+
check("email_threads_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
612
636
|
]);
|
|
613
637
|
export const emails = sqliteTable("emails", {
|
|
614
|
-
id: integer("id").primaryKey(),
|
|
638
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
615
639
|
accountId: integer("account_id")
|
|
616
640
|
.notNull()
|
|
617
641
|
.references(() => accounts.id),
|
|
@@ -646,11 +670,15 @@ export const emails = sqliteTable("emails", {
|
|
|
646
670
|
unique().on(table.accountId, table.externalId),
|
|
647
671
|
index("emails_by_time").on(table.accountId, desc(table.sentAt)),
|
|
648
672
|
index("emails_by_mail_rule_id").on(table.mailRuleId).where(sql `mail_rule_id IS NOT NULL`),
|
|
673
|
+
index("emails_by_list_id").on(sql `coalesce(json_extract(headers, '$."list-id"'), json_extract(metadata, '$.listId'))`),
|
|
649
674
|
index("emails_by_email_thread_id").on(table.emailThreadId),
|
|
650
675
|
index("emails_by_from_identity_id").on(table.fromIdentityId),
|
|
676
|
+
check("emails_references_json", sql `"references" IS NULL OR json_valid("references")`),
|
|
677
|
+
check("emails_headers_json", sql `"headers" IS NULL OR json_valid("headers")`),
|
|
678
|
+
check("emails_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
651
679
|
]);
|
|
652
680
|
export const mailRules = sqliteTable("mail_rules", {
|
|
653
|
-
id: integer("id").primaryKey(),
|
|
681
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
654
682
|
accountId: integer("account_id")
|
|
655
683
|
.notNull()
|
|
656
684
|
.references(() => accounts.id),
|
|
@@ -662,9 +690,13 @@ export const mailRules = sqliteTable("mail_rules", {
|
|
|
662
690
|
decidedAt: integer("decided_at").notNull(),
|
|
663
691
|
createdAt: integer("created_at").notNull(),
|
|
664
692
|
updatedAt: integer("updated_at").notNull(),
|
|
665
|
-
}, (table) => [
|
|
693
|
+
}, (table) => [
|
|
694
|
+
unique().on(table.accountId, table.conditions),
|
|
695
|
+
check("mail_rules_conditions_json", sql `"conditions" IS NULL OR json_valid("conditions")`),
|
|
696
|
+
check("mail_rules_actions_json", sql `"actions" IS NULL OR json_valid("actions")`),
|
|
697
|
+
]);
|
|
666
698
|
export const emailRecipients = sqliteTable("email_recipients", {
|
|
667
|
-
id: integer("id").primaryKey(),
|
|
699
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
668
700
|
emailId: integer("email_id")
|
|
669
701
|
.notNull()
|
|
670
702
|
.references(() => emails.id),
|
|
@@ -680,7 +712,7 @@ export const emailRecipients = sqliteTable("email_recipients", {
|
|
|
680
712
|
index("email_recipients_by_identity_id").on(table.identityId),
|
|
681
713
|
]);
|
|
682
714
|
export const mailboxes = sqliteTable("mailboxes", {
|
|
683
|
-
id: integer("id").primaryKey(),
|
|
715
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
684
716
|
accountId: integer("account_id")
|
|
685
717
|
.notNull()
|
|
686
718
|
.references(() => accounts.id),
|
|
@@ -725,7 +757,7 @@ export const emailIndexPending = sqliteTable("email_index_pending", {
|
|
|
725
757
|
indexableType: text("indexable_type").notNull(),
|
|
726
758
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
727
759
|
export const attachments = sqliteTable("attachments", {
|
|
728
|
-
id: integer("id").primaryKey(),
|
|
760
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
729
761
|
attachableType: text("attachable_type").notNull(),
|
|
730
762
|
attachableId: integer("attachable_id").notNull(),
|
|
731
763
|
position: integer("position").notNull(),
|
|
@@ -759,6 +791,8 @@ export const attachments = sqliteTable("attachments", {
|
|
|
759
791
|
index("attachments_local_path_to_fold")
|
|
760
792
|
.on(table.id)
|
|
761
793
|
.where(sql `local_path IS NOT NULL AND local_path_folded IS NULL`),
|
|
794
|
+
check("attachments_provider_ref_json", sql `"provider_ref" IS NULL OR json_valid("provider_ref")`),
|
|
795
|
+
check("attachments_contact_json", sql `"contact" IS NULL OR json_valid("contact")`),
|
|
762
796
|
]);
|
|
763
797
|
export const transcriptIndexPending = sqliteTable("transcript_index_pending", {
|
|
764
798
|
id: integer("id").notNull(),
|
|
@@ -766,7 +800,7 @@ export const transcriptIndexPending = sqliteTable("transcript_index_pending", {
|
|
|
766
800
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
767
801
|
export { documentAnnotationTransfers } from "./schema/document-transfers.js";
|
|
768
802
|
export const documents = sqliteTable("documents", {
|
|
769
|
-
id: integer("id").primaryKey(),
|
|
803
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
770
804
|
accountId: integer("account_id")
|
|
771
805
|
.notNull()
|
|
772
806
|
.references(() => accounts.id),
|
|
@@ -798,9 +832,13 @@ export const documents = sqliteTable("documents", {
|
|
|
798
832
|
deletedAt: integer("deleted_at"),
|
|
799
833
|
pinnedFileId: integer("pinned_file_id"),
|
|
800
834
|
removal: text("removal"),
|
|
801
|
-
}, (table) => [
|
|
835
|
+
}, (table) => [
|
|
836
|
+
unique().on(table.accountId, table.externalId),
|
|
837
|
+
check("documents_front_matter_json", sql `"front_matter" IS NULL OR json_valid("front_matter")`),
|
|
838
|
+
check("documents_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
839
|
+
]);
|
|
802
840
|
export const files = sqliteTable("files", {
|
|
803
|
-
id: integer("id").primaryKey(),
|
|
841
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
804
842
|
accountId: integer("account_id")
|
|
805
843
|
.notNull()
|
|
806
844
|
.references(() => accounts.id),
|
|
@@ -828,9 +866,10 @@ export const files = sqliteTable("files", {
|
|
|
828
866
|
index("files_path_to_fold").on(table.id).where(sql `path_folded IS NULL`),
|
|
829
867
|
index("files_by_parent_id").on(table.parentId),
|
|
830
868
|
index("files_by_document_id").on(table.documentId),
|
|
869
|
+
check("files_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
831
870
|
]);
|
|
832
871
|
export const documentRevisions = sqliteTable("document_revisions", {
|
|
833
|
-
id: integer("id").primaryKey(),
|
|
872
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
834
873
|
documentId: integer("document_id")
|
|
835
874
|
.notNull()
|
|
836
875
|
.references(() => documents.id),
|
|
@@ -840,11 +879,14 @@ export const documentRevisions = sqliteTable("document_revisions", {
|
|
|
840
879
|
title: text("title"),
|
|
841
880
|
frontMatter: text("front_matter"),
|
|
842
881
|
reason: text("reason"),
|
|
843
|
-
}, (table) => [
|
|
882
|
+
}, (table) => [
|
|
883
|
+
index("document_revisions_by_document_id").on(table.documentId),
|
|
884
|
+
check("document_revisions_front_matter_json", sql `"front_matter" IS NULL OR json_valid("front_matter")`),
|
|
885
|
+
]);
|
|
844
886
|
export { documentChanges } from "./schema/document-changes.js";
|
|
845
887
|
export { documentIndexPending } from "./schema/document-index-pending.js";
|
|
846
888
|
export const notes = sqliteTable("notes", {
|
|
847
|
-
id: integer("id").primaryKey(),
|
|
889
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
848
890
|
notableType: text("notable_type").notNull(),
|
|
849
891
|
notableId: integer("notable_id").notNull(),
|
|
850
892
|
title: text("title"),
|
|
@@ -858,9 +900,10 @@ export const notes = sqliteTable("notes", {
|
|
|
858
900
|
}, (table) => [
|
|
859
901
|
index("notes_by_notable_type_notable_id").on(table.notableType, table.notableId),
|
|
860
902
|
index("notes_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
903
|
+
check("notes_author_pair", sql `("author_type" IS NULL) = ("author_id" IS NULL)`),
|
|
861
904
|
]);
|
|
862
905
|
export const noteRevisions = sqliteTable("note_revisions", {
|
|
863
|
-
id: integer("id").primaryKey(),
|
|
906
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
864
907
|
noteId: integer("note_id")
|
|
865
908
|
.notNull()
|
|
866
909
|
.references(() => notes.id),
|
|
@@ -873,7 +916,7 @@ export const noteIndexPending = sqliteTable("note_index_pending", {
|
|
|
873
916
|
indexableType: text("indexable_type").notNull(),
|
|
874
917
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
875
918
|
export const memories = sqliteTable("memories", {
|
|
876
|
-
id: integer("id").primaryKey(),
|
|
919
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
877
920
|
kind: text("kind").notNull(),
|
|
878
921
|
body: text("body").notNull(),
|
|
879
922
|
subjectType: text("subject_type"),
|
|
@@ -895,13 +938,14 @@ export const memories = sqliteTable("memories", {
|
|
|
895
938
|
index("memories_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
896
939
|
index("memories_by_supersedes_id").on(table.supersedesId),
|
|
897
940
|
index("memories_by_project_id").on(table.projectId),
|
|
941
|
+
check("memories_subject_pair", sql `("subject_type" IS NULL) = ("subject_id" IS NULL)`),
|
|
898
942
|
]);
|
|
899
943
|
export const memoryIndexPending = sqliteTable("memory_index_pending", {
|
|
900
944
|
id: integer("id").notNull(),
|
|
901
945
|
indexableType: text("indexable_type").notNull(),
|
|
902
946
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
903
947
|
export const calendars = sqliteTable("calendars", {
|
|
904
|
-
id: integer("id").primaryKey(),
|
|
948
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
905
949
|
accountId: integer("account_id")
|
|
906
950
|
.notNull()
|
|
907
951
|
.references(() => accounts.id),
|
|
@@ -917,7 +961,7 @@ export const calendars = sqliteTable("calendars", {
|
|
|
917
961
|
deletedAt: integer("deleted_at"),
|
|
918
962
|
}, (table) => [unique().on(table.accountId, table.externalId)]);
|
|
919
963
|
export const calendarEntries = sqliteTable("calendar_entries", {
|
|
920
|
-
id: integer("id").primaryKey(),
|
|
964
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
921
965
|
calendarId: integer("calendar_id")
|
|
922
966
|
.notNull()
|
|
923
967
|
.references(() => calendars.id),
|
|
@@ -972,9 +1016,11 @@ export const calendarEntries = sqliteTable("calendar_entries", {
|
|
|
972
1016
|
index("calendar_entries_by_event_series_id").on(table.eventSeriesId),
|
|
973
1017
|
index("calendar_entries_by_event_type_event_id").on(table.eventType, table.eventId),
|
|
974
1018
|
index("calendar_entries_by_organizer_identity_id").on(table.organizerIdentityId),
|
|
1019
|
+
check("calendar_entries_recurrence_json", sql `"recurrence" IS NULL OR json_valid("recurrence")`),
|
|
1020
|
+
check("calendar_entries_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
975
1021
|
]);
|
|
976
1022
|
export const calendarEntryRevisions = sqliteTable("calendar_entry_revisions", {
|
|
977
|
-
id: integer("id").primaryKey(),
|
|
1023
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
978
1024
|
entryId: integer("entry_id")
|
|
979
1025
|
.notNull()
|
|
980
1026
|
.references(() => calendarEntries.id),
|
|
@@ -989,7 +1035,7 @@ export const calendarEntryRevisions = sqliteTable("calendar_entry_revisions", {
|
|
|
989
1035
|
createdAt: integer("created_at").notNull(),
|
|
990
1036
|
}, (table) => [index("calendar_entry_revisions_by_entry_id_created_at").on(table.entryId, table.createdAt)]);
|
|
991
1037
|
export const calendarEntryParticipants = sqliteTable("calendar_entry_participants", {
|
|
992
|
-
id: integer("id").primaryKey(),
|
|
1038
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
993
1039
|
entryId: integer("entry_id")
|
|
994
1040
|
.notNull()
|
|
995
1041
|
.references(() => calendarEntries.id),
|
|
@@ -1012,7 +1058,7 @@ export const eventIndexPending = sqliteTable("event_index_pending", {
|
|
|
1012
1058
|
indexableType: text("indexable_type").notNull(),
|
|
1013
1059
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
1014
1060
|
export const eventSeries = sqliteTable("event_series", {
|
|
1015
|
-
id: integer("id").primaryKey(),
|
|
1061
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1016
1062
|
title: text("title"),
|
|
1017
1063
|
recurrence: text("recurrence"),
|
|
1018
1064
|
origin: text("origin").notNull(),
|
|
@@ -1020,7 +1066,7 @@ export const eventSeries = sqliteTable("event_series", {
|
|
|
1020
1066
|
updatedAt: integer("updated_at").notNull(),
|
|
1021
1067
|
});
|
|
1022
1068
|
export const events = sqliteTable("events", {
|
|
1023
|
-
id: integer("id").primaryKey(),
|
|
1069
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1024
1070
|
eventSeriesId: integer("event_series_id").references(() => eventSeries.id),
|
|
1025
1071
|
title: text("title"),
|
|
1026
1072
|
description: text("description"),
|
|
@@ -1037,7 +1083,7 @@ export const events = sqliteTable("events", {
|
|
|
1037
1083
|
sourceDeletedAt: integer("source_deleted_at"),
|
|
1038
1084
|
}, (table) => [index("events_by_time").on(table.startsAt), index("events_by_event_series_id").on(table.eventSeriesId)]);
|
|
1039
1085
|
export const meetingSeries = sqliteTable("meeting_series", {
|
|
1040
|
-
id: integer("id").primaryKey(),
|
|
1086
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1041
1087
|
accountId: integer("account_id")
|
|
1042
1088
|
.notNull()
|
|
1043
1089
|
.references(() => accounts.id),
|
|
@@ -1057,9 +1103,11 @@ export const meetingSeries = sqliteTable("meeting_series", {
|
|
|
1057
1103
|
unique().on(table.accountId, table.externalId),
|
|
1058
1104
|
index("meeting_series_by_event_series_id").on(table.eventSeriesId),
|
|
1059
1105
|
index("meeting_series_by_host_identity_id").on(table.hostIdentityId),
|
|
1106
|
+
check("meeting_series_recurrence_json", sql `"recurrence" IS NULL OR json_valid("recurrence")`),
|
|
1107
|
+
check("meeting_series_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1060
1108
|
]);
|
|
1061
1109
|
export const meetings = sqliteTable("meetings", {
|
|
1062
|
-
id: integer("id").primaryKey(),
|
|
1110
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1063
1111
|
accountId: integer("account_id")
|
|
1064
1112
|
.notNull()
|
|
1065
1113
|
.references(() => accounts.id),
|
|
@@ -1094,9 +1142,10 @@ export const meetings = sqliteTable("meetings", {
|
|
|
1094
1142
|
index("meetings_by_meeting_series_id").on(table.meetingSeriesId),
|
|
1095
1143
|
index("meetings_by_event_id").on(table.eventId),
|
|
1096
1144
|
index("meetings_by_host_identity_id").on(table.hostIdentityId),
|
|
1145
|
+
check("meetings_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1097
1146
|
]);
|
|
1098
1147
|
export const meetingParticipants = sqliteTable("meeting_participants", {
|
|
1099
|
-
id: integer("id").primaryKey(),
|
|
1148
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1100
1149
|
meetingId: integer("meeting_id")
|
|
1101
1150
|
.notNull()
|
|
1102
1151
|
.references(() => meetings.id),
|
|
@@ -1117,9 +1166,11 @@ export const meetingParticipants = sqliteTable("meeting_participants", {
|
|
|
1117
1166
|
}, (table) => [
|
|
1118
1167
|
unique().on(table.meetingId, table.identityId),
|
|
1119
1168
|
index("meeting_participants_by_identity_id").on(table.identityId),
|
|
1169
|
+
check("meeting_participants_sessions_json", sql `"sessions" IS NULL OR json_valid("sessions")`),
|
|
1170
|
+
check("meeting_participants_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1120
1171
|
]);
|
|
1121
1172
|
export const meetingTranscripts = sqliteTable("meeting_transcripts", {
|
|
1122
|
-
id: integer("id").primaryKey(),
|
|
1173
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1123
1174
|
meetingId: integer("meeting_id")
|
|
1124
1175
|
.notNull()
|
|
1125
1176
|
.references(() => meetings.id),
|
|
@@ -1133,9 +1184,12 @@ export const meetingTranscripts = sqliteTable("meeting_transcripts", {
|
|
|
1133
1184
|
createdAt: integer("created_at").notNull(),
|
|
1134
1185
|
updatedAt: integer("updated_at").notNull(),
|
|
1135
1186
|
deletedAt: integer("deleted_at"),
|
|
1136
|
-
}, (table) => [
|
|
1187
|
+
}, (table) => [
|
|
1188
|
+
index("meeting_transcripts_by_meeting_id").on(table.meetingId),
|
|
1189
|
+
check("meeting_transcripts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1190
|
+
]);
|
|
1137
1191
|
export const meetingTranscriptRows = sqliteTable("meeting_transcript_rows", {
|
|
1138
|
-
id: integer("id").primaryKey(),
|
|
1192
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1139
1193
|
meetingTranscriptId: integer("meeting_transcript_id")
|
|
1140
1194
|
.notNull()
|
|
1141
1195
|
.references(() => meetingTranscripts.id),
|
|
@@ -1151,9 +1205,10 @@ export const meetingTranscriptRows = sqliteTable("meeting_transcript_rows", {
|
|
|
1151
1205
|
}, (table) => [
|
|
1152
1206
|
unique().on(table.meetingTranscriptId, table.position),
|
|
1153
1207
|
index("meeting_transcript_rows_by_speaker_participant_id").on(table.speakerParticipantId),
|
|
1208
|
+
check("meeting_transcript_rows_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1154
1209
|
]);
|
|
1155
1210
|
export const meetingChatMessages = sqliteTable("meeting_chat_messages", {
|
|
1156
|
-
id: integer("id").primaryKey(),
|
|
1211
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1157
1212
|
meetingId: integer("meeting_id")
|
|
1158
1213
|
.notNull()
|
|
1159
1214
|
.references(() => meetings.id),
|
|
@@ -1173,9 +1228,10 @@ export const meetingChatMessages = sqliteTable("meeting_chat_messages", {
|
|
|
1173
1228
|
.where(sql `external_id IS NOT NULL`),
|
|
1174
1229
|
index("meeting_chat_messages_by_meeting_id").on(table.meetingId),
|
|
1175
1230
|
index("meeting_chat_messages_by_sender_participant_id").on(table.senderParticipantId),
|
|
1231
|
+
check("meeting_chat_messages_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1176
1232
|
]);
|
|
1177
1233
|
export const meetingSummaries = sqliteTable("meeting_summaries", {
|
|
1178
|
-
id: integer("id").primaryKey(),
|
|
1234
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1179
1235
|
meetingId: integer("meeting_id")
|
|
1180
1236
|
.notNull()
|
|
1181
1237
|
.references(() => meetings.id),
|
|
@@ -1191,14 +1247,19 @@ export const meetingSummaries = sqliteTable("meeting_summaries", {
|
|
|
1191
1247
|
metadata: text("metadata"),
|
|
1192
1248
|
createdAt: integer("created_at").notNull(),
|
|
1193
1249
|
updatedAt: integer("updated_at").notNull(),
|
|
1194
|
-
}, (table) => [
|
|
1250
|
+
}, (table) => [
|
|
1251
|
+
unique().on(table.meetingId, table.source),
|
|
1252
|
+
check("meeting_summaries_sections_json", sql `"sections" IS NULL OR json_valid("sections")`),
|
|
1253
|
+
check("meeting_summaries_next_steps_json", sql `"next_steps" IS NULL OR json_valid("next_steps")`),
|
|
1254
|
+
check("meeting_summaries_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1255
|
+
]);
|
|
1195
1256
|
/** Keyed by type and id: transcript rows, chat messages and summaries share the queue, and their ids overlap. */
|
|
1196
1257
|
export const meetingIndexPending = sqliteTable("meeting_index_pending", {
|
|
1197
1258
|
id: integer("id").notNull(),
|
|
1198
1259
|
indexableType: text("indexable_type").notNull(),
|
|
1199
1260
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
1200
1261
|
export const reminders = sqliteTable("reminders", {
|
|
1201
|
-
id: integer("id").primaryKey(),
|
|
1262
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1202
1263
|
taskId: integer("task_id")
|
|
1203
1264
|
.notNull()
|
|
1204
1265
|
.references(() => tasks.id),
|
|
@@ -1218,7 +1279,7 @@ export const reminders = sqliteTable("reminders", {
|
|
|
1218
1279
|
index("reminders_by_task_id").on(table.taskId),
|
|
1219
1280
|
]);
|
|
1220
1281
|
export const projects = sqliteTable("projects", {
|
|
1221
|
-
id: integer("id").primaryKey(),
|
|
1282
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1222
1283
|
key: text("key").notNull().unique(),
|
|
1223
1284
|
name: text("name").notNull(),
|
|
1224
1285
|
description: text("description"),
|
|
@@ -1240,9 +1301,10 @@ export const projects = sqliteTable("projects", {
|
|
|
1240
1301
|
index("projects_by_organization_id").on(table.organizationId),
|
|
1241
1302
|
index("projects_by_account_id").on(table.accountId),
|
|
1242
1303
|
index("projects_by_owner_type_owner_id").on(table.ownerType, table.ownerId),
|
|
1304
|
+
check("projects_owner_pair", sql `("owner_type" IS NULL) = ("owner_id" IS NULL)`),
|
|
1243
1305
|
]);
|
|
1244
1306
|
export const tasks = sqliteTable("tasks", {
|
|
1245
|
-
id: integer("id").primaryKey(),
|
|
1307
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1246
1308
|
projectId: integer("project_id")
|
|
1247
1309
|
.notNull()
|
|
1248
1310
|
.references(() => projects.id),
|
|
@@ -1310,13 +1372,16 @@ export const tasks = sqliteTable("tasks", {
|
|
|
1310
1372
|
index("tasks_by_closed_by_type_closed_by_id").on(table.closedByType, table.closedById),
|
|
1311
1373
|
index("tasks_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1312
1374
|
index("tasks_by_close_suggested_by_type_close_suggested_by_id").on(table.closeSuggestedByType, table.closeSuggestedById),
|
|
1375
|
+
check("tasks_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1376
|
+
check("tasks_closed_by_pair", sql `("closed_by_type" IS NULL) = ("closed_by_id" IS NULL)`),
|
|
1377
|
+
check("tasks_close_suggested_by_pair", sql `("close_suggested_by_type" IS NULL) = ("close_suggested_by_id" IS NULL)`),
|
|
1313
1378
|
]);
|
|
1314
1379
|
export const taskKeyCounters = sqliteTable("task_key_counters", {
|
|
1315
1380
|
prefix: text("prefix").primaryKey(),
|
|
1316
1381
|
tasksCount: integer("tasks_count").notNull(),
|
|
1317
1382
|
});
|
|
1318
1383
|
export const taskAssignments = sqliteTable("task_assignments", {
|
|
1319
|
-
id: integer("id").primaryKey(),
|
|
1384
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1320
1385
|
taskId: integer("task_id")
|
|
1321
1386
|
.notNull()
|
|
1322
1387
|
.references(() => tasks.id),
|
|
@@ -1330,7 +1395,7 @@ export const taskAssignments = sqliteTable("task_assignments", {
|
|
|
1330
1395
|
index("task_assignments_by_assignee_type_assignee_id").on(table.assigneeType, table.assigneeId),
|
|
1331
1396
|
]);
|
|
1332
1397
|
export const taskEvents = sqliteTable("task_events", {
|
|
1333
|
-
id: integer("id").primaryKey(),
|
|
1398
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1334
1399
|
taskId: integer("task_id")
|
|
1335
1400
|
.notNull()
|
|
1336
1401
|
.references(() => tasks.id),
|
|
@@ -1342,9 +1407,11 @@ export const taskEvents = sqliteTable("task_events", {
|
|
|
1342
1407
|
}, (table) => [
|
|
1343
1408
|
index("task_events_by_task_id").on(table.taskId),
|
|
1344
1409
|
index("task_events_by_actor_type_actor_id").on(table.actorType, table.actorId),
|
|
1410
|
+
check("task_events_changes_json", sql `"changes" IS NULL OR json_valid("changes")`),
|
|
1411
|
+
check("task_events_actor_pair", sql `("actor_type" IS NULL) = ("actor_id" IS NULL)`),
|
|
1345
1412
|
]);
|
|
1346
1413
|
export const taskPairs = sqliteTable("task_pairs", {
|
|
1347
|
-
id: integer("id").primaryKey(),
|
|
1414
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1348
1415
|
taskId: integer("task_id").references(() => tasks.id),
|
|
1349
1416
|
sourceLocator: text("source_locator"),
|
|
1350
1417
|
otherId: integer("other_id")
|
|
@@ -1365,13 +1432,16 @@ export const taskPairs = sqliteTable("task_pairs", {
|
|
|
1365
1432
|
index("task_pairs_by_decision_created_at").on(table.decision, table.createdAt),
|
|
1366
1433
|
index("task_pairs_by_other_id").on(table.otherId),
|
|
1367
1434
|
index("task_pairs_by_decided_by_type_decided_by_id").on(table.decidedByType, table.decidedById),
|
|
1435
|
+
check("task_pairs_levels_json", sql `"levels" IS NULL OR json_valid("levels")`),
|
|
1436
|
+
check("task_pairs_reasons_json", sql `"reasons" IS NULL OR json_valid("reasons")`),
|
|
1437
|
+
check("task_pairs_decided_by_pair", sql `("decided_by_type" IS NULL) = ("decided_by_id" IS NULL)`),
|
|
1368
1438
|
]);
|
|
1369
1439
|
export const taskIndexPending = sqliteTable("task_index_pending", {
|
|
1370
1440
|
id: integer("id").notNull(),
|
|
1371
1441
|
indexableType: text("indexable_type").notNull(),
|
|
1372
1442
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
1373
1443
|
export const decisions = sqliteTable("decisions", {
|
|
1374
|
-
id: integer("id").primaryKey(),
|
|
1444
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1375
1445
|
projectId: integer("project_id").references(() => projects.id),
|
|
1376
1446
|
statement: text("statement").notNull(),
|
|
1377
1447
|
status: text("status").notNull(),
|
|
@@ -1388,9 +1458,11 @@ export const decisions = sqliteTable("decisions", {
|
|
|
1388
1458
|
index("decisions_by_project_id").on(table.projectId),
|
|
1389
1459
|
index("decisions_by_supersedes_id").on(table.supersedesId),
|
|
1390
1460
|
index("decisions_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1461
|
+
check("decisions_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1462
|
+
check("decisions_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1391
1463
|
]);
|
|
1392
1464
|
export const facts = sqliteTable("facts", {
|
|
1393
|
-
id: integer("id").primaryKey(),
|
|
1465
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1394
1466
|
type: text("type").notNull(),
|
|
1395
1467
|
statement: text("statement").notNull(),
|
|
1396
1468
|
status: text("status").notNull(),
|
|
@@ -1416,10 +1488,13 @@ export const facts = sqliteTable("facts", {
|
|
|
1416
1488
|
index("facts_by_supersedes_id").on(table.supersedesId),
|
|
1417
1489
|
index("facts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1418
1490
|
index("facts_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1491
|
+
check("facts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1492
|
+
check("facts_subject_pair", sql `("subject_type" IS NULL) = ("subject_id" IS NULL)`),
|
|
1493
|
+
check("facts_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1419
1494
|
]);
|
|
1420
1495
|
/** One row per removed fact: that it was removed, by whom, when and why; never its text or value. */
|
|
1421
1496
|
export const factRemovals = sqliteTable("fact_removals", {
|
|
1422
|
-
id: integer("id").primaryKey(),
|
|
1497
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1423
1498
|
factId: integer("fact_id").notNull(),
|
|
1424
1499
|
subject: text("subject"),
|
|
1425
1500
|
removedBy: text("removed_by").notNull(),
|
|
@@ -1429,7 +1504,7 @@ export const factRemovals = sqliteTable("fact_removals", {
|
|
|
1429
1504
|
}, (table) => [index("fact_removals_by_removed_at").on(table.removedAt)]);
|
|
1430
1505
|
/** An invoice the owner issued or received; its total is the sum of its lines, its status follows allocations. */
|
|
1431
1506
|
export const invoices = sqliteTable("invoices", {
|
|
1432
|
-
id: integer("id").primaryKey(),
|
|
1507
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1433
1508
|
direction: text("direction").notNull(),
|
|
1434
1509
|
number: text("number"),
|
|
1435
1510
|
issuerType: text("issuer_type"),
|
|
@@ -1464,9 +1539,13 @@ export const invoices = sqliteTable("invoices", {
|
|
|
1464
1539
|
index("invoices_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1465
1540
|
index("invoices_by_contract_id").on(table.contractId),
|
|
1466
1541
|
index("invoices_by_subscription_id").on(table.subscriptionId),
|
|
1542
|
+
check("invoices_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1543
|
+
check("invoices_issuer_pair", sql `("issuer_type" IS NULL) = ("issuer_id" IS NULL)`),
|
|
1544
|
+
check("invoices_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1545
|
+
check("invoices_total_not_negative", sql `"total" IS NULL OR "total" >= 0`),
|
|
1467
1546
|
]);
|
|
1468
1547
|
export const invoiceLines = sqliteTable("invoice_lines", {
|
|
1469
|
-
id: integer("id").primaryKey(),
|
|
1548
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1470
1549
|
invoiceId: integer("invoice_id")
|
|
1471
1550
|
.notNull()
|
|
1472
1551
|
.references(() => invoices.id),
|
|
@@ -1482,10 +1561,12 @@ export const invoiceLines = sqliteTable("invoice_lines", {
|
|
|
1482
1561
|
}, (table) => [
|
|
1483
1562
|
unique().on(table.invoiceId, table.position),
|
|
1484
1563
|
index("invoice_lines_by_catalog_item_id").on(table.catalogItemId),
|
|
1564
|
+
check("invoice_lines_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1565
|
+
check("invoice_lines_unit_price_not_negative", sql `"unit_price" IS NULL OR "unit_price" >= 0`),
|
|
1485
1566
|
]);
|
|
1486
1567
|
/** Money that moved to or from the owner, in minor units of its currency. */
|
|
1487
1568
|
export const payments = sqliteTable("payments", {
|
|
1488
|
-
id: integer("id").primaryKey(),
|
|
1569
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1489
1570
|
direction: text("direction").notNull(),
|
|
1490
1571
|
payerType: text("payer_type"),
|
|
1491
1572
|
payerId: integer("payer_id"),
|
|
@@ -1517,10 +1598,14 @@ export const payments = sqliteTable("payments", {
|
|
|
1517
1598
|
index("payments_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1518
1599
|
index("payments_by_refund_of").on(table.refundOf),
|
|
1519
1600
|
index("payments_by_subscription_id").on(table.subscriptionId),
|
|
1601
|
+
check("payments_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1602
|
+
check("payments_payer_pair", sql `("payer_type" IS NULL) = ("payer_id" IS NULL)`),
|
|
1603
|
+
check("payments_payee_pair", sql `("payee_type" IS NULL) = ("payee_id" IS NULL)`),
|
|
1604
|
+
check("payments_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1520
1605
|
]);
|
|
1521
1606
|
/** How much of a payment settles an invoice; triggers keep it within both and in one currency. */
|
|
1522
1607
|
export const paymentAllocations = sqliteTable("payment_allocations", {
|
|
1523
|
-
id: integer("id").primaryKey(),
|
|
1608
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1524
1609
|
paymentId: integer("payment_id")
|
|
1525
1610
|
.notNull()
|
|
1526
1611
|
.references(() => payments.id),
|
|
@@ -1538,7 +1623,7 @@ export const paymentAllocations = sqliteTable("payment_allocations", {
|
|
|
1538
1623
|
index("payment_allocations_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1539
1624
|
]);
|
|
1540
1625
|
export const orders = sqliteTable("orders", {
|
|
1541
|
-
id: integer("id").primaryKey(),
|
|
1626
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1542
1627
|
customerType: text("customer_type").notNull(),
|
|
1543
1628
|
customerId: integer("customer_id").notNull(),
|
|
1544
1629
|
purpose: text("purpose").notNull(),
|
|
@@ -1580,10 +1665,14 @@ export const orders = sqliteTable("orders", {
|
|
|
1580
1665
|
index("orders_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1581
1666
|
index("orders_by_contract_id").on(table.contractId),
|
|
1582
1667
|
index("orders_by_deal_id").on(table.dealId),
|
|
1668
|
+
check("orders_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1669
|
+
check("orders_supplier_pair", sql `("supplier_type" IS NULL) = ("supplier_id" IS NULL)`),
|
|
1670
|
+
check("orders_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1671
|
+
check("orders_total_not_negative", sql `"total" IS NULL OR "total" >= 0`),
|
|
1583
1672
|
]);
|
|
1584
1673
|
/** A sales pipeline: the stages a deal or a lead goes through, in order; the owner's own or a CRM account's. */
|
|
1585
1674
|
export const pipelines = sqliteTable("pipelines", {
|
|
1586
|
-
id: integer("id").primaryKey(),
|
|
1675
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1587
1676
|
accountId: integer("account_id").references(() => accounts.id),
|
|
1588
1677
|
externalId: text("external_id"),
|
|
1589
1678
|
kind: text("kind").notNull().default("deal"),
|
|
@@ -1599,7 +1688,7 @@ export const pipelines = sqliteTable("pipelines", {
|
|
|
1599
1688
|
uniqueIndex("pipelines_by_name_folded_kind").on(table.nameFolded, table.kind).where(sql `account_id IS NULL`),
|
|
1600
1689
|
]);
|
|
1601
1690
|
export const pipelineStages = sqliteTable("pipeline_stages", {
|
|
1602
|
-
id: integer("id").primaryKey(),
|
|
1691
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1603
1692
|
pipelineId: integer("pipeline_id")
|
|
1604
1693
|
.notNull()
|
|
1605
1694
|
.references(() => pipelines.id),
|
|
@@ -1623,7 +1712,7 @@ export const pipelineStages = sqliteTable("pipeline_stages", {
|
|
|
1623
1712
|
]);
|
|
1624
1713
|
/** A deal: what the owner hopes to sell, where it stands in its pipeline, and whether it ended. */
|
|
1625
1714
|
export const deals = sqliteTable("deals", {
|
|
1626
|
-
id: integer("id").primaryKey(),
|
|
1715
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1627
1716
|
title: text("title").notNull(),
|
|
1628
1717
|
organizationId: integer("organization_id").references(() => organizations.id),
|
|
1629
1718
|
projectId: integer("project_id").references(() => projects.id),
|
|
@@ -1654,10 +1743,12 @@ export const deals = sqliteTable("deals", {
|
|
|
1654
1743
|
index("deals_by_project_id").on(table.projectId),
|
|
1655
1744
|
index("deals_by_stage_id").on(table.stageId),
|
|
1656
1745
|
index("deals_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1746
|
+
check("deals_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1747
|
+
check("deals_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1657
1748
|
]);
|
|
1658
1749
|
/** A lead: a first contact not yet a deal, in a lead pipeline; `deal_id` is the deal it became. */
|
|
1659
1750
|
export const leads = sqliteTable("leads", {
|
|
1660
|
-
id: integer("id").primaryKey(),
|
|
1751
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1661
1752
|
title: text("title").notNull(),
|
|
1662
1753
|
organizationId: integer("organization_id").references(() => organizations.id),
|
|
1663
1754
|
projectId: integer("project_id").references(() => projects.id),
|
|
@@ -1690,10 +1781,12 @@ export const leads = sqliteTable("leads", {
|
|
|
1690
1781
|
index("leads_by_stage_id").on(table.stageId),
|
|
1691
1782
|
index("leads_by_deal_id").on(table.dealId),
|
|
1692
1783
|
index("leads_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1784
|
+
check("leads_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1785
|
+
check("leads_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1693
1786
|
]);
|
|
1694
1787
|
/** Each stage a deal or a lead entered and when, written by triggers, so conversion between stages can be counted. */
|
|
1695
1788
|
export const pipelineStageChanges = sqliteTable("pipeline_stage_changes", {
|
|
1696
|
-
id: integer("id").primaryKey(),
|
|
1789
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1697
1790
|
itemType: text("item_type").notNull(),
|
|
1698
1791
|
itemId: integer("item_id").notNull(),
|
|
1699
1792
|
pipelineId: integer("pipeline_id")
|
|
@@ -1712,7 +1805,7 @@ export const pipelineStageChanges = sqliteTable("pipeline_stage_changes", {
|
|
|
1712
1805
|
]);
|
|
1713
1806
|
/** A CRM account's own fields on one kind; their values stay in each row's `metadata`, keyed by code. */
|
|
1714
1807
|
export const crmFields = sqliteTable("crm_fields", {
|
|
1715
|
-
id: integer("id").primaryKey(),
|
|
1808
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1716
1809
|
accountId: integer("account_id")
|
|
1717
1810
|
.notNull()
|
|
1718
1811
|
.references(() => accounts.id),
|
|
@@ -1727,10 +1820,13 @@ export const crmFields = sqliteTable("crm_fields", {
|
|
|
1727
1820
|
createdAt: integer("created_at").notNull(),
|
|
1728
1821
|
updatedAt: integer("updated_at").notNull(),
|
|
1729
1822
|
deletedAt: integer("deleted_at"),
|
|
1730
|
-
}, (table) => [
|
|
1823
|
+
}, (table) => [
|
|
1824
|
+
unique().on(table.accountId, table.kind, table.code),
|
|
1825
|
+
check("crm_fields_options_json", sql `"options" IS NULL OR json_valid("options")`),
|
|
1826
|
+
]);
|
|
1731
1827
|
/** A downloaded file of a CRM record with its text; never a download link. Only CRM code reads it, under the viewer. */
|
|
1732
1828
|
export const crmFiles = sqliteTable("crm_files", {
|
|
1733
|
-
id: integer("id").primaryKey(),
|
|
1829
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1734
1830
|
accountId: integer("account_id")
|
|
1735
1831
|
.notNull()
|
|
1736
1832
|
.references(() => accounts.id),
|
|
@@ -1758,7 +1854,7 @@ export const crmFiles = sqliteTable("crm_files", {
|
|
|
1758
1854
|
]);
|
|
1759
1855
|
/** What the owner or a supplier sells, a product or a service; a line copies its price and never reads it back. */
|
|
1760
1856
|
export const catalogItems = sqliteTable("catalog_items", {
|
|
1761
|
-
id: integer("id").primaryKey(),
|
|
1857
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1762
1858
|
kind: text("kind").notNull(),
|
|
1763
1859
|
name: text("name").notNull(),
|
|
1764
1860
|
nameFolded: text("name_folded").notNull(),
|
|
@@ -1787,9 +1883,12 @@ export const catalogItems = sqliteTable("catalog_items", {
|
|
|
1787
1883
|
.where(sql `supplier_id IS NULL AND sku IS NOT NULL AND deleted_at IS NULL`),
|
|
1788
1884
|
index("catalog_items_by_name_folded").on(table.nameFolded),
|
|
1789
1885
|
index("catalog_items_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1886
|
+
check("catalog_items_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1887
|
+
check("catalog_items_supplier_pair", sql `("supplier_type" IS NULL) = ("supplier_id" IS NULL)`),
|
|
1888
|
+
check("catalog_items_unit_price_not_negative", sql `"unit_price" IS NULL OR "unit_price" >= 0`),
|
|
1790
1889
|
]);
|
|
1791
1890
|
export const orderLines = sqliteTable("order_lines", {
|
|
1792
|
-
id: integer("id").primaryKey(),
|
|
1891
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1793
1892
|
orderId: integer("order_id")
|
|
1794
1893
|
.notNull()
|
|
1795
1894
|
.references(() => orders.id),
|
|
@@ -1804,10 +1903,12 @@ export const orderLines = sqliteTable("order_lines", {
|
|
|
1804
1903
|
}, (table) => [
|
|
1805
1904
|
unique().on(table.orderId, table.position),
|
|
1806
1905
|
index("order_lines_by_catalog_item_id").on(table.catalogItemId),
|
|
1906
|
+
check("order_lines_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1907
|
+
check("order_lines_unit_price_not_negative", sql `"unit_price" IS NULL OR "unit_price" >= 0`),
|
|
1807
1908
|
]);
|
|
1808
1909
|
/** A contract the owner works under; parties are relationships, the document an `attached` link. */
|
|
1809
1910
|
export const contracts = sqliteTable("contracts", {
|
|
1810
|
-
id: integer("id").primaryKey(),
|
|
1911
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1811
1912
|
name: text("name").notNull(),
|
|
1812
1913
|
number: text("number"),
|
|
1813
1914
|
kind: text("kind").notNull(),
|
|
@@ -1840,10 +1941,13 @@ export const contracts = sqliteTable("contracts", {
|
|
|
1840
1941
|
index("contracts_by_deal_id").on(table.dealId),
|
|
1841
1942
|
index("contracts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1842
1943
|
index("contracts_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1944
|
+
check("contracts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1945
|
+
check("contracts_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1946
|
+
check("contracts_value_not_negative", sql `"value" IS NULL OR "value" >= 0`),
|
|
1843
1947
|
]);
|
|
1844
1948
|
/** A subscription the owner bills or pays; its prices are `subscription_prices`, each a row of its own. */
|
|
1845
1949
|
export const subscriptions = sqliteTable("subscriptions", {
|
|
1846
|
-
id: integer("id").primaryKey(),
|
|
1950
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1847
1951
|
name: text("name").notNull(),
|
|
1848
1952
|
direction: text("direction").notNull(),
|
|
1849
1953
|
supplierType: text("supplier_type").notNull(),
|
|
@@ -1880,9 +1984,11 @@ export const subscriptions = sqliteTable("subscriptions", {
|
|
|
1880
1984
|
index("subscriptions_by_project_id").on(table.projectId),
|
|
1881
1985
|
index("subscriptions_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1882
1986
|
index("subscriptions_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1987
|
+
check("subscriptions_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1988
|
+
check("subscriptions_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1883
1989
|
]);
|
|
1884
1990
|
export const subscriptionPrices = sqliteTable("subscription_prices", {
|
|
1885
|
-
id: integer("id").primaryKey(),
|
|
1991
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1886
1992
|
subscriptionId: integer("subscription_id")
|
|
1887
1993
|
.notNull()
|
|
1888
1994
|
.references(() => subscriptions.id),
|
|
@@ -1905,10 +2011,13 @@ export const subscriptionPrices = sqliteTable("subscription_prices", {
|
|
|
1905
2011
|
.where(sql `review <> 'rejected'`),
|
|
1906
2012
|
index("subscription_prices_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1907
2013
|
index("subscription_prices_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
2014
|
+
check("subscription_prices_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
2015
|
+
check("subscription_prices_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
2016
|
+
check("subscription_prices_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1908
2017
|
]);
|
|
1909
2018
|
/** A bank account, card, cash box or wallet, in one currency; its balance is computed from its transactions. */
|
|
1910
2019
|
export const financialAccounts = sqliteTable("financial_accounts", {
|
|
1911
|
-
id: integer("id").primaryKey(),
|
|
2020
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1912
2021
|
name: text("name").notNull(),
|
|
1913
2022
|
nameFolded: text("name_folded").notNull(),
|
|
1914
2023
|
kind: text("kind").notNull(),
|
|
@@ -1932,10 +2041,12 @@ export const financialAccounts = sqliteTable("financial_accounts", {
|
|
|
1932
2041
|
index("financial_accounts_by_name_folded").on(table.nameFolded),
|
|
1933
2042
|
index("financial_accounts_by_holder_type_holder_id").on(table.holderType, table.holderId),
|
|
1934
2043
|
index("financial_accounts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
2044
|
+
check("financial_accounts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
2045
|
+
check("financial_accounts_holder_pair", sql `("holder_type" IS NULL) = ("holder_id" IS NULL)`),
|
|
1935
2046
|
]);
|
|
1936
2047
|
/** What a statement says moved on a financial account; a payment it settles is `payment_id`. */
|
|
1937
2048
|
export const financialTransactions = sqliteTable("financial_transactions", {
|
|
1938
|
-
id: integer("id").primaryKey(),
|
|
2049
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1939
2050
|
financialAccountId: integer("financial_account_id")
|
|
1940
2051
|
.notNull()
|
|
1941
2052
|
.references(() => financialAccounts.id),
|
|
@@ -1972,9 +2083,12 @@ export const financialTransactions = sqliteTable("financial_transactions", {
|
|
|
1972
2083
|
index("financial_transactions_by_project_id").on(table.projectId),
|
|
1973
2084
|
index("financial_transactions_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1974
2085
|
index("financial_transactions_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
2086
|
+
check("financial_transactions_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
2087
|
+
check("financial_transactions_counterparty_pair", sql `("counterparty_type" IS NULL) = ("counterparty_id" IS NULL)`),
|
|
2088
|
+
check("financial_transactions_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1975
2089
|
]);
|
|
1976
2090
|
export const transactionSplits = sqliteTable("transaction_splits", {
|
|
1977
|
-
id: integer("id").primaryKey(),
|
|
2091
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1978
2092
|
transactionId: integer("transaction_id")
|
|
1979
2093
|
.notNull()
|
|
1980
2094
|
.references(() => financialTransactions.id),
|
|
@@ -1996,7 +2110,7 @@ export { enrichments } from "./schema/enrichments.js";
|
|
|
1996
2110
|
export { templates, templatesHistory } from "./schema/templates.js";
|
|
1997
2111
|
/** What a source said about one of its records, as it said it: the layer under the entity an import makes. */
|
|
1998
2112
|
export const records = sqliteTable("records", {
|
|
1999
|
-
id: integer("id").primaryKey(),
|
|
2113
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2000
2114
|
accountId: integer("account_id")
|
|
2001
2115
|
.notNull()
|
|
2002
2116
|
.references(() => accounts.id),
|
|
@@ -2017,9 +2131,11 @@ export const records = sqliteTable("records", {
|
|
|
2017
2131
|
unique().on(table.accountId, table.type, table.externalId),
|
|
2018
2132
|
index("records_by_account_id_batch_id").on(table.accountId, table.batchId),
|
|
2019
2133
|
index("records_by_entity_type_entity_id").on(table.entityType, table.entityId),
|
|
2134
|
+
check("records_fields_json", sql `"fields" IS NULL OR json_valid("fields")`),
|
|
2135
|
+
check("records_entity_pair", sql `("entity_type" IS NULL) = ("entity_id" IS NULL)`),
|
|
2020
2136
|
]);
|
|
2021
2137
|
export const recordRelations = sqliteTable("record_relations", {
|
|
2022
|
-
id: integer("id").primaryKey(),
|
|
2138
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2023
2139
|
recordId: integer("record_id")
|
|
2024
2140
|
.notNull()
|
|
2025
2141
|
.references(() => records.id),
|
|
@@ -2036,7 +2152,7 @@ export const recordRelations = sqliteTable("record_relations", {
|
|
|
2036
2152
|
index("record_relations_by_target_id").on(table.targetId),
|
|
2037
2153
|
]);
|
|
2038
2154
|
export const proposedActions = sqliteTable("proposed_actions", {
|
|
2039
|
-
id: integer("id").primaryKey(),
|
|
2155
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2040
2156
|
kind: text("kind").notNull(),
|
|
2041
2157
|
accountId: integer("account_id").references(() => accounts.id),
|
|
2042
2158
|
targetType: text("target_type"),
|
|
@@ -2061,10 +2177,14 @@ export const proposedActions = sqliteTable("proposed_actions", {
|
|
|
2061
2177
|
index("proposed_actions_by_target_type_target_id").on(table.targetType, table.targetId),
|
|
2062
2178
|
index("proposed_actions_by_proposed_by_type_proposed_by_id").on(table.proposedByType, table.proposedById),
|
|
2063
2179
|
index("proposed_actions_by_decided_by_type_decided_by_id").on(table.decidedByType, table.decidedById),
|
|
2180
|
+
check("proposed_actions_payload_json", sql `"payload" IS NULL OR json_valid("payload")`),
|
|
2181
|
+
check("proposed_actions_result_json", sql `"result" IS NULL OR json_valid("result")`),
|
|
2182
|
+
check("proposed_actions_target_pair", sql `("target_type" IS NULL) = ("target_id" IS NULL)`),
|
|
2183
|
+
check("proposed_actions_decided_by_pair", sql `("decided_by_type" IS NULL) = ("decided_by_id" IS NULL)`),
|
|
2064
2184
|
]);
|
|
2065
2185
|
/** An audit trail that is itself readable by agents, so it names the target and never stores the arguments' text. */
|
|
2066
2186
|
export const agentActions = sqliteTable("agent_actions", {
|
|
2067
|
-
id: integer("id").primaryKey(),
|
|
2187
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2068
2188
|
actorType: text("actor_type").notNull(),
|
|
2069
2189
|
actorId: integer("actor_id").notNull(),
|
|
2070
2190
|
tool: text("tool").notNull(),
|
|
@@ -2080,6 +2200,7 @@ export const agentActions = sqliteTable("agent_actions", {
|
|
|
2080
2200
|
index("agent_actions_by_started_at_desc").on(desc(table.startedAt)),
|
|
2081
2201
|
index("agent_actions_by_actor_type_actor_id").on(table.actorType, table.actorId),
|
|
2082
2202
|
index("agent_actions_by_target_type_target_id").on(table.targetType, table.targetId),
|
|
2203
|
+
check("agent_actions_target_pair", sql `("target_type" IS NULL) = ("target_id" IS NULL)`),
|
|
2083
2204
|
]);
|
|
2084
2205
|
export { canonicalTags } from "./schema/canonical-tags.js";
|
|
2085
2206
|
export const canonicalAutoTagClaims = sqliteTable("canonical_auto_tag_claims", {
|
|
@@ -2104,7 +2225,7 @@ export { links } from "./schema/links.js";
|
|
|
2104
2225
|
* a message or a result. A row with a name is a saved search; an identical unnamed run counts on its row.
|
|
2105
2226
|
*/
|
|
2106
2227
|
export const searches = sqliteTable("searches", {
|
|
2107
|
-
id: integer("id").primaryKey(),
|
|
2228
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2108
2229
|
name: text("name").unique(),
|
|
2109
2230
|
command: text("command").notNull(),
|
|
2110
2231
|
params: text("params").notNull(),
|
|
@@ -2118,10 +2239,11 @@ export const searches = sqliteTable("searches", {
|
|
|
2118
2239
|
}, (table) => [
|
|
2119
2240
|
uniqueIndex("searches_history").on(table.command, table.params).where(sql `name IS NULL`),
|
|
2120
2241
|
index("searches_by_last_run").on(desc(table.lastRunAt)),
|
|
2242
|
+
check("searches_params_json", sql `"params" IS NULL OR json_valid("params")`),
|
|
2121
2243
|
]);
|
|
2122
2244
|
/** Polymorphic, so no foreign key to the tagged row: triggers drop a tagging when its chat or message goes. */
|
|
2123
2245
|
export const taggings = sqliteTable("taggings", {
|
|
2124
|
-
id: integer("id").primaryKey(),
|
|
2246
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2125
2247
|
tagId: integer("tag_id")
|
|
2126
2248
|
.notNull()
|
|
2127
2249
|
.references(() => canonicalTags.id),
|
|
@@ -2136,11 +2258,13 @@ export const taggings = sqliteTable("taggings", {
|
|
|
2136
2258
|
}, (table) => [
|
|
2137
2259
|
unique().on(table.tagId, table.taggableType, table.taggableId),
|
|
2138
2260
|
uniqueIndex("taggings_main_topic").on(table.taggableType, table.taggableId).where(sql `main = 1`),
|
|
2261
|
+
index("taggings_by_taggable_type_taggable_id").on(table.taggableType, table.taggableId),
|
|
2139
2262
|
index("taggings_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
2263
|
+
check("taggings_author_pair", sql `("author_type" IS NULL) = ("author_id" IS NULL)`),
|
|
2140
2264
|
]);
|
|
2141
2265
|
export { tagConsolidations, tagRedirects } from "./schema/tag-consolidations.js";
|
|
2142
2266
|
export const entityLinkEvents = sqliteTable("entity_link_events", {
|
|
2143
|
-
id: integer("id").primaryKey(),
|
|
2267
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2144
2268
|
linkableType: text("linkable_type").notNull(),
|
|
2145
2269
|
linkableId: integer("linkable_id").notNull(),
|
|
2146
2270
|
entityType: text("entity_type").notNull(),
|
|
@@ -2155,7 +2279,7 @@ export const entityLinkEvents = sqliteTable("entity_link_events", {
|
|
|
2155
2279
|
index("entity_link_events_by_entity_type_to_entity_id").on(table.entityType, table.toEntityId),
|
|
2156
2280
|
]);
|
|
2157
2281
|
export const linkReviews = sqliteTable("link_reviews", {
|
|
2158
|
-
id: integer("id").primaryKey(),
|
|
2282
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2159
2283
|
linkableType: text("linkable_type").notNull(),
|
|
2160
2284
|
linkableId: integer("linkable_id").notNull(),
|
|
2161
2285
|
entityType: text("entity_type").notNull(),
|
|
@@ -2170,9 +2294,10 @@ export const linkReviews = sqliteTable("link_reviews", {
|
|
|
2170
2294
|
}, (table) => [
|
|
2171
2295
|
unique().on(table.linkableType, table.linkableId, table.entityType),
|
|
2172
2296
|
index("link_reviews_by_status_created_at").on(table.status, table.createdAt),
|
|
2297
|
+
check("link_reviews_candidates_json", sql `"candidates" IS NULL OR json_valid("candidates")`),
|
|
2173
2298
|
]);
|
|
2174
2299
|
export const conversations = sqliteTable("conversations", {
|
|
2175
|
-
id: integer("id").primaryKey(),
|
|
2300
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2176
2301
|
chatId: integer("chat_id")
|
|
2177
2302
|
.notNull()
|
|
2178
2303
|
.references(() => chats.id, { onDelete: "cascade" }),
|
|
@@ -2383,7 +2508,7 @@ export const conversationReadiness = sqliteTable("conversation_readiness", {
|
|
|
2383
2508
|
* columns are what lists, filters and search read; the rest of the record is `data`, JSON in the domain's field names.
|
|
2384
2509
|
*/
|
|
2385
2510
|
export const trackerItems = sqliteTable("tracker_items", {
|
|
2386
|
-
id: integer("id").primaryKey(),
|
|
2511
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2387
2512
|
accountId: integer("account_id")
|
|
2388
2513
|
.notNull()
|
|
2389
2514
|
.references(() => accounts.id),
|
|
@@ -2405,10 +2530,11 @@ export const trackerItems = sqliteTable("tracker_items", {
|
|
|
2405
2530
|
}, (table) => [
|
|
2406
2531
|
unique().on(table.accountId, table.kind, table.externalId),
|
|
2407
2532
|
index("tracker_items_by_account_id_kind_parent_id").on(table.accountId, table.kind, table.parentId),
|
|
2533
|
+
check("tracker_items_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2408
2534
|
]);
|
|
2409
2535
|
/** A site or a social account a content account publishes on. */
|
|
2410
2536
|
export const contentChannels = sqliteTable("content_channels", {
|
|
2411
|
-
id: integer("id").primaryKey(),
|
|
2537
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2412
2538
|
accountId: integer("account_id")
|
|
2413
2539
|
.notNull()
|
|
2414
2540
|
.references(() => accounts.id),
|
|
@@ -2422,7 +2548,7 @@ export const contentChannels = sqliteTable("content_channels", {
|
|
|
2422
2548
|
syncedAt: integer("synced_at").notNull(),
|
|
2423
2549
|
}, (table) => [unique().on(table.accountId, table.externalId)]);
|
|
2424
2550
|
export const contentAuthors = sqliteTable("content_authors", {
|
|
2425
|
-
id: integer("id").primaryKey(),
|
|
2551
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2426
2552
|
accountId: integer("account_id")
|
|
2427
2553
|
.notNull()
|
|
2428
2554
|
.references(() => accounts.id),
|
|
@@ -2433,9 +2559,12 @@ export const contentAuthors = sqliteTable("content_authors", {
|
|
|
2433
2559
|
sourceUpdatedAt: integer("source_updated_at"),
|
|
2434
2560
|
deletedAt: integer("deleted_at"),
|
|
2435
2561
|
syncedAt: integer("synced_at").notNull(),
|
|
2436
|
-
}, (table) => [
|
|
2562
|
+
}, (table) => [
|
|
2563
|
+
unique().on(table.accountId, table.externalId),
|
|
2564
|
+
check("content_authors_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2565
|
+
]);
|
|
2437
2566
|
export const contentTerms = sqliteTable("content_terms", {
|
|
2438
|
-
id: integer("id").primaryKey(),
|
|
2567
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2439
2568
|
accountId: integer("account_id")
|
|
2440
2569
|
.notNull()
|
|
2441
2570
|
.references(() => accounts.id),
|
|
@@ -2449,10 +2578,14 @@ export const contentTerms = sqliteTable("content_terms", {
|
|
|
2449
2578
|
sourceUpdatedAt: integer("source_updated_at"),
|
|
2450
2579
|
deletedAt: integer("deleted_at"),
|
|
2451
2580
|
syncedAt: integer("synced_at").notNull(),
|
|
2452
|
-
}, (table) => [
|
|
2581
|
+
}, (table) => [
|
|
2582
|
+
unique().on(table.accountId, table.externalId),
|
|
2583
|
+
index("content_terms_by_tag_id").on(table.tagId),
|
|
2584
|
+
check("content_terms_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2585
|
+
]);
|
|
2453
2586
|
/** A post or page of a blog, or a social post, with its text as Markdown; the rest of the record is `data`. */
|
|
2454
2587
|
export const contentPosts = sqliteTable("content_posts", {
|
|
2455
|
-
id: integer("id").primaryKey(),
|
|
2588
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2456
2589
|
accountId: integer("account_id")
|
|
2457
2590
|
.notNull()
|
|
2458
2591
|
.references(() => accounts.id),
|
|
@@ -2477,10 +2610,11 @@ export const contentPosts = sqliteTable("content_posts", {
|
|
|
2477
2610
|
unique().on(table.accountId, table.externalId),
|
|
2478
2611
|
index("content_posts_by_account_id_status").on(table.accountId, table.status),
|
|
2479
2612
|
index("content_posts_by_account_id_published_at").on(table.accountId, table.publishedAt),
|
|
2613
|
+
check("content_posts_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2480
2614
|
]);
|
|
2481
2615
|
/** What a sync or a write replaced in a post, and a post the source deleted, kept before the change. */
|
|
2482
2616
|
export const contentPostRevisions = sqliteTable("content_post_revisions", {
|
|
2483
|
-
id: integer("id").primaryKey(),
|
|
2617
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2484
2618
|
postId: integer("post_id")
|
|
2485
2619
|
.notNull()
|
|
2486
2620
|
.references(() => contentPosts.id),
|
|
@@ -2494,7 +2628,7 @@ export const contentPostRevisions = sqliteTable("content_post_revisions", {
|
|
|
2494
2628
|
}, (table) => [index("content_post_revisions_by_post_id_created_at").on(table.postId, table.createdAt)]);
|
|
2495
2629
|
/** One reading of a post's numbers; each reading is a new row. */
|
|
2496
2630
|
export const contentMetrics = sqliteTable("content_metrics", {
|
|
2497
|
-
id: integer("id").primaryKey(),
|
|
2631
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2498
2632
|
postId: integer("post_id")
|
|
2499
2633
|
.notNull()
|
|
2500
2634
|
.references(() => contentPosts.id),
|
|
@@ -2505,7 +2639,10 @@ export const contentMetrics = sqliteTable("content_metrics", {
|
|
|
2505
2639
|
shares: integer("shares"),
|
|
2506
2640
|
clicks: integer("clicks"),
|
|
2507
2641
|
raw: text("raw"),
|
|
2508
|
-
}, (table) => [
|
|
2642
|
+
}, (table) => [
|
|
2643
|
+
index("content_metrics_by_post_id_at").on(table.postId, table.at),
|
|
2644
|
+
check("content_metrics_raw_json", sql `"raw" IS NULL OR json_valid("raw")`),
|
|
2645
|
+
]);
|
|
2509
2646
|
/** Settings of the store file itself, shared by every profile, tg and MAX — unlike a profile's config file. */
|
|
2510
2647
|
export const storeSettings = sqliteTable("store_settings", {
|
|
2511
2648
|
key: text("key").primaryKey(),
|