@pasosdejesus/m 0.15.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.
Files changed (324) hide show
  1. package/dist/blockchain/deployments.d.ts +40 -0
  2. package/dist/blockchain/deployments.d.ts.map +1 -0
  3. package/dist/blockchain/deployments.js +64 -0
  4. package/dist/debug/DebugConsole.d.ts +22 -0
  5. package/dist/debug/DebugConsole.d.ts.map +1 -0
  6. package/dist/debug/DebugConsole.js +79 -0
  7. package/dist/debug/Logger.d.ts +38 -0
  8. package/dist/debug/Logger.d.ts.map +1 -0
  9. package/dist/debug/Logger.js +94 -0
  10. package/dist/debug/index.d.ts +6 -0
  11. package/dist/debug/index.d.ts.map +1 -0
  12. package/dist/debug/index.js +4 -0
  13. package/dist/debug/useLogger.d.ts +14 -0
  14. package/dist/debug/useLogger.d.ts.map +1 -0
  15. package/dist/debug/useLogger.js +23 -0
  16. package/dist/debug/utils.d.ts +10 -0
  17. package/dist/debug/utils.d.ts.map +1 -0
  18. package/dist/debug/utils.js +53 -0
  19. package/dist/e2e/assertions.d.ts +5 -0
  20. package/dist/e2e/assertions.d.ts.map +1 -0
  21. package/dist/e2e/assertions.js +18 -0
  22. package/dist/e2e/browser.d.ts +37 -0
  23. package/dist/e2e/browser.d.ts.map +1 -0
  24. package/dist/e2e/browser.js +97 -0
  25. package/dist/e2e/env.d.ts +18 -0
  26. package/dist/e2e/env.d.ts.map +1 -0
  27. package/dist/e2e/env.js +57 -0
  28. package/dist/e2e/index.d.ts +11 -0
  29. package/dist/e2e/index.d.ts.map +1 -0
  30. package/dist/e2e/index.js +8 -0
  31. package/dist/e2e/navigation.d.ts +4 -0
  32. package/dist/e2e/navigation.d.ts.map +1 -0
  33. package/dist/e2e/navigation.js +32 -0
  34. package/dist/e2e/siwe-mock.d.ts +11 -0
  35. package/dist/e2e/siwe-mock.d.ts.map +1 -0
  36. package/dist/e2e/siwe-mock.js +112 -0
  37. package/dist/e2e/siwe.d.ts +15 -0
  38. package/dist/e2e/siwe.d.ts.map +1 -0
  39. package/dist/e2e/siwe.js +85 -0
  40. package/dist/e2e/wallet-mock.d.ts +13 -0
  41. package/dist/e2e/wallet-mock.d.ts.map +1 -0
  42. package/dist/e2e/wallet-mock.js +91 -0
  43. package/dist/i18n/common-cli.d.ts +11 -0
  44. package/dist/i18n/common-cli.d.ts.map +1 -0
  45. package/dist/i18n/common-cli.js +22 -0
  46. package/dist/i18n/createTranslator.d.ts +28 -0
  47. package/dist/i18n/createTranslator.d.ts.map +1 -0
  48. package/dist/i18n/createTranslator.js +48 -0
  49. package/dist/i18n/index.d.ts +4 -0
  50. package/dist/i18n/index.d.ts.map +1 -0
  51. package/dist/i18n/index.js +2 -0
  52. package/dist/i18n/locales/cli.d.ts +3 -0
  53. package/dist/i18n/locales/cli.d.ts.map +1 -0
  54. package/dist/i18n/locales/cli.js +180 -0
  55. package/dist/i18n/types.d.ts +3 -0
  56. package/dist/i18n/types.d.ts.map +1 -0
  57. package/dist/i18n/types.js +1 -0
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +15 -0
  61. package/dist/index.test.d.ts +2 -0
  62. package/dist/index.test.d.ts.map +1 -0
  63. package/dist/index.test.js +10 -0
  64. package/dist/m.d.ts +2 -0
  65. package/dist/m.d.ts.map +1 -0
  66. package/dist/m.js +334 -0
  67. package/dist/plugin.d.ts +10 -0
  68. package/dist/plugin.d.ts.map +1 -0
  69. package/dist/plugin.js +7 -0
  70. package/dist/shadcn_components/cn.d.ts +13 -0
  71. package/dist/shadcn_components/cn.d.ts.map +1 -0
  72. package/dist/shadcn_components/cn.js +15 -0
  73. package/dist/shadcn_components/ui/accordion.d.ts +8 -0
  74. package/dist/shadcn_components/ui/accordion.d.ts.map +1 -0
  75. package/dist/shadcn_components/ui/accordion.js +14 -0
  76. package/dist/shadcn_components/ui/alert-dialog.d.ts +21 -0
  77. package/dist/shadcn_components/ui/alert-dialog.d.ts.map +1 -0
  78. package/dist/shadcn_components/ui/alert-dialog.js +27 -0
  79. package/dist/shadcn_components/ui/alert.d.ts +9 -0
  80. package/dist/shadcn_components/ui/alert.d.ts.map +1 -0
  81. package/dist/shadcn_components/ui/alert.js +22 -0
  82. package/dist/shadcn_components/ui/avatar.d.ts +7 -0
  83. package/dist/shadcn_components/ui/avatar.d.ts.map +1 -0
  84. package/dist/shadcn_components/ui/avatar.js +12 -0
  85. package/dist/shadcn_components/ui/badge.d.ts +10 -0
  86. package/dist/shadcn_components/ui/badge.d.ts.map +1 -0
  87. package/dist/shadcn_components/ui/badge.js +22 -0
  88. package/dist/shadcn_components/ui/button.d.ts +11 -0
  89. package/dist/shadcn_components/ui/button.d.ts.map +1 -0
  90. package/dist/shadcn_components/ui/button.js +31 -0
  91. package/dist/shadcn_components/ui/card.d.ts +10 -0
  92. package/dist/shadcn_components/ui/card.d.ts.map +1 -0
  93. package/dist/shadcn_components/ui/card.js +24 -0
  94. package/dist/shadcn_components/ui/checkbox.d.ts +5 -0
  95. package/dist/shadcn_components/ui/checkbox.d.ts.map +1 -0
  96. package/dist/shadcn_components/ui/checkbox.js +9 -0
  97. package/dist/shadcn_components/ui/dialog.d.ts +20 -0
  98. package/dist/shadcn_components/ui/dialog.d.ts.map +1 -0
  99. package/dist/shadcn_components/ui/dialog.js +23 -0
  100. package/dist/shadcn_components/ui/dropdown-menu.d.ts +28 -0
  101. package/dist/shadcn_components/ui/dropdown-menu.d.ts.map +1 -0
  102. package/dist/shadcn_components/ui/dropdown-menu.js +36 -0
  103. package/dist/shadcn_components/ui/form.d.ts +24 -0
  104. package/dist/shadcn_components/ui/form.d.ts.map +1 -0
  105. package/dist/shadcn_components/ui/form.js +63 -0
  106. package/dist/shadcn_components/ui/input.d.ts +4 -0
  107. package/dist/shadcn_components/ui/input.d.ts.map +1 -0
  108. package/dist/shadcn_components/ui/input.js +6 -0
  109. package/dist/shadcn_components/ui/label.d.ts +6 -0
  110. package/dist/shadcn_components/ui/label.d.ts.map +1 -0
  111. package/dist/shadcn_components/ui/label.js +10 -0
  112. package/dist/shadcn_components/ui/menubar.d.ts +29 -0
  113. package/dist/shadcn_components/ui/menubar.d.ts.map +1 -0
  114. package/dist/shadcn_components/ui/menubar.js +46 -0
  115. package/dist/shadcn_components/ui/popover.d.ts +7 -0
  116. package/dist/shadcn_components/ui/popover.d.ts.map +1 -0
  117. package/dist/shadcn_components/ui/popover.js +10 -0
  118. package/dist/shadcn_components/ui/progress.d.ts +5 -0
  119. package/dist/shadcn_components/ui/progress.d.ts.map +1 -0
  120. package/dist/shadcn_components/ui/progress.js +8 -0
  121. package/dist/shadcn_components/ui/radio-group.d.ts +6 -0
  122. package/dist/shadcn_components/ui/radio-group.d.ts.map +1 -0
  123. package/dist/shadcn_components/ui/radio-group.js +15 -0
  124. package/dist/shadcn_components/ui/scroll-area.d.ts +6 -0
  125. package/dist/shadcn_components/ui/scroll-area.d.ts.map +1 -0
  126. package/dist/shadcn_components/ui/scroll-area.js +12 -0
  127. package/dist/shadcn_components/ui/select.d.ts +14 -0
  128. package/dist/shadcn_components/ui/select.d.ts.map +1 -0
  129. package/dist/shadcn_components/ui/select.js +27 -0
  130. package/dist/shadcn_components/ui/separator.d.ts +5 -0
  131. package/dist/shadcn_components/ui/separator.d.ts.map +1 -0
  132. package/dist/shadcn_components/ui/separator.js +8 -0
  133. package/dist/shadcn_components/ui/sheet.d.ts +26 -0
  134. package/dist/shadcn_components/ui/sheet.d.ts.map +1 -0
  135. package/dist/shadcn_components/ui/sheet.js +37 -0
  136. package/dist/shadcn_components/ui/skeleton.d.ts +3 -0
  137. package/dist/shadcn_components/ui/skeleton.d.ts.map +1 -0
  138. package/dist/shadcn_components/ui/skeleton.js +6 -0
  139. package/dist/shadcn_components/ui/slider.d.ts +5 -0
  140. package/dist/shadcn_components/ui/slider.d.ts.map +1 -0
  141. package/dist/shadcn_components/ui/slider.js +8 -0
  142. package/dist/shadcn_components/ui/switch.d.ts +5 -0
  143. package/dist/shadcn_components/ui/switch.d.ts.map +1 -0
  144. package/dist/shadcn_components/ui/switch.js +8 -0
  145. package/dist/shadcn_components/ui/table.d.ts +11 -0
  146. package/dist/shadcn_components/ui/table.d.ts.map +1 -0
  147. package/dist/shadcn_components/ui/table.js +20 -0
  148. package/dist/shadcn_components/ui/tabs.d.ts +8 -0
  149. package/dist/shadcn_components/ui/tabs.d.ts.map +1 -0
  150. package/dist/shadcn_components/ui/tabs.js +13 -0
  151. package/dist/shadcn_components/ui/textarea.d.ts +4 -0
  152. package/dist/shadcn_components/ui/textarea.d.ts.map +1 -0
  153. package/dist/shadcn_components/ui/textarea.js +8 -0
  154. package/dist/shadcn_components/ui/toast.d.ts +16 -0
  155. package/dist/shadcn_components/ui/toast.d.ts.map +1 -0
  156. package/dist/shadcn_components/ui/toast.js +34 -0
  157. package/dist/shadcn_components/ui/toaster.d.ts +2 -0
  158. package/dist/shadcn_components/ui/toaster.d.ts.map +1 -0
  159. package/dist/shadcn_components/ui/toaster.js +10 -0
  160. package/dist/shadcn_components/ui/tooltip.d.ts +8 -0
  161. package/dist/shadcn_components/ui/tooltip.d.ts.map +1 -0
  162. package/dist/shadcn_components/ui/tooltip.js +11 -0
  163. package/dist/shadcn_components/ui/use-toast.d.ts +45 -0
  164. package/dist/shadcn_components/ui/use-toast.d.ts.map +1 -0
  165. package/dist/shadcn_components/ui/use-toast.js +126 -0
  166. package/dist/tasks/context.d.ts +13 -0
  167. package/dist/tasks/context.d.ts.map +1 -0
  168. package/dist/tasks/context.js +310 -0
  169. package/dist/tasks/create.d.ts +2 -0
  170. package/dist/tasks/create.d.ts.map +1 -0
  171. package/dist/tasks/create.js +91 -0
  172. package/dist/tasks/db.d.ts +19 -0
  173. package/dist/tasks/db.d.ts.map +1 -0
  174. package/dist/tasks/db.js +791 -0
  175. package/dist/tasks/e2e.d.ts +2 -0
  176. package/dist/tasks/e2e.d.ts.map +1 -0
  177. package/dist/tasks/e2e.js +124 -0
  178. package/dist/tasks/edit.d.ts +7 -0
  179. package/dist/tasks/edit.d.ts.map +1 -0
  180. package/dist/tasks/edit.js +471 -0
  181. package/dist/tasks/engine.d.ts +2 -0
  182. package/dist/tasks/engine.d.ts.map +1 -0
  183. package/dist/tasks/engine.js +149 -0
  184. package/dist/tasks/env-diff.d.ts +2 -0
  185. package/dist/tasks/env-diff.d.ts.map +1 -0
  186. package/dist/tasks/env-diff.js +140 -0
  187. package/dist/tasks/fuzzy.d.ts +9 -0
  188. package/dist/tasks/fuzzy.d.ts.map +1 -0
  189. package/dist/tasks/fuzzy.js +153 -0
  190. package/dist/tasks/glob.d.ts +5 -0
  191. package/dist/tasks/glob.d.ts.map +1 -0
  192. package/dist/tasks/glob.js +57 -0
  193. package/dist/tasks/grep.d.ts +9 -0
  194. package/dist/tasks/grep.d.ts.map +1 -0
  195. package/dist/tasks/grep.js +93 -0
  196. package/dist/tasks/readfile.d.ts +2 -0
  197. package/dist/tasks/readfile.d.ts.map +1 -0
  198. package/dist/tasks/readfile.js +177 -0
  199. package/dist/tasks/update.d.ts +5 -0
  200. package/dist/tasks/update.d.ts.map +1 -0
  201. package/dist/tasks/update.js +200 -0
  202. package/dist/tasks/util.d.ts +12 -0
  203. package/dist/tasks/util.d.ts.map +1 -0
  204. package/dist/tasks/util.js +42 -0
  205. package/dist/tasks/wallet.d.ts +2 -0
  206. package/dist/tasks/wallet.d.ts.map +1 -0
  207. package/dist/tasks/wallet.js +697 -0
  208. package/dist/tasks/writefile.d.ts +2 -0
  209. package/dist/tasks/writefile.d.ts.map +1 -0
  210. package/dist/tasks/writefile.js +66 -0
  211. package/dist/templates/AGENTS.md.hbs +81 -0
  212. package/dist/templates/ARCHITECTURE.md.hbs +146 -0
  213. package/dist/templates/CONTRIBUTING.md.hbs +83 -0
  214. package/dist/templates/LICENCIA.md +21 -0
  215. package/dist/templates/LICENSE.md +15 -0
  216. package/dist/templates/Makefile +16 -0
  217. package/dist/templates/README.md.hbs +111 -0
  218. package/dist/templates/apps/.env.example.hbs +75 -0
  219. package/dist/templates/apps/hardhat/.prettierrc +16 -0
  220. package/dist/templates/apps/hardhat/MOCK_USDT_README.md +20 -0
  221. package/dist/templates/apps/hardhat/Makefile +13 -0
  222. package/dist/templates/apps/hardhat/README.md +129 -0
  223. package/dist/templates/apps/hardhat/bin/MusdtVerification +4 -0
  224. package/dist/templates/apps/hardhat/bin/approveDepositOwner +7 -0
  225. package/dist/templates/apps/hardhat/bin/contractVerification +9 -0
  226. package/dist/templates/apps/hardhat/bin/deployMockUSDT +7 -0
  227. package/dist/templates/apps/hardhat/bin/prepadJ.sh +14 -0
  228. package/dist/templates/apps/hardhat/bin/verifyMockUSDT +7 -0
  229. package/dist/templates/apps/hardhat/contracts/MockUSDT.sol +47 -0
  230. package/dist/templates/apps/hardhat/hardhat.config.ts +102 -0
  231. package/dist/templates/apps/hardhat/package.json +55 -0
  232. package/dist/templates/apps/hardhat/scripts/approveDepositOwner.ts +22 -0
  233. package/dist/templates/apps/hardhat/scripts/deployMockUSDT.ts +49 -0
  234. package/dist/templates/apps/hardhat/scripts/verifyDeployment.ts +93 -0
  235. package/dist/templates/apps/hardhat/scripts/verifyMockUSDT.ts +52 -0
  236. package/dist/templates/apps/hardhat/sync-abis.mjs +58 -0
  237. package/dist/templates/apps/hardhat/test/MockUSDT.test.ts +40 -0
  238. package/dist/templates/apps/hardhat/tsconfig.json +27 -0
  239. package/dist/templates/apps/nextjs/.config/kysely.config.ts +36 -0
  240. package/dist/templates/apps/nextjs/Makefile +24 -0
  241. package/dist/templates/apps/nextjs/README.md.hbs +76 -0
  242. package/dist/templates/apps/nextjs/abis/IERC20.json +74 -0
  243. package/dist/templates/apps/nextjs/abis/MockUSDT.json +242 -0
  244. package/dist/templates/apps/nextjs/abis/ReentrancyGuard.json +1 -0
  245. package/dist/templates/apps/nextjs/app/globals.css +3 -0
  246. package/dist/templates/apps/nextjs/app/layout.tsx.hbs +26 -0
  247. package/dist/templates/apps/nextjs/app/page.tsx.hbs +225 -0
  248. package/dist/templates/apps/nextjs/app/testui/page.tsx +371 -0
  249. package/dist/templates/apps/nextjs/bin/m +8 -0
  250. package/dist/templates/apps/nextjs/components.json +21 -0
  251. package/dist/templates/apps/nextjs/next-env.d.ts +5 -0
  252. package/dist/templates/apps/nextjs/next.config.ts +10 -0
  253. package/dist/templates/apps/nextjs/package.json.hbs +48 -0
  254. package/dist/templates/apps/nextjs/pnpm-workspace.yaml +13 -0
  255. package/dist/templates/apps/nextjs/postcss.config.mjs +6 -0
  256. package/dist/templates/apps/nextjs/tailwind.config.js +11 -0
  257. package/dist/templates/apps/nextjs/tests/helpers.ts +31 -0
  258. package/dist/templates/apps/nextjs/tests/index.test.ts +7 -0
  259. package/dist/templates/apps/nextjs/tests/setup-env.ts.hbs +8 -0
  260. package/dist/templates/apps/nextjs/tests/test-utils.example.test.ts +168 -0
  261. package/dist/templates/apps/nextjs/tsconfig.json +44 -0
  262. package/dist/templates/apps/nextjs/tsconfig.test.json +38 -0
  263. package/dist/templates/apps/nextjs/vitest.config.ts +13 -0
  264. package/dist/test-utils/fs-mocks.d.ts +32 -0
  265. package/dist/test-utils/fs-mocks.d.ts.map +1 -0
  266. package/dist/test-utils/fs-mocks.js +63 -0
  267. package/dist/test-utils/i18n-mock.d.ts +21 -0
  268. package/dist/test-utils/i18n-mock.d.ts.map +1 -0
  269. package/dist/test-utils/i18n-mock.js +29 -0
  270. package/dist/test-utils/index.d.ts +12 -0
  271. package/dist/test-utils/index.d.ts.map +1 -0
  272. package/dist/test-utils/index.js +11 -0
  273. package/dist/test-utils/kysely-mocks.d.ts +298 -0
  274. package/dist/test-utils/kysely-mocks.d.ts.map +1 -0
  275. package/dist/test-utils/kysely-mocks.js +173 -0
  276. package/dist/test-utils/radix-mocks.d.ts +134 -0
  277. package/dist/test-utils/radix-mocks.d.ts.map +1 -0
  278. package/dist/test-utils/radix-mocks.js +175 -0
  279. package/dist/test-utils/rainbowkit-mocks.d.ts +80 -0
  280. package/dist/test-utils/rainbowkit-mocks.d.ts.map +1 -0
  281. package/dist/test-utils/rainbowkit-mocks.js +247 -0
  282. package/dist/test-utils/viem-mocks.d.ts +86 -0
  283. package/dist/test-utils/viem-mocks.d.ts.map +1 -0
  284. package/dist/test-utils/viem-mocks.js +54 -0
  285. package/dist/util/cli-parser.d.ts +20 -0
  286. package/dist/util/cli-parser.d.ts.map +1 -0
  287. package/dist/util/cli-parser.js +38 -0
  288. package/dist/util/colors.d.ts +5 -0
  289. package/dist/util/colors.d.ts.map +1 -0
  290. package/dist/util/colors.js +5 -0
  291. package/dist/util/locale.d.ts +3 -0
  292. package/dist/util/locale.d.ts.map +1 -0
  293. package/dist/util/locale.js +10 -0
  294. package/dist/wba/client.d.ts +19 -0
  295. package/dist/wba/client.d.ts.map +1 -0
  296. package/dist/wba/client.js +31 -0
  297. package/dist/wba/index.d.ts +4 -0
  298. package/dist/wba/index.d.ts.map +1 -0
  299. package/dist/wba/index.js +2 -0
  300. package/dist/wba/routes/event.d.ts +32 -0
  301. package/dist/wba/routes/event.d.ts.map +1 -0
  302. package/dist/wba/routes/event.js +42 -0
  303. package/dist/wba/routes/index.d.ts +3 -0
  304. package/dist/wba/routes/index.d.ts.map +1 -0
  305. package/dist/wba/routes/index.js +2 -0
  306. package/dist/wba/routes/summary.d.ts +44 -0
  307. package/dist/wba/routes/summary.d.ts.map +1 -0
  308. package/dist/wba/routes/summary.js +146 -0
  309. package/dist/wba/server.d.ts +18 -0
  310. package/dist/wba/server.d.ts.map +1 -0
  311. package/dist/wba/server.js +29 -0
  312. package/dist/wba/types.d.ts +68 -0
  313. package/dist/wba/types.d.ts.map +1 -0
  314. package/dist/wba/types.js +6 -0
  315. package/package.json +223 -0
  316. package/src/blockchain/README.md +80 -0
  317. package/src/debug/README.md +94 -0
  318. package/src/e2e/README.md +105 -0
  319. package/src/i18n/README.md +143 -0
  320. package/src/shadcn_components/README.md +125 -0
  321. package/src/tasks/README.md +69 -0
  322. package/src/test-utils/README.md +638 -0
  323. package/src/util/README.md +18 -0
  324. package/src/wba/README.md +175 -0
