@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,132 @@
|
|
|
1
|
+
import { ClientConfigFailureCode } from '../../../models/client-config.js';
|
|
2
|
+
import { DEFAULT_PROFILE, PROFILE_ENV_VAR } from '../../../models/auth/sign-in.js';
|
|
3
|
+
import { DEMO_SERVER_NAME } from '../../../models/demo/core.js';
|
|
4
|
+
import { NPX_COMMAND, PRODUCT_NAME } from '../../../models/package.js';
|
|
5
|
+
import { DEMO_FLAG, DemoEntryChange, PASSWORD_STDIN_FLAG, REMOVE_DEMO_FLAG, SETUP_POSITIONALS, SetupOptionsSchema, } from '../../../wire/in/cli.js';
|
|
6
|
+
import { EXIT_FAILURE, EXIT_OK, exitCodeOf, fail, parseFlags } from '../io.js';
|
|
7
|
+
import { ensureOwnerClaimed } from './auth.js';
|
|
8
|
+
import { offerSignIn } from './login.js';
|
|
9
|
+
const SETUP_FLAGS = {
|
|
10
|
+
[PASSWORD_STDIN_FLAG]: { type: 'boolean' },
|
|
11
|
+
username: { type: 'string' },
|
|
12
|
+
profile: { type: 'string' },
|
|
13
|
+
[DEMO_FLAG]: { type: 'boolean' },
|
|
14
|
+
[REMOVE_DEMO_FLAG]: { type: 'boolean' },
|
|
15
|
+
};
|
|
16
|
+
const CONFIG_FAILURE_VERB = {
|
|
17
|
+
[ClientConfigFailureCode.enum.read_failed]: 'read',
|
|
18
|
+
[ClientConfigFailureCode.enum.write_failed]: 'write',
|
|
19
|
+
};
|
|
20
|
+
/** What `setup` says. The help text is also printed for `patty setup` with no tool. */
|
|
21
|
+
export const SETUP_MESSAGES = {
|
|
22
|
+
help: `
|
|
23
|
+
Usage: ${NPX_COMMAND} setup <tool> [--username <name>] [--${PASSWORD_STDIN_FLAG}] [--profile <name>]
|
|
24
|
+
${NPX_COMMAND} setup <tool> --${DEMO_FLAG} | --${REMOVE_DEMO_FLAG}
|
|
25
|
+
|
|
26
|
+
Available tools:
|
|
27
|
+
claude-code Claude Code CLI (~/.claude/mcp.json)
|
|
28
|
+
claude-desktop Claude Desktop (OS-specific config path)
|
|
29
|
+
copilot VS Code / GitHub Copilot (.vscode/mcp.json in current directory)
|
|
30
|
+
vscode VS Code / GitHub Copilot (alias for copilot)
|
|
31
|
+
antigravity Google Antigravity (~/.gemini/config/mcp_config.json)
|
|
32
|
+
codex OpenAI Codex (prints the config snippet to paste)
|
|
33
|
+
|
|
34
|
+
${PRODUCT_NAME} requires a login. The first time, setup asks you to choose the owner's username and password
|
|
35
|
+
(typed twice, never echoed), writes the client's config, then offers to sign that client in. Re-running it is safe: an
|
|
36
|
+
owner that already has a login is left alone.
|
|
37
|
+
|
|
38
|
+
Options:
|
|
39
|
+
--username <name> the owner's username (required with --${PASSWORD_STDIN_FLAG})
|
|
40
|
+
--${PASSWORD_STDIN_FLAG} read the password from stdin instead of asking — for scripted installs
|
|
41
|
+
--profile <name> sign this client in as a separate profile (adds ${PROFILE_ENV_VAR} to its config); default: ${DEFAULT_PROFILE}
|
|
42
|
+
--${DEMO_FLAG} add a second MCP entry, ${DEMO_SERVER_NAME}, that runs on the demo database (see: ${NPX_COMMAND} demo);
|
|
43
|
+
the patty entry is never touched, and no login is needed
|
|
44
|
+
--${REMOVE_DEMO_FLAG} remove only the ${DEMO_SERVER_NAME} entry
|
|
45
|
+
|
|
46
|
+
Examples:
|
|
47
|
+
${NPX_COMMAND} setup claude-code
|
|
48
|
+
${NPX_COMMAND} setup copilot
|
|
49
|
+
${NPX_COMMAND} setup vscode
|
|
50
|
+
${NPX_COMMAND} setup antigravity
|
|
51
|
+
`.trimStart(),
|
|
52
|
+
unknownTool: (tool) => `patty setup: unknown tool "${tool}"\n\nRun without arguments to see available tools.`,
|
|
53
|
+
settingUp: (label) => `Setting up ${PRODUCT_NAME} MCP for ${label}...`,
|
|
54
|
+
settingUpDemo: (change, label) => `${change === DemoEntryChange.enum.add ? 'Adding' : 'Removing'} the ${DEMO_SERVER_NAME} MCP entry for ${label}...`,
|
|
55
|
+
demoNotCreated: ` Run \`${NPX_COMMAND} demo\` once to create the demo data.`,
|
|
56
|
+
done: 'Done.',
|
|
57
|
+
/** Said when a client's configuration file could not be used: the same words whichever file it was. */
|
|
58
|
+
configFailure: (failure) => `patty setup: failed to ${CONFIG_FAILURE_VERB[failure.code]} ${failure.path}: ${failure.reason}`,
|
|
59
|
+
};
|
|
60
|
+
/** Writes the client's configuration and answers the exit code: help is `EXIT_OK`, an unknown tool or a configuration
|
|
61
|
+
* file that cannot be read or written is reported on stderr and is `EXIT_FAILURE`. */
|
|
62
|
+
export const runSetup = (io, tool, profile = DEFAULT_PROFILE) => {
|
|
63
|
+
if (!tool) {
|
|
64
|
+
io.out(SETUP_MESSAGES.help);
|
|
65
|
+
return EXIT_OK;
|
|
66
|
+
}
|
|
67
|
+
const client = io.clients.find(tool);
|
|
68
|
+
if (!client) {
|
|
69
|
+
io.err(SETUP_MESSAGES.unknownTool(tool));
|
|
70
|
+
return EXIT_FAILURE;
|
|
71
|
+
}
|
|
72
|
+
io.out(SETUP_MESSAGES.settingUp(client.label));
|
|
73
|
+
return client.run(profile).match((report) => {
|
|
74
|
+
report.warnings.forEach((warning) => io.err(warning));
|
|
75
|
+
report.lines.forEach((line) => io.out(line));
|
|
76
|
+
io.out(SETUP_MESSAGES.done);
|
|
77
|
+
return EXIT_OK;
|
|
78
|
+
}, (failure) => {
|
|
79
|
+
failure.warnings.forEach((warning) => io.err(warning));
|
|
80
|
+
io.err(SETUP_MESSAGES.configFailure(failure));
|
|
81
|
+
return EXIT_FAILURE;
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
/** Claims the owner first, writes the client config only if that succeeded, then offers to sign the client in
|
|
85
|
+
* (ADR-034 §5.3). Help and an unknown tool never claim. `claimOwner` and `signIn` answer the exit code to end with
|
|
86
|
+
* (`EXIT_OK` to go on). */
|
|
87
|
+
export const runGuidedSetup = async (io, tool, claimOwner, signIn = async () => undefined, profile = DEFAULT_PROFILE) => {
|
|
88
|
+
if (!tool || io.clients.find(tool) === undefined)
|
|
89
|
+
return runSetup(io, tool, profile);
|
|
90
|
+
const claimed = await claimOwner();
|
|
91
|
+
if (claimed !== EXIT_OK)
|
|
92
|
+
return claimed;
|
|
93
|
+
const written = runSetup(io, tool, profile);
|
|
94
|
+
if (written !== EXIT_OK)
|
|
95
|
+
return written;
|
|
96
|
+
return (await signIn(profile)) ?? EXIT_OK;
|
|
97
|
+
};
|
|
98
|
+
export const runDemoEntry = (io, tool, change) => {
|
|
99
|
+
if (!tool) {
|
|
100
|
+
io.out(SETUP_MESSAGES.help);
|
|
101
|
+
return EXIT_OK;
|
|
102
|
+
}
|
|
103
|
+
const client = io.clients.find(tool);
|
|
104
|
+
if (!client) {
|
|
105
|
+
io.err(SETUP_MESSAGES.unknownTool(tool));
|
|
106
|
+
return EXIT_FAILURE;
|
|
107
|
+
}
|
|
108
|
+
io.out(SETUP_MESSAGES.settingUpDemo(change, client.label));
|
|
109
|
+
return (change === DemoEntryChange.enum.add ? client.addDemo(io.demo.databasePath) : client.removeDemo()).match((report) => {
|
|
110
|
+
report.warnings.forEach((warning) => io.err(warning));
|
|
111
|
+
report.lines.forEach((line) => io.out(line));
|
|
112
|
+
if (change === DemoEntryChange.enum.add && !io.demo.hasDatabase())
|
|
113
|
+
io.out(SETUP_MESSAGES.demoNotCreated);
|
|
114
|
+
io.out(SETUP_MESSAGES.done);
|
|
115
|
+
return EXIT_OK;
|
|
116
|
+
}, (failure) => {
|
|
117
|
+
failure.warnings.forEach((warning) => io.err(warning));
|
|
118
|
+
io.err(SETUP_MESSAGES.configFailure(failure));
|
|
119
|
+
return EXIT_FAILURE;
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
export const runSetupCommand = async (args, io) => {
|
|
123
|
+
const parsed = parseFlags(args, SETUP_FLAGS, SetupOptionsSchema, SETUP_POSITIONALS);
|
|
124
|
+
if ('error' in parsed)
|
|
125
|
+
return exitCodeOf(fail(io, parsed.error));
|
|
126
|
+
const [client] = parsed.positionals;
|
|
127
|
+
if (parsed.options.demo)
|
|
128
|
+
return runDemoEntry(io, client, DemoEntryChange.enum.add);
|
|
129
|
+
if (parsed.options.removeDemo)
|
|
130
|
+
return runDemoEntry(io, client, DemoEntryChange.enum.remove);
|
|
131
|
+
return runGuidedSetup(io, client, () => ensureOwnerClaimed(io, parsed.options), (profile) => offerSignIn(io, profile), parsed.options.profile);
|
|
132
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatAppError } from '../../../common/errors.js';
|
|
3
|
+
import { disableUser, enableUser, inviteUser, listUsers, reissueInvite, resolveUserId, setRole, } from '../../../controllers/auth/users.js';
|
|
4
|
+
import { inviteLink } from '../../../logic/auth/users.js';
|
|
5
|
+
import { UserRole } from '../../../models/auth/owner.js';
|
|
6
|
+
import { UsernameSchema } from '../../../models/auth/password.js';
|
|
7
|
+
import { ActorKind } from '../../../models/auth/users.js';
|
|
8
|
+
import { NPX_COMMAND } from '../../../models/package.js';
|
|
9
|
+
import { InviteOptionsSchema, TargetUsernameSchema, USERS_POSITIONALS, UsersSubcommand, } from '../../../wire/in/cli.js';
|
|
10
|
+
import { EXIT_FAILURE, EXIT_OK, exitCodeOf, fail, failed, parseFlags, withShell, } from '../io.js';
|
|
11
|
+
import { CLI_MESSAGES } from '../messages.js';
|
|
12
|
+
export const USERS_HELP = `
|
|
13
|
+
Usage: ${NPX_COMMAND} users <command>
|
|
14
|
+
|
|
15
|
+
Commands:
|
|
16
|
+
list Everyone who can sign in, with role, status and last login
|
|
17
|
+
invite <username> [--admin] Create a user and print a one-time invite link and code (members unless --admin)
|
|
18
|
+
reissue <username> A new invite; for a user who already claimed one, also clears their password and ends
|
|
19
|
+
every session, token and sign-in they hold
|
|
20
|
+
disable <username> Stop them logging in and end every session, token and sign-in they hold
|
|
21
|
+
enable <username> Let them log in again (earlier sessions and tokens stay revoked)
|
|
22
|
+
role <username> <member|admin>
|
|
23
|
+
|
|
24
|
+
Run from a terminal that can open the database: like \`auth setup\`, it needs no password. People choose their own
|
|
25
|
+
password by claiming the invite; users are disabled, never deleted, and the instance always keeps one active admin.
|
|
26
|
+
`.trimStart();
|
|
27
|
+
// The terminal is the trusted local operator: it holds the database key, so it has no session, no user and no step-up.
|
|
28
|
+
const NEEDS_USERNAME = 'a username is required';
|
|
29
|
+
const TERMINAL = { kind: ActorKind.enum.terminal };
|
|
30
|
+
// What each refusal says on this edge, in this edge's vocabulary: the domain's message is neutral.
|
|
31
|
+
const REFUSAL_HINT = {
|
|
32
|
+
user_disabled: (username) => `Run \`${NPX_COMMAND} users enable ${username}\` first.`,
|
|
33
|
+
last_admin: () => 'Make another user an administrator first.',
|
|
34
|
+
};
|
|
35
|
+
const refused = (io, error, username) => {
|
|
36
|
+
const hint = username === undefined ? undefined : REFUSAL_HINT[error.code]?.(username);
|
|
37
|
+
return failed(io, hint === undefined ? formatAppError(error) : `${formatAppError(error)} ${hint}`);
|
|
38
|
+
};
|
|
39
|
+
/** Opens the shell, names the one user the command is about, and hands both to `work`. */
|
|
40
|
+
const aboutUser = (io, rawUsername, work) => withShell(io, async (shell) => {
|
|
41
|
+
const named = TargetUsernameSchema.safeParse(rawUsername);
|
|
42
|
+
if (!named.success)
|
|
43
|
+
return exitCodeOf(fail(io, NEEDS_USERNAME));
|
|
44
|
+
const userId = await resolveUserId(shell.deps, named.data);
|
|
45
|
+
return userId.isErr() ? refused(io, userId.error) : work(shell, userId.value, named.data);
|
|
46
|
+
}, EXIT_FAILURE);
|
|
47
|
+
const printIssued = (io, shell, issued) => {
|
|
48
|
+
io.out(CLI_MESSAGES.invited(issued, shell.inviteOrigin === null ? null : inviteLink(shell.inviteOrigin, issued.code)));
|
|
49
|
+
};
|
|
50
|
+
const list = (io) => withShell(io, async (shell) => {
|
|
51
|
+
const users = await listUsers(shell.deps, TERMINAL);
|
|
52
|
+
if (users.isErr())
|
|
53
|
+
return refused(io, users.error);
|
|
54
|
+
io.out(users.value.length === 0 ? CLI_MESSAGES.noUsers : users.value.map(CLI_MESSAGES.userRow).join('\n'));
|
|
55
|
+
return EXIT_OK;
|
|
56
|
+
}, EXIT_FAILURE);
|
|
57
|
+
const invite = (positionals, options, io) => {
|
|
58
|
+
const username = UsernameSchema.safeParse(positionals[0]);
|
|
59
|
+
if (!username.success) {
|
|
60
|
+
return Promise.resolve(exitCodeOf(fail(io, username.error.issues[0]?.message ?? NEEDS_USERNAME)));
|
|
61
|
+
}
|
|
62
|
+
return withShell(io, async (shell) => {
|
|
63
|
+
const input = { username: username.data, role: options.role };
|
|
64
|
+
const issued = await shell.run(() => inviteUser(shell.deps, TERMINAL, input));
|
|
65
|
+
if (issued.isErr())
|
|
66
|
+
return refused(io, issued.error);
|
|
67
|
+
printIssued(io, shell, issued.value);
|
|
68
|
+
return EXIT_OK;
|
|
69
|
+
}, EXIT_FAILURE);
|
|
70
|
+
};
|
|
71
|
+
const reissue = (username, io) => aboutUser(io, username, async (shell, userId, name) => {
|
|
72
|
+
const issued = await shell.run(() => reissueInvite(shell.deps, TERMINAL, userId));
|
|
73
|
+
if (issued.isErr())
|
|
74
|
+
return refused(io, issued.error, name);
|
|
75
|
+
printIssued(io, shell, issued.value);
|
|
76
|
+
io.out(CLI_MESSAGES.reissueEnded(issued.value.revoked));
|
|
77
|
+
return EXIT_OK;
|
|
78
|
+
});
|
|
79
|
+
const report = (io, changed, say, name) => {
|
|
80
|
+
if (changed.isErr())
|
|
81
|
+
return refused(io, changed.error, name);
|
|
82
|
+
io.out(say(changed.value));
|
|
83
|
+
return EXIT_OK;
|
|
84
|
+
};
|
|
85
|
+
const disable = (username, io) => aboutUser(io, username, async (shell, userId, name) => report(io, await shell.run(() => disableUser(shell.deps, TERMINAL, userId)), (change) => CLI_MESSAGES.disabled(name, change.revoked), name));
|
|
86
|
+
const enable = (username, io) => aboutUser(io, username, async (shell, userId, name) => report(io, await shell.run(() => enableUser(shell.deps, TERMINAL, userId)), () => CLI_MESSAGES.enabled(name), name));
|
|
87
|
+
const role = (username, rawRole, io) => {
|
|
88
|
+
const chosen = UserRole.safeParse(rawRole);
|
|
89
|
+
if (!chosen.success)
|
|
90
|
+
return Promise.resolve(exitCodeOf(fail(io, `a role is required: ${UserRole.options.join(' or ')}`)));
|
|
91
|
+
return aboutUser(io, username, async (shell, userId, name) => report(io, await shell.run(() => setRole(shell.deps, TERMINAL, { userId, role: chosen.data })), () => CLI_MESSAGES.roleSet(name, chosen.data), name));
|
|
92
|
+
};
|
|
93
|
+
const NO_FLAGS = z.object({});
|
|
94
|
+
const INVITE_FLAGS = { admin: { type: 'boolean' } };
|
|
95
|
+
const parsedArguments = (subcommand, args) => subcommand === UsersSubcommand.enum.invite
|
|
96
|
+
? parseFlags(args, INVITE_FLAGS, InviteOptionsSchema, USERS_POSITIONALS.invite)
|
|
97
|
+
: parseFlags(args, {}, NO_FLAGS, USERS_POSITIONALS[subcommand]);
|
|
98
|
+
export const runUsersCommand = async (args, io) => {
|
|
99
|
+
const [name, ...rest] = args;
|
|
100
|
+
if (name === undefined) {
|
|
101
|
+
io.out(USERS_HELP);
|
|
102
|
+
return EXIT_OK;
|
|
103
|
+
}
|
|
104
|
+
const subcommand = UsersSubcommand.safeParse(name);
|
|
105
|
+
if (!subcommand.success) {
|
|
106
|
+
io.err(CLI_MESSAGES.failure(`unknown users command "${name}"`));
|
|
107
|
+
io.err(USERS_HELP);
|
|
108
|
+
return EXIT_FAILURE;
|
|
109
|
+
}
|
|
110
|
+
const parsed = parsedArguments(subcommand.data, rest);
|
|
111
|
+
if ('error' in parsed)
|
|
112
|
+
return exitCodeOf(fail(io, parsed.error));
|
|
113
|
+
const [first, second] = parsed.positionals;
|
|
114
|
+
const handlers = {
|
|
115
|
+
list: () => list(io),
|
|
116
|
+
invite: () => invite(parsed.positionals, parsed.options, io),
|
|
117
|
+
reissue: () => reissue(first, io),
|
|
118
|
+
disable: () => disable(first, io),
|
|
119
|
+
enable: () => enable(first, io),
|
|
120
|
+
role: () => role(first, second, io),
|
|
121
|
+
};
|
|
122
|
+
return handlers[subcommand.data]();
|
|
123
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CliCommand } from '../../wire/in/cli.js';
|
|
2
|
+
import { NPX_COMMAND, PRODUCT_NAME } from '../../models/package.js';
|
|
3
|
+
import { runAuthCommand } from './commands/auth.js';
|
|
4
|
+
import { runDbCommand } from './commands/db.js';
|
|
5
|
+
import { runDemoCommand } from './commands/demo.js';
|
|
6
|
+
import { runKeyCommand } from './commands/key.js';
|
|
7
|
+
import { runLogin, runLogout } from './commands/login.js';
|
|
8
|
+
import { runSetupCommand } from './commands/setup.js';
|
|
9
|
+
import { runUsersCommand } from './commands/users.js';
|
|
10
|
+
import { EXIT_FAILURE, EXIT_OK } from './io.js';
|
|
11
|
+
import { reasonOf } from '../../models/error.js';
|
|
12
|
+
import { CLI_MESSAGES } from './messages.js';
|
|
13
|
+
const HELP_ARGUMENTS = ['help', '--help', '-h'];
|
|
14
|
+
export const USAGE = `
|
|
15
|
+
Usage: ${NPX_COMMAND} <command>
|
|
16
|
+
|
|
17
|
+
Commands:
|
|
18
|
+
setup <client> Claim the owner, write the MCP client's config entry, and offer to sign that client in
|
|
19
|
+
login Sign a client in from this terminal (opens a browser approval, saves it to the OS keychain)
|
|
20
|
+
logout Revoke the saved sign-in and remove it from the keychain
|
|
21
|
+
auth <command> Owner login: setup, reset-password
|
|
22
|
+
users <command> Manage who can sign in: list, invite, reissue, disable, enable, role
|
|
23
|
+
key <command> Move the database key between installs (export --to <file>, import --from <file>)
|
|
24
|
+
db <command> Move an encrypted snapshot of the database between installs (export --to, import --from)
|
|
25
|
+
demo Try ${PRODUCT_NAME} on throwaway sample data, on its own port (--country, --reset)
|
|
26
|
+
|
|
27
|
+
The setup, auth, users, key and db commands print their own help when run with no arguments. With no command at all, ${PRODUCT_NAME} runs as an MCP server (stdio).
|
|
28
|
+
`.trimStart();
|
|
29
|
+
// Exhaustive by type: a command added to `CliCommand` without a runner fails to compile.
|
|
30
|
+
const RUNNERS = {
|
|
31
|
+
setup: runSetupCommand,
|
|
32
|
+
login: runLogin,
|
|
33
|
+
logout: runLogout,
|
|
34
|
+
auth: runAuthCommand,
|
|
35
|
+
users: runUsersCommand,
|
|
36
|
+
key: runKeyCommand,
|
|
37
|
+
db: runDbCommand,
|
|
38
|
+
demo: runDemoCommand,
|
|
39
|
+
};
|
|
40
|
+
/** Every argument is a command: an unknown one prints the usage and fails — it never falls through to starting a
|
|
41
|
+
* server, which is what an old or stale build once did with `auth setup`. */
|
|
42
|
+
export const runCli = async (args, io) => {
|
|
43
|
+
const [command, ...rest] = args;
|
|
44
|
+
if (command === undefined || HELP_ARGUMENTS.includes(command)) {
|
|
45
|
+
io.out(USAGE);
|
|
46
|
+
return EXIT_OK;
|
|
47
|
+
}
|
|
48
|
+
const known = CliCommand.safeParse(command);
|
|
49
|
+
if (!known.success) {
|
|
50
|
+
io.err(CLI_MESSAGES.failure(`unknown command "${command}"`));
|
|
51
|
+
io.err(USAGE);
|
|
52
|
+
return EXIT_FAILURE;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
return await RUNNERS[known.data](rest, io);
|
|
56
|
+
}
|
|
57
|
+
catch (cause) {
|
|
58
|
+
io.err(CLI_MESSAGES.failure(reasonOf(cause)));
|
|
59
|
+
return EXIT_FAILURE;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { lstatSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { err, ok, Result } from 'neverthrow';
|
|
4
|
+
import { isBesideData, isDatabaseFile } from '../../logic/export-destination.js';
|
|
5
|
+
import { reasonOf } from '../../models/error.js';
|
|
6
|
+
import { CLI_MESSAGES } from './messages.js';
|
|
7
|
+
export const realPath = Result.fromThrowable((path) => realpathSync.native(path), reasonOf);
|
|
8
|
+
export const statLink = Result.fromThrowable(lstatSync, reasonOf);
|
|
9
|
+
/** The destination as the filesystem sees it: its directory resolved through symlinks and relative segments, so a
|
|
10
|
+
* rule applied to it cannot be slipped past with a `..` or a link. The file itself is not followed. */
|
|
11
|
+
const locate = (to) => {
|
|
12
|
+
const requested = resolve(to);
|
|
13
|
+
return realPath(dirname(requested))
|
|
14
|
+
.mapErr(() => CLI_MESSAGES.destinationDirectoryMissing(requested))
|
|
15
|
+
.map((directory) => ({ destination: join(directory, basename(requested)), directory }));
|
|
16
|
+
};
|
|
17
|
+
/** An existing file is never overwritten — a dangling symlink counts as existing. `wx` is the backstop for a race. */
|
|
18
|
+
const refuseExisting = ({ destination }) => statLink(destination).isOk() ? err(CLI_MESSAGES.destinationExists(destination)) : ok(destination);
|
|
19
|
+
/** The directory the database really lives in: through a symlink on the file itself, else (no such file yet — the
|
|
20
|
+
* caller's key proof says so) through the directory's own. */
|
|
21
|
+
const dataDirectoryOf = (databaseFile) => realPath(databaseFile)
|
|
22
|
+
.map((real) => dirname(real))
|
|
23
|
+
.orElse(() => realPath(dirname(databaseFile)))
|
|
24
|
+
.mapErr(() => CLI_MESSAGES.destinationDirectoryMissing(databaseFile));
|
|
25
|
+
/** Where the key may be written: a new file, in a directory that is not the database's (nor under it). */
|
|
26
|
+
export const keyDestination = (exporter, to) => locate(to).andThen((located) => dataDirectoryOf(exporter.databasePath())
|
|
27
|
+
.andThen((dataDirectory) => isBesideData(dataDirectory, located.directory)
|
|
28
|
+
? err(CLI_MESSAGES.keyBesideData(located.directory))
|
|
29
|
+
: ok(located))
|
|
30
|
+
.andThen(refuseExisting));
|
|
31
|
+
/** Where a snapshot may be written: a new file that is not the live database. */
|
|
32
|
+
export const snapshotDestination = (exporter, to) => locate(to).andThen((located) => realPath(exporter.databasePath())
|
|
33
|
+
.orElse(() => ok(exporter.databasePath()))
|
|
34
|
+
.andThen((databaseFile) => isDatabaseFile(databaseFile, located.destination)
|
|
35
|
+
? err(CLI_MESSAGES.snapshotIsDatabase(located.destination))
|
|
36
|
+
: ok(located))
|
|
37
|
+
.andThen(refuseExisting));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { err, ok, Result } from 'neverthrow';
|
|
4
|
+
import { decodeKeyFile } from '../../logic/key-import.js';
|
|
5
|
+
import { isDatabaseFile } from '../../logic/export-destination.js';
|
|
6
|
+
import { reasonOf } from '../../models/error.js';
|
|
7
|
+
import { DATA_BEARING_SUFFIXES, DATABASE_COMPANION_SUFFIXES } from '../../models/export.js';
|
|
8
|
+
import { KEY_FILE_MAX_CHARACTERS } from '../../models/key-import.js';
|
|
9
|
+
import { realPath, statLink } from './export-file.js';
|
|
10
|
+
import { CLI_MESSAGES } from './messages.js';
|
|
11
|
+
const statFile = Result.fromThrowable((path) => statSync(path), reasonOf);
|
|
12
|
+
const readText = Result.fromThrowable((path) => readFileSync(path, 'utf8'), reasonOf);
|
|
13
|
+
const sourceFile = (from) => {
|
|
14
|
+
const requested = resolve(from);
|
|
15
|
+
const isFile = statFile(requested).match((stat) => stat.isFile(), () => false);
|
|
16
|
+
return isFile
|
|
17
|
+
? realPath(requested).mapErr(() => CLI_MESSAGES.importSourceMissing(requested))
|
|
18
|
+
: err(CLI_MESSAGES.importSourceMissing(requested));
|
|
19
|
+
};
|
|
20
|
+
export const keyFromFile = (from) => sourceFile(from).andThen((file) => statFile(file)
|
|
21
|
+
.mapErr(() => CLI_MESSAGES.importSourceUnreadable(file))
|
|
22
|
+
.andThen((stat) => (stat.size > KEY_FILE_MAX_CHARACTERS ? err(CLI_MESSAGES.keyFileInvalid) : ok(file)))
|
|
23
|
+
.andThen((small) => readText(small).mapErr(() => CLI_MESSAGES.importSourceUnreadable(small)))
|
|
24
|
+
.andThen((contents) => {
|
|
25
|
+
const key = decodeKeyFile(contents);
|
|
26
|
+
return key === null ? err(CLI_MESSAGES.keyFileInvalid) : ok(key);
|
|
27
|
+
}));
|
|
28
|
+
const firstExisting = (base, suffixes) => suffixes.map((suffix) => `${base}${suffix}`).find((path) => statLink(path).isOk());
|
|
29
|
+
const importRefusal = (file, target) => {
|
|
30
|
+
const live = realPath(target).orElse(() => ok(target));
|
|
31
|
+
if (live.isOk() && isDatabaseFile(live.value, file))
|
|
32
|
+
return CLI_MESSAGES.snapshotIsDatabase(file);
|
|
33
|
+
if (statLink(target).isOk())
|
|
34
|
+
return CLI_MESSAGES.databaseExists(target);
|
|
35
|
+
if (firstExisting(file, DATA_BEARING_SUFFIXES) !== undefined)
|
|
36
|
+
return CLI_MESSAGES.snapshotNotStandalone(file);
|
|
37
|
+
if (firstExisting(target, DATABASE_COMPANION_SUFFIXES) !== undefined)
|
|
38
|
+
return CLI_MESSAGES.databaseLeftovers(target);
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
41
|
+
export const snapshotSource = (importer, from) => sourceFile(from).andThen((file) => Result.fromThrowable(() => importer.databasePath(), reasonOf)().andThen((target) => {
|
|
42
|
+
const refusal = importRefusal(file, target);
|
|
43
|
+
return refusal === null ? ok({ file, target }) : err(refusal);
|
|
44
|
+
}));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { reasonOf } from '../../models/error.js';
|
|
3
|
+
import { databaseAheadMessage } from '../../models/database.js';
|
|
4
|
+
import { CLI_MESSAGES } from './messages.js';
|
|
5
|
+
import { isPromptEnded, PROMPT_MESSAGES } from './prompt.js';
|
|
6
|
+
import { PROMPT_ABORTED_MESSAGE, PromptEnd } from './terminal.js';
|
|
7
|
+
export const EXIT_OK = 0;
|
|
8
|
+
export const EXIT_FAILURE = 1;
|
|
9
|
+
/** The conventional status of a process stopped by Ctrl-C (128 + SIGINT). */
|
|
10
|
+
export const EXIT_INTERRUPTED = 130;
|
|
11
|
+
/** Runs `work` on the opened shell and closes it. When the database is newer than this build, says so on stderr
|
|
12
|
+
* (the one wording, `databaseAheadMessage`) and answers `whenUnavailable` without running anything. */
|
|
13
|
+
export const withShell = async (io, work, whenUnavailable) => {
|
|
14
|
+
const opened = await io.openShell();
|
|
15
|
+
if (opened.isErr()) {
|
|
16
|
+
io.err(databaseAheadMessage(opened.error.version));
|
|
17
|
+
return whenUnavailable;
|
|
18
|
+
}
|
|
19
|
+
const shell = opened.value;
|
|
20
|
+
try {
|
|
21
|
+
return await work(shell);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
shell.close();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const fail = (io, reason) => {
|
|
28
|
+
io.err(CLI_MESSAGES.failure(reason));
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
/** Says why on stderr and answers the failing exit code. */
|
|
32
|
+
export const failed = (io, reason) => exitCodeOf(fail(io, reason));
|
|
33
|
+
/** What a failed prompt answers: an invalid answer is a failure with its message; Ctrl-C is the interrupted exit
|
|
34
|
+
* (the terminal has already said its newline); Ctrl-D reads as "cancelled", a failure. */
|
|
35
|
+
export const exitCodeOfPrompt = (io, failure) => {
|
|
36
|
+
if (!isPromptEnded(failure))
|
|
37
|
+
return failed(io, failure.message);
|
|
38
|
+
return failure.how === PromptEnd.enum.interrupted ? EXIT_INTERRUPTED : failed(io, PROMPT_ABORTED_MESSAGE);
|
|
39
|
+
};
|
|
40
|
+
/** An unknown subcommand of `group`: says so, prints that group's help, and fails. */
|
|
41
|
+
export const refuseUnknownSubcommand = (io, group, name, help) => {
|
|
42
|
+
io.err(CLI_MESSAGES.failure(`unknown ${group} command "${name}"`));
|
|
43
|
+
io.err(help);
|
|
44
|
+
return EXIT_FAILURE;
|
|
45
|
+
};
|
|
46
|
+
export const exitCodeOf = (succeeded) => (succeeded ? EXIT_OK : EXIT_FAILURE);
|
|
47
|
+
export const parseFlags = (args, options, schema, maxPositionals) => {
|
|
48
|
+
try {
|
|
49
|
+
const parsed = parseArgs({ args: [...args], options, allowPositionals: true, strict: true });
|
|
50
|
+
const extra = parsed.positionals[maxPositionals];
|
|
51
|
+
if (extra !== undefined)
|
|
52
|
+
return { error: CLI_MESSAGES.unexpectedArgument(extra) };
|
|
53
|
+
const decoded = schema.safeParse(parsed.values);
|
|
54
|
+
return decoded.success
|
|
55
|
+
? { positionals: parsed.positionals, options: decoded.data }
|
|
56
|
+
: { error: decoded.error.issues[0]?.message ?? PROMPT_MESSAGES.invalidAnswer };
|
|
57
|
+
}
|
|
58
|
+
catch (cause) {
|
|
59
|
+
return { error: reasonOf(cause) };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { errAsync, okAsync, ResultAsync } from 'neverthrow';
|
|
2
|
+
import { guardClaimedAdminExists, confirmKeyExportAdmin } from '../../controllers/auth/key-export.js';
|
|
3
|
+
import { authErrors } from '../../models/auth/errors.js';
|
|
4
|
+
import { EXPORT_DECLINED, } from '../../models/auth/key-export.js';
|
|
5
|
+
import { AUTH_MESSAGES } from '../../models/auth/message.js';
|
|
6
|
+
import { CLI_MESSAGES } from './messages.js';
|
|
7
|
+
import { exitCodeOfPrompt, failed } from './io.js';
|
|
8
|
+
import { askAdminCredentials, askExportConfirmation, MAX_PROMPT_ATTEMPTS } from './prompt.js';
|
|
9
|
+
import { PromptFailureCode } from './terminal.js';
|
|
10
|
+
const isWrongAnswer = (failure) => failure.code === authErrors.invalidCredentials.code;
|
|
11
|
+
/** A wrong answer is told, followed by a fixed pause, and asked again — at most `MAX_PROMPT_ATTEMPTS` times in all.
|
|
12
|
+
* Anything else (the prompt ending, the database unreadable) stops at once. */
|
|
13
|
+
const askUntilConfirmed = (context, attemptsLeft) => askAdminCredentials(context.terminal)
|
|
14
|
+
.andThen(context.confirm)
|
|
15
|
+
.map(() => undefined)
|
|
16
|
+
.orElse((failure) => {
|
|
17
|
+
if (!isWrongAnswer(failure) || attemptsLeft <= 1)
|
|
18
|
+
return errAsync(failure);
|
|
19
|
+
context.terminal.tell(AUTH_MESSAGES.invalidCredentials);
|
|
20
|
+
return ResultAsync.fromSafePromise(context.pause()).andThen(() => askUntilConfirmed(context, attemptsLeft - 1));
|
|
21
|
+
});
|
|
22
|
+
const confirmWarning = (terminal, destination) => {
|
|
23
|
+
terminal.tell(CLI_MESSAGES.keyExportWarning(destination));
|
|
24
|
+
return askExportConfirmation(terminal).andThen((confirmed) => confirmed ? okAsync(undefined) : errAsync(EXPORT_DECLINED));
|
|
25
|
+
};
|
|
26
|
+
/** Everything that must hold before the key is written: an administrator with a login exists, one of them proved it
|
|
27
|
+
* with their password, and the person confirmed the warning. Writes nothing. */
|
|
28
|
+
export const approveKeyExport = ({ terminal, users, secrets, pause, destination, }) => guardClaimedAdminExists({ users })
|
|
29
|
+
.andThen(() => ResultAsync.fromSafePromise(secrets()))
|
|
30
|
+
.andThen((loaded) => {
|
|
31
|
+
const deps = { users, secrets: loaded };
|
|
32
|
+
return askUntilConfirmed({ terminal, pause, confirm: (credentials) => confirmKeyExportAdmin(deps, credentials) }, MAX_PROMPT_ATTEMPTS);
|
|
33
|
+
})
|
|
34
|
+
.andThen(() => confirmWarning(terminal, destination));
|
|
35
|
+
const isPromptFailure = (failure) => PromptFailureCode.safeParse(failure.code).success;
|
|
36
|
+
/** What a refused export answers: a prompt that ended or was invalid as every command does, anything else in words. */
|
|
37
|
+
export const exitCodeOfStop = (io, failure) => isPromptFailure(failure) ? exitCodeOfPrompt(io, failure) : failed(io, CLI_MESSAGES.keyExportStopped(failure));
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { PRIVATE_FILE_MODE } from '../../models/export.js';
|
|
2
|
+
import { DB_KEY_KEYCHAIN_ACCOUNT, KEYCHAIN_SERVICE } from '../../models/auth/sign-in.js';
|
|
3
|
+
import { AUTH_MESSAGES, TERMINAL_SETUP_HINT } from '../../models/auth/message.js';
|
|
4
|
+
import { EXPORT_DECLINED_CODE, USERS_UNREADABLE_CODE } from '../../models/auth/key-export.js';
|
|
5
|
+
import { KeyImportRefusal } from '../../models/key-import.js';
|
|
6
|
+
import { LOG_PREFIX, NPX_COMMAND, PRODUCT_NAME } from '../../models/package.js';
|
|
7
|
+
import { INVITE_PATH } from '../../models/auth/origin.js';
|
|
8
|
+
const MOVE_GUIDE = 'docs/auth.md, "Moving an npm install to Docker"';
|
|
9
|
+
const fileMode = () => PRIVATE_FILE_MODE.toString(8).padStart(4, '0');
|
|
10
|
+
const countsLine = (counts) => Object.entries(counts)
|
|
11
|
+
.map(([table, rows]) => `${table} ${rows}`)
|
|
12
|
+
.join(', ');
|
|
13
|
+
const KEY_IMPORT_REFUSALS = {
|
|
14
|
+
[KeyImportRefusal.enum.key_file_configured]: 'PATTY_DB_KEY_FILE is set: this install reads its key from that file, not from the keychain. Unset it to use the keychain',
|
|
15
|
+
[KeyImportRefusal.enum.key_env_configured]: 'PATTY_DB_KEY is set: this install reads its key from the environment, not from the keychain. Unset it to use the keychain',
|
|
16
|
+
[KeyImportRefusal.enum.keychain_holds_key]: `the OS keychain already holds a database key for this install; an import never replaces it. Remove the "${KEYCHAIN_SERVICE}" / "${DB_KEY_KEYCHAIN_ACCOUNT}" keychain entry yourself if you mean to`,
|
|
17
|
+
};
|
|
18
|
+
const NOTHING_WRITTEN = 'nothing was written';
|
|
19
|
+
const usersUnreadableMessage = (reason) => `cannot read the users of the database (${reason}). If it was last used by an older version, start ${PRODUCT_NAME} once (it migrates the database after its safety copy) and run the export again; ${NOTHING_WRITTEN}`;
|
|
20
|
+
const FIXED_STOP_MESSAGES = {
|
|
21
|
+
owner_unclaimed: `no administrator has a login yet, so there is no password to ask for: finish setting up ${PRODUCT_NAME} first ${TERMINAL_SETUP_HINT}`,
|
|
22
|
+
invalid_credentials: `${AUTH_MESSAGES.invalidCredentials} Too many attempts; ${NOTHING_WRITTEN}.`,
|
|
23
|
+
[EXPORT_DECLINED_CODE]: `not confirmed; ${NOTHING_WRITTEN}`,
|
|
24
|
+
};
|
|
25
|
+
const keyExportStopMessage = (stop) => stop.code === USERS_UNREADABLE_CODE ? usersUnreadableMessage(stop.reason) : FIXED_STOP_MESSAGES[stop.code];
|
|
26
|
+
const endedCredentials = (revoked) => `sessions ended: ${revoked.sessionsEnded}, tokens and sign-ins revoked: ${revoked.tokensRevoked}`;
|
|
27
|
+
/** What the command line says to the person who ran it. */
|
|
28
|
+
export const CLI_MESSAGES = {
|
|
29
|
+
ownerClaimed: (username) => `Owner claimed: "${username}". Log in to the dashboard (/ui) with this username and your password.`,
|
|
30
|
+
alreadyClaimed: (username) => `${PRODUCT_NAME} is already set up: the owner is "${username}".`,
|
|
31
|
+
passwordReset: (reset) => `Password reset for "${reset.username}".`,
|
|
32
|
+
sessionsEnded: (count) => `Sessions ended: ${count}`,
|
|
33
|
+
tokensRevoked: (count) => `Access tokens revoked: ${count}`,
|
|
34
|
+
resetting: (username) => `Choose a new password for "${username}".`,
|
|
35
|
+
noUsers: 'No users.',
|
|
36
|
+
userRow: (user) => [
|
|
37
|
+
(user.username ?? '(not set up yet)').padEnd(24),
|
|
38
|
+
user.role.padEnd(8),
|
|
39
|
+
user.status.padEnd(9),
|
|
40
|
+
`last login: ${user.lastLoginAt ?? 'never'}`,
|
|
41
|
+
].join(' '),
|
|
42
|
+
invited: (issued, link) => [
|
|
43
|
+
`Invite for "${issued.user.username}" (${issued.user.role}) — valid until ${issued.expiresAt}, single use, shown only now:`,
|
|
44
|
+
link === null
|
|
45
|
+
? ` Page: ${INVITE_PATH} on the server that runs this database (set PUBLIC_URL to print a link)`
|
|
46
|
+
: ` Link: ${link}`,
|
|
47
|
+
` Code: ${issued.code}`,
|
|
48
|
+
'They choose their own password; you never see it.',
|
|
49
|
+
].join('\n'),
|
|
50
|
+
reissueEnded: (revoked) => `Password cleared; ${endedCredentials(revoked)}. The invite is the only way back in.`,
|
|
51
|
+
disabled: (username, revoked) => `Disabled "${username}". ${endedCredentials(revoked)}.`,
|
|
52
|
+
enabled: (username) => `Enabled "${username}". They can log in again; their earlier sessions, tokens and sign-ins stay revoked.`,
|
|
53
|
+
roleSet: (username, role) => `"${username}" is now ${role}.`,
|
|
54
|
+
keyExported: (path) => [
|
|
55
|
+
`Database key written to ${path} (mode ${fileMode()}, never overwritten).`,
|
|
56
|
+
"Use it as PATTY_DB_KEY_FILE, or as the container's patty_db_key secret. Keep it away from the data and its backups.",
|
|
57
|
+
`Next: ${NPX_COMMAND} db export --to <file>, then follow ${MOVE_GUIDE}.`,
|
|
58
|
+
].join('\n'),
|
|
59
|
+
keyExportNeedsTerminal: 'exporting the database key needs a person at a terminal: run this command in an interactive terminal (it cannot be scripted)',
|
|
60
|
+
keyExportStopped: keyExportStopMessage,
|
|
61
|
+
keyExportWarning: (path) => [
|
|
62
|
+
`This writes the key that decrypts your ${PRODUCT_NAME} database to ${path} (mode ${fileMode()}, never overwritten).`,
|
|
63
|
+
'Whoever holds it and a copy of the database can read all your data.',
|
|
64
|
+
'Keep it somewhere safe, never in the same place as a backup of the database, and delete it once you have used it.',
|
|
65
|
+
].join('\n'),
|
|
66
|
+
snapshotExported: (path, counts) => [
|
|
67
|
+
`Database snapshot written to ${path} (mode ${fileMode()}, encrypted under the same key, never overwritten).`,
|
|
68
|
+
`Rows (whole database, every user): ${countsLine(counts)}`,
|
|
69
|
+
`Compare these after the move: ${MOVE_GUIDE}.`,
|
|
70
|
+
].join('\n'),
|
|
71
|
+
keyImported: () => [
|
|
72
|
+
'Database key stored in the OS keychain, where the server reads it.',
|
|
73
|
+
`Next: ${NPX_COMMAND} db import --from <snapshot>, then ${NPX_COMMAND} setup <client>.`,
|
|
74
|
+
].join('\n'),
|
|
75
|
+
snapshotImported: (path, counts) => [
|
|
76
|
+
`Database snapshot imported to ${path} (mode ${fileMode()}, never overwritten). Nothing was migrated: the next start does that, after its usual safety copy.`,
|
|
77
|
+
`Rows (whole database, every user): ${countsLine(counts)}`,
|
|
78
|
+
`Compare these with the export's: ${MOVE_GUIDE}. Next: ${NPX_COMMAND} setup <client>.`,
|
|
79
|
+
].join('\n'),
|
|
80
|
+
keyImportRefused: (refusal) => KEY_IMPORT_REFUSALS[refusal],
|
|
81
|
+
keyFileInvalid: 'the file does not hold a database key: expected 64 hexadecimal characters and at most one trailing newline (no spaces), as `key export` writes it',
|
|
82
|
+
keyDoesNotOpenDatabase: (path) => `the key does not open the database at ${path}; nothing was stored`,
|
|
83
|
+
keyDoesNotOpenSnapshot: (path) => `${path} does not open with this install's key, or is not a database; nothing was imported`,
|
|
84
|
+
noKeyToImport: `no database key found (PATTY_DB_KEY_FILE, PATTY_DB_KEY or the OS keychain); import the key first: ${NPX_COMMAND} key import --from <file>`,
|
|
85
|
+
snapshotNotStandalone: (path) => `${path} is not a standalone snapshot (a -wal or -journal file sits beside it); create one with \`${NPX_COMMAND} db export\``,
|
|
86
|
+
databaseLeftovers: (path) => `${path} has a leftover -wal, -shm or -journal file beside it; remove it yourself first, or it would be replayed on the imported database`,
|
|
87
|
+
importSourceMissing: (path) => `${path} does not exist or is not a file`,
|
|
88
|
+
importSourceUnreadable: (path) => `cannot read ${path}`,
|
|
89
|
+
databaseExists: (path) => `a database already exists at ${path}; an import never overwrites it. Move it away yourself if you mean to replace it`,
|
|
90
|
+
destinationExists: (path) => `${path} already exists; choose a new file (an export never overwrites)`,
|
|
91
|
+
destinationDirectoryMissing: (path) => `the directory of ${path} does not exist`,
|
|
92
|
+
keyBesideData: (directory) => `${directory} holds (or contains) the database; the key must never sit next to the data it unlocks. Choose another directory`,
|
|
93
|
+
snapshotIsDatabase: (path) => `${path} is the database itself; choose another file`,
|
|
94
|
+
failure: (reason) => `${LOG_PREFIX} ${reason}`,
|
|
95
|
+
unexpectedArgument: (argument) => `unexpected argument "${argument}"`,
|
|
96
|
+
};
|