@secondlayer/shared 0.2.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.
Files changed (76) hide show
  1. package/README.md +19 -0
  2. package/dist/src/crypto/hmac.d.ts +26 -0
  3. package/dist/src/crypto/hmac.js +75 -0
  4. package/dist/src/crypto/hmac.js.map +10 -0
  5. package/dist/src/db/index.d.ts +227 -0
  6. package/dist/src/db/index.js +75 -0
  7. package/dist/src/db/index.js.map +11 -0
  8. package/dist/src/db/jsonb.d.ts +13 -0
  9. package/dist/src/db/jsonb.js +35 -0
  10. package/dist/src/db/jsonb.js.map +10 -0
  11. package/dist/src/db/queries/accounts.d.ts +179 -0
  12. package/dist/src/db/queries/accounts.js +39 -0
  13. package/dist/src/db/queries/accounts.js.map +10 -0
  14. package/dist/src/db/queries/integrity.d.ts +178 -0
  15. package/dist/src/db/queries/integrity.js +68 -0
  16. package/dist/src/db/queries/integrity.js.map +10 -0
  17. package/dist/src/db/queries/metrics.d.ts +179 -0
  18. package/dist/src/db/queries/metrics.js +51 -0
  19. package/dist/src/db/queries/metrics.js.map +10 -0
  20. package/dist/src/db/queries/usage.d.ts +205 -0
  21. package/dist/src/db/queries/usage.js +117 -0
  22. package/dist/src/db/queries/usage.js.map +11 -0
  23. package/dist/src/db/queries/views.d.ts +191 -0
  24. package/dist/src/db/queries/views.js +111 -0
  25. package/dist/src/db/queries/views.js.map +11 -0
  26. package/dist/src/db/schema.d.ts +207 -0
  27. package/dist/src/db/schema.js +3 -0
  28. package/dist/src/db/schema.js.map +9 -0
  29. package/dist/src/env.d.ts +7 -0
  30. package/dist/src/env.js +60 -0
  31. package/dist/src/env.js.map +10 -0
  32. package/dist/src/errors.d.ts +51 -0
  33. package/dist/src/errors.js +103 -0
  34. package/dist/src/errors.js.map +10 -0
  35. package/dist/src/index.d.ts +464 -0
  36. package/dist/src/index.js +642 -0
  37. package/dist/src/index.js.map +19 -0
  38. package/dist/src/lib/plans.d.ts +10 -0
  39. package/dist/src/lib/plans.js +34 -0
  40. package/dist/src/lib/plans.js.map +10 -0
  41. package/dist/src/logger.d.ts +2 -0
  42. package/dist/src/logger.js +130 -0
  43. package/dist/src/logger.js.map +11 -0
  44. package/dist/src/node/client.d.ts +35 -0
  45. package/dist/src/node/client.js +56 -0
  46. package/dist/src/node/client.js.map +10 -0
  47. package/dist/src/node/hiro-client.d.ts +186 -0
  48. package/dist/src/node/hiro-client.js +410 -0
  49. package/dist/src/node/hiro-client.js.map +12 -0
  50. package/dist/src/queue/index.d.ts +50 -0
  51. package/dist/src/queue/index.js +176 -0
  52. package/dist/src/queue/index.js.map +12 -0
  53. package/dist/src/queue/listener.d.ts +20 -0
  54. package/dist/src/queue/listener.js +63 -0
  55. package/dist/src/queue/listener.js.map +10 -0
  56. package/dist/src/queue/recovery.d.ts +14 -0
  57. package/dist/src/queue/recovery.js +100 -0
  58. package/dist/src/queue/recovery.js.map +12 -0
  59. package/dist/src/schemas/filters.d.ts +30 -0
  60. package/dist/src/schemas/filters.js +133 -0
  61. package/dist/src/schemas/filters.js.map +10 -0
  62. package/dist/src/schemas/index.d.ts +109 -0
  63. package/dist/src/schemas/index.js +228 -0
  64. package/dist/src/schemas/index.js.map +12 -0
  65. package/dist/src/schemas/views.d.ts +51 -0
  66. package/dist/src/schemas/views.js +29 -0
  67. package/dist/src/schemas/views.js.map +10 -0
  68. package/dist/src/types.d.ts +102 -0
  69. package/dist/src/types.js +3 -0
  70. package/dist/src/types.js.map +9 -0
  71. package/migrations/0001_initial.ts +182 -0
  72. package/migrations/0002_api_keys.ts +38 -0
  73. package/migrations/0003_tenant_isolation.ts +114 -0
  74. package/migrations/0004_accounts_and_usage.ts +90 -0
  75. package/migrations/0005_sessions.ts +42 -0
  76. package/package.json +128 -0
