@solobrand/platform 0.0.0-stage → 0.1.1

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 (46) hide show
  1. package/README.md +172 -2
  2. package/dist/client.d.ts +122 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +419 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/env.d.ts +17 -0
  7. package/dist/env.d.ts.map +1 -0
  8. package/dist/env.js +61 -0
  9. package/dist/env.js.map +1 -0
  10. package/dist/flush.d.ts +31 -0
  11. package/dist/flush.d.ts.map +1 -0
  12. package/dist/flush.js +54 -0
  13. package/dist/flush.js.map +1 -0
  14. package/dist/index.d.ts +78 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +29 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/mailer.d.ts +10 -0
  19. package/dist/mailer.d.ts.map +1 -0
  20. package/dist/mailer.js +10 -0
  21. package/dist/mailer.js.map +1 -0
  22. package/dist/messages.d.ts +3 -0
  23. package/dist/messages.d.ts.map +1 -0
  24. package/dist/messages.js +34 -0
  25. package/dist/messages.js.map +1 -0
  26. package/dist/outbox.d.ts +48 -0
  27. package/dist/outbox.d.ts.map +1 -0
  28. package/dist/outbox.js +62 -0
  29. package/dist/outbox.js.map +1 -0
  30. package/dist/provider.d.ts +53 -0
  31. package/dist/provider.d.ts.map +1 -0
  32. package/dist/provider.js +149 -0
  33. package/dist/provider.js.map +1 -0
  34. package/dist/sale.d.ts +7 -0
  35. package/dist/sale.d.ts.map +1 -0
  36. package/dist/sale.js +8 -0
  37. package/dist/sale.js.map +1 -0
  38. package/dist/signature.d.ts +30 -0
  39. package/dist/signature.d.ts.map +1 -0
  40. package/dist/signature.js +82 -0
  41. package/dist/signature.js.map +1 -0
  42. package/dist/ulid.d.ts +7 -0
  43. package/dist/ulid.d.ts.map +1 -0
  44. package/dist/ulid.js +23 -0
  45. package/dist/ulid.js.map +1 -0
  46. package/package.json +50 -4
