@rfc0/patty 0.0.0-stage → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +214 -2
  3. package/dist/adapters/access-tokens.js +7 -0
  4. package/dist/adapters/accounts.js +37 -0
  5. package/dist/adapters/auth.js +11 -0
  6. package/dist/adapters/bills.js +32 -0
  7. package/dist/adapters/budgets.js +29 -0
  8. package/dist/adapters/categories.js +32 -0
  9. package/dist/adapters/client-grants.js +7 -0
  10. package/dist/adapters/credit-cards.js +33 -0
  11. package/dist/adapters/currencies.js +2 -0
  12. package/dist/adapters/currency-rates.js +18 -0
  13. package/dist/adapters/dashboards.js +43 -0
  14. package/dist/adapters/demo.js +13 -0
  15. package/dist/adapters/instance-settings.js +7 -0
  16. package/dist/adapters/invites.js +7 -0
  17. package/dist/adapters/recurring.js +55 -0
  18. package/dist/adapters/sessions.js +7 -0
  19. package/dist/adapters/settings.js +4 -0
  20. package/dist/adapters/setup-codes.js +7 -0
  21. package/dist/adapters/tags.js +9 -0
  22. package/dist/adapters/transactions.js +95 -0
  23. package/dist/adapters/users.js +7 -0
  24. package/dist/common/build-version.js +5 -0
  25. package/dist/common/errors.js +118 -0
  26. package/dist/common/net.js +71 -0
  27. package/dist/common/result.js +7 -0
  28. package/dist/composition/auth.js +106 -0
  29. package/dist/composition/boot.js +27 -0
  30. package/dist/composition/cli.js +86 -0
  31. package/dist/composition/demo/seed.js +92 -0
  32. package/dist/composition/demo/shell.js +107 -0
  33. package/dist/composition/export.js +89 -0
  34. package/dist/composition/http.js +110 -0
  35. package/dist/composition/import.js +55 -0
  36. package/dist/composition/lazy-modules.js +2 -0
  37. package/dist/composition/runtime.js +115 -0
  38. package/dist/composition/sign-in/interpreter.js +154 -0
  39. package/dist/composition/sign-in/server.js +36 -0
  40. package/dist/composition/sign-in/wiring.js +23 -0
  41. package/dist/composition/stdio.js +69 -0
  42. package/dist/config.js +136 -0
  43. package/dist/controllers/account/account.js +88 -0
  44. package/dist/controllers/account/transaction.js +119 -0
  45. package/dist/controllers/account/transfer.js +34 -0
  46. package/dist/controllers/aggregate.js +40 -0
  47. package/dist/controllers/auth/access-tokens.js +61 -0
  48. package/dist/controllers/auth/grants.js +136 -0
  49. package/dist/controllers/auth/key-export.js +20 -0
  50. package/dist/controllers/auth/owner.js +80 -0
  51. package/dist/controllers/auth/password.js +35 -0
  52. package/dist/controllers/auth/session.js +50 -0
  53. package/dist/controllers/auth/step-up.js +8 -0
  54. package/dist/controllers/auth/users.js +183 -0
  55. package/dist/controllers/budgets.js +87 -0
  56. package/dist/controllers/categories.js +67 -0
  57. package/dist/controllers/correlations.js +112 -0
  58. package/dist/controllers/credit-card/bill.js +105 -0
  59. package/dist/controllers/credit-card/credit-card.js +129 -0
  60. package/dist/controllers/credit-card/transaction.js +181 -0
  61. package/dist/controllers/currencies.js +1 -0
  62. package/dist/controllers/currency-rates.js +40 -0
  63. package/dist/controllers/dashboards.js +68 -0
  64. package/dist/controllers/demo/seed.js +31 -0
  65. package/dist/controllers/demo/tour.js +12 -0
  66. package/dist/controllers/deps.js +6 -0
  67. package/dist/controllers/instance.js +6 -0
  68. package/dist/controllers/merchants.js +12 -0
  69. package/dist/controllers/recurring.js +70 -0
  70. package/dist/controllers/resolve.js +37 -0
  71. package/dist/controllers/settings.js +47 -0
  72. package/dist/controllers/status.js +19 -0
  73. package/dist/controllers/summary.js +21 -0
  74. package/dist/controllers/tags.js +19 -0
  75. package/dist/controllers/transaction/bulk.js +6 -0
  76. package/dist/controllers/transaction/core.js +49 -0
  77. package/dist/controllers/transaction/read.js +28 -0
  78. package/dist/diplomat/auth/credentials.js +58 -0
  79. package/dist/diplomat/auth/sign-in-store.js +18 -0
  80. package/dist/diplomat/cli/commands/auth.js +100 -0
  81. package/dist/diplomat/cli/commands/db.js +72 -0
  82. package/dist/diplomat/cli/commands/demo.js +68 -0
  83. package/dist/diplomat/cli/commands/key.js +119 -0
  84. package/dist/diplomat/cli/commands/login.js +151 -0
  85. package/dist/diplomat/cli/commands/setup.js +132 -0
  86. package/dist/diplomat/cli/commands/users.js +123 -0
  87. package/dist/diplomat/cli/commands.js +61 -0
  88. package/dist/diplomat/cli/export-file.js +37 -0
  89. package/dist/diplomat/cli/import-file.js +44 -0
  90. package/dist/diplomat/cli/io.js +61 -0
  91. package/dist/diplomat/cli/key-export-approval.js +37 -0
  92. package/dist/diplomat/cli/messages.js +96 -0
  93. package/dist/diplomat/cli/prompt.js +74 -0
  94. package/dist/diplomat/cli/terminal.js +81 -0
  95. package/dist/diplomat/client-config/clients.js +150 -0
  96. package/dist/diplomat/client-config/merge.js +41 -0
  97. package/dist/diplomat/db/bootstrap.js +98 -0
  98. package/dist/diplomat/db/database-files.js +147 -0
  99. package/dist/diplomat/db/driver.js +167 -0
  100. package/dist/diplomat/db/effects.js +101 -0
  101. package/dist/diplomat/db/engine.js +9 -0
  102. package/dist/diplomat/db/export.js +22 -0
  103. package/dist/diplomat/db/file-lock.js +82 -0
  104. package/dist/diplomat/db/key-lock.js +14 -0
  105. package/dist/diplomat/db/locale-cache.js +23 -0
  106. package/dist/diplomat/db/migration-barrier.js +57 -0
  107. package/dist/diplomat/db/migration-journal.js +18 -0
  108. package/dist/diplomat/db/migration-lock.js +15 -0
  109. package/dist/diplomat/db/migrations.js +11 -0
  110. package/dist/diplomat/db/present.js +17 -0
  111. package/dist/diplomat/db/queries/aggregate-whitelist.js +35 -0
  112. package/dist/diplomat/db/queries/filters.js +59 -0
  113. package/dist/diplomat/db/queries/fts.js +18 -0
  114. package/dist/diplomat/db/queries/scope.js +8 -0
  115. package/dist/diplomat/db/queries/transaction-select.js +26 -0
  116. package/dist/diplomat/db/queries/tx-predicates.js +13 -0
  117. package/dist/diplomat/db/repos/access-tokens.js +27 -0
  118. package/dist/diplomat/db/repos/accounts.js +91 -0
  119. package/dist/diplomat/db/repos/bills.js +93 -0
  120. package/dist/diplomat/db/repos/budgets.js +72 -0
  121. package/dist/diplomat/db/repos/categories.js +53 -0
  122. package/dist/diplomat/db/repos/client-grants.js +67 -0
  123. package/dist/diplomat/db/repos/correlations.js +66 -0
  124. package/dist/diplomat/db/repos/credit-cards.js +67 -0
  125. package/dist/diplomat/db/repos/currencies.js +8 -0
  126. package/dist/diplomat/db/repos/currency-rates.js +40 -0
  127. package/dist/diplomat/db/repos/dashboards.js +123 -0
  128. package/dist/diplomat/db/repos/health.js +12 -0
  129. package/dist/diplomat/db/repos/instance-settings.js +14 -0
  130. package/dist/diplomat/db/repos/instance.js +58 -0
  131. package/dist/diplomat/db/repos/invites.js +43 -0
  132. package/dist/diplomat/db/repos/merchants.js +121 -0
  133. package/dist/diplomat/db/repos/recurring.js +29 -0
  134. package/dist/diplomat/db/repos/sessions.js +19 -0
  135. package/dist/diplomat/db/repos/settings.js +41 -0
  136. package/dist/diplomat/db/repos/setup-codes.js +28 -0
  137. package/dist/diplomat/db/repos/sub-categories.js +67 -0
  138. package/dist/diplomat/db/repos/tags.js +51 -0
  139. package/dist/diplomat/db/repos/transaction-tags.js +57 -0
  140. package/dist/diplomat/db/repos/transactions.js +163 -0
  141. package/dist/diplomat/db/repos/users.js +47 -0
  142. package/dist/diplomat/db/safety-copy.js +87 -0
  143. package/dist/diplomat/db/schema.js +348 -0
  144. package/dist/diplomat/db/seed/categories.js +112 -0
  145. package/dist/diplomat/db/seed/currencies.js +9 -0
  146. package/dist/diplomat/db/seed/demo/br.js +98 -0
  147. package/dist/diplomat/db/seed/demo/co.js +89 -0
  148. package/dist/diplomat/db/seed/demo/index.js +12 -0
  149. package/dist/diplomat/db/seed/demo/mx.js +90 -0
  150. package/dist/diplomat/db/seed/demo/shared.js +39 -0
  151. package/dist/diplomat/db/seed/demo/us.js +90 -0
  152. package/dist/diplomat/db/seed/merchant-rules.js +188 -0
  153. package/dist/diplomat/db/sqlite-errors.js +40 -0
  154. package/dist/diplomat/db/tenancy-integrity.js +45 -0
  155. package/dist/diplomat/db/version-guard.js +16 -0
  156. package/dist/diplomat/http/auth-pages.js +41 -0
  157. package/dist/diplomat/http/auth-paths.js +46 -0
  158. package/dist/diplomat/http/bearer.js +15 -0
  159. package/dist/diplomat/http/connect-pages.js +51 -0
  160. package/dist/diplomat/http/context.js +17 -0
  161. package/dist/diplomat/http/cookies.js +27 -0
  162. package/dist/diplomat/http/form-pages.js +38 -0
  163. package/dist/diplomat/http/hooks/auth.js +106 -0
  164. package/dist/diplomat/http/hooks/demo-marker.js +59 -0
  165. package/dist/diplomat/http/openapi.js +73 -0
  166. package/dist/diplomat/http/principal.js +1 -0
  167. package/dist/diplomat/http/rate-limiter.js +78 -0
  168. package/dist/diplomat/http/remedy.js +26 -0
  169. package/dist/diplomat/http/respond.js +50 -0
  170. package/dist/diplomat/http/routes/account.js +226 -0
  171. package/dist/diplomat/http/routes/aggregate.js +28 -0
  172. package/dist/diplomat/http/routes/auth.js +105 -0
  173. package/dist/diplomat/http/routes/budget.js +34 -0
  174. package/dist/diplomat/http/routes/category.js +109 -0
  175. package/dist/diplomat/http/routes/connect.js +124 -0
  176. package/dist/diplomat/http/routes/credit-card.js +263 -0
  177. package/dist/diplomat/http/routes/currency-rates.js +60 -0
  178. package/dist/diplomat/http/routes/currency.js +16 -0
  179. package/dist/diplomat/http/routes/dashboard.js +93 -0
  180. package/dist/diplomat/http/routes/invite.js +63 -0
  181. package/dist/diplomat/http/routes/recurring.js +65 -0
  182. package/dist/diplomat/http/routes/settings.js +38 -0
  183. package/dist/diplomat/http/routes/summary.js +23 -0
  184. package/dist/diplomat/http/routes/system.js +29 -0
  185. package/dist/diplomat/http/routes/tag.js +51 -0
  186. package/dist/diplomat/http/routes/tokens.js +72 -0
  187. package/dist/diplomat/http/routes/transaction.js +55 -0
  188. package/dist/diplomat/http/routes/transfer.js +35 -0
  189. package/dist/diplomat/http/routes/ui.js +110 -0
  190. package/dist/diplomat/http/routes/users.js +156 -0
  191. package/dist/diplomat/http/routes/well-known.js +26 -0
  192. package/dist/diplomat/http/routes.js +85 -0
  193. package/dist/diplomat/http/session.js +34 -0
  194. package/dist/diplomat/http/token-pages.js +75 -0
  195. package/dist/diplomat/http/ui-files.js +21 -0
  196. package/dist/diplomat/http/user-pages.js +93 -0
  197. package/dist/diplomat/mcp/annotations.js +8 -0
  198. package/dist/diplomat/mcp/auth-info.js +20 -0
  199. package/dist/diplomat/mcp/context.js +14 -0
  200. package/dist/diplomat/mcp/definition.js +3 -0
  201. package/dist/diplomat/mcp/gate.js +15 -0
  202. package/dist/diplomat/mcp/instructions.js +19 -0
  203. package/dist/diplomat/mcp/prompts.js +125 -0
  204. package/dist/diplomat/mcp/register.js +12 -0
  205. package/dist/diplomat/mcp/remedy.js +17 -0
  206. package/dist/diplomat/mcp/resources.js +93 -0
  207. package/dist/diplomat/mcp/respond.js +20 -0
  208. package/dist/diplomat/mcp/route.js +62 -0
  209. package/dist/diplomat/mcp/scopes.js +53 -0
  210. package/dist/diplomat/mcp/server.js +26 -0
  211. package/dist/diplomat/mcp/shared.js +5 -0
  212. package/dist/diplomat/mcp/stdio-session.js +94 -0
  213. package/dist/diplomat/mcp/stdio.js +23 -0
  214. package/dist/diplomat/mcp/tool-name.js +59 -0
  215. package/dist/diplomat/mcp/tools/account.js +218 -0
  216. package/dist/diplomat/mcp/tools/aggregate.js +32 -0
  217. package/dist/diplomat/mcp/tools/budget.js +99 -0
  218. package/dist/diplomat/mcp/tools/category.js +103 -0
  219. package/dist/diplomat/mcp/tools/correlations.js +70 -0
  220. package/dist/diplomat/mcp/tools/credit-card.js +239 -0
  221. package/dist/diplomat/mcp/tools/currency-rates.js +62 -0
  222. package/dist/diplomat/mcp/tools/dashboard.js +75 -0
  223. package/dist/diplomat/mcp/tools/index.js +31 -0
  224. package/dist/diplomat/mcp/tools/recurring.js +62 -0
  225. package/dist/diplomat/mcp/tools/summary.js +30 -0
  226. package/dist/diplomat/mcp/tools/system.js +83 -0
  227. package/dist/diplomat/mcp/tools/tag.js +48 -0
  228. package/dist/diplomat/mcp/tools/transaction.js +53 -0
  229. package/dist/diplomat/mcp/tools/transfer.js +28 -0
  230. package/dist/diplomat/mcp/tour.js +87 -0
  231. package/dist/logic/account.js +79 -0
  232. package/dist/logic/aggregate.js +37 -0
  233. package/dist/logic/auth/bearer.js +35 -0
  234. package/dist/logic/auth/grant.js +126 -0
  235. package/dist/logic/auth/key-export.js +10 -0
  236. package/dist/logic/auth/keychain.js +3 -0
  237. package/dist/logic/auth/message.js +22 -0
  238. package/dist/logic/auth/origin.js +57 -0
  239. package/dist/logic/auth/owner.js +22 -0
  240. package/dist/logic/auth/password.js +3 -0
  241. package/dist/logic/auth/redact.js +25 -0
  242. package/dist/logic/auth/revoke.js +28 -0
  243. package/dist/logic/auth/scope.js +17 -0
  244. package/dist/logic/auth/session.js +30 -0
  245. package/dist/logic/auth/sign-in-flow.js +305 -0
  246. package/dist/logic/auth/time.js +2 -0
  247. package/dist/logic/auth/token.js +74 -0
  248. package/dist/logic/auth/user-plans.js +84 -0
  249. package/dist/logic/auth/users.js +78 -0
  250. package/dist/logic/balance.js +2 -0
  251. package/dist/logic/bill.js +74 -0
  252. package/dist/logic/budget.js +78 -0
  253. package/dist/logic/category.js +37 -0
  254. package/dist/logic/classify.js +21 -0
  255. package/dist/logic/correlations.js +147 -0
  256. package/dist/logic/credit-card.js +2 -0
  257. package/dist/logic/currency-rate.js +69 -0
  258. package/dist/logic/dashboard.js +40 -0
  259. package/dist/logic/demo/database.js +30 -0
  260. package/dist/logic/demo/plan.js +308 -0
  261. package/dist/logic/demo/tour.js +33 -0
  262. package/dist/logic/export-destination.js +12 -0
  263. package/dist/logic/key-import.js +15 -0
  264. package/dist/logic/locale.js +5 -0
  265. package/dist/logic/localize.js +12 -0
  266. package/dist/logic/merchant.js +31 -0
  267. package/dist/logic/migration.js +1 -0
  268. package/dist/logic/money.js +12 -0
  269. package/dist/logic/period.js +45 -0
  270. package/dist/logic/persistence.js +48 -0
  271. package/dist/logic/recurring.js +51 -0
  272. package/dist/logic/resolve.js +44 -0
  273. package/dist/logic/summary.js +29 -0
  274. package/dist/logic/tag.js +13 -0
  275. package/dist/logic/transaction.js +197 -0
  276. package/dist/main.js +42 -0
  277. package/dist/models/account.js +197 -0
  278. package/dist/models/aggregate.js +61 -0
  279. package/dist/models/auth/bearer.js +11 -0
  280. package/dist/models/auth/entity.js +17 -0
  281. package/dist/models/auth/errors.js +42 -0
  282. package/dist/models/auth/grant.js +58 -0
  283. package/dist/models/auth/key-export.js +11 -0
  284. package/dist/models/auth/message.js +50 -0
  285. package/dist/models/auth/mode.js +7 -0
  286. package/dist/models/auth/origin.js +16 -0
  287. package/dist/models/auth/owner.js +36 -0
  288. package/dist/models/auth/password.js +24 -0
  289. package/dist/models/auth/principal.js +26 -0
  290. package/dist/models/auth/redact.js +4 -0
  291. package/dist/models/auth/scope.js +9 -0
  292. package/dist/models/auth/session.js +19 -0
  293. package/dist/models/auth/sign-in-flow.js +102 -0
  294. package/dist/models/auth/sign-in.js +41 -0
  295. package/dist/models/auth/time.js +5 -0
  296. package/dist/models/auth/token.js +50 -0
  297. package/dist/models/auth/users.js +52 -0
  298. package/dist/models/bill.js +55 -0
  299. package/dist/models/budget.js +106 -0
  300. package/dist/models/category.js +52 -0
  301. package/dist/models/client-config.js +18 -0
  302. package/dist/models/correlations.js +215 -0
  303. package/dist/models/credit-card.js +156 -0
  304. package/dist/models/currency-rate.js +83 -0
  305. package/dist/models/dashboard.js +54 -0
  306. package/dist/models/database.js +16 -0
  307. package/dist/models/date.js +8 -0
  308. package/dist/models/demo/core.js +58 -0
  309. package/dist/models/demo/tour.js +41 -0
  310. package/dist/models/encryption-key.js +2 -0
  311. package/dist/models/error.js +13 -0
  312. package/dist/models/export.js +9 -0
  313. package/dist/models/id.js +2 -0
  314. package/dist/models/instance.js +7 -0
  315. package/dist/models/key-import.js +6 -0
  316. package/dist/models/locale.js +25 -0
  317. package/dist/models/merchant.js +12 -0
  318. package/dist/models/money.js +14 -0
  319. package/dist/models/package.js +12 -0
  320. package/dist/models/page.js +56 -0
  321. package/dist/models/persistence.js +1 -0
  322. package/dist/models/prompts.js +5 -0
  323. package/dist/models/recurring.js +54 -0
  324. package/dist/models/remedy.js +17 -0
  325. package/dist/models/resolution.js +1 -0
  326. package/dist/models/startup.js +7 -0
  327. package/dist/models/summary.js +24 -0
  328. package/dist/models/tag.js +14 -0
  329. package/dist/models/tenancy.js +10 -0
  330. package/dist/models/transaction-tag.js +6 -0
  331. package/dist/models/transaction.js +275 -0
  332. package/dist/wire/db/access-tokens.js +1 -0
  333. package/dist/wire/db/accounts.js +7 -0
  334. package/dist/wire/db/aggregate.js +16 -0
  335. package/dist/wire/db/bills.js +14 -0
  336. package/dist/wire/db/budgets.js +33 -0
  337. package/dist/wire/db/categories.js +14 -0
  338. package/dist/wire/db/client-grants.js +1 -0
  339. package/dist/wire/db/correlations.js +49 -0
  340. package/dist/wire/db/credit-cards.js +1 -0
  341. package/dist/wire/db/currencies.js +1 -0
  342. package/dist/wire/db/currency-rates.js +1 -0
  343. package/dist/wire/db/dashboards.js +1 -0
  344. package/dist/wire/db/instance-settings.js +1 -0
  345. package/dist/wire/db/invites.js +1 -0
  346. package/dist/wire/db/merchants.js +18 -0
  347. package/dist/wire/db/recurring.js +19 -0
  348. package/dist/wire/db/sessions.js +1 -0
  349. package/dist/wire/db/settings.js +1 -0
  350. package/dist/wire/db/setup-codes.js +1 -0
  351. package/dist/wire/db/tags.js +1 -0
  352. package/dist/wire/db/tenancy.js +1 -0
  353. package/dist/wire/db/transactions.js +89 -0
  354. package/dist/wire/db/users.js +1 -0
  355. package/dist/wire/in/accounts.js +26 -0
  356. package/dist/wire/in/aggregate.js +10 -0
  357. package/dist/wire/in/auth.js +107 -0
  358. package/dist/wire/in/bills.js +11 -0
  359. package/dist/wire/in/budgets.js +11 -0
  360. package/dist/wire/in/categories.js +9 -0
  361. package/dist/wire/in/cli.js +106 -0
  362. package/dist/wire/in/coerce.js +6 -0
  363. package/dist/wire/in/common.js +17 -0
  364. package/dist/wire/in/credit-cards.js +16 -0
  365. package/dist/wire/in/currency-rates.js +8 -0
  366. package/dist/wire/in/period.js +7 -0
  367. package/dist/wire/in/recurring.js +6 -0
  368. package/dist/wire/in/settings.js +5 -0
  369. package/dist/wire/in/summary.js +5 -0
  370. package/dist/wire/in/tags.js +2 -0
  371. package/dist/wire/in/transactions.js +31 -0
  372. package/dist/wire/out/bills.js +9 -0
  373. package/dist/wire/out/budgets.js +10 -0
  374. package/dist/wire/out/client-config.js +2 -0
  375. package/dist/wire/out/common.js +4 -0
  376. package/dist/wire/out/credit-cards.js +15 -0
  377. package/dist/wire/out/currency-rates.js +11 -0
  378. package/dist/wire/out/errors.js +58 -0
  379. package/dist/wire/out/recurring.js +6 -0
  380. package/dist/wire/out/status.js +10 -0
  381. package/dist/wire/out/summary.js +9 -0
  382. package/dist/wire/out/transactions.js +52 -0
  383. package/drizzle/0000_futuristic_umar.sql +124 -0
  384. package/drizzle/0001_fts5_search.sql +23 -0
  385. package/drizzle/0002_rename_graph_to_history.sql +7 -0
  386. package/drizzle/0003_lyrical_hairball.sql +2 -0
  387. package/drizzle/0004_misty_ikaris.sql +7 -0
  388. package/drizzle/0005_credit-liability-accounts.sql +14 -0
  389. package/drizzle/0006_smart_aqueduct.sql +1 -0
  390. package/drizzle/0007_add_dashboards.sql +5 -0
  391. package/drizzle/0008_yummy_madripoor.sql +1 -0
  392. package/drizzle/0009_version_groundwork.sql +9 -0
  393. package/drizzle/0010_category_merchant_association_cascade.sql +16 -0
  394. package/drizzle/0011_dashboard_id_normalization.sql +16 -0
  395. package/drizzle/0012_hot_the_spike.sql +12 -0
  396. package/drizzle/0013_recurring_rules_merchant.sql +1 -0
  397. package/drizzle/0014_dashboard_source_discriminator.sql +17 -0
  398. package/drizzle/0015_currencies_decimals.sql +1 -0
  399. package/drizzle/0016_unusual_zaran.sql +13 -0
  400. package/drizzle/0017_premium_blur.sql +1 -0
  401. package/drizzle/0018_auth_identity.sql +39 -0
  402. package/drizzle/0019_access_tokens.sql +16 -0
  403. package/drizzle/0020_stdio_sign_in.sql +27 -0
  404. package/drizzle/0021_tenancy_data.sql +289 -0
  405. package/drizzle/0022_user_management.sql +17 -0
  406. package/drizzle/0023_instance_settings_row.sql +2 -0
  407. package/drizzle/0024_credentials_changed_at.sql +2 -0
  408. package/drizzle/0025_instance_kind.sql +2 -0
  409. package/drizzle/0026_demo_seeded_at.sql +2 -0
  410. package/drizzle/0027_demo_country.sql +2 -0
  411. package/drizzle/0028_reset_sign_ins.sql +2 -0
  412. package/drizzle/meta/0000_snapshot.json +894 -0
  413. package/drizzle/meta/0003_snapshot.json +910 -0
  414. package/drizzle/meta/0004_snapshot.json +951 -0
  415. package/drizzle/meta/0005_snapshot.json +991 -0
  416. package/drizzle/meta/0006_snapshot.json +998 -0
  417. package/drizzle/meta/0007_snapshot.json +1029 -0
  418. package/drizzle/meta/0008_snapshot.json +1049 -0
  419. package/drizzle/meta/0009_snapshot.json +1121 -0
  420. package/drizzle/meta/0010_snapshot.json +1121 -0
  421. package/drizzle/meta/0011_snapshot.json +1136 -0
  422. package/drizzle/meta/0012_snapshot.json +1227 -0
  423. package/drizzle/meta/0013_snapshot.json +1247 -0
  424. package/drizzle/meta/0014_snapshot.json +1267 -0
  425. package/drizzle/meta/0015_snapshot.json +1275 -0
  426. package/drizzle/meta/0016_snapshot.json +1371 -0
  427. package/drizzle/meta/0017_snapshot.json +1392 -0
  428. package/drizzle/meta/0018_snapshot.json +1603 -0
  429. package/drizzle/meta/0019_snapshot.json +1713 -0
  430. package/drizzle/meta/0020_snapshot.json +1904 -0
  431. package/drizzle/meta/0021_snapshot.json +2186 -0
  432. package/drizzle/meta/0022_snapshot.json +2311 -0
  433. package/drizzle/meta/0023_snapshot.json +2311 -0
  434. package/drizzle/meta/0024_snapshot.json +2318 -0
  435. package/drizzle/meta/0025_snapshot.json +2326 -0
  436. package/drizzle/meta/0026_snapshot.json +2333 -0
  437. package/drizzle/meta/0027_snapshot.json +2340 -0
  438. package/drizzle/meta/0028_snapshot.json +2340 -0
  439. package/drizzle/meta/_journal.json +209 -0
  440. package/package.json +106 -4
  441. package/skills/dashboard-building/SKILL.md +201 -0
  442. package/skills/patty-tour/SKILL.md +34 -0
  443. package/ui/app.css +758 -0
  444. package/ui/app.js +543 -0
  445. package/ui/connect-result.html +16 -0
  446. package/ui/connect.html +53 -0
  447. package/ui/dashboards/accounts.html +3189 -0
  448. package/ui/dashboards/budget.html +1734 -0
  449. package/ui/dashboards/cards.html +4032 -0
  450. package/ui/dashboards/categories.html +4694 -0
  451. package/ui/dashboards/comparative.html +2475 -0
  452. package/ui/dashboards/dashboards.html +839 -0
  453. package/ui/dashboards/overview.html +2405 -0
  454. package/ui/dashboards/pending.html +2973 -0
  455. package/ui/dashboards/projections.html +2528 -0
  456. package/ui/dashboards/tags.html +1365 -0
  457. package/ui/invite.html +44 -0
  458. package/ui/login.html +26 -0
  459. package/ui/money.js +175 -0
  460. package/ui/setup.html +29 -0
  461. package/ui/shell.html +96 -0
  462. package/ui/token-created.html +24 -0
  463. package/ui/tokens.html +58 -0
  464. package/ui/user-invited.html +27 -0
  465. package/ui/users.html +60 -0