@@ -0,0 +1,20 @@
1
+ export interface FlagDef {
2
+ /** 'string' (consumes next arg), 'boolean' (no value), or 'number' (parseInt next arg) */
3
+ type: 'string' | 'boolean' | 'number';
4
+ /** Alternate flag name (e.g. -n for --dry-run) */
5
+ alias?: string;
6
+ }
7
+ /**
8
+ * Parses CLI flags after a subcommand.
9
+ *
10
+ * Usage: const { options, positional } = parseFlags(argv, flagDefs)
11
+ *
12
+ * @param argv Argument array (typically process.argv.slice(2) or slice(3))
13
+ * @param flags Record of flag name → definition
14
+ * @returns { options, positional }
15
+ */
16
+ export declare function parseFlags(argv: string[], flags: Record<string, FlagDef>): {
17
+ options: Record<string, boolean | string | number | undefined>;
18
+ positional: string[];
19
+ };
20
+ //# sourceMappingURL=cli-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-parser.d.ts","sourceRoot":"","sources":["../../src/util/cli-parser.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,0FAA0F;IAC1F,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACtC,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAgC1F"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Parses CLI flags after a subcommand.
3
+ *
4
+ * Usage: const { options, positional } = parseFlags(argv, flagDefs)
5
+ *
6
+ * @param argv Argument array (typically process.argv.slice(2) or slice(3))
7
+ * @param flags Record of flag name → definition
8
+ * @returns { options, positional }
9
+ */
10
+ export function parseFlags(argv, flags) {
11
+ const options = {};
12
+ const positional = [];
13
+ for (let i = 0; i < argv.length; i++) {
14
+ const arg = argv[i];
15
+ // Check flag definitions by name or alias
16
+ let def;
17
+ let defKey;
18
+ for (const [k, d] of Object.entries(flags)) {
19
+ if (arg === `--${k}` || (d.alias && arg === d.alias)) {
20
+ def = d;
21
+ defKey = k;
22
+ break;
23
+ }
24
+ }
25
+ if (!def) {
26
+ positional.push(arg);
27
+ continue;
28
+ }
29
+ if (def.type === 'boolean') {
30
+ options[defKey] = true;
31
+ }
32
+ else if (i + 1 < argv.length) {
33
+ i++;
34
+ options[defKey] = def.type === 'number' ? parseInt(argv[i], 10) : argv[i];
35
+ }
36
+ }
37
+ return { options, positional };
38
+ }
@@ -0,0 +1,5 @@
1
+ export declare const success: (message: string) => void;
2
+ export declare const problem: (message: string) => void;
3
+ export declare const info: (message: string) => void;
4
+ export declare const warn: (message: string) => void;
5
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/util/colors.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,SAAmC,CAAC;AAC3E,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,SAAmC,CAAC;AAC3E,eAAO,MAAM,IAAI,GAAI,SAAS,MAAM,SAAkC,CAAC;AACvE,eAAO,MAAM,IAAI,GAAI,SAAS,MAAM,SAAqC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import pc from 'picocolors';
2
+ export const success = (message) => console.log(pc.green(message));
3
+ export const problem = (message) => console.error(pc.red(message));
4
+ export const info = (message) => console.log(pc.cyan(message));
5
+ export const warn = (message) => console.warn(pc.yellow(message));
@@ -0,0 +1,3 @@
1
+ export declare function detectLocale(): string;
2
+ export declare function setLocale(locale: string): void;
3
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/util/locale.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,QAEvC"}
@@ -0,0 +1,10 @@
1
+ let currentLocale = null;
2
+ export function detectLocale() {
3
+ if (currentLocale)
4
+ return currentLocale;
5
+ const locale = process.env.LANG || process.env.LC_MESSAGES || process.env.LC_ALL || 'en_US.UTF-8';
6
+ return locale.split('.')[0].split('_')[0];
7
+ }
8
+ export function setLocale(locale) {
9
+ currentLocale = locale;
10
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Client-side event sending — framework-agnostic.
3
+ *
4
+ * Fire-and-forget POST to a project-provided endpoint.
5
+ */
6
+ /**
7
+ * Sends an analytics event from the browser.
8
+ *
9
+ * @param url Full URL of the event endpoint
10
+ * (e.g. `/api/web-analytics/event`).
11
+ * @param eventType The event type string.
12
+ * @param metadata Optional structured metadata.
13
+ * @param extra Extra fields to include (e.g. wallet, session_id).
14
+ */
15
+ export declare function sendEvent(url: string, eventType: string, metadata?: Record<string, unknown>, extra?: {
16
+ wallet?: string;
17
+ session_id?: string;
18
+ }): void;
19
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/wba/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,KAAK,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C,IAAI,CAgBN"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Client-side event sending — framework-agnostic.
3
+ *
4
+ * Fire-and-forget POST to a project-provided endpoint.
5
+ */
6
+ /**
7
+ * Sends an analytics event from the browser.
8
+ *
9
+ * @param url Full URL of the event endpoint
10
+ * (e.g. `/api/web-analytics/event`).
11
+ * @param eventType The event type string.
12
+ * @param metadata Optional structured metadata.
13
+ * @param extra Extra fields to include (e.g. wallet, session_id).
14
+ */
15
+ export function sendEvent(url, eventType, metadata, extra) {
16
+ if (typeof window === 'undefined')
17
+ return; // SSR guard
18
+ fetch(url, {
19
+ method: 'POST',
20
+ headers: { 'Content-Type': 'application/json' },
21
+ body: JSON.stringify({
22
+ event_type: eventType,
23
+ metadata: metadata ?? null,
24
+ wallet: extra?.wallet ?? null,
25
+ session_id: extra?.session_id ?? null,
26
+ }),
27
+ keepalive: true,
28
+ }).catch(() => {
29
+ /* fire-and-forget — ignore network errors */
30
+ });
31
+ }
@@ -0,0 +1,4 @@
1
+ export type { WebEvent, SummaryResponse, SummaryOptions, ScalarResult, TopPageRow, } from './types.js';
2
+ export { recordEvent } from './server.js';
3
+ export { sendEvent } from './client.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wba/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { recordEvent } from './server.js';
2
+ export { sendEvent } from './client.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Next.js POST route factory for recording analytics events.
3
+ *
4
+ * Usage in a Next.js project:
5
+ *
6
+ * ```typescript
7
+ * // app/api/web-analytics/event/route.ts
8
+ * import { makeEventHandler } from '@pasosdejesus/m/wba/routes'
9
+ * import { newKyselyPostgresql } from '@/.config/kysely.config'
10
+ *
11
+ * export const POST = makeEventHandler(() => newKyselyPostgresql(), 'web_event')
12
+ * ```
13
+ *
14
+ * The factory reads `x-forwarded-for`, `user-agent`, and `referer` from
15
+ * request headers to enrich the event automatically.
16
+ */
17
+ import { type Kysely } from 'kysely';
18
+ import { NextRequest, NextResponse } from 'next/server.js';
19
+ type DbFactory = () => Kysely<unknown>;
20
+ /**
21
+ * Creates a Next.js POST handler that records an analytics event.
22
+ *
23
+ * @param dbFactory Function that returns a fresh Kysely instance per request.
24
+ * @param table Name of the event table (default `'web_event'`).
25
+ */
26
+ export declare function makeEventHandler(dbFactory: DbFactory, table?: string): (request: NextRequest) => Promise<NextResponse<{
27
+ error: string;
28
+ }> | NextResponse<{
29
+ success: boolean;
30
+ }>>;
31
+ export {};
32
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/wba/routes/event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAI1D,KAAK,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;AAEtC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,SAAc,IAC7C,SAAS,WAAW;;;;IA4ChD"}
@@ -0,0 +1,42 @@
1
+ import { NextResponse } from 'next/server.js';
2
+ import { recordEvent } from '../server.js';
3
+ /**
4
+ * Creates a Next.js POST handler that records an analytics event.
5
+ *
6
+ * @param dbFactory Function that returns a fresh Kysely instance per request.
7
+ * @param table Name of the event table (default `'web_event'`).
8
+ */
9
+ export function makeEventHandler(dbFactory, table = 'web_event') {
10
+ return async function POST(request) {
11
+ try {
12
+ const body = await request.json();
13
+ if (!body.event_type || typeof body.event_type !== 'string') {
14
+ return NextResponse.json({ error: 'event_type is required' }, { status: 400 });
15
+ }
16
+ // Enrich with request headers
17
+ const ip = request.headers.get('x-forwarded-for')?.split(',')[0]?.trim() ??
18
+ request.headers.get('x-real-ip') ??
19
+ undefined;
20
+ const userAgent = request.headers.get('user-agent') ?? undefined;
21
+ const referrer = request.headers.get('referer') ??
22
+ request.headers.get('referrer') ??
23
+ undefined;
24
+ const enriched = {
25
+ ...body,
26
+ ip: body.ip ?? ip,
27
+ user_agent: body.user_agent ?? userAgent,
28
+ referrer: body.referrer ?? referrer,
29
+ // If not provided via body, pathname from referrer path as fallback
30
+ pathname: body.pathname,
31
+ locale: body.locale,
32
+ };
33
+ const db = dbFactory();
34
+ await recordEvent(db, table, enriched);
35
+ return NextResponse.json({ success: true });
36
+ }
37
+ catch (error) {
38
+ console.error('[wba/event] Failed to record event:', error);
39
+ return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
40
+ }
41
+ };
42
+ }
@@ -0,0 +1,3 @@
1
+ export { makeEventHandler } from './event.js';
2
+ export { makeSummaryHandler, verifyTransactionSchema, verifyWebEventSchema } from './summary.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wba/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { makeEventHandler } from './event.js';
2
+ export { makeSummaryHandler, verifyTransactionSchema, verifyWebEventSchema } from './summary.js';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Next.js GET route factory for the analytics summary endpoint.
3
+ *
4
+ * Usage:
5
+ *
6
+ * ```typescript
7
+ * // app/api/web-analytics/summary/route.ts
8
+ * import { makeSummaryHandler } from '@pasosdejesus/m/wba/routes'
9
+ * import { newKyselyPostgresql } from '@/.config/kysely.config'
10
+ *
11
+ * export const GET = makeSummaryHandler(
12
+ * () => newKyselyPostgresql(),
13
+ * { transactionTable: 'transaction' },
14
+ * )
15
+ * ```
16
+ */
17
+ import { type Kysely } from 'kysely';
18
+ import { NextRequest, NextResponse } from 'next/server.js';
19
+ import type { SummaryOptions, SummaryResponse } from '../types.js';
20
+ /**
21
+ * Verify that the web_event table has the expected columns.
22
+ */
23
+ export declare function verifyWebEventSchema(db: Kysely<unknown>, tableName?: string): Promise<{
24
+ columns: number;
25
+ missing: string[];
26
+ colTypes: Record<string, string>;
27
+ } | null>;
28
+ /**
29
+ * Verify that the transaction table has the expected English columns.
30
+ * Throws with a descriptive message if columns are missing.
31
+ */
32
+ export declare function verifyTransactionSchema(db: Kysely<unknown>, tableName?: string): Promise<void>;
33
+ type DbFactory = () => Kysely<unknown>;
34
+ /**
35
+ * Creates a Next.js GET handler that returns the analytics summary.
36
+ *
37
+ * @param dbFactory Function that returns a fresh Kysely instance per request.
38
+ * @param opts Optional overrides (e.g. transaction table name).
39
+ */
40
+ export declare function makeSummaryHandler(dbFactory: DbFactory, opts?: SummaryOptions): (_request: NextRequest) => Promise<NextResponse<SummaryResponse> | NextResponse<{
41
+ error: string;
42
+ }>>;
43
+ export {};
44
+ //# sourceMappingURL=summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/wba/routes/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEhB,MAAM,aAAa,CAAA;AAEpB;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,SAAc;;;;UAmBtF;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,SAAgB,iBAmB3F;AAED,KAAK,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;AAStC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,IAAI,CAAC,EAAE,cAAc,IAIK,UAAU,WAAW;;IA6GhD"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Next.js GET route factory for the analytics summary endpoint.
3
+ *
4
+ * Usage:
5
+ *
6
+ * ```typescript
7
+ * // app/api/web-analytics/summary/route.ts
8
+ * import { makeSummaryHandler } from '@pasosdejesus/m/wba/routes'
9
+ * import { newKyselyPostgresql } from '@/.config/kysely.config'
10
+ *
11
+ * export const GET = makeSummaryHandler(
12
+ * () => newKyselyPostgresql(),
13
+ * { transactionTable: 'transaction' },
14
+ * )
15
+ * ```
16
+ */
17
+ import { sql } from 'kysely';
18
+ import { NextResponse } from 'next/server.js';
19
+ /**
20
+ * Verify that the web_event table has the expected columns.
21
+ */
22
+ export async function verifyWebEventSchema(db, tableName = 'web_event') {
23
+ const result = await sql `
24
+ SELECT column_name, data_type
25
+ FROM information_schema.columns
26
+ WHERE table_name = ${tableName}
27
+ ORDER BY column_name
28
+ `.execute(db);
29
+ const rows = result.rows;
30
+ if (rows.length === 0)
31
+ return null; // table doesn't exist — not an error
32
+ const columns = new Set(rows.map(r => r.column_name));
33
+ const required = ['id', 'event_type', 'pathname', 'created_at'];
34
+ const missing = required.filter(c => !columns.has(c));
35
+ const colTypes = {};
36
+ for (const r of rows)
37
+ colTypes[r.column_name] = r.data_type;
38
+ return { columns: rows.length, missing, colTypes };
39
+ }
40
+ /**
41
+ * Verify that the transaction table has the expected English columns.
42
+ * Throws with a descriptive message if columns are missing.
43
+ */
44
+ export async function verifyTransactionSchema(db, tableName = 'transaction') {
45
+ const result = await sql `
46
+ SELECT column_name, data_type
47
+ FROM information_schema.columns
48
+ WHERE table_name = ${tableName}
49
+ ORDER BY column_name
50
+ `.execute(db);
51
+ const columns = new Set(result.rows.map(r => r.column_name));
52
+ const required = ['crypto', 'amount', 'wallet'];
53
+ const missing = required.filter(c => !columns.has(c));
54
+ if (missing.length > 0) {
55
+ throw new Error(`Transaction table "${tableName}" is missing required columns: ${missing.join(', ')}.\n` +
56
+ `Expected schema: crypto VARCHAR, amount NUMERIC, wallet VARCHAR(42).\n` +
57
+ `If migrating from Spanish column names, rename: cantidad → amount, billetera → wallet.`);
58
+ }
59
+ }
60
+ const toNum = (rows) => rows?.[0] ? Number(rows[0].v ?? 0) : 0;
61
+ const toStr = (rows, fallback = '0') => rows?.[0] ? String(rows[0].v ?? fallback) : fallback;
62
+ /**
63
+ * Creates a Next.js GET handler that returns the analytics summary.
64
+ *
65
+ * @param dbFactory Function that returns a fresh Kysely instance per request.
66
+ * @param opts Optional overrides (e.g. transaction table name).
67
+ */
68
+ export function makeSummaryHandler(dbFactory, opts) {
69
+ const txTable = opts?.transactionTable ?? 'transaction';
70
+ return async function GET(_request) {
71
+ try {
72
+ const db = dbFactory();
73
+ const [views24h, views7d, views30d, sessions24h, sessions7d, sessions30d, wallets24h, wallets7d, ips24h, ips7d, donationStarted24h, donationCompleted24h, topPages, errorTotal24h, totalDonations, totalUsdtDonated, uniqueDonors,] = await Promise.all([
74
+ // page views
75
+ sql `SELECT count(*)::int8 AS v FROM web_event WHERE event_type = 'pageview' AND created_at >= now() - interval '24 hours'`.execute(db),
76
+ sql `SELECT count(*)::int8 AS v FROM web_event WHERE event_type = 'pageview' AND created_at >= now() - interval '7 days'`.execute(db),
77
+ sql `SELECT count(*)::int8 AS v FROM web_event WHERE event_type = 'pageview' AND created_at >= now() - interval '30 days'`.execute(db),
78
+ // unique sessions
79
+ sql `SELECT count(DISTINCT session_id)::int8 AS v FROM web_event WHERE event_type = 'pageview' AND session_id IS NOT NULL AND created_at >= now() - interval '24 hours'`.execute(db),
80
+ sql `SELECT count(DISTINCT session_id)::int8 AS v FROM web_event WHERE event_type = 'pageview' AND session_id IS NOT NULL AND created_at >= now() - interval '7 days'`.execute(db),
81
+ sql `SELECT count(DISTINCT session_id)::int8 AS v FROM web_event WHERE event_type = 'pageview' AND session_id IS NOT NULL AND created_at >= now() - interval '30 days'`.execute(db),
82
+ // unique wallets
83
+ sql `SELECT count(DISTINCT wallet)::int8 AS v FROM web_event WHERE wallet IS NOT NULL AND created_at >= now() - interval '24 hours'`.execute(db),
84
+ sql `SELECT count(DISTINCT wallet)::int8 AS v FROM web_event WHERE wallet IS NOT NULL AND created_at >= now() - interval '7 days'`.execute(db),
85
+ // unique IPs
86
+ sql `SELECT count(DISTINCT ip)::int8 AS v FROM web_event WHERE ip IS NOT NULL AND created_at >= now() - interval '24 hours'`.execute(db),
87
+ sql `SELECT count(DISTINCT ip)::int8 AS v FROM web_event WHERE ip IS NOT NULL AND created_at >= now() - interval '7 days'`.execute(db),
88
+ // donation conversion (24h)
89
+ sql `SELECT count(*)::int8 AS v FROM web_event WHERE event_type = 'donation_started' AND created_at >= now() - interval '24 hours'`.execute(db),
90
+ sql `SELECT count(*)::int8 AS v FROM web_event WHERE event_type = 'donation_completed' AND created_at >= now() - interval '24 hours'`.execute(db),
91
+ // top pages (30d)
92
+ sql `SELECT pathname, count(*)::int8 AS cnt FROM web_event WHERE event_type = 'pageview' AND pathname IS NOT NULL AND created_at >= now() - interval '30 days' GROUP BY pathname ORDER BY count(*) DESC LIMIT 10`.execute(db),
93
+ // errors (24h)
94
+ sql `SELECT count(*)::int8 AS v FROM web_event WHERE event_type = 'api_error' AND created_at >= now() - interval '24 hours'`.execute(db),
95
+ // on-chain: donation count
96
+ sql `SELECT count(*)::int8 AS v FROM ${sql.raw(txTable)} WHERE crypto = 'usdt'`.execute(db),
97
+ // on-chain: total USDT donated
98
+ sql `SELECT coalesce(sum(amount::numeric), 0)::text AS v FROM ${sql.raw(txTable)} WHERE crypto = 'usdt'`.execute(db),
99
+ // on-chain: unique donors
100
+ sql `SELECT count(DISTINCT wallet)::int8 AS v FROM ${sql.raw(txTable)} WHERE crypto = 'usdt'`.execute(db),
101
+ ]);
102
+ const started = toNum(donationStarted24h.rows);
103
+ const completed = toNum(donationCompleted24h.rows);
104
+ const summary = {
105
+ pageViews: {
106
+ '24h': toNum(views24h.rows),
107
+ '7d': toNum(views7d.rows),
108
+ '30d': toNum(views30d.rows),
109
+ },
110
+ uniqueSessions: {
111
+ '24h': toNum(sessions24h.rows),
112
+ '7d': toNum(sessions7d.rows),
113
+ '30d': toNum(sessions30d.rows),
114
+ },
115
+ uniqueWallets: {
116
+ '24h': toNum(wallets24h.rows),
117
+ '7d': toNum(wallets7d.rows),
118
+ },
119
+ uniqueIps: {
120
+ '24h': toNum(ips24h.rows),
121
+ '7d': toNum(ips7d.rows),
122
+ },
123
+ donationConversion: {
124
+ started,
125
+ completed,
126
+ rate: started > 0 ? Math.round((completed / started) * 100) : 0,
127
+ },
128
+ errors24h: toNum(errorTotal24h.rows),
129
+ topPages: topPages.rows.map((r) => ({
130
+ path: r.pathname,
131
+ views: Number(r.cnt),
132
+ })),
133
+ onChain: {
134
+ totalDonations: toNum(totalDonations.rows),
135
+ totalUsdtDonated: toStr(totalUsdtDonated.rows),
136
+ uniqueDonors: toNum(uniqueDonors.rows),
137
+ },
138
+ };
139
+ return NextResponse.json(summary);
140
+ }
141
+ catch (error) {
142
+ console.error('[wba/summary] Error:', error);
143
+ return NextResponse.json({ error: 'Failed to load analytics' }, { status: 500 });
144
+ }
145
+ };
146
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Server-side event recording — framework-agnostic.
3
+ *
4
+ * Inject your own Kysely instance and table name.
5
+ * No `next/headers` dependency — the caller is responsible for
6
+ * enriching the event with IP, user-agent, referrer, etc.
7
+ */
8
+ import type { Kysely } from 'kysely';
9
+ import type { WebEvent } from './types.js';
10
+ /**
11
+ * Inserts a row into the analytics event table. Never throws.
12
+ *
13
+ * @param db A Kysely instance connected to the project's database.
14
+ * @param table Name of the event table (e.g. `'web_event'`, `'userevent'`).
15
+ * @param event The event to record — the caller enriches with headers.
16
+ */
17
+ export declare function recordEvent(db: Kysely<unknown>, table: string, event: WebEvent): Promise<void>;
18
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/wba/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,QAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAqBf"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Inserts a row into the analytics event table. Never throws.
3
+ *
4
+ * @param db A Kysely instance connected to the project's database.
5
+ * @param table Name of the event table (e.g. `'web_event'`, `'userevent'`).
6
+ * @param event The event to record — the caller enriches with headers.
7
+ */
8
+ export async function recordEvent(db, table, event) {
9
+ try {
10
+ const { session_id, event_type, pathname, locale, referrer, user_agent, ip, wallet, metadata } = event;
11
+ await db
12
+ .insertInto(table)
13
+ .values({
14
+ session_id: session_id ?? null,
15
+ event_type,
16
+ pathname: pathname ?? null,
17
+ locale: locale ?? null,
18
+ referrer: referrer ?? null,
19
+ user_agent: user_agent ?? null,
20
+ ip: ip ?? null,
21
+ wallet: wallet ?? null,
22
+ metadata: metadata != null ? JSON.stringify(metadata) : null,
23
+ })
24
+ .execute();
25
+ }
26
+ catch (error) {
27
+ console.error('[wba/recordEvent] Failed to record event:', error);
28
+ }
29
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Web + Blockchain Analytics — types
3
+ *
4
+ * Frameworks-agnostic types shared between sivel.xyz and learn.tg.
5
+ */
6
+ /** Event to record into `web_event` (or equivalent) table. */
7
+ export interface WebEvent {
8
+ session_id?: string;
9
+ event_type: string;
10
+ pathname?: string;
11
+ locale?: string;
12
+ referrer?: string;
13
+ user_agent?: string;
14
+ ip?: string;
15
+ wallet?: string;
16
+ metadata?: Record<string, unknown>;
17
+ }
18
+ /** Row returned by the summary endpoint. */
19
+ export interface SummaryResponse {
20
+ pageViews: {
21
+ '24h': number;
22
+ '7d': number;
23
+ '30d': number;
24
+ };
25
+ uniqueSessions: {
26
+ '24h': number;
27
+ '7d': number;
28
+ '30d': number;
29
+ };
30
+ uniqueWallets: {
31
+ '24h': number;
32
+ '7d': number;
33
+ };
34
+ uniqueIps: {
35
+ '24h': number;
36
+ '7d': number;
37
+ };
38
+ donationConversion: {
39
+ started: number;
40
+ completed: number;
41
+ rate: number;
42
+ };
43
+ errors24h: number;
44
+ topPages: {
45
+ path: string;
46
+ views: number;
47
+ }[];
48
+ onChain: {
49
+ totalDonations: number;
50
+ totalUsdtDonated: string;
51
+ uniqueDonors: number;
52
+ };
53
+ }
54
+ /** Optional overrides for the summary handler. */
55
+ export interface SummaryOptions {
56
+ /** Name of the on-chain transaction table (default: 'transaction'). */
57
+ transactionTable?: string;
58
+ }
59
+ /** A single numeric result from a Kysely aggregation query. */
60
+ export interface ScalarResult {
61
+ v: string | number | bigint | undefined;
62
+ }
63
+ /** A row with pathname + count for top-pages query. */
64
+ export interface TopPageRow {
65
+ pathname: string;
66
+ cnt: number | bigint;
67
+ }
68
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/wba/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,QAAQ;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACzD,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9D,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1C,kBAAkB,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxE,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC3C,OAAO,EAAE;QACP,cAAc,EAAE,MAAM,CAAA;QACtB,gBAAgB,EAAE,MAAM,CAAA;QACxB,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;CACF;AAED,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACxC;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Web + Blockchain Analytics — types
3
+ *
4
+ * Frameworks-agnostic types shared between sivel.xyz and learn.tg.
5
+ */
6
+ export {};