@@ -0,0 +1,109 @@
1
+ import { z } from "zod";
2
+ declare const StxTransferFilterSchema: unknown;
3
+ declare const StxMintFilterSchema: unknown;
4
+ declare const StxBurnFilterSchema: unknown;
5
+ declare const StxLockFilterSchema: unknown;
6
+ declare const FtTransferFilterSchema: unknown;
7
+ declare const FtMintFilterSchema: unknown;
8
+ declare const FtBurnFilterSchema: unknown;
9
+ declare const NftTransferFilterSchema: unknown;
10
+ declare const NftMintFilterSchema: unknown;
11
+ declare const NftBurnFilterSchema: unknown;
12
+ declare const ContractCallFilterSchema: unknown;
13
+ declare const ContractDeployFilterSchema: unknown;
14
+ declare const PrintEventFilterSchema: unknown;
15
+ declare const StreamFilterSchema: unknown;
16
+ type StxTransferFilter = z.infer<typeof StxTransferFilterSchema>;
17
+ type StxMintFilter = z.infer<typeof StxMintFilterSchema>;
18
+ type StxBurnFilter = z.infer<typeof StxBurnFilterSchema>;
19
+ type StxLockFilter = z.infer<typeof StxLockFilterSchema>;
20
+ type FtTransferFilter = z.infer<typeof FtTransferFilterSchema>;
21
+ type FtMintFilter = z.infer<typeof FtMintFilterSchema>;
22
+ type FtBurnFilter = z.infer<typeof FtBurnFilterSchema>;
23
+ type NftTransferFilter = z.infer<typeof NftTransferFilterSchema>;
24
+ type NftMintFilter = z.infer<typeof NftMintFilterSchema>;
25
+ type NftBurnFilter = z.infer<typeof NftBurnFilterSchema>;
26
+ type ContractCallFilter = z.infer<typeof ContractCallFilterSchema>;
27
+ type ContractDeployFilter = z.infer<typeof ContractDeployFilterSchema>;
28
+ type PrintEventFilter = z.infer<typeof PrintEventFilterSchema>;
29
+ type StreamFilter = z.infer<typeof StreamFilterSchema>;
30
+ import { z as z2 } from "zod";
31
+ declare const DeployViewRequestSchema: unknown;
32
+ type DeployViewRequest = z2.infer<typeof DeployViewRequestSchema>;
33
+ interface DeployViewResponse {
34
+ action: "created" | "unchanged" | "updated" | "reindexed";
35
+ viewId: string;
36
+ message: string;
37
+ }
38
+ interface ViewSummary {
39
+ name: string;
40
+ version: string;
41
+ status: string;
42
+ lastProcessedBlock: number;
43
+ tables: string[];
44
+ createdAt: string;
45
+ }
46
+ interface ViewDetail {
47
+ name: string;
48
+ version: string;
49
+ status: string;
50
+ lastProcessedBlock: number;
51
+ health: {
52
+ totalProcessed: number
53
+ totalErrors: number
54
+ errorRate: number
55
+ lastError: string | null
56
+ lastErrorAt: string | null
57
+ };
58
+ tables: Record<string, {
59
+ endpoint: string
60
+ columns: Record<string, string>
61
+ rowCount: number
62
+ example: string
63
+ }>;
64
+ createdAt: string;
65
+ updatedAt: string;
66
+ }
67
+ interface ReindexResponse {
68
+ message: string;
69
+ fromBlock: number;
70
+ toBlock: number | string;
71
+ }
72
+ interface ViewQueryParams {
73
+ sort?: string;
74
+ order?: string;
75
+ limit?: number;
76
+ offset?: number;
77
+ fields?: string;
78
+ filters?: Record<string, string>;
79
+ }
80
+ import { z as z3 } from "zod";
81
+ declare const StreamOptionsSchema: unknown;
82
+ declare const CreateStreamSchema: unknown;
83
+ declare const UpdateStreamSchema: unknown;
84
+ declare const WebhookPayloadSchema: unknown;
85
+ declare const StreamMetricsSchema: unknown;
86
+ declare const StreamResponseSchema: unknown;
87
+ type StreamOptions = z3.infer<typeof StreamOptionsSchema>;
88
+ type CreateStream = z3.infer<typeof CreateStreamSchema>;
89
+ type UpdateStream = z3.infer<typeof UpdateStreamSchema>;
90
+ type WebhookPayload = z3.infer<typeof WebhookPayloadSchema>;
91
+ type StreamResponse = z3.infer<typeof StreamResponseSchema>;
92
+ type StreamMetricsResponse = z3.infer<typeof StreamMetricsSchema>;
93
+ interface CreateStreamResponse {
94
+ stream: StreamResponse;
95
+ webhookSecret: string;
96
+ }
97
+ interface ListStreamsResponse {
98
+ streams: StreamResponse[];
99
+ total: number;
100
+ }
101
+ interface BulkPauseResponse {
102
+ paused: number;
103
+ streams: StreamResponse[];
104
+ }
105
+ interface BulkResumeResponse {
106
+ resumed: number;
107
+ streams: StreamResponse[];
108
+ }
109
+ export { WebhookPayloadSchema, WebhookPayload, ViewSummary, ViewQueryParams, ViewDetail, UpdateStreamSchema, UpdateStream, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, StreamResponseSchema, StreamResponse, StreamOptionsSchema, StreamOptions, StreamMetricsSchema, StreamMetricsResponse, StreamFilterSchema, StreamFilter, ReindexResponse, PrintEventFilterSchema, PrintEventFilter, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, ListStreamsResponse, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, DeployViewResponse, DeployViewRequestSchema, DeployViewRequest, CreateStreamSchema, CreateStreamResponse, CreateStream, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, BulkResumeResponse, BulkPauseResponse };
@@ -0,0 +1,228 @@
1
+ import { createRequire } from "node:module";
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true,
8
+ configurable: true,
9
+ set: (newValue) => all[name] = () => newValue
10
+ });
11
+ };
12
+
13
+ // src/schemas/filters.ts
14
+ import { z } from "zod";
15
+ import { validateStacksAddress } from "@stacks/transactions";
16
+ var stacksPrincipal = z.string().refine((val) => {
17
+ const parts = val.split(".");
18
+ if (parts.length > 2)
19
+ return false;
20
+ return validateStacksAddress(parts[0]);
21
+ }, "Invalid Stacks principal address");
22
+ var baseFilter = {
23
+ sender: stacksPrincipal.optional(),
24
+ recipient: stacksPrincipal.optional()
25
+ };
26
+ var StxTransferFilterSchema = z.object({
27
+ type: z.literal("stx_transfer"),
28
+ ...baseFilter,
29
+ minAmount: z.coerce.number().int().positive().optional(),
30
+ maxAmount: z.coerce.number().int().positive().optional()
31
+ });
32
+ var StxMintFilterSchema = z.object({
33
+ type: z.literal("stx_mint"),
34
+ recipient: stacksPrincipal.optional(),
35
+ minAmount: z.coerce.number().int().positive().optional()
36
+ });
37
+ var StxBurnFilterSchema = z.object({
38
+ type: z.literal("stx_burn"),
39
+ sender: stacksPrincipal.optional(),
40
+ minAmount: z.coerce.number().int().positive().optional()
41
+ });
42
+ var StxLockFilterSchema = z.object({
43
+ type: z.literal("stx_lock"),
44
+ lockedAddress: stacksPrincipal.optional(),
45
+ minAmount: z.coerce.number().int().positive().optional()
46
+ });
47
+ var FtTransferFilterSchema = z.object({
48
+ type: z.literal("ft_transfer"),
49
+ ...baseFilter,
50
+ assetIdentifier: z.string().optional(),
51
+ minAmount: z.coerce.number().int().positive().optional()
52
+ });
53
+ var FtMintFilterSchema = z.object({
54
+ type: z.literal("ft_mint"),
55
+ recipient: stacksPrincipal.optional(),
56
+ assetIdentifier: z.string().optional(),
57
+ minAmount: z.coerce.number().int().positive().optional()
58
+ });
59
+ var FtBurnFilterSchema = z.object({
60
+ type: z.literal("ft_burn"),
61
+ sender: stacksPrincipal.optional(),
62
+ assetIdentifier: z.string().optional(),
63
+ minAmount: z.coerce.number().int().positive().optional()
64
+ });
65
+ var NftTransferFilterSchema = z.object({
66
+ type: z.literal("nft_transfer"),
67
+ ...baseFilter,
68
+ assetIdentifier: z.string().optional(),
69
+ tokenId: z.string().optional()
70
+ });
71
+ var NftMintFilterSchema = z.object({
72
+ type: z.literal("nft_mint"),
73
+ recipient: stacksPrincipal.optional(),
74
+ assetIdentifier: z.string().optional(),
75
+ tokenId: z.string().optional()
76
+ });
77
+ var NftBurnFilterSchema = z.object({
78
+ type: z.literal("nft_burn"),
79
+ sender: stacksPrincipal.optional(),
80
+ assetIdentifier: z.string().optional(),
81
+ tokenId: z.string().optional()
82
+ });
83
+ var ContractCallFilterSchema = z.object({
84
+ type: z.literal("contract_call"),
85
+ contractId: stacksPrincipal.optional(),
86
+ functionName: z.string().optional(),
87
+ caller: stacksPrincipal.optional()
88
+ });
89
+ var ContractDeployFilterSchema = z.object({
90
+ type: z.literal("contract_deploy"),
91
+ deployer: stacksPrincipal.optional(),
92
+ contractName: z.string().optional()
93
+ });
94
+ var PrintEventFilterSchema = z.object({
95
+ type: z.literal("print_event"),
96
+ contractId: stacksPrincipal.optional(),
97
+ topic: z.string().optional(),
98
+ contains: z.string().optional()
99
+ });
100
+ var StreamFilterSchema = z.discriminatedUnion("type", [
101
+ StxTransferFilterSchema,
102
+ StxMintFilterSchema,
103
+ StxBurnFilterSchema,
104
+ StxLockFilterSchema,
105
+ FtTransferFilterSchema,
106
+ FtMintFilterSchema,
107
+ FtBurnFilterSchema,
108
+ NftTransferFilterSchema,
109
+ NftMintFilterSchema,
110
+ NftBurnFilterSchema,
111
+ ContractCallFilterSchema,
112
+ ContractDeployFilterSchema,
113
+ PrintEventFilterSchema
114
+ ]);
115
+
116
+ // src/schemas/views.ts
117
+ import { z as z2 } from "zod";
118
+ var DeployViewRequestSchema = z2.object({
119
+ name: z2.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
120
+ version: z2.string().optional(),
121
+ description: z2.string().optional(),
122
+ sources: z2.array(z2.string()).min(1),
123
+ schema: z2.record(z2.unknown()),
124
+ handlerCode: z2.string().max(1048576, "handler code exceeds 1MB limit"),
125
+ reindex: z2.boolean().optional()
126
+ });
127
+ // src/schemas/stream.ts
128
+ import { z as z3 } from "zod";
129
+ var StreamOptionsSchema = z3.object({
130
+ decodeClarityValues: z3.boolean().default(true),
131
+ includeRawTx: z3.boolean().default(false),
132
+ includeBlockMetadata: z3.boolean().default(true),
133
+ rateLimit: z3.number().int().positive().max(100).default(10),
134
+ timeoutMs: z3.number().int().positive().max(30000).default(1e4),
135
+ maxRetries: z3.number().int().min(0).max(10).default(3)
136
+ });
137
+ var CreateStreamSchema = z3.object({
138
+ name: z3.string().min(1).max(255),
139
+ webhookUrl: z3.string().url(),
140
+ filters: z3.array(StreamFilterSchema).min(1),
141
+ options: StreamOptionsSchema.optional().default({}),
142
+ startBlock: z3.number().int().positive().optional(),
143
+ endBlock: z3.number().int().positive().optional()
144
+ });
145
+ var UpdateStreamSchema = z3.object({
146
+ name: z3.string().min(1).max(255).optional(),
147
+ webhookUrl: z3.string().url().optional(),
148
+ filters: z3.array(StreamFilterSchema).min(1).optional(),
149
+ options: StreamOptionsSchema.partial().optional()
150
+ }).refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided for update" });
151
+ var WebhookPayloadSchema = z3.object({
152
+ streamId: z3.string().uuid(),
153
+ streamName: z3.string(),
154
+ block: z3.object({
155
+ height: z3.number(),
156
+ hash: z3.string(),
157
+ parentHash: z3.string(),
158
+ burnBlockHeight: z3.number(),
159
+ timestamp: z3.number()
160
+ }),
161
+ matches: z3.object({
162
+ transactions: z3.array(z3.object({
163
+ txId: z3.string(),
164
+ type: z3.string(),
165
+ sender: z3.string(),
166
+ status: z3.string(),
167
+ contractId: z3.string().nullable(),
168
+ functionName: z3.string().nullable(),
169
+ rawTx: z3.string().optional()
170
+ })),
171
+ events: z3.array(z3.object({
172
+ txId: z3.string(),
173
+ eventIndex: z3.number(),
174
+ type: z3.string(),
175
+ data: z3.any()
176
+ }))
177
+ }),
178
+ isBackfill: z3.boolean(),
179
+ deliveredAt: z3.string().datetime()
180
+ });
181
+ var StreamMetricsSchema = z3.object({
182
+ totalDeliveries: z3.number(),
183
+ failedDeliveries: z3.number(),
184
+ lastTriggeredAt: z3.string().datetime().nullable(),
185
+ lastTriggeredBlock: z3.number().nullable(),
186
+ errorMessage: z3.string().nullable()
187
+ });
188
+ var StreamResponseSchema = z3.object({
189
+ id: z3.string().uuid(),
190
+ name: z3.string(),
191
+ status: z3.enum(["inactive", "active", "paused", "failed"]),
192
+ webhookUrl: z3.string().url(),
193
+ filters: z3.array(StreamFilterSchema),
194
+ options: StreamOptionsSchema,
195
+ totalDeliveries: z3.number().int().default(0),
196
+ failedDeliveries: z3.number().int().default(0),
197
+ lastTriggeredAt: z3.string().datetime().nullable().optional(),
198
+ lastTriggeredBlock: z3.number().int().nullable().optional(),
199
+ errorMessage: z3.string().nullable().optional(),
200
+ createdAt: z3.string().datetime(),
201
+ updatedAt: z3.string().datetime()
202
+ });
203
+ export {
204
+ WebhookPayloadSchema,
205
+ UpdateStreamSchema,
206
+ StxTransferFilterSchema,
207
+ StxMintFilterSchema,
208
+ StxLockFilterSchema,
209
+ StxBurnFilterSchema,
210
+ StreamResponseSchema,
211
+ StreamOptionsSchema,
212
+ StreamMetricsSchema,
213
+ StreamFilterSchema,
214
+ PrintEventFilterSchema,
215
+ NftTransferFilterSchema,
216
+ NftMintFilterSchema,
217
+ NftBurnFilterSchema,
218
+ FtTransferFilterSchema,
219
+ FtMintFilterSchema,
220
+ FtBurnFilterSchema,
221
+ DeployViewRequestSchema,
222
+ CreateStreamSchema,
223
+ ContractDeployFilterSchema,
224
+ ContractCallFilterSchema
225
+ };
226
+
227
+ //# debugId=EA479B00948EBF4D64756E2164756E21
228
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/schemas/filters.ts", "../src/schemas/views.ts", "../src/schemas/stream.ts"],
4
+ "sourcesContent": [
5
+ "import { z } from \"zod\";\nimport { validateStacksAddress } from \"@stacks/transactions\";\n\n/** Validate a Stacks principal (standard or contract, e.g. SP2J...ABC or SP2J...ABC.contract-name) */\nconst stacksPrincipal = z.string().refine((val) => {\n const parts = val.split(\".\");\n if (parts.length > 2) return false;\n return validateStacksAddress(parts[0]!);\n}, \"Invalid Stacks principal address\");\n\n// Base filter with common fields\nconst baseFilter = {\n // Optional: filter by sender\n sender: stacksPrincipal.optional(),\n // Optional: filter by recipient\n recipient: stacksPrincipal.optional(),\n};\n\n// STX Transfer Filter\nexport const StxTransferFilterSchema = z.object({\n type: z.literal(\"stx_transfer\"),\n ...baseFilter,\n // Optional: minimum amount in microSTX\n minAmount: z.coerce.number().int().positive().optional(),\n // Optional: maximum amount in microSTX\n maxAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Mint Filter\nexport const StxMintFilterSchema = z.object({\n type: z.literal(\"stx_mint\"),\n recipient: stacksPrincipal.optional(),\n minAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Burn Filter\nexport const StxBurnFilterSchema = z.object({\n type: z.literal(\"stx_burn\"),\n sender: stacksPrincipal.optional(),\n minAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Lock Filter\nexport const StxLockFilterSchema = z.object({\n type: z.literal(\"stx_lock\"),\n lockedAddress: stacksPrincipal.optional(),\n minAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Transfer Filter\nexport const FtTransferFilterSchema = z.object({\n type: z.literal(\"ft_transfer\"),\n ...baseFilter,\n // Contract that defines the token (e.g., SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx)\n assetIdentifier: z.string().optional(),\n minAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Mint Filter\nexport const FtMintFilterSchema = z.object({\n type: z.literal(\"ft_mint\"),\n recipient: stacksPrincipal.optional(),\n assetIdentifier: z.string().optional(),\n minAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Burn Filter\nexport const FtBurnFilterSchema = z.object({\n type: z.literal(\"ft_burn\"),\n sender: stacksPrincipal.optional(),\n assetIdentifier: z.string().optional(),\n minAmount: z.coerce.number().int().positive().optional(),\n});\n\n// NFT Transfer Filter\nexport const NftTransferFilterSchema = z.object({\n type: z.literal(\"nft_transfer\"),\n ...baseFilter,\n assetIdentifier: z.string().optional(),\n // Optional: filter by specific token ID (Clarity value as hex)\n tokenId: z.string().optional(),\n});\n\n// NFT Mint Filter\nexport const NftMintFilterSchema = z.object({\n type: z.literal(\"nft_mint\"),\n recipient: stacksPrincipal.optional(),\n assetIdentifier: z.string().optional(),\n tokenId: z.string().optional(),\n});\n\n// NFT Burn Filter\nexport const NftBurnFilterSchema = z.object({\n type: z.literal(\"nft_burn\"),\n sender: stacksPrincipal.optional(),\n assetIdentifier: z.string().optional(),\n tokenId: z.string().optional(),\n});\n\n// Contract Call Filter\nexport const ContractCallFilterSchema = z.object({\n type: z.literal(\"contract_call\"),\n // Contract being called\n contractId: stacksPrincipal.optional(),\n // Function name (supports wildcards with *)\n functionName: z.string().optional(),\n // Caller address\n caller: stacksPrincipal.optional(),\n});\n\n// Contract Deploy Filter\nexport const ContractDeployFilterSchema = z.object({\n type: z.literal(\"contract_deploy\"),\n // Deployer address\n deployer: stacksPrincipal.optional(),\n // Contract name pattern (supports wildcards)\n contractName: z.string().optional(),\n});\n\n// Print Event Filter (smart contract events)\nexport const PrintEventFilterSchema = z.object({\n type: z.literal(\"print_event\"),\n // Contract emitting the event\n contractId: stacksPrincipal.optional(),\n // Topic/name of the event\n topic: z.string().optional(),\n // Search for substring in event data\n contains: z.string().optional(),\n});\n\n// Union of all filter types\nexport const StreamFilterSchema = z.discriminatedUnion(\"type\", [\n StxTransferFilterSchema,\n StxMintFilterSchema,\n StxBurnFilterSchema,\n StxLockFilterSchema,\n FtTransferFilterSchema,\n FtMintFilterSchema,\n FtBurnFilterSchema,\n NftTransferFilterSchema,\n NftMintFilterSchema,\n NftBurnFilterSchema,\n ContractCallFilterSchema,\n ContractDeployFilterSchema,\n PrintEventFilterSchema,\n]);\n\n// Type exports\nexport type StxTransferFilter = z.infer<typeof StxTransferFilterSchema>;\nexport type StxMintFilter = z.infer<typeof StxMintFilterSchema>;\nexport type StxBurnFilter = z.infer<typeof StxBurnFilterSchema>;\nexport type StxLockFilter = z.infer<typeof StxLockFilterSchema>;\nexport type FtTransferFilter = z.infer<typeof FtTransferFilterSchema>;\nexport type FtMintFilter = z.infer<typeof FtMintFilterSchema>;\nexport type FtBurnFilter = z.infer<typeof FtBurnFilterSchema>;\nexport type NftTransferFilter = z.infer<typeof NftTransferFilterSchema>;\nexport type NftMintFilter = z.infer<typeof NftMintFilterSchema>;\nexport type NftBurnFilter = z.infer<typeof NftBurnFilterSchema>;\nexport type ContractCallFilter = z.infer<typeof ContractCallFilterSchema>;\nexport type ContractDeployFilter = z.infer<typeof ContractDeployFilterSchema>;\nexport type PrintEventFilter = z.infer<typeof PrintEventFilterSchema>;\nexport type StreamFilter = z.infer<typeof StreamFilterSchema>;\n",
6
+ "import { z } from \"zod\";\n\n// ── Deploy View Request ─────────────────────────────────────────────────\n\nexport const DeployViewRequestSchema = z.object({\n name: z.string().regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\").max(63),\n version: z.string().optional(),\n description: z.string().optional(),\n sources: z.array(z.string()).min(1),\n schema: z.record(z.unknown()),\n handlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n reindex: z.boolean().optional(),\n});\n\nexport type DeployViewRequest = z.infer<typeof DeployViewRequestSchema>;\n\nexport interface DeployViewResponse {\n action: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\";\n viewId: string;\n message: string;\n}\n\n// View API response types\n\nexport interface ViewSummary {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n tables: string[];\n createdAt: string;\n}\n\nexport interface ViewDetail {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n health: {\n totalProcessed: number;\n totalErrors: number;\n errorRate: number;\n lastError: string | null;\n lastErrorAt: string | null;\n };\n tables: Record<string, {\n endpoint: string;\n columns: Record<string, string>;\n rowCount: number;\n example: string;\n }>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ReindexResponse {\n message: string;\n fromBlock: number;\n toBlock: number | string;\n}\n\nexport interface ViewQueryParams {\n sort?: string;\n order?: string;\n limit?: number;\n offset?: number;\n fields?: string;\n filters?: Record<string, string>;\n}\n",
7
+ "import { z } from \"zod\";\nimport { StreamFilterSchema } from \"./filters.ts\";\n\n// Stream options schema\nexport const StreamOptionsSchema = z.object({\n // Include decoded Clarity values in webhook payload\n decodeClarityValues: z.boolean().default(true),\n // Include raw transaction hex in payload\n includeRawTx: z.boolean().default(false),\n // Include full block metadata\n includeBlockMetadata: z.boolean().default(true),\n // Rate limit: max webhooks per second\n rateLimit: z.number().int().positive().max(100).default(10),\n // Timeout for webhook delivery in ms\n timeoutMs: z.number().int().positive().max(30000).default(10000),\n // Max retry attempts for failed webhooks\n maxRetries: z.number().int().min(0).max(10).default(3),\n});\n\n// Create stream schema\nexport const CreateStreamSchema = z.object({\n name: z.string().min(1).max(255),\n webhookUrl: z.string().url(),\n // At least one filter required\n filters: z.array(StreamFilterSchema).min(1),\n // Optional settings\n options: StreamOptionsSchema.optional().default({}),\n // Optional: start processing from specific block (for backfill)\n startBlock: z.number().int().positive().optional(),\n // Optional: stop processing at specific block\n endBlock: z.number().int().positive().optional(),\n});\n\n// Update stream schema (all fields optional)\nexport const UpdateStreamSchema = z.object({\n name: z.string().min(1).max(255).optional(),\n webhookUrl: z.string().url().optional(),\n filters: z.array(StreamFilterSchema).min(1).optional(),\n options: StreamOptionsSchema.partial().optional(),\n}).refine(\n (data) => Object.keys(data).length > 0,\n { message: \"At least one field must be provided for update\" }\n);\n\n// Webhook payload schema (what gets sent to the user's endpoint)\nexport const WebhookPayloadSchema = z.object({\n // Stream metadata\n streamId: z.string().uuid(),\n streamName: z.string(),\n\n // Block metadata\n block: z.object({\n height: z.number(),\n hash: z.string(),\n parentHash: z.string(),\n burnBlockHeight: z.number(),\n timestamp: z.number(),\n }),\n\n // Matched data\n matches: z.object({\n transactions: z.array(z.object({\n txId: z.string(),\n type: z.string(),\n sender: z.string(),\n status: z.string(),\n contractId: z.string().nullable(),\n functionName: z.string().nullable(),\n rawTx: z.string().optional(),\n })),\n events: z.array(z.object({\n txId: z.string(),\n eventIndex: z.number(),\n type: z.string(),\n data: z.any(),\n })),\n }),\n\n // Metadata\n isBackfill: z.boolean(),\n deliveredAt: z.string().datetime(),\n});\n\n// Stream response schema (what API returns)\n// Stream metrics schema\nexport const StreamMetricsSchema = z.object({\n totalDeliveries: z.number(),\n failedDeliveries: z.number(),\n lastTriggeredAt: z.string().datetime().nullable(),\n lastTriggeredBlock: z.number().nullable(),\n errorMessage: z.string().nullable(),\n});\n\n// Stream response schema (what API returns)\nexport const StreamResponseSchema = z.object({\n id: z.string().uuid(),\n name: z.string(),\n status: z.enum([\"inactive\", \"active\", \"paused\", \"failed\"]),\n webhookUrl: z.string().url(),\n filters: z.array(StreamFilterSchema),\n options: StreamOptionsSchema,\n\n // Metrics (joined from stream_metrics)\n totalDeliveries: z.number().int().default(0),\n failedDeliveries: z.number().int().default(0),\n lastTriggeredAt: z.string().datetime().nullable().optional(),\n lastTriggeredBlock: z.number().int().nullable().optional(),\n errorMessage: z.string().nullable().optional(),\n\n createdAt: z.string().datetime(),\n updatedAt: z.string().datetime(),\n});\n\n// Type exports\nexport type StreamOptions = z.infer<typeof StreamOptionsSchema>;\nexport type CreateStream = z.infer<typeof CreateStreamSchema>;\nexport type UpdateStream = z.infer<typeof UpdateStreamSchema>;\nexport type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;\nexport type StreamResponse = z.infer<typeof StreamResponseSchema>;\nexport type StreamMetricsResponse = z.infer<typeof StreamMetricsSchema>;\n\n// API response types\nexport interface CreateStreamResponse {\n stream: StreamResponse;\n webhookSecret: string;\n}\n\nexport interface ListStreamsResponse {\n streams: StreamResponse[];\n total: number;\n}\n\nexport interface BulkPauseResponse {\n paused: number;\n streams: StreamResponse[];\n}\n\nexport interface BulkResumeResponse {\n resumed: number;\n streams: StreamResponse[];\n}\n"
8
+ ],
9
+ "mappings": ";;;;;;;;;;;;;AAAA;AACA;AAGA,IAAM,kBAAkB,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ;AAAA,EACjD,MAAM,QAAQ,IAAI,MAAM,GAAG;AAAA,EAC3B,IAAI,MAAM,SAAS;AAAA,IAAG,OAAO;AAAA,EAC7B,OAAO,sBAAsB,MAAM,EAAG;AAAA,GACrC,kCAAkC;AAGrC,IAAM,aAAa;AAAA,EAEjB,QAAQ,gBAAgB,SAAS;AAAA,EAEjC,WAAW,gBAAgB,SAAS;AACtC;AAGO,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,MAAM,EAAE,QAAQ,cAAc;AAAA,KAC3B;AAAA,EAEH,WAAW,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE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AAc,GAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAE7C,WAAW,GAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,WAAW,GAAE,OAAO,EAAE,SAAS;AACjC,CAAC;",
10
+ "debugId": "EA479B00948EBF4D64756E2164756E21",
11
+ "names": []
12
+ }
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ declare const DeployViewRequestSchema: unknown;
3
+ type DeployViewRequest = z.infer<typeof DeployViewRequestSchema>;
4
+ interface DeployViewResponse {
5
+ action: "created" | "unchanged" | "updated" | "reindexed";
6
+ viewId: string;
7
+ message: string;
8
+ }
9
+ interface ViewSummary {
10
+ name: string;
11
+ version: string;
12
+ status: string;
13
+ lastProcessedBlock: number;
14
+ tables: string[];
15
+ createdAt: string;
16
+ }
17
+ interface ViewDetail {
18
+ name: string;
19
+ version: string;
20
+ status: string;
21
+ lastProcessedBlock: number;
22
+ health: {
23
+ totalProcessed: number
24
+ totalErrors: number
25
+ errorRate: number
26
+ lastError: string | null
27
+ lastErrorAt: string | null
28
+ };
29
+ tables: Record<string, {
30
+ endpoint: string
31
+ columns: Record<string, string>
32
+ rowCount: number
33
+ example: string
34
+ }>;
35
+ createdAt: string;
36
+ updatedAt: string;
37
+ }
38
+ interface ReindexResponse {
39
+ message: string;
40
+ fromBlock: number;
41
+ toBlock: number | string;
42
+ }
43
+ interface ViewQueryParams {
44
+ sort?: string;
45
+ order?: string;
46
+ limit?: number;
47
+ offset?: number;
48
+ fields?: string;
49
+ filters?: Record<string, string>;
50
+ }
51
+ export { ViewSummary, ViewQueryParams, ViewDetail, ReindexResponse, DeployViewResponse, DeployViewRequestSchema, DeployViewRequest };
@@ -0,0 +1,29 @@
1
+ import { createRequire } from "node:module";
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true,
8
+ configurable: true,
9
+ set: (newValue) => all[name] = () => newValue
10
+ });
11
+ };
12
+
13
+ // src/schemas/views.ts
14
+ import { z } from "zod";
15
+ var DeployViewRequestSchema = z.object({
16
+ name: z.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
17
+ version: z.string().optional(),
18
+ description: z.string().optional(),
19
+ sources: z.array(z.string()).min(1),
20
+ schema: z.record(z.unknown()),
21
+ handlerCode: z.string().max(1048576, "handler code exceeds 1MB limit"),
22
+ reindex: z.boolean().optional()
23
+ });
24
+ export {
25
+ DeployViewRequestSchema
26
+ };
27
+
28
+ //# debugId=F7D47497A7667C0064756E2164756E21
29
+ //# sourceMappingURL=views.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/schemas/views.ts"],
4
+ "sourcesContent": [
5
+ "import { z } from \"zod\";\n\n// ── Deploy View Request ─────────────────────────────────────────────────\n\nexport const DeployViewRequestSchema = z.object({\n name: z.string().regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\").max(63),\n version: z.string().optional(),\n description: z.string().optional(),\n sources: z.array(z.string()).min(1),\n schema: z.record(z.unknown()),\n handlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n reindex: z.boolean().optional(),\n});\n\nexport type DeployViewRequest = z.infer<typeof DeployViewRequestSchema>;\n\nexport interface DeployViewResponse {\n action: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\";\n viewId: string;\n message: string;\n}\n\n// View API response types\n\nexport interface ViewSummary {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n tables: string[];\n createdAt: string;\n}\n\nexport interface ViewDetail {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n health: {\n totalProcessed: number;\n totalErrors: number;\n errorRate: number;\n lastError: string | null;\n lastErrorAt: string | null;\n };\n tables: Record<string, {\n endpoint: string;\n columns: Record<string, string>;\n rowCount: number;\n example: string;\n }>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ReindexResponse {\n message: string;\n fromBlock: number;\n toBlock: number | string;\n}\n\nexport interface ViewQueryParams {\n sort?: string;\n order?: string;\n limit?: number;\n offset?: number;\n fields?: string;\n filters?: Record<string, string>;\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;AAAA;AAIO,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,uCAAuC,EAAE,IAAI,EAAE;AAAA,EACtF,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC;AAAA,EAClC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EAC5B,aAAa,EAAE,OAAO,EAAE,IAAI,SAAW,gCAAgC;AAAA,EACvE,SAAS,EAAE,QAAQ,EAAE,SAAS;AAChC,CAAC;",
8
+ "debugId": "F7D47497A7667C0064756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,102 @@
1
+ import { Generated, Insertable, Selectable } from "kysely";
2
+ interface BlocksTable {
3
+ height: number;
4
+ hash: string;
5
+ parent_hash: string;
6
+ burn_block_height: number;
7
+ timestamp: number;
8
+ canonical: Generated<boolean>;
9
+ created_at: Generated<Date>;
10
+ }
11
+ interface TransactionsTable {
12
+ tx_id: string;
13
+ block_height: number;
14
+ type: string;
15
+ sender: string;
16
+ status: string;
17
+ contract_id: string | null;
18
+ function_name: string | null;
19
+ raw_tx: string;
20
+ created_at: Generated<Date>;
21
+ }
22
+ interface EventsTable {
23
+ id: Generated<string>;
24
+ tx_id: string;
25
+ block_height: number;
26
+ event_index: number;
27
+ type: string;
28
+ data: unknown;
29
+ created_at: Generated<Date>;
30
+ }
31
+ interface StreamsTable {
32
+ id: Generated<string>;
33
+ name: string;
34
+ status: Generated<string>;
35
+ filters: unknown;
36
+ options: Generated<unknown>;
37
+ webhook_url: string;
38
+ webhook_secret: string | null;
39
+ api_key_id: string | null;
40
+ created_at: Generated<Date>;
41
+ updated_at: Generated<Date>;
42
+ }
43
+ interface JobsTable {
44
+ id: Generated<string>;
45
+ stream_id: string;
46
+ block_height: number;
47
+ status: Generated<string>;
48
+ attempts: Generated<number>;
49
+ locked_at: Date | null;
50
+ locked_by: string | null;
51
+ error: string | null;
52
+ backfill: Generated<boolean>;
53
+ created_at: Generated<Date>;
54
+ completed_at: Date | null;
55
+ }
56
+ interface IndexProgressTable {
57
+ network: string;
58
+ last_indexed_block: Generated<number>;
59
+ last_contiguous_block: Generated<number>;
60
+ highest_seen_block: Generated<number>;
61
+ updated_at: Generated<Date>;
62
+ }
63
+ interface DeliveriesTable {
64
+ id: Generated<string>;
65
+ stream_id: string;
66
+ job_id: string | null;
67
+ block_height: number;
68
+ status: string;
69
+ status_code: number | null;
70
+ response_time_ms: number | null;
71
+ attempts: Generated<number>;
72
+ error: string | null;
73
+ payload: unknown;
74
+ created_at: Generated<Date>;
75
+ }
76
+ type Block = Selectable<BlocksTable>;
77
+ type InsertBlock = Insertable<BlocksTable>;
78
+ type Transaction = Selectable<TransactionsTable>;
79
+ type InsertTransaction = Insertable<TransactionsTable>;
80
+ type Event = Selectable<EventsTable>;
81
+ type InsertEvent = Insertable<EventsTable>;
82
+ type Stream = Selectable<StreamsTable>;
83
+ type InsertStream = Insertable<StreamsTable>;
84
+ type Job = Selectable<JobsTable>;
85
+ type InsertJob = Insertable<JobsTable>;
86
+ type IndexProgress = Selectable<IndexProgressTable>;
87
+ type InsertIndexProgress = Insertable<IndexProgressTable>;
88
+ type Delivery = Selectable<DeliveriesTable>;
89
+ type InsertDelivery = Insertable<DeliveriesTable>;
90
+ import { z } from "zod";
91
+ declare const envSchema: unknown;
92
+ type Env = z.infer<typeof envSchema> & {
93
+ enabledNetworks: ("mainnet" | "testnet")[]
94
+ };
95
+ interface QueueStats {
96
+ pending: number;
97
+ processing: number;
98
+ completed: number;
99
+ failed: number;
100
+ total: number;
101
+ }
102
+ export { Transaction, Stream, QueueStats, Job, InsertTransaction, InsertStream, InsertJob, InsertIndexProgress, InsertEvent, InsertDelivery, InsertBlock, IndexProgress, Event, Env, Delivery, Block };
@@ -0,0 +1,3 @@
1
+
2
+ //# debugId=F2B76011AEAE140064756E2164756E21
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "F2B76011AEAE140064756E2164756E21",
8
+ "names": []
9
+ }