@secondlayer/shared 7.2.2 → 7.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/src/db/index.d.ts +19 -1
  2. package/dist/src/db/index.js +2 -1
  3. package/dist/src/db/index.js.map +3 -3
  4. package/dist/src/db/queries/chain-reorgs.d.ts +17 -0
  5. package/dist/src/db/queries/chain-reorgs.js +2 -1
  6. package/dist/src/db/queries/chain-reorgs.js.map +3 -3
  7. package/dist/src/db/queries/contracts.d.ts +17 -0
  8. package/dist/src/db/queries/integrity.d.ts +17 -0
  9. package/dist/src/db/queries/subgraph-gaps.d.ts +17 -0
  10. package/dist/src/db/queries/subgraph-operations.d.ts +17 -0
  11. package/dist/src/db/queries/subgraphs.d.ts +17 -0
  12. package/dist/src/db/queries/subgraphs.js +2 -1
  13. package/dist/src/db/queries/subgraphs.js.map +3 -3
  14. package/dist/src/db/queries/subscriptions.d.ts +17 -0
  15. package/dist/src/db/schema.d.ts +18 -1
  16. package/dist/src/errors.d.ts +1 -1
  17. package/dist/src/errors.js +2 -1
  18. package/dist/src/errors.js.map +3 -3
  19. package/dist/src/index-http.d.ts +2 -0
  20. package/dist/src/index-http.js.map +2 -2
  21. package/dist/src/index.d.ts +40 -114
  22. package/dist/src/index.js +102 -227
  23. package/dist/src/index.js.map +8 -9
  24. package/dist/src/node/local-client.d.ts +17 -0
  25. package/dist/src/schemas/index.d.ts +16 -109
  26. package/dist/src/schemas/index.js +95 -213
  27. package/dist/src/schemas/index.js.map +4 -5
  28. package/dist/src/schemas/subgraphs.d.ts +2 -2
  29. package/dist/src/schemas/subgraphs.js.map +1 -1
  30. package/dist/src/subgraphs/spec.d.ts +4 -4
  31. package/dist/src/subgraphs/spec.js.map +1 -1
  32. package/migrations/0111_chain_read_cache.ts +64 -0
  33. package/package.json +2 -2
  34. package/dist/src/schemas/filters.d.ts +0 -94
  35. package/dist/src/schemas/filters.js +0 -138
  36. package/dist/src/schemas/filters.js.map +0 -10
@@ -666,6 +666,22 @@ interface BnsNamespacesTable {
666
666
  name_count: Generated<number>;
667
667
  updated_at: Generated<Date>;
668
668
  }
