@secondlayer/shared 13.12.0 → 13.13.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.
- package/dist/src/archive/range-digest.d.ts +53 -0
- package/dist/src/archive/semantic-digest-builder.d.ts +53 -0
- package/dist/src/coverage/index.d.ts +53 -0
- package/dist/src/db/index.d.ts +66 -2
- package/dist/src/db/index.js +5 -1
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +53 -0
- package/dist/src/db/queries/chain-reorgs.js +5 -1
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +53 -0
- package/dist/src/db/queries/instance.d.ts +53 -0
- package/dist/src/db/queries/integrity.d.ts +53 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +53 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +53 -0
- package/dist/src/db/queries/subgraphs.d.ts +53 -0
- package/dist/src/db/queries/sync-scope.d.ts +53 -0
- package/dist/src/db/queries/webhook-replays.d.ts +1431 -0
- package/dist/src/db/queries/webhook-replays.js +156 -0
- package/dist/src/db/queries/webhook-replays.js.map +10 -0
- package/dist/src/db/queries/webhooks.d.ts +53 -0
- package/dist/src/db/schema.d.ts +62 -2
- package/dist/src/email/index.d.ts +27 -6
- package/dist/src/email/index.js +135 -29
- package/dist/src/email/index.js.map +3 -3
- package/dist/src/index.d.ts +66 -2
- package/dist/src/index.js +9 -1
- package/dist/src/index.js.map +4 -4
- package/dist/src/insights/index.d.ts +70 -3
- package/dist/src/insights/index.js +40 -3
- package/dist/src/insights/index.js.map +3 -3
- package/dist/src/node/local-client.d.ts +53 -0
- package/dist/src/queue/listener.js +5 -1
- package/dist/src/queue/listener.js.map +3 -3
- package/dist/src/schemas/index.js +5 -1
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/webhooks.d.ts +45 -1
- package/dist/src/schemas/webhooks.js +6 -1
- package/dist/src/schemas/webhooks.js.map +3 -3
- package/migrations/0178_insight_snooze.ts +22 -0
- package/migrations/0179_webhook_replays.ts +56 -0
- package/migrations/0180_push.ts +54 -0
- package/migrations/0181_push_sent.ts +30 -0
- package/package.json +5 -1
|
@@ -343,6 +343,10 @@ var ReplayWebhookRequestSchema = z.object({
|
|
|
343
343
|
message: "fromBlock must be less than or equal to toBlock",
|
|
344
344
|
path: ["toBlock"]
|
|
345
345
|
});
|
|
346
|
+
var RequeueDeadRequestSchema = z.object({
|
|
347
|
+
replayId: z.string().regex(/^[0-9a-f]{16}$/, "replayId must be 16 hex characters").optional(),
|
|
348
|
+
since: z.iso.datetime({ offset: true }).optional()
|
|
349
|
+
});
|
|
346
350
|
var trigger = {
|
|
347
351
|
stxTransfer: (f = {}) => ({
|
|
348
352
|
type: "stx_transfer",
|
|
@@ -448,6 +452,7 @@ export {
|
|
|
448
452
|
MANAGED_NAME_PREFIXES,
|
|
449
453
|
PrintWhereSchema,
|
|
450
454
|
ReplayWebhookRequestSchema,
|
|
455
|
+
RequeueDeadRequestSchema,
|
|
451
456
|
UpdateWebhookRequestSchema,
|
|
452
457
|
WEBHOOK_FORMATS,
|
|
453
458
|
WEBHOOK_MAX_RETRIES_CEILING_DEFAULT,
|
|
@@ -462,5 +467,5 @@ export {
|
|
|
462
467
|
webhookTimeoutMsCeiling
|
|
463
468
|
};
|
|
464
469
|
|
|
465
|
-
//# debugId=
|
|
470
|
+
//# debugId=C674416999734A8164756E2164756E21
|
|
466
471
|
//# sourceMappingURL=webhooks.js.map
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/schemas/webhooks.ts", "../src/schemas/chain-triggers.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { z } from \"zod\";\n\nexport {\n\tCHAIN_TRIGGER_FIELDS,\n\tCHAIN_TRIGGER_TYPES,\n} from \"./chain-triggers\";\nexport type { ChainTriggerType } from \"./chain-triggers\";\n\nexport const WEBHOOK_FORMATS = [\n\t\"standard-webhooks\",\n\t\"inngest\",\n\t\"trigger\",\n\t\"cloudflare\",\n\t\"cloudevents\",\n\t\"raw\",\n] as const;\n\nexport const WEBHOOK_STATUSES = [\"active\", \"paused\", \"error\"] as const;\n\n/**\n * Delivery-cap ceilings. Self-host defaults keep today's hardcoded limits\n * (100 retries, 300s timeout); an operator raises or lowers them per env.\n * Read live (not baked in at import) so a changed env var takes effect on\n * the next request without a process restart, and so tests can override\n * per-case.\n */\nexport const WEBHOOK_MAX_RETRIES_CEILING_DEFAULT = 100;\nexport const WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT = 300_000;\n\nfunction ceilingFromEnv(envVar: string, fallback: number): number {\n\tconst raw = process.env[envVar];\n\tif (raw === undefined) return fallback;\n\tconst parsed = Number.parseInt(raw, 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\nexport function webhookMaxRetriesCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_MAX_RETRIES_CEILING\",\n\t\tWEBHOOK_MAX_RETRIES_CEILING_DEFAULT,\n\t);\n}\n\nexport function webhookTimeoutMsCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_TIMEOUT_MS_CEILING\",\n\t\tWEBHOOK_TIMEOUT_MS_CEILING_DEFAULT,\n\t);\n}\n\nfunction maxRetriesField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(0)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookMaxRetriesCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `maxRetries exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nfunction timeoutMsField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(100)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookTimeoutMsCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `timeoutMs exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nconst webhookUrl = z\n\t.string()\n\t.trim()\n\t.min(1)\n\t.refine(\n\t\t(value) => value.startsWith(\"http://\") || value.startsWith(\"https://\"),\n\t\t\"must be an http(s) URL\",\n\t);\n\nconst name = z.string().trim().min(1).max(128);\n\n/** Webhook names another first-party product owns and looks up by name.\n * Renaming one breaks that product's reconcile, so the API refuses it and\n * the dashboard shows the owner instead of Rename. Prefix -> display name. */\nexport const MANAGED_NAME_PREFIXES: Readonly<Record<string, string>> = {\n\t\"sentinel:\": \"Sentinel\",\n};\n\nexport function managedByForName(name: string): string | null {\n\tfor (const [prefix, owner] of Object.entries(MANAGED_NAME_PREFIXES)) {\n\t\tif (name.startsWith(prefix)) return owner;\n\t}\n\treturn null;\n}\n\nexport const WebhookStatusSchema: z.ZodType<WebhookStatus> =\n\tz.enum(WEBHOOK_STATUSES);\nexport const WebhookFormatSchema: z.ZodType<WebhookFormat> =\n\tz.enum(WEBHOOK_FORMATS);\n\n// --- Chain triggers (direct chain-level webhooks) -----------------------\n// A chain webhook reacts to raw chain events matched directly off the\n// Index/Streams clock (no subgraph). `triggers` is an array of these filters —\n// the JSON mirror of the subgraph runtime's `SubgraphFilter` union. Defined\n// here (not imported from @secondlayer/subgraphs) to avoid a shared→subgraphs\n// cycle; the evaluator maps these to `SubgraphFilter` at match time. Amounts are\n// non-negative integer strings (uint128 can exceed JS safe-int) or numbers.\n\n/** Runes trigger types (plan 060) — matched off `chain=bitcoin` Streams events\n * (plan 059), not the Stacks Index clock. `rune` is a RuneRef (an id like\n * `840000:3` or a name like `DOG•GO•TO•THE•MOON`); the API resolves and\n * normalizes it to its canonical id at create time (see `../../routes/webhooks.ts`),\n * rejecting an unresolvable one with 400 when Bitcoin data is configured. */\nconst runeRef = z.string().trim().min(1);\n\nconst triggerAmount = z.union([\n\tz.string().trim().regex(/^\\d+$/, \"must be a non-negative integer string\"),\n\tz.number().int().nonnegative(),\n]);\n/** Principal/identifier/name patterns — `*` wildcards allowed (matched by the\n * evaluator). */\nconst triggerPattern = z.string().trim().min(1);\nconst trait = z.string().trim().min(1);\n\n/**\n * `print_event` `where`: equality on top-level keys of the decoded print\n * tuple, spelled as the contract prints them. An array is any-of; multiple\n * keys AND. Values compare against the field's JSON-normalized form.\n */\nconst printWhereValue = z.string().min(1).max(256);\nexport const PrintWhereSchema: z.ZodType<Record<string, string | string[]>> = z\n\t.record(\n\t\tz.string().trim().min(1).max(64),\n\t\tz.union([printWhereValue, z.array(printWhereValue).min(1).max(20)]),\n\t)\n\t.refine((o) => {\n\t\tconst n = Object.keys(o).length;\n\t\treturn n >= 1 && n <= 10;\n\t}, \"where takes 1 to 10 keys\");\n\nexport const ChainTriggerSchema: z.ZodType<ChainTrigger> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_transfer\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_mint\"),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_burn\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_lock\"),\n\t\t\t\tlockedAddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_deploy\"),\n\t\t\t\tdeployer: triggerPattern.optional(),\n\t\t\t\tcontractName: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"print_event\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\ttopic: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t\twhere: PrintWhereSchema.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nested_contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"var_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tvarName: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_insert\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_delete\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_deposit\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\tbitcoinTxid: triggerPattern.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_create\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_accept\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_reject\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_swept_confirmed\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_etch\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_mint\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_transfer\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t\taddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_burn\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t],\n);\n\nexport const ChainTriggersSchema: z.ZodType<ChainTrigger[]> = z\n\t.array(ChainTriggerSchema)\n\t.min(1)\n\t.max(50);\n\nexport const CreateWebhookRequestSchema: z.ZodType<ParsedCreateWebhookRequest> =\n\tz.object({\n\t\tname,\n\t\ttriggers: ChainTriggersSchema,\n\t\turl: webhookUrl,\n\t\tformat: WebhookFormatSchema.default(\"standard-webhooks\"),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t});\n\nexport const UpdateWebhookRequestSchema: z.ZodType<UpdateWebhookRequest> = z\n\t.object({\n\t\tname: name.optional(),\n\t\turl: webhookUrl.optional(),\n\t\tformat: WebhookFormatSchema.optional(),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t})\n\t.refine((value) => Object.keys(value).length > 0, {\n\t\tmessage: \"At least one field must be provided\",\n\t});\n\nexport const ReplayWebhookRequestSchema: z.ZodType<ReplayWebhookRequest> = z\n\t.object({\n\t\tfromBlock: z.number().int().nonnegative(),\n\t\ttoBlock: z.number().int().nonnegative(),\n\t\tforce: z.string().trim().min(1).max(64).optional(),\n\t})\n\t.refine((value) => value.fromBlock <= value.toBlock, {\n\t\tmessage: \"fromBlock must be less than or equal to toBlock\",\n\t\tpath: [\"toBlock\"],\n\t});\n\nexport type WebhookStatus = (typeof WEBHOOK_STATUSES)[number];\n/** Webhook kind (mirrors db/types `WebhookKind`). Chain events only. */\nexport type WebhookKind = \"chain\";\nexport type WebhookFormat = (typeof WEBHOOK_FORMATS)[number];\n\n/** Non-negative integer amount over JSON (string for uint128 safety, or number). */\nexport type ChainTriggerAmount = string | number;\n\ninterface TraitScoped {\n\ttrait?: string;\n}\n\n/** JSON mirror of the subgraph runtime's `SubgraphFilter` union. */\nexport type ChainTrigger =\n\t| {\n\t\t\ttype: \"stx_transfer\";\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"stx_mint\"; recipient?: string; minAmount?: ChainTriggerAmount }\n\t| { type: \"stx_burn\"; sender?: string; minAmount?: ChainTriggerAmount }\n\t| {\n\t\t\ttype: \"stx_lock\";\n\t\t\tlockedAddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| ({\n\t\t\ttype: \"ft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t } & TraitScoped)\n\t| { type: \"contract_deploy\"; deployer?: string; contractName?: string }\n\t| ({\n\t\t\ttype: \"print_event\";\n\t\t\tcontractId?: string;\n\t\t\ttopic?: string;\n\t\t\t/** Equality on top-level keys of the decoded print tuple; array = any-of, keys AND. */\n\t\t\twhere?: Record<string, string | readonly string[]>;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nested_contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"var_set\";\n\t\t\tcontractId?: string;\n\t\t\tvarName?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_set\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_insert\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_delete\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| {\n\t\t\ttype: \"sbtc_deposit\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\tbitcoinTxid?: string;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_create\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_accept\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"sbtc_withdrawal_reject\"; requestId?: number }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_swept_confirmed\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"rune_etch\"; rune?: string }\n\t| { type: \"rune_mint\"; rune?: string }\n\t| {\n\t\t\ttype: \"rune_transfer\";\n\t\t\trune?: string;\n\t\t\taddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"rune_burn\"; rune?: string };\n\n/** Args for a chain-trigger builder — every field of a variant except `type`. */\ntype TriggerArgs<T extends ChainTrigger[\"type\"]> = Omit<\n\tExtract<ChainTrigger, { type: T }>,\n\t\"type\"\n>;\n\n/**\n * Ergonomic chain-trigger constructors for `webhooks.create({ triggers })`.\n * Each returns a bare `ChainTrigger` (the wire shape the API expects):\n *\n * ```ts\n * client.webhooks.create({\n * url: \"https://my.app/webhook\",\n * triggers: [trigger.contractCall({ contractId: \"SP....amm\", functionName: \"swap-*\" })],\n * });\n * ```\n */\nexport const trigger = {\n\tstxTransfer: (f: TriggerArgs<\"stx_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_transfer\",\n\t\t...f,\n\t}),\n\tstxMint: (f: TriggerArgs<\"stx_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_mint\",\n\t\t...f,\n\t}),\n\tstxBurn: (f: TriggerArgs<\"stx_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_burn\",\n\t\t...f,\n\t}),\n\tstxLock: (f: TriggerArgs<\"stx_lock\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_lock\",\n\t\t...f,\n\t}),\n\tftTransfer: (f: TriggerArgs<\"ft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_transfer\",\n\t\t...f,\n\t}),\n\tftMint: (f: TriggerArgs<\"ft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_mint\",\n\t\t...f,\n\t}),\n\tftBurn: (f: TriggerArgs<\"ft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_burn\",\n\t\t...f,\n\t}),\n\tnftTransfer: (f: TriggerArgs<\"nft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_transfer\",\n\t\t...f,\n\t}),\n\tnftMint: (f: TriggerArgs<\"nft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_mint\",\n\t\t...f,\n\t}),\n\tnftBurn: (f: TriggerArgs<\"nft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_burn\",\n\t\t...f,\n\t}),\n\tcontractCall: (f: TriggerArgs<\"contract_call\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_call\",\n\t\t...f,\n\t}),\n\tcontractDeploy: (f: TriggerArgs<\"contract_deploy\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_deploy\",\n\t\t...f,\n\t}),\n\tprintEvent: (f: TriggerArgs<\"print_event\"> = {}): ChainTrigger => ({\n\t\ttype: \"print_event\",\n\t\t...f,\n\t}),\n\tsbtcDeposit: (f: TriggerArgs<\"sbtc_deposit\"> = {}): ChainTrigger => ({\n\t\ttype: \"sbtc_deposit\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalCreate: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_create\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_create\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalAccept: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_accept\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_accept\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalReject: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_reject\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_reject\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalSweptConfirmed: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_swept_confirmed\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_swept_confirmed\",\n\t\t...f,\n\t}),\n\truneEtch: (f: TriggerArgs<\"rune_etch\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_etch\",\n\t\t...f,\n\t}),\n\truneMint: (f: TriggerArgs<\"rune_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_mint\",\n\t\t...f,\n\t}),\n\truneTransfer: (f: TriggerArgs<\"rune_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_transfer\",\n\t\t...f,\n\t}),\n\truneBurn: (f: TriggerArgs<\"rune_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_burn\",\n\t\t...f,\n\t}),\n} as const;\n\n/** The body for creating a webhook: name, triggers, URL, delivery options. */\nexport interface CreateWebhookRequest {\n\tname: string;\n\ttriggers: ChainTrigger[];\n\turl: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport interface ParsedCreateWebhookRequest\n\textends Omit<CreateWebhookRequest, \"format\"> {\n\tformat: WebhookFormat;\n}\n\n/** The fields of a webhook you can change. */\nexport interface UpdateWebhookRequest {\n\tname?: string;\n\turl?: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport type ParsedUpdateWebhookRequest = UpdateWebhookRequest;\n\nexport interface ReplayWebhookRequest {\n\tfromBlock: number;\n\ttoBlock: number;\n\tforce?: string;\n}\n\nexport type ParsedReplayWebhookRequest = ReplayWebhookRequest;\n\n/** A webhook's name, status, format, and URL. */\nexport interface WebhookSummary {\n\tid: string;\n\tname: string;\n\tstatus: WebhookStatus;\n\tkind: WebhookKind;\n\tformat: WebhookFormat;\n\turl: string;\n\tlastDeliveryAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** When the circuit breaker paused this webhook (20 straight failures);\n\t * cleared on resume. Present on the list summary (not detail-only) so a\n\t * numbers-only insight can be shown per row without a per-row fetch. */\n\tcircuitOpenedAt: string | null;\n\t/** Consecutive failed deliveries (reset to 0 on a success). On the\n\t * summary so the list can show a failing receiver per row without a\n\t * per-row fetch. */\n\tcircuitFailures: number;\n\t/** Owning product, derived from the name prefix (`MANAGED_NAME_PREFIXES`).\n\t * When non-null the API refuses to rename the webhook. */\n\tmanagedBy: string | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** What a webhook's receiver credentials look like once redacted for a\n * response — never the bearer token, basic-auth string, or header values\n * themselves, only enough to show what's set. `authConfig` on create/update\n * is unaffected (write-only: the API still accepts it, just never echoes\n * it back). */\nexport interface WebhookAuth {\n\ttype: \"bearer\" | \"basic\" | \"none\";\n\t/** Keys of any extra headers the receiver expects — never their values. */\n\theaderNames: string[];\n\t/** True when a bearer token or basic-auth string is set, whatever it is. */\n\thasSecret: boolean;\n}\n\n/** A webhook with its triggers, auth, retry, and timeout settings. */\nexport interface WebhookDetail extends WebhookSummary {\n\t/** Chain-trigger filters. */\n\ttriggers: ChainTrigger[];\n\tauth: WebhookAuth;\n\tmaxRetries: number;\n\ttimeoutMs: number;\n\tconcurrency: number;\n\tlastError: string | null;\n\t/** When the receiver's TLS certificate expires, from the periodic probe.\n\t * Null for http receivers, refused or unreachable hosts, and webhooks not\n\t * probed yet. */\n\treceiverCertExpiresAt: string | null;\n\t/** Set when this instance's chain-trigger\n\t * evaluator isn't running (`SUBGRAPH_SOURCE` != `streams-index`) — the\n\t * webhook will never fire until that's fixed. Null otherwise. Surfaced\n\t * on create (so it's seen immediately) and on every read (so `secondlayer\n\t * webhooks doctor` reports it for a webhook created before the mismatch,\n\t * or on an instance whose config changed since). */\n\twarning: string | null;\n}\n\n/** The new webhook and its signing secret, shown once. */\nexport interface CreateWebhookResponse {\n\twebhook: WebhookDetail;\n\t/** Plaintext signing secret — surfaced ONCE. Store it server-side. */\n\tsigningSecret: string;\n}\n\n/** The webhook and its new signing secret. */\nexport interface RotateSecretResponse {\n\twebhook: WebhookDetail;\n\tsigningSecret: string;\n}\n\n/** One delivery attempt: status code, error, duration, and response. */\nexport interface DeliveryRow {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\terrorMessage: string | null;\n\tdurationMs: number | null;\n\tresponseBody: string | null;\n\tdispatchedAt: string;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\tblockHeight: number | null;\n\t/** ISO timestamp of the delivered event's block. `null` for test\n\t * deliveries, events already compacted out of the outbox, and rows\n\t * written before this column existed. */\n\tblockTime: string | null;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\ttxId: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`.\n\t * Null for test deliveries, compacted rows, and rows with neither shape\n\t * (a settlement or reorg outbox row). */\n\teventIndex: number | null;\n}\n\n/** One hour of `webhook_outbox` activity (`GET /:id/activity`), zero-filled\n * so the events chart always has 168 bars. */\nexport interface WebhookActivityHour {\n\t/** ISO timestamp, UTC hour start. */\n\thour: string;\n\tdelivered: number;\n\twaiting: number;\n\tgaveUp: number;\n\t/** Failed attempts in the hour (no response or non-2xx), from\n\t * `webhook_deliveries`. Attempts, not events: a retried-then-delivered\n\t * event counts here but is `delivered` above. */\n\tfailed: number;\n}\n\n/** A week of hourly delivery counts and what is waiting now. */\nexport interface WebhookActivity {\n\t/** 168 hours, oldest first. */\n\thours: WebhookActivityHour[];\n\t/** Pending rows right now, no time bound. */\n\twaiting: number;\n\tnextAttemptAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** 7-day counts per `event_type` (same 168-hour window as `hours`), e.g.\n\t * `chain.stx_transfer.apply` — the config card's per-trigger volume. */\n\tbyEventType: Record<string, number>;\n\t/** Typical delivered attempts for each UTC hour of day (p10 and p90 of the\n\t * last 28 days, from `webhook_deliveries`). Null at low volume, where\n\t * \"usual\" is not meaningful. */\n\tusualByHourOfDay: Array<{ lo: number; hi: number }> | null;\n\t/** Present with `?days=30`: 30 UTC days, oldest first, from\n\t * `webhook_deliveries` (2xx is delivered, everything else failed). */\n\tdays?: WebhookActivityDay[];\n}\n\n/** One UTC day of delivery attempts (`GET /:id/activity?days=30`). */\nexport interface WebhookActivityDay {\n\t/** YYYY-MM-DD, UTC. */\n\tday: string;\n\tdelivered: number;\n\tfailed: number;\n}\n\n/** Heat data for every webhook on the account (`GET /api/webhooks/activity`),\n * from `webhook_deliveries` attempts. */\nexport interface WebhooksActivitySummary {\n\t/** 168 ISO UTC hour starts, oldest first. */\n\thours: string[];\n\t/** Arrays are aligned to `hours` and zero-filled. */\n\twebhooks: Array<{ id: string; delivered: number[]; failed: number[] }>;\n}\n\n/**\n * One delivery attempt with its outbox context.\n *\n * Serves the delivery card (`GET /:id/deliveries/:deliveryId`). `payload`,\n * `outboxId`, `eventType`, `txId`, `blockHeight`, `blockTime`, and `eventIndex`\n * are null once the outbox row is gone (compacted after 7 days) or for a test\n * delivery, which never had one.\n */\nexport interface WebhookDeliveryDetail {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\tdurationMs: number | null;\n\tdispatchedAt: string;\n\terrorMessage: string | null;\n\tresponseBody: string | null;\n\tresponseHeaders: Record<string, string> | null;\n\toutboxId: string | null;\n\t/** The outbox row's own status — `null` once it's gone (compacted after\n\t * delivery, or never had one, e.g. a test delivery). Only `\"dead\"` means\n\t * a resend is possible: it's the one status `POST /:id/dead/:outboxId/\n\t * requeue` accepts. */\n\toutboxStatus: \"pending\" | \"delivered\" | \"dead\" | null;\n\teventType: string | null;\n\ttxId: string | null;\n\tblockHeight: number | null;\n\tblockTime: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`\n\t * (`event_index` for a chain-trigger row). Null when `row_pk` carries\n\t * none — a settlement or reorg outbox row, or no outbox row at all. */\n\teventIndex: number | null;\n\tpayload: unknown | null;\n}\n\n/** How many events a replay scanned and enqueued. */\nexport interface ReplayResult {\n\treplayId: string;\n\tenqueuedCount: number;\n\tscannedCount: number;\n}\n\n/** Result of a one-off test delivery (`POST /:id/test`). Logged as a delivery\n * row (with a null outbox_id) so it shows up under the webhook's deliveries. */\nexport interface WebhookTestResult {\n\tok: boolean;\n\tstatusCode: number | null;\n\terror: string | null;\n\tdurationMs: number;\n\tdeliveryId: string;\n}\n\n/** A delivery that ran out of retries. */\nexport interface DeadRow {\n\tid: string;\n\teventType: string;\n\tattempt: number;\n\tblockHeight: number;\n\ttxId: string | null;\n\tpayload: Record<string, unknown>;\n\tfailedAt: string | null;\n\tcreatedAt: string;\n}\n\nfunction formatIssuePath(path: PropertyKey[]): string {\n\treturn path.length > 0 ? `${path.map(String).join(\".\")}: ` : \"\";\n}\n\nexport function formatWebhookSchemaErrors(error: z.ZodError): string[] {\n\treturn error.issues.map(\n\t\t(issue) => `${formatIssuePath(issue.path)}${issue.message}`,\n\t);\n}\n",
|
|
5
|
+
"import { z } from \"zod\";\n\nexport {\n\tCHAIN_TRIGGER_FIELDS,\n\tCHAIN_TRIGGER_TYPES,\n} from \"./chain-triggers\";\nexport type { ChainTriggerType } from \"./chain-triggers\";\n\nexport const WEBHOOK_FORMATS = [\n\t\"standard-webhooks\",\n\t\"inngest\",\n\t\"trigger\",\n\t\"cloudflare\",\n\t\"cloudevents\",\n\t\"raw\",\n] as const;\n\nexport const WEBHOOK_STATUSES = [\"active\", \"paused\", \"error\"] as const;\n\n/**\n * Delivery-cap ceilings. Self-host defaults keep today's hardcoded limits\n * (100 retries, 300s timeout); an operator raises or lowers them per env.\n * Read live (not baked in at import) so a changed env var takes effect on\n * the next request without a process restart, and so tests can override\n * per-case.\n */\nexport const WEBHOOK_MAX_RETRIES_CEILING_DEFAULT = 100;\nexport const WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT = 300_000;\n\nfunction ceilingFromEnv(envVar: string, fallback: number): number {\n\tconst raw = process.env[envVar];\n\tif (raw === undefined) return fallback;\n\tconst parsed = Number.parseInt(raw, 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\nexport function webhookMaxRetriesCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_MAX_RETRIES_CEILING\",\n\t\tWEBHOOK_MAX_RETRIES_CEILING_DEFAULT,\n\t);\n}\n\nexport function webhookTimeoutMsCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_TIMEOUT_MS_CEILING\",\n\t\tWEBHOOK_TIMEOUT_MS_CEILING_DEFAULT,\n\t);\n}\n\nfunction maxRetriesField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(0)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookMaxRetriesCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `maxRetries exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nfunction timeoutMsField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(100)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookTimeoutMsCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `timeoutMs exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nconst webhookUrl = z\n\t.string()\n\t.trim()\n\t.min(1)\n\t.refine(\n\t\t(value) => value.startsWith(\"http://\") || value.startsWith(\"https://\"),\n\t\t\"must be an http(s) URL\",\n\t);\n\nconst name = z.string().trim().min(1).max(128);\n\n/** Webhook names another first-party product owns and looks up by name.\n * Renaming one breaks that product's reconcile, so the API refuses it and\n * the dashboard shows the owner instead of Rename. Prefix -> display name. */\nexport const MANAGED_NAME_PREFIXES: Readonly<Record<string, string>> = {\n\t\"sentinel:\": \"Sentinel\",\n};\n\nexport function managedByForName(name: string): string | null {\n\tfor (const [prefix, owner] of Object.entries(MANAGED_NAME_PREFIXES)) {\n\t\tif (name.startsWith(prefix)) return owner;\n\t}\n\treturn null;\n}\n\nexport const WebhookStatusSchema: z.ZodType<WebhookStatus> =\n\tz.enum(WEBHOOK_STATUSES);\nexport const WebhookFormatSchema: z.ZodType<WebhookFormat> =\n\tz.enum(WEBHOOK_FORMATS);\n\n// --- Chain triggers (direct chain-level webhooks) -----------------------\n// A chain webhook reacts to raw chain events matched directly off the\n// Index/Streams clock (no subgraph). `triggers` is an array of these filters —\n// the JSON mirror of the subgraph runtime's `SubgraphFilter` union. Defined\n// here (not imported from @secondlayer/subgraphs) to avoid a shared→subgraphs\n// cycle; the evaluator maps these to `SubgraphFilter` at match time. Amounts are\n// non-negative integer strings (uint128 can exceed JS safe-int) or numbers.\n\n/** Runes trigger types (plan 060) — matched off `chain=bitcoin` Streams events\n * (plan 059), not the Stacks Index clock. `rune` is a RuneRef (an id like\n * `840000:3` or a name like `DOG•GO•TO•THE•MOON`); the API resolves and\n * normalizes it to its canonical id at create time (see `../../routes/webhooks.ts`),\n * rejecting an unresolvable one with 400 when Bitcoin data is configured. */\nconst runeRef = z.string().trim().min(1);\n\nconst triggerAmount = z.union([\n\tz.string().trim().regex(/^\\d+$/, \"must be a non-negative integer string\"),\n\tz.number().int().nonnegative(),\n]);\n/** Principal/identifier/name patterns — `*` wildcards allowed (matched by the\n * evaluator). */\nconst triggerPattern = z.string().trim().min(1);\nconst trait = z.string().trim().min(1);\n\n/**\n * `print_event` `where`: equality on top-level keys of the decoded print\n * tuple, spelled as the contract prints them. An array is any-of; multiple\n * keys AND. Values compare against the field's JSON-normalized form.\n */\nconst printWhereValue = z.string().min(1).max(256);\nexport const PrintWhereSchema: z.ZodType<Record<string, string | string[]>> = z\n\t.record(\n\t\tz.string().trim().min(1).max(64),\n\t\tz.union([printWhereValue, z.array(printWhereValue).min(1).max(20)]),\n\t)\n\t.refine((o) => {\n\t\tconst n = Object.keys(o).length;\n\t\treturn n >= 1 && n <= 10;\n\t}, \"where takes 1 to 10 keys\");\n\nexport const ChainTriggerSchema: z.ZodType<ChainTrigger> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_transfer\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_mint\"),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_burn\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_lock\"),\n\t\t\t\tlockedAddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_deploy\"),\n\t\t\t\tdeployer: triggerPattern.optional(),\n\t\t\t\tcontractName: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"print_event\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\ttopic: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t\twhere: PrintWhereSchema.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nested_contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"var_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tvarName: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_insert\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_delete\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_deposit\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\tbitcoinTxid: triggerPattern.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_create\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_accept\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_reject\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_swept_confirmed\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_etch\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_mint\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_transfer\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t\taddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_burn\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t],\n);\n\nexport const ChainTriggersSchema: z.ZodType<ChainTrigger[]> = z\n\t.array(ChainTriggerSchema)\n\t.min(1)\n\t.max(50);\n\nexport const CreateWebhookRequestSchema: z.ZodType<ParsedCreateWebhookRequest> =\n\tz.object({\n\t\tname,\n\t\ttriggers: ChainTriggersSchema,\n\t\turl: webhookUrl,\n\t\tformat: WebhookFormatSchema.default(\"standard-webhooks\"),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t});\n\nexport const UpdateWebhookRequestSchema: z.ZodType<UpdateWebhookRequest> = z\n\t.object({\n\t\tname: name.optional(),\n\t\turl: webhookUrl.optional(),\n\t\tformat: WebhookFormatSchema.optional(),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t})\n\t.refine((value) => Object.keys(value).length > 0, {\n\t\tmessage: \"At least one field must be provided\",\n\t});\n\nexport const ReplayWebhookRequestSchema: z.ZodType<ReplayWebhookRequest> = z\n\t.object({\n\t\tfromBlock: z.number().int().nonnegative(),\n\t\ttoBlock: z.number().int().nonnegative(),\n\t\tforce: z.string().trim().min(1).max(64).optional(),\n\t})\n\t.refine((value) => value.fromBlock <= value.toBlock, {\n\t\tmessage: \"fromBlock must be less than or equal to toBlock\",\n\t\tpath: [\"toBlock\"],\n\t});\n\nexport const RequeueDeadRequestSchema: z.ZodType<RequeueDeadRequest> = z.object(\n\t{\n\t\treplayId: z\n\t\t\t.string()\n\t\t\t.regex(/^[0-9a-f]{16}$/, \"replayId must be 16 hex characters\")\n\t\t\t.optional(),\n\t\tsince: z.iso.datetime({ offset: true }).optional(),\n\t},\n);\n\nexport type WebhookStatus = (typeof WEBHOOK_STATUSES)[number];\n/** Webhook kind (mirrors db/types `WebhookKind`). Chain events only. */\nexport type WebhookKind = \"chain\";\nexport type WebhookFormat = (typeof WEBHOOK_FORMATS)[number];\n\n/** Non-negative integer amount over JSON (string for uint128 safety, or number). */\nexport type ChainTriggerAmount = string | number;\n\ninterface TraitScoped {\n\ttrait?: string;\n}\n\n/** JSON mirror of the subgraph runtime's `SubgraphFilter` union. */\nexport type ChainTrigger =\n\t| {\n\t\t\ttype: \"stx_transfer\";\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"stx_mint\"; recipient?: string; minAmount?: ChainTriggerAmount }\n\t| { type: \"stx_burn\"; sender?: string; minAmount?: ChainTriggerAmount }\n\t| {\n\t\t\ttype: \"stx_lock\";\n\t\t\tlockedAddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| ({\n\t\t\ttype: \"ft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t } & TraitScoped)\n\t| { type: \"contract_deploy\"; deployer?: string; contractName?: string }\n\t| ({\n\t\t\ttype: \"print_event\";\n\t\t\tcontractId?: string;\n\t\t\ttopic?: string;\n\t\t\t/** Equality on top-level keys of the decoded print tuple; array = any-of, keys AND. */\n\t\t\twhere?: Record<string, string | readonly string[]>;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nested_contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"var_set\";\n\t\t\tcontractId?: string;\n\t\t\tvarName?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_set\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_insert\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_delete\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| {\n\t\t\ttype: \"sbtc_deposit\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\tbitcoinTxid?: string;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_create\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_accept\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"sbtc_withdrawal_reject\"; requestId?: number }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_swept_confirmed\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"rune_etch\"; rune?: string }\n\t| { type: \"rune_mint\"; rune?: string }\n\t| {\n\t\t\ttype: \"rune_transfer\";\n\t\t\trune?: string;\n\t\t\taddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"rune_burn\"; rune?: string };\n\n/** Args for a chain-trigger builder — every field of a variant except `type`. */\ntype TriggerArgs<T extends ChainTrigger[\"type\"]> = Omit<\n\tExtract<ChainTrigger, { type: T }>,\n\t\"type\"\n>;\n\n/**\n * Ergonomic chain-trigger constructors for `webhooks.create({ triggers })`.\n * Each returns a bare `ChainTrigger` (the wire shape the API expects):\n *\n * ```ts\n * client.webhooks.create({\n * url: \"https://my.app/webhook\",\n * triggers: [trigger.contractCall({ contractId: \"SP....amm\", functionName: \"swap-*\" })],\n * });\n * ```\n */\nexport const trigger = {\n\tstxTransfer: (f: TriggerArgs<\"stx_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_transfer\",\n\t\t...f,\n\t}),\n\tstxMint: (f: TriggerArgs<\"stx_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_mint\",\n\t\t...f,\n\t}),\n\tstxBurn: (f: TriggerArgs<\"stx_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_burn\",\n\t\t...f,\n\t}),\n\tstxLock: (f: TriggerArgs<\"stx_lock\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_lock\",\n\t\t...f,\n\t}),\n\tftTransfer: (f: TriggerArgs<\"ft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_transfer\",\n\t\t...f,\n\t}),\n\tftMint: (f: TriggerArgs<\"ft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_mint\",\n\t\t...f,\n\t}),\n\tftBurn: (f: TriggerArgs<\"ft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_burn\",\n\t\t...f,\n\t}),\n\tnftTransfer: (f: TriggerArgs<\"nft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_transfer\",\n\t\t...f,\n\t}),\n\tnftMint: (f: TriggerArgs<\"nft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_mint\",\n\t\t...f,\n\t}),\n\tnftBurn: (f: TriggerArgs<\"nft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_burn\",\n\t\t...f,\n\t}),\n\tcontractCall: (f: TriggerArgs<\"contract_call\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_call\",\n\t\t...f,\n\t}),\n\tcontractDeploy: (f: TriggerArgs<\"contract_deploy\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_deploy\",\n\t\t...f,\n\t}),\n\tprintEvent: (f: TriggerArgs<\"print_event\"> = {}): ChainTrigger => ({\n\t\ttype: \"print_event\",\n\t\t...f,\n\t}),\n\tsbtcDeposit: (f: TriggerArgs<\"sbtc_deposit\"> = {}): ChainTrigger => ({\n\t\ttype: \"sbtc_deposit\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalCreate: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_create\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_create\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalAccept: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_accept\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_accept\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalReject: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_reject\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_reject\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalSweptConfirmed: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_swept_confirmed\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_swept_confirmed\",\n\t\t...f,\n\t}),\n\truneEtch: (f: TriggerArgs<\"rune_etch\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_etch\",\n\t\t...f,\n\t}),\n\truneMint: (f: TriggerArgs<\"rune_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_mint\",\n\t\t...f,\n\t}),\n\truneTransfer: (f: TriggerArgs<\"rune_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_transfer\",\n\t\t...f,\n\t}),\n\truneBurn: (f: TriggerArgs<\"rune_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_burn\",\n\t\t...f,\n\t}),\n} as const;\n\n/** The body for creating a webhook: name, triggers, URL, delivery options. */\nexport interface CreateWebhookRequest {\n\tname: string;\n\ttriggers: ChainTrigger[];\n\turl: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport interface ParsedCreateWebhookRequest\n\textends Omit<CreateWebhookRequest, \"format\"> {\n\tformat: WebhookFormat;\n}\n\n/** The fields of a webhook you can change. */\nexport interface UpdateWebhookRequest {\n\tname?: string;\n\turl?: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport type ParsedUpdateWebhookRequest = UpdateWebhookRequest;\n\nexport interface ReplayWebhookRequest {\n\tfromBlock: number;\n\ttoBlock: number;\n\tforce?: string;\n}\n\nexport type ParsedReplayWebhookRequest = ReplayWebhookRequest;\n\n/** Body of `POST /:id/dead/requeue`. Both fields narrow which dead rows requeue. */\nexport interface RequeueDeadRequest {\n\treplayId?: string;\n\t/** ISO datetime; only dead rows that failed at or after it. */\n\tsince?: string;\n}\n\n/** A webhook's name, status, format, and URL. */\nexport interface WebhookSummary {\n\tid: string;\n\tname: string;\n\tstatus: WebhookStatus;\n\tkind: WebhookKind;\n\tformat: WebhookFormat;\n\turl: string;\n\tlastDeliveryAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** When the circuit breaker paused this webhook (20 straight failures);\n\t * cleared on resume. Present on the list summary (not detail-only) so a\n\t * numbers-only insight can be shown per row without a per-row fetch. */\n\tcircuitOpenedAt: string | null;\n\t/** Consecutive failed deliveries (reset to 0 on a success). On the\n\t * summary so the list can show a failing receiver per row without a\n\t * per-row fetch. */\n\tcircuitFailures: number;\n\t/** Owning product, derived from the name prefix (`MANAGED_NAME_PREFIXES`).\n\t * When non-null the API refuses to rename the webhook. */\n\tmanagedBy: string | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** What a webhook's receiver credentials look like once redacted for a\n * response — never the bearer token, basic-auth string, or header values\n * themselves, only enough to show what's set. `authConfig` on create/update\n * is unaffected (write-only: the API still accepts it, just never echoes\n * it back). */\nexport interface WebhookAuth {\n\ttype: \"bearer\" | \"basic\" | \"none\";\n\t/** Keys of any extra headers the receiver expects — never their values. */\n\theaderNames: string[];\n\t/** True when a bearer token or basic-auth string is set, whatever it is. */\n\thasSecret: boolean;\n}\n\n/** A webhook with its triggers, auth, retry, and timeout settings. */\nexport interface WebhookDetail extends WebhookSummary {\n\t/** Chain-trigger filters. */\n\ttriggers: ChainTrigger[];\n\tauth: WebhookAuth;\n\tmaxRetries: number;\n\ttimeoutMs: number;\n\tconcurrency: number;\n\tlastError: string | null;\n\t/** When the receiver's TLS certificate expires, from the periodic probe.\n\t * Null for http receivers, refused or unreachable hosts, and webhooks not\n\t * probed yet. */\n\treceiverCertExpiresAt: string | null;\n\t/** Set when this instance's chain-trigger\n\t * evaluator isn't running (`SUBGRAPH_SOURCE` != `streams-index`) — the\n\t * webhook will never fire until that's fixed. Null otherwise. Surfaced\n\t * on create (so it's seen immediately) and on every read (so `secondlayer\n\t * webhooks doctor` reports it for a webhook created before the mismatch,\n\t * or on an instance whose config changed since). */\n\twarning: string | null;\n}\n\n/** The new webhook and its signing secret, shown once. */\nexport interface CreateWebhookResponse {\n\twebhook: WebhookDetail;\n\t/** Plaintext signing secret — surfaced ONCE. Store it server-side. */\n\tsigningSecret: string;\n}\n\n/** The webhook and its new signing secret. */\nexport interface RotateSecretResponse {\n\twebhook: WebhookDetail;\n\tsigningSecret: string;\n}\n\n/** One delivery attempt: status code, error, duration, and response. */\nexport interface DeliveryRow {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\terrorMessage: string | null;\n\tdurationMs: number | null;\n\tresponseBody: string | null;\n\tdispatchedAt: string;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\tblockHeight: number | null;\n\t/** ISO timestamp of the delivered event's block. `null` for test\n\t * deliveries, events already compacted out of the outbox, and rows\n\t * written before this column existed. */\n\tblockTime: string | null;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\ttxId: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`.\n\t * Null for test deliveries, compacted rows, and rows with neither shape\n\t * (a settlement or reorg outbox row). */\n\teventIndex: number | null;\n}\n\n/** One hour of `webhook_outbox` activity (`GET /:id/activity`), zero-filled\n * so the events chart always has 168 bars. */\nexport interface WebhookActivityHour {\n\t/** ISO timestamp, UTC hour start. */\n\thour: string;\n\tdelivered: number;\n\twaiting: number;\n\tgaveUp: number;\n\t/** Failed attempts in the hour (no response or non-2xx), from\n\t * `webhook_deliveries`. Attempts, not events: a retried-then-delivered\n\t * event counts here but is `delivered` above. */\n\tfailed: number;\n}\n\n/** A week of hourly delivery counts and what is waiting now. */\nexport interface WebhookActivity {\n\t/** 168 hours, oldest first. */\n\thours: WebhookActivityHour[];\n\t/** Pending rows right now, no time bound. */\n\twaiting: number;\n\tnextAttemptAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** 7-day counts per `event_type` (same 168-hour window as `hours`), e.g.\n\t * `chain.stx_transfer.apply` — the config card's per-trigger volume. */\n\tbyEventType: Record<string, number>;\n\t/** Typical delivered attempts for each UTC hour of day (p10 and p90 of the\n\t * last 28 days, from `webhook_deliveries`). Null at low volume, where\n\t * \"usual\" is not meaningful. */\n\tusualByHourOfDay: Array<{ lo: number; hi: number }> | null;\n\t/** Present with `?days=30`: 30 UTC days, oldest first, from\n\t * `webhook_deliveries` (2xx is delivered, everything else failed). */\n\tdays?: WebhookActivityDay[];\n}\n\n/** One UTC day of delivery attempts (`GET /:id/activity?days=30`). */\nexport interface WebhookActivityDay {\n\t/** YYYY-MM-DD, UTC. */\n\tday: string;\n\tdelivered: number;\n\tfailed: number;\n}\n\n/** Heat data for every webhook on the account (`GET /api/webhooks/activity`),\n * from `webhook_deliveries` attempts. */\nexport interface WebhooksActivitySummary {\n\t/** 168 ISO UTC hour starts, oldest first. */\n\thours: string[];\n\t/** Arrays are aligned to `hours` and zero-filled. */\n\twebhooks: Array<{ id: string; delivered: number[]; failed: number[] }>;\n}\n\n/**\n * One delivery attempt with its outbox context.\n *\n * Serves the delivery card (`GET /:id/deliveries/:deliveryId`). `payload`,\n * `outboxId`, `eventType`, `txId`, `blockHeight`, `blockTime`, and `eventIndex`\n * are null once the outbox row is gone (compacted after 7 days) or for a test\n * delivery, which never had one.\n */\nexport interface WebhookDeliveryDetail {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\tdurationMs: number | null;\n\tdispatchedAt: string;\n\terrorMessage: string | null;\n\tresponseBody: string | null;\n\tresponseHeaders: Record<string, string> | null;\n\toutboxId: string | null;\n\t/** The outbox row's own status — `null` once it's gone (compacted after\n\t * delivery, or never had one, e.g. a test delivery). Only `\"dead\"` means\n\t * a resend is possible: it's the one status `POST /:id/dead/:outboxId/\n\t * requeue` accepts. */\n\toutboxStatus: \"pending\" | \"delivered\" | \"dead\" | null;\n\teventType: string | null;\n\ttxId: string | null;\n\tblockHeight: number | null;\n\tblockTime: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`\n\t * (`event_index` for a chain-trigger row). Null when `row_pk` carries\n\t * none — a settlement or reorg outbox row, or no outbox row at all. */\n\teventIndex: number | null;\n\tpayload: unknown | null;\n}\n\n/** How many events a replay scanned and enqueued. */\nexport interface ReplayResult {\n\treplayId: string;\n\tenqueuedCount: number;\n\tscannedCount: number;\n}\n\n/** Live state of one stored replay. */\nexport interface ReplayProgress {\n\treplayId: string;\n\twebhookId: string;\n\tstatus: \"scanning\" | \"running\" | \"done\" | \"failed\";\n\tfromBlock: number;\n\ttoBlock: number;\n\t/** Events the replay enqueued. */\n\ttotal: number;\n\t/** Delivered or gave up (`total - pending`). */\n\tprocessed: number;\n\tpending: number;\n\t/** Null until the replay finishes. */\n\tdelivered: number | null;\n\t/** Null until the replay finishes. */\n\tgaveUp: number | null;\n\tstartedAt: string;\n\tfinishedAt: string | null;\n\terror: string | null;\n}\n\n/** Range presets for starting a replay, from `GET /:id/replays`. */\nexport interface ReplayRanges {\n\t/** Last evaluated block; null when the webhook has no evaluator state yet. */\n\ttip: number | null;\n\tpresets: Array<{\n\t\tblocks: 100 | 1000 | 10000;\n\t\tfromBlock: number;\n\t\ttoBlock: number;\n\t\t/** Lower bound: delivered rows are deleted after 7 days. */\n\t\tknownEvents: number;\n\t}>;\n\t/** Dead rows since the webhook last succeeded (all dead rows when it never has). */\n\tdeadSinceFailing: { since: string | null; count: number };\n}\n\n/** Result of a one-off test delivery (`POST /:id/test`). Logged as a delivery\n * row (with a null outbox_id) so it shows up under the webhook's deliveries. */\nexport interface WebhookTestResult {\n\tok: boolean;\n\tstatusCode: number | null;\n\terror: string | null;\n\tdurationMs: number;\n\tdeliveryId: string;\n}\n\n/** A delivery that ran out of retries. */\nexport interface DeadRow {\n\tid: string;\n\teventType: string;\n\tattempt: number;\n\tblockHeight: number;\n\ttxId: string | null;\n\tpayload: Record<string, unknown>;\n\tfailedAt: string | null;\n\tcreatedAt: string;\n}\n\nfunction formatIssuePath(path: PropertyKey[]): string {\n\treturn path.length > 0 ? `${path.map(String).join(\".\")}: ` : \"\";\n}\n\nexport function formatWebhookSchemaErrors(error: z.ZodError): string[] {\n\treturn error.issues.map(\n\t\t(issue) => `${formatIssuePath(issue.path)}${issue.message}`,\n\t);\n}\n",
|
|
6
6
|
"// This file must stay import-free. The SDK's `webhooks/triggers` subpath\n// re-exports it, and that reaches the browser through apps/web, so anything\n// imported here (zod especially) would ship to the client bundle.\n//\n// CHAIN_TRIGGER_FIELDS is a literal, checked against ChainTriggerSchema in\n// webhooks.test.ts so it can never drift behind the validator.\n\nexport const CHAIN_TRIGGER_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"contract_call\",\n\t\"contract_deploy\",\n\t\"print_event\",\n\t\"nested_contract_call\",\n\t\"var_set\",\n\t\"map_set\",\n\t\"map_insert\",\n\t\"map_delete\",\n\t\"sbtc_deposit\",\n\t\"sbtc_withdrawal_create\",\n\t\"sbtc_withdrawal_accept\",\n\t\"sbtc_withdrawal_reject\",\n\t\"sbtc_withdrawal_swept_confirmed\",\n\t\"rune_etch\",\n\t\"rune_mint\",\n\t\"rune_transfer\",\n\t\"rune_burn\",\n] as const;\n\nexport type ChainTriggerType = (typeof CHAIN_TRIGGER_TYPES)[number];\n\n/**\n * Per-type accepted filter fields for chain triggers, in validator key order.\n */\nexport const CHAIN_TRIGGER_FIELDS: Record<string, string[]> = {\n\tstx_transfer: [\"sender\", \"recipient\", \"minAmount\", \"maxAmount\"],\n\tstx_mint: [\"recipient\", \"minAmount\"],\n\tstx_burn: [\"sender\", \"minAmount\"],\n\tstx_lock: [\"lockedAddress\", \"minAmount\"],\n\tft_transfer: [\"assetIdentifier\", \"sender\", \"recipient\", \"minAmount\", \"trait\"],\n\tft_mint: [\"assetIdentifier\", \"recipient\", \"minAmount\", \"trait\"],\n\tft_burn: [\"assetIdentifier\", \"sender\", \"minAmount\", \"trait\"],\n\tnft_transfer: [\"assetIdentifier\", \"sender\", \"recipient\", \"trait\"],\n\tnft_mint: [\"assetIdentifier\", \"recipient\", \"trait\"],\n\tnft_burn: [\"assetIdentifier\", \"sender\", \"trait\"],\n\tcontract_call: [\"contractId\", \"functionName\", \"caller\", \"trait\"],\n\tcontract_deploy: [\"deployer\", \"contractName\"],\n\tprint_event: [\"contractId\", \"topic\", \"trait\", \"where\"],\n\tnested_contract_call: [\n\t\t\"contractId\",\n\t\t\"functionName\",\n\t\t\"caller\",\n\t\t\"sender\",\n\t\t\"trait\",\n\t],\n\tvar_set: [\"contractId\", \"varName\", \"trait\"],\n\tmap_set: [\"contractId\", \"map\", \"trait\"],\n\tmap_insert: [\"contractId\", \"map\", \"trait\"],\n\tmap_delete: [\"contractId\", \"map\", \"trait\"],\n\tsbtc_deposit: [\n\t\t\"sender\",\n\t\t\"minAmount\",\n\t\t\"maxAmount\",\n\t\t\"bitcoinTxid\",\n\t\t\"requestId\",\n\t],\n\tsbtc_withdrawal_create: [\"sender\", \"minAmount\", \"maxAmount\", \"requestId\"],\n\tsbtc_withdrawal_accept: [\"requestId\", \"sweepTxid\"],\n\tsbtc_withdrawal_reject: [\"requestId\"],\n\tsbtc_withdrawal_swept_confirmed: [\"requestId\", \"sweepTxid\"],\n\trune_etch: [\"rune\"],\n\trune_mint: [\"rune\"],\n\trune_transfer: [\"rune\", \"address\", \"minAmount\"],\n\trune_burn: [\"rune\"],\n};\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";AAAA;;;ACOO,IAAM,sBAAsB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AU,CAAC,IAA8B,CAAC,OAAqB;AAAA,IAC9D,MAAM;AAAA,OACH;AAAA,EACJ;AACD;AAuSA,SAAS,eAAe,CAAC,MAA6B;AAAA,EACrD,OAAO,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,MAAM,EAAE,KAAK,GAAG,QAAQ;AAAA;AAGvD,SAAS,yBAAyB,CAAC,OAA6B;AAAA,EACtE,OAAO,MAAM,OAAO,IACnB,CAAC,UAAU,GAAG,gBAAgB,MAAM,IAAI,IAAI,MAAM,SACnD;AAAA;",
|
|
9
|
+
"debugId": "C674416999734A8164756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hides an open insight until this time ("Until tomorrow" on the phone).
|
|
6
|
+
* Survives re-fires, like `dismissed_at`.
|
|
7
|
+
*/
|
|
8
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
9
|
+
await onControlPlane(async () => {
|
|
10
|
+
await sql`
|
|
11
|
+
ALTER TABLE insights ADD COLUMN IF NOT EXISTS snoozed_until timestamptz
|
|
12
|
+
`.execute(db);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
17
|
+
await onControlPlane(async () => {
|
|
18
|
+
await sql`ALTER TABLE insights DROP COLUMN IF EXISTS snoozed_until`.execute(
|
|
19
|
+
db,
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One stored record per webhook replay, so a replay can be watched (queued,
|
|
6
|
+
* delivering N of M, done) and what gave up can be requeued. The partial
|
|
7
|
+
* unique index lets the database, not process memory, enforce "one replay
|
|
8
|
+
* scanning per webhook at a time".
|
|
9
|
+
*
|
|
10
|
+
* `webhook_outbox.replay_id` links outbox rows to their replay. It is a
|
|
11
|
+
* nullable column with no default (instant) and deliberately has NO index:
|
|
12
|
+
* building one on the large, hot outbox would block delivery inserts on every
|
|
13
|
+
* hosted stack. Progress counts use the existing partial index on pending rows.
|
|
14
|
+
*/
|
|
15
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
16
|
+
await onControlPlane(async () => {
|
|
17
|
+
await sql`
|
|
18
|
+
CREATE TABLE webhook_replays (
|
|
19
|
+
id text PRIMARY KEY,
|
|
20
|
+
webhook_id uuid NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE,
|
|
21
|
+
from_block bigint NOT NULL,
|
|
22
|
+
to_block bigint NOT NULL,
|
|
23
|
+
status text NOT NULL CHECK (status IN ('scanning','running','done','failed')),
|
|
24
|
+
scanned_count integer NOT NULL DEFAULT 0,
|
|
25
|
+
enqueued_count integer NOT NULL DEFAULT 0,
|
|
26
|
+
total integer,
|
|
27
|
+
delivered integer,
|
|
28
|
+
gave_up integer,
|
|
29
|
+
error text,
|
|
30
|
+
started_at timestamptz NOT NULL DEFAULT now(),
|
|
31
|
+
finished_at timestamptz
|
|
32
|
+
)
|
|
33
|
+
`.execute(db);
|
|
34
|
+
await sql`
|
|
35
|
+
CREATE UNIQUE INDEX webhook_replays_one_scanning
|
|
36
|
+
ON webhook_replays (webhook_id)
|
|
37
|
+
WHERE status = 'scanning'
|
|
38
|
+
`.execute(db);
|
|
39
|
+
await sql`
|
|
40
|
+
CREATE INDEX webhook_replays_webhook_started
|
|
41
|
+
ON webhook_replays (webhook_id, started_at DESC)
|
|
42
|
+
`.execute(db);
|
|
43
|
+
await sql`
|
|
44
|
+
ALTER TABLE webhook_outbox ADD COLUMN IF NOT EXISTS replay_id text
|
|
45
|
+
`.execute(db);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
50
|
+
await onControlPlane(async () => {
|
|
51
|
+
await sql`ALTER TABLE webhook_outbox DROP COLUMN IF EXISTS replay_id`.execute(
|
|
52
|
+
db,
|
|
53
|
+
);
|
|
54
|
+
await sql`DROP TABLE IF EXISTS webhook_replays`.execute(db);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Web push for the installed phone app.
|
|
6
|
+
*
|
|
7
|
+
* `push_subscriptions`: one row per browser/device subscription. `endpoint` is
|
|
8
|
+
* unique, so the same browser re-subscribing (or signing in as another
|
|
9
|
+
* account) moves its row instead of duplicating it. `failed_count` counts
|
|
10
|
+
* delivery errors since the last success; 404/410 responses delete the row.
|
|
11
|
+
*
|
|
12
|
+
* `push_prefs`: one row per account, written on first change. A missing row
|
|
13
|
+
* means the column defaults, so most accounts never have one.
|
|
14
|
+
*/
|
|
15
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
16
|
+
await onControlPlane(async () => {
|
|
17
|
+
await sql`
|
|
18
|
+
CREATE TABLE push_subscriptions (
|
|
19
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
20
|
+
account_id uuid NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
|
|
21
|
+
endpoint text NOT NULL UNIQUE,
|
|
22
|
+
p256dh text NOT NULL,
|
|
23
|
+
auth text NOT NULL,
|
|
24
|
+
user_agent text,
|
|
25
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
26
|
+
last_success_at timestamptz,
|
|
27
|
+
failed_count integer NOT NULL DEFAULT 0
|
|
28
|
+
)
|
|
29
|
+
`.execute(db);
|
|
30
|
+
await sql`
|
|
31
|
+
CREATE INDEX push_subscriptions_account
|
|
32
|
+
ON push_subscriptions (account_id)
|
|
33
|
+
`.execute(db);
|
|
34
|
+
await sql`
|
|
35
|
+
CREATE TABLE push_prefs (
|
|
36
|
+
account_id uuid PRIMARY KEY REFERENCES accounts(id) ON DELETE CASCADE,
|
|
37
|
+
webhook_failing boolean NOT NULL DEFAULT true,
|
|
38
|
+
subgraph_stopped boolean NOT NULL DEFAULT true,
|
|
39
|
+
subgraph_not_serving boolean NOT NULL DEFAULT true,
|
|
40
|
+
replay_done boolean NOT NULL DEFAULT true,
|
|
41
|
+
spend_cap boolean NOT NULL DEFAULT false,
|
|
42
|
+
key_repeat boolean NOT NULL DEFAULT false,
|
|
43
|
+
updated_at timestamptz NOT NULL DEFAULT now()
|
|
44
|
+
)
|
|
45
|
+
`.execute(db);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
50
|
+
await onControlPlane(async () => {
|
|
51
|
+
await sql`DROP TABLE IF EXISTS push_prefs`.execute(db);
|
|
52
|
+
await sql`DROP TABLE IF EXISTS push_subscriptions`.execute(db);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One row per push already sent, so a signal that is seen again never pushes
|
|
6
|
+
* twice. `key` encodes "once per what" (an outage, a stop, a finished
|
|
7
|
+
* replay). Rows are purged after 30 days.
|
|
8
|
+
*/
|
|
9
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
10
|
+
await onControlPlane(async () => {
|
|
11
|
+
await sql`
|
|
12
|
+
CREATE TABLE push_sent (
|
|
13
|
+
account_id uuid NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
|
|
14
|
+
key text NOT NULL,
|
|
15
|
+
kind text NOT NULL,
|
|
16
|
+
sent_at timestamptz NOT NULL DEFAULT now(),
|
|
17
|
+
PRIMARY KEY (account_id, key)
|
|
18
|
+
)
|
|
19
|
+
`.execute(db);
|
|
20
|
+
await sql`
|
|
21
|
+
CREATE INDEX push_sent_sent_at ON push_sent (sent_at)
|
|
22
|
+
`.execute(db);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
27
|
+
await onControlPlane(async () => {
|
|
28
|
+
await sql`DROP TABLE IF EXISTS push_sent`.execute(db);
|
|
29
|
+
});
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/shared",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.13.1",
|
|
4
4
|
"description": "Internal building blocks shared across Secondlayer packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
"types": "./dist/src/db/queries/webhooks.d.ts",
|
|
86
86
|
"import": "./dist/src/db/queries/webhooks.js"
|
|
87
87
|
},
|
|
88
|
+
"./db/queries/webhook-replays": {
|
|
89
|
+
"types": "./dist/src/db/queries/webhook-replays.d.ts",
|
|
90
|
+
"import": "./dist/src/db/queries/webhook-replays.js"
|
|
91
|
+
},
|
|
88
92
|
"./crypto/standard-webhooks": {
|
|
89
93
|
"types": "./dist/src/crypto/standard-webhooks.d.ts",
|
|
90
94
|
"import": "./dist/src/crypto/standard-webhooks.js"
|