package/README.md CHANGED
@@ -1,3 +1,173 @@
1
- # Temporary Holding Version
1
+ # @solobrand/platform
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Bridge to SoloBrand: CRM events, the services layer, measurement.
4
+
5
+ Part of the [SoloBrand framework](../../README.md). Public API: `src/index.ts` (frozen types, see CONTRIBUTING.md).
6
+
7
+ An app never holds a provider key. Mail, AI, images… are asked of SoloBrand with the app's own
8
+ token, and SoloBrand charges credits. An app **is** an event source of the CRM.
9
+
10
+ ## Env (Worker vars / secrets) — all required
11
+
12
+ | Name | What |
13
+ |---|---|
14
+ | `SOLOBRAND_EVENTS_URL` | Where events are POSTed (https; http only to `localhost`). |
15
+ | `SOLOBRAND_EVENTS_KEY` | The event source's signing key (secret, ≥ 16 chars). |
16
+ | `SOLOBRAND_SERVICES_URL` | Base of the services layer (https). |
17
+ | `SOLOBRAND_APP_TOKEN` | The app's token (secret), sent as `Authorization: Bearer` to services only. |
18
+
19
+ `createPlatformClient` fails at once on a missing one with
20
+ `AppError('internal', 'platform.env_missing', { params: { missing: 'A, B' } })` listing **every**
21
+ missing name (never values); a bad URL/short key gives `platform.env_invalid`.
22
+
23
+ `platformProvider()` is lazy: the app boots without them (local dev, tests, an app not linked
24
+ yet). On first use it logs `platform.not_configured` once and the client degrades: an event goes
25
+ to the outbox if there is one (the cron sends it once the app is linked) or is dropped with
26
+ `platform.event_dropped` (type and id only); `services.call` and `mail.send` answer
27
+ `err(platform.env_missing | platform.env_invalid)`. Nothing is thrown at the request.
28
+ `platformProvider({ strict: true })` keeps the old boot check.
29
+
30
+ ## Use
31
+
32
+ ```ts
33
+ import { platformMailer, platformProvider, platformToken } from '@solobrand/platform';
34
+ import { authTokens } from '@solobrand/auth';
35
+
36
+ // One client per container: a request scope gets its own, delivering in that request's waitUntil.
37
+ app.register(platformProvider({ ctx: (c) => c.make(httpTokens.context).execution }));
38
+ // …or bind it in the request scope: ctx.container.instance(platformExecutionToken, ctx.execution)
39
+ app.singleton(authTokens.mailer, (c) => platformMailer(c.make(platformToken))); // auth mails via SoloBrand
40
+
41
+ const platform = app.make(platformToken);
42
+ await platform.events.emit({ type: 'reserva.creada', contact: { email }, data: { seats: 2 } });
43
+ await platform.events.sale.paid({ amount_minor: 1999, currency: 'MXN', sale_id: 's_1' }); // crm.sale.paid
44
+ const r = await platform.services.call<{ text: string }>('ai.complete', { prompt });
45
+ if (!r.ok) return r; // AppError shape: e.g. 402 → { code: 'unavailable', messageKey: 'platform.no_credits' }
46
+ ```
47
+
48
+ Cron (`scheduled`): `ctx.waitUntil(flushPlatformOutboxOf(createApp(env)))` retries what the
49
+ outbox holds; without an outbox or without `SOLOBRAND_*` it returns zeros.
50
+
51
+ Or directly: `createPlatformClient(env, ctx, options?)`. `events.sale.paid / refunded / failed` is part of
52
+ `PlatformClient` (emits `crm.sale.*`). `saleEvents(client)` and the type `SoloBrandPlatformClient` remain
53
+ as **deprecated** aliases from the first release.
54
+
55
+ ## Events — the wire format (SoloBrand aligns to this)
56
+
57
+ `POST ${SOLOBRAND_EVENTS_URL}`, `Content-Type: application/json`, body:
58
+
59
+ ```json
60
+ { "id": "01JDZ…(ULID)", "type": "crm.sale.paid", "occurredAt": "2026-11-28T12:00:00.000Z",
61
+ "contact": { "email": "…", "phone": "…", "name": "…" }, "data": { "amount_minor": 1999, "currency": "MXN" } }
62
+ ```
63
+
64
+ Headers:
65
+
66
+ ```
67
+ Idempotency-Key: <id>
68
+ X-SoloBrand-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(SOLOBRAND_EVENTS_KEY, `${t}.${rawBody}`)>
69
+ ```
70
+
71
+ - Exported as constants/functions: `SIGNATURE_HEADER`, `SIGNATURE_VERSION` (`v1`),
72
+ `SIGNATURE_TOLERANCE_SECONDS` (300), `signEvent()`, `parseSignatureHeader()`,
73
+ `verifyEventSignature()` (constant-time, rejects stale `t`). The receiver verifies the raw body
74
+ **before** parsing, rejects `t` outside ±300 s and dedupes on `id`.
75
+ - `id` is a ULID unless given, and is the **same** on every retry; `t` is fresh per attempt.
76
+ - Delivery runs in `ctx.waitUntil`; `emit()` resolves right away and never throws. Up to 3 retries
77
+ on 5xx / 429 / network errors, backoff 250 ms · 2ⁿ (`retries`, `backoffMs` options). Other 4xx are
78
+ not retried. Redirects are not followed.
79
+ - **All attempts of one event fit in 24 s** (`deliveryBudgetMs`, never above 25 s): a Worker's
80
+ `waitUntil` is cut at 30 s, and anything still running then is lost without a log line. Each
81
+ attempt's timeout is `min(timeoutMs, (budget − backoffs) / attempts)` — 5.5 s with the defaults —
82
+ and retries that would not leave 1 s each are dropped (`planDelivery()` shows the plan).
83
+ - Logged on failure: `platform.event_retry` / `platform.event_failed` with `{ type, id, attempt(s),
84
+ status | error name }` only — never contact, data, the key or the token.
85
+ - `data` and `contact` are deep-copied without secret-named keys (`password*`, `*token`, `*secret*`,
86
+ `api_key`, `authorization`, `cookie`, `*_hash`, `cvv`, `card_number`, …) and prototype keys.
87
+ - `type` must match `^[a-z0-9][a-z0-9_-]*(\.[a-z0-9][a-z0-9_-]*)*$`; a bad type/id/occurredAt, or a
88
+ sale with a non-integer/negative `amount_minor` or a non-ISO-4217 `currency`, is logged
89
+ (`platform.event_invalid`) and not sent.
90
+
91
+ ## Durable outbox — an outage never loses an event
92
+
93
+ Retries inside `waitUntil` cover a blip, not an outage: when SoloBrand is down for minutes, a
94
+ `crm.sale.paid` would be gone. With an outbox the event is written to the app's own D1 **before**
95
+ the first attempt, removed once SoloBrand takes it, and otherwise retried by the app's cron:
96
+
97
+ ```ts
98
+ // database/index.ts — the table comes from a platform migration
99
+ import { platformMigrations } from '@solobrand/platform';
100
+ export const allMigrations = [...authMigrations, ...platformMigrations, ...migrations];
101
+
102
+ // bootstrap/app.ts
103
+ import { dbTokens } from '@solobrand/db';
104
+ import { databaseOutbox, platformProvider } from '@solobrand/platform';
105
+ platformProvider({ ctx: () => currentExecutionContext, outbox: (app) => databaseOutbox(app.make(dbTokens.database)) });
106
+
107
+ // src/worker.ts — and `"triggers": { "crons": ["*/5 * * * *"] }` in wrangler.jsonc
108
+ async scheduled(_controller, env, ctx) {
109
+ const app = appFor(env); // the booted app
110
+ ctx.waitUntil(flushPlatformOutbox(env, { outbox: databaseOutbox(app.make(dbTokens.database)), logger: app.logger }));
111
+ }
112
+ ```
113
+
114
+ - Table `platform_event_outbox` (`createPlatformOutboxTable`, in `platformMigrations`): one row per
115
+ **event id**, which is also the `Idempotency-Key` — saving the same event twice is one row, and a
116
+ flush that overlaps a late `waitUntil` is still counted once by SoloBrand. It holds the envelope
117
+ (contact and scrubbed data) only until it is delivered.
118
+ - After the in-request retries fail with 5xx / 429 / network, the row waits 1 min; each cron run
119
+ tries every due row once (`limit`, default 50) and doubles the wait (at most 1 h). A 4xx, or
120
+ `MAX_OUTBOX_ATTEMPTS` (20) attempts, marks it `failed_at` and logs `platform.event_failed`: kept to
121
+ be looked at, never retried, never deleted silently.
122
+ - If the outbox itself fails (D1 down), the event is still sent now and `platform.outbox_failed`
123
+ is logged. `flushPlatformOutbox()` returns `{ delivered, retried, failed }`.
124
+ - Logs while queued: `platform.event_queued` (warn) — type, id, attempts and why, never the data.
125
+
126
+ ## Services
127
+
128
+ `services.call(name, input)` → `POST ${SOLOBRAND_SERVICES_URL}/${name}` with
129
+ `Authorization: Bearer ${SOLOBRAND_APP_TOKEN}`, `redirect: 'manual'`, 10 s timeout, response capped
130
+ at 1 MiB. `name` uses the same pattern as event types (no `/`, `..`, `@`, `:`, `%`, spaces).
131
+ Success: `{ ok: true, value }` (or `data`), or any other JSON body as the value.
132
+
133
+ | SoloBrand says | Result error (`code` / `messageKey`) |
134
+ |---|---|
135
+ | HTTP 402, or `reason: no_credits` | `unavailable` / `platform.no_credits` |
136
+ | `reason: rate_limited`, HTTP 429 | `rate_limited` / `platform.rate_limited` |
137
+ | `reason: invalid_input`, HTTP 400/422 | `validation_failed` / `platform.invalid_input` (+ `errors` when well-formed) |
138
+ | `reason: forbidden`, HTTP 403 | `forbidden` / `platform.forbidden` |
139
+ | HTTP 401 | `internal` / `platform.unauthorized` (the app token is wrong — not the user's fault) |
140
+ | HTTP 404, `reason: not_found` | `internal` / `platform.service_not_found` |
141
+ | 5xx, network error, timeout | `unavailable` / `platform.unavailable` |
142
+ | 3xx, non-JSON 2xx, too large | `unavailable` / `platform.bad_response` |
143
+ | `{ ok:false }` with an unknown reason | `unavailable` / `platform.service_failed` (the reason is not echoed) |
144
+ | invalid service name | `internal` / `platform.service_invalid` (no request made) |
145
+
146
+ `mail.send({ to, subject, text, html? })` calls the `mail.send` service; a bad address, a line
147
+ break in `to`/`subject`, or more than one recipient (`,` or `;` in `to`) is `validation_failed` /
148
+ `platform.mail_invalid` without calling SoloBrand.
149
+ `platformMailer(client)` implements `@solobrand/auth`'s `Mailer` port (type-only import; auth is an
150
+ optional peer dependency).
151
+
152
+ Messages: `platformMessages` (es, en), added by `platformProvider()`.
153
+
154
+ ## Status
155
+
156
+ **TERMINADO** — F8 platform, 2026-11-28.
157
+
158
+ - **Implemented**: `createPlatformClient` (events with HMAC signature, ULID ids, waitUntil
159
+ delivery, 3 retries with backoff, PII-free logs, secret-key scrubbing; services with error
160
+ mapping incl. `platform.no_credits`; mail), `events.sale.paid/refunded/failed` on the
161
+ `PlatformClient` contract (accepted change, 2nd round), `platformMailer`, `platformProvider()`
162
+ (binds `platformToken`, adds messages, checks env at boot), `readPlatformEnv`, signature helpers
163
+ (`signEvent` / `verifyEventSignature`), `ulid`. Deprecated aliases: `saleEvents()`,
164
+ `SoloBrandPlatformClient` (still referenced by `docs/es`).
165
+ - **Tested** (`src/platform.test.ts`, fetch mock, 57 tests, ~99 % lines): signature verifiable and
166
+ checked against an independent HMAC vector; tampered/stale/wrong-key rejected; retries and
167
+ backoff; idempotency id and body stable across retries; no retry on 4xx; no PII / key / token in
168
+ logs; T-PL-1 (service names), T-PL-2 (no redirects, token only to the configured origin),
169
+ T-PL-4 (oversized / non-JSON responses), T-PL-5 (secret keys never forwarded); every error
170
+ mapping; missing/invalid env; provider boot; `events.sale` through the contract type.
171
+ - **Left (outside F8)**: the SoloBrand receiver adopts the signature format (integrator, in
172
+ brandai); `docs/es` can drop `saleEvents` / `SoloBrandPlatformClient` for `events.sale` / `PlatformClient`
173
+ (F7 docs); measurement is not in the contract yet.
@@ -0,0 +1,122 @@
1
+ import { type AppErrorShape, type Clock, type ErrorCode, type Logger } from '@solobrand/core';
2
+ import type { PlatformClient } from './index.js';
3
+ import { type PlatformEnv } from './env.js';
4
+ import { type EventOutbox } from './outbox.js';
5
+ export interface PlatformClientOptions {
6
+ /** Default `globalThis.fetch`. */
7
+ fetch?: typeof fetch;
8
+ /** Default a JSON logger (`createLogger()`). */
9
+ logger?: Logger;
10
+ clock?: Clock;
11
+ /** Retries after the first event delivery attempt, on 5xx / 429 / network errors. Default 3. */
12
+ retries?: number;
13
+ /** Backoff before retry n (1-based) is `backoffMs * 2^(n-1)`. Default 250 ms → 250, 500, 1000. */
14
+ backoffMs?: number;
15
+ /** How the client waits between retries (tests pass a no-op). Default `setTimeout`. */
16
+ sleep?: (ms: number) => Promise<void>;
17
+ /**
18
+ * Per-request timeout. Default 10 000 ms. For event delivery it is also capped so every
19
+ * attempt plus the backoffs fit in `deliveryBudgetMs`.
20
+ */
21
+ timeoutMs?: number;
22
+ /**
23
+ * Worst-case time for ALL delivery attempts of one event, backoffs included. Default
24
+ * 24 000 ms, never more than 25 000: a Worker's `waitUntil` is cut at 30 s, and work past
25
+ * it is lost without a trace (AUD-05). Retries that would not fit are dropped.
26
+ */
27
+ deliveryBudgetMs?: number;
28
+ /**
29
+ * Durable outbox (AUD-05): the event is written here BEFORE the first attempt and removed
30
+ * once delivered; an event SoloBrand did not take waits there for `flushPlatformOutbox()`
31
+ * (the app's cron). Without it, an outage longer than the retries loses the event (logged).
32
+ */
33
+ outbox?: EventOutbox;
34
+ /** Biggest services response read, in bytes. Default 1 MiB. */
35
+ maxResponseBytes?: number;
36
+ }
37
+ export type EmitInput = Parameters<PlatformClient['events']['emit']>[0];
38
+ /** @deprecated `PlatformClient` has `events.sale` now; use `PlatformClient`. */
39
+ export type SoloBrandPlatformClient = PlatformClient;
40
+ /** Event types and service names: lowercase, dot-separated, no path characters (T-PL-1). */
41
+ export declare const NAME_PATTERN: RegExp;
42
+ export declare function isValidName(name: unknown): name is string;
43
+ /**
44
+ * Keys never forwarded in event data, at any depth (T-PL-5, SEC-015): the logger's
45
+ * {@link SECRET_KEY_PATTERN} from `@solobrand/core` (one definition for the framework)
46
+ * plus payment fields.
47
+ */
48
+ export declare const SECRET_KEY: {
49
+ readonly test: (key: string) => boolean;
50
+ };
51
+ /** A JSON-safe deep copy of `data` without secret-named keys. */
52
+ export declare function scrubData(value: unknown, depth?: number): unknown;
53
+ export declare function appError(code: ErrorCode, messageKey: string, extra?: {
54
+ params?: Record<string, string | number>;
55
+ errors?: Record<string, readonly string[]>;
56
+ }): AppErrorShape;
57
+ /** HTTP status from SoloBrand → our error (`platform.no_credits` for 402). */
58
+ export declare function errorForStatus(status: number, service: string): AppErrorShape;
59
+ export declare const DEFAULT_DELIVERY_BUDGET_MS = 24000;
60
+ /** The hard ceiling: under the 30 s a Worker's `waitUntil` lives. */
61
+ export declare const MAX_DELIVERY_BUDGET_MS = 25000;
62
+ export interface DeliveryPlan {
63
+ /** Attempts in total (first + retries). */
64
+ readonly attempts: number;
65
+ /** Timeout of each attempt. */
66
+ readonly attemptTimeoutMs: number;
67
+ /** Wait before retry n (index n-1). */
68
+ readonly backoffs: readonly number[];
69
+ /** attempts * attemptTimeoutMs + the backoffs: never above the budget. */
70
+ readonly worstCaseMs: number;
71
+ }
72
+ /**
73
+ * How one event is delivered inside its budget: drops retries whose backoff would not leave
74
+ * at least 1 s per attempt, then shares what is left between the attempts (each at most
75
+ * `timeoutMs`). The worst case always fits in `min(budget, 25 s)`.
76
+ */
77
+ export declare function planDelivery(options?: {
78
+ retries?: number | undefined;
79
+ backoffMs?: number | undefined;
80
+ timeoutMs?: number | undefined;
81
+ deliveryBudgetMs?: number | undefined;
82
+ }): DeliveryPlan;
83
+ /** What one delivery ended in. */
84
+ export type DeliveryOutcome = {
85
+ readonly ok: true;
86
+ readonly attempts: number;
87
+ } | {
88
+ readonly ok: false;
89
+ readonly attempts: number;
90
+ readonly retryable: boolean;
91
+ readonly reason: string;
92
+ };
93
+ export interface Deliverer {
94
+ deliver(type: string, id: string, body: string, plan: DeliveryPlan): Promise<DeliveryOutcome>;
95
+ }
96
+ export declare function createDeliverer(config: PlatformEnv, deps: {
97
+ doFetch: typeof fetch;
98
+ logger: Logger;
99
+ clock: Clock;
100
+ sleep: (ms: number) => Promise<void>;
101
+ }): Deliverer;
102
+ /** `status_503` → `{ status: 503 }`, `error_TypeError` → `{ error: 'TypeError' }` (for logs). */
103
+ export declare function reasonFields(reason: string): {
104
+ status: number;
105
+ } | {
106
+ error: string;
107
+ };
108
+ /**
109
+ * Builds the client. Reads the env first: a missing/invalid name throws at boot
110
+ * (`platform.env_missing` / `platform.env_invalid`), never later in a request.
111
+ */
112
+ /**
113
+ * Checks an event and serializes its signed body (`{ id, type, occurredAt, data, contact? }`,
114
+ * secrets scrubbed). `null` (logged as `platform.event_invalid`) when it cannot be sent.
115
+ */
116
+ export declare function buildEventBody(event: EmitInput, clock: Clock, logger: Logger): {
117
+ type: string;
118
+ id: string;
119
+ body: string;
120
+ } | null;
121
+ export declare function buildPlatformClient(env: Readonly<Record<string, unknown>>, ctx: ExecutionContext, options?: PlatformClientOptions): PlatformClient;
122
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkF,KAAK,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAe,MAAM,iBAAiB,CAAC;AAC3L,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,YAAY,CAAC;AAC5D,OAAO,EAA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