@rfc0/patty 0.0.0-stage → 1.0.2
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/LICENSE +201 -0
- package/README.md +214 -2
- package/dist/adapters/access-tokens.js +7 -0
- package/dist/adapters/accounts.js +37 -0
- package/dist/adapters/auth.js +11 -0
- package/dist/adapters/bills.js +32 -0
- package/dist/adapters/budgets.js +29 -0
- package/dist/adapters/categories.js +32 -0
- package/dist/adapters/client-grants.js +7 -0
- package/dist/adapters/credit-cards.js +33 -0
- package/dist/adapters/currencies.js +2 -0
- package/dist/adapters/currency-rates.js +18 -0
- package/dist/adapters/dashboards.js +43 -0
- package/dist/adapters/demo.js +13 -0
- package/dist/adapters/instance-settings.js +7 -0
- package/dist/adapters/invites.js +7 -0
- package/dist/adapters/recurring.js +55 -0
- package/dist/adapters/sessions.js +7 -0
- package/dist/adapters/settings.js +4 -0
- package/dist/adapters/setup-codes.js +7 -0
- package/dist/adapters/tags.js +9 -0
- package/dist/adapters/transactions.js +95 -0
- package/dist/adapters/users.js +7 -0
- package/dist/common/build-version.js +5 -0
- package/dist/common/errors.js +118 -0
- package/dist/common/net.js +71 -0
- package/dist/common/result.js +7 -0
- package/dist/composition/auth.js +106 -0
- package/dist/composition/boot.js +27 -0
- package/dist/composition/cli.js +86 -0
- package/dist/composition/demo/seed.js +92 -0
- package/dist/composition/demo/shell.js +107 -0
- package/dist/composition/export.js +89 -0
- package/dist/composition/http.js +110 -0
- package/dist/composition/import.js +55 -0
- package/dist/composition/lazy-modules.js +2 -0
- package/dist/composition/runtime.js +115 -0
- package/dist/composition/sign-in/interpreter.js +154 -0
- package/dist/composition/sign-in/server.js +36 -0
- package/dist/composition/sign-in/wiring.js +23 -0
- package/dist/composition/stdio.js +69 -0
- package/dist/config.js +136 -0
- package/dist/controllers/account/account.js +88 -0
- package/dist/controllers/account/transaction.js +119 -0
- package/dist/controllers/account/transfer.js +34 -0
- package/dist/controllers/aggregate.js +40 -0
- package/dist/controllers/auth/access-tokens.js +61 -0
- package/dist/controllers/auth/grants.js +136 -0
- package/dist/controllers/auth/key-export.js +20 -0
- package/dist/controllers/auth/owner.js +80 -0
- package/dist/controllers/auth/password.js +35 -0
- package/dist/controllers/auth/session.js +50 -0
- package/dist/controllers/auth/step-up.js +8 -0
- package/dist/controllers/auth/users.js +183 -0
- package/dist/controllers/budgets.js +87 -0
- package/dist/controllers/categories.js +67 -0
- package/dist/controllers/correlations.js +112 -0
- package/dist/controllers/credit-card/bill.js +105 -0
- package/dist/controllers/credit-card/credit-card.js +129 -0
- package/dist/controllers/credit-card/transaction.js +181 -0
- package/dist/controllers/currencies.js +1 -0
- package/dist/controllers/currency-rates.js +40 -0
- package/dist/controllers/dashboards.js +68 -0
- package/dist/controllers/demo/seed.js +31 -0
- package/dist/controllers/demo/tour.js +12 -0
- package/dist/controllers/deps.js +6 -0
- package/dist/controllers/instance.js +6 -0
- package/dist/controllers/merchants.js +12 -0
- package/dist/controllers/recurring.js +70 -0
- package/dist/controllers/resolve.js +37 -0
- package/dist/controllers/settings.js +47 -0
- package/dist/controllers/status.js +19 -0
- package/dist/controllers/summary.js +21 -0
- package/dist/controllers/tags.js +19 -0
- package/dist/controllers/transaction/bulk.js +6 -0
- package/dist/controllers/transaction/core.js +49 -0
- package/dist/controllers/transaction/read.js +28 -0
- package/dist/diplomat/auth/credentials.js +58 -0
- package/dist/diplomat/auth/sign-in-store.js +18 -0
- package/dist/diplomat/cli/commands/auth.js +100 -0
- package/dist/diplomat/cli/commands/db.js +72 -0
- package/dist/diplomat/cli/commands/demo.js +68 -0
- package/dist/diplomat/cli/commands/key.js +119 -0
- package/dist/diplomat/cli/commands/login.js +151 -0
- package/dist/diplomat/cli/commands/setup.js +132 -0
- package/dist/diplomat/cli/commands/users.js +123 -0
- package/dist/diplomat/cli/commands.js +61 -0
- package/dist/diplomat/cli/export-file.js +37 -0
- package/dist/diplomat/cli/import-file.js +44 -0
- package/dist/diplomat/cli/io.js +61 -0
- package/dist/diplomat/cli/key-export-approval.js +37 -0
- package/dist/diplomat/cli/messages.js +96 -0
- package/dist/diplomat/cli/prompt.js +74 -0
- package/dist/diplomat/cli/terminal.js +81 -0
- package/dist/diplomat/client-config/clients.js +150 -0
- package/dist/diplomat/client-config/merge.js +41 -0
- package/dist/diplomat/db/bootstrap.js +98 -0
- package/dist/diplomat/db/database-files.js +147 -0
- package/dist/diplomat/db/driver.js +167 -0
- package/dist/diplomat/db/effects.js +101 -0
- package/dist/diplomat/db/engine.js +9 -0
- package/dist/diplomat/db/export.js +22 -0
- package/dist/diplomat/db/file-lock.js +82 -0
- package/dist/diplomat/db/key-lock.js +14 -0
- package/dist/diplomat/db/locale-cache.js +23 -0
- package/dist/diplomat/db/migration-barrier.js +57 -0
- package/dist/diplomat/db/migration-journal.js +18 -0
- package/dist/diplomat/db/migration-lock.js +15 -0
- package/dist/diplomat/db/migrations.js +11 -0
- package/dist/diplomat/db/present.js +17 -0
- package/dist/diplomat/db/queries/aggregate-whitelist.js +35 -0
- package/dist/diplomat/db/queries/filters.js +59 -0
- package/dist/diplomat/db/queries/fts.js +18 -0
- package/dist/diplomat/db/queries/scope.js +8 -0
- package/dist/diplomat/db/queries/transaction-select.js +26 -0
- package/dist/diplomat/db/queries/tx-predicates.js +13 -0
- package/dist/diplomat/db/repos/access-tokens.js +27 -0
- package/dist/diplomat/db/repos/accounts.js +91 -0
- package/dist/diplomat/db/repos/bills.js +93 -0
- package/dist/diplomat/db/repos/budgets.js +72 -0
- package/dist/diplomat/db/repos/categories.js +53 -0
- package/dist/diplomat/db/repos/client-grants.js +67 -0
- package/dist/diplomat/db/repos/correlations.js +66 -0
- package/dist/diplomat/db/repos/credit-cards.js +67 -0
- package/dist/diplomat/db/repos/currencies.js +8 -0
- package/dist/diplomat/db/repos/currency-rates.js +40 -0
- package/dist/diplomat/db/repos/dashboards.js +123 -0
- package/dist/diplomat/db/repos/health.js +12 -0
- package/dist/diplomat/db/repos/instance-settings.js +14 -0
- package/dist/diplomat/db/repos/instance.js +58 -0
- package/dist/diplomat/db/repos/invites.js +43 -0
- package/dist/diplomat/db/repos/merchants.js +121 -0
- package/dist/diplomat/db/repos/recurring.js +29 -0
- package/dist/diplomat/db/repos/sessions.js +19 -0
- package/dist/diplomat/db/repos/settings.js +41 -0
- package/dist/diplomat/db/repos/setup-codes.js +28 -0
- package/dist/diplomat/db/repos/sub-categories.js +67 -0
- package/dist/diplomat/db/repos/tags.js +51 -0
- package/dist/diplomat/db/repos/transaction-tags.js +57 -0
- package/dist/diplomat/db/repos/transactions.js +163 -0
- package/dist/diplomat/db/repos/users.js +47 -0
- package/dist/diplomat/db/safety-copy.js +87 -0
- package/dist/diplomat/db/schema.js +348 -0
- package/dist/diplomat/db/seed/categories.js +112 -0
- package/dist/diplomat/db/seed/currencies.js +9 -0
- package/dist/diplomat/db/seed/demo/br.js +98 -0
- package/dist/diplomat/db/seed/demo/co.js +89 -0
- package/dist/diplomat/db/seed/demo/index.js +12 -0
- package/dist/diplomat/db/seed/demo/mx.js +90 -0
- package/dist/diplomat/db/seed/demo/shared.js +39 -0
- package/dist/diplomat/db/seed/demo/us.js +90 -0
- package/dist/diplomat/db/seed/merchant-rules.js +188 -0
- package/dist/diplomat/db/sqlite-errors.js +40 -0
- package/dist/diplomat/db/tenancy-integrity.js +45 -0
- package/dist/diplomat/db/version-guard.js +16 -0
- package/dist/diplomat/http/auth-pages.js +41 -0
- package/dist/diplomat/http/auth-paths.js +46 -0
- package/dist/diplomat/http/bearer.js +15 -0
- package/dist/diplomat/http/connect-pages.js +51 -0
- package/dist/diplomat/http/context.js +17 -0
- package/dist/diplomat/http/cookies.js +27 -0
- package/dist/diplomat/http/form-pages.js +38 -0
- package/dist/diplomat/http/hooks/auth.js +106 -0
- package/dist/diplomat/http/hooks/demo-marker.js +59 -0
- package/dist/diplomat/http/openapi.js +73 -0
- package/dist/diplomat/http/principal.js +1 -0
- package/dist/diplomat/http/rate-limiter.js +78 -0
- package/dist/diplomat/http/remedy.js +26 -0
- package/dist/diplomat/http/respond.js +50 -0
- package/dist/diplomat/http/routes/account.js +226 -0
- package/dist/diplomat/http/routes/aggregate.js +28 -0
- package/dist/diplomat/http/routes/auth.js +105 -0
- package/dist/diplomat/http/routes/budget.js +34 -0
- package/dist/diplomat/http/routes/category.js +109 -0
- package/dist/diplomat/http/routes/connect.js +124 -0
- package/dist/diplomat/http/routes/credit-card.js +263 -0
- package/dist/diplomat/http/routes/currency-rates.js +60 -0
- package/dist/diplomat/http/routes/currency.js +16 -0
- package/dist/diplomat/http/routes/dashboard.js +93 -0
- package/dist/diplomat/http/routes/invite.js +63 -0
- package/dist/diplomat/http/routes/recurring.js +65 -0
- package/dist/diplomat/http/routes/settings.js +38 -0
- package/dist/diplomat/http/routes/summary.js +23 -0
- package/dist/diplomat/http/routes/system.js +29 -0
- package/dist/diplomat/http/routes/tag.js +51 -0
- package/dist/diplomat/http/routes/tokens.js +72 -0
- package/dist/diplomat/http/routes/transaction.js +55 -0
- package/dist/diplomat/http/routes/transfer.js +35 -0
- package/dist/diplomat/http/routes/ui.js +110 -0
- package/dist/diplomat/http/routes/users.js +156 -0
- package/dist/diplomat/http/routes/well-known.js +26 -0
- package/dist/diplomat/http/routes.js +85 -0
- package/dist/diplomat/http/session.js +34 -0
- package/dist/diplomat/http/token-pages.js +75 -0
- package/dist/diplomat/http/ui-files.js +21 -0
- package/dist/diplomat/http/user-pages.js +93 -0
- package/dist/diplomat/mcp/annotations.js +8 -0
- package/dist/diplomat/mcp/auth-info.js +20 -0
- package/dist/diplomat/mcp/context.js +14 -0
- package/dist/diplomat/mcp/definition.js +3 -0
- package/dist/diplomat/mcp/gate.js +15 -0
- package/dist/diplomat/mcp/instructions.js +19 -0
- package/dist/diplomat/mcp/prompts.js +125 -0
- package/dist/diplomat/mcp/register.js +12 -0
- package/dist/diplomat/mcp/remedy.js +17 -0
- package/dist/diplomat/mcp/resources.js +93 -0
- package/dist/diplomat/mcp/respond.js +20 -0
- package/dist/diplomat/mcp/route.js +62 -0
- package/dist/diplomat/mcp/scopes.js +53 -0
- package/dist/diplomat/mcp/server.js +26 -0
- package/dist/diplomat/mcp/shared.js +5 -0
- package/dist/diplomat/mcp/stdio-session.js +94 -0
- package/dist/diplomat/mcp/stdio.js +23 -0
- package/dist/diplomat/mcp/tool-name.js +59 -0
- package/dist/diplomat/mcp/tools/account.js +218 -0
- package/dist/diplomat/mcp/tools/aggregate.js +32 -0
- package/dist/diplomat/mcp/tools/budget.js +99 -0
- package/dist/diplomat/mcp/tools/category.js +103 -0
- package/dist/diplomat/mcp/tools/correlations.js +70 -0
- package/dist/diplomat/mcp/tools/credit-card.js +239 -0
- package/dist/diplomat/mcp/tools/currency-rates.js +62 -0
- package/dist/diplomat/mcp/tools/dashboard.js +75 -0
- package/dist/diplomat/mcp/tools/index.js +31 -0
- package/dist/diplomat/mcp/tools/recurring.js +62 -0
- package/dist/diplomat/mcp/tools/summary.js +30 -0
- package/dist/diplomat/mcp/tools/system.js +83 -0
- package/dist/diplomat/mcp/tools/tag.js +48 -0
- package/dist/diplomat/mcp/tools/transaction.js +53 -0
- package/dist/diplomat/mcp/tools/transfer.js +28 -0
- package/dist/diplomat/mcp/tour.js +87 -0
- package/dist/logic/account.js +79 -0
- package/dist/logic/aggregate.js +37 -0
- package/dist/logic/auth/bearer.js +35 -0
- package/dist/logic/auth/grant.js +126 -0
- package/dist/logic/auth/key-export.js +10 -0
- package/dist/logic/auth/keychain.js +3 -0
- package/dist/logic/auth/message.js +22 -0
- package/dist/logic/auth/origin.js +57 -0
- package/dist/logic/auth/owner.js +22 -0
- package/dist/logic/auth/password.js +3 -0
- package/dist/logic/auth/redact.js +25 -0
- package/dist/logic/auth/revoke.js +28 -0
- package/dist/logic/auth/scope.js +17 -0
- package/dist/logic/auth/session.js +30 -0
- package/dist/logic/auth/sign-in-flow.js +305 -0
- package/dist/logic/auth/time.js +2 -0
- package/dist/logic/auth/token.js +74 -0
- package/dist/logic/auth/user-plans.js +84 -0
- package/dist/logic/auth/users.js +78 -0
- package/dist/logic/balance.js +2 -0
- package/dist/logic/bill.js +74 -0
- package/dist/logic/budget.js +78 -0
- package/dist/logic/category.js +37 -0
- package/dist/logic/classify.js +21 -0
- package/dist/logic/correlations.js +147 -0
- package/dist/logic/credit-card.js +2 -0
- package/dist/logic/currency-rate.js +69 -0
- package/dist/logic/dashboard.js +40 -0
- package/dist/logic/demo/database.js +30 -0
- package/dist/logic/demo/plan.js +308 -0
- package/dist/logic/demo/tour.js +33 -0
- package/dist/logic/export-destination.js +12 -0
- package/dist/logic/key-import.js +15 -0
- package/dist/logic/locale.js +5 -0
- package/dist/logic/localize.js +12 -0
- package/dist/logic/merchant.js +31 -0
- package/dist/logic/migration.js +1 -0
- package/dist/logic/money.js +12 -0
- package/dist/logic/period.js +45 -0
- package/dist/logic/persistence.js +48 -0
- package/dist/logic/recurring.js +51 -0
- package/dist/logic/resolve.js +44 -0
- package/dist/logic/summary.js +29 -0
- package/dist/logic/tag.js +13 -0
- package/dist/logic/transaction.js +197 -0
- package/dist/main.js +42 -0
- package/dist/models/account.js +197 -0
- package/dist/models/aggregate.js +61 -0
- package/dist/models/auth/bearer.js +11 -0
- package/dist/models/auth/entity.js +17 -0
- package/dist/models/auth/errors.js +42 -0
- package/dist/models/auth/grant.js +58 -0
- package/dist/models/auth/key-export.js +11 -0
- package/dist/models/auth/message.js +50 -0
- package/dist/models/auth/mode.js +7 -0
- package/dist/models/auth/origin.js +16 -0
- package/dist/models/auth/owner.js +36 -0
- package/dist/models/auth/password.js +24 -0
- package/dist/models/auth/principal.js +26 -0
- package/dist/models/auth/redact.js +4 -0
- package/dist/models/auth/scope.js +9 -0
- package/dist/models/auth/session.js +19 -0
- package/dist/models/auth/sign-in-flow.js +102 -0
- package/dist/models/auth/sign-in.js +41 -0
- package/dist/models/auth/time.js +5 -0
- package/dist/models/auth/token.js +50 -0
- package/dist/models/auth/users.js +52 -0
- package/dist/models/bill.js +55 -0
- package/dist/models/budget.js +106 -0
- package/dist/models/category.js +52 -0
- package/dist/models/client-config.js +18 -0
- package/dist/models/correlations.js +215 -0
- package/dist/models/credit-card.js +156 -0
- package/dist/models/currency-rate.js +83 -0
- package/dist/models/dashboard.js +54 -0
- package/dist/models/database.js +16 -0
- package/dist/models/date.js +8 -0
- package/dist/models/demo/core.js +58 -0
- package/dist/models/demo/tour.js +41 -0
- package/dist/models/encryption-key.js +2 -0
- package/dist/models/error.js +13 -0
- package/dist/models/export.js +9 -0
- package/dist/models/id.js +2 -0
- package/dist/models/instance.js +7 -0
- package/dist/models/key-import.js +6 -0
- package/dist/models/locale.js +25 -0
- package/dist/models/merchant.js +12 -0
- package/dist/models/money.js +14 -0
- package/dist/models/package.js +12 -0
- package/dist/models/page.js +56 -0
- package/dist/models/persistence.js +1 -0
- package/dist/models/prompts.js +5 -0
- package/dist/models/recurring.js +54 -0
- package/dist/models/remedy.js +17 -0
- package/dist/models/resolution.js +1 -0
- package/dist/models/startup.js +7 -0
- package/dist/models/summary.js +24 -0
- package/dist/models/tag.js +14 -0
- package/dist/models/tenancy.js +10 -0
- package/dist/models/transaction-tag.js +6 -0
- package/dist/models/transaction.js +275 -0
- package/dist/wire/db/access-tokens.js +1 -0
- package/dist/wire/db/accounts.js +7 -0
- package/dist/wire/db/aggregate.js +16 -0
- package/dist/wire/db/bills.js +14 -0
- package/dist/wire/db/budgets.js +33 -0
- package/dist/wire/db/categories.js +14 -0
- package/dist/wire/db/client-grants.js +1 -0
- package/dist/wire/db/correlations.js +49 -0
- package/dist/wire/db/credit-cards.js +1 -0
- package/dist/wire/db/currencies.js +1 -0
- package/dist/wire/db/currency-rates.js +1 -0
- package/dist/wire/db/dashboards.js +1 -0
- package/dist/wire/db/instance-settings.js +1 -0
- package/dist/wire/db/invites.js +1 -0
- package/dist/wire/db/merchants.js +18 -0
- package/dist/wire/db/recurring.js +19 -0
- package/dist/wire/db/sessions.js +1 -0
- package/dist/wire/db/settings.js +1 -0
- package/dist/wire/db/setup-codes.js +1 -0
- package/dist/wire/db/tags.js +1 -0
- package/dist/wire/db/tenancy.js +1 -0
- package/dist/wire/db/transactions.js +89 -0
- package/dist/wire/db/users.js +1 -0
- package/dist/wire/in/accounts.js +26 -0
- package/dist/wire/in/aggregate.js +10 -0
- package/dist/wire/in/auth.js +107 -0
- package/dist/wire/in/bills.js +11 -0
- package/dist/wire/in/budgets.js +11 -0
- package/dist/wire/in/categories.js +9 -0
- package/dist/wire/in/cli.js +106 -0
- package/dist/wire/in/coerce.js +6 -0
- package/dist/wire/in/common.js +17 -0
- package/dist/wire/in/credit-cards.js +16 -0
- package/dist/wire/in/currency-rates.js +8 -0
- package/dist/wire/in/period.js +7 -0
- package/dist/wire/in/recurring.js +6 -0
- package/dist/wire/in/settings.js +5 -0
- package/dist/wire/in/summary.js +5 -0
- package/dist/wire/in/tags.js +2 -0
- package/dist/wire/in/transactions.js +31 -0
- package/dist/wire/out/bills.js +9 -0
- package/dist/wire/out/budgets.js +10 -0
- package/dist/wire/out/client-config.js +2 -0
- package/dist/wire/out/common.js +4 -0
- package/dist/wire/out/credit-cards.js +15 -0
- package/dist/wire/out/currency-rates.js +11 -0
- package/dist/wire/out/errors.js +58 -0
- package/dist/wire/out/recurring.js +6 -0
- package/dist/wire/out/status.js +10 -0
- package/dist/wire/out/summary.js +9 -0
- package/dist/wire/out/transactions.js +52 -0
- package/drizzle/0000_futuristic_umar.sql +124 -0
- package/drizzle/0001_fts5_search.sql +23 -0
- package/drizzle/0002_rename_graph_to_history.sql +7 -0
- package/drizzle/0003_lyrical_hairball.sql +2 -0
- package/drizzle/0004_misty_ikaris.sql +7 -0
- package/drizzle/0005_credit-liability-accounts.sql +14 -0
- package/drizzle/0006_smart_aqueduct.sql +1 -0
- package/drizzle/0007_add_dashboards.sql +5 -0
- package/drizzle/0008_yummy_madripoor.sql +1 -0
- package/drizzle/0009_version_groundwork.sql +9 -0
- package/drizzle/0010_category_merchant_association_cascade.sql +16 -0
- package/drizzle/0011_dashboard_id_normalization.sql +16 -0
- package/drizzle/0012_hot_the_spike.sql +12 -0
- package/drizzle/0013_recurring_rules_merchant.sql +1 -0
- package/drizzle/0014_dashboard_source_discriminator.sql +17 -0
- package/drizzle/0015_currencies_decimals.sql +1 -0
- package/drizzle/0016_unusual_zaran.sql +13 -0
- package/drizzle/0017_premium_blur.sql +1 -0
- package/drizzle/0018_auth_identity.sql +39 -0
- package/drizzle/0019_access_tokens.sql +16 -0
- package/drizzle/0020_stdio_sign_in.sql +27 -0
- package/drizzle/0021_tenancy_data.sql +289 -0
- package/drizzle/0022_user_management.sql +17 -0
- package/drizzle/0023_instance_settings_row.sql +2 -0
- package/drizzle/0024_credentials_changed_at.sql +2 -0
- package/drizzle/0025_instance_kind.sql +2 -0
- package/drizzle/0026_demo_seeded_at.sql +2 -0
- package/drizzle/0027_demo_country.sql +2 -0
- package/drizzle/0028_reset_sign_ins.sql +2 -0
- package/drizzle/meta/0000_snapshot.json +894 -0
- package/drizzle/meta/0003_snapshot.json +910 -0
- package/drizzle/meta/0004_snapshot.json +951 -0
- package/drizzle/meta/0005_snapshot.json +991 -0
- package/drizzle/meta/0006_snapshot.json +998 -0
- package/drizzle/meta/0007_snapshot.json +1029 -0
- package/drizzle/meta/0008_snapshot.json +1049 -0
- package/drizzle/meta/0009_snapshot.json +1121 -0
- package/drizzle/meta/0010_snapshot.json +1121 -0
- package/drizzle/meta/0011_snapshot.json +1136 -0
- package/drizzle/meta/0012_snapshot.json +1227 -0
- package/drizzle/meta/0013_snapshot.json +1247 -0
- package/drizzle/meta/0014_snapshot.json +1267 -0
- package/drizzle/meta/0015_snapshot.json +1275 -0
- package/drizzle/meta/0016_snapshot.json +1371 -0
- package/drizzle/meta/0017_snapshot.json +1392 -0
- package/drizzle/meta/0018_snapshot.json +1603 -0
- package/drizzle/meta/0019_snapshot.json +1713 -0
- package/drizzle/meta/0020_snapshot.json +1904 -0
- package/drizzle/meta/0021_snapshot.json +2186 -0
- package/drizzle/meta/0022_snapshot.json +2311 -0
- package/drizzle/meta/0023_snapshot.json +2311 -0
- package/drizzle/meta/0024_snapshot.json +2318 -0
- package/drizzle/meta/0025_snapshot.json +2326 -0
- package/drizzle/meta/0026_snapshot.json +2333 -0
- package/drizzle/meta/0027_snapshot.json +2340 -0
- package/drizzle/meta/0028_snapshot.json +2340 -0
- package/drizzle/meta/_journal.json +209 -0
- package/package.json +106 -4
- package/skills/dashboard-building/SKILL.md +201 -0
- package/skills/patty-tour/SKILL.md +34 -0
- package/ui/app.css +758 -0
- package/ui/app.js +543 -0
- package/ui/connect-result.html +16 -0
- package/ui/connect.html +53 -0
- package/ui/dashboards/accounts.html +3189 -0
- package/ui/dashboards/budget.html +1734 -0
- package/ui/dashboards/cards.html +4032 -0
- package/ui/dashboards/categories.html +4694 -0
- package/ui/dashboards/comparative.html +2475 -0
- package/ui/dashboards/dashboards.html +839 -0
- package/ui/dashboards/overview.html +2405 -0
- package/ui/dashboards/pending.html +2973 -0
- package/ui/dashboards/projections.html +2528 -0
- package/ui/dashboards/tags.html +1365 -0
- package/ui/invite.html +44 -0
- package/ui/login.html +26 -0
- package/ui/money.js +175 -0
- package/ui/setup.html +29 -0
- package/ui/shell.html +96 -0
- package/ui/token-created.html +24 -0
- package/ui/tokens.html +58 -0
- package/ui/user-invited.html +27 -0
- package/ui/users.html +60 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
-- Tenancy: every owned row gets a user_id, backfilled to the owner (looked up, so a missing owner fails NOT NULL and rolls back); shared defaults keep NULL.
|
|
2
|
+
-- Tables are rebuilt because SQLite cannot add a NOT NULL foreign key or drop a UNIQUE in place. That needs foreign keys OFF: dropping
|
|
3
|
+
-- `transactions` with them on would cascade away `transaction_tags`, so the guard below aborts otherwise.
|
|
4
|
+
CREATE TABLE `__fk_guard` (`enforcement_is_off` integer NOT NULL);
|
|
5
|
+
--> statement-breakpoint
|
|
6
|
+
INSERT INTO `__fk_guard` SELECT CASE WHEN `foreign_keys` = 0 THEN 1 END FROM pragma_foreign_keys;
|
|
7
|
+
--> statement-breakpoint
|
|
8
|
+
DROP TABLE `__fk_guard`;
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
CREATE TABLE `user_settings` (
|
|
11
|
+
`user_id` text PRIMARY KEY NOT NULL,
|
|
12
|
+
`locale` text DEFAULT 'en' NOT NULL,
|
|
13
|
+
`locale_source` text DEFAULT 'default' NOT NULL,
|
|
14
|
+
`base_currency` text,
|
|
15
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
16
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
17
|
+
FOREIGN KEY (`base_currency`) REFERENCES `currencies`(`code`) ON UPDATE no action ON DELETE no action
|
|
18
|
+
);
|
|
19
|
+
--> statement-breakpoint
|
|
20
|
+
INSERT INTO `user_settings` (`user_id`, `locale`, `locale_source`, `base_currency`, `version`)
|
|
21
|
+
SELECT (SELECT `id` FROM `users` WHERE `id` = 'user-owner'), `locale`, `locale_source`, `base_currency`, `version` FROM `settings` WHERE `id` = 'singleton';
|
|
22
|
+
--> statement-breakpoint
|
|
23
|
+
CREATE TABLE `__new_settings` (
|
|
24
|
+
`id` text PRIMARY KEY DEFAULT 'singleton' NOT NULL,
|
|
25
|
+
`version` integer DEFAULT 0 NOT NULL
|
|
26
|
+
);
|
|
27
|
+
--> statement-breakpoint
|
|
28
|
+
INSERT INTO `__new_settings` (`id`, `version`) SELECT `id`, `version` FROM `settings`;
|
|
29
|
+
--> statement-breakpoint
|
|
30
|
+
DROP TABLE `settings`;
|
|
31
|
+
--> statement-breakpoint
|
|
32
|
+
ALTER TABLE `__new_settings` RENAME TO `settings`;
|
|
33
|
+
--> statement-breakpoint
|
|
34
|
+
CREATE TABLE `__new_accounts` (
|
|
35
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
36
|
+
`name` text NOT NULL,
|
|
37
|
+
`type` text NOT NULL,
|
|
38
|
+
`initial_balance` real DEFAULT 0 NOT NULL,
|
|
39
|
+
`currency` text NOT NULL,
|
|
40
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
41
|
+
`user_id` text NOT NULL,
|
|
42
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
43
|
+
FOREIGN KEY (`currency`) REFERENCES `currencies`(`code`) ON UPDATE no action ON DELETE no action
|
|
44
|
+
);
|
|
45
|
+
--> statement-breakpoint
|
|
46
|
+
INSERT INTO `__new_accounts` (`id`, `name`, `type`, `initial_balance`, `currency`, `version`, `user_id`) SELECT `id`, `name`, `type`, `initial_balance`, `currency`, `version`, (SELECT `id` FROM `users` WHERE `id` = 'user-owner') FROM `accounts`;
|
|
47
|
+
--> statement-breakpoint
|
|
48
|
+
DROP TABLE `accounts`;
|
|
49
|
+
--> statement-breakpoint
|
|
50
|
+
ALTER TABLE `__new_accounts` RENAME TO `accounts`;
|
|
51
|
+
--> statement-breakpoint
|
|
52
|
+
CREATE TABLE `__new_credit_cards` (
|
|
53
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
54
|
+
`name` text NOT NULL,
|
|
55
|
+
`closing_day` integer NOT NULL,
|
|
56
|
+
`due_day` integer NOT NULL,
|
|
57
|
+
`limit_amount` real,
|
|
58
|
+
`currency` text NOT NULL,
|
|
59
|
+
`account_id` text NOT NULL,
|
|
60
|
+
`payment_account_id` text,
|
|
61
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
62
|
+
`user_id` text NOT NULL,
|
|
63
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
64
|
+
FOREIGN KEY (`currency`) REFERENCES `currencies`(`code`) ON UPDATE no action ON DELETE no action,
|
|
65
|
+
FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON UPDATE no action ON DELETE no action,
|
|
66
|
+
FOREIGN KEY (`payment_account_id`) REFERENCES `accounts`(`id`) ON UPDATE no action ON DELETE no action
|
|
67
|
+
);
|
|
68
|
+
--> statement-breakpoint
|
|
69
|
+
INSERT INTO `__new_credit_cards` (`id`, `name`, `closing_day`, `due_day`, `limit_amount`, `currency`, `account_id`, `payment_account_id`, `version`, `user_id`) SELECT `id`, `name`, `closing_day`, `due_day`, `limit_amount`, `currency`, `account_id`, `payment_account_id`, `version`, (SELECT `id` FROM `users` WHERE `id` = 'user-owner') FROM `credit_cards`;
|
|
70
|
+
--> statement-breakpoint
|
|
71
|
+
DROP TABLE `credit_cards`;
|
|
72
|
+
--> statement-breakpoint
|
|
73
|
+
ALTER TABLE `__new_credit_cards` RENAME TO `credit_cards`;
|
|
74
|
+
--> statement-breakpoint
|
|
75
|
+
CREATE TABLE `__new_bills` (
|
|
76
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
77
|
+
`credit_card_id` text NOT NULL,
|
|
78
|
+
`month` integer NOT NULL,
|
|
79
|
+
`year` integer NOT NULL,
|
|
80
|
+
`close_date` text NOT NULL,
|
|
81
|
+
`due_date` text NOT NULL,
|
|
82
|
+
`status` text NOT NULL,
|
|
83
|
+
`payment_transaction_id` text,
|
|
84
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
85
|
+
`user_id` text NOT NULL,
|
|
86
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
87
|
+
FOREIGN KEY (`credit_card_id`) REFERENCES `credit_cards`(`id`) ON UPDATE no action ON DELETE no action,
|
|
88
|
+
FOREIGN KEY (`payment_transaction_id`) REFERENCES `transactions`(`id`) ON UPDATE no action ON DELETE no action
|
|
89
|
+
);
|
|
90
|
+
--> statement-breakpoint
|
|
91
|
+
INSERT INTO `__new_bills` (`id`, `credit_card_id`, `month`, `year`, `close_date`, `due_date`, `status`, `payment_transaction_id`, `version`, `user_id`) SELECT `id`, `credit_card_id`, `month`, `year`, `close_date`, `due_date`, `status`, `payment_transaction_id`, `version`, (SELECT `id` FROM `users` WHERE `id` = 'user-owner') FROM `bills`;
|
|
92
|
+
--> statement-breakpoint
|
|
93
|
+
DROP TABLE `bills`;
|
|
94
|
+
--> statement-breakpoint
|
|
95
|
+
ALTER TABLE `__new_bills` RENAME TO `bills`;
|
|
96
|
+
--> statement-breakpoint
|
|
97
|
+
CREATE UNIQUE INDEX `bills_card_month_year` ON `bills` (`credit_card_id`,`month`,`year`);
|
|
98
|
+
--> statement-breakpoint
|
|
99
|
+
CREATE TABLE `__new_tags` (
|
|
100
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
101
|
+
`name` text NOT NULL,
|
|
102
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
103
|
+
`user_id` text NOT NULL,
|
|
104
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict
|
|
105
|
+
);
|
|
106
|
+
--> statement-breakpoint
|
|
107
|
+
INSERT INTO `__new_tags` (`id`, `name`, `version`, `user_id`) SELECT `id`, `name`, `version`, (SELECT `id` FROM `users` WHERE `id` = 'user-owner') FROM `tags`;
|
|
108
|
+
--> statement-breakpoint
|
|
109
|
+
DROP TABLE `tags`;
|
|
110
|
+
--> statement-breakpoint
|
|
111
|
+
ALTER TABLE `__new_tags` RENAME TO `tags`;
|
|
112
|
+
--> statement-breakpoint
|
|
113
|
+
CREATE UNIQUE INDEX `tags_user_name` ON `tags` (`user_id`,`name`);
|
|
114
|
+
--> statement-breakpoint
|
|
115
|
+
CREATE TABLE `__new_budgets` (
|
|
116
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
117
|
+
`category_id` text NOT NULL,
|
|
118
|
+
`currency` text NOT NULL,
|
|
119
|
+
`limit_amount` real NOT NULL,
|
|
120
|
+
`period` text DEFAULT 'monthly' NOT NULL,
|
|
121
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
122
|
+
`user_id` text NOT NULL,
|
|
123
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
124
|
+
FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`) ON UPDATE no action ON DELETE no action,
|
|
125
|
+
FOREIGN KEY (`currency`) REFERENCES `currencies`(`code`) ON UPDATE no action ON DELETE no action
|
|
126
|
+
);
|
|
127
|
+
--> statement-breakpoint
|
|
128
|
+
INSERT INTO `__new_budgets` (`id`, `category_id`, `currency`, `limit_amount`, `period`, `version`, `user_id`) SELECT `id`, `category_id`, `currency`, `limit_amount`, `period`, `version`, (SELECT `id` FROM `users` WHERE `id` = 'user-owner') FROM `budgets`;
|
|
129
|
+
--> statement-breakpoint
|
|
130
|
+
DROP TABLE `budgets`;
|
|
131
|
+
--> statement-breakpoint
|
|
132
|
+
ALTER TABLE `__new_budgets` RENAME TO `budgets`;
|
|
133
|
+
--> statement-breakpoint
|
|
134
|
+
CREATE UNIQUE INDEX `budgets_user_category_currency_period` ON `budgets` (`user_id`,`category_id`,`currency`,`period`);
|
|
135
|
+
--> statement-breakpoint
|
|
136
|
+
CREATE TABLE `__new_recurring_rules` (
|
|
137
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
138
|
+
`description` text NOT NULL,
|
|
139
|
+
`amount` real NOT NULL,
|
|
140
|
+
`type` text NOT NULL,
|
|
141
|
+
`period` text NOT NULL,
|
|
142
|
+
`next_due` text NOT NULL,
|
|
143
|
+
`currency` text NOT NULL,
|
|
144
|
+
`account_id` text,
|
|
145
|
+
`category_id` text,
|
|
146
|
+
`merchant_key` text,
|
|
147
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
148
|
+
`user_id` text NOT NULL,
|
|
149
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
150
|
+
FOREIGN KEY (`currency`) REFERENCES `currencies`(`code`) ON UPDATE no action ON DELETE no action,
|
|
151
|
+
FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON UPDATE no action ON DELETE no action,
|
|
152
|
+
FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`) ON UPDATE no action ON DELETE no action,
|
|
153
|
+
FOREIGN KEY (`merchant_key`) REFERENCES `merchants`(`key`) ON UPDATE no action ON DELETE no action
|
|
154
|
+
);
|
|
155
|
+
--> statement-breakpoint
|
|
156
|
+
INSERT INTO `__new_recurring_rules` (`id`, `description`, `amount`, `type`, `period`, `next_due`, `currency`, `account_id`, `category_id`, `merchant_key`, `version`, `user_id`) SELECT `id`, `description`, `amount`, `type`, `period`, `next_due`, `currency`, `account_id`, `category_id`, `merchant_key`, `version`, (SELECT `id` FROM `users` WHERE `id` = 'user-owner') FROM `recurring_rules`;
|
|
157
|
+
--> statement-breakpoint
|
|
158
|
+
DROP TABLE `recurring_rules`;
|
|
159
|
+
--> statement-breakpoint
|
|
160
|
+
ALTER TABLE `__new_recurring_rules` RENAME TO `recurring_rules`;
|
|
161
|
+
--> statement-breakpoint
|
|
162
|
+
CREATE TABLE `__new_transactions` (
|
|
163
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
164
|
+
`description` text NOT NULL,
|
|
165
|
+
`amount` real NOT NULL,
|
|
166
|
+
`type` text NOT NULL,
|
|
167
|
+
`date` text NOT NULL,
|
|
168
|
+
`currency` text NOT NULL,
|
|
169
|
+
`source` text NOT NULL,
|
|
170
|
+
`idempotency_key` text NOT NULL,
|
|
171
|
+
`classification_method` text NOT NULL,
|
|
172
|
+
`confidence` real NOT NULL,
|
|
173
|
+
`raw_input` text,
|
|
174
|
+
`from_account_id` text,
|
|
175
|
+
`to_account_id` text,
|
|
176
|
+
`credit_card_id` text,
|
|
177
|
+
`category_id` text,
|
|
178
|
+
`subcategory_id` text,
|
|
179
|
+
`merchant_key` text,
|
|
180
|
+
`bill_id` text,
|
|
181
|
+
`status` text DEFAULT 'effective' NOT NULL,
|
|
182
|
+
`note` text,
|
|
183
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
184
|
+
`user_id` text NOT NULL,
|
|
185
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
186
|
+
FOREIGN KEY (`currency`) REFERENCES `currencies`(`code`) ON UPDATE no action ON DELETE no action,
|
|
187
|
+
FOREIGN KEY (`from_account_id`) REFERENCES `accounts`(`id`) ON UPDATE no action ON DELETE no action,
|
|
188
|
+
FOREIGN KEY (`to_account_id`) REFERENCES `accounts`(`id`) ON UPDATE no action ON DELETE no action,
|
|
189
|
+
FOREIGN KEY (`credit_card_id`) REFERENCES `credit_cards`(`id`) ON UPDATE no action ON DELETE no action,
|
|
190
|
+
FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`) ON UPDATE no action ON DELETE no action,
|
|
191
|
+
FOREIGN KEY (`subcategory_id`) REFERENCES `categories`(`id`) ON UPDATE no action ON DELETE no action,
|
|
192
|
+
FOREIGN KEY (`merchant_key`) REFERENCES `merchants`(`key`) ON UPDATE no action ON DELETE no action,
|
|
193
|
+
FOREIGN KEY (`bill_id`) REFERENCES `bills`(`id`) ON UPDATE no action ON DELETE no action,
|
|
194
|
+
CONSTRAINT "subcategory_requires_category" CHECK(`subcategory_id` IS NULL OR `category_id` IS NOT NULL)
|
|
195
|
+
);
|
|
196
|
+
--> statement-breakpoint
|
|
197
|
+
INSERT INTO `__new_transactions` (`rowid`, `id`, `description`, `amount`, `type`, `date`, `currency`, `source`, `idempotency_key`, `classification_method`, `confidence`, `raw_input`, `from_account_id`, `to_account_id`, `credit_card_id`, `category_id`, `subcategory_id`, `merchant_key`, `bill_id`, `status`, `note`, `version`, `user_id`) SELECT `rowid`, `id`, `description`, `amount`, `type`, `date`, `currency`, `source`, `idempotency_key`, `classification_method`, `confidence`, `raw_input`, `from_account_id`, `to_account_id`, `credit_card_id`, `category_id`, `subcategory_id`, `merchant_key`, `bill_id`, `status`, `note`, `version`, (SELECT `id` FROM `users` WHERE `id` = 'user-owner') FROM `transactions`;
|
|
198
|
+
--> statement-breakpoint
|
|
199
|
+
DROP TABLE `transactions`;
|
|
200
|
+
--> statement-breakpoint
|
|
201
|
+
ALTER TABLE `__new_transactions` RENAME TO `transactions`;
|
|
202
|
+
--> statement-breakpoint
|
|
203
|
+
-- rowid is preserved so the external-content FTS index stays valid; the sync triggers are recreated after the copy so no row is indexed twice.
|
|
204
|
+
CREATE UNIQUE INDEX `transactions_user_idempotency_key` ON `transactions` (`user_id`,`idempotency_key`);
|
|
205
|
+
--> statement-breakpoint
|
|
206
|
+
CREATE INDEX `idx_transactions_user_date` ON `transactions` (`user_id`,`date`);
|
|
207
|
+
--> statement-breakpoint
|
|
208
|
+
CREATE INDEX `idx_transactions_category` ON `transactions` (`category_id`);
|
|
209
|
+
--> statement-breakpoint
|
|
210
|
+
CREATE INDEX `idx_transactions_date` ON `transactions` (`date`);
|
|
211
|
+
--> statement-breakpoint
|
|
212
|
+
CREATE INDEX `idx_transactions_from_account` ON `transactions` (`from_account_id`);
|
|
213
|
+
--> statement-breakpoint
|
|
214
|
+
CREATE INDEX `idx_transactions_status_date` ON `transactions` (`status`,`date`);
|
|
215
|
+
--> statement-breakpoint
|
|
216
|
+
CREATE INDEX `idx_transactions_to_account` ON `transactions` (`to_account_id`);
|
|
217
|
+
--> statement-breakpoint
|
|
218
|
+
CREATE TRIGGER IF NOT EXISTS transactions_fts_insert
|
|
219
|
+
AFTER INSERT ON transactions BEGIN
|
|
220
|
+
INSERT INTO transactions_fts(rowid, description) VALUES (new.rowid, new.description);
|
|
221
|
+
END;
|
|
222
|
+
--> statement-breakpoint
|
|
223
|
+
CREATE TRIGGER IF NOT EXISTS transactions_fts_update
|
|
224
|
+
AFTER UPDATE OF description ON transactions BEGIN
|
|
225
|
+
INSERT INTO transactions_fts(transactions_fts, rowid, description)
|
|
226
|
+
VALUES ('delete', old.rowid, old.description);
|
|
227
|
+
INSERT INTO transactions_fts(rowid, description) VALUES (new.rowid, new.description);
|
|
228
|
+
END;
|
|
229
|
+
--> statement-breakpoint
|
|
230
|
+
CREATE TRIGGER IF NOT EXISTS transactions_fts_delete
|
|
231
|
+
AFTER DELETE ON transactions BEGIN
|
|
232
|
+
INSERT INTO transactions_fts(transactions_fts, rowid, description)
|
|
233
|
+
VALUES ('delete', old.rowid, old.description);
|
|
234
|
+
END;
|
|
235
|
+
--> statement-breakpoint
|
|
236
|
+
-- the 15 seeded defaults stay shared; every other category is the owner's.
|
|
237
|
+
ALTER TABLE `categories` ADD COLUMN `user_id` text REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict;
|
|
238
|
+
--> statement-breakpoint
|
|
239
|
+
UPDATE `categories` SET `user_id` = (SELECT `id` FROM `users` WHERE `id` = 'user-owner') WHERE `id` NOT IN ('cat-food', 'cat-transport', 'cat-housing', 'cat-utilities', 'cat-health', 'cat-education', 'cat-leisure', 'cat-shopping', 'cat-subscriptions', 'cat-travel', 'cat-taxes', 'cat-salary', 'cat-extra-income', 'cat-investments', 'cat-other');
|
|
240
|
+
--> statement-breakpoint
|
|
241
|
+
-- `rule` edges stay shared, `history` edges are the owner's; the primary key becomes two partial unique indexes (NULLs are distinct in UNIQUE).
|
|
242
|
+
CREATE TABLE `__new_merchant_category` (
|
|
243
|
+
`merchant_key` text NOT NULL,
|
|
244
|
+
`category_id` text NOT NULL,
|
|
245
|
+
`weight` real DEFAULT 1 NOT NULL,
|
|
246
|
+
`origin` text NOT NULL,
|
|
247
|
+
`last_seen` integer,
|
|
248
|
+
`user_id` text,
|
|
249
|
+
FOREIGN KEY (`merchant_key`) REFERENCES `merchants`(`key`) ON UPDATE no action ON DELETE no action,
|
|
250
|
+
FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
251
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
252
|
+
CONSTRAINT "merchant_category_origin_owner" CHECK((`origin` = 'rule' AND `user_id` IS NULL) OR (`origin` = 'history' AND `user_id` IS NOT NULL))
|
|
253
|
+
);
|
|
254
|
+
--> statement-breakpoint
|
|
255
|
+
INSERT INTO `__new_merchant_category` (`merchant_key`, `category_id`, `weight`, `origin`, `last_seen`, `user_id`)
|
|
256
|
+
SELECT `merchant_key`, `category_id`, `weight`, `origin`, `last_seen`, CASE WHEN `origin` = 'history' THEN (SELECT `id` FROM `users` WHERE `id` = 'user-owner') END FROM `merchant_category`;
|
|
257
|
+
--> statement-breakpoint
|
|
258
|
+
DROP TABLE `merchant_category`;
|
|
259
|
+
--> statement-breakpoint
|
|
260
|
+
ALTER TABLE `__new_merchant_category` RENAME TO `merchant_category`;
|
|
261
|
+
--> statement-breakpoint
|
|
262
|
+
CREATE UNIQUE INDEX `merchant_category_shared_key` ON `merchant_category` (`merchant_key`,`category_id`) WHERE `user_id` IS NULL;
|
|
263
|
+
--> statement-breakpoint
|
|
264
|
+
CREATE UNIQUE INDEX `merchant_category_user_key` ON `merchant_category` (`user_id`,`merchant_key`,`category_id`) WHERE `user_id` IS NOT NULL;
|
|
265
|
+
--> statement-breakpoint
|
|
266
|
+
CREATE TABLE `__new_dashboards` (
|
|
267
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
268
|
+
`name` text NOT NULL,
|
|
269
|
+
`html` text,
|
|
270
|
+
`source` text DEFAULT 'inline' NOT NULL,
|
|
271
|
+
`path` text,
|
|
272
|
+
`updated_at` text NOT NULL,
|
|
273
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
274
|
+
`user_id` text,
|
|
275
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
276
|
+
CONSTRAINT "dashboard_source_owner" CHECK((`source` = 'file' AND `user_id` IS NULL) OR (`source` = 'inline' AND `user_id` IS NOT NULL)),
|
|
277
|
+
CONSTRAINT "dashboard_source_content" CHECK((`source` = 'inline' AND `html` IS NOT NULL AND `path` IS NULL) OR (`source` = 'file' AND `html` IS NULL AND `path` IS NOT NULL))
|
|
278
|
+
);
|
|
279
|
+
--> statement-breakpoint
|
|
280
|
+
INSERT INTO `__new_dashboards` (`id`, `name`, `html`, `source`, `path`, `updated_at`, `version`, `user_id`)
|
|
281
|
+
SELECT `id`, `name`, `html`, `source`, `path`, `updated_at`, `version`, CASE WHEN `source` = 'inline' THEN (SELECT `id` FROM `users` WHERE `id` = 'user-owner') END FROM `dashboards`;
|
|
282
|
+
--> statement-breakpoint
|
|
283
|
+
DROP TABLE `dashboards`;
|
|
284
|
+
--> statement-breakpoint
|
|
285
|
+
ALTER TABLE `__new_dashboards` RENAME TO `dashboards`;
|
|
286
|
+
--> statement-breakpoint
|
|
287
|
+
CREATE UNIQUE INDEX `dashboards_shared_name` ON `dashboards` (`name`) WHERE `user_id` IS NULL;
|
|
288
|
+
--> statement-breakpoint
|
|
289
|
+
CREATE UNIQUE INDEX `dashboards_user_name` ON `dashboards` (`user_id`,`name`) WHERE `user_id` IS NOT NULL;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CREATE TABLE `invites` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`user_id` text NOT NULL,
|
|
4
|
+
`code_hash` text NOT NULL,
|
|
5
|
+
`created_by` text,
|
|
6
|
+
`created_at` text NOT NULL,
|
|
7
|
+
`expires_at` text NOT NULL,
|
|
8
|
+
`used_at` text,
|
|
9
|
+
`version` integer DEFAULT 0 NOT NULL,
|
|
10
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
11
|
+
FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE restrict
|
|
12
|
+
);
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
CREATE UNIQUE INDEX `invites_code_hash_unique` ON `invites` (`code_hash`);--> statement-breakpoint
|
|
15
|
+
CREATE UNIQUE INDEX `invites_one_open_per_user` ON `invites` (`user_id`) WHERE "invites"."used_at" IS NULL;--> statement-breakpoint
|
|
16
|
+
ALTER TABLE `settings` ADD `max_sign_in_duration` text DEFAULT '30d' NOT NULL;--> statement-breakpoint
|
|
17
|
+
ALTER TABLE `users` ADD `last_login_at` text;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
-- When this user's set of ways in (sessions, tokens, sign-in requests, invites) last changed. Issuing or ending a credential writes it, so a revocation that read the credentials earlier conflicts with the issuance and re-reads them.
|
|
2
|
+
ALTER TABLE `users` ADD `credentials_changed_at` text;
|