669
+ /**
670
+ * Memoized `ctx.client.readOnly()` results. Keyed on `index_block_hash` so a
671
+ * reorg-replaced block never inherits the orphaned fork's answer; a NULL
672
+ * `index_block_hash` marks a caller-declared contract-constant value, cached
673
+ * once per contract+args instead of once per block.
674
+ */
675
+ interface ChainReadCacheTable {
676
+ id: Generated<number>;
677
+ contract_id: string;
678
+ function_name: string;
679
+ args_hash: string;
680
+ index_block_hash: string | null;
681
+ block_height: ColumnType<number | null, number | null | undefined, number | null>;
682
+ result_hex: string;
683
+ created_at: Generated<Date>;
684
+ }
669
685
  interface Database {
670
686
  blocks: BlocksTable;
671
687
  transactions: TransactionsTable;
@@ -727,6 +743,7 @@ interface Database {
727
743
  service_heartbeats: ServiceHeartbeatsTable;
728
744
  x402_payments: X402PaymentsTable;
729
745
  x402_balances: X402BalancesTable;
746
+ chain_read_cache: ChainReadCacheTable;
730
747
  }
731
748
  /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
732
749
  interface X402BalancesTable {
@@ -1,97 +1,4 @@
1
1
  import { z } from "zod";
2
- interface StxTransferFilter {
3
- type: "stx_transfer";
4
- sender?: string;
5
- recipient?: string;
6
- minAmount?: number;
7
- maxAmount?: number;
8
- }
9
- interface StxMintFilter {
10
- type: "stx_mint";
11
- recipient?: string;
12
- minAmount?: number;
13
- }
14
- interface StxBurnFilter {
15
- type: "stx_burn";
16
- sender?: string;
17
- minAmount?: number;
18
- }
19
- interface StxLockFilter {
20
- type: "stx_lock";
21
- lockedAddress?: string;
22
- minAmount?: number;
23
- }
24
- interface FtTransferFilter {
25
- type: "ft_transfer";
26
- sender?: string;
27
- recipient?: string;
28
- assetIdentifier?: string;
29
- minAmount?: number;
30
- }
31
- interface FtMintFilter {
32
- type: "ft_mint";
33
- recipient?: string;
34
- assetIdentifier?: string;
35
- minAmount?: number;
36
- }
37
- interface FtBurnFilter {
38
- type: "ft_burn";
39
- sender?: string;
40
- assetIdentifier?: string;
41
- minAmount?: number;
42
- }
43
- interface NftTransferFilter {
44
- type: "nft_transfer";
45
- sender?: string;
46
- recipient?: string;
47
- assetIdentifier?: string;
48
- tokenId?: string;
49
- }
50
- interface NftMintFilter {
51
- type: "nft_mint";
52
- recipient?: string;
53
- assetIdentifier?: string;
54
- tokenId?: string;
55
- }
56
- interface NftBurnFilter {
57
- type: "nft_burn";
58
- sender?: string;
59
- assetIdentifier?: string;
60
- tokenId?: string;
61
- }
62
- interface ContractCallFilter {
63
- type: "contract_call";
64
- contractId?: string;
65
- functionName?: string;
66
- caller?: string;
67
- }
68
- interface ContractDeployFilter {
69
- type: "contract_deploy";
70
- deployer?: string;
71
- contractName?: string;
72
- }
73
- interface PrintEventFilter {
74
- type: "print_event";
75
- contractId?: string;
76
- topic?: string;
77
- contains?: string;
78
- }
79
- type EventFilter = StxTransferFilter | StxMintFilter | StxBurnFilter | StxLockFilter | FtTransferFilter | FtMintFilter | FtBurnFilter | NftTransferFilter | NftMintFilter | NftBurnFilter | ContractCallFilter | ContractDeployFilter | PrintEventFilter;
80
- declare const StxTransferFilterSchema: z.ZodType<StxTransferFilter>;
81
- declare const StxMintFilterSchema: z.ZodType<StxMintFilter>;
82
- declare const StxBurnFilterSchema: z.ZodType<StxBurnFilter>;
83
- declare const StxLockFilterSchema: z.ZodType<StxLockFilter>;
84
- declare const FtTransferFilterSchema: z.ZodType<FtTransferFilter>;
85
- declare const FtMintFilterSchema: z.ZodType<FtMintFilter>;
86
- declare const FtBurnFilterSchema: z.ZodType<FtBurnFilter>;
87
- declare const NftTransferFilterSchema: z.ZodType<NftTransferFilter>;
88
- declare const NftMintFilterSchema: z.ZodType<NftMintFilter>;
89
- declare const NftBurnFilterSchema: z.ZodType<NftBurnFilter>;
90
- declare const ContractCallFilterSchema: z.ZodType<ContractCallFilter>;
91
- declare const ContractDeployFilterSchema: z.ZodType<ContractDeployFilter>;
92
- declare const PrintEventFilterSchema: z.ZodType<PrintEventFilter>;
93
- declare const EventFilterSchema: z.ZodType<EventFilter>;
94
- import { z as z2 } from "zod";
95
2
  interface DeploySubgraphRequest {
96
3
  name: string;
97
4
  version?: string;
@@ -119,7 +26,7 @@ interface DeploySubgraphRequest {
119
26
  */
120
27
  visibility?: "public" | "private";
121
28
  }
122
- declare const DeploySubgraphRequestSchema: z2.ZodType<DeploySubgraphRequest>;
29
+ declare const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest>;
123
30
  interface DeploySubgraphResponse {
124
31
  action: "created" | "unchanged" | "handler_updated" | "updated" | "reindexed";
125
32
  subgraphId: string;
@@ -254,8 +161,8 @@ interface SubgraphDetail {
254
161
  }>
255
162
  rowCount: number
256
163
  example: string
257
- indexes?: string[][]
258
- uniqueKeys?: string[][]
164
+ indexes?: readonly (readonly string[])[]
165
+ uniqueKeys?: readonly (readonly string[])[]
259
166
  }>;
260
167
  createdAt: string;
261
168
  updatedAt: string;
@@ -318,18 +225,18 @@ interface SubgraphAggregateResponse {
318
225
  min?: Record<string, string | null>;
319
226
  max?: Record<string, string | null>;
320
227
  }
321
- import { z as z3 } from "zod";
228
+ import { z as z2 } from "zod";
322
229
  declare const SUBSCRIPTION_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
323
230
  declare const SUBSCRIPTION_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
324
231
  declare const SUBSCRIPTION_STATUSES: readonly ["active", "paused", "error"];
325
232
  declare const SUBSCRIPTION_FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in"];
326
- declare const SubscriptionStatusSchema: z3.ZodType<SubscriptionStatus>;
327
- declare const SubscriptionFormatSchema: z3.ZodType<SubscriptionFormat>;
328
- declare const SubscriptionRuntimeSchema: z3.ZodType<SubscriptionRuntime>;
329
- declare const SubscriptionFilterPrimitiveSchema: z3.ZodType<SubscriptionFilterPrimitive>;
330
- declare const SubscriptionFilterOperatorSchema: z3.ZodType<SubscriptionFilterOperator>;
331
- declare const SubscriptionFilterClauseSchema: z3.ZodType<SubscriptionFilterClause>;
332
- declare const SubscriptionFilterSchema: z3.ZodType<SubscriptionFilter>;
233
+ declare const SubscriptionStatusSchema: z2.ZodType<SubscriptionStatus>;
234
+ declare const SubscriptionFormatSchema: z2.ZodType<SubscriptionFormat>;
235
+ declare const SubscriptionRuntimeSchema: z2.ZodType<SubscriptionRuntime>;
236
+ declare const SubscriptionFilterPrimitiveSchema: z2.ZodType<SubscriptionFilterPrimitive>;
237
+ declare const SubscriptionFilterOperatorSchema: z2.ZodType<SubscriptionFilterOperator>;
238
+ declare const SubscriptionFilterClauseSchema: z2.ZodType<SubscriptionFilterClause>;
239
+ declare const SubscriptionFilterSchema: z2.ZodType<SubscriptionFilter>;
333
240
  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"];
334
241
  /**
335
242
  * Per-type accepted filter fields for chain triggers, DERIVED from
@@ -337,9 +244,9 @@ declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_bu
337
244
  * the validator. `{ stx_transfer: ["sender","recipient","minAmount","maxAmount"], ... }`.
338
245
  */
339
246
  declare const CHAIN_TRIGGER_FIELDS: Record<string, string[]>;
340
- declare const CreateSubscriptionRequestSchema: z3.ZodType<ParsedCreateSubscriptionRequest>;
341
- declare const UpdateSubscriptionRequestSchema: z3.ZodType<UpdateSubscriptionRequest>;
342
- declare const ReplaySubscriptionRequestSchema: z3.ZodType<ReplaySubscriptionRequest>;
247
+ declare const CreateSubscriptionRequestSchema: z2.ZodType<ParsedCreateSubscriptionRequest>;
248
+ declare const UpdateSubscriptionRequestSchema: z2.ZodType<UpdateSubscriptionRequest>;
249
+ declare const ReplaySubscriptionRequestSchema: z2.ZodType<ReplaySubscriptionRequest>;
343
250
  type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];
344
251
  /** Polymorphic subscription mode (mirrors db/types `SubscriptionKind`). */
345
252
  type SubscriptionKind = "subgraph" | "chain";
@@ -560,11 +467,11 @@ interface SubscriptionSchemaTable {
560
467
  columns: Record<string, SubscriptionSchemaColumn>;
561
468
  }
562
469
  type SubscriptionSchemaTables = Record<string, SubscriptionSchemaTable>;
563
- declare function formatSubscriptionSchemaErrors(error: z3.ZodError): string[];
470
+ declare function formatSubscriptionSchemaErrors(error: z2.ZodError): string[];
564
471
  declare function validateSubscriptionFilterForTable(input: {
565
472
  subgraphName?: string
566
473
  tableName: string
567
474
  filter?: unknown
568
475
  tables: SubscriptionSchemaTables
569
476
  }): string[];
570
- export { validateSubscriptionFilterForTable, formatSubscriptionSchemaErrors, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionFormatSchema, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubgraphSyncInfo, SubgraphSummary, SubgraphResourceWarning, SubgraphQueryParams, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, RotateSecretResponse, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, ReindexResponse, PrintEventFilterSchema, PrintEventFilter, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, EventFilterSchema, EventFilter, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DeadRow, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS };
477
+ export { validateSubscriptionFilterForTable, formatSubscriptionSchemaErrors, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionFormatSchema, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubgraphSyncInfo, SubgraphSummary, SubgraphResourceWarning, SubgraphQueryParams, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, RotateSecretResponse, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, ReindexResponse, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DeadRow, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS };
@@ -14,128 +14,24 @@ var __export = (target, all) => {
14
14
  });
15
15
  };
