@secondlayer/shared 12.1.1 → 12.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/archive/copy-loader.d.ts +1 -0
- package/dist/src/archive/copy-loader.js.map +2 -2
- package/dist/src/archive/instance-diagnosis.d.ts +1 -0
- package/dist/src/archive/instance-diagnosis.js.map +2 -2
- package/dist/src/archive/reference.d.ts +1 -0
- package/dist/src/archive/reference.js.map +2 -2
- package/dist/src/archive/status.d.ts +1 -0
- package/dist/src/archive/status.js.map +2 -2
- package/dist/src/db/queries/subgraphs.js.map +2 -2
- package/dist/src/index-http.d.ts +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.js.map +4 -4
- package/dist/src/node/archive-client.d.ts +1 -0
- package/dist/src/node/archive-client.js.map +2 -2
- package/dist/src/schemas/index.d.ts +15 -0
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subgraphs.d.ts +6 -0
- package/dist/src/schemas/subgraphs.js.map +2 -2
- package/dist/src/schemas/webhooks.d.ts +18 -5
- package/dist/src/schemas/webhooks.js.map +2 -2
- package/dist/src/streams-rows/index.d.ts +7 -3
- package/dist/src/subgraphs/spec.d.ts +3 -0
- package/dist/src/subgraphs/spec.js.map +2 -2
- package/package.json +2 -2
|
@@ -197,6 +197,7 @@ declare const trigger: {
|
|
|
197
197
|
readonly runeTransfer: (f?: TriggerArgs<"rune_transfer">) => ChainTrigger
|
|
198
198
|
readonly runeBurn: (f?: TriggerArgs<"rune_burn">) => ChainTrigger
|
|
199
199
|
};
|
|
200
|
+
/** The body for creating a webhook: name, triggers, URL, delivery options. */
|
|
200
201
|
interface CreateWebhookRequest {
|
|
201
202
|
name: string;
|
|
202
203
|
triggers: ChainTrigger[];
|
|
@@ -210,6 +211,7 @@ interface CreateWebhookRequest {
|
|
|
210
211
|
interface ParsedCreateWebhookRequest extends Omit<CreateWebhookRequest, "format"> {
|
|
211
212
|
format: WebhookFormat;
|
|
212
213
|
}
|
|
214
|
+
/** The fields of a webhook you can change. */
|
|
213
215
|
interface UpdateWebhookRequest {
|
|
214
216
|
name?: string;
|
|
215
217
|
url?: string;
|
|
@@ -226,6 +228,7 @@ interface ReplayWebhookRequest {
|
|
|
226
228
|
force?: string;
|
|
227
229
|
}
|
|
228
230
|
type ParsedReplayWebhookRequest = ReplayWebhookRequest;
|
|
231
|
+
/** A webhook's name, status, format, and URL. */
|
|
229
232
|
interface WebhookSummary {
|
|
230
233
|
id: string;
|
|
231
234
|
name: string;
|
|
@@ -258,6 +261,7 @@ interface WebhookAuth {
|
|
|
258
261
|
/** True when a bearer token or basic-auth string is set, whatever it is. */
|
|
259
262
|
hasSecret: boolean;
|
|
260
263
|
}
|
|
264
|
+
/** A webhook with its triggers, auth, retry, and timeout settings. */
|
|
261
265
|
interface WebhookDetail extends WebhookSummary {
|
|
262
266
|
/** Chain-trigger filters. */
|
|
263
267
|
triggers: ChainTrigger[];
|
|
@@ -274,15 +278,18 @@ interface WebhookDetail extends WebhookSummary {
|
|
|
274
278
|
* or on an instance whose config changed since). */
|
|
275
279
|
warning: string | null;
|
|
276
280
|
}
|
|
281
|
+
/** The new webhook and its signing secret, shown once. */
|
|
277
282
|
interface CreateWebhookResponse {
|
|
278
283
|
webhook: WebhookDetail;
|
|
279
284
|
/** Plaintext signing secret — surfaced ONCE. Store it server-side. */
|
|
280
285
|
signingSecret: string;
|
|
281
286
|
}
|
|
287
|
+
/** The webhook and its new signing secret. */
|
|
282
288
|
interface RotateSecretResponse {
|
|
283
289
|
webhook: WebhookDetail;
|
|
284
290
|
signingSecret: string;
|
|
285
291
|
}
|
|
292
|
+
/** One delivery attempt: status code, error, duration, and response. */
|
|
286
293
|
interface DeliveryRow {
|
|
287
294
|
id: string;
|
|
288
295
|
attempt: number;
|
|
@@ -315,6 +322,7 @@ interface WebhookActivityHour {
|
|
|
315
322
|
waiting: number;
|
|
316
323
|
gaveUp: number;
|
|
317
324
|
}
|
|
325
|
+
/** A week of hourly delivery counts and what is waiting now. */
|
|
318
326
|
interface WebhookActivity {
|
|
319
327
|
/** 168 hours, oldest first. */
|
|
320
328
|
hours: WebhookActivityHour[];
|
|
@@ -326,11 +334,14 @@ interface WebhookActivity {
|
|
|
326
334
|
* `chain.stx_transfer.apply` — the config card's per-trigger volume. */
|
|
327
335
|
byEventType: Record<string, number>;
|
|
328
336
|
}
|
|
329
|
-
/**
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
337
|
+
/**
|
|
338
|
+
* One delivery attempt with its outbox context.
|
|
339
|
+
*
|
|
340
|
+
* Serves the delivery card (`GET /:id/deliveries/:deliveryId`). `payload`,
|
|
341
|
+
* `outboxId`, `eventType`, `txId`, `blockHeight`, `blockTime`, and `eventIndex`
|
|
342
|
+
* are null once the outbox row is gone (compacted after 7 days) or for a test
|
|
343
|
+
* delivery, which never had one.
|
|
344
|
+
*/
|
|
334
345
|
interface WebhookDeliveryDetail {
|
|
335
346
|
id: string;
|
|
336
347
|
attempt: number;
|
|
@@ -356,6 +367,7 @@ interface WebhookDeliveryDetail {
|
|
|
356
367
|
eventIndex: number | null;
|
|
357
368
|
payload: unknown | null;
|
|
358
369
|
}
|
|
370
|
+
/** How many events a replay scanned and enqueued. */
|
|
359
371
|
interface ReplayResult {
|
|
360
372
|
replayId: string;
|
|
361
373
|
enqueuedCount: number;
|
|
@@ -370,6 +382,7 @@ interface WebhookTestResult {
|
|
|
370
382
|
durationMs: number;
|
|
371
383
|
deliveryId: string;
|
|
372
384
|
}
|
|
385
|
+
/** A delivery that ran out of retries. */
|
|
373
386
|
interface DeadRow {
|
|
374
387
|
id: string;
|
|
375
388
|
eventType: string;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/schemas/webhooks.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { z } from \"zod\";\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\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\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\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\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})\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\n/**\n * Per-type accepted filter fields for chain triggers, DERIVED from\n * {@link ChainTriggerSchema} so the agent-facing reference can never drift behind\n * the validator. `{ stx_transfer: [\"sender\",\"recipient\",\"minAmount\",\"maxAmount\"], ... }`.\n */\nexport const CHAIN_TRIGGER_FIELDS: Record<string, string[]> =\n\tObject.fromEntries(\n\t\t// biome-ignore lint/suspicious/noExplicitAny: zod-internal introspection of this module's own discriminated union\n\t\t((ChainTriggerSchema as any)._zod.def.options as any[]).map((opt) => {\n\t\t\tconst shape = opt._zod.def.shape as Record<string, unknown>;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: literal value lives on the zod-internal def\n\t\t\tconst type = (shape.type as any)._zod.def.values[0] as string;\n\t\t\treturn [type, Object.keys(shape).filter((k) => k !== \"type\")];\n\t\t}),\n\t);\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\nexport type ChainTriggerType = (typeof CHAIN_TRIGGER_TYPES)[number];\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 } & 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\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\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\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\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\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/** 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\nexport interface CreateWebhookResponse {\n\twebhook: WebhookDetail;\n\t/** Plaintext signing secret — surfaced ONCE. Store it server-side. */\n\tsigningSecret: string;\n}\n\nexport interface RotateSecretResponse {\n\twebhook: WebhookDetail;\n\tsigningSecret: string;\n}\n\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}\n\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}\n\n/** One delivery attempt with its outbox context, for the delivery card\n * (`GET /:id/deliveries/:deliveryId`). `payload`/`outboxId`/`eventType`/\n * `txId`/`blockHeight`/`blockTime`/`eventIndex` are null once the outbox\n * row is gone (compacted after 7 days) or for a test delivery, which never\n * had one. */\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\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\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 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\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\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\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\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})\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\n/**\n * Per-type accepted filter fields for chain triggers, DERIVED from\n * {@link ChainTriggerSchema} so the agent-facing reference can never drift behind\n * the validator. `{ stx_transfer: [\"sender\",\"recipient\",\"minAmount\",\"maxAmount\"], ... }`.\n */\nexport const CHAIN_TRIGGER_FIELDS: Record<string, string[]> =\n\tObject.fromEntries(\n\t\t// biome-ignore lint/suspicious/noExplicitAny: zod-internal introspection of this module's own discriminated union\n\t\t((ChainTriggerSchema as any)._zod.def.options as any[]).map((opt) => {\n\t\t\tconst shape = opt._zod.def.shape as Record<string, unknown>;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: literal value lives on the zod-internal def\n\t\t\tconst type = (shape.type as any)._zod.def.values[0] as string;\n\t\t\treturn [type, Object.keys(shape).filter((k) => k !== \"type\")];\n\t\t}),\n\t);\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\nexport type ChainTriggerType = (typeof CHAIN_TRIGGER_TYPES)[number];\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 } & 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\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/** 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}\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}\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) => `${formatIssueP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;AAAA,OACH;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,IAA8B,CAAC,OAAqB;AAAA,IAC9D,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,IAA8B,CAAC,OAAqB;AAAA,IAC9D,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,cAAc,CAAC,IAAkC,CAAC,OAAqB;AAAA,IACtE,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,IAA8B,CAAC,OAAqB;AAAA,IAC9D,MAAM;AAAA,OACH;AAAA,EACJ;AACD;AAyNA,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;",
|
|
8
8
|
"debugId": "EBE29289B5D1F08864756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -212,6 +212,7 @@ type RuneEventPayload = {
|
|
|
212
212
|
/** `rune_etch` only — the entry this event created. */
|
|
213
213
|
entry?: RuneEtchEntry
|
|
214
214
|
};
|
|
215
|
+
/** A Bitcoin rune event as Streams serves it. */
|
|
215
216
|
type RuneStreamsEvent = {
|
|
216
217
|
cursor: string
|
|
217
218
|
chain: "bitcoin"
|
|
@@ -231,9 +232,12 @@ type RuneStreamsEvent = {
|
|
|
231
232
|
* Optional for back-compat with the same reasoning as `StreamsEventBase`. */
|
|
232
233
|
finalized?: boolean
|
|
233
234
|
};
|
|
234
|
-
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
235
|
+
/**
|
|
236
|
+
* Any row `GET /v1/streams/events` can return.
|
|
237
|
+
*
|
|
238
|
+
* Stacks rows on the classic clock, vm rows on `clock=vm`, or Runes rows on
|
|
239
|
+
* `chain=bitcoin`. A response never mixes chains or clocks.
|
|
240
|
+
*/
|
|
237
241
|
type StreamsWireEvent = StreamsEvent | VmStreamsEvent | RuneStreamsEvent;
|
|
238
242
|
/** Superset of the columns the decoded_events table holds. Every decoded
|
|
239
243
|
* event's `decoded_payload` is assignable to this, so the indexer's writer
|
|
@@ -61,6 +61,7 @@ interface SubgraphSyncInfo {
|
|
|
61
61
|
/** history_filling = expected gaps while a tip-first backfill op runs. */
|
|
62
62
|
integrity: "complete" | "gaps_detected" | "history_filling";
|
|
63
63
|
}
|
|
64
|
+
/** A subgraph's version, pin, status, tables, and sources. */
|
|
64
65
|
interface SubgraphDetail {
|
|
65
66
|
name: string;
|
|
66
67
|
version: string;
|
|
@@ -103,10 +104,12 @@ interface SubgraphDetail {
|
|
|
103
104
|
updatedAt: string;
|
|
104
105
|
}
|
|
105
106
|
type SubgraphSpecFormat = "openapi" | "agent" | "markdown";
|
|
107
|
+
/** Options for generating a subgraph's agent schema. */
|
|
106
108
|
interface SubgraphSpecOptions {
|
|
107
109
|
serverUrl?: string;
|
|
108
110
|
generatedAt?: string;
|
|
109
111
|
}
|
|
112
|
+
/** A subgraph's tables and columns in a form agents can read. */
|
|
110
113
|
interface SubgraphAgentSchema {
|
|
111
114
|
name: string;
|
|
112
115
|
version: string;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/subgraphs/spec.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { SubgraphDetail } from \"../schemas/subgraphs.ts\";\n\nexport type SubgraphSpecFormat = \"openapi\" | \"agent\" | \"markdown\";\n\nexport interface SubgraphSpecOptions {\n\tserverUrl?: string;\n\tgeneratedAt?: string;\n}\n\nexport interface SubgraphAgentSchema {\n\tname: string;\n\tversion: string;\n\tdescription?: string;\n\tschemaHash?: string;\n\tpin?: string;\n\tgeneratedAt: string;\n\tserverUrl: string;\n\tsources?: Record<string, unknown>;\n\ttables: Record<\n\t\tstring,\n\t\t{\n\t\t\tendpoint: string;\n\t\t\tcountEndpoint: string;\n\t\t\taggregateEndpoint?: string;\n\t\t\tstreamEndpoint?: string;\n\t\t\trowCount: number;\n\t\t\tcolumns: SubgraphDetail[\"tables\"][string][\"columns\"];\n\t\t\tindexes?: readonly (readonly string[])[];\n\t\t\tuniqueKeys?: readonly (readonly string[])[];\n\t\t\tquery: {\n\t\t\t\tparameters: string[];\n\t\t\t\tsortable: string[];\n\t\t\t\tselectable: string[];\n\t\t\t\tsearchable: string[];\n\t\t\t\tfilters: string[];\n\t\t\t};\n\t\t\texamples: {\n\t\t\t\tlist: Record<string, unknown>;\n\t\t\t\tcount: { count: number };\n\t\t\t\tcurl: string;\n\t\t\t};\n\t\t}\n\t>;\n}\n\ntype ColumnMeta = SubgraphDetail[\"tables\"][string][\"columns\"][string];\n\nconst SYSTEM_COLUMNS = [\"_id\", \"_block_height\", \"_tx_id\", \"_created_at\"];\n// /v1 rejects _offset: keyset pagination via cursor + _order.\nconst BASE_QUERY_PARAMS = [\"_limit\", \"cursor\", \"_order\", \"_fields\"];\nconst COMPARISON_OPS = [\"neq\", \"gt\", \"gte\", \"lt\", \"lte\"];\n\nfunction generatedAt(options: SubgraphSpecOptions): string {\n\treturn options.generatedAt ?? new Date().toISOString();\n}\n\n/**\n * Callers that know their instance pass `serverUrl` (the API derives it from the\n * request; the CLI from its resolved API URL). The fallback is the documented\n * default bind, not a hosted host — a spec that advertises someone else's API\n * produces a client that silently talks to the wrong place.\n */\nfunction normalizeServerUrl(serverUrl?: string): string {\n\treturn (serverUrl ?? \"http://127.0.0.1:3800\").replace(/\\/+$/, \"\");\n}\n\nfunction tablePath(subgraphName: string, tableName: string): string {\n\treturn `/v1/subgraphs/${subgraphName}/${tableName}`;\n}\n\nfunction countPath(subgraphName: string, tableName: string): string {\n\treturn `${tablePath(subgraphName, tableName)}/count`;\n}\n\nfunction isTextLike(type: string): boolean {\n\treturn type === \"text\" || type === \"principal\" || type === \"timestamp\";\n}\n\nfunction isComparable(type: string): boolean {\n\treturn (\n\t\ttype === \"uint\" ||\n\t\ttype === \"int\" ||\n\t\ttype === \"bigint\" ||\n\t\ttype === \"serial\" ||\n\t\ttype === \"timestamp\"\n\t);\n}\n\nfunction exampleForColumn(type: string): unknown {\n\tswitch (type) {\n\t\tcase \"uint\":\n\t\tcase \"int\":\n\t\tcase \"bigint\":\n\t\t\treturn \"1000\";\n\t\tcase \"serial\":\n\t\t\treturn 1;\n\t\tcase \"principal\":\n\t\t\treturn \"SP000000000000000000002Q6VF78\";\n\t\tcase \"timestamp\":\n\t\t\treturn \"2026-01-01T00:00:00.000Z\";\n\t\tcase \"boolean\":\n\t\t\treturn true;\n\t\tcase \"jsonb\":\n\t\t\treturn { example: true };\n\t\tdefault:\n\t\t\treturn \"example\";\n\t}\n}\n\nfunction openApiSchemaForColumn(col: ColumnMeta): Record<string, unknown> {\n\tlet schema: Record<string, unknown>;\n\tswitch (col.type) {\n\t\tcase \"uint\":\n\t\tcase \"int\":\n\t\tcase \"bigint\":\n\t\t\tschema = { type: \"string\", pattern: \"^-?\\\\d+(\\\\.\\\\d+)?$\" };\n\t\t\tbreak;\n\t\tcase \"serial\":\n\t\t\tschema = { type: \"integer\" };\n\t\t\tbreak;\n\t\tcase \"principal\":\n\t\tcase \"text\":\n\t\t\tschema = { type: \"string\" };\n\t\t\tbreak;\n\t\tcase \"timestamp\":\n\t\t\tschema = { type: \"string\", format: \"date-time\" };\n\t\t\tbreak;\n\t\tcase \"boolean\":\n\t\t\tschema = { type: \"boolean\" };\n\t\t\tbreak;\n\t\tcase \"jsonb\":\n\t\t\tschema = { type: \"object\", additionalProperties: true };\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tschema = {};\n\t\t\tbreak;\n\t}\n\tif (col.nullable) {\n\t\tconst type = schema.type;\n\t\tif (typeof type === \"string\") schema.type = [type, \"null\"];\n\t}\n\treturn schema;\n}\n\nfunction columnEntries(table: SubgraphDetail[\"tables\"][string]) {\n\treturn Object.entries(table.columns);\n}\n\nfunction selectableColumns(table: SubgraphDetail[\"tables\"][string]): string[] {\n\treturn columnEntries(table).map(([name]) => name);\n}\n\nfunction searchableColumns(table: SubgraphDetail[\"tables\"][string]): string[] {\n\treturn columnEntries(table)\n\t\t.filter(([, col]) => col.searchable)\n\t\t.map(([name]) => name);\n}\n\nfunction filterNames(table: SubgraphDetail[\"tables\"][string]): string[] {\n\tconst result: string[] = [];\n\tfor (const [name, col] of columnEntries(table)) {\n\t\tresult.push(name);\n\t\tresult.push(`${name}.neq`);\n\t\tif (isComparable(col.type)) {\n\t\t\tfor (const op of COMPARISON_OPS.filter((op) => op !== \"neq\")) {\n\t\t\t\tresult.push(`${name}.${op}`);\n\t\t\t}\n\t\t}\n\t\tif (isTextLike(col.type)) result.push(`${name}.like`);\n\t}\n\treturn result;\n}\n\nfunction queryParameters(table: SubgraphDetail[\"tables\"][string]): string[] {\n\tconst params = [...BASE_QUERY_PARAMS];\n\tif (searchableColumns(table).length > 0) params.push(\"_search\");\n\treturn params;\n}\n\nfunction rowExample(table: SubgraphDetail[\"tables\"][string]) {\n\tconst row: Record<string, unknown> = {};\n\tfor (const [name, col] of columnEntries(table)) {\n\t\trow[name] = exampleForColumn(col.type);\n\t}\n\treturn row;\n}\n\nfunction openApiParameter(\n\tname: string,\n\tdescription: string,\n\tschema: Record<string, unknown> = { type: \"string\" },\n) {\n\treturn {\n\t\tname,\n\t\tin: \"query\",\n\t\trequired: false,\n\t\tdescription,\n\t\tschema,\n\t};\n}\n\nfunction tableParameters(table: SubgraphDetail[\"tables\"][string]) {\n\tconst parameters = [\n\t\topenApiParameter(\"_limit\", \"Maximum rows to return.\", {\n\t\t\ttype: \"integer\",\n\t\t\tdefault: 50,\n\t\t\tminimum: 1,\n\t\t\tmaximum: 1000,\n\t\t}),\n\t\topenApiParameter(\n\t\t\t\"cursor\",\n\t\t\t\"Resume token from next_cursor (keyset pagination on _id).\",\n\t\t\t{ type: \"string\" },\n\t\t),\n\t\topenApiParameter(\"_order\", \"Sort direction (_id keyset).\", {\n\t\t\ttype: \"string\",\n\t\t\tenum: [\"asc\", \"desc\"],\n\t\t\tdefault: \"asc\",\n\t\t}),\n\t\topenApiParameter(\"_fields\", \"Comma-separated columns to include.\", {\n\t\t\ttype: \"string\",\n\t\t}),\n\t];\n\tif (searchableColumns(table).length > 0) {\n\t\tparameters.push(\n\t\t\topenApiParameter(\"_search\", \"Search across searchable columns.\", {\n\t\t\t\ttype: \"string\",\n\t\t\t}),\n\t\t);\n\t}\n\tfor (const [name, col] of columnEntries(table)) {\n\t\tparameters.push(\n\t\t\topenApiParameter(name, `Filter ${name} by equality.`, {\n\t\t\t\ttype: \"string\",\n\t\t\t}),\n\t\t);\n\t\tparameters.push(\n\t\t\topenApiParameter(`${name}.neq`, `Filter ${name} by inequality.`, {\n\t\t\t\ttype: \"string\",\n\t\t\t}),\n\t\t);\n\t\tif (isComparable(col.type)) {\n\t\t\tfor (const op of [\"gt\", \"gte\", \"lt\", \"lte\"]) {\n\t\t\t\tparameters.push(\n\t\t\t\t\topenApiParameter(`${name}.${op}`, `Filter ${name} with ${op}.`, {\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (isTextLike(col.type)) {\n\t\t\tparameters.push(\n\t\t\t\topenApiParameter(\n\t\t\t\t\t`${name}.like`,\n\t\t\t\t\t`Case-insensitive contains filter for ${name}.`,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\treturn parameters;\n}\n\nexport function generateSubgraphAgentSchema(\n\tdetail: SubgraphDetail,\n\toptions: SubgraphSpecOptions = {},\n): SubgraphAgentSchema {\n\tconst serverUrl = normalizeServerUrl(options.serverUrl);\n\tconst tables: SubgraphAgentSchema[\"tables\"] = {};\n\tfor (const [tableName, table] of Object.entries(detail.tables)) {\n\t\tconst path = tablePath(detail.name, tableName);\n\t\ttables[tableName] = {\n\t\t\tendpoint: `${serverUrl}${path}`,\n\t\t\tcountEndpoint: `${serverUrl}${countPath(detail.name, tableName)}`,\n\t\t\taggregateEndpoint: `${serverUrl}${path}/aggregate`,\n\t\t\tstreamEndpoint: `${serverUrl}${path}/stream`,\n\t\t\trowCount: table.rowCount,\n\t\t\tcolumns: table.columns,\n\t\t\t...(table.indexes ? { indexes: table.indexes } : {}),\n\t\t\t...(table.uniqueKeys ? { uniqueKeys: table.uniqueKeys } : {}),\n\t\t\tquery: {\n\t\t\t\tparameters: queryParameters(table),\n\t\t\t\t// /v1 is _id keyset only — no _sort.\n\t\t\t\tsortable: [],\n\t\t\t\tselectable: selectableColumns(table),\n\t\t\t\tsearchable: searchableColumns(table),\n\t\t\t\tfilters: filterNames(table),\n\t\t\t},\n\t\t\texamples: {\n\t\t\t\tlist: rowExample(table),\n\t\t\t\tcount: { count: table.rowCount },\n\t\t\t\tcurl: `curl '${serverUrl}${path}?_limit=10&_order=desc'`,\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\tname: detail.name,\n\t\tversion: detail.version,\n\t\t...(detail.description ? { description: detail.description } : {}),\n\t\t...(detail.schemaHash ? { schemaHash: detail.schemaHash } : {}),\n\t\t...(detail.pin ? { pin: detail.pin } : {}),\n\t\tgeneratedAt: generatedAt(options),\n\t\tserverUrl,\n\t\t...(detail.sources ? { sources: detail.sources } : {}),\n\t\ttables,\n\t};\n}\n\nexport function generateSubgraphOpenApi(\n\tdetail: SubgraphDetail,\n\toptions: SubgraphSpecOptions = {},\n): Record<string, unknown> {\n\tconst serverUrl = normalizeServerUrl(options.serverUrl);\n\tconst paths: Record<string, unknown> = {};\n\tconst schemas: Record<string, unknown> = {};\n\n\tfor (const [tableName, table] of Object.entries(detail.tables)) {\n\t\tconst schemaName = `${tableName}Row`;\n\t\tconst properties: Record<string, unknown> = {};\n\t\tconst required: string[] = [];\n\t\tfor (const [columnName, column] of columnEntries(table)) {\n\t\t\tproperties[columnName] = openApiSchemaForColumn(column);\n\t\t\tif (!column.nullable) required.push(columnName);\n\t\t}\n\t\tschemas[schemaName] = {\n\t\t\ttype: \"object\",\n\t\t\tproperties,\n\t\t\trequired,\n\t\t\texample: rowExample(table),\n\t\t};\n\n\t\tconst responseSchema = {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\trows: {\n\t\t\t\t\ttype: \"array\",\n\t\t\t\t\titems: { $ref: `#/components/schemas/${schemaName}` },\n\t\t\t\t},\n\t\t\t\tnext_cursor: { type: [\"string\", \"null\"] },\n\t\t\t\ttip: {\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tblock_height: { type: \"integer\" },\n\t\t\t\t\t\tsubgraph_height: { type: \"integer\" },\n\t\t\t\t\t\tblocks_behind: { type: \"integer\" },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tpaths[tablePath(detail.name, tableName)] = {\n\t\t\tget: {\n\t\t\t\tsummary: `Query ${detail.name}.${tableName}`,\n\t\t\t\toperationId: `query_${detail.name.replace(/-/g, \"_\")}_${tableName}`,\n\t\t\t\tparameters: tableParameters(table),\n\t\t\t\tresponses: {\n\t\t\t\t\t\"200\": {\n\t\t\t\t\t\tdescription: \"Rows returned from the subgraph table.\",\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\t\t\tschema: responseSchema,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tpaths[countPath(detail.name, tableName)] = {\n\t\t\tget: {\n\t\t\t\tsummary: `Count ${detail.name}.${tableName}`,\n\t\t\t\toperationId: `count_${detail.name.replace(/-/g, \"_\")}_${tableName}`,\n\t\t\t\tparameters: tableParameters(table),\n\t\t\t\tresponses: {\n\t\t\t\t\t\"200\": {\n\t\t\t\t\t\tdescription: \"Row count for the filtered table query.\",\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\t\t\t\tproperties: { count: { type: \"integer\" } },\n\t\t\t\t\t\t\t\t\trequired: [\"count\"],\n\t\t\t\t\t\t\t\t\texample: { count: table.rowCount },\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\topenapi: \"3.1.0\",\n\t\tinfo: {\n\t\t\ttitle: `${detail.name} Subgraph API`,\n\t\t\tversion: detail.version,\n\t\t\t...(detail.description ? { description: detail.description } : {}),\n\t\t},\n\t\tservers: [{ url: serverUrl }],\n\t\tpaths,\n\t\tcomponents: { schemas },\n\t\t\"x-secondlayer-subgraph\": detail.name,\n\t\t\"x-secondlayer-version\": detail.version,\n\t\t\"x-secondlayer-schema-hash\": detail.schemaHash,\n\t\t...(detail.pin ? { \"x-secondlayer-pin\": detail.pin } : {}),\n\t\t\"x-secondlayer-generated-at\": generatedAt(options),\n\t\t\"x-secondlayer-sources\": detail.sources ?? {},\n\t\t\"x-secondlayer-tables\": Object.keys(detail.tables),\n\t};\n}\n\nexport function generateSubgraphMarkdown(\n\tdetail: SubgraphDetail,\n\toptions: SubgraphSpecOptions = {},\n): string {\n\tconst agent = generateSubgraphAgentSchema(detail, options);\n\tconst lines = [\n\t\t`# ${detail.name} Subgraph API`,\n\t\t\"\",\n\t\t`Version: ${detail.version}`,\n\t\tdetail.schemaHash ? `Schema hash: ${detail.schemaHash}` : undefined,\n\t\tdetail.pin ? `Pin: ${detail.pin}` : undefined,\n\t\t`Server: ${agent.serverUrl}`,\n\t\t\"Responses use the `{ rows, next_cursor, tip }` envelope; paginate with `?cursor=<next_cursor>` and `_order=asc|desc` (`_offset` is rejected).\",\n\t\t\"\",\n\t\tdetail.description,\n\t].filter((line): line is string => line !== undefined && line !== \"\");\n\n\tfor (const [tableName, table] of Object.entries(agent.tables)) {\n\t\tlines.push(\n\t\t\t\"\",\n\t\t\t`## ${tableName}`,\n\t\t\t\"\",\n\t\t\t`GET ${table.endpoint}`,\n\t\t\t`GET ${table.countEndpoint}`,\n\t\t\t...(table.aggregateEndpoint ? [`GET ${table.aggregateEndpoint}`] : []),\n\t\t\t...(table.streamEndpoint ? [`GET ${table.streamEndpoint} (SSE)`] : []),\n\t\t\t\"\",\n\t\t\t`Rows: ${table.rowCount}`,\n\t\t\t\"\",\n\t\t\t\"### Columns\",\n\t\t\t\"\",\n\t\t\t\"| Column | Type | Attributes |\",\n\t\t\t\"| --- | --- | --- |\",\n\t\t);\n\t\tfor (const [columnName, col] of Object.entries(table.columns)) {\n\t\t\tconst attrs = [\n\t\t\t\tSYSTEM_COLUMNS.includes(columnName) ? \"system\" : undefined,\n\t\t\t\tcol.nullable ? \"nullable\" : undefined,\n\t\t\t\tcol.indexed ? \"indexed\" : undefined,\n\t\t\t\tcol.searchable ? \"searchable\" : undefined,\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\", \");\n\t\t\tlines.push(`| \\`${columnName}\\` | \\`${col.type}\\` | ${attrs || \"-\"} |`);\n\t\t}\n\t\tlines.push(\n\t\t\t\"\",\n\t\t\t\"### Query\",\n\t\t\t\"\",\n\t\t\t`Parameters: ${table.query.parameters.map((p) => `\\`${p}\\``).join(\", \")}`,\n\t\t\t`Filters: ${table.query.filters.map((p) => `\\`${p}\\``).join(\", \")}`,\n\t\t\t\"\",\n\t\t\t\"### Example\",\n\t\t\t\"\",\n\t\t\t\"```bash\",\n\t\t\ttable.examples.curl,\n\t\t\t\"```\",\n\t\t);\n\t}\n\treturn `${lines.join(\"\\n\")}\\n`;\n}\n\nexport function generateSubgraphSpec(\n\tdetail: SubgraphDetail,\n\tformat: SubgraphSpecFormat,\n\toptions: SubgraphSpecOptions = {},\n): Record<string, unknown> | SubgraphAgentSchema | string {\n\tif (format === \"openapi\") return generateSubgraphOpenApi(detail, options);\n\tif (format === \"agent\") return generateSubgraphAgentSchema(detail, options);\n\treturn generateSubgraphMarkdown(detail, options);\n}\n"
|
|
5
|
+
"import type { SubgraphDetail } from \"../schemas/subgraphs.ts\";\n\nexport type SubgraphSpecFormat = \"openapi\" | \"agent\" | \"markdown\";\n\n/** Options for generating a subgraph's agent schema. */\nexport interface SubgraphSpecOptions {\n\tserverUrl?: string;\n\tgeneratedAt?: string;\n}\n\n/** A subgraph's tables and columns in a form agents can read. */\nexport interface SubgraphAgentSchema {\n\tname: string;\n\tversion: string;\n\tdescription?: string;\n\tschemaHash?: string;\n\tpin?: string;\n\tgeneratedAt: string;\n\tserverUrl: string;\n\tsources?: Record<string, unknown>;\n\ttables: Record<\n\t\tstring,\n\t\t{\n\t\t\tendpoint: string;\n\t\t\tcountEndpoint: string;\n\t\t\taggregateEndpoint?: string;\n\t\t\tstreamEndpoint?: string;\n\t\t\trowCount: number;\n\t\t\tcolumns: SubgraphDetail[\"tables\"][string][\"columns\"];\n\t\t\tindexes?: readonly (readonly string[])[];\n\t\t\tuniqueKeys?: readonly (readonly string[])[];\n\t\t\tquery: {\n\t\t\t\tparameters: string[];\n\t\t\t\tsortable: string[];\n\t\t\t\tselectable: string[];\n\t\t\t\tsearchable: string[];\n\t\t\t\tfilters: string[];\n\t\t\t};\n\t\t\texamples: {\n\t\t\t\tlist: Record<string, unknown>;\n\t\t\t\tcount: { count: number };\n\t\t\t\tcurl: string;\n\t\t\t};\n\t\t}\n\t>;\n}\n\ntype ColumnMeta = SubgraphDetail[\"tables\"][string][\"columns\"][string];\n\nconst SYSTEM_COLUMNS = [\"_id\", \"_block_height\", \"_tx_id\", \"_created_at\"];\n// /v1 rejects _offset: keyset pagination via cursor + _order.\nconst BASE_QUERY_PARAMS = [\"_limit\", \"cursor\", \"_order\", \"_fields\"];\nconst COMPARISON_OPS = [\"neq\", \"gt\", \"gte\", \"lt\", \"lte\"];\n\nfunction generatedAt(options: SubgraphSpecOptions): string {\n\treturn options.generatedAt ?? new Date().toISOString();\n}\n\n/**\n * Callers that know their instance pass `serverUrl` (the API derives it from the\n * request; the CLI from its resolved API URL). The fallback is the documented\n * default bind, not a hosted host — a spec that advertises someone else's API\n * produces a client that silently talks to the wrong place.\n */\nfunction normalizeServerUrl(serverUrl?: string): string {\n\treturn (serverUrl ?? \"http://127.0.0.1:3800\").replace(/\\/+$/, \"\");\n}\n\nfunction tablePath(subgraphName: string, tableName: string): string {\n\treturn `/v1/subgraphs/${subgraphName}/${tableName}`;\n}\n\nfunction countPath(subgraphName: string, tableName: string): string {\n\treturn `${tablePath(subgraphName, tableName)}/count`;\n}\n\nfunction isTextLike(type: string): boolean {\n\treturn type === \"text\" || type === \"principal\" || type === \"timestamp\";\n}\n\nfunction isComparable(type: string): boolean {\n\treturn (\n\t\ttype === \"uint\" ||\n\t\ttype === \"int\" ||\n\t\ttype === \"bigint\" ||\n\t\ttype === \"serial\" ||\n\t\ttype === \"timestamp\"\n\t);\n}\n\nfunction exampleForColumn(type: string): unknown {\n\tswitch (type) {\n\t\tcase \"uint\":\n\t\tcase \"int\":\n\t\tcase \"bigint\":\n\t\t\treturn \"1000\";\n\t\tcase \"serial\":\n\t\t\treturn 1;\n\t\tcase \"principal\":\n\t\t\treturn \"SP000000000000000000002Q6VF78\";\n\t\tcase \"timestamp\":\n\t\t\treturn \"2026-01-01T00:00:00.000Z\";\n\t\tcase \"boolean\":\n\t\t\treturn true;\n\t\tcase \"jsonb\":\n\t\t\treturn { example: true };\n\t\tdefault:\n\t\t\treturn \"example\";\n\t}\n}\n\nfunction openApiSchemaForColumn(col: ColumnMeta): Record<string, unknown> {\n\tlet schema: Record<string, unknown>;\n\tswitch (col.type) {\n\t\tcase \"uint\":\n\t\tcase \"int\":\n\t\tcase \"bigint\":\n\t\t\tschema = { type: \"string\", pattern: \"^-?\\\\d+(\\\\.\\\\d+)?$\" };\n\t\t\tbreak;\n\t\tcase \"serial\":\n\t\t\tschema = { type: \"integer\" };\n\t\t\tbreak;\n\t\tcase \"principal\":\n\t\tcase \"text\":\n\t\t\tschema = { type: \"string\" };\n\t\t\tbreak;\n\t\tcase \"timestamp\":\n\t\t\tschema = { type: \"string\", format: \"date-time\" };\n\t\t\tbreak;\n\t\tcase \"boolean\":\n\t\t\tschema = { type: \"boolean\" };\n\t\t\tbreak;\n\t\tcase \"jsonb\":\n\t\t\tschema = { type: \"object\", additionalProperties: true };\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tschema = {};\n\t\t\tbreak;\n\t}\n\tif (col.nullable) {\n\t\tconst type = schema.type;\n\t\tif (typeof type === \"string\") schema.type = [type, \"null\"];\n\t}\n\treturn schema;\n}\n\nfunction columnEntries(table: SubgraphDetail[\"tables\"][string]) {\n\treturn Object.entries(table.columns);\n}\n\nfunction selectableColumns(table: SubgraphDetail[\"tables\"][string]): string[] {\n\treturn columnEntries(table).map(([name]) => name);\n}\n\nfunction searchableColumns(table: SubgraphDetail[\"tables\"][string]): string[] {\n\treturn columnEntries(table)\n\t\t.filter(([, col]) => col.searchable)\n\t\t.map(([name]) => name);\n}\n\nfunction filterNames(table: SubgraphDetail[\"tables\"][string]): string[] {\n\tconst result: string[] = [];\n\tfor (const [name, col] of columnEntries(table)) {\n\t\tresult.push(name);\n\t\tresult.push(`${name}.neq`);\n\t\tif (isComparable(col.type)) {\n\t\t\tfor (const op of COMPARISON_OPS.filter((op) => op !== \"neq\")) {\n\t\t\t\tresult.push(`${name}.${op}`);\n\t\t\t}\n\t\t}\n\t\tif (isTextLike(col.type)) result.push(`${name}.like`);\n\t}\n\treturn result;\n}\n\nfunction queryParameters(table: SubgraphDetail[\"tables\"][string]): string[] {\n\tconst params = [...BASE_QUERY_PARAMS];\n\tif (searchableColumns(table).length > 0) params.push(\"_search\");\n\treturn params;\n}\n\nfunction rowExample(table: SubgraphDetail[\"tables\"][string]) {\n\tconst row: Record<string, unknown> = {};\n\tfor (const [name, col] of columnEntries(table)) {\n\t\trow[name] = exampleForColumn(col.type);\n\t}\n\treturn row;\n}\n\nfunction openApiParameter(\n\tname: string,\n\tdescription: string,\n\tschema: Record<string, unknown> = { type: \"string\" },\n) {\n\treturn {\n\t\tname,\n\t\tin: \"query\",\n\t\trequired: false,\n\t\tdescription,\n\t\tschema,\n\t};\n}\n\nfunction tableParameters(table: SubgraphDetail[\"tables\"][string]) {\n\tconst parameters = [\n\t\topenApiParameter(\"_limit\", \"Maximum rows to return.\", {\n\t\t\ttype: \"integer\",\n\t\t\tdefault: 50,\n\t\t\tminimum: 1,\n\t\t\tmaximum: 1000,\n\t\t}),\n\t\topenApiParameter(\n\t\t\t\"cursor\",\n\t\t\t\"Resume token from next_cursor (keyset pagination on _id).\",\n\t\t\t{ type: \"string\" },\n\t\t),\n\t\topenApiParameter(\"_order\", \"Sort direction (_id keyset).\", {\n\t\t\ttype: \"string\",\n\t\t\tenum: [\"asc\", \"desc\"],\n\t\t\tdefault: \"asc\",\n\t\t}),\n\t\topenApiParameter(\"_fields\", \"Comma-separated columns to include.\", {\n\t\t\ttype: \"string\",\n\t\t}),\n\t];\n\tif (searchableColumns(table).length > 0) {\n\t\tparameters.push(\n\t\t\topenApiParameter(\"_search\", \"Search across searchable columns.\", {\n\t\t\t\ttype: \"string\",\n\t\t\t}),\n\t\t);\n\t}\n\tfor (const [name, col] of columnEntries(table)) {\n\t\tparameters.push(\n\t\t\topenApiParameter(name, `Filter ${name} by equality.`, {\n\t\t\t\ttype: \"string\",\n\t\t\t}),\n\t\t);\n\t\tparameters.push(\n\t\t\topenApiParameter(`${name}.neq`, `Filter ${name} by inequality.`, {\n\t\t\t\ttype: \"string\",\n\t\t\t}),\n\t\t);\n\t\tif (isComparable(col.type)) {\n\t\t\tfor (const op of [\"gt\", \"gte\", \"lt\", \"lte\"]) {\n\t\t\t\tparameters.push(\n\t\t\t\t\topenApiParameter(`${name}.${op}`, `Filter ${name} with ${op}.`, {\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (isTextLike(col.type)) {\n\t\t\tparameters.push(\n\t\t\t\topenApiParameter(\n\t\t\t\t\t`${name}.like`,\n\t\t\t\t\t`Case-insensitive contains filter for ${name}.`,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\treturn parameters;\n}\n\nexport function generateSubgraphAgentSchema(\n\tdetail: SubgraphDetail,\n\toptions: SubgraphSpecOptions = {},\n): SubgraphAgentSchema {\n\tconst serverUrl = normalizeServerUrl(options.serverUrl);\n\tconst tables: SubgraphAgentSchema[\"tables\"] = {};\n\tfor (const [tableName, table] of Object.entries(detail.tables)) {\n\t\tconst path = tablePath(detail.name, tableName);\n\t\ttables[tableName] = {\n\t\t\tendpoint: `${serverUrl}${path}`,\n\t\t\tcountEndpoint: `${serverUrl}${countPath(detail.name, tableName)}`,\n\t\t\taggregateEndpoint: `${serverUrl}${path}/aggregate`,\n\t\t\tstreamEndpoint: `${serverUrl}${path}/stream`,\n\t\t\trowCount: table.rowCount,\n\t\t\tcolumns: table.columns,\n\t\t\t...(table.indexes ? { indexes: table.indexes } : {}),\n\t\t\t...(table.uniqueKeys ? { uniqueKeys: table.uniqueKeys } : {}),\n\t\t\tquery: {\n\t\t\t\tparameters: queryParameters(table),\n\t\t\t\t// /v1 is _id keyset only — no _sort.\n\t\t\t\tsortable: [],\n\t\t\t\tselectable: selectableColumns(table),\n\t\t\t\tsearchable: searchableColumns(table),\n\t\t\t\tfilters: filterNames(table),\n\t\t\t},\n\t\t\texamples: {\n\t\t\t\tlist: rowExample(table),\n\t\t\t\tcount: { count: table.rowCount },\n\t\t\t\tcurl: `curl '${serverUrl}${path}?_limit=10&_order=desc'`,\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\tname: detail.name,\n\t\tversion: detail.version,\n\t\t...(detail.description ? { description: detail.description } : {}),\n\t\t...(detail.schemaHash ? { schemaHash: detail.schemaHash } : {}),\n\t\t...(detail.pin ? { pin: detail.pin } : {}),\n\t\tgeneratedAt: generatedAt(options),\n\t\tserverUrl,\n\t\t...(detail.sources ? { sources: detail.sources } : {}),\n\t\ttables,\n\t};\n}\n\nexport function generateSubgraphOpenApi(\n\tdetail: SubgraphDetail,\n\toptions: SubgraphSpecOptions = {},\n): Record<string, unknown> {\n\tconst serverUrl = normalizeServerUrl(options.serverUrl);\n\tconst paths: Record<string, unknown> = {};\n\tconst schemas: Record<string, unknown> = {};\n\n\tfor (const [tableName, table] of Object.entries(detail.tables)) {\n\t\tconst schemaName = `${tableName}Row`;\n\t\tconst properties: Record<string, unknown> = {};\n\t\tconst required: string[] = [];\n\t\tfor (const [columnName, column] of columnEntries(table)) {\n\t\t\tproperties[columnName] = openApiSchemaForColumn(column);\n\t\t\tif (!column.nullable) required.push(columnName);\n\t\t}\n\t\tschemas[schemaName] = {\n\t\t\ttype: \"object\",\n\t\t\tproperties,\n\t\t\trequired,\n\t\t\texample: rowExample(table),\n\t\t};\n\n\t\tconst responseSchema = {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\trows: {\n\t\t\t\t\ttype: \"array\",\n\t\t\t\t\titems: { $ref: `#/components/schemas/${schemaName}` },\n\t\t\t\t},\n\t\t\t\tnext_cursor: { type: [\"string\", \"null\"] },\n\t\t\t\ttip: {\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tblock_height: { type: \"integer\" },\n\t\t\t\t\t\tsubgraph_height: { type: \"integer\" },\n\t\t\t\t\t\tblocks_behind: { type: \"integer\" },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tpaths[tablePath(detail.name, tableName)] = {\n\t\t\tget: {\n\t\t\t\tsummary: `Query ${detail.name}.${tableName}`,\n\t\t\t\toperationId: `query_${detail.name.replace(/-/g, \"_\")}_${tableName}`,\n\t\t\t\tparameters: tableParameters(table),\n\t\t\t\tresponses: {\n\t\t\t\t\t\"200\": {\n\t\t\t\t\t\tdescription: \"Rows returned from the subgraph table.\",\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\t\t\tschema: responseSchema,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tpaths[countPath(detail.name, tableName)] = {\n\t\t\tget: {\n\t\t\t\tsummary: `Count ${detail.name}.${tableName}`,\n\t\t\t\toperationId: `count_${detail.name.replace(/-/g, \"_\")}_${tableName}`,\n\t\t\t\tparameters: tableParameters(table),\n\t\t\t\tresponses: {\n\t\t\t\t\t\"200\": {\n\t\t\t\t\t\tdescription: \"Row count for the filtered table query.\",\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\t\t\t\tproperties: { count: { type: \"integer\" } },\n\t\t\t\t\t\t\t\t\trequired: [\"count\"],\n\t\t\t\t\t\t\t\t\texample: { count: table.rowCount },\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\topenapi: \"3.1.0\",\n\t\tinfo: {\n\t\t\ttitle: `${detail.name} Subgraph API`,\n\t\t\tversion: detail.version,\n\t\t\t...(detail.description ? { description: detail.description } : {}),\n\t\t},\n\t\tservers: [{ url: serverUrl }],\n\t\tpaths,\n\t\tcomponents: { schemas },\n\t\t\"x-secondlayer-subgraph\": detail.name,\n\t\t\"x-secondlayer-version\": detail.version,\n\t\t\"x-secondlayer-schema-hash\": detail.schemaHash,\n\t\t...(detail.pin ? { \"x-secondlayer-pin\": detail.pin } : {}),\n\t\t\"x-secondlayer-generated-at\": generatedAt(options),\n\t\t\"x-secondlayer-sources\": detail.sources ?? {},\n\t\t\"x-secondlayer-tables\": Object.keys(detail.tables),\n\t};\n}\n\nexport function generateSubgraphMarkdown(\n\tdetail: SubgraphDetail,\n\toptions: SubgraphSpecOptions = {},\n): string {\n\tconst agent = generateSubgraphAgentSchema(detail, options);\n\tconst lines = [\n\t\t`# ${detail.name} Subgraph API`,\n\t\t\"\",\n\t\t`Version: ${detail.version}`,\n\t\tdetail.schemaHash ? `Schema hash: ${detail.schemaHash}` : undefined,\n\t\tdetail.pin ? `Pin: ${detail.pin}` : undefined,\n\t\t`Server: ${agent.serverUrl}`,\n\t\t\"Responses use the `{ rows, next_cursor, tip }` envelope; paginate with `?cursor=<next_cursor>` and `_order=asc|desc` (`_offset` is rejected).\",\n\t\t\"\",\n\t\tdetail.description,\n\t].filter((line): line is string => line !== undefined && line !== \"\");\n\n\tfor (const [tableName, table] of Object.entries(agent.tables)) {\n\t\tlines.push(\n\t\t\t\"\",\n\t\t\t`## ${tableName}`,\n\t\t\t\"\",\n\t\t\t`GET ${table.endpoint}`,\n\t\t\t`GET ${table.countEndpoint}`,\n\t\t\t...(table.aggregateEndpoint ? [`GET ${table.aggregateEndpoint}`] : []),\n\t\t\t...(table.streamEndpoint ? [`GET ${table.streamEndpoint} (SSE)`] : []),\n\t\t\t\"\",\n\t\t\t`Rows: ${table.rowCount}`,\n\t\t\t\"\",\n\t\t\t\"### Columns\",\n\t\t\t\"\",\n\t\t\t\"| Column | Type | Attributes |\",\n\t\t\t\"| --- | --- | --- |\",\n\t\t);\n\t\tfor (const [columnName, col] of Object.entries(table.columns)) {\n\t\t\tconst attrs = [\n\t\t\t\tSYSTEM_COLUMNS.includes(columnName) ? \"system\" : undefined,\n\t\t\t\tcol.nullable ? \"nullable\" : undefined,\n\t\t\t\tcol.indexed ? \"indexed\" : undefined,\n\t\t\t\tcol.searchable ? \"searchable\" : undefined,\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\", \");\n\t\t\tlines.push(`| \\`${columnName}\\` | \\`${col.type}\\` | ${attrs || \"-\"} |`);\n\t\t}\n\t\tlines.push(\n\t\t\t\"\",\n\t\t\t\"### Query\",\n\t\t\t\"\",\n\t\t\t`Parameters: ${table.query.parameters.map((p) => `\\`${p}\\``).join(\", \")}`,\n\t\t\t`Filters: ${table.query.filters.map((p) => `\\`${p}\\``).join(\", \")}`,\n\t\t\t\"\",\n\t\t\t\"### Example\",\n\t\t\t\"\",\n\t\t\t\"```bash\",\n\t\t\ttable.examples.curl,\n\t\t\t\"```\",\n\t\t);\n\t}\n\treturn `${lines.join(\"\\n\")}\\n`;\n}\n\nexport function generateSubgraphSpec(\n\tdetail: SubgraphDetail,\n\tformat: SubgraphSpecFormat,\n\toptions: SubgraphSpecOptions = {},\n): Record<string, unknown> | SubgraphAgentSchema | string {\n\tif (format === \"openapi\") return generateSubgraphOpenApi(detail, options);\n\tif (format === \"agent\") return generateSubgraphAgentSchema(detail, options);\n\treturn generateSubgraphMarkdown(detail, options);\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";
|
|
7
|
+
"mappings": ";AAiDA,IAAM,iBAAiB,CAAC,OAAO,iBAAiB,UAAU,aAAa;AAEvE,IAAM,oBAAoB,CAAC,UAAU,UAAU,UAAU,SAAS;AAClE,IAAM,iBAAiB,CAAC,OAAO,MAAM,OAAO,MAAM,KAAK;AAEvD,SAAS,WAAW,CAAC,SAAsC;AAAA,EAC1D,OAAO,QAAQ,eAAe,IAAI,KAAK,EAAE,YAAY;AAAA;AAStD,SAAS,kBAAkB,CAAC,WAA4B;AAAA,EACvD,QAAQ,aAAa,yBAAyB,QAAQ,QAAQ,EAAE;AAAA;AAGjE,SAAS,SAAS,CAAC,cAAsB,WAA2B;AAAA,EACnE,OAAO,iBAAiB,gBAAgB;AAAA;AAGzC,SAAS,SAAS,CAAC,cAAsB,WAA2B;AAAA,EACnE,OAAO,GAAG,UAAU,cAAc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ACA,eAAe,MAAM,MAAM,WAAW,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,KAAK,IAAI,KACtE,YAAY,MAAM,MAAM,QAAQ,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,KAAK,IAAI,KAChE,IACA,eACA,IACA,WACA,MAAM,SAAS,MACf,KACD;AAAA,EACD;AAAA,EACA,OAAO,GAAG,MAAM,KAAK;AAAA,CAAI;AAAA;AAAA;AAGnB,SAAS,oBAAoB,CACnC,QACA,QACA,UAA+B,CAAC,GACyB;AAAA,EACzD,IAAI,WAAW;AAAA,IAAW,OAAO,wBAAwB,QAAQ,OAAO;AAAA,EACxE,IAAI,WAAW;AAAA,IAAS,OAAO,4BAA4B,QAAQ,OAAO;AAAA,EAC1E,OAAO,yBAAyB,QAAQ,OAAO;AAAA;",
|
|
8
8
|
"debugId": "6661229CE3F259A564756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/shared",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.2",
|
|
4
4
|
"description": "Internal building blocks shared across Secondlayer packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -249,7 +249,7 @@
|
|
|
249
249
|
"prepublishOnly": "bun run build"
|
|
250
250
|
},
|
|
251
251
|
"dependencies": {
|
|
252
|
-
"@secondlayer/stacks": "^6.2.
|
|
252
|
+
"@secondlayer/stacks": "^6.2.2",
|
|
253
253
|
"kysely": "0.28.17",
|
|
254
254
|
"kysely-postgres-js": "3.0.0",
|
|
255
255
|
"postgres": "^3.4.6",
|