@adriangalilea/utils 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -33
- package/dist/bot/create.d.ts.map +1 -1
- package/dist/bot/create.js +8 -5
- package/dist/bot/create.js.map +1 -1
- package/dist/bot/payments/handlers.d.ts.map +1 -1
- package/dist/bot/payments/handlers.js +58 -18
- package/dist/bot/payments/handlers.js.map +1 -1
- package/dist/bot/payments/invoice.d.ts.map +1 -1
- package/dist/bot/payments/invoice.js +26 -8
- package/dist/bot/payments/invoice.js.map +1 -1
- package/dist/bot/payments/refund.d.ts.map +1 -1
- package/dist/bot/payments/refund.js +18 -10
- package/dist/bot/payments/refund.js.map +1 -1
- package/dist/bot/payments/waiver.js +3 -3
- package/dist/bot/payments/waiver.js.map +1 -1
- package/dist/bot/profile.d.ts.map +1 -1
- package/dist/bot/profile.js +18 -11
- package/dist/bot/profile.js.map +1 -1
- package/dist/bot/storage-d1.d.ts.map +1 -1
- package/dist/bot/storage-d1.js +4 -4
- package/dist/bot/storage-d1.js.map +1 -1
- package/dist/bot/storage.js +5 -5
- package/dist/bot/storage.js.map +1 -1
- package/dist/bot/worker.d.ts.map +1 -1
- package/dist/bot/worker.js +23 -11
- package/dist/bot/worker.js.map +1 -1
- package/dist/offensive.d.ts.map +1 -1
- package/dist/offensive.js +3 -4
- package/dist/offensive.js.map +1 -1
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +12 -0
- package/dist/runtime.js.map +1 -1
- package/dist/universal/format.d.ts +3 -2
- package/dist/universal/format.d.ts.map +1 -1
- package/dist/universal/format.js +3 -2
- package/dist/universal/format.js.map +1 -1
- package/dist/universal/log.d.ts +176 -95
- package/dist/universal/log.d.ts.map +1 -1
- package/dist/universal/log.js +677 -217
- package/dist/universal/log.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ts-utils
|
|
2
2
|
|
|
3
|
-
TypeScript utilities - logger, currency, offensive programming, file operations, environment management, and more. The sibling of [swift-utils](https://github.com/adriangalilea/swift-utils), [py-utils](https://github.com/adriangalilea/py-utils), and [go-utils](https://github.com/adriangalilea/go-utils). The logging
|
|
3
|
+
TypeScript utilities - logger, currency, offensive programming, file operations, environment management, and more. The sibling of [swift-utils](https://github.com/adriangalilea/swift-utils), [py-utils](https://github.com/adriangalilea/py-utils), and [go-utils](https://github.com/adriangalilea/go-utils). The logging contract the three share, and the harness that proves they write the same event stream, live in [utils](https://github.com/adriangalilea/utils).
|
|
4
4
|
|
|
5
5
|
## Product metrics
|
|
6
6
|
|
|
@@ -87,50 +87,99 @@ pnpm add @adriangalilea/utils
|
|
|
87
87
|
|
|
88
88
|
### Logger
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
A program's logs and traces are one stream of events. A line is an event; a span is a piece of work written as a start and an end; every line written through a span carries its id. go-utils and py-utils write the same stream byte for byte, so their output can be read, merged and traced together. The contract, its JSON schema and the harness that runs all three live in [utils](https://github.com/adriangalilea/utils).
|
|
91
91
|
|
|
92
92
|
```typescript
|
|
93
|
-
import {
|
|
93
|
+
import { log } from '@adriangalilea/utils/log'
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
log.info('ready')
|
|
96
|
+
log.warn('retrying', { attempt: 2 })
|
|
97
|
+
log.error('charge failed', { err })
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Every verb takes a message, then optional fields. The message says what happened, the fields say with what. Fields are a plain object; anything else (an `Error`, a string, extra arguments) panics.
|
|
101
|
+
|
|
102
|
+
| verb | level | human |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| `error`, `fail` | error | `⨯` |
|
|
105
|
+
| `warn` | warn | `⚠` |
|
|
106
|
+
| `warnOnce` | warn, once per message and scope (bounded memory) | `⚠` |
|
|
107
|
+
| `info` | info | |
|
|
108
|
+
| `success` | info | `✓` |
|
|
109
|
+
| `wait` | info | `○` |
|
|
110
|
+
| `ready` | info | `▶` |
|
|
111
|
+
| `step` | info | `•`, indented |
|
|
112
|
+
| `debug` | debug | `◦` |
|
|
113
|
+
| `trace` | trace | `»` |
|
|
106
114
|
|
|
107
|
-
|
|
108
|
-
warnOnce('This warning appears only once')
|
|
115
|
+
**Scopes.** `log.scope('api')` returns a child logger whose events carry `["api"]`; `log.scope('api').scope('auth')` carries `["api", "auth"]`.
|
|
109
116
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
**Spans.** A span is a logger: what is written through it belongs to it, and nothing else does (there is no ambient context, a function that logs inside a span takes the span). `span` returns what the callback returns, a Promise when it is async; a throw ends the span failed, with the error in `fields.err`, and is rethrown.
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
await log.span('sync', { repo }, async (s) => {
|
|
121
|
+
s.info('cloned', { files: 3 })
|
|
122
|
+
await s.span('build', async (c) => { c.step('compiling') })
|
|
123
|
+
s.set({ pushed: true }) // carried on the span's end event
|
|
124
|
+
})
|
|
114
125
|
|
|
115
|
-
//
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
// Work that does not fit a block: open it, end it once (twice panics).
|
|
127
|
+
const up = log.begin('upload', { size })
|
|
128
|
+
stream.on('end', () => up.end())
|
|
129
|
+
stream.on('error', (err) => up.end(err))
|
|
119
130
|
```
|
|
120
131
|
|
|
121
|
-
|
|
132
|
+
**Traces cross processes explicitly.** `s.traceparent()` is the W3C value to hand on, in an HTTP `traceparent` header or the `TRACEPARENT` env of a child process. `log.join(req.headers.get('traceparent'))` returns a logger whose spans are children of that remote span; `null` or `undefined` returns the logger itself, and a malformed value is ignored with one warn per distinct value. A process started with `TRACEPARENT` set joins it for every root span, with no code.
|
|
133
|
+
|
|
134
|
+
**Levels.** `silent < error < warn < info < debug < trace`, default `info`. A scoped event reads its threshold live from the most specific variable set: `["api", "auth"]` reads `API_AUTH_LOG_LEVEL`, then `API_LOG_LEVEL`, then `LOG_LEVEL`, then `setLogLevel()`, then `info`. `GZIP_LOG_LEVEL=silent` shuts one subsystem up without touching code. Whether a span is shown is decided once, when it begins; a hidden span writes no end, and what it holds (lines, child spans, `traceparent()`) attaches to the nearest shown span, so a viewer never meets a missing parent. A remote span joined through `join` or `TRACEPARENT` counts as shown. With no shown ancestor, a hidden span's lines carry no ids, as lines outside any span.
|
|
122
135
|
|
|
123
|
-
|
|
136
|
+
**Renderings.** `json` is one event per line on stderr, keys in the contract's order, fields sorted at every depth, errors as `{type, message, stack, cause, …}`:
|
|
124
137
|
|
|
125
|
-
|
|
126
|
-
-
|
|
138
|
+
```json
|
|
139
|
+
{"time":"2026-10-12T12:20:39.123Z","level":"warn","verb":"warn","msg":"retrying","service":"checkout","scope":["payments"],"trace_id":"4bf92f3577b34da6a3ce929d0e0e4736","span_id":"00f067aa0ba902b7","fields":{"attempt":2}}
|
|
140
|
+
```
|
|
127
141
|
|
|
128
|
-
|
|
142
|
+
`human` is symbols, colour (TTY, `NO_COLOR`, `FORCE_COLOR`), fields dim as `key=value`, an error's stack under its line, and spans with what they hold indented:
|
|
129
143
|
|
|
130
144
|
```
|
|
131
|
-
|
|
145
|
+
○ sync repo=ui
|
|
146
|
+
cloned files=3
|
|
147
|
+
○ build
|
|
148
|
+
• compiling
|
|
149
|
+
✓ build 51ms
|
|
150
|
+
✓ sync 51ms pushed=true
|
|
132
151
|
```
|
|
133
152
|
|
|
153
|
+
Node, Bun and Deno write every event through `console.error` (stdout stays data, and a `cli` live region keeps lines above it); browsers and Workers use the level's console method.
|
|
154
|
+
|
|
155
|
+
**Configuration.** Each variable has a setter. The setter is the program's default and the variable, read live, overrides it. Values match without regard to case, an empty variable is unset, and an unknown value panics.
|
|
156
|
+
|
|
157
|
+
| variable | setter | values | default |
|
|
158
|
+
|---|---|---|---|
|
|
159
|
+
| `LOG_FORMAT` | `setLogFormat` | `human`, `json` | Node: human when stderr is a TTY, else json. Browser: human. Worker: json |
|
|
160
|
+
| `LOG_TIME` | `setLogTime` | `1`, `0` | off. Puts a dim local `HH:MM:SS` before human lines; json always carries `time` |
|
|
161
|
+
| `LOG_LEVEL`, `{SCOPE}_LOG_LEVEL` | `setLogLevel` | the levels | `info` |
|
|
162
|
+
| `LOG_SERVICE` | `setLogService` | a name | the entry script's name without extension. A Worker or browser has none: set it, or the first json event panics |
|
|
163
|
+
|
|
164
|
+
**Reading the stream.** `LogEvent` is the wire shape as a type (a line, a span start, an ok end or a failed end, discriminated by `phase` and `status`), and `parseEvent(line)` reads one line back: an event, `null` for a line that is not one (pass it through), or a `Panic` for a JSON object with a `verb` key that breaks the shape.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { parseEvent, type LogEvent } from '@adriangalilea/utils/log'
|
|
168
|
+
|
|
169
|
+
const e = parseEvent(line)
|
|
170
|
+
if (e?.phase === 'end') e.dur_ms
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Migrating from 8.x
|
|
174
|
+
|
|
175
|
+
- Messages are one string plus fields: `log.warn('retry', n, err)` becomes `log.warn('retry', { attempt: n, err })`, and `log.scope(e.source).error(e.operation, e.toJSON())` becomes `log.scope(e.source).error(e.operation, { err: e })`.
|
|
176
|
+
- Import `log` and call its verbs: the bare `info`, `warn`, `scope`, … exports are gone.
|
|
177
|
+
- `time`/`timeEnd` are gone: wrap the work in `log.span(name, fn)`, which writes its duration.
|
|
178
|
+
- `LOG_FORMAT=record` and `setLogFormat('record')` are gone: `json` replaces the record line, and `logs` from go-utils renders a file back into a greppable line.
|
|
179
|
+
- The environment now wins over `setLogFormat` and `setLogTime`, and `LOG_TIME` is off by default.
|
|
180
|
+
- A Worker that writes json must call `setLogService(name)`.
|
|
181
|
+
- `SourcedError.message` is the message given, without the `[source:operation]` prefix.
|
|
182
|
+
|
|
134
183
|
### Currency
|
|
135
184
|
|
|
136
185
|
Currency utilities with comprehensive crypto support (500+ symbols):
|
|
@@ -479,7 +528,7 @@ catch (e) {
|
|
|
479
528
|
return { error: 'card declined' }
|
|
480
529
|
}
|
|
481
530
|
if (isSourcedError(e)) {
|
|
482
|
-
log.scope(e.source).error(e.operation, e
|
|
531
|
+
log.scope(e.source).error(e.operation, { err: e }) // source, operation, status, context, cause
|
|
483
532
|
throw e
|
|
484
533
|
}
|
|
485
534
|
throw e // unknown — re-throw
|
|
@@ -490,7 +539,7 @@ Every `SourcedError` carries `source`, `operation`, `status`, `context`, and the
|
|
|
490
539
|
|
|
491
540
|
## Features
|
|
492
541
|
|
|
493
|
-
- **Logger**:
|
|
542
|
+
- **Logger**: one event stream shared byte for byte with go-utils and py-utils (lines and spans, W3C trace ids), json or human rendering, scoped env-controlled levels
|
|
494
543
|
- **Currency**:
|
|
495
544
|
- 13,750+ crypto symbols from CoinGecko (auto-updatable)
|
|
496
545
|
- Alternative ticker support (XBT→BTC, wrapped tokens, etc.)
|
|
@@ -691,7 +740,7 @@ Telegram's [Threaded Mode](https://telegram.org/blog/threaded-conversations) for
|
|
|
691
740
|
| `@adriangalilea/utils/metrics/sqlite` | Atomic SQLite driver, explicit provisioning schema, and inclusive UTC daily reports; libSQL is its own module (`metrics/libsql`) over the same driver shape. Connections and credentials belong to the application. |
|
|
692
741
|
| `@adriangalilea/utils/bot/menu` | `botMenu({ command, description, items, privacy?, personalData?, adminContact })` — `/settings` command + InlineKeyboard router. Root view always renders a `🛡️ Privacy & data` submenu button that wraps the privacy policy link plus (if `personalData: { storage }`) 🗑 Forget + 📥 Export buttons. Items take `keepRow` (render on the same row as the next item — e.g. a two-per-row language picker) and `rootExtra` (render at the bottom of the root menu, below Privacy & data). `label` / `header` / `style` / `visible` resolvers may be **async** (read your db at render time — never cache render strings in the session); `parseMode: 'HTML'` renders the header formatted (you own escaping); `personalData.onForget(ctx, userId)` wipes YOUR tables inside the same try as the session delete, so Forget either forgets everything or reports failure. `toggleMenuItem({ id, read, write, label: { off, on }, toast? })` — convenience factory for boolean-toggle items with dynamic label + optional toast, storage-agnostic via `read`/`write` closures. |
|
|
693
742
|
| `@adriangalilea/utils/bot/payments` | `botPayments({ session, storage, paysupport, paysupportHint?, legal, waiver, vip?, credits?, perks? })` — Telegram Stars monetization in one drop-in plugin. **Three axes, all optional:** `vip` (positional tier ladder — single rung in v1 is just `vip: [{...}]`, ladder is `vip: [{...}, {...}]`; ids are `vip.1`, `vip.2`, …), `credits` (consumable balance + top-up packs `credits.1`, `credits.2`, …), `perks` (orthogonal one-shot unlocks `perks.<key>`). **Surface:** `ctx.payments.atLeast('vip')` / `atLeast('vip.2')` (typed rank check), `ctx.payments.tier()` / `.tier.level()` / `.tier.label()`, `ctx.payments.credits.{balance, consume, tryConsume}` (throws `InsufficientCredits`), `ctx.payments.has(perkId)`, `await ctx.payments.require('vip', { feature? })` (gate that sends a localized upgrade prompt deep-linked to `/settings → 💎 VIP`), `await ctx.payments.invoice(productKey)` (threads Art. 103(m) TRLGDCU consent inline before `sendInvoice`). **Owns:** waiver consent flow (versioned text → forces re-consent on bump, snapshotted on every charge for audit), `/paysupport` slash command (Telegram ToS §6.5; `paysupportHint` overrides the where-to-manage-charges line when your menu isn't `/settings`), idempotent `successful_payment` fulfillment via `pay:idempotency:{chargeId}` sentinel, lazy subscription expiry (no cron needed), tier upgrade auto-cancel of the lower rung's renewal, and admin-DM refund approval (mirror of `accessControl`'s [✅ Aprobar][❌ Denegar] pattern). **Returns:** `{ plugin, menuItem, payouts, admin, onFulfilled, onRefunded }` — `menuItem` is the drop-in `💎 VIP` entry for `botMenu`; `admin.{listCharges, getCharge}` backs custom admin commands; `payouts.{record, list, export, exportForUsers}` is the Fragment payout ledger (you receive TON, log the EUR conversion, export time-windowed CSV/JSON for your gestor); `onFulfilled(productKey \| '*', handler)` / `onRefunded(...)` register fire-and-forget hooks (purchase applied / admin-approved refund — a revenue ledger writes on one, reverses on the other). **Stars-only by design** — Telegram ToS §6.2 forbids third-party payment providers for digital goods. Crypto Pay deferred (MiCA risk); Stripe-outside-Telegram is a future v2 channel. Full compliance memo (Spanish-autónomo seller-of-record analysis, Verifactu vs Crea y Crece, MiCA, Art. 103(m) waiver text, GDPR retention) in `src/bot/payments/CLAUDE.md`. |
|
|
694
|
-
| `@adriangalilea/utils/bot/create` | `createBot<S>({ token?, storage?, initial?, admins?, language?, menu?, access?, payments?, handlers?, worker? })` — the composer (see "One bot file, ideation → production" above). Returns `{ build, session, poll, isMain, fetch }`: `poll()` long-polls, `export default app` is a complete Worker, `app.session(ctx)` / the `handlers` callback's `session(ctx)` is the TYPED accessor for your `S` fields. Owns storage+session wiring; resolves storage per environment (D1 binding → `bot/storage-d1`; `BOT_PERSIST` path → sqlite, `redis://` → redis, lazily-imported optional peers; else announced-ephemeral memory) — or pass `storage: (env) => Storage` when the choice is env-dependent (e.g. a D1 binding not named `DB`). Boot NARRATES the composition (`session
|
|
743
|
+
| `@adriangalilea/utils/bot/create` | `createBot<S>({ token?, storage?, initial?, admins?, language?, menu?, access?, payments?, handlers?, worker? })` — the composer (see "One bot file, ideation → production" above). Returns `{ build, session, poll, isMain, fetch }`: `poll()` long-polls, `export default app` is a complete Worker, `app.session(ctx)` / the `handlers` callback's `session(ctx)` is the TYPED accessor for your `S` fields. Owns storage+session wiring; resolves storage per environment (D1 binding → `bot/storage-d1`; `BOT_PERSIST` path → sqlite, `redis://` → redis, lazily-imported optional peers; else announced-ephemeral memory) — or pass `storage: (env) => Storage` when the choice is env-dependent (e.g. a D1 binding not named `DB`). Boot NARRATES the composition (`session storage kind="memory (ephemeral …)"`, `features features=["language(en,es)","menu(/settings)"]`) so every implicit decision is visible where you're looking. Runnable demo: `pnpm demo:bot`. |
|
|
695
744
|
| `@adriangalilea/utils/bot/worker` | `botWorkerFetch(resolve)` — the Cloudflare Worker cap: secret-checked webhook (ack fast, work + storage flush ride `ctx.waitUntil`, errors DM admins throttled), `POST /setup` (webhook registration with handler-derived `allowed_updates` + a commit-narrating 🚀 deploy DM from the request body), `POST /deploy-started` (the 🛳 "what is shipping" DM — curl it from your deploy script on the still-live version, body `{sha, author, message, etaSeconds?}`), operator-authed `/pause` `/resume` `/webhook-status` (+ `statusExtra`), and a `routes` escape hatch tried before the built-ins. Structural bot type — no workers-types dependency. |
|
|
696
745
|
| `@adriangalilea/utils/bot/flags` | `defineFlags(spec, { read, write? })` — feature flags declared ONCE in code, resolved LIVE from the bot's operator-config record (D1 json row, Redis hash — storage-agnostic, Worker-safe, zero deps). Each flag: `{ kind: 'bool'\|'number'\|'string', label, help?, default }`, where `default` is a scalar or a **tier map** `{ free, vip?, 'vip.N'? }` resolved off `ctx.payments.tier()` — "free users get this limit, premium users get that model" is one declaration, zero branching at the call site (ladder walks down: exact rung → lower rungs → `vip` → `free`). Read sites: `await flags.<key>(ctx)` — stored override wins over the code default, per-ctx reads coalesce into one config fetch. `flags.describe()` is the JSON schema admin panels render generically, so a new flag appears in every panel with zero panel edits; `flags.set(ctx, key, value)` writes a kind-checked live override (`null` clears it — RFC 7386 null-delete, matching SQLite `json_patch`); `flags.overrides(ctx)` lists what's overridden. Corrupt stored values scream (`SourcedError`); bad specs panic at construction. |
|
|
697
746
|
| `@adriangalilea/utils/bot/storage-d1` | `d1Storage({ db, table? })` — `@gramio/storage` adapter over a D1 `session` table (schema in the module doc). `flush()` matters: the session plugin writes un-awaited and workerd freezes the isolate the instant `fetch()` returns — hand `flush` to `bot/worker` (automatic via `createBot`) so writes survive. |
|
package/dist/bot/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/bot/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,Q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E,KAAK,CACJ,GAAG,CAAC,EAAE,OAAO,GACX,OAAO,CAAC;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC;IACxE,kFAAkF;IAClF,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,CAAC,CAAC;IACzB,oGAAoG;IACpG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,+FAA+F;IAC/F,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAClC,iFAAiF;IACjF,KAAK,CACJ,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE;QAAE,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;KAAE,GAC3C,OAAO,CAAC,QAAQ,CAAC,CAAC;CACrB,CAAC;AAkBF,wBAAgB,SAAS,CACxB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1D,IAAI,GAAE,gBAAgB,CAAC,CAAC,CAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAmN3C"}
|
package/dist/bot/create.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
import { inMemoryStorage } from "@gramio/storage";
|
|
32
32
|
import { Bot } from "gramio";
|
|
33
33
|
import { runtime } from "../runtime.js";
|
|
34
|
-
import {
|
|
34
|
+
import { log as root } from "../universal/log.js";
|
|
35
35
|
import { accessControl } from "./access-control.js";
|
|
36
36
|
import { adminContext } from "./admin.js";
|
|
37
37
|
import { language } from "./language.js";
|
|
@@ -40,7 +40,7 @@ import { botPayments } from "./payments/index.js";
|
|
|
40
40
|
import { botSession } from "./session.js";
|
|
41
41
|
import { d1Storage } from "./storage-d1.js";
|
|
42
42
|
import { botWorkerFetch } from "./worker.js";
|
|
43
|
-
const log = scope("bot");
|
|
43
|
+
const log = root.scope("bot");
|
|
44
44
|
// Optional Node-only peers, loaded lazily on the poll path. The specifier goes
|
|
45
45
|
// through a variable so TS doesn't demand types for an optional dependency.
|
|
46
46
|
async function importPeer(name, why) {
|
|
@@ -104,7 +104,7 @@ export function createBot(opts = {}) {
|
|
|
104
104
|
const e = env ?? (runtime.isNode ? process.env : {});
|
|
105
105
|
const bot = new Bot(resolveToken(e));
|
|
106
106
|
const { storage, kind, flush } = await resolveStorage(e);
|
|
107
|
-
log.info(
|
|
107
|
+
log.info("session storage", { kind });
|
|
108
108
|
// ONE session, threaded everywhere — the composer's whole job.
|
|
109
109
|
const session = botSession({
|
|
110
110
|
storage,
|
|
@@ -168,7 +168,7 @@ export function createBot(opts = {}) {
|
|
|
168
168
|
: null,
|
|
169
169
|
].filter(Boolean);
|
|
170
170
|
if (features.length > 0)
|
|
171
|
-
log.info(
|
|
171
|
+
log.info("features", { features });
|
|
172
172
|
return { bot, storage, flush };
|
|
173
173
|
})();
|
|
174
174
|
return built;
|
|
@@ -207,7 +207,10 @@ export function createBot(opts = {}) {
|
|
|
207
207
|
async poll() {
|
|
208
208
|
const { bot } = await build();
|
|
209
209
|
await bot.start();
|
|
210
|
-
log.ready(
|
|
210
|
+
log.ready("polling", {
|
|
211
|
+
bot: opts.name ?? "bot",
|
|
212
|
+
username: bot.info?.username,
|
|
213
|
+
});
|
|
211
214
|
},
|
|
212
215
|
isMain(meta) {
|
|
213
216
|
const main = meta.main;
|
package/dist/bot/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/bot/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,eAAe,EAAgB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7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@@
|
|
|
22
22
|
*/
|
|
23
23
|
import { panic, SourcedError } from "../../offensive.js";
|
|
24
24
|
import { say } from "../../say/index.js";
|
|
25
|
-
import {
|
|
25
|
+
import { log as root } from "../../universal/log.js";
|
|
26
26
|
import { ctxLang, FALLBACK_LANG } from "../lang.js";
|
|
27
27
|
import { decodePayload } from "./payload.js";
|
|
28
28
|
import { applyCharge } from "./state.js";
|
|
29
|
-
const log = scope("bot/payments");
|
|
29
|
+
const log = root.scope("bot/payments");
|
|
30
30
|
// Single-sourced product discriminator. Order (vip, credits, perk-default)
|
|
31
31
|
// is load-bearing: it mirrors the prefix checks both builders rely on.
|
|
32
32
|
const kindOf = (product) => product.id.startsWith("vip.")
|
|
@@ -50,9 +50,15 @@ const kindOf = (product) => product.id.startsWith("vip.")
|
|
|
50
50
|
* user sees Telegram's "Payment failed" sheet with that reason.
|
|
51
51
|
*/
|
|
52
52
|
export const buildPreCheckoutHandler = (catalog) => async (ctx) => {
|
|
53
|
-
log.success(
|
|
53
|
+
log.success("pre_checkout_query received", {
|
|
54
|
+
user: ctx.from.id,
|
|
55
|
+
currency: ctx.currency,
|
|
56
|
+
amount: ctx.totalAmount,
|
|
57
|
+
payload: ctx.invoicePayload,
|
|
58
|
+
id: ctx.id,
|
|
59
|
+
});
|
|
54
60
|
const reject = async (reasonEn, reasonEs) => {
|
|
55
|
-
log.warn(
|
|
61
|
+
log.warn("pre_checkout rejecting", { reason: reasonEn, id: ctx.id });
|
|
56
62
|
try {
|
|
57
63
|
await ctx.bot.api.answerPreCheckoutQuery({
|
|
58
64
|
pre_checkout_query_id: ctx.id,
|
|
@@ -64,7 +70,7 @@ export const buildPreCheckoutHandler = (catalog) => async (ctx) => {
|
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
72
|
catch (e) {
|
|
67
|
-
log.error(
|
|
73
|
+
log.error("answerPreCheckoutQuery failed", { ok: false, err: e });
|
|
68
74
|
}
|
|
69
75
|
};
|
|
70
76
|
if (ctx.currency !== "XTR") {
|
|
@@ -89,7 +95,11 @@ export const buildPreCheckoutHandler = (catalog) => async (ctx) => {
|
|
|
89
95
|
await reject(`Price changed (expected ${product.xtr}, got ${ctx.totalAmount}).`, "Precio cambiado.");
|
|
90
96
|
return;
|
|
91
97
|
}
|
|
92
|
-
log.success(
|
|
98
|
+
log.success("pre_checkout approving", {
|
|
99
|
+
product: decoded.productKey,
|
|
100
|
+
user: ctx.from.id,
|
|
101
|
+
amount: ctx.totalAmount,
|
|
102
|
+
});
|
|
93
103
|
try {
|
|
94
104
|
await ctx.bot.api.answerPreCheckoutQuery({
|
|
95
105
|
pre_checkout_query_id: ctx.id,
|
|
@@ -97,7 +107,7 @@ export const buildPreCheckoutHandler = (catalog) => async (ctx) => {
|
|
|
97
107
|
});
|
|
98
108
|
}
|
|
99
109
|
catch (e) {
|
|
100
|
-
log.error(
|
|
110
|
+
log.error("answerPreCheckoutQuery failed", { ok: true, err: e });
|
|
101
111
|
}
|
|
102
112
|
};
|
|
103
113
|
// ─── successful_payment handler ────────────────────────────────────
|
|
@@ -150,15 +160,23 @@ const buildChargeRecord = (product, userId, payment, waiverSnapshot) => {
|
|
|
150
160
|
export const buildSuccessfulPaymentHandler = (opts) => async (ctx) => {
|
|
151
161
|
const payment = ctx.eventPayment?.payload;
|
|
152
162
|
if (!payment) {
|
|
153
|
-
log.warn("successful_payment
|
|
163
|
+
log.warn("successful_payment without ctx.eventPayment.payload, gramio context shape changed?");
|
|
154
164
|
return;
|
|
155
165
|
}
|
|
156
166
|
if (payment.currency !== "XTR")
|
|
157
167
|
return; // fiat — not ours
|
|
158
|
-
log.success(
|
|
168
|
+
log.success("successful_payment received", {
|
|
169
|
+
charge_id: payment.telegram_payment_charge_id,
|
|
170
|
+
amount: payment.total_amount,
|
|
171
|
+
payload: payment.invoice_payload,
|
|
172
|
+
subscription_expires: payment.subscription_expiration_date,
|
|
173
|
+
});
|
|
159
174
|
const decoded = decodePayload(payment.invoice_payload);
|
|
160
175
|
if (!decoded) {
|
|
161
|
-
log.error(
|
|
176
|
+
log.error("successful_payment payload undecodable, fulfillment skipped", {
|
|
177
|
+
charge_id: payment.telegram_payment_charge_id,
|
|
178
|
+
payload: payment.invoice_payload,
|
|
179
|
+
});
|
|
162
180
|
return;
|
|
163
181
|
}
|
|
164
182
|
const userId = ctx.from?.id ?? decoded.userId;
|
|
@@ -170,12 +188,17 @@ export const buildSuccessfulPaymentHandler = (opts) => async (ctx) => {
|
|
|
170
188
|
// bounded by Telegram's retry delay and acceptable for v1.
|
|
171
189
|
const claimed = await opts.stores.idempotency.claim(ctx, payment.telegram_payment_charge_id);
|
|
172
190
|
if (!claimed) {
|
|
173
|
-
log.info(
|
|
191
|
+
log.info("successful_payment already fulfilled, no-op", {
|
|
192
|
+
charge_id: payment.telegram_payment_charge_id,
|
|
193
|
+
});
|
|
174
194
|
return;
|
|
175
195
|
}
|
|
176
196
|
const product = opts.catalog.byKey.get(decoded.productKey);
|
|
177
197
|
if (!product) {
|
|
178
|
-
log.error(
|
|
198
|
+
log.error("successful_payment for unknown productKey, config drift?", {
|
|
199
|
+
product_key: decoded.productKey,
|
|
200
|
+
charge_id: payment.telegram_payment_charge_id,
|
|
201
|
+
});
|
|
179
202
|
return;
|
|
180
203
|
}
|
|
181
204
|
const waiverSnapshot = ctx.session.pay?.waiver;
|
|
@@ -187,7 +210,10 @@ export const buildSuccessfulPaymentHandler = (opts) => async (ctx) => {
|
|
|
187
210
|
// snapshot" entry that's auditable. The `panic` is
|
|
188
211
|
// intentionally after the persistence path on purpose to keep
|
|
189
212
|
// the user whole; the next event will crash.
|
|
190
|
-
log.error(
|
|
213
|
+
log.error("CRITICAL: successful_payment without prior waiver, gate bypassed?", {
|
|
214
|
+
user: userId,
|
|
215
|
+
charge_id: payment.telegram_payment_charge_id,
|
|
216
|
+
});
|
|
191
217
|
}
|
|
192
218
|
const charge = buildChargeRecord(product, userId, payment, waiverSnapshot ?? {
|
|
193
219
|
at: Date.now(),
|
|
@@ -198,7 +224,13 @@ export const buildSuccessfulPaymentHandler = (opts) => async (ctx) => {
|
|
|
198
224
|
// (Idempotency sentinel was already claimed above.)
|
|
199
225
|
await opts.stores.charges.set(ctx, charge.chargeId, charge);
|
|
200
226
|
await opts.stores.userCharges(userId).prepend(ctx, charge.chargeId);
|
|
201
|
-
log.info(
|
|
227
|
+
log.info("charge persisted", {
|
|
228
|
+
charge_id: charge.chargeId,
|
|
229
|
+
product: charge.productKey,
|
|
230
|
+
user: userId,
|
|
231
|
+
xtr: charge.xtr,
|
|
232
|
+
credits_granted: charge.creditsGranted,
|
|
233
|
+
});
|
|
202
234
|
// 2. Apply to session (cache). Capture the previous vip chargeId
|
|
203
235
|
// FIRST so we can cancel its renewal below if this was an upgrade.
|
|
204
236
|
const previousVipChargeId = ctx.session.pay?.vip?.chargeId;
|
|
@@ -221,11 +253,15 @@ export const buildSuccessfulPaymentHandler = (opts) => async (ctx) => {
|
|
|
221
253
|
telegram_payment_charge_id: previousVipChargeId,
|
|
222
254
|
is_canceled: true,
|
|
223
255
|
});
|
|
224
|
-
log.info(
|
|
256
|
+
log.info("auto-canceled previous vip rung on upgrade", {
|
|
257
|
+
from_rung: previousVipRung,
|
|
258
|
+
to_rung: charge.vipRung,
|
|
259
|
+
user: userId,
|
|
260
|
+
});
|
|
225
261
|
}
|
|
226
262
|
catch (e) {
|
|
227
263
|
// Already canceled, expired, etc. Log; don't block fulfillment.
|
|
228
|
-
log.warn(
|
|
264
|
+
log.warn("auto-cancel of the previous vip subscription failed, likely already canceled or expired", { user: userId, previous_charge_id: previousVipChargeId, err: e });
|
|
229
265
|
}
|
|
230
266
|
}
|
|
231
267
|
// 4. User-facing confirmation
|
|
@@ -248,13 +284,17 @@ export const buildSuccessfulPaymentHandler = (opts) => async (ctx) => {
|
|
|
248
284
|
fn(event, ctx);
|
|
249
285
|
}
|
|
250
286
|
catch (e) {
|
|
251
|
-
log.error(
|
|
287
|
+
log.error("onFulfilled handler threw", { key, err: e });
|
|
252
288
|
}
|
|
253
289
|
}
|
|
254
290
|
};
|
|
255
291
|
fireBucket(product.id);
|
|
256
292
|
fireBucket("*");
|
|
257
|
-
log.success(
|
|
293
|
+
log.success("fulfillment complete", {
|
|
294
|
+
product: product.id,
|
|
295
|
+
user: userId,
|
|
296
|
+
charge_id: charge.chargeId,
|
|
297
|
+
});
|
|
258
298
|
// 6. Sanity-fail AFTER everything has been persisted + the user
|
|
259
299
|
// has their confirmation — defensive, see CRITICAL log above.
|
|
260
300
|
if (!waiverSnapshot) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/bot/payments/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/bot/payments/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAazC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAgDvC,2EAA2E;AAC3E,uEAAuE;AACvE,MAAM,MAAM,GAAG,CACd,OAA6D,EAChC,EAAE,CAC/B,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,MA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qEAAqE;AACrE,KAAK,iBAAiB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAyHF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GACjC,KAAK,UAAU,EACf,KAAK,iBAAiB,CAAC,MAAM,CAAC,EAC9B,SAAS,eAAe,GAAG,mBAAmB,GAAG,YAAY,EAC7D,QAAQ,MAAM,KACZ,OAAO,CAAC,IAAI,CA2Dd,CAAC;AAIF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAC7B,cAAc,GACd,oBAAoB,GACpB,iBAAiB,CAAC;AAErB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAC1B,KAAK,UAAU,GAAG;IACjB,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D,EACD,KAAK,iBAAiB,CAAC,MAAM,CAAC,EAC9B,SAAS,cAAc,EACvB,YAAY,MAAM,KAChB,OAAO,CAAC,oBAAoB,CA4C9B,CAAC"}
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { panic, SourcedError } from "../../offensive.js";
|
|
20
20
|
import { say } from "../../say/index.js";
|
|
21
|
-
import {
|
|
21
|
+
import { log as root } from "../../universal/log.js";
|
|
22
22
|
import { ctxLang, FALLBACK_LANG } from "../lang.js";
|
|
23
23
|
import { encodePayload } from "./payload.js";
|
|
24
24
|
import { renderConsentBody, waiverKeyboard } from "./waiver.js";
|
|
25
|
-
const log = scope("bot/payments");
|
|
25
|
+
const log = root.scope("bot/payments");
|
|
26
26
|
// Telegram caps from the Bot API (sendInvoice §):
|
|
27
27
|
const TITLE_MAX = 32;
|
|
28
28
|
const DESCRIPTION_MAX = 255;
|
|
@@ -140,14 +140,23 @@ export const sendInvoiceForProduct = async (ctx, cfg, product, userId) => {
|
|
|
140
140
|
if (product.id.startsWith("vip.")) {
|
|
141
141
|
params.subscription_period = product.periodSeconds;
|
|
142
142
|
}
|
|
143
|
-
log.success(
|
|
143
|
+
log.success("sendInvoice sent to telegram", {
|
|
144
|
+
product: product.id,
|
|
145
|
+
user: userId,
|
|
146
|
+
xtr: product.xtr,
|
|
147
|
+
title,
|
|
148
|
+
subscription_period: params.subscription_period,
|
|
149
|
+
});
|
|
144
150
|
try {
|
|
145
151
|
await ctx.bot.api.sendInvoice(params);
|
|
146
|
-
log.success(
|
|
152
|
+
log.success("sendInvoice accepted by telegram", {
|
|
153
|
+
product: product.id,
|
|
154
|
+
user: userId,
|
|
155
|
+
});
|
|
147
156
|
}
|
|
148
157
|
catch (e) {
|
|
149
158
|
const msg = e instanceof Error ? e.message : String(e);
|
|
150
|
-
log.error(
|
|
159
|
+
log.error("sendInvoice rejected by telegram", { err: e });
|
|
151
160
|
// Hint on the specific subscription-export setup gotcha — there's
|
|
152
161
|
// no documented fix path in gramio/telegram docs, so surface ours.
|
|
153
162
|
if (msg.includes("SUBSCRIPTION_EXPORT_MISSING")) {
|
|
@@ -179,7 +188,7 @@ export const sendInvoiceForProduct = async (ctx, cfg, product, userId) => {
|
|
|
179
188
|
export const presentInvoice = async (ctx, cfg, catalog, productKey) => {
|
|
180
189
|
const product = catalog.byKey.get(productKey);
|
|
181
190
|
if (!product) {
|
|
182
|
-
log.warn(
|
|
191
|
+
log.warn("presentInvoice unknown productKey", { product_key: productKey });
|
|
183
192
|
const lang = ctxLang(ctx);
|
|
184
193
|
await ctx.send(say({
|
|
185
194
|
en: `❌ Unknown product "${productKey}".`,
|
|
@@ -194,14 +203,23 @@ export const presentInvoice = async (ctx, cfg, catalog, productKey) => {
|
|
|
194
203
|
const stored = ctx.session?.pay?.waiver;
|
|
195
204
|
const fresh = stored && stored.version === cfg.waiver.version;
|
|
196
205
|
if (!fresh) {
|
|
197
|
-
log.info(
|
|
206
|
+
log.info("presentInvoice sending waiver consent prompt", {
|
|
207
|
+
waiver: stored ? "stale" : "missing",
|
|
208
|
+
stored_version: stored?.version,
|
|
209
|
+
current_version: cfg.waiver.version,
|
|
210
|
+
product: product.id,
|
|
211
|
+
user: userId,
|
|
212
|
+
});
|
|
198
213
|
const lang = ctxLang(ctx);
|
|
199
214
|
await ctx.send(renderConsentBody(cfg, lang), {
|
|
200
215
|
reply_markup: waiverKeyboard(cfg, product.id, lang),
|
|
201
216
|
});
|
|
202
217
|
return "waiver_prompt_sent";
|
|
203
218
|
}
|
|
204
|
-
log.info(
|
|
219
|
+
log.info("presentInvoice waiver fresh, sending invoice", {
|
|
220
|
+
product: product.id,
|
|
221
|
+
user: userId,
|
|
222
|
+
});
|
|
205
223
|
await sendInvoiceForProduct(ctx, cfg, product, userId);
|
|
206
224
|
return "invoice_sent";
|
|
207
225
|
};
|