16
16
 
17
- // src/schemas/filters.ts
18
- import { isValidAddress as _isValidAddress } from "@secondlayer/stacks";
19
- import { z } from "zod";
20
- var isValidAddress = _isValidAddress;
21
- var stacksPrincipal = z.string().refine((val) => {
22
- const parts = val.split(".");
23
- if (parts.length > 2)
24
- return false;
25
- return isValidAddress(parts[0]);
26
- }, "Invalid Stacks principal address");
27
- var baseFilter = {
28
- sender: stacksPrincipal.optional(),
29
- recipient: stacksPrincipal.optional()
30
- };
31
- var StxTransferFilterSchema = z.object({
32
- type: z.literal("stx_transfer"),
33
- ...baseFilter,
34
- minAmount: z.coerce.number().int().positive().optional(),
35
- maxAmount: z.coerce.number().int().positive().optional()
36
- });
37
- var StxMintFilterSchema = z.object({
38
- type: z.literal("stx_mint"),
39
- recipient: stacksPrincipal.optional(),
40
- minAmount: z.coerce.number().int().positive().optional()
41
- });
42
- var StxBurnFilterSchema = z.object({
43
- type: z.literal("stx_burn"),
44
- sender: stacksPrincipal.optional(),
45
- minAmount: z.coerce.number().int().positive().optional()
46
- });
47
- var StxLockFilterSchema = z.object({
48
- type: z.literal("stx_lock"),
49
- lockedAddress: stacksPrincipal.optional(),
50
- minAmount: z.coerce.number().int().positive().optional()
51
- });
52
- var FtTransferFilterSchema = z.object({
53
- type: z.literal("ft_transfer"),
54
- ...baseFilter,
55
- assetIdentifier: z.string().optional(),
56
- minAmount: z.coerce.number().int().positive().optional()
57
- });
58
- var FtMintFilterSchema = z.object({
59
- type: z.literal("ft_mint"),
60
- recipient: stacksPrincipal.optional(),
61
- assetIdentifier: z.string().optional(),
62
- minAmount: z.coerce.number().int().positive().optional()
63
- });
64
- var FtBurnFilterSchema = z.object({
65
- type: z.literal("ft_burn"),
66
- sender: stacksPrincipal.optional(),
67
- assetIdentifier: z.string().optional(),
68
- minAmount: z.coerce.number().int().positive().optional()
69
- });
70
- var NftTransferFilterSchema = z.object({
71
- type: z.literal("nft_transfer"),
72
- ...baseFilter,
73
- assetIdentifier: z.string().optional(),
74
- tokenId: z.string().optional()
75
- });
76
- var NftMintFilterSchema = z.object({
77
- type: z.literal("nft_mint"),
78
- recipient: stacksPrincipal.optional(),
79
- assetIdentifier: z.string().optional(),
80
- tokenId: z.string().optional()
81
- });
82
- var NftBurnFilterSchema = z.object({
83
- type: z.literal("nft_burn"),
84
- sender: stacksPrincipal.optional(),
85
- assetIdentifier: z.string().optional(),
86
- tokenId: z.string().optional()
87
- });
88
- var ContractCallFilterSchema = z.object({
89
- type: z.literal("contract_call"),
90
- contractId: stacksPrincipal.optional(),
91
- functionName: z.string().optional(),
92
- caller: stacksPrincipal.optional()
93
- });
94
- var ContractDeployFilterSchema = z.object({
95
- type: z.literal("contract_deploy"),
96
- deployer: stacksPrincipal.optional(),
97
- contractName: z.string().optional()
98
- });
99
- var PrintEventFilterSchema = z.object({
100
- type: z.literal("print_event"),
101
- contractId: stacksPrincipal.optional(),
102
- topic: z.string().optional(),
103
- contains: z.string().optional()
104
- });
105
- var EventFilterSchema = z.discriminatedUnion("type", [
106
- StxTransferFilterSchema,
107
- StxMintFilterSchema,
108
- StxBurnFilterSchema,
109
- StxLockFilterSchema,
110
- FtTransferFilterSchema,
111
- FtMintFilterSchema,
112
- FtBurnFilterSchema,
113
- NftTransferFilterSchema,
114
- NftMintFilterSchema,
115
- NftBurnFilterSchema,
116
- ContractCallFilterSchema,
117
- ContractDeployFilterSchema,
118
- PrintEventFilterSchema
119
- ]);
120
-
121
17
  // src/schemas/subgraphs.ts
