@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
package/ui/app.js
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
// PATTY app shell client (ADR-027 Phase 1) — vanilla JS, no build step. Renders the dashboard
|
|
2
|
+
// menu from GET /api/dashboards, loads the selected dashboard's fragment from
|
|
3
|
+
// GET /api/dashboards/:name, and injects it into #content. Client-side navigation between
|
|
4
|
+
// dashboards never reloads the page. ADR-027 Phase 3 adds live update: one EventSource for the
|
|
5
|
+
// life of the page (fragment swaps never reopen it), forwarding each message to whichever
|
|
6
|
+
// fragment is currently loaded via the window.onAppDataChanged contract (see connectEvents
|
|
7
|
+
// below) — the shell knows nothing about a fragment's own sections, only that one may want to
|
|
8
|
+
// know when data changed.
|
|
9
|
+
(function () {
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
window.addEventListener('error', function (e) {
|
|
13
|
+
showDiagnosticError(e.error ? e.error.message + '\n' + e.error.stack : e.message);
|
|
14
|
+
});
|
|
15
|
+
window.addEventListener('unhandledrejection', function (e) {
|
|
16
|
+
showDiagnosticError('Unhandled Promise Rejection: ' + (e.reason ? (e.reason.stack || e.reason.message || e.reason) : e));
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function showDiagnosticError(message) {
|
|
20
|
+
console.error("DIAGNOSTIC ERROR CAUGHT:", message);
|
|
21
|
+
var errDiv = document.getElementById('shell-diagnostic-error');
|
|
22
|
+
if (!errDiv) {
|
|
23
|
+
errDiv = document.createElement('div');
|
|
24
|
+
errDiv.id = 'shell-diagnostic-error';
|
|
25
|
+
errDiv.style.cssText = 'position: fixed; top: 10px; right: 10px; left: 10px; background: rgba(220, 38, 38, 0.95); color: #fff; padding: 16px; border-radius: 8px; font-family: monospace; font-size: 12px; z-index: 10000; box-shadow: 0 4px 12px rgba(0,0,0,0.5); white-space: pre-wrap; overflow-y: auto; max-height: 200px; border: 1px solid #ef4444;';
|
|
26
|
+
var closeBtn = document.createElement('button');
|
|
27
|
+
closeBtn.textContent = '✕';
|
|
28
|
+
closeBtn.style.cssText = 'float: right; background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; margin-left: 10px;';
|
|
29
|
+
closeBtn.onclick = function() { errDiv.remove(); };
|
|
30
|
+
errDiv.appendChild(closeBtn);
|
|
31
|
+
var pre = document.createElement('pre');
|
|
32
|
+
pre.style.margin = '0';
|
|
33
|
+
pre.style.whiteSpace = 'pre-wrap';
|
|
34
|
+
pre.textContent = message;
|
|
35
|
+
errDiv.appendChild(pre);
|
|
36
|
+
document.body.appendChild(errDiv);
|
|
37
|
+
} else {
|
|
38
|
+
var existingPre = errDiv.querySelector('pre');
|
|
39
|
+
if (existingPre) existingPre.textContent += '\n\n' + message;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var DEFAULT_DASHBOARD_NAME = 'overview';
|
|
44
|
+
var UI_PATH_PREFIX = '/ui/';
|
|
45
|
+
var EVENTS_PATH = '/ui/events';
|
|
46
|
+
var currentLocale = 'en';
|
|
47
|
+
|
|
48
|
+
var DASHBOARD_ICONS = {
|
|
49
|
+
overview: 'fa-chart-pie',
|
|
50
|
+
accounts: 'fa-building-columns',
|
|
51
|
+
cards: 'fa-credit-card',
|
|
52
|
+
categories: 'fa-sitemap',
|
|
53
|
+
tags: 'fa-tags',
|
|
54
|
+
pending: 'fa-clock',
|
|
55
|
+
projections: 'fa-chart-line',
|
|
56
|
+
comparative: 'fa-scale-balanced',
|
|
57
|
+
dashboards: 'fa-sliders',
|
|
58
|
+
budget: 'fa-bullseye'
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var LOCALIZED_TOOLTIPS = {
|
|
62
|
+
en: {
|
|
63
|
+
overview: 'Overview',
|
|
64
|
+
accounts: 'Bank Accounts',
|
|
65
|
+
cards: 'Credit Cards',
|
|
66
|
+
categories: 'Categories',
|
|
67
|
+
tags: 'Tags',
|
|
68
|
+
pending: 'Pending',
|
|
69
|
+
projections: 'Projections',
|
|
70
|
+
comparative: 'Comparative',
|
|
71
|
+
dashboards: 'Dashboards Manager',
|
|
72
|
+
budget: 'Budget'
|
|
73
|
+
},
|
|
74
|
+
pt: {
|
|
75
|
+
overview: 'Visão Geral',
|
|
76
|
+
accounts: 'Contas Bancárias',
|
|
77
|
+
cards: 'Cartões de Crédito',
|
|
78
|
+
categories: 'Categorias',
|
|
79
|
+
tags: 'Tags',
|
|
80
|
+
pending: 'Pendentes',
|
|
81
|
+
projections: 'Projeções',
|
|
82
|
+
comparative: 'Comparativo',
|
|
83
|
+
dashboards: 'Gerenciador de Dashboards',
|
|
84
|
+
budget: 'Orçamento'
|
|
85
|
+
},
|
|
86
|
+
es: {
|
|
87
|
+
overview: 'Visión General',
|
|
88
|
+
accounts: 'Cuentas Bancarias',
|
|
89
|
+
cards: 'Tarjetas de Crédito',
|
|
90
|
+
categories: 'Categorías',
|
|
91
|
+
tags: 'Tags',
|
|
92
|
+
pending: 'Pendientes',
|
|
93
|
+
projections: 'Proyecciones',
|
|
94
|
+
comparative: 'Comparativo',
|
|
95
|
+
dashboards: 'Gestor de Dashboards',
|
|
96
|
+
budget: 'Presupuesto'
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Module-scope, not local to connectEvents() — an EventSource with no surviving reference to the
|
|
101
|
+
// object itself risks being garbage-collected in some implementations even with a handler
|
|
102
|
+
// attached, which would silently stop live update. Also guards connectEvents() itself against
|
|
103
|
+
// ever opening a second connection.
|
|
104
|
+
var eventSource = null;
|
|
105
|
+
|
|
106
|
+
var Api = {
|
|
107
|
+
status: '/api/status',
|
|
108
|
+
dashboards: '/api/dashboards',
|
|
109
|
+
currencies: '/api/currencies',
|
|
110
|
+
preferences: '/api/preferences',
|
|
111
|
+
dashboard: function (name) {
|
|
112
|
+
return '/api/dashboards/' + encodeURIComponent(name);
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// Keyed by code — window.formatMoney (ui/money.js) reads this to format a currency Intl's
|
|
117
|
+
// currency mode can't handle correctly: USDC (4 letters) throws, BTC (3 letters, syntactically
|
|
118
|
+
// valid) doesn't throw but silently mis-formats with fiat-shaped precision and no real symbol.
|
|
119
|
+
// Both fall back to this currency's own symbol/decimals instead.
|
|
120
|
+
function indexCurrenciesByCode(currencies) {
|
|
121
|
+
var map = {};
|
|
122
|
+
(currencies || []).forEach(function (c) {
|
|
123
|
+
map[c.code] = c;
|
|
124
|
+
});
|
|
125
|
+
return map;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function h(tag, props, children) {
|
|
129
|
+
var el = document.createElement(tag);
|
|
130
|
+
if (props) {
|
|
131
|
+
Object.keys(props).forEach(function (key) {
|
|
132
|
+
if (key === 'class') el.className = props[key];
|
|
133
|
+
else if (key === 'text') el.textContent = props[key];
|
|
134
|
+
else el.setAttribute(key, props[key]);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
(children || []).forEach(function (child) {
|
|
138
|
+
if (typeof child === 'string') el.appendChild(document.createTextNode(child));
|
|
139
|
+
else if (child) el.appendChild(child);
|
|
140
|
+
});
|
|
141
|
+
return el;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function clearNode(el) {
|
|
145
|
+
while (el.firstChild) el.removeChild(el.firstChild);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function setLoading(el, message) {
|
|
149
|
+
clearNode(el);
|
|
150
|
+
el.appendChild(h('p', { class: 'state', text: message }));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function setError(el, message) {
|
|
154
|
+
clearNode(el);
|
|
155
|
+
el.appendChild(h('p', { class: 'state state-error', role: 'alert', text: 'Could not load: ' + message }));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function fetchJson(path) {
|
|
159
|
+
return fetch(path, { headers: { accept: 'application/json' } }).then(function (res) {
|
|
160
|
+
if (res.ok) return res.json();
|
|
161
|
+
return res
|
|
162
|
+
.json()
|
|
163
|
+
.catch(function () {
|
|
164
|
+
return null;
|
|
165
|
+
})
|
|
166
|
+
.then(function (body) {
|
|
167
|
+
var detail = res.statusText;
|
|
168
|
+
if (body && body.error && Array.isArray(body.error.issues) && body.error.issues.length) {
|
|
169
|
+
detail = body.error.issues.join(', ');
|
|
170
|
+
} else if (body && body.error && body.error.code) {
|
|
171
|
+
detail = body.error.code;
|
|
172
|
+
}
|
|
173
|
+
throw new Error('Request failed (' + res.status + '): ' + detail);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Only the first path segment after /ui/ names the dashboard — anything past that (there is no
|
|
179
|
+
// such route today) is ignored rather than rejected, so a stray trailing slash still resolves.
|
|
180
|
+
function currentDashboardName() {
|
|
181
|
+
var path = window.location.pathname;
|
|
182
|
+
if (path.indexOf(UI_PATH_PREFIX) !== 0) return DEFAULT_DASHBOARD_NAME;
|
|
183
|
+
var name = path.slice(UI_PATH_PREFIX.length).split('/')[0];
|
|
184
|
+
return name ? decodeURIComponent(name) : DEFAULT_DASHBOARD_NAME;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function nameFromMenuHref(href) {
|
|
188
|
+
return decodeURIComponent(href.slice(UI_PATH_PREFIX.length));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// A fragment's <script> tags are inert once injected via innerHTML — replacing each with a
|
|
192
|
+
// freshly created <script> element is what actually triggers execution once it lands back in
|
|
193
|
+
// the live document. The fragment's own script runs its init synchronously at this point (it
|
|
194
|
+
// can't rely on DOMContentLoaded, which only ever fires once for the whole shell page).
|
|
195
|
+
function executeScripts(container) {
|
|
196
|
+
container.querySelectorAll('script').forEach(function (oldScript) {
|
|
197
|
+
// save_dashboard already rejects a src= script server-side (fragments carry zero external
|
|
198
|
+
// references — the shell owns Chart.js now), but a row saved before that check existed
|
|
199
|
+
// could still carry one; never execute it client-side either.
|
|
200
|
+
if (oldScript.hasAttribute('src')) {
|
|
201
|
+
oldScript.remove();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
var newScript = document.createElement('script');
|
|
205
|
+
for (var i = 0; i < oldScript.attributes.length; i++) {
|
|
206
|
+
var attr = oldScript.attributes[i];
|
|
207
|
+
newScript.setAttribute(attr.name, attr.value);
|
|
208
|
+
}
|
|
209
|
+
newScript.textContent = oldScript.textContent;
|
|
210
|
+
oldScript.replaceWith(newScript);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function renderFragment(container, html) {
|
|
215
|
+
// Reset before tearing down the outgoing fragment's DOM, not after injecting the new one — a
|
|
216
|
+
// stale closure referencing already-removed elements must never fire again, and a fragment
|
|
217
|
+
// whose own script errors before reaching its own registration simply gets no live update
|
|
218
|
+
// rather than the previous fragment's.
|
|
219
|
+
window.onAppDataChanged = null;
|
|
220
|
+
clearNode(container);
|
|
221
|
+
var temp = document.createElement('div');
|
|
222
|
+
temp.innerHTML = html;
|
|
223
|
+
while (temp.firstChild) container.appendChild(temp.firstChild);
|
|
224
|
+
executeScripts(container);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// The server marks <body> on a demo database (Feature Design 022 §5); titles set after load keep the prefix.
|
|
228
|
+
function demoTitlePrefix() {
|
|
229
|
+
return document.body.getAttribute('data-instance-kind') === 'demo' ? '[Demo] ' : '';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function loadDashboard(name) {
|
|
233
|
+
var container = document.getElementById('content');
|
|
234
|
+
setLoading(container, 'Loading dashboard…');
|
|
235
|
+
return fetchJson(Api.dashboard(name) + '?t=' + Date.now())
|
|
236
|
+
.then(function (dashboard) {
|
|
237
|
+
document.title = demoTitlePrefix() + 'PATTY — ' + dashboard.name;
|
|
238
|
+
renderFragment(container, dashboard.html);
|
|
239
|
+
})
|
|
240
|
+
.catch(function (err) {
|
|
241
|
+
setError(container, err.message);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function menuLink(dashboard, activeName) {
|
|
246
|
+
var key = dashboard.name.toLowerCase();
|
|
247
|
+
var tooltipText = dashboard.name;
|
|
248
|
+
var iconClass = DASHBOARD_ICONS[key] || 'fa-chart-simple';
|
|
249
|
+
|
|
250
|
+
var dict = LOCALIZED_TOOLTIPS[currentLocale] || LOCALIZED_TOOLTIPS['en'];
|
|
251
|
+
if (dict && dict[key]) {
|
|
252
|
+
tooltipText = dict[key];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
var iconEl = h('i', { class: 'fa-solid ' + iconClass });
|
|
256
|
+
var link = h('a', {
|
|
257
|
+
href: UI_PATH_PREFIX + encodeURIComponent(dashboard.name),
|
|
258
|
+
title: tooltipText,
|
|
259
|
+
'aria-label': tooltipText
|
|
260
|
+
}, [iconEl]);
|
|
261
|
+
|
|
262
|
+
if (dashboard.name === activeName) {
|
|
263
|
+
link.classList.add('active');
|
|
264
|
+
link.setAttribute('aria-current', 'page');
|
|
265
|
+
}
|
|
266
|
+
return link;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function dropdownLink(dashboard, activeName) {
|
|
270
|
+
var key = dashboard.name.toLowerCase();
|
|
271
|
+
var displayText = dashboard.name;
|
|
272
|
+
var iconClass = DASHBOARD_ICONS[key] || 'fa-chart-simple';
|
|
273
|
+
|
|
274
|
+
var dict = LOCALIZED_TOOLTIPS[currentLocale] || LOCALIZED_TOOLTIPS['en'];
|
|
275
|
+
if (dict && dict[key]) {
|
|
276
|
+
displayText = dict[key];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
var iconEl = h('i', { class: 'fa-solid ' + iconClass });
|
|
280
|
+
var link = h('a', { href: UI_PATH_PREFIX + encodeURIComponent(dashboard.name) }, [iconEl, ' ' + displayText]);
|
|
281
|
+
|
|
282
|
+
if (dashboard.name === activeName) {
|
|
283
|
+
link.classList.add('active');
|
|
284
|
+
}
|
|
285
|
+
return link;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ADR-027 Phase 2: file-backed defaults get a fixed slot in mainSequence/dropdownSequence below;
|
|
289
|
+
// inline (custom) dashboards are never in either list, so they always fall through to the
|
|
290
|
+
// dropdown, after a divider once at least one exists.
|
|
291
|
+
function renderMenu(dashboards, activeName) {
|
|
292
|
+
var nav = document.getElementById('dashboard-menu');
|
|
293
|
+
clearNode(nav);
|
|
294
|
+
var dropdown = document.getElementById('more-dropdown');
|
|
295
|
+
clearNode(dropdown);
|
|
296
|
+
|
|
297
|
+
// Order of items in the main sidebar list:
|
|
298
|
+
var mainSequence = ['overview', 'pending', 'budget', 'comparative', 'projections', 'accounts', 'cards'];
|
|
299
|
+
// Order of items in the dropdown list:
|
|
300
|
+
var dropdownSequence = ['categories', 'tags', 'dashboards'];
|
|
301
|
+
|
|
302
|
+
// Map by name lowercase for fast lookup
|
|
303
|
+
var dbMap = {};
|
|
304
|
+
dashboards.forEach(function(d) {
|
|
305
|
+
dbMap[d.name.toLowerCase()] = d;
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// 1. Render main sequence icons
|
|
309
|
+
mainSequence.forEach(function(nameKey) {
|
|
310
|
+
var d = dbMap[nameKey];
|
|
311
|
+
if (d) {
|
|
312
|
+
nav.appendChild(menuLink(d, activeName));
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// 2. Render dropdown sequence text items
|
|
317
|
+
dropdownSequence.forEach(function(nameKey) {
|
|
318
|
+
var d = dbMap[nameKey];
|
|
319
|
+
if (d) {
|
|
320
|
+
dropdown.appendChild(dropdownLink(d, activeName));
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// 3. Render any custom (user-uploaded) dashboards inside the dropdown as well
|
|
325
|
+
var customs = dashboards.filter(function(d) {
|
|
326
|
+
var key = d.name.toLowerCase();
|
|
327
|
+
return d.source !== 'file' && mainSequence.indexOf(key) === -1 && dropdownSequence.indexOf(key) === -1;
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
if (customs.length > 0) {
|
|
331
|
+
var divider = h('hr', { class: 'sidebar-divider', style: 'width: 90%; margin: 0.25rem auto;' });
|
|
332
|
+
dropdown.appendChild(divider);
|
|
333
|
+
customs.forEach(function(d) {
|
|
334
|
+
dropdown.appendChild(dropdownLink(d, activeName));
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function updateActiveMenuLink(activeName) {
|
|
340
|
+
document.querySelectorAll('#dashboard-menu a, #more-dropdown a').forEach(function (link) {
|
|
341
|
+
var isActive = nameFromMenuHref(link.getAttribute('href')) === activeName;
|
|
342
|
+
link.classList.toggle('active', isActive);
|
|
343
|
+
if (isActive) link.setAttribute('aria-current', 'page');
|
|
344
|
+
else link.removeAttribute('aria-current');
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function navigate(name, push) {
|
|
349
|
+
if (push) window.history.pushState(null, '', UI_PATH_PREFIX + encodeURIComponent(name));
|
|
350
|
+
updateActiveMenuLink(name);
|
|
351
|
+
return loadDashboard(name);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
window.addEventListener('popstate', function () {
|
|
355
|
+
navigate(currentDashboardName(), false);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// ADR-027 Phase 3 — live update. Opened once, for the page's whole lifetime; fragment swaps
|
|
359
|
+
// (navigate/renderFragment above) never touch this connection, only the
|
|
360
|
+
// window.onAppDataChanged slot it delivers into. EventSource reconnects on its own after a
|
|
361
|
+
// drop (the browser's built-in retry), so no reconnect logic is needed here; a message that
|
|
362
|
+
// arrives with no fragment currently registered (or between "torn down" and "registered again")
|
|
363
|
+
// is simply dropped — the next live-relevant fetch a user triggers (period change, manual
|
|
364
|
+
// refresh) always reflects current data regardless.
|
|
365
|
+
function connectEvents() {
|
|
366
|
+
if (typeof EventSource === 'undefined' || eventSource) return;
|
|
367
|
+
eventSource = new EventSource(EVENTS_PATH);
|
|
368
|
+
eventSource.onmessage = function (event) {
|
|
369
|
+
var payload;
|
|
370
|
+
try {
|
|
371
|
+
payload = JSON.parse(event.data);
|
|
372
|
+
} catch {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (!Array.isArray(payload.entities)) return;
|
|
376
|
+
var forward = function () {
|
|
377
|
+
if (typeof window.onAppDataChanged === 'function') window.onAppDataChanged(payload.entities);
|
|
378
|
+
};
|
|
379
|
+
if (payload.entities.indexOf('userSettings') === -1) return forward();
|
|
380
|
+
// A base-currency change updates the default before the fragment re-renders with it.
|
|
381
|
+
fetchJson(Api.preferences)
|
|
382
|
+
.then(function (prefs) {
|
|
383
|
+
window.setBaseCurrency(prefs && prefs.baseCurrency);
|
|
384
|
+
})
|
|
385
|
+
.catch(function (err) {
|
|
386
|
+
console.error('Could not refresh preferences:', err);
|
|
387
|
+
})
|
|
388
|
+
.then(forward);
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
393
|
+
var menu = document.getElementById('dashboard-menu');
|
|
394
|
+
menu.addEventListener('click', function (event) {
|
|
395
|
+
var link = event.target.closest('a');
|
|
396
|
+
if (!link) return;
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
navigate(nameFromMenuHref(link.getAttribute('href')), true);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
var dropdown = document.getElementById('more-dropdown');
|
|
402
|
+
var moreContainer = document.getElementById('more-container');
|
|
403
|
+
var moreBtn = document.getElementById('more-btn');
|
|
404
|
+
|
|
405
|
+
if (dropdown && moreContainer && moreBtn) {
|
|
406
|
+
var setMoreOpen = function (open) {
|
|
407
|
+
moreContainer.classList.toggle('open', open);
|
|
408
|
+
moreBtn.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
dropdown.addEventListener('click', function (event) {
|
|
412
|
+
var link = event.target.closest('a');
|
|
413
|
+
if (!link) return;
|
|
414
|
+
event.preventDefault();
|
|
415
|
+
setMoreOpen(false);
|
|
416
|
+
navigate(nameFromMenuHref(link.getAttribute('href')), true);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
moreBtn.addEventListener('click', function (event) {
|
|
420
|
+
event.stopPropagation();
|
|
421
|
+
setMoreOpen(!moreContainer.classList.contains('open'));
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
document.addEventListener('click', function () {
|
|
425
|
+
setMoreOpen(false);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
var initialName = currentDashboardName();
|
|
430
|
+
|
|
431
|
+
// Currency metadata (symbol/decimals) must be cached before the first dashboard renders — its
|
|
432
|
+
// fragment script calls window.formatMoney synchronously while rendering, with no re-render on
|
|
433
|
+
// late-arriving data. Sequenced with locale (both fast local calls); the dashboards list fetch
|
|
434
|
+
// (menu chrome) stays parallel to content, same as before this sequencing existed.
|
|
435
|
+
var bootPromise = fetchJson(Api.status)
|
|
436
|
+
.then(function (status) {
|
|
437
|
+
if (status && status.locale) {
|
|
438
|
+
currentLocale = status.locale;
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
.catch(function () {
|
|
442
|
+
// Fallback to English silently
|
|
443
|
+
})
|
|
444
|
+
.then(function () {
|
|
445
|
+
return fetchJson(Api.currencies);
|
|
446
|
+
})
|
|
447
|
+
.then(function (currencies) {
|
|
448
|
+
window.__appCurrencies = indexCurrenciesByCode(currencies);
|
|
449
|
+
})
|
|
450
|
+
.catch(function (err) {
|
|
451
|
+
// Fiat (BRL/USD) is unaffected — formatMoney's ISO path never reads this metadata. A
|
|
452
|
+
// crypto amount (BTC/USDC) would silently degrade to fiat-shaped 2-decimal precision and
|
|
453
|
+
// no real symbol without it, which is exactly the wrong-precision-with-no-signal gotcha
|
|
454
|
+
// this file exists to avoid — so surface it loudly instead of proceeding silently.
|
|
455
|
+
window.__appCurrencies = window.__appCurrencies || {};
|
|
456
|
+
showDiagnosticError(
|
|
457
|
+
'Could not load currency metadata: ' +
|
|
458
|
+
err.message +
|
|
459
|
+
'. Crypto amounts (BTC/USDC) may display at the wrong precision until this is refreshed.',
|
|
460
|
+
);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
// Base currency resolves before any fragment renders (a fragment reads DEFAULT_CURRENCY
|
|
464
|
+
// synchronously); a failure keeps the last-resort default and never blocks the page.
|
|
465
|
+
bootPromise = bootPromise
|
|
466
|
+
.then(function () {
|
|
467
|
+
return fetchJson(Api.preferences);
|
|
468
|
+
})
|
|
469
|
+
.then(function (prefs) {
|
|
470
|
+
window.setBaseCurrency(prefs && prefs.baseCurrency);
|
|
471
|
+
})
|
|
472
|
+
.catch(function (err) {
|
|
473
|
+
console.error('Could not load preferences; keeping the default currency:', err);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
bootPromise.then(function () {
|
|
477
|
+
return loadDashboard(initialName);
|
|
478
|
+
}).then(function () {
|
|
479
|
+
connectEvents();
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
bootPromise
|
|
483
|
+
.then(function () {
|
|
484
|
+
return fetchJson(Api.dashboards);
|
|
485
|
+
})
|
|
486
|
+
.then(function (dashboards) {
|
|
487
|
+
renderMenu(dashboards, initialName);
|
|
488
|
+
})
|
|
489
|
+
.catch(function (err) {
|
|
490
|
+
setError(menu, err.message);
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>PATTY — connect a client</title>
|
|
7
|
+
<link rel="stylesheet" href="{{stylesheet}}" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main class="auth-card">
|
|
11
|
+
<h1>{{heading}}</h1>
|
|
12
|
+
<p class="auth-lede" data-testid="connect-result">{{message}}</p>
|
|
13
|
+
{{next}}
|
|
14
|
+
</main>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
package/ui/connect.html
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>PATTY — connect a client</title>
|
|
7
|
+
<link rel="stylesheet" href="{{stylesheet}}" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main class="auth-card">
|
|
11
|
+
<h1>Connect a client</h1>
|
|
12
|
+
<p class="auth-lede">A program is asking to sign in to PATTY as you.</p>
|
|
13
|
+
{{error}}
|
|
14
|
+
<dl class="connect-facts">
|
|
15
|
+
<dt>Client <span class="connect-note">(reported by the client)</span></dt>
|
|
16
|
+
<dd>{{clientName}} <span class="connect-note">{{clientVersion}}</span></dd>
|
|
17
|
+
<dt>Profile</dt>
|
|
18
|
+
<dd>{{profile}}</dd>
|
|
19
|
+
<dt>Requested</dt>
|
|
20
|
+
<dd>{{requestedAt}}</dd>
|
|
21
|
+
<dt>Code</dt>
|
|
22
|
+
<dd class="connect-code" data-testid="connect-code">{{userCode}}</dd>
|
|
23
|
+
</dl>
|
|
24
|
+
<p class="auth-warning" role="note">
|
|
25
|
+
Only approve if you just asked a Claude session on this machine to connect, and the code above is the one it
|
|
26
|
+
showed you.
|
|
27
|
+
</p>
|
|
28
|
+
<form class="auth-form connect-form" method="post" action="{{action}}">
|
|
29
|
+
<input type="hidden" name="code" value="{{userCode}}" />
|
|
30
|
+
<fieldset>
|
|
31
|
+
<legend>Access</legend>
|
|
32
|
+
{{accessOptions}}
|
|
33
|
+
</fieldset>
|
|
34
|
+
<fieldset>
|
|
35
|
+
<legend>Stay signed in for</legend>
|
|
36
|
+
{{durationOptions}}
|
|
37
|
+
</fieldset>
|
|
38
|
+
<label class="connect-password"
|
|
39
|
+
>Your password, to approve
|
|
40
|
+
<input
|
|
41
|
+
type="password"
|
|
42
|
+
name="{{passwordName}}"
|
|
43
|
+
autocomplete="current-password"
|
|
44
|
+
maxlength="{{passwordMaxLength}}"
|
|
45
|
+
required
|
|
46
|
+
/>
|
|
47
|
+
</label>
|
|
48
|
+
<button type="submit" name="decision" value="approve">Approve</button>
|
|
49
|
+
<button type="submit" name="decision" value="deny" class="connect-deny" formnovalidate>Deny</button>
|
|
50
|
+
</form>
|
|
51
|
+
</main>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|