@secondlayer/shared 11.4.3 → 11.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/src/archive/derived-stage-report.d.ts +2 -2
- package/dist/src/archive/derived-stage-report.js.map +1 -1
- package/dist/src/archive/instance-diagnosis.js +2 -2
- package/dist/src/archive/instance-diagnosis.js.map +2 -2
- package/dist/src/archive/range-digest.d.ts +25 -25
- package/dist/src/archive/semantic-digest-builder.d.ts +25 -25
- package/dist/src/coverage/index.d.ts +25 -25
- package/dist/src/coverage/index.js.map +1 -1
- package/dist/src/crypto/secondlayer-webhook.d.ts +2 -2
- package/dist/src/crypto/secondlayer-webhook.js.map +1 -1
- package/dist/src/crypto/secrets.js.map +1 -1
- package/dist/src/db/index.d.ts +37 -37
- package/dist/src/db/index.js +4 -4
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +25 -25
- package/dist/src/db/queries/chain-reorgs.js +4 -4
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +25 -25
- package/dist/src/db/queries/instance.d.ts +25 -25
- package/dist/src/db/queries/integrity.d.ts +25 -25
- package/dist/src/db/queries/subgraph-gaps.d.ts +25 -25
- package/dist/src/db/queries/subgraph-operations.d.ts +25 -25
- package/dist/src/db/queries/subgraphs.d.ts +25 -25
- package/dist/src/db/queries/subgraphs.js +4 -4
- package/dist/src/db/queries/subgraphs.js.map +3 -3
- package/dist/src/db/queries/sync-scope.d.ts +25 -25
- package/dist/src/db/queries/{subscriptions.d.ts → webhooks.d.ts} +58 -58
- package/dist/src/db/queries/{subscriptions.js → webhooks.js} +38 -38
- package/dist/src/db/queries/webhooks.js.map +13 -0
- package/dist/src/db/schema.d.ts +34 -34
- package/dist/src/index.d.ts +109 -107
- package/dist/src/index.js +51 -54
- package/dist/src/index.js.map +6 -6
- package/dist/src/leader.d.ts +4 -4
- package/dist/src/leader.js +3 -3
- package/dist/src/leader.js.map +3 -3
- package/dist/src/node/local-client.d.ts +25 -25
- package/dist/src/queue/listener.d.ts +2 -2
- package/dist/src/queue/listener.js.map +1 -1
- package/dist/src/runtime/index.js +2 -6
- package/dist/src/runtime/index.js.map +4 -4
- package/dist/src/schemas/index.d.ts +61 -61
- package/dist/src/schemas/index.js +48 -51
- package/dist/src/schemas/index.js.map +5 -5
- package/dist/src/schemas/subgraphs.d.ts +2 -2
- package/dist/src/schemas/subgraphs.js.map +1 -1
- package/dist/src/schemas/{subscriptions.d.ts → webhooks.d.ts} +63 -63
- package/dist/src/schemas/{subscriptions.js → webhooks.js} +49 -52
- package/dist/src/schemas/webhooks.js.map +10 -0
- package/migrations/0126_rename_subscriptions_to_webhooks.ts +96 -0
- package/migrations/0127_rename_webhook_catalog_names.ts +55 -0
- package/package.json +8 -8
- package/dist/src/db/queries/subscriptions.js.map +0 -13
- package/dist/src/schemas/subscriptions.js.map +0 -10
|
@@ -60,8 +60,8 @@ interface SubgraphSummary {
|
|
|
60
60
|
lastErrorAt?: string | null;
|
|
61
61
|
/** Last row mutation timestamp; powers per-card freshness. */
|
|
62
62
|
updatedAt?: string | null;
|
|
63
|
-
/** Number of
|
|
64
|
-
|
|
63
|
+
/** Number of webhooks attached to this subgraph. */
|
|
64
|
+
webhookCount?: number;
|
|
65
65
|
createdAt: string;
|
|
66
66
|
}
|
|
67
67
|
interface SubgraphGapRange {
|
|
@@ -202,17 +202,17 @@ interface SubgraphAggregateResponse {
|
|
|
202
202
|
max?: Record<string, string | null>;
|
|
203
203
|
}
|
|
204
204
|
import { z as z2 } from "zod";
|
|
205
|
-
declare const
|
|
206
|
-
declare const
|
|
207
|
-
declare const
|
|
208
|
-
declare const
|
|
209
|
-
declare const
|
|
210
|
-
declare const
|
|
211
|
-
declare const
|
|
212
|
-
declare const
|
|
213
|
-
declare const
|
|
214
|
-
declare const
|
|
215
|
-
declare const
|
|
205
|
+
declare const WEBHOOK_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
|
|
206
|
+
declare const WEBHOOK_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
|
|
207
|
+
declare const WEBHOOK_STATUSES: readonly ["active", "paused", "error"];
|
|
208
|
+
declare const WEBHOOK_FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in"];
|
|
209
|
+
declare const WebhookStatusSchema: z2.ZodType<WebhookStatus>;
|
|
210
|
+
declare const WebhookFormatSchema: z2.ZodType<WebhookFormat>;
|
|
211
|
+
declare const WebhookRuntimeSchema: z2.ZodType<WebhookRuntime>;
|
|
212
|
+
declare const WebhookFilterPrimitiveSchema: z2.ZodType<WebhookFilterPrimitive>;
|
|
213
|
+
declare const WebhookFilterOperatorSchema: z2.ZodType<WebhookFilterOperator>;
|
|
214
|
+
declare const WebhookFilterClauseSchema: z2.ZodType<WebhookFilterClause>;
|
|
215
|
+
declare const WebhookFilterSchema: z2.ZodType<WebhookFilter>;
|
|
216
216
|
declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "contract_call", "contract_deploy", "print_event", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject", "sbtc_withdrawal_swept_confirmed"];
|
|
217
217
|
/**
|
|
218
218
|
* Per-type accepted filter fields for chain triggers, DERIVED from
|
|
@@ -220,19 +220,19 @@ declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_bu
|
|
|
220
220
|
* the validator. `{ stx_transfer: ["sender","recipient","minAmount","maxAmount"], ... }`.
|
|
221
221
|
*/
|
|
222
222
|
declare const CHAIN_TRIGGER_FIELDS: Record<string, string[]>;
|
|
223
|
-
declare const
|
|
224
|
-
declare const
|
|
225
|
-
declare const
|
|
226
|
-
type
|
|
227
|
-
/** Polymorphic
|
|
228
|
-
type
|
|
229
|
-
type
|
|
230
|
-
type
|
|
231
|
-
type
|
|
232
|
-
type
|
|
233
|
-
eq:
|
|
223
|
+
declare const CreateWebhookRequestSchema: z2.ZodType<ParsedCreateWebhookRequest>;
|
|
224
|
+
declare const UpdateWebhookRequestSchema: z2.ZodType<UpdateWebhookRequest>;
|
|
225
|
+
declare const ReplayWebhookRequestSchema: z2.ZodType<ReplayWebhookRequest>;
|
|
226
|
+
type WebhookStatus = (typeof WEBHOOK_STATUSES)[number];
|
|
227
|
+
/** Polymorphic webhook mode (mirrors db/types `WebhookKind`). */
|
|
228
|
+
type WebhookKind = "subgraph" | "chain";
|
|
229
|
+
type WebhookFormat = (typeof WEBHOOK_FORMATS)[number];
|
|
230
|
+
type WebhookRuntime = (typeof WEBHOOK_RUNTIMES)[number];
|
|
231
|
+
type WebhookFilterPrimitive = string | number | boolean;
|
|
232
|
+
type WebhookFilterOperator = {
|
|
233
|
+
eq: WebhookFilterPrimitive
|
|
234
234
|
} | {
|
|
235
|
-
neq:
|
|
235
|
+
neq: WebhookFilterPrimitive
|
|
236
236
|
} | {
|
|
237
237
|
gt: string | number
|
|
238
238
|
} | {
|
|
@@ -242,10 +242,10 @@ type SubscriptionFilterOperator = {
|
|
|
242
242
|
} | {
|
|
243
243
|
lte: string | number
|
|
244
244
|
} | {
|
|
245
|
-
in:
|
|
245
|
+
in: WebhookFilterPrimitive[]
|
|
246
246
|
};
|
|
247
|
-
type
|
|
248
|
-
type
|
|
247
|
+
type WebhookFilterClause = WebhookFilterPrimitive | WebhookFilterOperator;
|
|
248
|
+
type WebhookFilter = Record<string, WebhookFilterClause>;
|
|
249
249
|
/** Non-negative integer amount over JSON (string for uint128 safety, or number). */
|
|
250
250
|
type ChainTriggerAmount = string | number;
|
|
251
251
|
interface TraitScoped {
|
|
@@ -337,63 +337,63 @@ type ChainTrigger = {
|
|
|
337
337
|
requestId?: number
|
|
338
338
|
sweepTxid?: string
|
|
339
339
|
};
|
|
340
|
-
interface
|
|
340
|
+
interface CreateWebhookRequest {
|
|
341
341
|
name: string;
|
|
342
342
|
/** Subgraph mode. */
|
|
343
343
|
subgraphName?: string;
|
|
344
344
|
tableName?: string;
|
|
345
|
-
filter?:
|
|
345
|
+
filter?: WebhookFilter;
|
|
346
346
|
/** Chain mode. */
|
|
347
347
|
triggers?: ChainTrigger[];
|
|
348
348
|
url: string;
|
|
349
|
-
format?:
|
|
350
|
-
runtime?:
|
|
349
|
+
format?: WebhookFormat;
|
|
350
|
+
runtime?: WebhookRuntime | null;
|
|
351
351
|
authConfig?: Record<string, unknown>;
|
|
352
352
|
maxRetries?: number;
|
|
353
353
|
timeoutMs?: number;
|
|
354
354
|
concurrency?: number;
|
|
355
355
|
}
|
|
356
|
-
interface
|
|
357
|
-
format:
|
|
356
|
+
interface ParsedCreateWebhookRequest extends Omit<CreateWebhookRequest, "format"> {
|
|
357
|
+
format: WebhookFormat;
|
|
358
358
|
}
|
|
359
|
-
interface
|
|
359
|
+
interface UpdateWebhookRequest {
|
|
360
360
|
name?: string;
|
|
361
361
|
url?: string;
|
|
362
|
-
filter?:
|
|
363
|
-
format?:
|
|
364
|
-
runtime?:
|
|
362
|
+
filter?: WebhookFilter;
|
|
363
|
+
format?: WebhookFormat;
|
|
364
|
+
runtime?: WebhookRuntime | null;
|
|
365
365
|
authConfig?: Record<string, unknown>;
|
|
366
366
|
maxRetries?: number;
|
|
367
367
|
timeoutMs?: number;
|
|
368
368
|
concurrency?: number;
|
|
369
369
|
}
|
|
370
|
-
type
|
|
371
|
-
interface
|
|
370
|
+
type ParsedUpdateWebhookRequest = UpdateWebhookRequest;
|
|
371
|
+
interface ReplayWebhookRequest {
|
|
372
372
|
fromBlock: number;
|
|
373
373
|
toBlock: number;
|
|
374
374
|
force?: string;
|
|
375
375
|
}
|
|
376
|
-
type
|
|
377
|
-
interface
|
|
376
|
+
type ParsedReplayWebhookRequest = ReplayWebhookRequest;
|
|
377
|
+
interface WebhookSummary {
|
|
378
378
|
id: string;
|
|
379
379
|
name: string;
|
|
380
|
-
status:
|
|
381
|
-
kind:
|
|
382
|
-
/** Null for chain
|
|
380
|
+
status: WebhookStatus;
|
|
381
|
+
kind: WebhookKind;
|
|
382
|
+
/** Null for chain webhooks. */
|
|
383
383
|
subgraphName: string | null;
|
|
384
|
-
/** Null for chain
|
|
384
|
+
/** Null for chain webhooks. */
|
|
385
385
|
tableName: string | null;
|
|
386
|
-
format:
|
|
387
|
-
runtime:
|
|
386
|
+
format: WebhookFormat;
|
|
387
|
+
runtime: WebhookRuntime | null;
|
|
388
388
|
url: string;
|
|
389
389
|
lastDeliveryAt: string | null;
|
|
390
390
|
lastSuccessAt: string | null;
|
|
391
391
|
createdAt: string;
|
|
392
392
|
updatedAt: string;
|
|
393
393
|
}
|
|
394
|
-
interface
|
|
394
|
+
interface WebhookDetail extends WebhookSummary {
|
|
395
395
|
filter: Record<string, unknown>;
|
|
396
|
-
/** Chain-trigger filters (chain
|
|
396
|
+
/** Chain-trigger filters (chain webhooks only). */
|
|
397
397
|
triggers: ChainTrigger[] | null;
|
|
398
398
|
authConfig: Record<string, unknown>;
|
|
399
399
|
maxRetries: number;
|
|
@@ -403,13 +403,13 @@ interface SubscriptionDetail extends SubscriptionSummary {
|
|
|
403
403
|
circuitOpenedAt: string | null;
|
|
404
404
|
lastError: string | null;
|
|
405
405
|
}
|
|
406
|
-
interface
|
|
407
|
-
|
|
406
|
+
interface CreateWebhookResponse {
|
|
407
|
+
webhook: WebhookDetail;
|
|
408
408
|
/** Plaintext signing secret — surfaced ONCE. Store it server-side. */
|
|
409
409
|
signingSecret: string;
|
|
410
410
|
}
|
|
411
411
|
interface RotateSecretResponse {
|
|
412
|
-
|
|
412
|
+
webhook: WebhookDetail;
|
|
413
413
|
signingSecret: string;
|
|
414
414
|
}
|
|
415
415
|
interface DeliveryRow {
|
|
@@ -436,18 +436,18 @@ interface DeadRow {
|
|
|
436
436
|
failedAt: string | null;
|
|
437
437
|
createdAt: string;
|
|
438
438
|
}
|
|
439
|
-
interface
|
|
439
|
+
interface WebhookSchemaColumn {
|
|
440
440
|
type?: unknown;
|
|
441
441
|
}
|
|
442
|
-
interface
|
|
443
|
-
columns: Record<string,
|
|
442
|
+
interface WebhookSchemaTable {
|
|
443
|
+
columns: Record<string, WebhookSchemaColumn>;
|
|
444
444
|
}
|
|
445
|
-
type
|
|
446
|
-
declare function
|
|
447
|
-
declare function
|
|
445
|
+
type WebhookSchemaTables = Record<string, WebhookSchemaTable>;
|
|
446
|
+
declare function formatWebhookSchemaErrors(error: z2.ZodError): string[];
|
|
447
|
+
declare function validateWebhookFilterForTable(input: {
|
|
448
448
|
subgraphName?: string
|
|
449
449
|
tableName: string
|
|
450
450
|
filter?: unknown
|
|
451
|
-
tables:
|
|
451
|
+
tables: WebhookSchemaTables
|
|
452
452
|
}): string[];
|
|
453
|
-
export {
|
|
453
|
+
export { validateWebhookFilterForTable, formatWebhookSchemaErrors, WebhookSummary, WebhookStatusSchema, WebhookSchemaTables, WebhookSchemaTable, WebhookSchemaColumn, WebhookRuntimeSchema, WebhookFormatSchema, WebhookFilterSchema, WebhookFilterPrimitiveSchema, WebhookFilterPrimitive, WebhookFilterOperatorSchema, WebhookFilterOperator, WebhookFilterClauseSchema, WebhookFilterClause, WebhookFilter, WebhookDetail, WEBHOOK_STATUSES, WEBHOOK_RUNTIMES, WEBHOOK_FORMATS, WEBHOOK_FILTER_OPERATORS, UpdateWebhookRequestSchema, UpdateWebhookRequest, SubgraphSyncInfo, SubgraphSummary, SubgraphQueryParams, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, RotateSecretResponse, ReplayWebhookRequestSchema, ReplayWebhookRequest, ReplayResult, ReindexResponse, ParsedUpdateWebhookRequest, ParsedReplayWebhookRequest, ParsedCreateWebhookRequest, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DeadRow, CreateWebhookResponse, CreateWebhookRequestSchema, CreateWebhookRequest, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS };
|
|
@@ -28,9 +28,9 @@ var DeploySubgraphRequestSchema = z.object({
|
|
|
28
28
|
dryRun: z.boolean().optional()
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
// src/schemas/
|
|
31
|
+
// src/schemas/webhooks.ts
|
|
32
32
|
import { z as z2 } from "zod";
|
|
33
|
-
var
|
|
33
|
+
var WEBHOOK_FORMATS = [
|
|
34
34
|
"standard-webhooks",
|
|
35
35
|
"inngest",
|
|
36
36
|
"trigger",
|
|
@@ -38,14 +38,14 @@ var SUBSCRIPTION_FORMATS = [
|
|
|
38
38
|
"cloudevents",
|
|
39
39
|
"raw"
|
|
40
40
|
];
|
|
41
|
-
var
|
|
41
|
+
var WEBHOOK_RUNTIMES = [
|
|
42
42
|
"inngest",
|
|
43
43
|
"trigger",
|
|
44
44
|
"cloudflare",
|
|
45
45
|
"node"
|
|
46
46
|
];
|
|
47
|
-
var
|
|
48
|
-
var
|
|
47
|
+
var WEBHOOK_STATUSES = ["active", "paused", "error"];
|
|
48
|
+
var WEBHOOK_FILTER_OPERATORS = [
|
|
49
49
|
"eq",
|
|
50
50
|
"neq",
|
|
51
51
|
"gt",
|
|
@@ -57,26 +57,23 @@ var SUBSCRIPTION_FILTER_OPERATORS = [
|
|
|
57
57
|
var webhookUrl = z2.string().trim().min(1).refine((value) => value.startsWith("http://") || value.startsWith("https://"), "must be an http(s) URL");
|
|
58
58
|
var name = z2.string().trim().min(1).max(128);
|
|
59
59
|
var resourceName = z2.string().trim().min(1).max(128);
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
z2.object({ eq:
|
|
66
|
-
z2.object({ neq:
|
|
60
|
+
var WebhookStatusSchema = z2.enum(WEBHOOK_STATUSES);
|
|
61
|
+
var WebhookFormatSchema = z2.enum(WEBHOOK_FORMATS);
|
|
62
|
+
var WebhookRuntimeSchema = z2.enum(WEBHOOK_RUNTIMES);
|
|
63
|
+
var WebhookFilterPrimitiveSchema = z2.union([z2.string(), z2.number().finite(), z2.boolean()]);
|
|
64
|
+
var WebhookFilterOperatorSchema = z2.union([
|
|
65
|
+
z2.object({ eq: WebhookFilterPrimitiveSchema }).strict(),
|
|
66
|
+
z2.object({ neq: WebhookFilterPrimitiveSchema }).strict(),
|
|
67
67
|
z2.object({ gt: z2.union([z2.string(), z2.number().finite()]) }).strict(),
|
|
68
68
|
z2.object({ gte: z2.union([z2.string(), z2.number().finite()]) }).strict(),
|
|
69
69
|
z2.object({ lt: z2.union([z2.string(), z2.number().finite()]) }).strict(),
|
|
70
70
|
z2.object({ lte: z2.union([z2.string(), z2.number().finite()]) }).strict(),
|
|
71
71
|
z2.object({
|
|
72
|
-
in: z2.array(
|
|
72
|
+
in: z2.array(WebhookFilterPrimitiveSchema).min(1)
|
|
73
73
|
}).strict()
|
|
74
74
|
]);
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
SubscriptionFilterOperatorSchema
|
|
78
|
-
]);
|
|
79
|
-
var SubscriptionFilterSchema = z2.record(z2.string().min(1), SubscriptionFilterClauseSchema);
|
|
75
|
+
var WebhookFilterClauseSchema = z2.union([WebhookFilterPrimitiveSchema, WebhookFilterOperatorSchema]);
|
|
76
|
+
var WebhookFilterSchema = z2.record(z2.string().min(1), WebhookFilterClauseSchema);
|
|
80
77
|
var CHAIN_TRIGGER_TYPES = [
|
|
81
78
|
"stx_transfer",
|
|
82
79
|
"stx_mint",
|
|
@@ -221,15 +218,15 @@ var CHAIN_TRIGGER_FIELDS = Object.fromEntries(ChainTriggerSchema._zod.def.option
|
|
|
221
218
|
const type = shape.type._zod.def.values[0];
|
|
222
219
|
return [type, Object.keys(shape).filter((k) => k !== "type")];
|
|
223
220
|
}));
|
|
224
|
-
var
|
|
221
|
+
var CreateWebhookRequestSchema = z2.object({
|
|
225
222
|
name,
|
|
226
223
|
subgraphName: resourceName.optional(),
|
|
227
224
|
tableName: resourceName.optional(),
|
|
228
|
-
filter:
|
|
225
|
+
filter: WebhookFilterSchema.optional(),
|
|
229
226
|
triggers: ChainTriggersSchema.optional(),
|
|
230
227
|
url: webhookUrl,
|
|
231
|
-
format:
|
|
232
|
-
runtime:
|
|
228
|
+
format: WebhookFormatSchema.default("standard-webhooks"),
|
|
229
|
+
runtime: WebhookRuntimeSchema.nullable().optional(),
|
|
233
230
|
authConfig: z2.record(z2.string(), z2.unknown()).optional(),
|
|
234
231
|
maxRetries: z2.number().int().min(0).max(100).optional(),
|
|
235
232
|
timeoutMs: z2.number().int().min(100).max(300000).optional(),
|
|
@@ -243,17 +240,17 @@ var CreateSubscriptionRequestSchema = z2.object({
|
|
|
243
240
|
return true;
|
|
244
241
|
return v.subgraphName !== undefined && v.tableName !== undefined;
|
|
245
242
|
}, {
|
|
246
|
-
message: "provide either { subgraphName, tableName } for a subgraph
|
|
243
|
+
message: "provide either { subgraphName, tableName } for a subgraph webhook OR { triggers } for a chain webhook — not both"
|
|
247
244
|
}).refine((v) => v.filter === undefined || v.triggers === undefined, {
|
|
248
|
-
message: "`filter` applies to subgraph
|
|
245
|
+
message: "`filter` applies to subgraph webhooks; chain webhooks use `triggers`",
|
|
249
246
|
path: ["filter"]
|
|
250
247
|
});
|
|
251
|
-
var
|
|
248
|
+
var UpdateWebhookRequestSchema = z2.object({
|
|
252
249
|
name: name.optional(),
|
|
253
250
|
url: webhookUrl.optional(),
|
|
254
|
-
filter:
|
|
255
|
-
format:
|
|
256
|
-
runtime:
|
|
251
|
+
filter: WebhookFilterSchema.optional(),
|
|
252
|
+
format: WebhookFormatSchema.optional(),
|
|
253
|
+
runtime: WebhookRuntimeSchema.nullable().optional(),
|
|
257
254
|
authConfig: z2.record(z2.string(), z2.unknown()).optional(),
|
|
258
255
|
maxRetries: z2.number().int().min(0).max(100).optional(),
|
|
259
256
|
timeoutMs: z2.number().int().min(100).max(300000).optional(),
|
|
@@ -261,7 +258,7 @@ var UpdateSubscriptionRequestSchema = z2.object({
|
|
|
261
258
|
}).refine((value) => Object.keys(value).length > 0, {
|
|
262
259
|
message: "At least one field must be provided"
|
|
263
260
|
});
|
|
264
|
-
var
|
|
261
|
+
var ReplayWebhookRequestSchema = z2.object({
|
|
265
262
|
fromBlock: z2.number().int().nonnegative(),
|
|
266
263
|
toBlock: z2.number().int().nonnegative(),
|
|
267
264
|
force: z2.string().trim().min(1).max(64).optional()
|
|
@@ -355,7 +352,7 @@ var COMPARISON_COLUMN_TYPES = new Set(["uint", "int", "timestamp"]);
|
|
|
355
352
|
function formatIssuePath(path) {
|
|
356
353
|
return path.length > 0 ? `${path.map(String).join(".")}: ` : "";
|
|
357
354
|
}
|
|
358
|
-
function
|
|
355
|
+
function formatWebhookSchemaErrors(error) {
|
|
359
356
|
return error.issues.map((issue) => `${formatIssuePath(issue.path)}${issue.message}`);
|
|
360
357
|
}
|
|
361
358
|
function operatorForClause(clause) {
|
|
@@ -364,7 +361,7 @@ function operatorForClause(clause) {
|
|
|
364
361
|
}
|
|
365
362
|
return Object.keys(clause)[0] ?? "eq";
|
|
366
363
|
}
|
|
367
|
-
function
|
|
364
|
+
function validateWebhookFilterForTable(input) {
|
|
368
365
|
const errors = [];
|
|
369
366
|
const table = input.tables[input.tableName];
|
|
370
367
|
if (!table) {
|
|
@@ -374,9 +371,9 @@ function validateSubscriptionFilterForTable(input) {
|
|
|
374
371
|
}
|
|
375
372
|
if (input.filter === undefined)
|
|
376
373
|
return errors;
|
|
377
|
-
const parsed =
|
|
374
|
+
const parsed = WebhookFilterSchema.safeParse(input.filter);
|
|
378
375
|
if (!parsed.success) {
|
|
379
|
-
return
|
|
376
|
+
return formatWebhookSchemaErrors(parsed.error);
|
|
380
377
|
}
|
|
381
378
|
for (const [field, clause] of Object.entries(parsed.data)) {
|
|
382
379
|
const column = table.columns[field];
|
|
@@ -386,7 +383,7 @@ function validateSubscriptionFilterForTable(input) {
|
|
|
386
383
|
}
|
|
387
384
|
const columnType = typeof column.type === "string" ? column.type.toLowerCase() : "";
|
|
388
385
|
if (!SCALAR_COLUMN_TYPES.has(columnType)) {
|
|
389
|
-
errors.push(`Filter field "${field}" has unsupported type "${columnType || "unknown"}";
|
|
386
|
+
errors.push(`Filter field "${field}" has unsupported type "${columnType || "unknown"}"; webhook filters require scalar columns.`);
|
|
390
387
|
continue;
|
|
391
388
|
}
|
|
392
389
|
const operator = operatorForClause(clause);
|
|
@@ -397,26 +394,26 @@ function validateSubscriptionFilterForTable(input) {
|
|
|
397
394
|
return errors;
|
|
398
395
|
}
|
|
399
396
|
export {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
397
|
+
validateWebhookFilterForTable,
|
|
398
|
+
formatWebhookSchemaErrors,
|
|
399
|
+
WebhookStatusSchema,
|
|
400
|
+
WebhookRuntimeSchema,
|
|
401
|
+
WebhookFormatSchema,
|
|
402
|
+
WebhookFilterSchema,
|
|
403
|
+
WebhookFilterPrimitiveSchema,
|
|
404
|
+
WebhookFilterOperatorSchema,
|
|
405
|
+
WebhookFilterClauseSchema,
|
|
406
|
+
WEBHOOK_STATUSES,
|
|
407
|
+
WEBHOOK_RUNTIMES,
|
|
408
|
+
WEBHOOK_FORMATS,
|
|
409
|
+
WEBHOOK_FILTER_OPERATORS,
|
|
410
|
+
UpdateWebhookRequestSchema,
|
|
411
|
+
ReplayWebhookRequestSchema,
|
|
415
412
|
DeploySubgraphRequestSchema,
|
|
416
|
-
|
|
413
|
+
CreateWebhookRequestSchema,
|
|
417
414
|
CHAIN_TRIGGER_TYPES,
|
|
418
415
|
CHAIN_TRIGGER_FIELDS
|
|
419
416
|
};
|
|
420
417
|
|
|
421
|
-
//# debugId=
|
|
418
|
+
//# debugId=6EDFF4FE6F27581C64756E2164756E21
|
|
422
419
|
//# sourceMappingURL=index.js.map
|