@@ -0,0 +1,348 @@
1
+ import { check, foreignKey, index, integer, primaryKey, real, sqliteTable, text, uniqueIndex, } from 'drizzle-orm/sqlite-core';
2
+ import { sql } from 'drizzle-orm';
3
+ import { GrantChannel, GrantStatus } from '../../models/auth/grant.js';
4
+ import { UserRole } from '../../models/auth/owner.js';
5
+ import { DEFAULT_SIGN_IN_CAP, SignInCap } from '../../models/auth/users.js';
6
+ import { AccessTokenKind } from '../../models/auth/token.js';
7
+ import { BudgetPeriod } from '../../models/budget.js';
8
+ import { DemoCountry } from '../../models/demo/core.js';
9
+ import { DashboardSource } from '../../models/dashboard.js';
10
+ import { DEFAULT_INSTANCE_KIND, InstanceKind } from '../../models/instance.js';
11
+ import { Locale, LocaleSource } from '../../models/locale.js';
12
+ import { RecurringPeriod } from '../../models/recurring.js';
13
+ import { ClassificationMethod, TransactionStatus } from '../../models/transaction.js';
14
+ // Owned rows name their user (RESTRICT); shared defaults carry null.
15
+ const ownerColumn = () => text('user_id')
16
+ .notNull()
17
+ .references(() => users.id, { onDelete: 'restrict' });
18
+ const sharedOrOwnerColumn = () => text('user_id').references(() => users.id, { onDelete: 'restrict' });
19
+ export const currencies = sqliteTable('currencies', {
20
+ code: text('code').primaryKey(),
21
+ symbol: text('symbol').notNull(),
22
+ name: text('name').notNull(),
23
+ // Fractional digits for display/rounding (fiat 2, USDC 6, BTC 8) — ADR-026 Phase 1. Defaults to
24
+ // fiat's 2 so the migration backfill needs no per-row logic.
25
+ decimals: integer('decimals').notNull().default(2),
26
+ });
27
+ export const accounts = sqliteTable('accounts', {
28
+ id: text('id').primaryKey(),
29
+ name: text('name').notNull(),
30
+ type: text('type', { enum: ['checking', 'savings', 'wallet', 'investment', 'credit'] }).notNull(),
31
+ initialBalance: real('initial_balance').notNull().default(0),
32
+ currency: text('currency')
33
+ .notNull()
34
+ .references(() => currencies.code),
35
+ // Optimistic-concurrency token for the generic versioned unit of work (ADR-021); unread/unbumped
36
+ // by any flow not yet converted off its own repo write method.
37
+ version: integer('version').notNull().default(0),
38
+ userId: ownerColumn(),
39
+ });
40
+ export const creditCards = sqliteTable('credit_cards', {
41
+ id: text('id').primaryKey(),
42
+ name: text('name').notNull(),
43
+ closingDay: integer('closing_day').notNull(),
44
+ dueDay: integer('due_day').notNull(),
45
+ limitAmount: real('limit_amount'),
46
+ currency: text('currency')
47
+ .notNull()
48
+ .references(() => currencies.code),
49
+ accountId: text('account_id')
50
+ .notNull()
51
+ .references(() => accounts.id),
52
+ paymentAccountId: text('payment_account_id').references(() => accounts.id),
53
+ version: integer('version').notNull().default(0),
54
+ userId: ownerColumn(),
55
+ });
56
+ export const categories = sqliteTable('categories', {
57
+ id: text('id').primaryKey(),
58
+ name: text('name').notNull(),
59
+ kind: text('kind', { enum: ['expense', 'income', 'both'] }).notNull(),
60
+ parentId: text('parent_id'),
61
+ names: text('names'),
62
+ version: integer('version').notNull().default(0),
63
+ userId: sharedOrOwnerColumn(),
64
+ }, (t) => [foreignKey({ columns: [t.parentId], foreignColumns: [t.id] })]);
65
+ export const merchants = sqliteTable('merchants', {
66
+ key: text('key').primaryKey(),
67
+ });
68
+ export const merchantCategory = sqliteTable('merchant_category', {
69
+ merchantKey: text('merchant_key')
70
+ .notNull()
71
+ .references(() => merchants.key),
72
+ categoryId: text('category_id')
73
+ .notNull()
74
+ .references(() => categories.id, { onDelete: 'cascade' }),
75
+ weight: real('weight').notNull().default(1),
76
+ origin: text('origin', { enum: [ClassificationMethod.enum.rule, ClassificationMethod.enum.history] }).notNull(),
77
+ lastSeen: integer('last_seen'),
78
+ userId: sharedOrOwnerColumn(),
79
+ }, (t) => [
80
+ // NULLs are distinct in a UNIQUE index, hence one partial index per audience.
81
+ uniqueIndex('merchant_category_shared_key')
82
+ .on(t.merchantKey, t.categoryId)
83
+ .where(sql `${t.userId} IS NULL`),
84
+ uniqueIndex('merchant_category_user_key')
85
+ .on(t.userId, t.merchantKey, t.categoryId)
86
+ .where(sql `${t.userId} IS NOT NULL`),
87
+ check('merchant_category_origin_owner', sql `(${t.origin} = ${sql.raw(`'${ClassificationMethod.enum.rule}'`)} AND ${t.userId} IS NULL) OR (${t.origin} = ${sql.raw(`'${ClassificationMethod.enum.history}'`)} AND ${t.userId} IS NOT NULL)`),
88
+ ]);
89
+ export const tags = sqliteTable('tags', {
90
+ id: text('id').primaryKey(),
91
+ name: text('name').notNull(),
92
+ version: integer('version').notNull().default(0),
93
+ userId: ownerColumn(),
94
+ }, (t) => [uniqueIndex('tags_user_name').on(t.userId, t.name)]);
95
+ export const bills = sqliteTable('bills', {
96
+ id: text('id').primaryKey(),
97
+ creditCardId: text('credit_card_id')
98
+ .notNull()
99
+ .references(() => creditCards.id),
100
+ month: integer('month').notNull(),
101
+ year: integer('year').notNull(),
102
+ closeDate: text('close_date').notNull(),
103
+ dueDate: text('due_date').notNull(),
104
+ status: text('status', { enum: ['open', 'closed', 'paid'] }).notNull(),
105
+ paymentTransactionId: text('payment_transaction_id').references(() => transactions.id),
106
+ version: integer('version').notNull().default(0),
107
+ userId: ownerColumn(),
108
+ }, (t) => [uniqueIndex('bills_card_month_year').on(t.creditCardId, t.month, t.year)]);
109
+ export const transactions = sqliteTable('transactions', {
110
+ id: text('id').primaryKey(),
111
+ description: text('description').notNull(),
112
+ amount: real('amount').notNull(),
113
+ type: text('type', { enum: ['income', 'expense', 'transfer'] }).notNull(),
114
+ status: text('status', { enum: TransactionStatus.options }).notNull().default(TransactionStatus.enum.effective),
115
+ date: text('date').notNull(),
116
+ currency: text('currency')
117
+ .notNull()
118
+ .references(() => currencies.code),
119
+ source: text('source', { enum: ['mcp', 'rest', 'import'] }).notNull(),
120
+ idempotencyKey: text('idempotency_key').notNull(),
121
+ classificationMethod: text('classification_method', { enum: ClassificationMethod.options }).notNull(),
122
+ confidence: real('confidence').notNull(),
123
+ rawInput: text('raw_input'),
124
+ fromAccountId: text('from_account_id').references(() => accounts.id),
125
+ toAccountId: text('to_account_id').references(() => accounts.id),
126
+ creditCardId: text('credit_card_id').references(() => creditCards.id),
127
+ categoryId: text('category_id').references(() => categories.id),
128
+ subcategoryId: text('subcategory_id').references(() => categories.id),
129
+ merchantKey: text('merchant_key').references(() => merchants.key),
130
+ note: text('note'),
131
+ billId: text('bill_id').references(() => bills.id),
132
+ version: integer('version').notNull().default(0),
133
+ userId: ownerColumn(),
134
+ }, (t) => [
135
+ uniqueIndex('transactions_user_idempotency_key').on(t.userId, t.idempotencyKey),
136
+ index('idx_transactions_user_date').on(t.userId, t.date),
137
+ index('idx_transactions_date').on(t.date),
138
+ index('idx_transactions_from_account').on(t.fromAccountId),
139
+ index('idx_transactions_to_account').on(t.toAccountId),
140
+ index('idx_transactions_category').on(t.categoryId),
141
+ index('idx_transactions_status_date').on(t.status, t.date),
142
+ // sub-category requires a parent category
143
+ check('subcategory_requires_category', sql `${t.subcategoryId} IS NULL OR ${t.categoryId} IS NOT NULL`),
144
+ ]);
145
+ export const transactionTags = sqliteTable('transaction_tags', {
146
+ transactionId: text('transaction_id')
147
+ .notNull()
148
+ .references(() => transactions.id, { onDelete: 'cascade' }),
149
+ tagId: text('tag_id')
150
+ .notNull()
151
+ .references(() => tags.id, { onDelete: 'cascade' }),
152
+ }, (t) => [primaryKey({ columns: [t.transactionId, t.tagId] })]);
153
+ export const recurringRules = sqliteTable('recurring_rules', {
154
+ id: text('id').primaryKey(),
155
+ description: text('description').notNull(),
156
+ amount: real('amount').notNull(),
157
+ type: text('type', { enum: ['income', 'expense'] }).notNull(),
158
+ period: text('period', { enum: RecurringPeriod.options }).notNull(),
159
+ nextDue: text('next_due').notNull(),
160
+ currency: text('currency')
161
+ .notNull()
162
+ .references(() => currencies.code),
163
+ accountId: text('account_id').references(() => accounts.id),
164
+ categoryId: text('category_id').references(() => categories.id),
165
+ merchantKey: text('merchant_key').references(() => merchants.key),
166
+ version: integer('version').notNull().default(0),
167
+ userId: ownerColumn(),
168
+ });
169
+ export const dashboards = sqliteTable('dashboards', {
170
+ id: text('id').primaryKey(),
171
+ name: text('name').notNull(),
172
+ // Nullable — a source: 'file' row resolves content from `path` at read time instead
173
+ // (ADR-027 Phase 2); exactly one of html/path is non-null per source, enforced below.
174
+ html: text('html'),
175
+ source: text('source', { enum: DashboardSource.options }).notNull().default(DashboardSource.enum.inline),
176
+ path: text('path'),
177
+ updatedAt: text('updated_at').notNull(),
178
+ version: integer('version').notNull().default(0),
179
+ userId: sharedOrOwnerColumn(),
180
+ }, (t) => [
181
+ // Unique among the shared defaults and, separately, among each user's own (partial indexes: NULLs are distinct).
182
+ uniqueIndex('dashboards_shared_name')
183
+ .on(t.name)
184
+ .where(sql `${t.userId} IS NULL`),
185
+ uniqueIndex('dashboards_user_name')
186
+ .on(t.userId, t.name)
187
+ .where(sql `${t.userId} IS NOT NULL`),
188
+ check('dashboard_source_owner', sql `(${t.source} = 'file' AND ${t.userId} IS NULL) OR (${t.source} = 'inline' AND ${t.userId} IS NOT NULL)`),
189
+ check('dashboard_source_content', sql `(${t.source} = 'inline' AND ${t.html} IS NOT NULL AND ${t.path} IS NULL) OR (${t.source} = 'file' AND ${t.html} IS NULL AND ${t.path} IS NOT NULL)`),
190
+ ]);
191
+ export const budgets = sqliteTable('budgets', {
192
+ id: text('id').primaryKey(),
193
+ // The budgeted node's own id — a top-level category or sub-category (both rows in
194
+ // `categories`); one column, so `UNIQUE` needs no nullable discriminator (Feature Design 015).
195
+ categoryId: text('category_id')
196
+ .notNull()
197
+ .references(() => categories.id),
198
+ currency: text('currency')
199
+ .notNull()
200
+ .references(() => currencies.code),
201
+ limitAmount: real('limit_amount').notNull(),
202
+ period: text('period', { enum: BudgetPeriod.options }).notNull().default(BudgetPeriod.enum.monthly),
203
+ version: integer('version').notNull().default(0),
204
+ userId: ownerColumn(),
205
+ }, (t) => [uniqueIndex('budgets_user_category_currency_period').on(t.userId, t.categoryId, t.currency, t.period)]);
206
+ // The instance-wide singleton; preferences live in user_settings. `max_sign_in_duration` is the longest a stdio
207
+ // sign-in may last; `instance_kind` is what this database says it is (`demo` only when the demo seeder made it);
208
+ // `demo_seeded_at` is when that seeder finished (null on a standard database, and on an interrupted demo);
209
+ // `demo_country` is the data set it seeded (null off the demo, and on a demo seeded before it was recorded).
210
+ export const settings = sqliteTable('settings', {
211
+ id: text('id').primaryKey().default('singleton'),
212
+ maxSignInDuration: text('max_sign_in_duration', { enum: SignInCap.options }).notNull().default(DEFAULT_SIGN_IN_CAP),
213
+ instanceKind: text('instance_kind', { enum: InstanceKind.options }).notNull().default(DEFAULT_INSTANCE_KIND),
214
+ demoSeededAt: text('demo_seeded_at'),
215
+ demoCountry: text('demo_country', { enum: DemoCountry.options }),
216
+ version: integer('version').notNull().default(0),
217
+ });
218
+ // One row per user; none means the defaults apply.
219
+ export const userSettings = sqliteTable('user_settings', {
220
+ userId: text('user_id')
221
+ .primaryKey()
222
+ .references(() => users.id, { onDelete: 'cascade' }),
223
+ locale: text('locale', { enum: Locale.options }).notNull().default(Locale.enum.en),
224
+ localeSource: text('locale_source', { enum: LocaleSource.options }).notNull().default(LocaleSource.enum.default),
225
+ // Nullable — unset means "derive from locale" (pt->BRL, en/es->USD), resolved at read time by
226
+ // logic/locale.ts's resolveBaseCurrency (ADR-026 Phase 2); no DB default, unlike locale/localeSource,
227
+ // since there is no third "explicit vs inferred" source to track here.
228
+ baseCurrency: text('base_currency').references(() => currencies.code),
229
+ version: integer('version').notNull().default(0),
230
+ });
231
+ export const currencyRates = sqliteTable('currency_rates', {
232
+ id: text('id').primaryKey(),
233
+ // 1 unit of fromCode = `rate` units of toCode, as of `asOf` (ADR-026 Phase 2).
234
+ fromCode: text('from_code')
235
+ .notNull()
236
+ .references(() => currencies.code),
237
+ toCode: text('to_code')
238
+ .notNull()
239
+ .references(() => currencies.code),
240
+ rate: real('rate').notNull(),
241
+ asOf: text('as_of').notNull(),
242
+ // Free-text provenance (e.g. "PTAX", "coingecko") — agent-supplied, never validated against a
243
+ // fixed list; nullable since the agent may not always report one.
244
+ source: text('source'),
245
+ version: integer('version').notNull().default(0),
246
+ }, (t) => [uniqueIndex('currency_rates_from_to').on(t.fromCode, t.toCode)]);
247
+ // ADR-033 §2/§7. `username`/`password_hash` are null until the owner row (inserted by migration on
248
+ // every database) is claimed through the setup code; `username` holds the normalized form, so the
249
+ // plain UNIQUE index is case-insensitive.
250
+ export const users = sqliteTable('users', {
251
+ id: text('id').primaryKey(),
252
+ username: text('username').unique(),
253
+ passwordHash: text('password_hash'),
254
+ role: text('role', { enum: UserRole.options }).notNull(),
255
+ createdAt: text('created_at').notNull(),
256
+ disabledAt: text('disabled_at'),
257
+ lastLoginAt: text('last_login_at'),
258
+ credentialsChangedAt: text('credentials_changed_at'),
259
+ version: integer('version').notNull().default(0),
260
+ });
261
+ // An invitation to claim one unclaimed user. Only sha256(code) is stored. Users are disabled, never
262
+ // deleted, so both references are RESTRICT: an invite can never outlive its user's row or the admin's.
263
+ export const invites = sqliteTable('invites', {
264
+ id: text('id').primaryKey(),
265
+ userId: text('user_id')
266
+ .notNull()
267
+ .references(() => users.id, { onDelete: 'restrict' }),
268
+ codeHash: text('code_hash').notNull().unique(),
269
+ // Null = issued from the trusted terminal, which acts as no user.
270
+ createdBy: text('created_by').references(() => users.id, { onDelete: 'restrict' }),
271
+ createdAt: text('created_at').notNull(),
272
+ expiresAt: text('expires_at').notNull(),
273
+ usedAt: text('used_at'),
274
+ version: integer('version').notNull().default(0),
275
+ }, (table) => [
276
+ // At most one unclaimed invite per user: issuing a new one removes the previous in the same batch.
277
+ uniqueIndex('invites_one_open_per_user')
278
+ .on(table.userId)
279
+ .where(sql `${table.usedAt} IS NULL`),
280
+ ]);
281
+ // Only sha256(token) is stored — a database read never yields a usable session.
282
+ export const sessions = sqliteTable('sessions', {
283
+ id: text('id').primaryKey(),
284
+ userId: text('user_id')
285
+ .notNull()
286
+ .references(() => users.id, { onDelete: 'cascade' }),
287
+ tokenHash: text('token_hash').notNull().unique(),
288
+ createdAt: text('created_at').notNull(),
289
+ lastSeenAt: text('last_seen_at').notNull(),
290
+ expiresAt: text('expires_at').notNull(),
291
+ version: integer('version').notNull().default(0),
292
+ });
293
+ // Only sha256(token) is stored; `prefix` is display-only. `scopes` is a JSON array of the `Scope` enum. `kind` says
294
+ // what minted it — a person at the token page (`pat`) or a stdio sign-in (`stdio`, ADR-034), which also records the
295
+ // client that asked and the profile it signs in.
296
+ export const accessTokens = sqliteTable('access_tokens', {
297
+ id: text('id').primaryKey(),
298
+ userId: text('user_id')
299
+ .notNull()
300
+ .references(() => users.id, { onDelete: 'cascade' }),
301
+ kind: text('kind', { enum: AccessTokenKind.options }).notNull().default(AccessTokenKind.enum.pat),
302
+ clientName: text('client_name'),
303
+ profile: text('profile'),
304
+ name: text('name').notNull(),
305
+ tokenHash: text('token_hash').notNull().unique(),
306
+ prefix: text('prefix').notNull(),
307
+ scopes: text('scopes', { mode: 'json' }).$type().notNull(),
308
+ createdAt: text('created_at').notNull(),
309
+ lastUsedAt: text('last_used_at'),
310
+ expiresAt: text('expires_at'),
311
+ revokedAt: text('revoked_at'),
312
+ version: integer('version').notNull().default(0),
313
+ });
314
+ export const setupCodes = sqliteTable('setup_codes', {
315
+ id: text('id').primaryKey(),
316
+ codeHash: text('code_hash').notNull().unique(),
317
+ createdAt: text('created_at').notNull(),
318
+ expiresAt: text('expires_at').notNull(),
319
+ usedAt: text('used_at'),
320
+ version: integer('version').notNull().default(0),
321
+ });
322
+ // ADR-034 §3: a pending/answered stdio (or `patty login`) sign-in. Only sha256(device code) is stored — the
323
+ // plaintext lives in the asking process. The user code is unique among PENDING grants only, so a finished one
324
+ // never blocks a fresh code; `user_id` is set by the approval and is whoever approved.
325
+ export const clientGrants = sqliteTable('client_grants', {
326
+ id: text('id').primaryKey(),
327
+ deviceCodeHash: text('device_code_hash').notNull().unique(),
328
+ userCode: text('user_code').notNull(),
329
+ clientName: text('client_name').notNull(),
330
+ clientVersion: text('client_version').notNull(),
331
+ profile: text('profile').notNull(),
332
+ channel: text('channel', { enum: GrantChannel.options }).notNull().default(GrantChannel.enum.stdio),
333
+ hintAccess: text('hint_access').$type(),
334
+ hintDuration: text('hint_duration').$type(),
335
+ status: text('status', { enum: GrantStatus.options }).notNull().default(GrantStatus.enum.pending),
336
+ userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }),
337
+ scopes: text('scopes', { mode: 'json' }).$type(),
338
+ duration: text('duration').$type(),
339
+ createdAt: text('created_at').notNull(),
340
+ approvedAt: text('approved_at'),
341
+ expiresAt: text('expires_at').notNull(),
342
+ version: integer('version').notNull().default(0),
343
+ }, (table) => [
344
+ uniqueIndex('client_grants_pending_user_code')
345
+ .on(table.userCode)
346
+ .where(sql `${table.status} = ${sql.raw(`'${GrantStatus.enum.pending}'`)}`),
347
+ index('client_grants_user_code_idx').on(table.userCode),
348
+ ]);
@@ -0,0 +1,112 @@
1
+ import { z } from 'zod';
2
+ import { CategoryKind } from '../../../models/category.js';
3
+ export const DefaultCategoryId = z.enum([
4
+ 'cat-food',
5
+ 'cat-transport',
6
+ 'cat-housing',
7
+ 'cat-utilities',
8
+ 'cat-health',
9
+ 'cat-education',
10
+ 'cat-leisure',
11
+ 'cat-shopping',
12
+ 'cat-subscriptions',
13
+ 'cat-travel',
14
+ 'cat-taxes',
15
+ 'cat-salary',
16
+ 'cat-extra-income',
17
+ 'cat-investments',
18
+ 'cat-other',
19
+ ]);
20
+ const D = DefaultCategoryId.enum;
21
+ export const CATEGORIES = [
22
+ {
23
+ id: D['cat-food'],
24
+ name: 'Food',
25
+ kind: CategoryKind.enum.expense,
26
+ names: JSON.stringify({ pt: 'Alimentação', es: 'Alimentación' }),
27
+ },
28
+ {
29
+ id: D['cat-transport'],
30
+ name: 'Transport',
31
+ kind: CategoryKind.enum.expense,
32
+ names: JSON.stringify({ pt: 'Transporte', es: 'Transporte' }),
33
+ },
34
+ {
35
+ id: D['cat-housing'],
36
+ name: 'Housing',
37
+ kind: CategoryKind.enum.expense,
38
+ names: JSON.stringify({ pt: 'Moradia', es: 'Vivienda' }),
39
+ },
40
+ {
41
+ id: D['cat-utilities'],
42
+ name: 'Utilities',
43
+ kind: CategoryKind.enum.expense,
44
+ names: JSON.stringify({ pt: 'Contas & Serviços', es: 'Servicios' }),
45
+ },
46
+ {
47
+ id: D['cat-health'],
48
+ name: 'Health',
49
+ kind: CategoryKind.enum.expense,
50
+ names: JSON.stringify({ pt: 'Saúde', es: 'Salud' }),
51
+ },
52
+ {
53
+ id: D['cat-education'],
54
+ name: 'Education',
55
+ kind: CategoryKind.enum.expense,
56
+ names: JSON.stringify({ pt: 'Educação', es: 'Educación' }),
57
+ },
58
+ {
59
+ id: D['cat-leisure'],
60
+ name: 'Leisure',
61
+ kind: CategoryKind.enum.expense,
62
+ names: JSON.stringify({ pt: 'Lazer', es: 'Ocio' }),
63
+ },
64
+ {
65
+ id: D['cat-shopping'],
66
+ name: 'Shopping',
67
+ kind: CategoryKind.enum.expense,
68
+ names: JSON.stringify({ pt: 'Compras', es: 'Compras' }),
69
+ },
70
+ {
71
+ id: D['cat-subscriptions'],
72
+ name: 'Subscriptions',
73
+ kind: CategoryKind.enum.expense,
74
+ names: JSON.stringify({ pt: 'Assinaturas', es: 'Suscripciones' }),
75
+ },
76
+ {
77
+ id: D['cat-travel'],
78
+ name: 'Travel',
79
+ kind: CategoryKind.enum.expense,
80
+ names: JSON.stringify({ pt: 'Viagem', es: 'Viajes' }),
81
+ },
82
+ {
83
+ id: D['cat-taxes'],
84
+ name: 'Taxes',
85
+ kind: CategoryKind.enum.expense,
86
+ names: JSON.stringify({ pt: 'Impostos & Taxas', es: 'Impuestos & Tasas' }),
87
+ },
88
+ {
89
+ id: D['cat-salary'],
90
+ name: 'Salary',
91
+ kind: CategoryKind.enum.income,
92
+ names: JSON.stringify({ pt: 'Salário', es: 'Salario' }),
93
+ },
94
+ {
95
+ id: D['cat-extra-income'],
96
+ name: 'Extra Income',
97
+ kind: CategoryKind.enum.income,
98
+ names: JSON.stringify({ pt: 'Renda Extra', es: 'Ingresos Extra' }),
99
+ },
100
+ {
101
+ id: D['cat-investments'],
102
+ name: 'Investments',
103
+ kind: CategoryKind.enum.both,
104
+ names: JSON.stringify({ pt: 'Investimentos', es: 'Inversiones' }),
105
+ },
106
+ {
107
+ id: D['cat-other'],
108
+ name: 'Other',
109
+ kind: CategoryKind.enum.both,
110
+ names: JSON.stringify({ pt: 'Outros', es: 'Otros' }),
111
+ },
112
+ ];
@@ -0,0 +1,9 @@
1
+ import { CurrencyCode } from '../../../models/money.js';
2
+ export const CURRENCIES = [
3
+ { code: CurrencyCode.enum.BRL, symbol: 'R$', name: 'Real Brasileiro', decimals: 2 },
4
+ { code: CurrencyCode.enum.USD, symbol: '$', name: 'US Dollar', decimals: 2 },
5
+ { code: CurrencyCode.enum.MXN, symbol: 'MX$', name: 'Peso Mexicano', decimals: 2 },
6
+ { code: CurrencyCode.enum.COP, symbol: 'COL$', name: 'Peso Colombiano', decimals: 2 },
7
+ { code: CurrencyCode.enum.USDC, symbol: 'USDC', name: 'USD Coin', decimals: 6 },
8
+ { code: CurrencyCode.enum.BTC, symbol: '₿', name: 'Bitcoin', decimals: 8 },
9
+ ];
@@ -0,0 +1,98 @@
1
+ import { DemoCountry, DemoFunding } from '../../../../models/demo/core.js';
2
+ import { TOUR_FACTS } from '../../../../models/demo/tour.js';
3
+ import { Locale } from '../../../../models/locale.js';
4
+ import { CurrencyCode } from '../../../../models/money.js';
5
+ import { DefaultCategoryId } from '../categories.js';
6
+ import { BUDGET_SHAPES, fixedLine, pendingLine, spendLine, tripItem } from './shared.js';
7
+ const C = DefaultCategoryId.enum;
8
+ const F = DemoFunding.enum;
9
+ const WORK = 'trabalho';
10
+ const FAMILY = 'família';
11
+ /** Brazil: pt, BRL — Nubank and Itaú, a dollar Conta Global, a trip to Florianópolis. */
12
+ export const BR_PACK = {
13
+ country: DemoCountry.enum.br,
14
+ locale: Locale.enum.pt,
15
+ currency: CurrencyCode.enum.BRL,
16
+ amountStep: 0.01,
17
+ usdRate: 5.4,
18
+ accounts: {
19
+ checking: { name: 'Nubank', initialBalance: 6500 },
20
+ savings: { name: 'Caixinha Nubank', initialBalance: 18000 },
21
+ investment: { name: 'Itaú Investimentos', initialBalance: 42000 },
22
+ wallet: { name: 'Carteira', initialBalance: 300 },
23
+ usdc: { name: 'Cripto USDC', initialBalance: 420 },
24
+ btc: { name: 'Cripto BTC', initialBalance: 0.0185 },
25
+ },
26
+ global: {
27
+ name: 'Nubank Conta Global',
28
+ initialBalance: 600,
29
+ spending: [
30
+ spendLine(F.global, C['cat-shopping'], 'Amazon.com', [18, 75], 1),
31
+ spendLine(F.global, C['cat-education'], 'Udemy', [12, 30], 1),
32
+ ],
33
+ },
34
+ cards: {
35
+ primary: { name: 'Nubank Roxinho', closingDay: 3, dueDay: 10, limit: 12000 },
36
+ secondary: { name: 'Itaú Platinum', closingDay: 20, dueDay: 27, limit: 18000 },
37
+ },
38
+ tags: [WORK, FAMILY],
39
+ salary: fixedLine(C['cat-salary'], 'Salário Empresa XYZ', 8500, 5),
40
+ rent: fixedLine(C['cat-housing'], 'Aluguel', 2200, 8),
41
+ subscriptions: [
42
+ fixedLine(C['cat-subscriptions'], 'Netflix', 55.9, 12),
43
+ fixedLine(C['cat-subscriptions'], 'Spotify', 21.9, 15),
44
+ fixedLine(C['cat-health'], 'Academia SmartFit', 119.9, 10),
45
+ fixedLine(C['cat-utilities'], 'Internet Vivo Fibra', 129.9, 20),
46
+ ],
47
+ freelance: fixedLine(C['cat-extra-income'], 'Freelance site institucional', 1800, 18),
48
+ spending: [
49
+ spendLine(F.primaryCard, C['cat-food'], 'Pão de Açúcar', [180, 420], 2),
50
+ spendLine(F.checking, C['cat-food'], 'Mercado Assaí', [120, 300], 1),
51
+ spendLine(F.wallet, C['cat-food'], 'Hortifruti Natural', [40, 90], 2),
52
+ spendLine(F.primaryCard, C['cat-food'], 'iFood', [38, 95], 4),
53
+ spendLine(F.secondaryCard, C['cat-food'], 'Restaurante Madero', [90, 220], 2),
54
+ spendLine(F.wallet, C['cat-food'], 'Padaria Pão Quente', [12, 35], 3),
55
+ spendLine(F.primaryCard, C['cat-food'], 'Almoço com cliente', [70, 150], 1, WORK),
56
+ spendLine(F.primaryCard, C['cat-transport'], 'Uber', [14, 48], 5),
57
+ spendLine(F.checking, C['cat-transport'], '99 Táxi', [12, 35], 2),
58
+ spendLine(F.secondaryCard, C['cat-transport'], 'Posto Shell', [180, 260], 1),
59
+ spendLine(F.wallet, C['cat-transport'], 'Estacionamento Shopping', [15, 40], 1),
60
+ spendLine(F.checking, C['cat-health'], 'Farmácia Drogasil', [35, 160], 2),
61
+ spendLine(F.checking, C['cat-health'], 'Consulta Dr. Silva', [280, 320], 1),
62
+ spendLine(F.primaryCard, C['cat-leisure'], 'Cinema Cinemark', [45, 90], 1),
63
+ spendLine(F.secondaryCard, C['cat-leisure'], 'Bar do Zé', [80, 200], 2),
64
+ spendLine(F.secondaryCard, C['cat-shopping'], 'Amazon', [70, 350], 1),
65
+ spendLine(F.primaryCard, C['cat-shopping'], 'Mercado Livre', [60, 280], 1),
66
+ spendLine(F.secondaryCard, C['cat-shopping'], 'Renner', [120, 380], 1),
67
+ spendLine(F.secondaryCard, C['cat-shopping'], 'Presente para a família', [80, 200], 1, FAMILY),
68
+ spendLine(F.checking, C['cat-utilities'], 'Conta de luz Enel', [140, 230], 1),
69
+ spendLine(F.checking, C['cat-utilities'], 'Conta de água Sabesp', [70, 120], 1),
70
+ spendLine(F.checking, C['cat-education'], 'Escola de inglês', [390, 390], 1),
71
+ ],
72
+ transfers: {
73
+ savings: { description: 'Aporte mensal', amount: 1500 },
74
+ investment: { description: 'Aporte Tesouro Selic', amount: 1000 },
75
+ wallet: { description: 'Saque para a carteira', amount: 400 },
76
+ },
77
+ pending: [
78
+ pendingLine(C['cat-housing'], 'Condomínio', 780, 5),
79
+ pendingLine(C['cat-transport'], 'Seguro do carro', 350, 9),
80
+ pendingLine(C['cat-extra-income'], 'Reembolso de despesas', 450, 3, true),
81
+ ],
82
+ budgets: BUDGET_SHAPES,
83
+ trip: {
84
+ destination: TOUR_FACTS[DemoCountry.enum.br].destination,
85
+ items: [
86
+ tripItem(0, F.primaryCard, C['cat-travel'], 'Passagem aérea LATAM para Florianópolis', 1380),
87
+ tripItem(0, F.primaryCard, C['cat-travel'], 'Pousada Ilha Azul Florianópolis', 2150),
88
+ tripItem(0, F.checking, C['cat-transport'], 'Uber do aeroporto de Florianópolis', 62),
89
+ tripItem(1, F.secondaryCard, C['cat-food'], 'Restaurante Ostradamus Florianópolis', 380),
90
+ tripItem(1, F.secondaryCard, C['cat-transport'], 'Aluguel de carro Localiza Florianópolis', 640),
91
+ tripItem(2, F.secondaryCard, C['cat-leisure'], 'Passeio de barco Ilha do Campeche Florianópolis', 260),
92
+ tripItem(3, F.wallet, C['cat-food'], 'Almoço Lagoa da Conceição Florianópolis', 145),
93
+ tripItem(4, F.secondaryCard, C['cat-shopping'], 'Lembranças Mercado Público Florianópolis', 320),
94
+ tripItem(4, F.primaryCard, C['cat-food'], 'Jantar Santo Antônio de Lisboa Florianópolis', 290),
95
+ tripItem(5, F.checking, C['cat-transport'], 'Táxi para o aeroporto de Florianópolis', 85),
96
+ ],
97
+ },
98
+ };
@@ -0,0 +1,89 @@
1
+ import { DemoCountry, DemoFunding } from '../../../../models/demo/core.js';
2
+ import { TOUR_FACTS } from '../../../../models/demo/tour.js';
3
+ import { Locale } from '../../../../models/locale.js';
4
+ import { CurrencyCode } from '../../../../models/money.js';
5
+ import { DefaultCategoryId } from '../categories.js';
6
+ import { BUDGET_SHAPES, fixedLine, pendingLine, SPANISH_TAGS, spendLine, tripItem } from './shared.js';
7
+ const C = DefaultCategoryId.enum;
8
+ const F = DemoFunding.enum;
9
+ const WORK = SPANISH_TAGS.work;
10
+ const FAMILY = SPANISH_TAGS.family;
11
+ /** Colombia: es, COP — Nu Colombia, Bancolombia and Davivienda, a trip to Cartagena. */
12
+ export const CO_PACK = {
13
+ country: DemoCountry.enum.co,
14
+ locale: Locale.enum.es,
15
+ currency: CurrencyCode.enum.COP,
16
+ amountStep: 100,
17
+ usdRate: 4100,
18
+ accounts: {
19
+ checking: { name: 'Bancolombia', initialBalance: 6500000 },
20
+ savings: { name: 'Nu Colombia Cajita', initialBalance: 9500000 },
21
+ investment: { name: 'Davivienda Inversión', initialBalance: 28000000 },
22
+ wallet: { name: 'Efectivo', initialBalance: 250000 },
23
+ usdc: { name: 'USDC Cripto', initialBalance: 450 },
24
+ btc: { name: 'BTC Cripto', initialBalance: 0.0185 },
25
+ },
26
+ cards: {
27
+ primary: { name: 'Nu Colombia Tarjeta', closingDay: 5, dueDay: 25, limit: 9000000 },
28
+ secondary: { name: 'Davivienda Visa', closingDay: 20, dueDay: 8, limit: 12000000 },
29
+ },
30
+ tags: [WORK, FAMILY],
31
+ salary: fixedLine(C['cat-salary'], 'Nómina Empresa', 6800000, 28),
32
+ rent: fixedLine(C['cat-housing'], 'Arriendo', 1900000, 3),
33
+ subscriptions: [
34
+ fixedLine(C['cat-subscriptions'], 'Netflix', 26900, 12),
35
+ fixedLine(C['cat-subscriptions'], 'Spotify', 16900, 15),
36
+ fixedLine(C['cat-health'], 'Gimnasio Bodytech', 129900, 8),
37
+ fixedLine(C['cat-utilities'], 'Internet Claro Hogar', 99900, 20),
38
+ ],
39
+ freelance: fixedLine(C['cat-extra-income'], 'Proyecto freelance', 1500000, 18),
40
+ spending: [
41
+ spendLine(F.primaryCard, C['cat-food'], 'Éxito', [140000, 330000], 2),
42
+ spendLine(F.checking, C['cat-food'], 'Carulla', [90000, 220000], 1),
43
+ spendLine(F.wallet, C['cat-food'], 'Plaza de mercado', [40000, 90000], 2),
44
+ spendLine(F.primaryCard, C['cat-food'], 'Rappi', [28000, 75000], 4),
45
+ spendLine(F.secondaryCard, C['cat-food'], 'Restaurante Andrés Carne de Res', [120000, 260000], 1),
46
+ spendLine(F.wallet, C['cat-food'], 'Panadería', [8000, 22000], 3),
47
+ spendLine(F.primaryCard, C['cat-food'], 'Almuerzo con cliente', [70000, 150000], 1, WORK),
48
+ spendLine(F.primaryCard, C['cat-transport'], 'DiDi', [9000, 32000], 5),
49
+ spendLine(F.secondaryCard, C['cat-transport'], 'Uber', [12000, 38000], 2),
50
+ spendLine(F.secondaryCard, C['cat-transport'], 'Estación de servicio Terpel', [130000, 190000], 1),
51
+ spendLine(F.wallet, C['cat-transport'], 'Parqueadero', [6000, 16000], 2),
52
+ spendLine(F.checking, C['cat-health'], 'Droguería Cruz Verde', [25000, 140000], 2),
53
+ spendLine(F.checking, C['cat-health'], 'Consulta Dr. Ramírez', [160000, 160000], 1),
54
+ spendLine(F.primaryCard, C['cat-leisure'], 'Cine Colombia', [22000, 60000], 1),
55
+ spendLine(F.secondaryCard, C['cat-leisure'], 'Bar Theatron', [70000, 180000], 2),
56
+ spendLine(F.secondaryCard, C['cat-shopping'], 'Falabella', [90000, 420000], 1),
57
+ spendLine(F.primaryCard, C['cat-shopping'], 'Mercado Libre', [60000, 350000], 1),
58
+ spendLine(F.secondaryCard, C['cat-shopping'], 'Regalo para la familia', [80000, 220000], 1, FAMILY),
59
+ spendLine(F.checking, C['cat-utilities'], 'Recibo de energía Enel', [120000, 210000], 1),
60
+ spendLine(F.checking, C['cat-utilities'], 'Acueducto', [60000, 110000], 1),
61
+ spendLine(F.checking, C['cat-education'], 'Curso de inglés', [320000, 320000], 1),
62
+ ],
63
+ transfers: {
64
+ savings: { description: 'Ahorro mensual', amount: 800000 },
65
+ investment: { description: 'Aporte a inversión', amount: 600000 },
66
+ wallet: { description: 'Retiro para efectivo', amount: 250000 },
67
+ },
68
+ pending: [
69
+ pendingLine(C['cat-housing'], 'Administración del edificio', 320000, 5),
70
+ pendingLine(C['cat-transport'], 'Seguro del carro', 280000, 9),
71
+ pendingLine(C['cat-extra-income'], 'Reembolso de gastos', 380000, 3, true),
72
+ ],
73
+ budgets: BUDGET_SHAPES,
74
+ trip: {
75
+ destination: TOUR_FACTS[DemoCountry.enum.co].destination,
76
+ items: [
77
+ tripItem(0, F.primaryCard, C['cat-travel'], 'Vuelo Avianca a Cartagena', 620000),
78
+ tripItem(0, F.primaryCard, C['cat-travel'], 'Hotel Casa San Agustín Cartagena', 1850000),
79
+ tripItem(0, F.checking, C['cat-transport'], 'Taxi del aeropuerto de Cartagena', 18000),
80
+ tripItem(1, F.secondaryCard, C['cat-food'], 'Cena en La Cevichería Cartagena', 310000),
81
+ tripItem(1, F.secondaryCard, C['cat-transport'], 'Alquiler de carro Cartagena', 480000),
82
+ tripItem(2, F.secondaryCard, C['cat-leisure'], 'Tour a las Islas del Rosario Cartagena', 280000),
83
+ tripItem(3, F.wallet, C['cat-food'], 'Almuerzo en Getsemaní Cartagena', 95000),
84
+ tripItem(4, F.secondaryCard, C['cat-shopping'], 'Artesanías en el Centro Histórico Cartagena', 240000),
85
+ tripItem(4, F.primaryCard, C['cat-food'], 'Cena en Café del Mar Cartagena', 260000),
86
+ tripItem(5, F.checking, C['cat-transport'], 'Taxi al aeropuerto de Cartagena', 20000),
87
+ ],
88
+ },
89
+ };