@rfc0/patty 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +493 -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 +1716 -0
- package/ui/dashboards/cards.html +4032 -0
- package/ui/dashboards/categories.html +4694 -0
- package/ui/dashboards/comparative.html +2464 -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 +2517 -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,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SignInDuration } from '../../models/auth/grant.js';
|
|
3
|
+
import { CONNECT_CODE_PARAM, CONNECT_PASSWORD_PARAM, DEFAULT_LANDING_PATH, INVITE_CODE_PARAM, isUiPath, } from '../../models/auth/origin.js';
|
|
4
|
+
import { UserRole } from '../../models/auth/owner.js';
|
|
5
|
+
import { SignInCap } from '../../models/auth/users.js';
|
|
6
|
+
import { PASSWORD_MAX_LENGTH, PasswordSchema, UsernameSchema, normalizeUsername } from '../../models/auth/password.js';
|
|
7
|
+
import { CLIENT_NAME_MAX_LENGTH, CLIENT_VERSION_MAX_LENGTH, UNKNOWN_CLIENT_NAME, UNKNOWN_CLIENT_VERSION, } from '../../models/auth/sign-in.js';
|
|
8
|
+
import { TOKEN_NAME_MAX_LENGTH, TokenAccess, TokenExpiry } from '../../models/auth/token.js';
|
|
9
|
+
// Login accepts whatever was typed (an unknown name must fail like a wrong password, not like bad
|
|
10
|
+
// input); only the length is bounded so a body cannot be used to make argon2 chew on megabytes.
|
|
11
|
+
const LOGIN_FIELD_MAX_LENGTH = 256;
|
|
12
|
+
const SETUP_CODE_MAX_LENGTH = 64;
|
|
13
|
+
const MAX_NEXT_LENGTH = 2048;
|
|
14
|
+
const SAME_ORIGIN_PROBE = 'http://same-origin.invalid';
|
|
15
|
+
const UNSAFE_NEXT_CHARACTERS = /[\\\u0000-\u001f\u007f]/;
|
|
16
|
+
/**
|
|
17
|
+
* Where to send the browser after login/setup: a same-origin path under `/ui`, or the default. Anything
|
|
18
|
+
* else — absolute URLs, protocol-relative `//host`, backslash tricks, control characters, paths that
|
|
19
|
+
* normalize out of `/ui` — falls back, so `next` can never become an open redirect. A tolerant reader:
|
|
20
|
+
* a bad `next` is not an error, it is simply not honored.
|
|
21
|
+
*/
|
|
22
|
+
export const safeNextPath = (raw) => {
|
|
23
|
+
if (raw === undefined || raw.length === 0 || raw.length > MAX_NEXT_LENGTH)
|
|
24
|
+
return DEFAULT_LANDING_PATH;
|
|
25
|
+
if (!raw.startsWith('/') || raw.startsWith('//') || UNSAFE_NEXT_CHARACTERS.test(raw))
|
|
26
|
+
return DEFAULT_LANDING_PATH;
|
|
27
|
+
const resolved = new URL(raw, SAME_ORIGIN_PROBE);
|
|
28
|
+
return resolved.origin === SAME_ORIGIN_PROBE && isUiPath(resolved.pathname)
|
|
29
|
+
? `${resolved.pathname}${resolved.search}`
|
|
30
|
+
: DEFAULT_LANDING_PATH;
|
|
31
|
+
};
|
|
32
|
+
const NextPathSchema = z.string().optional().catch(undefined).transform(safeNextPath);
|
|
33
|
+
export const LoginFormSchema = z.object({
|
|
34
|
+
username: z.string().min(1).max(LOGIN_FIELD_MAX_LENGTH).transform(normalizeUsername),
|
|
35
|
+
password: z.string().min(1).max(PASSWORD_MAX_LENGTH),
|
|
36
|
+
next: NextPathSchema,
|
|
37
|
+
});
|
|
38
|
+
export const SetupFormSchema = z.object({
|
|
39
|
+
code: z.string().min(1).max(SETUP_CODE_MAX_LENGTH),
|
|
40
|
+
username: UsernameSchema,
|
|
41
|
+
password: PasswordSchema,
|
|
42
|
+
});
|
|
43
|
+
/** The query string of /ui/login and /ui/setup — where to go afterwards. */
|
|
44
|
+
export const NextQuerySchema = z.object({ next: NextPathSchema });
|
|
45
|
+
/** `POST /ui/access/tokens`: what the token form submits. */
|
|
46
|
+
export const CreateTokenFormSchema = z.object({
|
|
47
|
+
name: z.string().trim().min(1, 'Give the token a name.').max(TOKEN_NAME_MAX_LENGTH),
|
|
48
|
+
access: TokenAccess,
|
|
49
|
+
expiry: TokenExpiry,
|
|
50
|
+
password: z.string().min(1, 'Enter your password to create a token.').max(PASSWORD_MAX_LENGTH),
|
|
51
|
+
});
|
|
52
|
+
// The code a person types or follows: lookups normalize it, so only its length is bounded here.
|
|
53
|
+
const USER_CODE_INPUT_MAX_LENGTH = 32;
|
|
54
|
+
/** `GET /ui/connect?code=…`. */
|
|
55
|
+
export const ConnectQuerySchema = z.object({
|
|
56
|
+
[CONNECT_CODE_PARAM]: z.string().min(1).max(USER_CODE_INPUT_MAX_LENGTH).optional().catch(undefined),
|
|
57
|
+
});
|
|
58
|
+
export const ConnectDecision = z.enum(['approve', 'deny']);
|
|
59
|
+
/** `POST /ui/connect`: the consent form. */
|
|
60
|
+
export const ConnectFormSchema = z.object({
|
|
61
|
+
[CONNECT_CODE_PARAM]: z.string().min(1).max(USER_CODE_INPUT_MAX_LENGTH),
|
|
62
|
+
decision: ConnectDecision,
|
|
63
|
+
access: TokenAccess,
|
|
64
|
+
duration: SignInDuration,
|
|
65
|
+
// Only an approval needs it; the controller refuses an absent one like a wrong one.
|
|
66
|
+
[CONNECT_PASSWORD_PARAM]: z.string().max(PASSWORD_MAX_LENGTH).optional(),
|
|
67
|
+
});
|
|
68
|
+
// `clientInfo` comes from whatever program spawned us and is shown to the approver, so it is cleaned, not trusted:
|
|
69
|
+
// control characters become spaces, the length is bounded, and an unusable value falls back rather than failing
|
|
70
|
+
// the sign-in. (It is escaped wherever it is rendered.)
|
|
71
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f]/g;
|
|
72
|
+
const reported = (maxLength, fallback) => z
|
|
73
|
+
.string()
|
|
74
|
+
.optional()
|
|
75
|
+
.catch(undefined)
|
|
76
|
+
.transform((raw) => raw?.replace(CONTROL_CHARACTERS, ' ').trim().slice(0, maxLength) || fallback);
|
|
77
|
+
const ClientInfoSchema = z.object({
|
|
78
|
+
name: reported(CLIENT_NAME_MAX_LENGTH, UNKNOWN_CLIENT_NAME),
|
|
79
|
+
version: reported(CLIENT_VERSION_MAX_LENGTH, UNKNOWN_CLIENT_VERSION),
|
|
80
|
+
});
|
|
81
|
+
export const clientInfoOf = (raw) => ClientInfoSchema.catch({
|
|
82
|
+
name: UNKNOWN_CLIENT_NAME,
|
|
83
|
+
version: UNKNOWN_CLIENT_VERSION,
|
|
84
|
+
}).parse(raw ?? {});
|
|
85
|
+
const STEP_UP_PASSWORD = z.string().min(1, 'Enter your password to confirm.').max(PASSWORD_MAX_LENGTH);
|
|
86
|
+
/** `POST /ui/access/users`: invite a new user. */
|
|
87
|
+
export const InviteUserFormSchema = z.object({ username: UsernameSchema, role: UserRole, password: STEP_UP_PASSWORD });
|
|
88
|
+
/** The actions that only re-ask the admin's password: reissue, disable. */
|
|
89
|
+
export const StepUpFormSchema = z.object({ password: STEP_UP_PASSWORD });
|
|
90
|
+
export const SetRoleFormSchema = z.object({ role: UserRole, password: STEP_UP_PASSWORD });
|
|
91
|
+
export const SignInCapFormSchema = z.object({ maxSignInDuration: SignInCap, password: STEP_UP_PASSWORD });
|
|
92
|
+
/** `:id` of a user action. */
|
|
93
|
+
export const UserParamsSchema = z.object({ id: z.string().min(1).max(LOGIN_FIELD_MAX_LENGTH) });
|
|
94
|
+
const INVITE_CODE_INPUT_MAX_LENGTH = 64;
|
|
95
|
+
/** `GET /ui/access/invite?code=…` — the code may also be typed. A bad value is simply not prefilled. */
|
|
96
|
+
export const InviteQuerySchema = z.object({
|
|
97
|
+
[INVITE_CODE_PARAM]: z.string().max(INVITE_CODE_INPUT_MAX_LENGTH).optional().catch(undefined),
|
|
98
|
+
});
|
|
99
|
+
/** What the claim page shows back in its code field after a refusal: whatever was typed, if it was text. */
|
|
100
|
+
export const ClaimedCodeEchoSchema = z
|
|
101
|
+
.object({ code: z.string().max(INVITE_CODE_INPUT_MAX_LENGTH).catch('') })
|
|
102
|
+
.catch({ code: '' });
|
|
103
|
+
/** `POST /ui/access/invite`: the invited person's code and chosen password. */
|
|
104
|
+
export const ClaimInviteFormSchema = z.object({
|
|
105
|
+
code: z.string().min(1, 'Enter your invite code.').max(INVITE_CODE_INPUT_MAX_LENGTH),
|
|
106
|
+
password: PasswordSchema,
|
|
107
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BillQuerySchema, PayBillSchema } from '../../models/bill.js';
|
|
3
|
+
import { coerceToNumber } from './coerce.js';
|
|
4
|
+
export const BillQuery = BillQuerySchema.extend({
|
|
5
|
+
month: z.preprocess(coerceToNumber, BillQuerySchema.shape.month),
|
|
6
|
+
year: z.preprocess(coerceToNumber, BillQuerySchema.shape.year),
|
|
7
|
+
});
|
|
8
|
+
export const PayBill = BillQuery.extend({
|
|
9
|
+
account: PayBillSchema.shape.account,
|
|
10
|
+
paymentDate: PayBillSchema.shape.paymentDate,
|
|
11
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as modelBudget from '../../models/budget.js';
|
|
2
|
+
import { CurrencyCode } from '../../models/money.js';
|
|
3
|
+
import { CoercedPeriodSchema } from './period.js';
|
|
4
|
+
// The boundary owns the quality-of-life default; the domain keeps `period` required (not-null).
|
|
5
|
+
export const CreateBudgetSchema = modelBudget.CreateBudgetSchema.extend({
|
|
6
|
+
period: modelBudget.CreateBudgetSchema.shape.period.default(modelBudget.BudgetPeriod.enum.monthly),
|
|
7
|
+
});
|
|
8
|
+
export const UpdateBudgetSchema = modelBudget.UpdateBudgetSchema;
|
|
9
|
+
export const BudgetStatusQuerySchema = CoercedPeriodSchema.extend({
|
|
10
|
+
displayCurrency: CurrencyCode.optional().describe('Opt-in: also return a converted grand total of committed spend in this currency'),
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as modelCategory from '../../models/category.js';
|
|
3
|
+
// The boundary owns quality-of-life defaults; the domain keeps these fields required (not-null).
|
|
4
|
+
// Default kind is the most common category usage.
|
|
5
|
+
export const CreateCategorySchema = modelCategory.CreateCategorySchema.extend({
|
|
6
|
+
kind: modelCategory.CreateCategorySchema.shape.kind.default(modelCategory.CategoryKind.enum.expense),
|
|
7
|
+
});
|
|
8
|
+
export const CreateSubCategorySchema = modelCategory.CreateSubCategorySchema.omit({ id: true });
|
|
9
|
+
export const SubCategoriesQuerySchema = z.object({ parentId: z.string().optional() });
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LoginDuration } from '../../models/auth/grant.js';
|
|
3
|
+
import { UserRole } from '../../models/auth/owner.js';
|
|
4
|
+
import { UsernameSchema, normalizeUsername } from '../../models/auth/password.js';
|
|
5
|
+
import { DEFAULT_PROFILE, ProfileSchema } from '../../models/auth/sign-in.js';
|
|
6
|
+
import { TokenAccess } from '../../models/auth/token.js';
|
|
7
|
+
import { DemoCountry } from '../../models/demo/core.js';
|
|
8
|
+
/** The CLI's argv grammar: the commands, their subcommands, their flags and how many positionals each takes. */
|
|
9
|
+
export const PASSWORD_STDIN_FLAG = 'password-stdin';
|
|
10
|
+
/** How many positional arguments each command takes: `setup` names one client, the `auth` subcommands none. */
|
|
11
|
+
export const SETUP_POSITIONALS = 1;
|
|
12
|
+
export const AUTH_POSITIONALS = 0;
|
|
13
|
+
/** `login` and `logout` take flags only. */
|
|
14
|
+
export const SIGN_IN_POSITIONALS = 0;
|
|
15
|
+
export const CliCommand = z.enum(['setup', 'auth', 'login', 'logout', 'users', 'key', 'db', 'demo']);
|
|
16
|
+
export const AuthSubcommand = z.enum(['setup', 'reset-password']);
|
|
17
|
+
const OPTION_MAX_LENGTH = 256;
|
|
18
|
+
const PATH_MAX_LENGTH = 4096;
|
|
19
|
+
export const ClaimOptionsSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
[PASSWORD_STDIN_FLAG]: z.boolean().default(false),
|
|
22
|
+
username: UsernameSchema.optional(),
|
|
23
|
+
})
|
|
24
|
+
.transform((flags) => ({ passwordStdin: flags[PASSWORD_STDIN_FLAG], username: flags.username }));
|
|
25
|
+
/** `--user` is only normalized: an unknown name is a clear "no such user", not a validation failure. */
|
|
26
|
+
export const ResetOptionsSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
[PASSWORD_STDIN_FLAG]: z.boolean().default(false),
|
|
29
|
+
user: z.string().transform(normalizeUsername).pipe(z.string().min(1).max(OPTION_MAX_LENGTH)).optional(),
|
|
30
|
+
})
|
|
31
|
+
.transform((flags) => ({ passwordStdin: flags[PASSWORD_STDIN_FLAG], user: flags.user }));
|
|
32
|
+
export const DEMO_FLAG = 'demo';
|
|
33
|
+
export const REMOVE_DEMO_FLAG = 'remove-demo';
|
|
34
|
+
export const DemoEntryChange = z.enum(['add', 'remove']);
|
|
35
|
+
const DEMO_EXCLUSIVE_MESSAGE = `--${DEMO_FLAG} and --${REMOVE_DEMO_FLAG} only edit the client's demo entry: use them alone`;
|
|
36
|
+
export const SetupOptionsSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
[PASSWORD_STDIN_FLAG]: z.boolean().default(false),
|
|
39
|
+
username: UsernameSchema.optional(),
|
|
40
|
+
profile: ProfileSchema.optional(),
|
|
41
|
+
[DEMO_FLAG]: z.boolean().default(false),
|
|
42
|
+
[REMOVE_DEMO_FLAG]: z.boolean().default(false),
|
|
43
|
+
})
|
|
44
|
+
.refine((flags) => !(flags[DEMO_FLAG] || flags[REMOVE_DEMO_FLAG]) ||
|
|
45
|
+
(flags[DEMO_FLAG] !== flags[REMOVE_DEMO_FLAG] &&
|
|
46
|
+
!flags[PASSWORD_STDIN_FLAG] &&
|
|
47
|
+
flags.username === undefined &&
|
|
48
|
+
flags.profile === undefined), { message: DEMO_EXCLUSIVE_MESSAGE })
|
|
49
|
+
.transform((flags) => ({
|
|
50
|
+
passwordStdin: flags[PASSWORD_STDIN_FLAG],
|
|
51
|
+
username: flags.username,
|
|
52
|
+
profile: flags.profile ?? DEFAULT_PROFILE,
|
|
53
|
+
demo: flags[DEMO_FLAG],
|
|
54
|
+
removeDemo: flags[REMOVE_DEMO_FLAG],
|
|
55
|
+
}));
|
|
56
|
+
export const DEMO_POSITIONALS = 0;
|
|
57
|
+
export const DemoOptionsSchema = z.object({
|
|
58
|
+
country: z
|
|
59
|
+
.string()
|
|
60
|
+
.refine((value) => DemoCountry.safeParse(value).success, {
|
|
61
|
+
message: `--country must be one of: ${DemoCountry.options.join(', ')}`,
|
|
62
|
+
})
|
|
63
|
+
.pipe(DemoCountry)
|
|
64
|
+
.optional(),
|
|
65
|
+
reset: z.boolean().default(false),
|
|
66
|
+
});
|
|
67
|
+
/** `login`: `profile` falls back to `PATTY_PROFILE` (the shell decides); `duration`/`scope` only pre-select the
|
|
68
|
+
* consent page — the person approving still chooses. */
|
|
69
|
+
export const LoginOptionsSchema = z.object({
|
|
70
|
+
profile: ProfileSchema.optional(),
|
|
71
|
+
duration: LoginDuration.optional(),
|
|
72
|
+
scope: TokenAccess.optional(),
|
|
73
|
+
});
|
|
74
|
+
export const LogoutOptionsSchema = z.object({ profile: ProfileSchema.optional() });
|
|
75
|
+
export const UsersSubcommand = z.enum(['list', 'invite', 'reissue', 'disable', 'enable', 'role']);
|
|
76
|
+
/** How many positionals each `users` subcommand takes: none, one username, or a username and a role. */
|
|
77
|
+
export const USERS_POSITIONALS = {
|
|
78
|
+
list: 0,
|
|
79
|
+
invite: 1,
|
|
80
|
+
reissue: 1,
|
|
81
|
+
disable: 1,
|
|
82
|
+
enable: 1,
|
|
83
|
+
role: 2,
|
|
84
|
+
};
|
|
85
|
+
/** `users invite <username> [--admin]`: members unless `--admin`. */
|
|
86
|
+
export const InviteOptionsSchema = z
|
|
87
|
+
.object({ admin: z.boolean().default(false) })
|
|
88
|
+
.transform((flags) => ({ role: flags.admin ? UserRole.enum.admin : UserRole.enum.member }));
|
|
89
|
+
/** A username named on the command line is only normalized: an unknown one is a clear "no such user". */
|
|
90
|
+
export const TargetUsernameSchema = z
|
|
91
|
+
.string()
|
|
92
|
+
.transform(normalizeUsername)
|
|
93
|
+
.pipe(z.string().min(1).max(OPTION_MAX_LENGTH));
|
|
94
|
+
export const KeySubcommand = z.enum(['export', 'import']);
|
|
95
|
+
export const DbSubcommand = z.enum(['export', 'import']);
|
|
96
|
+
export const EXPORT_POSITIONALS = 0;
|
|
97
|
+
export const IMPORT_POSITIONALS = 0;
|
|
98
|
+
const pathOption = (flag) => z
|
|
99
|
+
.string({ required_error: `the file is required: --${flag} <file>` })
|
|
100
|
+
.min(1)
|
|
101
|
+
.max(PATH_MAX_LENGTH);
|
|
102
|
+
export const ExportOptionsSchema = z.object({ to: pathOption('to') });
|
|
103
|
+
export const ImportOptionsSchema = z.object({ from: pathOption('from') });
|
|
104
|
+
/** The flags both export subcommands take, in `parseArgs` form. */
|
|
105
|
+
export const EXPORT_FLAGS = { to: { type: 'string' } };
|
|
106
|
+
export const IMPORT_FLAGS = { from: { type: 'string' } };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const coerceToNumber = (v) => (typeof v === 'string' ? Number(v) : v);
|
|
3
|
+
// Bare regex (no custom message) — matches the inline checks previously duplicated across
|
|
4
|
+
// diplomat/http/routes.ts query/body validators, now a single named schema both the runtime
|
|
5
|
+
// validation and the route's OpenAPI documentation (routes.ts) derive from.
|
|
6
|
+
export const IsoDateQuerySchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Generic path-param / query shapes shared across many routes' `req.params`/`req.query` reads
|
|
3
|
+
// (diplomat/http/routes.ts) — not owned by any single domain, so they don't belong in one
|
|
4
|
+
// domain's wire/in file. routes.ts casts these directly rather than parsing them today
|
|
5
|
+
// (tracked as tech debt: github.com/RafaelFCarneiro/patty/issues/76), so these schemas
|
|
6
|
+
// back the OpenAPI documentation only, not runtime validation.
|
|
7
|
+
export const NameParamSchema = z.object({ name: z.string().min(1) });
|
|
8
|
+
export const IdParamSchema = z.object({ id: z.string().min(1) });
|
|
9
|
+
// A query string never carries a real boolean — every boolean query flag parses as this literal
|
|
10
|
+
// "true"/"false" pair; how it becomes a real boolean differs per consumer. includeTotal
|
|
11
|
+
// (SearchTransactionsQuerySchema) converts via a `.transform()` on the schema itself; confirm
|
|
12
|
+
// below is converted ad hoc in the route handler (`req.query.confirm === 'true'`), the same
|
|
13
|
+
// direct-cast pattern NameParamSchema/IdParamSchema's comment above notes as tech debt (issue #76).
|
|
14
|
+
export const BooleanQuerySchema = z.enum(['true', 'false']);
|
|
15
|
+
export const ConfirmQuerySchema = z.object({
|
|
16
|
+
confirm: BooleanQuerySchema.optional().describe('Pass "true" to actually perform the action (dry-run otherwise)'),
|
|
17
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CurrencyCode } from '../../models/money.js';
|
|
2
|
+
import * as modelCreditCard from '../../models/credit-card.js';
|
|
3
|
+
// The boundary owns quality-of-life defaults; the domain keeps these fields required (not-null).
|
|
4
|
+
// Default currency follows the default language (en → USD).
|
|
5
|
+
export const CreateCreditCardSchema = modelCreditCard.CreateCreditCardSchema.extend({
|
|
6
|
+
currency: modelCreditCard.CreateCreditCardSchema.shape.currency.default(CurrencyCode.enum.USD),
|
|
7
|
+
});
|
|
8
|
+
// Pass-through — no boundary-only defaults needed.
|
|
9
|
+
export const UpdateCreditCardSchema = modelCreditCard.UpdateCreditCardSchema;
|
|
10
|
+
// Pass-through — no boundary-only defaults needed; every field required by the domain schema is
|
|
11
|
+
// already required here.
|
|
12
|
+
export const AddCardPurchaseSchema = modelCreditCard.AddCardPurchaseSchema;
|
|
13
|
+
// Pass-through — no boundary-only defaults needed.
|
|
14
|
+
export const UpdateCardTransactionSchema = modelCreditCard.UpdateCardTransactionSchema;
|
|
15
|
+
// Pass-through — no boundary-only defaults needed.
|
|
16
|
+
export const ImportCardStatementSchema = modelCreditCard.ImportCardStatementSchema;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SetExchangeRateSchema } from '../../models/currency-rate.js';
|
|
3
|
+
// Caps a single bulk call — an agent refreshing rates after a web pull touches a handful of
|
|
4
|
+
// pairs, never hundreds; keeps one call bounded rather than an unbounded array.
|
|
5
|
+
const MAX_BULK_EXCHANGE_RATES = 50;
|
|
6
|
+
export const SetExchangeRatesSchema = z.object({
|
|
7
|
+
rates: z.array(SetExchangeRateSchema).min(1).max(MAX_BULK_EXCHANGE_RATES),
|
|
8
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PeriodSchema } from '../../models/date.js';
|
|
3
|
+
import { coerceToNumber } from './coerce.js';
|
|
4
|
+
export const CoercedPeriodSchema = PeriodSchema.extend({
|
|
5
|
+
month: z.preprocess(coerceToNumber, PeriodSchema.shape.month),
|
|
6
|
+
year: z.preprocess(coerceToNumber, PeriodSchema.shape.year),
|
|
7
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as modelRecurring from '../../models/recurring.js';
|
|
3
|
+
import { IsoDateQuerySchema } from './coerce.js';
|
|
4
|
+
// No QoL defaults needed for recurring — currency is resolved by resolveCurrency in the controller.
|
|
5
|
+
export const CreateRecurringSchema = modelRecurring.CreateRecurringSchema;
|
|
6
|
+
export const ApplyDueBodySchema = z.object({ through: IsoDateQuerySchema.optional() });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CurrencyCode } from '../../models/money.js';
|
|
2
|
+
import { CoercedPeriodSchema } from './period.js';
|
|
3
|
+
export const SummaryQuerySchema = CoercedPeriodSchema.extend({
|
|
4
|
+
displayCurrency: CurrencyCode.optional().describe('Opt-in: also return a converted grand total of expenses in this currency'),
|
|
5
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { INCLUDE_TOTAL_DESCRIPTION, SortDirection } from '../../models/page.js';
|
|
3
|
+
import * as modelTransaction from '../../models/transaction.js';
|
|
4
|
+
import { SearchTransactionsSchema, TransactionSortField } from '../../models/transaction.js';
|
|
5
|
+
import { BooleanQuerySchema } from './common.js';
|
|
6
|
+
import { coerceToNumber } from './coerce.js';
|
|
7
|
+
// Wire input schemas — derived from model schemas.
|
|
8
|
+
// Boundary-only behavior (limit default) stays here; everything else is pass-through.
|
|
9
|
+
// Pass-through — no boundary-only defaults needed.
|
|
10
|
+
export const ConfirmTransactionSchema = modelTransaction.ConfirmTransactionSchema;
|
|
11
|
+
// Pre-transform query shape — a plain ZodObject, so it can also serve as the route's
|
|
12
|
+
// OpenAPI query schema (routes.ts), which needs a ZodObject rather than the ZodEffects
|
|
13
|
+
// that .transform() produces below. QoL defaults (limit → 50, sort → date, dir → desc) are
|
|
14
|
+
// applied by the transform below, per the defaults-by-intent rule (domain stays honest about
|
|
15
|
+
// what's genuinely required). `includeTotal` arrives as a query string, not a real boolean.
|
|
16
|
+
export const SearchTransactionsQuerySchema = SearchTransactionsSchema.extend({
|
|
17
|
+
// A query string never carries a real number — coerce, like CoercedPeriodSchema (wire/in/period.js).
|
|
18
|
+
month: z.preprocess(coerceToNumber, SearchTransactionsSchema.shape.month),
|
|
19
|
+
year: z.preprocess(coerceToNumber, SearchTransactionsSchema.shape.year),
|
|
20
|
+
limit: z.preprocess(coerceToNumber, SearchTransactionsSchema.shape.limit).optional(),
|
|
21
|
+
sort: SearchTransactionsSchema.shape.sort.optional(),
|
|
22
|
+
dir: SearchTransactionsSchema.shape.dir.optional(),
|
|
23
|
+
includeTotal: BooleanQuerySchema.optional().describe(INCLUDE_TOTAL_DESCRIPTION),
|
|
24
|
+
});
|
|
25
|
+
export const SearchTransactionsInputSchema = SearchTransactionsQuerySchema.transform((input) => ({
|
|
26
|
+
...input,
|
|
27
|
+
limit: input.limit ?? 50,
|
|
28
|
+
sort: input.sort ?? TransactionSortField.enum.date,
|
|
29
|
+
dir: input.dir ?? SortDirection.enum.desc,
|
|
30
|
+
includeTotal: input.includeTotal === 'true',
|
|
31
|
+
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BillSchema } from '../../models/bill.js';
|
|
3
|
+
import { RawTransactionViewSchema } from '../../models/transaction.js';
|
|
4
|
+
export const BillViewOut = z.object({
|
|
5
|
+
bill: BillSchema,
|
|
6
|
+
cardName: z.string(),
|
|
7
|
+
transactions: z.array(RawTransactionViewSchema),
|
|
8
|
+
total: z.number(),
|
|
9
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PeriodSchema } from '../../models/date.js';
|
|
3
|
+
import { BudgetStatusGroupSchema } from '../../models/budget.js';
|
|
4
|
+
import { ConvertedTotalSchema } from '../../models/currency-rate.js';
|
|
5
|
+
export const BudgetStatusOutSchema = z.object({
|
|
6
|
+
period: PeriodSchema,
|
|
7
|
+
categories: z.array(BudgetStatusGroupSchema),
|
|
8
|
+
converted: ConvertedTotalSchema.optional().describe('Opt-in converted grand total of committed (effective + pending) spend across budgeted categories, ' +
|
|
9
|
+
'in every currency — present only when displayCurrency was supplied'),
|
|
10
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Shared across several domains' delete responses (accounts, categories, sub-categories, tags) —
|
|
3
|
+
// not owned by any single entity, so it doesn't belong in one domain's wire/out file.
|
|
4
|
+
export const DeletedOut = z.object({ deleted: z.boolean() });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const DeleteCreditCardResultOut = z.union([
|
|
3
|
+
z.object({ deleted: z.literal(true), card: z.string() }),
|
|
4
|
+
z.object({
|
|
5
|
+
deleted: z.literal(false),
|
|
6
|
+
dryRun: z.literal(true),
|
|
7
|
+
wouldDelete: z.object({
|
|
8
|
+
card: z.string(),
|
|
9
|
+
account: z.string(),
|
|
10
|
+
transactions: z.number().int(),
|
|
11
|
+
bills: z.number().int(),
|
|
12
|
+
}),
|
|
13
|
+
hint: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CurrencyCode } from '../../models/money.js';
|
|
3
|
+
import { CurrencyRateViewSchema } from '../../models/currency-rate.js';
|
|
4
|
+
/** Bulk `set_exchange_rates` per-item outcome — mirrors `wire/out/transactions.ts`'s `BulkItemOut`
|
|
5
|
+
* shape: one discriminated union, `error` collapsed from `AppError` to a plain string via
|
|
6
|
+
* `formatAppError` (adapters/currency-rates.ts), safe for external consumers. */
|
|
7
|
+
const BulkExchangeRateItemOut = z.discriminatedUnion('status', [
|
|
8
|
+
z.object({ status: z.literal('ok'), rate: CurrencyRateViewSchema }),
|
|
9
|
+
z.object({ status: z.literal('error'), from: CurrencyCode, to: CurrencyCode, error: z.string() }),
|
|
10
|
+
]);
|
|
11
|
+
export const BulkSetExchangeRatesOut = z.object({ items: z.array(BulkExchangeRateItemOut) });
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Wire shape of `{ error: AppError }` responses. `common/errors.ts` owns the AppError union and
|
|
3
|
+
// its httpStatus mapping (every code resolves to exactly one of 404 / 409 / 422) — but that
|
|
4
|
+
// mapping is many-to-one: several distinct AppError shapes share the same HTTP status
|
|
5
|
+
// (models/error.ts's shared primitives, plus the transaction/bill one-offs below), so each
|
|
6
|
+
// status bucket is documented as a union of every shape reachable at that status, not a single
|
|
7
|
+
// uniform shape.
|
|
8
|
+
// unknown_*/ambiguous_* (account, category, sub_category, card) — models/error.ts's
|
|
9
|
+
// NotFound<E>/Ambiguous<E>.
|
|
10
|
+
const ResolutionErrorOut = z.object({ code: z.string(), query: z.string(), candidates: z.array(z.string()) });
|
|
11
|
+
// unknown_transaction has its own shape (models/transaction.ts) — an id, not query/candidates.
|
|
12
|
+
const UnknownTransactionErrorOut = z.object({ code: z.literal('unknown_transaction'), id: z.string() });
|
|
13
|
+
// unknown_bill has its own shape (models/bill.ts) — no query/candidates either.
|
|
14
|
+
const UnknownBillErrorOut = z.object({
|
|
15
|
+
code: z.literal('unknown_bill'),
|
|
16
|
+
card: z.string(),
|
|
17
|
+
month: z.number(),
|
|
18
|
+
year: z.number(),
|
|
19
|
+
});
|
|
20
|
+
// duplicate_name (models/error.ts's DuplicateName<E>).
|
|
21
|
+
const DuplicateNameErrorOut = z.object({ code: z.literal('duplicate_name'), entity: z.string(), name: z.string() });
|
|
22
|
+
// in_use (models/error.ts's InUse<E, R>) — `references` shape varies per entity
|
|
23
|
+
// (AccountReferences vs CategoryReferences have different field names), so it's left loose.
|
|
24
|
+
const InUseErrorOut = z.object({
|
|
25
|
+
code: z.literal('in_use'),
|
|
26
|
+
entity: z.string(),
|
|
27
|
+
name: z.string(),
|
|
28
|
+
references: z.record(z.string(), z.unknown()),
|
|
29
|
+
});
|
|
30
|
+
// The generic validation shape (models/error.ts's ValidationError) — used by every domain's
|
|
31
|
+
// `code: 'validation'` errors (accounts, categories, credit cards, transfers, ...).
|
|
32
|
+
// `hint` (optional) names the operation to use instead, in the edge's own words ("use POST /api/bills/pay").
|
|
33
|
+
const GenericValidationErrorOut = z.object({
|
|
34
|
+
code: z.literal('validation'),
|
|
35
|
+
issues: z.array(z.string()),
|
|
36
|
+
hint: z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
// conflict (models/error.ts's Conflict) — the versioned unit of work's generic optimistic-
|
|
39
|
+
// concurrency failure (ADR-021); no business payload, by design.
|
|
40
|
+
const VersionConflictErrorOut = z.object({ code: z.literal('conflict') });
|
|
41
|
+
// category_kind_mismatch has its own shape (models/transaction.ts) — only reachable from
|
|
42
|
+
// create/update transaction.
|
|
43
|
+
const CategoryKindMismatchErrorOut = z.object({
|
|
44
|
+
code: z.literal('category_kind_mismatch'),
|
|
45
|
+
transactionType: z.string(),
|
|
46
|
+
categoryName: z.string(),
|
|
47
|
+
categoryKind: z.string(),
|
|
48
|
+
hint: z.string(),
|
|
49
|
+
});
|
|
50
|
+
export const NotFoundErrorOut = z.object({
|
|
51
|
+
error: z.union([ResolutionErrorOut, UnknownTransactionErrorOut, UnknownBillErrorOut]),
|
|
52
|
+
});
|
|
53
|
+
export const ConflictErrorOut = z.object({
|
|
54
|
+
error: z.union([ResolutionErrorOut, DuplicateNameErrorOut, InUseErrorOut, VersionConflictErrorOut]),
|
|
55
|
+
});
|
|
56
|
+
export const ValidationErrorOut = z.object({
|
|
57
|
+
error: z.union([GenericValidationErrorOut, CategoryKindMismatchErrorOut]),
|
|
58
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TransactionViewSchema } from '../../models/transaction.js';
|
|
3
|
+
export const ApplyDueResultOut = z.object({
|
|
4
|
+
applied: z.array(z.object({ rule: z.string(), date: z.string(), transaction: TransactionViewSchema })),
|
|
5
|
+
count: z.number().int(),
|
|
6
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Locale } from '../../models/locale.js';
|
|
3
|
+
export const StatusOut = z.object({
|
|
4
|
+
name: z.literal('patty'),
|
|
5
|
+
version: z.string(),
|
|
6
|
+
db: z.enum(['ok', 'error']),
|
|
7
|
+
locale: Locale,
|
|
8
|
+
demo: z.boolean().describe("True when this database is a demo: sample data, not the person's finances"),
|
|
9
|
+
});
|
|
10
|
+
export const HealthOut = z.object({ status: z.literal('ok'), db: z.enum(['ok', 'error']) });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PeriodSchema } from '../../models/date.js';
|
|
3
|
+
import { ConvertedTotalSchema } from '../../models/currency-rate.js';
|
|
4
|
+
import { CurrencySummarySchema } from '../../models/summary.js';
|
|
5
|
+
export const SpendingSummaryOut = z.object({
|
|
6
|
+
period: PeriodSchema,
|
|
7
|
+
currencies: z.array(CurrencySummarySchema),
|
|
8
|
+
converted: ConvertedTotalSchema.optional().describe('Opt-in converted grand total of expenses across currencies — present only when displayCurrency was supplied'),
|
|
9
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ClassificationMethod, TransactionViewSchema } from '../../models/transaction.js';
|
|
3
|
+
// ─── Outbound wire schemas ────────────────────────────────────────────────────
|
|
4
|
+
// These are the serialized shapes that diplomats (MCP/HTTP) send to clients.
|
|
5
|
+
// They differ from models in two ways:
|
|
6
|
+
// 1. AppError is collapsed to a string message (safe for external consumers)
|
|
7
|
+
// 2. Zod schemas enforce the contract and serve as documentation
|
|
8
|
+
const ClassifyOutcomeOut = z.object({
|
|
9
|
+
method: ClassificationMethod,
|
|
10
|
+
confidence: z.number(),
|
|
11
|
+
categoryId: z.string().optional(),
|
|
12
|
+
categoryName: z.string().optional(),
|
|
13
|
+
merchantKey: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
export const CreateTransactionOut = z.object({
|
|
16
|
+
transaction: TransactionViewSchema,
|
|
17
|
+
created: z.boolean(),
|
|
18
|
+
classification: ClassifyOutcomeOut,
|
|
19
|
+
});
|
|
20
|
+
const BulkItemOut = z.discriminatedUnion('status', [
|
|
21
|
+
z.object({
|
|
22
|
+
status: z.literal('created'),
|
|
23
|
+
transaction: TransactionViewSchema,
|
|
24
|
+
classification: ClassifyOutcomeOut,
|
|
25
|
+
}),
|
|
26
|
+
z.object({
|
|
27
|
+
status: z.literal('needs_review'),
|
|
28
|
+
transaction: TransactionViewSchema,
|
|
29
|
+
classification: ClassifyOutcomeOut,
|
|
30
|
+
}),
|
|
31
|
+
z.object({ status: z.literal('duplicate'), transaction: TransactionViewSchema }),
|
|
32
|
+
z.object({ status: z.literal('error'), description: z.string(), error: z.string() }),
|
|
33
|
+
]);
|
|
34
|
+
export const BulkResultOut = z.object({
|
|
35
|
+
summary: z.object({
|
|
36
|
+
created: z.number().int(),
|
|
37
|
+
needsReview: z.number().int(),
|
|
38
|
+
duplicates: z.number().int(),
|
|
39
|
+
errors: z.number().int(),
|
|
40
|
+
}),
|
|
41
|
+
items: z.array(BulkItemOut),
|
|
42
|
+
});
|
|
43
|
+
export const DeleteTransactionOut = z.discriminatedUnion('deleted', [
|
|
44
|
+
z.object({ deleted: z.literal(true), transaction: TransactionViewSchema }),
|
|
45
|
+
z.object({
|
|
46
|
+
deleted: z.literal(false),
|
|
47
|
+
dryRun: z.literal(true),
|
|
48
|
+
wouldDelete: TransactionViewSchema,
|
|
49
|
+
hint: z.string(),
|
|
50
|
+
}),
|
|
51
|
+
]);
|
|
52
|
+
export const TransferResultOut = z.object({ transaction: TransactionViewSchema, created: z.boolean() });
|