@secondlayer/shared 7.2.1 → 7.3.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/dist/src/index.d.ts +17 -109
- package/dist/src/index.js +100 -227
- package/dist/src/index.js.map +4 -5
- package/dist/src/schemas/index.d.ts +14 -107
- package/dist/src/schemas/index.js +95 -213
- package/dist/src/schemas/index.js.map +3 -4
- package/migrations/0082_contracts_registry.ts +4 -2
- package/migrations/0083_burnchain_rewards.ts +4 -2
- package/migrations/0107_burnchain_drop_canonical.ts +4 -2
- package/package.json +3 -6
- package/dist/src/schemas/filters.d.ts +0 -94
- package/dist/src/schemas/filters.js +0 -138
- package/dist/src/schemas/filters.js.map +0 -10
|
@@ -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:
|
|
29
|
+
declare const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest>;
|
|
123
30
|
interface DeploySubgraphResponse {
|
|
124
31
|
action: "created" | "unchanged" | "handler_updated" | "updated" | "reindexed";
|
|
125
32
|
subgraphId: 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
|
|
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:
|
|
327
|
-
declare const SubscriptionFormatSchema:
|
|
328
|
-
declare const SubscriptionRuntimeSchema:
|
|
329
|
-
declare const SubscriptionFilterPrimitiveSchema:
|
|
330
|
-
declare const SubscriptionFilterOperatorSchema:
|
|
331
|
-
declare const SubscriptionFilterClauseSchema:
|
|
332
|
-
declare const SubscriptionFilterSchema:
|
|
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:
|
|
341
|
-
declare const UpdateSubscriptionRequestSchema:
|
|
342
|
-
declare const ReplaySubscriptionRequestSchema:
|
|
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:
|
|
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,
|
|
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
|
|
123
|
-
var DeploySubgraphRequestSchema =
|
|
124
|
-
name:
|
|
125
|
-
version:
|
|
126
|
-
description:
|
|
127
|
-
sources:
|
|
128
|
-
schema:
|
|
129
|
-
handlerCode:
|
|
130
|
-
startBlock:
|
|
131
|
-
sourceCode:
|
|
132
|
-
databaseUrl:
|
|
133
|
-
dryRun:
|
|
134
|
-
visibility:
|
|
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
|
|
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 =
|
|
164
|
-
var name =
|
|
165
|
-
var resourceName =
|
|
166
|
-
var SubscriptionStatusSchema =
|
|
167
|
-
var SubscriptionFormatSchema =
|
|
168
|
-
var SubscriptionRuntimeSchema =
|
|
169
|
-
var SubscriptionFilterPrimitiveSchema =
|
|
170
|
-
var SubscriptionFilterOperatorSchema =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
in:
|
|
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 =
|
|
77
|
+
var SubscriptionFilterClauseSchema = z2.union([
|
|
182
78
|
SubscriptionFilterPrimitiveSchema,
|
|
183
79
|
SubscriptionFilterOperatorSchema
|
|
184
80
|
]);
|
|
185
|
-
var SubscriptionFilterSchema =
|
|
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 =
|
|
207
|
-
|
|
208
|
-
|
|
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 =
|
|
211
|
-
var trait =
|
|
212
|
-
var ChainTriggerSchema =
|
|
213
|
-
|
|
214
|
-
type:
|
|
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
|
-
|
|
221
|
-
type:
|
|
116
|
+
z2.object({
|
|
117
|
+
type: z2.literal("stx_mint"),
|
|
222
118
|
recipient: triggerPattern.optional(),
|
|
223
119
|
minAmount: triggerAmount.optional()
|
|
224
120
|
}).strict(),
|
|
225
|
-
|
|
226
|
-
type:
|
|
121
|
+
z2.object({
|
|
122
|
+
type: z2.literal("stx_burn"),
|
|
227
123
|
sender: triggerPattern.optional(),
|
|
228
124
|
minAmount: triggerAmount.optional()
|
|
229
125
|
}).strict(),
|
|
230
|
-
|
|
231
|
-
type:
|
|
126
|
+
z2.object({
|
|
127
|
+
type: z2.literal("stx_lock"),
|
|
232
128
|
lockedAddress: triggerPattern.optional(),
|
|
233
129
|
minAmount: triggerAmount.optional()
|
|
234
130
|
}).strict(),
|
|
235
|
-
|
|
236
|
-
type:
|
|
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
|
-
|
|
244
|
-
type:
|
|
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
|
-
|
|
251
|
-
type:
|
|
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
|
-
|
|
258
|
-
type:
|
|
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
|
-
|
|
265
|
-
type:
|
|
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
|
-
|
|
271
|
-
type:
|
|
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
|
-
|
|
277
|
-
type:
|
|
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
|
-
|
|
284
|
-
type:
|
|
179
|
+
z2.object({
|
|
180
|
+
type: z2.literal("contract_deploy"),
|
|
285
181
|
deployer: triggerPattern.optional(),
|
|
286
182
|
contractName: triggerPattern.optional()
|
|
287
183
|
}).strict(),
|
|
288
|
-
|
|
289
|
-
type:
|
|
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
|
-
|
|
295
|
-
type:
|
|
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:
|
|
196
|
+
requestId: z2.number().int().nonnegative().optional()
|
|
301
197
|
}).strict(),
|
|
302
|
-
|
|
303
|
-
type:
|
|
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:
|
|
203
|
+
requestId: z2.number().int().nonnegative().optional()
|
|
308
204
|
}).strict(),
|
|
309
|
-
|
|
310
|
-
type:
|
|
311
|
-
requestId:
|
|
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
|
-
|
|
315
|
-
type:
|
|
316
|
-
requestId:
|
|
210
|
+
z2.object({
|
|
211
|
+
type: z2.literal("sbtc_withdrawal_reject"),
|
|
212
|
+
requestId: z2.number().int().nonnegative().optional()
|
|
317
213
|
}).strict(),
|
|
318
|
-
|
|
319
|
-
type:
|
|
320
|
-
requestId:
|
|
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 =
|
|
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 =
|
|
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:
|
|
340
|
-
maxRetries:
|
|
341
|
-
timeoutMs:
|
|
342
|
-
concurrency:
|
|
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 =
|
|
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:
|
|
364
|
-
maxRetries:
|
|
365
|
-
timeoutMs:
|
|
366
|
-
concurrency:
|
|
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 =
|
|
371
|
-
fromBlock:
|
|
372
|
-
toBlock:
|
|
373
|
-
force:
|
|
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=
|
|
423
|
+
//# debugId=5B85C16DA0B4FD7864756E2164756E21
|
|
542
424
|
//# sourceMappingURL=index.js.map
|