@wirecat/cli-core 0.753.0 → 1.0.0-rc.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 +142 -0
- package/README.md +9 -6
- 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/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 +1 -0
- 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 +3 -2
- package/dist/cli/bot/api-input.js +3 -2
- 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/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/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 +4 -1
- 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/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/person-kinds.d.ts +3 -1
- 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/knowledge-lists.d.ts +3 -0
- package/dist/entities/knowledge-lists.js +3 -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 +5 -38
- 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/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/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.d.ts +1 -1
- package/dist/services/search-all.js +2 -2
- 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/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 +40 -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 +1 -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 +5 -4
- 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/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/manifest.js +105 -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 +652 -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/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 +17 -17
- 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/tag-consolidations.js +5 -2
- package/dist/store/sqlite/schema/templates.js +1 -1
- package/dist/store/sqlite/schema.js +243 -108
- 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-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.js +3 -1
- 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 +12 -5
- package/dist/tracker/testing/manifest-fake.d.ts +2 -1
- 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,12 @@ 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
|
+
]);
|
|
257
269
|
export const chats = sqliteTable("chats", {
|
|
258
|
-
id: integer("id").primaryKey(),
|
|
270
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
259
271
|
accountId: integer("account_id")
|
|
260
272
|
.notNull()
|
|
261
273
|
.references(() => accounts.id),
|
|
@@ -291,6 +303,7 @@ export const chats = sqliteTable("chats", {
|
|
|
291
303
|
index("chats_by_recency").on(table.accountId, desc(table.lastMessageAt)),
|
|
292
304
|
index("chats_title_to_fold").on(table.id).where(sql `title IS NOT NULL AND title_folded IS NULL`),
|
|
293
305
|
index("chats_by_parent_chat_id").on(table.parentChatId),
|
|
306
|
+
check("chats_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
294
307
|
]);
|
|
295
308
|
/** Who is in a chat, as the account last saw it: a list replaces the chat's membership whole. */
|
|
296
309
|
export const chatMembers = sqliteTable("chat_members", {
|
|
@@ -310,7 +323,7 @@ export const chatMembers = sqliteTable("chat_members", {
|
|
|
310
323
|
* row. `left_at` is set only from a list read whole: a cut list says nothing about who is missing.
|
|
311
324
|
*/
|
|
312
325
|
export const memberStays = sqliteTable("member_stays", {
|
|
313
|
-
id: integer("id").primaryKey(),
|
|
326
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
314
327
|
chatId: integer("chat_id")
|
|
315
328
|
.notNull()
|
|
316
329
|
.references(() => chats.id),
|
|
@@ -342,7 +355,7 @@ export const memberCounts = sqliteTable("member_counts", {
|
|
|
342
355
|
createdAt: integer("created_at").notNull(),
|
|
343
356
|
}, (table) => [primaryKey({ columns: [table.chatId, table.date] })]);
|
|
344
357
|
export const messages = sqliteTable("messages", {
|
|
345
|
-
id: integer("id").primaryKey(),
|
|
358
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
346
359
|
chatId: integer("chat_id")
|
|
347
360
|
.notNull()
|
|
348
361
|
.references(() => chats.id),
|
|
@@ -385,11 +398,19 @@ export const messages = sqliteTable("messages", {
|
|
|
385
398
|
index("messages_by_account").on(table.accountId, table.externalId),
|
|
386
399
|
// Empty once the backfill is done, so every open can ask "anything left?" without reading the table.
|
|
387
400
|
index("messages_to_normalize").on(table.id).where(sql `normalized_text IS NULL AND deleted_at IS NULL`),
|
|
401
|
+
index("messages_by_chat_id_thread_external_id")
|
|
402
|
+
.on(table.chatId, table.threadExternalId)
|
|
403
|
+
.where(sql `thread_root_id IS NULL AND thread_external_id IS NOT NULL`),
|
|
388
404
|
index("messages_by_sender_identity_id").on(table.senderIdentityId),
|
|
389
405
|
index("messages_by_thread_root_id").on(table.threadRootId),
|
|
406
|
+
check("messages_reply_to_json", sql `"reply_to" IS NULL OR json_valid("reply_to")`),
|
|
407
|
+
check("messages_forward_json", sql `"forward" IS NULL OR json_valid("forward")`),
|
|
408
|
+
check("messages_reactions_json", sql `"reactions" IS NULL OR json_valid("reactions")`),
|
|
409
|
+
check("messages_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
410
|
+
check("messages_mentions_json", sql `"mentions" IS NULL OR json_valid("mentions")`),
|
|
390
411
|
]);
|
|
391
412
|
export const messageRevisions = sqliteTable("message_revisions", {
|
|
392
|
-
id: integer("id").primaryKey(),
|
|
413
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
393
414
|
messageId: integer("message_id")
|
|
394
415
|
.notNull()
|
|
395
416
|
.references(() => messages.id),
|
|
@@ -403,7 +424,7 @@ export const messageRevisions = sqliteTable("message_revisions", {
|
|
|
403
424
|
*/
|
|
404
425
|
/** Each candidate for "the earlier message this one answers", and where it came from. */
|
|
405
426
|
export const messageLinks = sqliteTable("message_links", {
|
|
406
|
-
id: integer("id").primaryKey(),
|
|
427
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
407
428
|
/** The message's chat, kept here so a rebuild finds and drops an old build without reading `messages`. */
|
|
408
429
|
chatId: integer("chat_id")
|
|
409
430
|
.notNull()
|
|
@@ -444,7 +465,7 @@ export const messageCounterObservations = sqliteTable("message_counter_observati
|
|
|
444
465
|
* holds it, and `message_id` is set once it does. Derived — it can be heard again.
|
|
445
466
|
*/
|
|
446
467
|
export const messageTranscripts = sqliteTable("message_transcripts", {
|
|
447
|
-
id: integer("id").primaryKey(),
|
|
468
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
448
469
|
messageId: integer("message_id").references(() => messages.id),
|
|
449
470
|
chatId: integer("chat_id")
|
|
450
471
|
.notNull()
|
|
@@ -468,7 +489,7 @@ export const messageStemsPending = sqliteTable("message_stems_pending", {
|
|
|
468
489
|
* chat and external id: a vote can arrive before the poll's message is stored.
|
|
469
490
|
*/
|
|
470
491
|
export const pollVotes = sqliteTable("poll_votes", {
|
|
471
|
-
id: integer("id").primaryKey(),
|
|
492
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
472
493
|
chatId: integer("chat_id")
|
|
473
494
|
.notNull()
|
|
474
495
|
.references(() => chats.id),
|
|
@@ -483,6 +504,7 @@ export const pollVotes = sqliteTable("poll_votes", {
|
|
|
483
504
|
}, (table) => [
|
|
484
505
|
unique().on(table.chatId, table.messageExternalId, table.identityId),
|
|
485
506
|
index("poll_votes_by_identity_id").on(table.identityId),
|
|
507
|
+
check("poll_votes_answers_json", sql `"answers" IS NULL OR json_valid("answers")`),
|
|
486
508
|
]);
|
|
487
509
|
export { linkRevisions } from "./schema/link-revisions.js";
|
|
488
510
|
/**
|
|
@@ -490,7 +512,7 @@ export { linkRevisions } from "./schema/link-revisions.js";
|
|
|
490
512
|
* keys: an older build purges chats without knowing this table, and a trigger drops a purged chat's rows instead.
|
|
491
513
|
*/
|
|
492
514
|
export const chatRevisions = sqliteTable("chat_revisions", {
|
|
493
|
-
id: integer("id").primaryKey(),
|
|
515
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
494
516
|
chatId: integer("chat_id").notNull(),
|
|
495
517
|
accountId: integer("account_id").notNull(),
|
|
496
518
|
field: text("field").notNull(),
|
|
@@ -506,13 +528,13 @@ export const chatRevisions = sqliteTable("chat_revisions", {
|
|
|
506
528
|
]);
|
|
507
529
|
/** The source and time the `chat_revisions` trigger records, set by the store inside its write and gone by commit. */
|
|
508
530
|
export const chatRevisionSource = sqliteTable("chat_revision_source", {
|
|
509
|
-
id: integer("id").primaryKey(),
|
|
531
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
510
532
|
source: text("source").notNull(),
|
|
511
533
|
at: integer("at").notNull(),
|
|
512
534
|
});
|
|
513
535
|
/** Changes to who is in a chat, and to its title, for a messenger whose history is pushed to the store. */
|
|
514
536
|
export const chatEvents = sqliteTable("chat_events", {
|
|
515
|
-
id: integer("id").primaryKey(),
|
|
537
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
516
538
|
chatId: integer("chat_id")
|
|
517
539
|
.notNull()
|
|
518
540
|
.references(() => chats.id),
|
|
@@ -544,7 +566,7 @@ export const chatEventPeople = sqliteTable("chat_event_people", {
|
|
|
544
566
|
* derives `messages.reactions` from them. Keyed by chat and external id: a reaction can arrive before its message.
|
|
545
567
|
*/
|
|
546
568
|
export const messageReactions = sqliteTable("message_reactions", {
|
|
547
|
-
id: integer("id").primaryKey(),
|
|
569
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
548
570
|
chatId: integer("chat_id")
|
|
549
571
|
.notNull()
|
|
550
572
|
.references(() => chats.id),
|
|
@@ -563,7 +585,7 @@ export const messageReactions = sqliteTable("message_reactions", {
|
|
|
563
585
|
]);
|
|
564
586
|
/** One read of a chat's member list. Retention reads presence at a checkpoint from these, not from stays. */
|
|
565
587
|
export const memberObservations = sqliteTable("member_observations", {
|
|
566
|
-
id: integer("id").primaryKey(),
|
|
588
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
567
589
|
chatId: integer("chat_id")
|
|
568
590
|
.notNull()
|
|
569
591
|
.references(() => chats.id),
|
|
@@ -593,7 +615,7 @@ export const memberObservationMembers = sqliteTable("member_observation_members"
|
|
|
593
615
|
index("member_observation_members_by_identity_id").on(table.identityId),
|
|
594
616
|
]);
|
|
595
617
|
export const emailThreads = sqliteTable("email_threads", {
|
|
596
|
-
id: integer("id").primaryKey(),
|
|
618
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
597
619
|
accountId: integer("account_id")
|
|
598
620
|
.notNull()
|
|
599
621
|
.references(() => accounts.id),
|
|
@@ -609,9 +631,10 @@ export const emailThreads = sqliteTable("email_threads", {
|
|
|
609
631
|
}, (table) => [
|
|
610
632
|
unique().on(table.accountId, table.externalId),
|
|
611
633
|
index("email_threads_subject_to_fold").on(table.id).where(sql `subject IS NOT NULL AND subject_folded IS NULL`),
|
|
634
|
+
check("email_threads_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
612
635
|
]);
|
|
613
636
|
export const emails = sqliteTable("emails", {
|
|
614
|
-
id: integer("id").primaryKey(),
|
|
637
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
615
638
|
accountId: integer("account_id")
|
|
616
639
|
.notNull()
|
|
617
640
|
.references(() => accounts.id),
|
|
@@ -648,9 +671,12 @@ export const emails = sqliteTable("emails", {
|
|
|
648
671
|
index("emails_by_mail_rule_id").on(table.mailRuleId).where(sql `mail_rule_id IS NOT NULL`),
|
|
649
672
|
index("emails_by_email_thread_id").on(table.emailThreadId),
|
|
650
673
|
index("emails_by_from_identity_id").on(table.fromIdentityId),
|
|
674
|
+
check("emails_references_json", sql `"references" IS NULL OR json_valid("references")`),
|
|
675
|
+
check("emails_headers_json", sql `"headers" IS NULL OR json_valid("headers")`),
|
|
676
|
+
check("emails_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
651
677
|
]);
|
|
652
678
|
export const mailRules = sqliteTable("mail_rules", {
|
|
653
|
-
id: integer("id").primaryKey(),
|
|
679
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
654
680
|
accountId: integer("account_id")
|
|
655
681
|
.notNull()
|
|
656
682
|
.references(() => accounts.id),
|
|
@@ -662,9 +688,13 @@ export const mailRules = sqliteTable("mail_rules", {
|
|
|
662
688
|
decidedAt: integer("decided_at").notNull(),
|
|
663
689
|
createdAt: integer("created_at").notNull(),
|
|
664
690
|
updatedAt: integer("updated_at").notNull(),
|
|
665
|
-
}, (table) => [
|
|
691
|
+
}, (table) => [
|
|
692
|
+
unique().on(table.accountId, table.conditions),
|
|
693
|
+
check("mail_rules_conditions_json", sql `"conditions" IS NULL OR json_valid("conditions")`),
|
|
694
|
+
check("mail_rules_actions_json", sql `"actions" IS NULL OR json_valid("actions")`),
|
|
695
|
+
]);
|
|
666
696
|
export const emailRecipients = sqliteTable("email_recipients", {
|
|
667
|
-
id: integer("id").primaryKey(),
|
|
697
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
668
698
|
emailId: integer("email_id")
|
|
669
699
|
.notNull()
|
|
670
700
|
.references(() => emails.id),
|
|
@@ -680,7 +710,7 @@ export const emailRecipients = sqliteTable("email_recipients", {
|
|
|
680
710
|
index("email_recipients_by_identity_id").on(table.identityId),
|
|
681
711
|
]);
|
|
682
712
|
export const mailboxes = sqliteTable("mailboxes", {
|
|
683
|
-
id: integer("id").primaryKey(),
|
|
713
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
684
714
|
accountId: integer("account_id")
|
|
685
715
|
.notNull()
|
|
686
716
|
.references(() => accounts.id),
|
|
@@ -725,7 +755,7 @@ export const emailIndexPending = sqliteTable("email_index_pending", {
|
|
|
725
755
|
indexableType: text("indexable_type").notNull(),
|
|
726
756
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
727
757
|
export const attachments = sqliteTable("attachments", {
|
|
728
|
-
id: integer("id").primaryKey(),
|
|
758
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
729
759
|
attachableType: text("attachable_type").notNull(),
|
|
730
760
|
attachableId: integer("attachable_id").notNull(),
|
|
731
761
|
position: integer("position").notNull(),
|
|
@@ -759,6 +789,8 @@ export const attachments = sqliteTable("attachments", {
|
|
|
759
789
|
index("attachments_local_path_to_fold")
|
|
760
790
|
.on(table.id)
|
|
761
791
|
.where(sql `local_path IS NOT NULL AND local_path_folded IS NULL`),
|
|
792
|
+
check("attachments_provider_ref_json", sql `"provider_ref" IS NULL OR json_valid("provider_ref")`),
|
|
793
|
+
check("attachments_contact_json", sql `"contact" IS NULL OR json_valid("contact")`),
|
|
762
794
|
]);
|
|
763
795
|
export const transcriptIndexPending = sqliteTable("transcript_index_pending", {
|
|
764
796
|
id: integer("id").notNull(),
|
|
@@ -766,7 +798,7 @@ export const transcriptIndexPending = sqliteTable("transcript_index_pending", {
|
|
|
766
798
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
767
799
|
export { documentAnnotationTransfers } from "./schema/document-transfers.js";
|
|
768
800
|
export const documents = sqliteTable("documents", {
|
|
769
|
-
id: integer("id").primaryKey(),
|
|
801
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
770
802
|
accountId: integer("account_id")
|
|
771
803
|
.notNull()
|
|
772
804
|
.references(() => accounts.id),
|
|
@@ -798,9 +830,13 @@ export const documents = sqliteTable("documents", {
|
|
|
798
830
|
deletedAt: integer("deleted_at"),
|
|
799
831
|
pinnedFileId: integer("pinned_file_id"),
|
|
800
832
|
removal: text("removal"),
|
|
801
|
-
}, (table) => [
|
|
833
|
+
}, (table) => [
|
|
834
|
+
unique().on(table.accountId, table.externalId),
|
|
835
|
+
check("documents_front_matter_json", sql `"front_matter" IS NULL OR json_valid("front_matter")`),
|
|
836
|
+
check("documents_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
837
|
+
]);
|
|
802
838
|
export const files = sqliteTable("files", {
|
|
803
|
-
id: integer("id").primaryKey(),
|
|
839
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
804
840
|
accountId: integer("account_id")
|
|
805
841
|
.notNull()
|
|
806
842
|
.references(() => accounts.id),
|
|
@@ -828,9 +864,10 @@ export const files = sqliteTable("files", {
|
|
|
828
864
|
index("files_path_to_fold").on(table.id).where(sql `path_folded IS NULL`),
|
|
829
865
|
index("files_by_parent_id").on(table.parentId),
|
|
830
866
|
index("files_by_document_id").on(table.documentId),
|
|
867
|
+
check("files_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
831
868
|
]);
|
|
832
869
|
export const documentRevisions = sqliteTable("document_revisions", {
|
|
833
|
-
id: integer("id").primaryKey(),
|
|
870
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
834
871
|
documentId: integer("document_id")
|
|
835
872
|
.notNull()
|
|
836
873
|
.references(() => documents.id),
|
|
@@ -840,11 +877,14 @@ export const documentRevisions = sqliteTable("document_revisions", {
|
|
|
840
877
|
title: text("title"),
|
|
841
878
|
frontMatter: text("front_matter"),
|
|
842
879
|
reason: text("reason"),
|
|
843
|
-
}, (table) => [
|
|
880
|
+
}, (table) => [
|
|
881
|
+
index("document_revisions_by_document_id").on(table.documentId),
|
|
882
|
+
check("document_revisions_front_matter_json", sql `"front_matter" IS NULL OR json_valid("front_matter")`),
|
|
883
|
+
]);
|
|
844
884
|
export { documentChanges } from "./schema/document-changes.js";
|
|
845
885
|
export { documentIndexPending } from "./schema/document-index-pending.js";
|
|
846
886
|
export const notes = sqliteTable("notes", {
|
|
847
|
-
id: integer("id").primaryKey(),
|
|
887
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
848
888
|
notableType: text("notable_type").notNull(),
|
|
849
889
|
notableId: integer("notable_id").notNull(),
|
|
850
890
|
title: text("title"),
|
|
@@ -858,9 +898,10 @@ export const notes = sqliteTable("notes", {
|
|
|
858
898
|
}, (table) => [
|
|
859
899
|
index("notes_by_notable_type_notable_id").on(table.notableType, table.notableId),
|
|
860
900
|
index("notes_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
901
|
+
check("notes_author_pair", sql `("author_type" IS NULL) = ("author_id" IS NULL)`),
|
|
861
902
|
]);
|
|
862
903
|
export const noteRevisions = sqliteTable("note_revisions", {
|
|
863
|
-
id: integer("id").primaryKey(),
|
|
904
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
864
905
|
noteId: integer("note_id")
|
|
865
906
|
.notNull()
|
|
866
907
|
.references(() => notes.id),
|
|
@@ -873,7 +914,7 @@ export const noteIndexPending = sqliteTable("note_index_pending", {
|
|
|
873
914
|
indexableType: text("indexable_type").notNull(),
|
|
874
915
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
875
916
|
export const memories = sqliteTable("memories", {
|
|
876
|
-
id: integer("id").primaryKey(),
|
|
917
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
877
918
|
kind: text("kind").notNull(),
|
|
878
919
|
body: text("body").notNull(),
|
|
879
920
|
subjectType: text("subject_type"),
|
|
@@ -895,13 +936,14 @@ export const memories = sqliteTable("memories", {
|
|
|
895
936
|
index("memories_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
896
937
|
index("memories_by_supersedes_id").on(table.supersedesId),
|
|
897
938
|
index("memories_by_project_id").on(table.projectId),
|
|
939
|
+
check("memories_subject_pair", sql `("subject_type" IS NULL) = ("subject_id" IS NULL)`),
|
|
898
940
|
]);
|
|
899
941
|
export const memoryIndexPending = sqliteTable("memory_index_pending", {
|
|
900
942
|
id: integer("id").notNull(),
|
|
901
943
|
indexableType: text("indexable_type").notNull(),
|
|
902
944
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
903
945
|
export const calendars = sqliteTable("calendars", {
|
|
904
|
-
id: integer("id").primaryKey(),
|
|
946
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
905
947
|
accountId: integer("account_id")
|
|
906
948
|
.notNull()
|
|
907
949
|
.references(() => accounts.id),
|
|
@@ -917,7 +959,7 @@ export const calendars = sqliteTable("calendars", {
|
|
|
917
959
|
deletedAt: integer("deleted_at"),
|
|
918
960
|
}, (table) => [unique().on(table.accountId, table.externalId)]);
|
|
919
961
|
export const calendarEntries = sqliteTable("calendar_entries", {
|
|
920
|
-
id: integer("id").primaryKey(),
|
|
962
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
921
963
|
calendarId: integer("calendar_id")
|
|
922
964
|
.notNull()
|
|
923
965
|
.references(() => calendars.id),
|
|
@@ -972,9 +1014,11 @@ export const calendarEntries = sqliteTable("calendar_entries", {
|
|
|
972
1014
|
index("calendar_entries_by_event_series_id").on(table.eventSeriesId),
|
|
973
1015
|
index("calendar_entries_by_event_type_event_id").on(table.eventType, table.eventId),
|
|
974
1016
|
index("calendar_entries_by_organizer_identity_id").on(table.organizerIdentityId),
|
|
1017
|
+
check("calendar_entries_recurrence_json", sql `"recurrence" IS NULL OR json_valid("recurrence")`),
|
|
1018
|
+
check("calendar_entries_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
975
1019
|
]);
|
|
976
1020
|
export const calendarEntryRevisions = sqliteTable("calendar_entry_revisions", {
|
|
977
|
-
id: integer("id").primaryKey(),
|
|
1021
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
978
1022
|
entryId: integer("entry_id")
|
|
979
1023
|
.notNull()
|
|
980
1024
|
.references(() => calendarEntries.id),
|
|
@@ -989,7 +1033,7 @@ export const calendarEntryRevisions = sqliteTable("calendar_entry_revisions", {
|
|
|
989
1033
|
createdAt: integer("created_at").notNull(),
|
|
990
1034
|
}, (table) => [index("calendar_entry_revisions_by_entry_id_created_at").on(table.entryId, table.createdAt)]);
|
|
991
1035
|
export const calendarEntryParticipants = sqliteTable("calendar_entry_participants", {
|
|
992
|
-
id: integer("id").primaryKey(),
|
|
1036
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
993
1037
|
entryId: integer("entry_id")
|
|
994
1038
|
.notNull()
|
|
995
1039
|
.references(() => calendarEntries.id),
|
|
@@ -1012,7 +1056,7 @@ export const eventIndexPending = sqliteTable("event_index_pending", {
|
|
|
1012
1056
|
indexableType: text("indexable_type").notNull(),
|
|
1013
1057
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
1014
1058
|
export const eventSeries = sqliteTable("event_series", {
|
|
1015
|
-
id: integer("id").primaryKey(),
|
|
1059
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1016
1060
|
title: text("title"),
|
|
1017
1061
|
recurrence: text("recurrence"),
|
|
1018
1062
|
origin: text("origin").notNull(),
|
|
@@ -1020,7 +1064,7 @@ export const eventSeries = sqliteTable("event_series", {
|
|
|
1020
1064
|
updatedAt: integer("updated_at").notNull(),
|
|
1021
1065
|
});
|
|
1022
1066
|
export const events = sqliteTable("events", {
|
|
1023
|
-
id: integer("id").primaryKey(),
|
|
1067
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1024
1068
|
eventSeriesId: integer("event_series_id").references(() => eventSeries.id),
|
|
1025
1069
|
title: text("title"),
|
|
1026
1070
|
description: text("description"),
|
|
@@ -1037,7 +1081,7 @@ export const events = sqliteTable("events", {
|
|
|
1037
1081
|
sourceDeletedAt: integer("source_deleted_at"),
|
|
1038
1082
|
}, (table) => [index("events_by_time").on(table.startsAt), index("events_by_event_series_id").on(table.eventSeriesId)]);
|
|
1039
1083
|
export const meetingSeries = sqliteTable("meeting_series", {
|
|
1040
|
-
id: integer("id").primaryKey(),
|
|
1084
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1041
1085
|
accountId: integer("account_id")
|
|
1042
1086
|
.notNull()
|
|
1043
1087
|
.references(() => accounts.id),
|
|
@@ -1057,9 +1101,11 @@ export const meetingSeries = sqliteTable("meeting_series", {
|
|
|
1057
1101
|
unique().on(table.accountId, table.externalId),
|
|
1058
1102
|
index("meeting_series_by_event_series_id").on(table.eventSeriesId),
|
|
1059
1103
|
index("meeting_series_by_host_identity_id").on(table.hostIdentityId),
|
|
1104
|
+
check("meeting_series_recurrence_json", sql `"recurrence" IS NULL OR json_valid("recurrence")`),
|
|
1105
|
+
check("meeting_series_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1060
1106
|
]);
|
|
1061
1107
|
export const meetings = sqliteTable("meetings", {
|
|
1062
|
-
id: integer("id").primaryKey(),
|
|
1108
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1063
1109
|
accountId: integer("account_id")
|
|
1064
1110
|
.notNull()
|
|
1065
1111
|
.references(() => accounts.id),
|
|
@@ -1094,9 +1140,10 @@ export const meetings = sqliteTable("meetings", {
|
|
|
1094
1140
|
index("meetings_by_meeting_series_id").on(table.meetingSeriesId),
|
|
1095
1141
|
index("meetings_by_event_id").on(table.eventId),
|
|
1096
1142
|
index("meetings_by_host_identity_id").on(table.hostIdentityId),
|
|
1143
|
+
check("meetings_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1097
1144
|
]);
|
|
1098
1145
|
export const meetingParticipants = sqliteTable("meeting_participants", {
|
|
1099
|
-
id: integer("id").primaryKey(),
|
|
1146
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1100
1147
|
meetingId: integer("meeting_id")
|
|
1101
1148
|
.notNull()
|
|
1102
1149
|
.references(() => meetings.id),
|
|
@@ -1117,9 +1164,11 @@ export const meetingParticipants = sqliteTable("meeting_participants", {
|
|
|
1117
1164
|
}, (table) => [
|
|
1118
1165
|
unique().on(table.meetingId, table.identityId),
|
|
1119
1166
|
index("meeting_participants_by_identity_id").on(table.identityId),
|
|
1167
|
+
check("meeting_participants_sessions_json", sql `"sessions" IS NULL OR json_valid("sessions")`),
|
|
1168
|
+
check("meeting_participants_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1120
1169
|
]);
|
|
1121
1170
|
export const meetingTranscripts = sqliteTable("meeting_transcripts", {
|
|
1122
|
-
id: integer("id").primaryKey(),
|
|
1171
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1123
1172
|
meetingId: integer("meeting_id")
|
|
1124
1173
|
.notNull()
|
|
1125
1174
|
.references(() => meetings.id),
|
|
@@ -1133,9 +1182,12 @@ export const meetingTranscripts = sqliteTable("meeting_transcripts", {
|
|
|
1133
1182
|
createdAt: integer("created_at").notNull(),
|
|
1134
1183
|
updatedAt: integer("updated_at").notNull(),
|
|
1135
1184
|
deletedAt: integer("deleted_at"),
|
|
1136
|
-
}, (table) => [
|
|
1185
|
+
}, (table) => [
|
|
1186
|
+
index("meeting_transcripts_by_meeting_id").on(table.meetingId),
|
|
1187
|
+
check("meeting_transcripts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1188
|
+
]);
|
|
1137
1189
|
export const meetingTranscriptRows = sqliteTable("meeting_transcript_rows", {
|
|
1138
|
-
id: integer("id").primaryKey(),
|
|
1190
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1139
1191
|
meetingTranscriptId: integer("meeting_transcript_id")
|
|
1140
1192
|
.notNull()
|
|
1141
1193
|
.references(() => meetingTranscripts.id),
|
|
@@ -1151,9 +1203,10 @@ export const meetingTranscriptRows = sqliteTable("meeting_transcript_rows", {
|
|
|
1151
1203
|
}, (table) => [
|
|
1152
1204
|
unique().on(table.meetingTranscriptId, table.position),
|
|
1153
1205
|
index("meeting_transcript_rows_by_speaker_participant_id").on(table.speakerParticipantId),
|
|
1206
|
+
check("meeting_transcript_rows_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1154
1207
|
]);
|
|
1155
1208
|
export const meetingChatMessages = sqliteTable("meeting_chat_messages", {
|
|
1156
|
-
id: integer("id").primaryKey(),
|
|
1209
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1157
1210
|
meetingId: integer("meeting_id")
|
|
1158
1211
|
.notNull()
|
|
1159
1212
|
.references(() => meetings.id),
|
|
@@ -1173,9 +1226,10 @@ export const meetingChatMessages = sqliteTable("meeting_chat_messages", {
|
|
|
1173
1226
|
.where(sql `external_id IS NOT NULL`),
|
|
1174
1227
|
index("meeting_chat_messages_by_meeting_id").on(table.meetingId),
|
|
1175
1228
|
index("meeting_chat_messages_by_sender_participant_id").on(table.senderParticipantId),
|
|
1229
|
+
check("meeting_chat_messages_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1176
1230
|
]);
|
|
1177
1231
|
export const meetingSummaries = sqliteTable("meeting_summaries", {
|
|
1178
|
-
id: integer("id").primaryKey(),
|
|
1232
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1179
1233
|
meetingId: integer("meeting_id")
|
|
1180
1234
|
.notNull()
|
|
1181
1235
|
.references(() => meetings.id),
|
|
@@ -1191,14 +1245,19 @@ export const meetingSummaries = sqliteTable("meeting_summaries", {
|
|
|
1191
1245
|
metadata: text("metadata"),
|
|
1192
1246
|
createdAt: integer("created_at").notNull(),
|
|
1193
1247
|
updatedAt: integer("updated_at").notNull(),
|
|
1194
|
-
}, (table) => [
|
|
1248
|
+
}, (table) => [
|
|
1249
|
+
unique().on(table.meetingId, table.source),
|
|
1250
|
+
check("meeting_summaries_sections_json", sql `"sections" IS NULL OR json_valid("sections")`),
|
|
1251
|
+
check("meeting_summaries_next_steps_json", sql `"next_steps" IS NULL OR json_valid("next_steps")`),
|
|
1252
|
+
check("meeting_summaries_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1253
|
+
]);
|
|
1195
1254
|
/** Keyed by type and id: transcript rows, chat messages and summaries share the queue, and their ids overlap. */
|
|
1196
1255
|
export const meetingIndexPending = sqliteTable("meeting_index_pending", {
|
|
1197
1256
|
id: integer("id").notNull(),
|
|
1198
1257
|
indexableType: text("indexable_type").notNull(),
|
|
1199
1258
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
1200
1259
|
export const reminders = sqliteTable("reminders", {
|
|
1201
|
-
id: integer("id").primaryKey(),
|
|
1260
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1202
1261
|
taskId: integer("task_id")
|
|
1203
1262
|
.notNull()
|
|
1204
1263
|
.references(() => tasks.id),
|
|
@@ -1218,7 +1277,7 @@ export const reminders = sqliteTable("reminders", {
|
|
|
1218
1277
|
index("reminders_by_task_id").on(table.taskId),
|
|
1219
1278
|
]);
|
|
1220
1279
|
export const projects = sqliteTable("projects", {
|
|
1221
|
-
id: integer("id").primaryKey(),
|
|
1280
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1222
1281
|
key: text("key").notNull().unique(),
|
|
1223
1282
|
name: text("name").notNull(),
|
|
1224
1283
|
description: text("description"),
|
|
@@ -1240,9 +1299,10 @@ export const projects = sqliteTable("projects", {
|
|
|
1240
1299
|
index("projects_by_organization_id").on(table.organizationId),
|
|
1241
1300
|
index("projects_by_account_id").on(table.accountId),
|
|
1242
1301
|
index("projects_by_owner_type_owner_id").on(table.ownerType, table.ownerId),
|
|
1302
|
+
check("projects_owner_pair", sql `("owner_type" IS NULL) = ("owner_id" IS NULL)`),
|
|
1243
1303
|
]);
|
|
1244
1304
|
export const tasks = sqliteTable("tasks", {
|
|
1245
|
-
id: integer("id").primaryKey(),
|
|
1305
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1246
1306
|
projectId: integer("project_id")
|
|
1247
1307
|
.notNull()
|
|
1248
1308
|
.references(() => projects.id),
|
|
@@ -1310,13 +1370,16 @@ export const tasks = sqliteTable("tasks", {
|
|
|
1310
1370
|
index("tasks_by_closed_by_type_closed_by_id").on(table.closedByType, table.closedById),
|
|
1311
1371
|
index("tasks_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1312
1372
|
index("tasks_by_close_suggested_by_type_close_suggested_by_id").on(table.closeSuggestedByType, table.closeSuggestedById),
|
|
1373
|
+
check("tasks_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1374
|
+
check("tasks_closed_by_pair", sql `("closed_by_type" IS NULL) = ("closed_by_id" IS NULL)`),
|
|
1375
|
+
check("tasks_close_suggested_by_pair", sql `("close_suggested_by_type" IS NULL) = ("close_suggested_by_id" IS NULL)`),
|
|
1313
1376
|
]);
|
|
1314
1377
|
export const taskKeyCounters = sqliteTable("task_key_counters", {
|
|
1315
1378
|
prefix: text("prefix").primaryKey(),
|
|
1316
1379
|
tasksCount: integer("tasks_count").notNull(),
|
|
1317
1380
|
});
|
|
1318
1381
|
export const taskAssignments = sqliteTable("task_assignments", {
|
|
1319
|
-
id: integer("id").primaryKey(),
|
|
1382
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1320
1383
|
taskId: integer("task_id")
|
|
1321
1384
|
.notNull()
|
|
1322
1385
|
.references(() => tasks.id),
|
|
@@ -1330,7 +1393,7 @@ export const taskAssignments = sqliteTable("task_assignments", {
|
|
|
1330
1393
|
index("task_assignments_by_assignee_type_assignee_id").on(table.assigneeType, table.assigneeId),
|
|
1331
1394
|
]);
|
|
1332
1395
|
export const taskEvents = sqliteTable("task_events", {
|
|
1333
|
-
id: integer("id").primaryKey(),
|
|
1396
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1334
1397
|
taskId: integer("task_id")
|
|
1335
1398
|
.notNull()
|
|
1336
1399
|
.references(() => tasks.id),
|
|
@@ -1342,9 +1405,11 @@ export const taskEvents = sqliteTable("task_events", {
|
|
|
1342
1405
|
}, (table) => [
|
|
1343
1406
|
index("task_events_by_task_id").on(table.taskId),
|
|
1344
1407
|
index("task_events_by_actor_type_actor_id").on(table.actorType, table.actorId),
|
|
1408
|
+
check("task_events_changes_json", sql `"changes" IS NULL OR json_valid("changes")`),
|
|
1409
|
+
check("task_events_actor_pair", sql `("actor_type" IS NULL) = ("actor_id" IS NULL)`),
|
|
1345
1410
|
]);
|
|
1346
1411
|
export const taskPairs = sqliteTable("task_pairs", {
|
|
1347
|
-
id: integer("id").primaryKey(),
|
|
1412
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1348
1413
|
taskId: integer("task_id").references(() => tasks.id),
|
|
1349
1414
|
sourceLocator: text("source_locator"),
|
|
1350
1415
|
otherId: integer("other_id")
|
|
@@ -1365,13 +1430,16 @@ export const taskPairs = sqliteTable("task_pairs", {
|
|
|
1365
1430
|
index("task_pairs_by_decision_created_at").on(table.decision, table.createdAt),
|
|
1366
1431
|
index("task_pairs_by_other_id").on(table.otherId),
|
|
1367
1432
|
index("task_pairs_by_decided_by_type_decided_by_id").on(table.decidedByType, table.decidedById),
|
|
1433
|
+
check("task_pairs_levels_json", sql `"levels" IS NULL OR json_valid("levels")`),
|
|
1434
|
+
check("task_pairs_reasons_json", sql `"reasons" IS NULL OR json_valid("reasons")`),
|
|
1435
|
+
check("task_pairs_decided_by_pair", sql `("decided_by_type" IS NULL) = ("decided_by_id" IS NULL)`),
|
|
1368
1436
|
]);
|
|
1369
1437
|
export const taskIndexPending = sqliteTable("task_index_pending", {
|
|
1370
1438
|
id: integer("id").notNull(),
|
|
1371
1439
|
indexableType: text("indexable_type").notNull(),
|
|
1372
1440
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
1373
1441
|
export const decisions = sqliteTable("decisions", {
|
|
1374
|
-
id: integer("id").primaryKey(),
|
|
1442
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1375
1443
|
projectId: integer("project_id").references(() => projects.id),
|
|
1376
1444
|
statement: text("statement").notNull(),
|
|
1377
1445
|
status: text("status").notNull(),
|
|
@@ -1388,9 +1456,11 @@ export const decisions = sqliteTable("decisions", {
|
|
|
1388
1456
|
index("decisions_by_project_id").on(table.projectId),
|
|
1389
1457
|
index("decisions_by_supersedes_id").on(table.supersedesId),
|
|
1390
1458
|
index("decisions_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1459
|
+
check("decisions_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1460
|
+
check("decisions_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1391
1461
|
]);
|
|
1392
1462
|
export const facts = sqliteTable("facts", {
|
|
1393
|
-
id: integer("id").primaryKey(),
|
|
1463
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1394
1464
|
type: text("type").notNull(),
|
|
1395
1465
|
statement: text("statement").notNull(),
|
|
1396
1466
|
status: text("status").notNull(),
|
|
@@ -1416,10 +1486,13 @@ export const facts = sqliteTable("facts", {
|
|
|
1416
1486
|
index("facts_by_supersedes_id").on(table.supersedesId),
|
|
1417
1487
|
index("facts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1418
1488
|
index("facts_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1489
|
+
check("facts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1490
|
+
check("facts_subject_pair", sql `("subject_type" IS NULL) = ("subject_id" IS NULL)`),
|
|
1491
|
+
check("facts_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1419
1492
|
]);
|
|
1420
1493
|
/** One row per removed fact: that it was removed, by whom, when and why; never its text or value. */
|
|
1421
1494
|
export const factRemovals = sqliteTable("fact_removals", {
|
|
1422
|
-
id: integer("id").primaryKey(),
|
|
1495
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1423
1496
|
factId: integer("fact_id").notNull(),
|
|
1424
1497
|
subject: text("subject"),
|
|
1425
1498
|
removedBy: text("removed_by").notNull(),
|
|
@@ -1429,7 +1502,7 @@ export const factRemovals = sqliteTable("fact_removals", {
|
|
|
1429
1502
|
}, (table) => [index("fact_removals_by_removed_at").on(table.removedAt)]);
|
|
1430
1503
|
/** An invoice the owner issued or received; its total is the sum of its lines, its status follows allocations. */
|
|
1431
1504
|
export const invoices = sqliteTable("invoices", {
|
|
1432
|
-
id: integer("id").primaryKey(),
|
|
1505
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1433
1506
|
direction: text("direction").notNull(),
|
|
1434
1507
|
number: text("number"),
|
|
1435
1508
|
issuerType: text("issuer_type"),
|
|
@@ -1464,9 +1537,13 @@ export const invoices = sqliteTable("invoices", {
|
|
|
1464
1537
|
index("invoices_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1465
1538
|
index("invoices_by_contract_id").on(table.contractId),
|
|
1466
1539
|
index("invoices_by_subscription_id").on(table.subscriptionId),
|
|
1540
|
+
check("invoices_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1541
|
+
check("invoices_issuer_pair", sql `("issuer_type" IS NULL) = ("issuer_id" IS NULL)`),
|
|
1542
|
+
check("invoices_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1543
|
+
check("invoices_total_not_negative", sql `"total" IS NULL OR "total" >= 0`),
|
|
1467
1544
|
]);
|
|
1468
1545
|
export const invoiceLines = sqliteTable("invoice_lines", {
|
|
1469
|
-
id: integer("id").primaryKey(),
|
|
1546
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1470
1547
|
invoiceId: integer("invoice_id")
|
|
1471
1548
|
.notNull()
|
|
1472
1549
|
.references(() => invoices.id),
|
|
@@ -1482,10 +1559,12 @@ export const invoiceLines = sqliteTable("invoice_lines", {
|
|
|
1482
1559
|
}, (table) => [
|
|
1483
1560
|
unique().on(table.invoiceId, table.position),
|
|
1484
1561
|
index("invoice_lines_by_catalog_item_id").on(table.catalogItemId),
|
|
1562
|
+
check("invoice_lines_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1563
|
+
check("invoice_lines_unit_price_not_negative", sql `"unit_price" IS NULL OR "unit_price" >= 0`),
|
|
1485
1564
|
]);
|
|
1486
1565
|
/** Money that moved to or from the owner, in minor units of its currency. */
|
|
1487
1566
|
export const payments = sqliteTable("payments", {
|
|
1488
|
-
id: integer("id").primaryKey(),
|
|
1567
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1489
1568
|
direction: text("direction").notNull(),
|
|
1490
1569
|
payerType: text("payer_type"),
|
|
1491
1570
|
payerId: integer("payer_id"),
|
|
@@ -1517,10 +1596,14 @@ export const payments = sqliteTable("payments", {
|
|
|
1517
1596
|
index("payments_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1518
1597
|
index("payments_by_refund_of").on(table.refundOf),
|
|
1519
1598
|
index("payments_by_subscription_id").on(table.subscriptionId),
|
|
1599
|
+
check("payments_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1600
|
+
check("payments_payer_pair", sql `("payer_type" IS NULL) = ("payer_id" IS NULL)`),
|
|
1601
|
+
check("payments_payee_pair", sql `("payee_type" IS NULL) = ("payee_id" IS NULL)`),
|
|
1602
|
+
check("payments_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1520
1603
|
]);
|
|
1521
1604
|
/** How much of a payment settles an invoice; triggers keep it within both and in one currency. */
|
|
1522
1605
|
export const paymentAllocations = sqliteTable("payment_allocations", {
|
|
1523
|
-
id: integer("id").primaryKey(),
|
|
1606
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1524
1607
|
paymentId: integer("payment_id")
|
|
1525
1608
|
.notNull()
|
|
1526
1609
|
.references(() => payments.id),
|
|
@@ -1538,7 +1621,7 @@ export const paymentAllocations = sqliteTable("payment_allocations", {
|
|
|
1538
1621
|
index("payment_allocations_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1539
1622
|
]);
|
|
1540
1623
|
export const orders = sqliteTable("orders", {
|
|
1541
|
-
id: integer("id").primaryKey(),
|
|
1624
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1542
1625
|
customerType: text("customer_type").notNull(),
|
|
1543
1626
|
customerId: integer("customer_id").notNull(),
|
|
1544
1627
|
purpose: text("purpose").notNull(),
|
|
@@ -1580,10 +1663,14 @@ export const orders = sqliteTable("orders", {
|
|
|
1580
1663
|
index("orders_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1581
1664
|
index("orders_by_contract_id").on(table.contractId),
|
|
1582
1665
|
index("orders_by_deal_id").on(table.dealId),
|
|
1666
|
+
check("orders_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1667
|
+
check("orders_supplier_pair", sql `("supplier_type" IS NULL) = ("supplier_id" IS NULL)`),
|
|
1668
|
+
check("orders_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1669
|
+
check("orders_total_not_negative", sql `"total" IS NULL OR "total" >= 0`),
|
|
1583
1670
|
]);
|
|
1584
1671
|
/** A sales pipeline: the stages a deal or a lead goes through, in order; the owner's own or a CRM account's. */
|
|
1585
1672
|
export const pipelines = sqliteTable("pipelines", {
|
|
1586
|
-
id: integer("id").primaryKey(),
|
|
1673
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1587
1674
|
accountId: integer("account_id").references(() => accounts.id),
|
|
1588
1675
|
externalId: text("external_id"),
|
|
1589
1676
|
kind: text("kind").notNull().default("deal"),
|
|
@@ -1599,7 +1686,7 @@ export const pipelines = sqliteTable("pipelines", {
|
|
|
1599
1686
|
uniqueIndex("pipelines_by_name_folded_kind").on(table.nameFolded, table.kind).where(sql `account_id IS NULL`),
|
|
1600
1687
|
]);
|
|
1601
1688
|
export const pipelineStages = sqliteTable("pipeline_stages", {
|
|
1602
|
-
id: integer("id").primaryKey(),
|
|
1689
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1603
1690
|
pipelineId: integer("pipeline_id")
|
|
1604
1691
|
.notNull()
|
|
1605
1692
|
.references(() => pipelines.id),
|
|
@@ -1623,7 +1710,7 @@ export const pipelineStages = sqliteTable("pipeline_stages", {
|
|
|
1623
1710
|
]);
|
|
1624
1711
|
/** A deal: what the owner hopes to sell, where it stands in its pipeline, and whether it ended. */
|
|
1625
1712
|
export const deals = sqliteTable("deals", {
|
|
1626
|
-
id: integer("id").primaryKey(),
|
|
1713
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1627
1714
|
title: text("title").notNull(),
|
|
1628
1715
|
organizationId: integer("organization_id").references(() => organizations.id),
|
|
1629
1716
|
projectId: integer("project_id").references(() => projects.id),
|
|
@@ -1654,10 +1741,12 @@ export const deals = sqliteTable("deals", {
|
|
|
1654
1741
|
index("deals_by_project_id").on(table.projectId),
|
|
1655
1742
|
index("deals_by_stage_id").on(table.stageId),
|
|
1656
1743
|
index("deals_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1744
|
+
check("deals_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1745
|
+
check("deals_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1657
1746
|
]);
|
|
1658
1747
|
/** A lead: a first contact not yet a deal, in a lead pipeline; `deal_id` is the deal it became. */
|
|
1659
1748
|
export const leads = sqliteTable("leads", {
|
|
1660
|
-
id: integer("id").primaryKey(),
|
|
1749
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1661
1750
|
title: text("title").notNull(),
|
|
1662
1751
|
organizationId: integer("organization_id").references(() => organizations.id),
|
|
1663
1752
|
projectId: integer("project_id").references(() => projects.id),
|
|
@@ -1690,10 +1779,12 @@ export const leads = sqliteTable("leads", {
|
|
|
1690
1779
|
index("leads_by_stage_id").on(table.stageId),
|
|
1691
1780
|
index("leads_by_deal_id").on(table.dealId),
|
|
1692
1781
|
index("leads_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1782
|
+
check("leads_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1783
|
+
check("leads_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1693
1784
|
]);
|
|
1694
1785
|
/** Each stage a deal or a lead entered and when, written by triggers, so conversion between stages can be counted. */
|
|
1695
1786
|
export const pipelineStageChanges = sqliteTable("pipeline_stage_changes", {
|
|
1696
|
-
id: integer("id").primaryKey(),
|
|
1787
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1697
1788
|
itemType: text("item_type").notNull(),
|
|
1698
1789
|
itemId: integer("item_id").notNull(),
|
|
1699
1790
|
pipelineId: integer("pipeline_id")
|
|
@@ -1712,7 +1803,7 @@ export const pipelineStageChanges = sqliteTable("pipeline_stage_changes", {
|
|
|
1712
1803
|
]);
|
|
1713
1804
|
/** A CRM account's own fields on one kind; their values stay in each row's `metadata`, keyed by code. */
|
|
1714
1805
|
export const crmFields = sqliteTable("crm_fields", {
|
|
1715
|
-
id: integer("id").primaryKey(),
|
|
1806
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1716
1807
|
accountId: integer("account_id")
|
|
1717
1808
|
.notNull()
|
|
1718
1809
|
.references(() => accounts.id),
|
|
@@ -1727,10 +1818,13 @@ export const crmFields = sqliteTable("crm_fields", {
|
|
|
1727
1818
|
createdAt: integer("created_at").notNull(),
|
|
1728
1819
|
updatedAt: integer("updated_at").notNull(),
|
|
1729
1820
|
deletedAt: integer("deleted_at"),
|
|
1730
|
-
}, (table) => [
|
|
1821
|
+
}, (table) => [
|
|
1822
|
+
unique().on(table.accountId, table.kind, table.code),
|
|
1823
|
+
check("crm_fields_options_json", sql `"options" IS NULL OR json_valid("options")`),
|
|
1824
|
+
]);
|
|
1731
1825
|
/** A downloaded file of a CRM record with its text; never a download link. Only CRM code reads it, under the viewer. */
|
|
1732
1826
|
export const crmFiles = sqliteTable("crm_files", {
|
|
1733
|
-
id: integer("id").primaryKey(),
|
|
1827
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1734
1828
|
accountId: integer("account_id")
|
|
1735
1829
|
.notNull()
|
|
1736
1830
|
.references(() => accounts.id),
|
|
@@ -1758,7 +1852,7 @@ export const crmFiles = sqliteTable("crm_files", {
|
|
|
1758
1852
|
]);
|
|
1759
1853
|
/** What the owner or a supplier sells, a product or a service; a line copies its price and never reads it back. */
|
|
1760
1854
|
export const catalogItems = sqliteTable("catalog_items", {
|
|
1761
|
-
id: integer("id").primaryKey(),
|
|
1855
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1762
1856
|
kind: text("kind").notNull(),
|
|
1763
1857
|
name: text("name").notNull(),
|
|
1764
1858
|
nameFolded: text("name_folded").notNull(),
|
|
@@ -1787,9 +1881,12 @@ export const catalogItems = sqliteTable("catalog_items", {
|
|
|
1787
1881
|
.where(sql `supplier_id IS NULL AND sku IS NOT NULL AND deleted_at IS NULL`),
|
|
1788
1882
|
index("catalog_items_by_name_folded").on(table.nameFolded),
|
|
1789
1883
|
index("catalog_items_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1884
|
+
check("catalog_items_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1885
|
+
check("catalog_items_supplier_pair", sql `("supplier_type" IS NULL) = ("supplier_id" IS NULL)`),
|
|
1886
|
+
check("catalog_items_unit_price_not_negative", sql `"unit_price" IS NULL OR "unit_price" >= 0`),
|
|
1790
1887
|
]);
|
|
1791
1888
|
export const orderLines = sqliteTable("order_lines", {
|
|
1792
|
-
id: integer("id").primaryKey(),
|
|
1889
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1793
1890
|
orderId: integer("order_id")
|
|
1794
1891
|
.notNull()
|
|
1795
1892
|
.references(() => orders.id),
|
|
@@ -1804,10 +1901,12 @@ export const orderLines = sqliteTable("order_lines", {
|
|
|
1804
1901
|
}, (table) => [
|
|
1805
1902
|
unique().on(table.orderId, table.position),
|
|
1806
1903
|
index("order_lines_by_catalog_item_id").on(table.catalogItemId),
|
|
1904
|
+
check("order_lines_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1905
|
+
check("order_lines_unit_price_not_negative", sql `"unit_price" IS NULL OR "unit_price" >= 0`),
|
|
1807
1906
|
]);
|
|
1808
1907
|
/** A contract the owner works under; parties are relationships, the document an `attached` link. */
|
|
1809
1908
|
export const contracts = sqliteTable("contracts", {
|
|
1810
|
-
id: integer("id").primaryKey(),
|
|
1909
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1811
1910
|
name: text("name").notNull(),
|
|
1812
1911
|
number: text("number"),
|
|
1813
1912
|
kind: text("kind").notNull(),
|
|
@@ -1840,10 +1939,13 @@ export const contracts = sqliteTable("contracts", {
|
|
|
1840
1939
|
index("contracts_by_deal_id").on(table.dealId),
|
|
1841
1940
|
index("contracts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1842
1941
|
index("contracts_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1942
|
+
check("contracts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1943
|
+
check("contracts_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1944
|
+
check("contracts_value_not_negative", sql `"value" IS NULL OR "value" >= 0`),
|
|
1843
1945
|
]);
|
|
1844
1946
|
/** A subscription the owner bills or pays; its prices are `subscription_prices`, each a row of its own. */
|
|
1845
1947
|
export const subscriptions = sqliteTable("subscriptions", {
|
|
1846
|
-
id: integer("id").primaryKey(),
|
|
1948
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1847
1949
|
name: text("name").notNull(),
|
|
1848
1950
|
direction: text("direction").notNull(),
|
|
1849
1951
|
supplierType: text("supplier_type").notNull(),
|
|
@@ -1880,9 +1982,11 @@ export const subscriptions = sqliteTable("subscriptions", {
|
|
|
1880
1982
|
index("subscriptions_by_project_id").on(table.projectId),
|
|
1881
1983
|
index("subscriptions_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1882
1984
|
index("subscriptions_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1985
|
+
check("subscriptions_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
1986
|
+
check("subscriptions_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1883
1987
|
]);
|
|
1884
1988
|
export const subscriptionPrices = sqliteTable("subscription_prices", {
|
|
1885
|
-
id: integer("id").primaryKey(),
|
|
1989
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1886
1990
|
subscriptionId: integer("subscription_id")
|
|
1887
1991
|
.notNull()
|
|
1888
1992
|
.references(() => subscriptions.id),
|
|
@@ -1905,10 +2009,13 @@ export const subscriptionPrices = sqliteTable("subscription_prices", {
|
|
|
1905
2009
|
.where(sql `review <> 'rejected'`),
|
|
1906
2010
|
index("subscription_prices_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1907
2011
|
index("subscription_prices_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
2012
|
+
check("subscription_prices_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
2013
|
+
check("subscription_prices_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
2014
|
+
check("subscription_prices_amount_not_negative", sql `"amount" IS NULL OR "amount" >= 0`),
|
|
1908
2015
|
]);
|
|
1909
2016
|
/** A bank account, card, cash box or wallet, in one currency; its balance is computed from its transactions. */
|
|
1910
2017
|
export const financialAccounts = sqliteTable("financial_accounts", {
|
|
1911
|
-
id: integer("id").primaryKey(),
|
|
2018
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1912
2019
|
name: text("name").notNull(),
|
|
1913
2020
|
nameFolded: text("name_folded").notNull(),
|
|
1914
2021
|
kind: text("kind").notNull(),
|
|
@@ -1932,10 +2039,12 @@ export const financialAccounts = sqliteTable("financial_accounts", {
|
|
|
1932
2039
|
index("financial_accounts_by_name_folded").on(table.nameFolded),
|
|
1933
2040
|
index("financial_accounts_by_holder_type_holder_id").on(table.holderType, table.holderId),
|
|
1934
2041
|
index("financial_accounts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
2042
|
+
check("financial_accounts_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
2043
|
+
check("financial_accounts_holder_pair", sql `("holder_type" IS NULL) = ("holder_id" IS NULL)`),
|
|
1935
2044
|
]);
|
|
1936
2045
|
/** What a statement says moved on a financial account; a payment it settles is `payment_id`. */
|
|
1937
2046
|
export const financialTransactions = sqliteTable("financial_transactions", {
|
|
1938
|
-
id: integer("id").primaryKey(),
|
|
2047
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1939
2048
|
financialAccountId: integer("financial_account_id")
|
|
1940
2049
|
.notNull()
|
|
1941
2050
|
.references(() => financialAccounts.id),
|
|
@@ -1972,9 +2081,12 @@ export const financialTransactions = sqliteTable("financial_transactions", {
|
|
|
1972
2081
|
index("financial_transactions_by_project_id").on(table.projectId),
|
|
1973
2082
|
index("financial_transactions_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1974
2083
|
index("financial_transactions_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
2084
|
+
check("financial_transactions_metadata_json", sql `"metadata" IS NULL OR json_valid("metadata")`),
|
|
2085
|
+
check("financial_transactions_counterparty_pair", sql `("counterparty_type" IS NULL) = ("counterparty_id" IS NULL)`),
|
|
2086
|
+
check("financial_transactions_confirmed_by_pair", sql `("confirmed_by_type" IS NULL) = ("confirmed_by_id" IS NULL)`),
|
|
1975
2087
|
]);
|
|
1976
2088
|
export const transactionSplits = sqliteTable("transaction_splits", {
|
|
1977
|
-
id: integer("id").primaryKey(),
|
|
2089
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
1978
2090
|
transactionId: integer("transaction_id")
|
|
1979
2091
|
.notNull()
|
|
1980
2092
|
.references(() => financialTransactions.id),
|
|
@@ -1996,7 +2108,7 @@ export { enrichments } from "./schema/enrichments.js";
|
|
|
1996
2108
|
export { templates, templatesHistory } from "./schema/templates.js";
|
|
1997
2109
|
/** What a source said about one of its records, as it said it: the layer under the entity an import makes. */
|
|
1998
2110
|
export const records = sqliteTable("records", {
|
|
1999
|
-
id: integer("id").primaryKey(),
|
|
2111
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2000
2112
|
accountId: integer("account_id")
|
|
2001
2113
|
.notNull()
|
|
2002
2114
|
.references(() => accounts.id),
|
|
@@ -2017,9 +2129,11 @@ export const records = sqliteTable("records", {
|
|
|
2017
2129
|
unique().on(table.accountId, table.type, table.externalId),
|
|
2018
2130
|
index("records_by_account_id_batch_id").on(table.accountId, table.batchId),
|
|
2019
2131
|
index("records_by_entity_type_entity_id").on(table.entityType, table.entityId),
|
|
2132
|
+
check("records_fields_json", sql `"fields" IS NULL OR json_valid("fields")`),
|
|
2133
|
+
check("records_entity_pair", sql `("entity_type" IS NULL) = ("entity_id" IS NULL)`),
|
|
2020
2134
|
]);
|
|
2021
2135
|
export const recordRelations = sqliteTable("record_relations", {
|
|
2022
|
-
id: integer("id").primaryKey(),
|
|
2136
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2023
2137
|
recordId: integer("record_id")
|
|
2024
2138
|
.notNull()
|
|
2025
2139
|
.references(() => records.id),
|
|
@@ -2036,7 +2150,7 @@ export const recordRelations = sqliteTable("record_relations", {
|
|
|
2036
2150
|
index("record_relations_by_target_id").on(table.targetId),
|
|
2037
2151
|
]);
|
|
2038
2152
|
export const proposedActions = sqliteTable("proposed_actions", {
|
|
2039
|
-
id: integer("id").primaryKey(),
|
|
2153
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2040
2154
|
kind: text("kind").notNull(),
|
|
2041
2155
|
accountId: integer("account_id").references(() => accounts.id),
|
|
2042
2156
|
targetType: text("target_type"),
|
|
@@ -2061,10 +2175,14 @@ export const proposedActions = sqliteTable("proposed_actions", {
|
|
|
2061
2175
|
index("proposed_actions_by_target_type_target_id").on(table.targetType, table.targetId),
|
|
2062
2176
|
index("proposed_actions_by_proposed_by_type_proposed_by_id").on(table.proposedByType, table.proposedById),
|
|
2063
2177
|
index("proposed_actions_by_decided_by_type_decided_by_id").on(table.decidedByType, table.decidedById),
|
|
2178
|
+
check("proposed_actions_payload_json", sql `"payload" IS NULL OR json_valid("payload")`),
|
|
2179
|
+
check("proposed_actions_result_json", sql `"result" IS NULL OR json_valid("result")`),
|
|
2180
|
+
check("proposed_actions_target_pair", sql `("target_type" IS NULL) = ("target_id" IS NULL)`),
|
|
2181
|
+
check("proposed_actions_decided_by_pair", sql `("decided_by_type" IS NULL) = ("decided_by_id" IS NULL)`),
|
|
2064
2182
|
]);
|
|
2065
2183
|
/** An audit trail that is itself readable by agents, so it names the target and never stores the arguments' text. */
|
|
2066
2184
|
export const agentActions = sqliteTable("agent_actions", {
|
|
2067
|
-
id: integer("id").primaryKey(),
|
|
2185
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2068
2186
|
actorType: text("actor_type").notNull(),
|
|
2069
2187
|
actorId: integer("actor_id").notNull(),
|
|
2070
2188
|
tool: text("tool").notNull(),
|
|
@@ -2080,6 +2198,7 @@ export const agentActions = sqliteTable("agent_actions", {
|
|
|
2080
2198
|
index("agent_actions_by_started_at_desc").on(desc(table.startedAt)),
|
|
2081
2199
|
index("agent_actions_by_actor_type_actor_id").on(table.actorType, table.actorId),
|
|
2082
2200
|
index("agent_actions_by_target_type_target_id").on(table.targetType, table.targetId),
|
|
2201
|
+
check("agent_actions_target_pair", sql `("target_type" IS NULL) = ("target_id" IS NULL)`),
|
|
2083
2202
|
]);
|
|
2084
2203
|
export { canonicalTags } from "./schema/canonical-tags.js";
|
|
2085
2204
|
export const canonicalAutoTagClaims = sqliteTable("canonical_auto_tag_claims", {
|
|
@@ -2104,7 +2223,7 @@ export { links } from "./schema/links.js";
|
|
|
2104
2223
|
* a message or a result. A row with a name is a saved search; an identical unnamed run counts on its row.
|
|
2105
2224
|
*/
|
|
2106
2225
|
export const searches = sqliteTable("searches", {
|
|
2107
|
-
id: integer("id").primaryKey(),
|
|
2226
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2108
2227
|
name: text("name").unique(),
|
|
2109
2228
|
command: text("command").notNull(),
|
|
2110
2229
|
params: text("params").notNull(),
|
|
@@ -2118,10 +2237,11 @@ export const searches = sqliteTable("searches", {
|
|
|
2118
2237
|
}, (table) => [
|
|
2119
2238
|
uniqueIndex("searches_history").on(table.command, table.params).where(sql `name IS NULL`),
|
|
2120
2239
|
index("searches_by_last_run").on(desc(table.lastRunAt)),
|
|
2240
|
+
check("searches_params_json", sql `"params" IS NULL OR json_valid("params")`),
|
|
2121
2241
|
]);
|
|
2122
2242
|
/** Polymorphic, so no foreign key to the tagged row: triggers drop a tagging when its chat or message goes. */
|
|
2123
2243
|
export const taggings = sqliteTable("taggings", {
|
|
2124
|
-
id: integer("id").primaryKey(),
|
|
2244
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2125
2245
|
tagId: integer("tag_id")
|
|
2126
2246
|
.notNull()
|
|
2127
2247
|
.references(() => canonicalTags.id),
|
|
@@ -2136,11 +2256,13 @@ export const taggings = sqliteTable("taggings", {
|
|
|
2136
2256
|
}, (table) => [
|
|
2137
2257
|
unique().on(table.tagId, table.taggableType, table.taggableId),
|
|
2138
2258
|
uniqueIndex("taggings_main_topic").on(table.taggableType, table.taggableId).where(sql `main = 1`),
|
|
2259
|
+
index("taggings_by_taggable_type_taggable_id").on(table.taggableType, table.taggableId),
|
|
2139
2260
|
index("taggings_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
2261
|
+
check("taggings_author_pair", sql `("author_type" IS NULL) = ("author_id" IS NULL)`),
|
|
2140
2262
|
]);
|
|
2141
2263
|
export { tagConsolidations, tagRedirects } from "./schema/tag-consolidations.js";
|
|
2142
2264
|
export const entityLinkEvents = sqliteTable("entity_link_events", {
|
|
2143
|
-
id: integer("id").primaryKey(),
|
|
2265
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2144
2266
|
linkableType: text("linkable_type").notNull(),
|
|
2145
2267
|
linkableId: integer("linkable_id").notNull(),
|
|
2146
2268
|
entityType: text("entity_type").notNull(),
|
|
@@ -2155,7 +2277,7 @@ export const entityLinkEvents = sqliteTable("entity_link_events", {
|
|
|
2155
2277
|
index("entity_link_events_by_entity_type_to_entity_id").on(table.entityType, table.toEntityId),
|
|
2156
2278
|
]);
|
|
2157
2279
|
export const linkReviews = sqliteTable("link_reviews", {
|
|
2158
|
-
id: integer("id").primaryKey(),
|
|
2280
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2159
2281
|
linkableType: text("linkable_type").notNull(),
|
|
2160
2282
|
linkableId: integer("linkable_id").notNull(),
|
|
2161
2283
|
entityType: text("entity_type").notNull(),
|
|
@@ -2170,9 +2292,10 @@ export const linkReviews = sqliteTable("link_reviews", {
|
|
|
2170
2292
|
}, (table) => [
|
|
2171
2293
|
unique().on(table.linkableType, table.linkableId, table.entityType),
|
|
2172
2294
|
index("link_reviews_by_status_created_at").on(table.status, table.createdAt),
|
|
2295
|
+
check("link_reviews_candidates_json", sql `"candidates" IS NULL OR json_valid("candidates")`),
|
|
2173
2296
|
]);
|
|
2174
2297
|
export const conversations = sqliteTable("conversations", {
|
|
2175
|
-
id: integer("id").primaryKey(),
|
|
2298
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2176
2299
|
chatId: integer("chat_id")
|
|
2177
2300
|
.notNull()
|
|
2178
2301
|
.references(() => chats.id, { onDelete: "cascade" }),
|
|
@@ -2383,7 +2506,7 @@ export const conversationReadiness = sqliteTable("conversation_readiness", {
|
|
|
2383
2506
|
* columns are what lists, filters and search read; the rest of the record is `data`, JSON in the domain's field names.
|
|
2384
2507
|
*/
|
|
2385
2508
|
export const trackerItems = sqliteTable("tracker_items", {
|
|
2386
|
-
id: integer("id").primaryKey(),
|
|
2509
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2387
2510
|
accountId: integer("account_id")
|
|
2388
2511
|
.notNull()
|
|
2389
2512
|
.references(() => accounts.id),
|
|
@@ -2405,10 +2528,11 @@ export const trackerItems = sqliteTable("tracker_items", {
|
|
|
2405
2528
|
}, (table) => [
|
|
2406
2529
|
unique().on(table.accountId, table.kind, table.externalId),
|
|
2407
2530
|
index("tracker_items_by_account_id_kind_parent_id").on(table.accountId, table.kind, table.parentId),
|
|
2531
|
+
check("tracker_items_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2408
2532
|
]);
|
|
2409
2533
|
/** A site or a social account a content account publishes on. */
|
|
2410
2534
|
export const contentChannels = sqliteTable("content_channels", {
|
|
2411
|
-
id: integer("id").primaryKey(),
|
|
2535
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2412
2536
|
accountId: integer("account_id")
|
|
2413
2537
|
.notNull()
|
|
2414
2538
|
.references(() => accounts.id),
|
|
@@ -2422,7 +2546,7 @@ export const contentChannels = sqliteTable("content_channels", {
|
|
|
2422
2546
|
syncedAt: integer("synced_at").notNull(),
|
|
2423
2547
|
}, (table) => [unique().on(table.accountId, table.externalId)]);
|
|
2424
2548
|
export const contentAuthors = sqliteTable("content_authors", {
|
|
2425
|
-
id: integer("id").primaryKey(),
|
|
2549
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2426
2550
|
accountId: integer("account_id")
|
|
2427
2551
|
.notNull()
|
|
2428
2552
|
.references(() => accounts.id),
|
|
@@ -2433,9 +2557,12 @@ export const contentAuthors = sqliteTable("content_authors", {
|
|
|
2433
2557
|
sourceUpdatedAt: integer("source_updated_at"),
|
|
2434
2558
|
deletedAt: integer("deleted_at"),
|
|
2435
2559
|
syncedAt: integer("synced_at").notNull(),
|
|
2436
|
-
}, (table) => [
|
|
2560
|
+
}, (table) => [
|
|
2561
|
+
unique().on(table.accountId, table.externalId),
|
|
2562
|
+
check("content_authors_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2563
|
+
]);
|
|
2437
2564
|
export const contentTerms = sqliteTable("content_terms", {
|
|
2438
|
-
id: integer("id").primaryKey(),
|
|
2565
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2439
2566
|
accountId: integer("account_id")
|
|
2440
2567
|
.notNull()
|
|
2441
2568
|
.references(() => accounts.id),
|
|
@@ -2449,10 +2576,14 @@ export const contentTerms = sqliteTable("content_terms", {
|
|
|
2449
2576
|
sourceUpdatedAt: integer("source_updated_at"),
|
|
2450
2577
|
deletedAt: integer("deleted_at"),
|
|
2451
2578
|
syncedAt: integer("synced_at").notNull(),
|
|
2452
|
-
}, (table) => [
|
|
2579
|
+
}, (table) => [
|
|
2580
|
+
unique().on(table.accountId, table.externalId),
|
|
2581
|
+
index("content_terms_by_tag_id").on(table.tagId),
|
|
2582
|
+
check("content_terms_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2583
|
+
]);
|
|
2453
2584
|
/** A post or page of a blog, or a social post, with its text as Markdown; the rest of the record is `data`. */
|
|
2454
2585
|
export const contentPosts = sqliteTable("content_posts", {
|
|
2455
|
-
id: integer("id").primaryKey(),
|
|
2586
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2456
2587
|
accountId: integer("account_id")
|
|
2457
2588
|
.notNull()
|
|
2458
2589
|
.references(() => accounts.id),
|
|
@@ -2477,10 +2608,11 @@ export const contentPosts = sqliteTable("content_posts", {
|
|
|
2477
2608
|
unique().on(table.accountId, table.externalId),
|
|
2478
2609
|
index("content_posts_by_account_id_status").on(table.accountId, table.status),
|
|
2479
2610
|
index("content_posts_by_account_id_published_at").on(table.accountId, table.publishedAt),
|
|
2611
|
+
check("content_posts_data_json", sql `"data" IS NULL OR json_valid("data")`),
|
|
2480
2612
|
]);
|
|
2481
2613
|
/** What a sync or a write replaced in a post, and a post the source deleted, kept before the change. */
|
|
2482
2614
|
export const contentPostRevisions = sqliteTable("content_post_revisions", {
|
|
2483
|
-
id: integer("id").primaryKey(),
|
|
2615
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2484
2616
|
postId: integer("post_id")
|
|
2485
2617
|
.notNull()
|
|
2486
2618
|
.references(() => contentPosts.id),
|
|
@@ -2494,7 +2626,7 @@ export const contentPostRevisions = sqliteTable("content_post_revisions", {
|
|
|
2494
2626
|
}, (table) => [index("content_post_revisions_by_post_id_created_at").on(table.postId, table.createdAt)]);
|
|
2495
2627
|
/** One reading of a post's numbers; each reading is a new row. */
|
|
2496
2628
|
export const contentMetrics = sqliteTable("content_metrics", {
|
|
2497
|
-
id: integer("id").primaryKey(),
|
|
2629
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
2498
2630
|
postId: integer("post_id")
|
|
2499
2631
|
.notNull()
|
|
2500
2632
|
.references(() => contentPosts.id),
|
|
@@ -2505,7 +2637,10 @@ export const contentMetrics = sqliteTable("content_metrics", {
|
|
|
2505
2637
|
shares: integer("shares"),
|
|
2506
2638
|
clicks: integer("clicks"),
|
|
2507
2639
|
raw: text("raw"),
|
|
2508
|
-
}, (table) => [
|
|
2640
|
+
}, (table) => [
|
|
2641
|
+
index("content_metrics_by_post_id_at").on(table.postId, table.at),
|
|
2642
|
+
check("content_metrics_raw_json", sql `"raw" IS NULL OR json_valid("raw")`),
|
|
2643
|
+
]);
|
|
2509
2644
|
/** Settings of the store file itself, shared by every profile, tg and MAX — unlike a profile's config file. */
|
|
2510
2645
|
export const storeSettings = sqliteTable("store_settings", {
|
|
2511
2646
|
key: text("key").primaryKey(),
|