122
- import { z as z2 } from "zod";
123
- var DeploySubgraphRequestSchema = z2.object({
124
- name: z2.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
125
- version: z2.string().optional(),
126
- description: z2.string().optional(),
127
- sources: z2.record(z2.string(), z2.record(z2.string(), z2.unknown())).refine((s) => Object.keys(s).length > 0, "Must have at least one source"),
128
- schema: z2.record(z2.string(), z2.unknown()),
129
- handlerCode: z2.string().max(1048576, "handler code exceeds 1MB limit"),
130
- startBlock: z2.number().int().nonnegative().optional(),
131
- sourceCode: z2.string().max(1048576, "source code exceeds 1MB limit").optional(),
132
- databaseUrl: z2.string().url().refine((u) => u.startsWith("postgres://") || u.startsWith("postgresql://"), "must be a postgres:// connection string").optional(),
133
- dryRun: z2.boolean().optional(),
134
- visibility: z2.enum(["public", "private"]).optional()
18
+ import { z } from "zod";
19
+ var DeploySubgraphRequestSchema = z.object({
20
+ name: z.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
21
+ version: z.string().optional(),
22
+ description: z.string().optional(),
23
+ sources: z.record(z.string(), z.record(z.string(), z.unknown())).refine((s) => Object.keys(s).length > 0, "Must have at least one source"),
24
+ schema: z.record(z.string(), z.unknown()),
25
+ handlerCode: z.string().max(1048576, "handler code exceeds 1MB limit"),
26
+ startBlock: z.number().int().nonnegative().optional(),
27
+ sourceCode: z.string().max(1048576, "source code exceeds 1MB limit").optional(),
28
+ databaseUrl: z.string().url().refine((u) => u.startsWith("postgres://") || u.startsWith("postgresql://"), "must be a postgres:// connection string").optional(),
29
+ dryRun: z.boolean().optional(),
30
+ visibility: z.enum(["public", "private"]).optional()
135
31
  });
136
32
 
137
33
  // src/schemas/subscriptions.ts
138
- import { z as z3 } from "zod";
34
+ import { z as z2 } from "zod";
139
35
  var SUBSCRIPTION_FORMATS = [
140
36
  "standard-webhooks",
141
37
  "inngest",
@@ -160,29 +56,29 @@ var SUBSCRIPTION_FILTER_OPERATORS = [
160
56
  "lte",
161
57
  "in"
162
58
  ];
163
- var webhookUrl = z3.string().trim().min(1).refine((value) => value.startsWith("http://") || value.startsWith("https://"), "must be an http(s) URL");
164
- var name = z3.string().trim().min(1).max(128);
165
- var resourceName = z3.string().trim().min(1).max(128);
166
- var SubscriptionStatusSchema = z3.enum(SUBSCRIPTION_STATUSES);
167
- var SubscriptionFormatSchema = z3.enum(SUBSCRIPTION_FORMATS);
168
- var SubscriptionRuntimeSchema = z3.enum(SUBSCRIPTION_RUNTIMES);
169
- var SubscriptionFilterPrimitiveSchema = z3.union([z3.string(), z3.number().finite(), z3.boolean()]);
170
- var SubscriptionFilterOperatorSchema = z3.union([
171
- z3.object({ eq: SubscriptionFilterPrimitiveSchema }).strict(),
172
- z3.object({ neq: SubscriptionFilterPrimitiveSchema }).strict(),
173
- z3.object({ gt: z3.union([z3.string(), z3.number().finite()]) }).strict(),
174
- z3.object({ gte: z3.union([z3.string(), z3.number().finite()]) }).strict(),
175
- z3.object({ lt: z3.union([z3.string(), z3.number().finite()]) }).strict(),
176
- z3.object({ lte: z3.union([z3.string(), z3.number().finite()]) }).strict(),
177
- z3.object({
178
- in: z3.array(SubscriptionFilterPrimitiveSchema).min(1)
59
+ var webhookUrl = z2.string().trim().min(1).refine((value) => value.startsWith("http://") || value.startsWith("https://"), "must be an http(s) URL");
60
+ var name = z2.string().trim().min(1).max(128);
61
+ var resourceName = z2.string().trim().min(1).max(128);
62
+ var SubscriptionStatusSchema = z2.enum(SUBSCRIPTION_STATUSES);
63
+ var SubscriptionFormatSchema = z2.enum(SUBSCRIPTION_FORMATS);
64
+ var SubscriptionRuntimeSchema = z2.enum(SUBSCRIPTION_RUNTIMES);
65
+ var SubscriptionFilterPrimitiveSchema = z2.union([z2.string(), z2.number().finite(), z2.boolean()]);
66
+ var SubscriptionFilterOperatorSchema = z2.union([
67
+ z2.object({ eq: SubscriptionFilterPrimitiveSchema }).strict(),
68
+ z2.object({ neq: SubscriptionFilterPrimitiveSchema }).strict(),
69
+ z2.object({ gt: z2.union([z2.string(), z2.number().finite()]) }).strict(),
70
+ z2.object({ gte: z2.union([z2.string(), z2.number().finite()]) }).strict(),
71
+ z2.object({ lt: z2.union([z2.string(), z2.number().finite()]) }).strict(),
72
+ z2.object({ lte: z2.union([z2.string(), z2.number().finite()]) }).strict(),
73
+ z2.object({
74
+ in: z2.array(SubscriptionFilterPrimitiveSchema).min(1)
179
75
  }).strict()
180
76
  ]);
181
- var SubscriptionFilterClauseSchema = z3.union([
77
+ var SubscriptionFilterClauseSchema = z2.union([
182
78
  SubscriptionFilterPrimitiveSchema,
183
79
  SubscriptionFilterOperatorSchema
184
80
  ]);
185
- var SubscriptionFilterSchema = z3.record(z3.string().min(1), SubscriptionFilterClauseSchema);
81
+ var SubscriptionFilterSchema = z2.record(z2.string().min(1), SubscriptionFilterClauseSchema);
186
82
  var CHAIN_TRIGGER_TYPES = [
187
83
  "stx_transfer",
188
84
  "stx_mint",
@@ -203,131 +99,131 @@ var CHAIN_TRIGGER_TYPES = [
203
99
  "sbtc_withdrawal_reject",
204
100
  "sbtc_withdrawal_swept_confirmed"
205
101
  ];
206
- var triggerAmount = z3.union([
207
- z3.string().trim().regex(/^\d+$/, "must be a non-negative integer string"),
208
- z3.number().int().nonnegative()
102
+ var triggerAmount = z2.union([
103
+ z2.string().trim().regex(/^\d+$/, "must be a non-negative integer string"),
104
+ z2.number().int().nonnegative()
209
105
  ]);
210
- var triggerPattern = z3.string().trim().min(1);
211
- var trait = z3.string().trim().min(1);
212
- var ChainTriggerSchema = z3.discriminatedUnion("type", [
213
- z3.object({
214
- type: z3.literal("stx_transfer"),
106
+ var triggerPattern = z2.string().trim().min(1);
107
+ var trait = z2.string().trim().min(1);
108
+ var ChainTriggerSchema = z2.discriminatedUnion("type", [
109
+ z2.object({
110
+ type: z2.literal("stx_transfer"),
215
111
  sender: triggerPattern.optional(),
216
112
  recipient: triggerPattern.optional(),
217
113
  minAmount: triggerAmount.optional(),
218
114
  maxAmount: triggerAmount.optional()
219
115
  }).strict(),
220
- z3.object({
221
- type: z3.literal("stx_mint"),
116
+ z2.object({
117
+ type: z2.literal("stx_mint"),
222
118
  recipient: triggerPattern.optional(),
223
119
  minAmount: triggerAmount.optional()
224
120
  }).strict(),
225
- z3.object({
226
- type: z3.literal("stx_burn"),
121
+ z2.object({
122
+ type: z2.literal("stx_burn"),
227
123
  sender: triggerPattern.optional(),
228
124
  minAmount: triggerAmount.optional()
229
125
  }).strict(),
230
- z3.object({
231
- type: z3.literal("stx_lock"),
126
+ z2.object({
127
+ type: z2.literal("stx_lock"),
232
128
  lockedAddress: triggerPattern.optional(),
233
129
  minAmount: triggerAmount.optional()
234
130
  }).strict(),
235
- z3.object({
236
- type: z3.literal("ft_transfer"),
131
+ z2.object({
132
+ type: z2.literal("ft_transfer"),
237
133
  assetIdentifier: triggerPattern.optional(),
238
134
  sender: triggerPattern.optional(),
239
135
  recipient: triggerPattern.optional(),
240
136
  minAmount: triggerAmount.optional(),
241
137
  trait: trait.optional()
242
138
  }).strict(),
243
- z3.object({
244
- type: z3.literal("ft_mint"),
139
+ z2.object({
140
+ type: z2.literal("ft_mint"),
245
141
  assetIdentifier: triggerPattern.optional(),
246
142
  recipient: triggerPattern.optional(),
247
143
  minAmount: triggerAmount.optional(),
248
144
  trait: trait.optional()
249
145
  }).strict(),
250
- z3.object({
251
- type: z3.literal("ft_burn"),
146
+ z2.object({
147
+ type: z2.literal("ft_burn"),
252
148
  assetIdentifier: triggerPattern.optional(),
253
149
  sender: triggerPattern.optional(),
254
150
  minAmount: triggerAmount.optional(),
255
151
  trait: trait.optional()
256
152
  }).strict(),
257
- z3.object({
258
- type: z3.literal("nft_transfer"),
153
+ z2.object({
154
+ type: z2.literal("nft_transfer"),
259
155
  assetIdentifier: triggerPattern.optional(),
260
156
  sender: triggerPattern.optional(),
261
157
  recipient: triggerPattern.optional(),
262
158
  trait: trait.optional()
263
159
  }).strict(),
264
- z3.object({
265
- type: z3.literal("nft_mint"),
160
+ z2.object({
161
+ type: z2.literal("nft_mint"),
266
162
  assetIdentifier: triggerPattern.optional(),
267
163
  recipient: triggerPattern.optional(),
268
164
  trait: trait.optional()
269
165
  }).strict(),
270
- z3.object({
271
- type: z3.literal("nft_burn"),
166
+ z2.object({
167
+ type: z2.literal("nft_burn"),
272
168
  assetIdentifier: triggerPattern.optional(),
273
169
  sender: triggerPattern.optional(),
274
170
  trait: trait.optional()
275
171
  }).strict(),
276
- z3.object({
277
- type: z3.literal("contract_call"),
172
+ z2.object({
173
+ type: z2.literal("contract_call"),
278
174
  contractId: triggerPattern.optional(),
279
175
  functionName: triggerPattern.optional(),
280
176
  caller: triggerPattern.optional(),
281
177
  trait: trait.optional()
282
178
  }).strict(),
283
- z3.object({
284
- type: z3.literal("contract_deploy"),
179
+ z2.object({
180
+ type: z2.literal("contract_deploy"),
285
181
  deployer: triggerPattern.optional(),
286
182
  contractName: triggerPattern.optional()
287
183
  }).strict(),
288
- z3.object({
289
- type: z3.literal("print_event"),
184
+ z2.object({
185
+ type: z2.literal("print_event"),
290
186
  contractId: triggerPattern.optional(),
291
187
  topic: triggerPattern.optional(),
292
188
  trait: trait.optional()
293
189
  }).strict(),
294
- z3.object({
295
- type: z3.literal("sbtc_deposit"),
190
+ z2.object({
191
+ type: z2.literal("sbtc_deposit"),
296
192
  sender: triggerPattern.optional(),
297
193
  minAmount: triggerAmount.optional(),
298
194
  maxAmount: triggerAmount.optional(),
299
195
  bitcoinTxid: triggerPattern.optional(),
300
- requestId: z3.number().int().nonnegative().optional()
196
+ requestId: z2.number().int().nonnegative().optional()
301
197
  }).strict(),
302
- z3.object({
303
- type: z3.literal("sbtc_withdrawal_create"),
198
+ z2.object({
199
+ type: z2.literal("sbtc_withdrawal_create"),
304
200
  sender: triggerPattern.optional(),
305
201
  minAmount: triggerAmount.optional(),
306
202
  maxAmount: triggerAmount.optional(),
307
- requestId: z3.number().int().nonnegative().optional()
203
+ requestId: z2.number().int().nonnegative().optional()
308
204
  }).strict(),
309
- z3.object({
310
- type: z3.literal("sbtc_withdrawal_accept"),
311
- requestId: z3.number().int().nonnegative().optional(),
205
+ z2.object({
206
+ type: z2.literal("sbtc_withdrawal_accept"),
207
+ requestId: z2.number().int().nonnegative().optional(),
312
208
  sweepTxid: triggerPattern.optional()
313
209
  }).strict(),
314
- z3.object({
315
- type: z3.literal("sbtc_withdrawal_reject"),
316
- requestId: z3.number().int().nonnegative().optional()
210
+ z2.object({
211
+ type: z2.literal("sbtc_withdrawal_reject"),
212
+ requestId: z2.number().int().nonnegative().optional()
317
213
  }).strict(),
318
- z3.object({
319
- type: z3.literal("sbtc_withdrawal_swept_confirmed"),
320
- requestId: z3.number().int().nonnegative().optional(),
214
+ z2.object({
215
+ type: z2.literal("sbtc_withdrawal_swept_confirmed"),
216
+ requestId: z2.number().int().nonnegative().optional(),
321
217
  sweepTxid: triggerPattern.optional()
322
218
  }).strict()
323
219
  ]);
324
- var ChainTriggersSchema = z3.array(ChainTriggerSchema).min(1).max(50);
220
+ var ChainTriggersSchema = z2.array(ChainTriggerSchema).min(1).max(50);
325
221
  var CHAIN_TRIGGER_FIELDS = Object.fromEntries(ChainTriggerSchema._zod.def.options.map((opt) => {
326
222
  const shape = opt._zod.def.shape;
327
223
  const type = shape.type._zod.def.values[0];
328
224
  return [type, Object.keys(shape).filter((k) => k !== "type")];
329
225
  }));
330
- var CreateSubscriptionRequestSchema = z3.object({
226
+ var CreateSubscriptionRequestSchema = z2.object({
331
227
  name,
332
228
  subgraphName: resourceName.optional(),
333
229
  tableName: resourceName.optional(),
@@ -336,10 +232,10 @@ var CreateSubscriptionRequestSchema = z3.object({
336
232
  url: webhookUrl,
337
233
  format: SubscriptionFormatSchema.default("standard-webhooks"),
338
234
  runtime: SubscriptionRuntimeSchema.nullable().optional(),
339
- authConfig: z3.record(z3.string(), z3.unknown()).optional(),
340
- maxRetries: z3.number().int().min(0).max(100).optional(),
341
- timeoutMs: z3.number().int().min(100).max(300000).optional(),
342
- concurrency: z3.number().int().min(1).max(100).optional()
235
+ authConfig: z2.record(z2.string(), z2.unknown()).optional(),
236
+ maxRetries: z2.number().int().min(0).max(100).optional(),
237
+ timeoutMs: z2.number().int().min(100).max(300000).optional(),
238
+ concurrency: z2.number().int().min(1).max(100).optional()
343
239
  }).refine((v) => {
344
240
  const subgraphMode = v.subgraphName !== undefined || v.tableName !== undefined;
345
241
  const chainMode = v.triggers !== undefined;
@@ -354,23 +250,23 @@ var CreateSubscriptionRequestSchema = z3.object({
354
250
  message: "`filter` applies to subgraph subscriptions; chain subscriptions use `triggers`",
355
251
  path: ["filter"]
356
252
  });
357
- var UpdateSubscriptionRequestSchema = z3.object({
253
+ var UpdateSubscriptionRequestSchema = z2.object({
358
254
  name: name.optional(),
359
255
  url: webhookUrl.optional(),
360
256
  filter: SubscriptionFilterSchema.optional(),
361
257
  format: SubscriptionFormatSchema.optional(),
362
258
  runtime: SubscriptionRuntimeSchema.nullable().optional(),
363
- authConfig: z3.record(z3.string(), z3.unknown()).optional(),
364
- maxRetries: z3.number().int().min(0).max(100).optional(),
365
- timeoutMs: z3.number().int().min(100).max(300000).optional(),
366
- concurrency: z3.number().int().min(1).max(100).optional()
259
+ authConfig: z2.record(z2.string(), z2.unknown()).optional(),
260
+ maxRetries: z2.number().int().min(0).max(100).optional(),
261
+ timeoutMs: z2.number().int().min(100).max(300000).optional(),
262
+ concurrency: z2.number().int().min(1).max(100).optional()
367
263
  }).refine((value) => Object.keys(value).length > 0, {
368
264
  message: "At least one field must be provided"
369
265
  });
370
- var ReplaySubscriptionRequestSchema = z3.object({
371
- fromBlock: z3.number().int().nonnegative(),
372
- toBlock: z3.number().int().nonnegative(),
373
- force: z3.string().trim().min(1).max(64).optional()
266
+ var ReplaySubscriptionRequestSchema = z2.object({
267
+ fromBlock: z2.number().int().nonnegative(),
268
+ toBlock: z2.number().int().nonnegative(),
269
+ force: z2.string().trim().min(1).max(64).optional()
374
270
  }).refine((value) => value.fromBlock <= value.toBlock, {
375
271
  message: "fromBlock must be less than or equal to toBlock",
376
272
  path: ["toBlock"]
@@ -513,30 +409,16 @@ export {
513
409
  SubscriptionFilterPrimitiveSchema,
514
410
  SubscriptionFilterOperatorSchema,
515
411
  SubscriptionFilterClauseSchema,
516
- StxTransferFilterSchema,
517
- StxMintFilterSchema,
518
- StxLockFilterSchema,
519
- StxBurnFilterSchema,
520
412
  SUBSCRIPTION_STATUSES,
521
413
  SUBSCRIPTION_RUNTIMES,
522
414
  SUBSCRIPTION_FORMATS,
523
415
  SUBSCRIPTION_FILTER_OPERATORS,
524
416
  ReplaySubscriptionRequestSchema,
525
- PrintEventFilterSchema,
526
- NftTransferFilterSchema,
527
- NftMintFilterSchema,
528
- NftBurnFilterSchema,
529
- FtTransferFilterSchema,
530
- FtMintFilterSchema,
531
- FtBurnFilterSchema,
532
- EventFilterSchema,
533
417
  DeploySubgraphRequestSchema,
534
418
  CreateSubscriptionRequestSchema,
535
- ContractDeployFilterSchema,
536
- ContractCallFilterSchema,
537
419
  CHAIN_TRIGGER_TYPES,
538
420
  CHAIN_TRIGGER_FIELDS
539
421
  };
540
422
 
541
- //# debugId=0630F78448A93F0564756E2164756E21
423
+ //# debugId=5B85C16DA0B4FD7864756E2164756E21
542
424
  //# sourceMappingURL=index.js.map