@secondlayer/shared 0.4.0 → 0.5.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.
- package/dist/src/crypto/hmac.d.ts +1 -1
- package/dist/src/crypto/hmac.js +6 -2
- package/dist/src/crypto/hmac.js.map +3 -3
- package/dist/src/db/index.d.ts +85 -8
- package/dist/src/db/index.js +6 -2
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/jsonb.js +6 -2
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/accounts.d.ts +77 -5
- package/dist/src/db/queries/accounts.js +17 -2
- package/dist/src/db/queries/accounts.js.map +3 -3
- package/dist/src/db/queries/integrity.d.ts +75 -4
- package/dist/src/db/queries/integrity.js +6 -2
- package/dist/src/db/queries/integrity.js.map +2 -2
- package/dist/src/db/queries/metrics.d.ts +75 -4
- package/dist/src/db/queries/metrics.js +6 -2
- package/dist/src/db/queries/metrics.js.map +2 -2
- package/dist/src/db/queries/{views.d.ts → subgraphs.d.ts} +89 -18
- package/dist/src/db/queries/{views.js → subgraphs.js} +37 -33
- package/dist/src/db/queries/subgraphs.js.map +11 -0
- package/dist/src/db/queries/usage.d.ts +78 -7
- package/dist/src/db/queries/usage.js +13 -9
- package/dist/src/db/queries/usage.js.map +4 -4
- package/dist/src/db/schema.d.ts +85 -8
- package/dist/src/env.d.ts +1 -1
- package/dist/src/env.js +8 -4
- package/dist/src/env.js.map +3 -3
- package/dist/src/errors.d.ts +3 -3
- package/dist/src/errors.js +9 -5
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index.d.ts +104 -27
- package/dist/src/index.js +24 -20
- package/dist/src/index.js.map +9 -9
- package/dist/src/lib/plans.d.ts +1 -1
- package/dist/src/lib/plans.js +7 -3
- package/dist/src/lib/plans.js.map +3 -3
- package/dist/src/logger.js +8 -4
- package/dist/src/logger.js.map +3 -3
- package/dist/src/node/client.js +6 -2
- package/dist/src/node/client.js.map +2 -2
- package/dist/src/node/hiro-client.js +8 -4
- package/dist/src/node/hiro-client.js.map +3 -3
- package/dist/src/node/local-client.d.ts +75 -4
- package/dist/src/node/local-client.js +6 -2
- package/dist/src/node/local-client.js.map +3 -3
- package/dist/src/queue/index.js +6 -2
- package/dist/src/queue/index.js.map +2 -2
- package/dist/src/queue/listener.js +6 -2
- package/dist/src/queue/listener.js.map +2 -2
- package/dist/src/queue/recovery.js +6 -2
- package/dist/src/queue/recovery.js.map +2 -2
- package/dist/src/schemas/filters.d.ts +1 -1
- package/dist/src/schemas/filters.js +7 -3
- package/dist/src/schemas/filters.js.map +3 -3
- package/dist/src/schemas/index.d.ts +17 -17
- package/dist/src/schemas/index.js +19 -15
- package/dist/src/schemas/index.js.map +6 -6
- package/dist/src/schemas/{views.d.ts → subgraphs.d.ts} +9 -9
- package/dist/src/schemas/{views.js → subgraphs.js} +12 -8
- package/dist/src/schemas/subgraphs.js.map +10 -0
- package/dist/src/types.d.ts +2 -2
- package/dist/src/types.js +1 -12
- package/dist/src/types.js.map +1 -1
- package/migrations/0009_waitlist.ts +19 -0
- package/migrations/0010_waitlist_status.ts +12 -0
- package/migrations/0011_account_insights.ts +63 -0
- package/migrations/0012_view_health_snapshots.ts +29 -0
- package/migrations/0013_view_processing_stats.ts +42 -0
- package/migrations/0014_view_table_snapshots.ts +33 -0
- package/migrations/0015_rename_views_to_subgraphs.ts +136 -0
- package/migrations/0016_rename_webhook_to_endpoint.ts +12 -0
- package/package.json +8 -8
- package/dist/src/db/queries/views.js.map +0 -11
- package/dist/src/schemas/views.js.map +0 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
2
|
interface StxTransferFilter {
|
|
3
3
|
type: "stx_transfer";
|
|
4
4
|
sender?: string;
|
|
@@ -91,8 +91,8 @@ declare const ContractCallFilterSchema: z.ZodType<ContractCallFilter>;
|
|
|
91
91
|
declare const ContractDeployFilterSchema: z.ZodType<ContractDeployFilter>;
|
|
92
92
|
declare const PrintEventFilterSchema: z.ZodType<PrintEventFilter>;
|
|
93
93
|
declare const StreamFilterSchema: z.ZodType<StreamFilter>;
|
|
94
|
-
import { z as z2 } from "zod";
|
|
95
|
-
interface
|
|
94
|
+
import { z as z2 } from "zod/v4";
|
|
95
|
+
interface DeploySubgraphRequest {
|
|
96
96
|
name: string;
|
|
97
97
|
version?: string;
|
|
98
98
|
description?: string;
|
|
@@ -101,13 +101,13 @@ interface DeployViewRequest {
|
|
|
101
101
|
handlerCode: string;
|
|
102
102
|
reindex?: boolean;
|
|
103
103
|
}
|
|
104
|
-
declare const
|
|
105
|
-
interface
|
|
104
|
+
declare const DeploySubgraphRequestSchema: z2.ZodType<DeploySubgraphRequest>;
|
|
105
|
+
interface DeploySubgraphResponse {
|
|
106
106
|
action: "created" | "unchanged" | "updated" | "reindexed";
|
|
107
|
-
|
|
107
|
+
subgraphId: string;
|
|
108
108
|
message: string;
|
|
109
109
|
}
|
|
110
|
-
interface
|
|
110
|
+
interface SubgraphSummary {
|
|
111
111
|
name: string;
|
|
112
112
|
version: string;
|
|
113
113
|
status: string;
|
|
@@ -115,7 +115,7 @@ interface ViewSummary {
|
|
|
115
115
|
tables: string[];
|
|
116
116
|
createdAt: string;
|
|
117
117
|
}
|
|
118
|
-
interface
|
|
118
|
+
interface SubgraphDetail {
|
|
119
119
|
name: string;
|
|
120
120
|
version: string;
|
|
121
121
|
status: string;
|
|
@@ -144,7 +144,7 @@ interface ReindexResponse {
|
|
|
144
144
|
fromBlock: number;
|
|
145
145
|
toBlock: number | string;
|
|
146
146
|
}
|
|
147
|
-
interface
|
|
147
|
+
interface SubgraphQueryParams {
|
|
148
148
|
sort?: string;
|
|
149
149
|
order?: string;
|
|
150
150
|
limit?: number;
|
|
@@ -152,7 +152,7 @@ interface ViewQueryParams {
|
|
|
152
152
|
fields?: string;
|
|
153
153
|
filters?: Record<string, string>;
|
|
154
154
|
}
|
|
155
|
-
import { z as z3 } from "zod";
|
|
155
|
+
import { z as z3 } from "zod/v4";
|
|
156
156
|
interface StreamOptions {
|
|
157
157
|
decodeClarityValues: boolean;
|
|
158
158
|
includeRawTx: boolean;
|
|
@@ -163,7 +163,7 @@ interface StreamOptions {
|
|
|
163
163
|
}
|
|
164
164
|
interface CreateStream {
|
|
165
165
|
name: string;
|
|
166
|
-
|
|
166
|
+
endpointUrl: string;
|
|
167
167
|
filters: StreamFilter[];
|
|
168
168
|
options?: StreamOptions;
|
|
169
169
|
startBlock?: number;
|
|
@@ -171,11 +171,11 @@ interface CreateStream {
|
|
|
171
171
|
}
|
|
172
172
|
interface UpdateStream {
|
|
173
173
|
name?: string;
|
|
174
|
-
|
|
174
|
+
endpointUrl?: string;
|
|
175
175
|
filters?: StreamFilter[];
|
|
176
176
|
options?: Partial<StreamOptions>;
|
|
177
177
|
}
|
|
178
|
-
interface
|
|
178
|
+
interface DeliveryPayload {
|
|
179
179
|
streamId: string;
|
|
180
180
|
streamName: string;
|
|
181
181
|
block: {
|
|
@@ -216,7 +216,7 @@ interface StreamResponse {
|
|
|
216
216
|
id: string;
|
|
217
217
|
name: string;
|
|
218
218
|
status: "inactive" | "active" | "paused" | "failed";
|
|
219
|
-
|
|
219
|
+
endpointUrl: string;
|
|
220
220
|
filters: StreamFilter[];
|
|
221
221
|
options: StreamOptions;
|
|
222
222
|
totalDeliveries: number;
|
|
@@ -230,12 +230,12 @@ interface StreamResponse {
|
|
|
230
230
|
declare const StreamOptionsSchema: z3.ZodType<StreamOptions>;
|
|
231
231
|
declare const CreateStreamSchema: z3.ZodType<CreateStream>;
|
|
232
232
|
declare const UpdateStreamSchema: z3.ZodType<UpdateStream>;
|
|
233
|
-
declare const
|
|
233
|
+
declare const DeliveryPayloadSchema: z3.ZodType<DeliveryPayload>;
|
|
234
234
|
declare const StreamMetricsSchema: z3.ZodType<StreamMetricsResponse>;
|
|
235
235
|
declare const StreamResponseSchema: z3.ZodType<StreamResponse>;
|
|
236
236
|
interface CreateStreamResponse {
|
|
237
237
|
stream: StreamResponse;
|
|
238
|
-
|
|
238
|
+
signingSecret: string;
|
|
239
239
|
}
|
|
240
240
|
interface ListStreamsResponse {
|
|
241
241
|
streams: StreamResponse[];
|
|
@@ -249,4 +249,4 @@ interface BulkResumeResponse {
|
|
|
249
249
|
resumed: number;
|
|
250
250
|
streams: StreamResponse[];
|
|
251
251
|
}
|
|
252
|
-
export {
|
|
252
|
+
export { UpdateStreamSchema, UpdateStream, SubgraphSummary, SubgraphQueryParams, SubgraphDetail, 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, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryPayloadSchema, DeliveryPayload, CreateStreamSchema, CreateStreamResponse, CreateStream, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, BulkResumeResponse, BulkPauseResponse };
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
3
7
|
var __export = (target, all) => {
|
|
4
8
|
for (var name in all)
|
|
5
9
|
__defProp(target, name, {
|
|
6
10
|
get: all[name],
|
|
7
11
|
enumerable: true,
|
|
8
12
|
configurable: true,
|
|
9
|
-
set: (
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
10
14
|
});
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
// src/schemas/filters.ts
|
|
14
|
-
import { z } from "zod";
|
|
18
|
+
import { z } from "zod/v4";
|
|
15
19
|
import { isValidAddress as _isValidAddress } from "@secondlayer/stacks";
|
|
16
20
|
var isValidAddress = _isValidAddress;
|
|
17
21
|
var stacksPrincipal = z.string().refine((val) => {
|
|
@@ -114,19 +118,19 @@ var StreamFilterSchema = z.discriminatedUnion("type", [
|
|
|
114
118
|
PrintEventFilterSchema
|
|
115
119
|
]);
|
|
116
120
|
|
|
117
|
-
// src/schemas/
|
|
118
|
-
import { z as z2 } from "zod";
|
|
119
|
-
var
|
|
121
|
+
// src/schemas/subgraphs.ts
|
|
122
|
+
import { z as z2 } from "zod/v4";
|
|
123
|
+
var DeploySubgraphRequestSchema = z2.object({
|
|
120
124
|
name: z2.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
|
|
121
125
|
version: z2.string().optional(),
|
|
122
126
|
description: z2.string().optional(),
|
|
123
127
|
sources: z2.array(z2.string()).min(1),
|
|
124
|
-
schema: z2.record(z2.unknown()),
|
|
128
|
+
schema: z2.record(z2.string(), z2.unknown()),
|
|
125
129
|
handlerCode: z2.string().max(1048576, "handler code exceeds 1MB limit"),
|
|
126
130
|
reindex: z2.boolean().optional()
|
|
127
131
|
});
|
|
128
132
|
// src/schemas/stream.ts
|
|
129
|
-
import { z as z3 } from "zod";
|
|
133
|
+
import { z as z3 } from "zod/v4";
|
|
130
134
|
var streamOptionsShape = z3.object({
|
|
131
135
|
decodeClarityValues: z3.boolean().default(true),
|
|
132
136
|
includeRawTx: z3.boolean().default(false),
|
|
@@ -138,19 +142,19 @@ var streamOptionsShape = z3.object({
|
|
|
138
142
|
var StreamOptionsSchema = streamOptionsShape;
|
|
139
143
|
var CreateStreamSchema = z3.object({
|
|
140
144
|
name: z3.string().min(1).max(255),
|
|
141
|
-
|
|
145
|
+
endpointUrl: z3.string().url(),
|
|
142
146
|
filters: z3.array(StreamFilterSchema).min(1),
|
|
143
|
-
options: streamOptionsShape.optional().default(
|
|
147
|
+
options: streamOptionsShape.optional().default(undefined),
|
|
144
148
|
startBlock: z3.number().int().positive().optional(),
|
|
145
149
|
endBlock: z3.number().int().positive().optional()
|
|
146
150
|
});
|
|
147
151
|
var UpdateStreamSchema = z3.object({
|
|
148
152
|
name: z3.string().min(1).max(255).optional(),
|
|
149
|
-
|
|
153
|
+
endpointUrl: z3.string().url().optional(),
|
|
150
154
|
filters: z3.array(StreamFilterSchema).min(1).optional(),
|
|
151
155
|
options: streamOptionsShape.partial().optional()
|
|
152
156
|
}).refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided for update" });
|
|
153
|
-
var
|
|
157
|
+
var DeliveryPayloadSchema = z3.object({
|
|
154
158
|
streamId: z3.string().uuid(),
|
|
155
159
|
streamName: z3.string(),
|
|
156
160
|
block: z3.object({
|
|
@@ -191,7 +195,7 @@ var StreamResponseSchema = z3.object({
|
|
|
191
195
|
id: z3.string().uuid(),
|
|
192
196
|
name: z3.string(),
|
|
193
197
|
status: z3.enum(["inactive", "active", "paused", "failed"]),
|
|
194
|
-
|
|
198
|
+
endpointUrl: z3.string().url(),
|
|
195
199
|
filters: z3.array(StreamFilterSchema),
|
|
196
200
|
options: streamOptionsShape,
|
|
197
201
|
totalDeliveries: z3.number().int().default(0),
|
|
@@ -203,7 +207,6 @@ var StreamResponseSchema = z3.object({
|
|
|
203
207
|
updatedAt: z3.string().datetime()
|
|
204
208
|
});
|
|
205
209
|
export {
|
|
206
|
-
WebhookPayloadSchema,
|
|
207
210
|
UpdateStreamSchema,
|
|
208
211
|
StxTransferFilterSchema,
|
|
209
212
|
StxMintFilterSchema,
|
|
@@ -220,11 +223,12 @@ export {
|
|
|
220
223
|
FtTransferFilterSchema,
|
|
221
224
|
FtMintFilterSchema,
|
|
222
225
|
FtBurnFilterSchema,
|
|
223
|
-
|
|
226
|
+
DeploySubgraphRequestSchema,
|
|
227
|
+
DeliveryPayloadSchema,
|
|
224
228
|
CreateStreamSchema,
|
|
225
229
|
ContractDeployFilterSchema,
|
|
226
230
|
ContractCallFilterSchema
|
|
227
231
|
};
|
|
228
232
|
|
|
229
|
-
//# debugId=
|
|
233
|
+
//# debugId=6E87BC7BC360F10E64756E2164756E21
|
|
230
234
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/schemas/filters.ts", "../src/schemas/
|
|
3
|
+
"sources": ["../src/schemas/filters.ts", "../src/schemas/subgraphs.ts", "../src/schemas/stream.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { z } from \"zod\";\nimport { isValidAddress as _isValidAddress } from \"@secondlayer/stacks\";\n\nconst isValidAddress = _isValidAddress as (addr: string) => boolean;\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 isValidAddress(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// Type exports — defined first so they can annotate schemas\nexport interface StxTransferFilter {\n type: \"stx_transfer\";\n sender?: string;\n recipient?: string;\n minAmount?: number;\n maxAmount?: number;\n}\n\nexport interface StxMintFilter {\n type: \"stx_mint\";\n recipient?: string;\n minAmount?: number;\n}\n\nexport interface StxBurnFilter {\n type: \"stx_burn\";\n sender?: string;\n minAmount?: number;\n}\n\nexport interface StxLockFilter {\n type: \"stx_lock\";\n lockedAddress?: string;\n minAmount?: number;\n}\n\nexport interface FtTransferFilter {\n type: \"ft_transfer\";\n sender?: string;\n recipient?: string;\n assetIdentifier?: string;\n minAmount?: number;\n}\n\nexport interface FtMintFilter {\n type: \"ft_mint\";\n recipient?: string;\n assetIdentifier?: string;\n minAmount?: number;\n}\n\nexport interface FtBurnFilter {\n type: \"ft_burn\";\n sender?: string;\n assetIdentifier?: string;\n minAmount?: number;\n}\n\nexport interface NftTransferFilter {\n type: \"nft_transfer\";\n sender?: string;\n recipient?: string;\n assetIdentifier?: string;\n tokenId?: string;\n}\n\nexport interface NftMintFilter {\n type: \"nft_mint\";\n recipient?: string;\n assetIdentifier?: string;\n tokenId?: string;\n}\n\nexport interface NftBurnFilter {\n type: \"nft_burn\";\n sender?: string;\n assetIdentifier?: string;\n tokenId?: string;\n}\n\nexport interface ContractCallFilter {\n type: \"contract_call\";\n contractId?: string;\n functionName?: string;\n caller?: string;\n}\n\nexport interface ContractDeployFilter {\n type: \"contract_deploy\";\n deployer?: string;\n contractName?: string;\n}\n\nexport interface PrintEventFilter {\n type: \"print_event\";\n contractId?: string;\n topic?: string;\n contains?: string;\n}\n\nexport type StreamFilter =\n | StxTransferFilter\n | StxMintFilter\n | StxBurnFilter\n | StxLockFilter\n | FtTransferFilter\n | FtMintFilter\n | FtBurnFilter\n | NftTransferFilter\n | NftMintFilter\n | NftBurnFilter\n | ContractCallFilter\n | ContractDeployFilter\n | PrintEventFilter;\n\n// STX Transfer Filter\nexport const StxTransferFilterSchema: z.ZodType<StxTransferFilter> = 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.ZodType<StxMintFilter> = 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.ZodType<StxBurnFilter> = 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.ZodType<StxLockFilter> = 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.ZodType<FtTransferFilter> = 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.ZodType<FtMintFilter> = 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.ZodType<FtBurnFilter> = 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.ZodType<NftTransferFilter> = 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.ZodType<NftMintFilter> = 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.ZodType<NftBurnFilter> = 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.ZodType<ContractCallFilter> = 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.ZodType<ContractDeployFilter> = 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.ZodType<PrintEventFilter> = 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.ZodType<StreamFilter> = z.discriminatedUnion(\"type\", [\n StxTransferFilterSchema as
|
|
6
|
-
"import { z } from \"zod\";\n\n// ── Deploy
|
|
7
|
-
"import { z } from \"zod\";\nimport { StreamFilterSchema, type StreamFilter } from \"./filters.ts\";\n\n// ── Type interfaces ──────────────────────────────────────────────────\n\nexport interface StreamOptions {\n decodeClarityValues: boolean;\n includeRawTx: boolean;\n includeBlockMetadata: boolean;\n rateLimit: number;\n timeoutMs: number;\n maxRetries: number;\n}\n\nexport interface CreateStream {\n name: string;\n
|
|
5
|
+
"import { z } from \"zod/v4\";\nimport { isValidAddress as _isValidAddress } from \"@secondlayer/stacks\";\n\nconst isValidAddress = _isValidAddress as (addr: string) => boolean;\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 isValidAddress(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// Type exports — defined first so they can annotate schemas\nexport interface StxTransferFilter {\n type: \"stx_transfer\";\n sender?: string;\n recipient?: string;\n minAmount?: number;\n maxAmount?: number;\n}\n\nexport interface StxMintFilter {\n type: \"stx_mint\";\n recipient?: string;\n minAmount?: number;\n}\n\nexport interface StxBurnFilter {\n type: \"stx_burn\";\n sender?: string;\n minAmount?: number;\n}\n\nexport interface StxLockFilter {\n type: \"stx_lock\";\n lockedAddress?: string;\n minAmount?: number;\n}\n\nexport interface FtTransferFilter {\n type: \"ft_transfer\";\n sender?: string;\n recipient?: string;\n assetIdentifier?: string;\n minAmount?: number;\n}\n\nexport interface FtMintFilter {\n type: \"ft_mint\";\n recipient?: string;\n assetIdentifier?: string;\n minAmount?: number;\n}\n\nexport interface FtBurnFilter {\n type: \"ft_burn\";\n sender?: string;\n assetIdentifier?: string;\n minAmount?: number;\n}\n\nexport interface NftTransferFilter {\n type: \"nft_transfer\";\n sender?: string;\n recipient?: string;\n assetIdentifier?: string;\n tokenId?: string;\n}\n\nexport interface NftMintFilter {\n type: \"nft_mint\";\n recipient?: string;\n assetIdentifier?: string;\n tokenId?: string;\n}\n\nexport interface NftBurnFilter {\n type: \"nft_burn\";\n sender?: string;\n assetIdentifier?: string;\n tokenId?: string;\n}\n\nexport interface ContractCallFilter {\n type: \"contract_call\";\n contractId?: string;\n functionName?: string;\n caller?: string;\n}\n\nexport interface ContractDeployFilter {\n type: \"contract_deploy\";\n deployer?: string;\n contractName?: string;\n}\n\nexport interface PrintEventFilter {\n type: \"print_event\";\n contractId?: string;\n topic?: string;\n contains?: string;\n}\n\nexport type StreamFilter =\n | StxTransferFilter\n | StxMintFilter\n | StxBurnFilter\n | StxLockFilter\n | FtTransferFilter\n | FtMintFilter\n | FtBurnFilter\n | NftTransferFilter\n | NftMintFilter\n | NftBurnFilter\n | ContractCallFilter\n | ContractDeployFilter\n | PrintEventFilter;\n\n// STX Transfer Filter\nexport const StxTransferFilterSchema: z.ZodType<StxTransferFilter> = 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.ZodType<StxMintFilter> = 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.ZodType<StxBurnFilter> = 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.ZodType<StxLockFilter> = 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.ZodType<FtTransferFilter> = 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.ZodType<FtMintFilter> = 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.ZodType<FtBurnFilter> = 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.ZodType<NftTransferFilter> = 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.ZodType<NftMintFilter> = 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.ZodType<NftBurnFilter> = 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.ZodType<ContractCallFilter> = 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.ZodType<ContractDeployFilter> = 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.ZodType<PrintEventFilter> = 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.ZodType<StreamFilter> = z.discriminatedUnion(\"type\", [\n StxTransferFilterSchema as any,\n StxMintFilterSchema as any,\n StxBurnFilterSchema as any,\n StxLockFilterSchema as any,\n FtTransferFilterSchema as any,\n FtMintFilterSchema as any,\n FtBurnFilterSchema as any,\n NftTransferFilterSchema as any,\n NftMintFilterSchema as any,\n NftBurnFilterSchema as any,\n ContractCallFilterSchema as any,\n ContractDeployFilterSchema as any,\n PrintEventFilterSchema as any,\n]);\n",
|
|
6
|
+
"import { z } from \"zod/v4\";\n\n// ── Deploy Subgraph Request ─────────────────────────────────────────────────\n\nexport interface DeploySubgraphRequest {\n name: string;\n version?: string;\n description?: string;\n sources: string[];\n schema: Record<string, unknown>;\n handlerCode: string;\n reindex?: boolean;\n}\n\nexport const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest> = 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.string(), z.unknown()),\n handlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n reindex: z.boolean().optional(),\n});\n\nexport interface DeploySubgraphResponse {\n action: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\";\n subgraphId: string;\n message: string;\n}\n\n// Subgraph API response types\n\nexport interface SubgraphSummary {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n tables: string[];\n createdAt: string;\n}\n\nexport interface SubgraphDetail {\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, { type: string; nullable?: boolean }>;\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 SubgraphQueryParams {\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/v4\";\nimport { StreamFilterSchema, type StreamFilter } from \"./filters.ts\";\n\n// ── Type interfaces ──────────────────────────────────────────────────\n\nexport interface StreamOptions {\n decodeClarityValues: boolean;\n includeRawTx: boolean;\n includeBlockMetadata: boolean;\n rateLimit: number;\n timeoutMs: number;\n maxRetries: number;\n}\n\nexport interface CreateStream {\n name: string;\n endpointUrl: string;\n filters: StreamFilter[];\n options?: StreamOptions;\n startBlock?: number;\n endBlock?: number;\n}\n\nexport interface UpdateStream {\n name?: string;\n endpointUrl?: string;\n filters?: StreamFilter[];\n options?: Partial<StreamOptions>;\n}\n\nexport interface DeliveryPayload {\n streamId: string;\n streamName: string;\n block: {\n height: number;\n hash: string;\n parentHash: string;\n burnBlockHeight: number;\n timestamp: number;\n };\n matches: {\n transactions: Array<{\n txId: string;\n type: string;\n sender: string;\n status: string;\n contractId: string | null;\n functionName: string | null;\n rawTx?: string;\n }>;\n events: Array<{\n txId: string;\n eventIndex: number;\n type: string;\n data?: any;\n }>;\n };\n isBackfill: boolean;\n deliveredAt: string;\n}\n\nexport interface StreamMetricsResponse {\n totalDeliveries: number;\n failedDeliveries: number;\n lastTriggeredAt: string | null;\n lastTriggeredBlock: number | null;\n errorMessage: string | null;\n}\n\nexport interface StreamResponse {\n id: string;\n name: string;\n status: \"inactive\" | \"active\" | \"paused\" | \"failed\";\n endpointUrl: string;\n filters: StreamFilter[];\n options: StreamOptions;\n totalDeliveries: number;\n failedDeliveries: number;\n lastTriggeredAt?: string | null;\n lastTriggeredBlock?: number | null;\n errorMessage?: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\n// ── Zod schemas ──────────────────────────────────────────────────────\n\n// Stream options schema (internal, keeps ZodObject methods like .partial())\nconst streamOptionsShape = z.object({\n decodeClarityValues: z.boolean().default(true),\n includeRawTx: z.boolean().default(false),\n includeBlockMetadata: z.boolean().default(true),\n rateLimit: z.number().int().positive().max(100).default(10),\n timeoutMs: z.number().int().positive().max(30000).default(10000),\n maxRetries: z.number().int().min(0).max(10).default(3),\n});\n\n// Cast: .default() makes _input fields optional, but output type matches StreamOptions\nexport const StreamOptionsSchema: z.ZodType<StreamOptions> =\n streamOptionsShape as unknown as z.ZodType<StreamOptions>;\n\nexport const CreateStreamSchema: z.ZodType<CreateStream> = z.object({\n name: z.string().min(1).max(255),\n endpointUrl: z.string().url(),\n filters: z.array(StreamFilterSchema).min(1),\n options: streamOptionsShape.optional().default(undefined),\n startBlock: z.number().int().positive().optional(),\n endBlock: z.number().int().positive().optional(),\n}) as unknown as z.ZodType<CreateStream>;\n\nexport const UpdateStreamSchema: z.ZodType<UpdateStream> = z.object({\n name: z.string().min(1).max(255).optional(),\n endpointUrl: z.string().url().optional(),\n filters: z.array(StreamFilterSchema).min(1).optional(),\n options: streamOptionsShape.partial().optional(),\n}).refine(\n (data) => Object.keys(data).length > 0,\n { message: \"At least one field must be provided for update\" }\n) as unknown as z.ZodType<UpdateStream>;\n\nexport const DeliveryPayloadSchema: z.ZodType<DeliveryPayload> = z.object({\n streamId: z.string().uuid(),\n streamName: z.string(),\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 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 isBackfill: z.boolean(),\n deliveredAt: z.string().datetime(),\n}) as unknown as z.ZodType<DeliveryPayload>;\n\nexport const StreamMetricsSchema: z.ZodType<StreamMetricsResponse> = 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\nexport const StreamResponseSchema: z.ZodType<StreamResponse> = z.object({\n id: z.string().uuid(),\n name: z.string(),\n status: z.enum([\"inactive\", \"active\", \"paused\", \"failed\"]),\n endpointUrl: z.string().url(),\n filters: z.array(StreamFilterSchema),\n options: streamOptionsShape,\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 createdAt: z.string().datetime(),\n updatedAt: z.string().datetime(),\n}) as unknown as z.ZodType<StreamResponse>;\n\n// API response types\nexport interface CreateStreamResponse {\n stream: StreamResponse;\n signingSecret: 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
8
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AACA,2BAAS;AAET,IAAM,iBAAiB;AAGvB,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,eAAe,MAAM,EAAG;AAAA,GAC9B,kCAAkC;AAGrC,IAAM,aAAa;AAAA,EAEjB,QAAQ,gBAAgB,SAAS;AAAA,EAEjC,WAAW,gBAAgB,SAAS;AACtC;AA6GO,IAAM,0BAAwD,EAAE,OAAO;AAAA,EAC5E,MAAM,EAAE,QAAQ,cAAc;AAAA,KAC3B;AAAA,EAEH,WAAW,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA,EAEvD,WAAW,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AACzD,CAAC;AAGM,IAAM,sBAAgD,EAAE,OAAO;AAAA,EACpE,MAAM,EAAE,QAAQ,UAAU;AAAA,EAC1B,WAAW,gBAAgB,SAAS;AAAA,EACpC,WAAW,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AACzD,CAAC;AAGM,IAAM,sBAAgD,EA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1
|
+
import { z } from "zod/v4";
|
|
2
|
+
interface DeploySubgraphRequest {
|
|
3
3
|
name: string;
|
|
4
4
|
version?: string;
|
|
5
5
|
description?: string;
|
|
@@ -8,13 +8,13 @@ interface DeployViewRequest {
|
|
|
8
8
|
handlerCode: string;
|
|
9
9
|
reindex?: boolean;
|
|
10
10
|
}
|
|
11
|
-
declare const
|
|
12
|
-
interface
|
|
11
|
+
declare const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest>;
|
|
12
|
+
interface DeploySubgraphResponse {
|
|
13
13
|
action: "created" | "unchanged" | "updated" | "reindexed";
|
|
14
|
-
|
|
14
|
+
subgraphId: string;
|
|
15
15
|
message: string;
|
|
16
16
|
}
|
|
17
|
-
interface
|
|
17
|
+
interface SubgraphSummary {
|
|
18
18
|
name: string;
|
|
19
19
|
version: string;
|
|
20
20
|
status: string;
|
|
@@ -22,7 +22,7 @@ interface ViewSummary {
|
|
|
22
22
|
tables: string[];
|
|
23
23
|
createdAt: string;
|
|
24
24
|
}
|
|
25
|
-
interface
|
|
25
|
+
interface SubgraphDetail {
|
|
26
26
|
name: string;
|
|
27
27
|
version: string;
|
|
28
28
|
status: string;
|
|
@@ -51,7 +51,7 @@ interface ReindexResponse {
|
|
|
51
51
|
fromBlock: number;
|
|
52
52
|
toBlock: number | string;
|
|
53
53
|
}
|
|
54
|
-
interface
|
|
54
|
+
interface SubgraphQueryParams {
|
|
55
55
|
sort?: string;
|
|
56
56
|
order?: string;
|
|
57
57
|
limit?: number;
|
|
@@ -59,4 +59,4 @@ interface ViewQueryParams {
|
|
|
59
59
|
fields?: string;
|
|
60
60
|
filters?: Record<string, string>;
|
|
61
61
|
}
|
|
62
|
-
export {
|
|
62
|
+
export { SubgraphSummary, SubgraphQueryParams, SubgraphDetail, ReindexResponse, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest };
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
3
7
|
var __export = (target, all) => {
|
|
4
8
|
for (var name in all)
|
|
5
9
|
__defProp(target, name, {
|
|
6
10
|
get: all[name],
|
|
7
11
|
enumerable: true,
|
|
8
12
|
configurable: true,
|
|
9
|
-
set: (
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
10
14
|
});
|
|
11
15
|
};
|
|
12
16
|
|
|
13
|
-
// src/schemas/
|
|
14
|
-
import { z } from "zod";
|
|
15
|
-
var
|
|
17
|
+
// src/schemas/subgraphs.ts
|
|
18
|
+
import { z } from "zod/v4";
|
|
19
|
+
var DeploySubgraphRequestSchema = z.object({
|
|
16
20
|
name: z.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
|
|
17
21
|
version: z.string().optional(),
|
|
18
22
|
description: z.string().optional(),
|
|
19
23
|
sources: z.array(z.string()).min(1),
|
|
20
|
-
schema: z.record(z.unknown()),
|
|
24
|
+
schema: z.record(z.string(), z.unknown()),
|
|
21
25
|
handlerCode: z.string().max(1048576, "handler code exceeds 1MB limit"),
|
|
22
26
|
reindex: z.boolean().optional()
|
|
23
27
|
});
|
|
24
28
|
export {
|
|
25
|
-
|
|
29
|
+
DeploySubgraphRequestSchema
|
|
26
30
|
};
|
|
27
31
|
|
|
28
|
-
//# debugId=
|
|
29
|
-
//# sourceMappingURL=
|
|
32
|
+
//# debugId=26911156B2F638FD64756E2164756E21
|
|
33
|
+
//# sourceMappingURL=subgraphs.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/schemas/subgraphs.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { z } from \"zod/v4\";\n\n// ── Deploy Subgraph Request ─────────────────────────────────────────────────\n\nexport interface DeploySubgraphRequest {\n name: string;\n version?: string;\n description?: string;\n sources: string[];\n schema: Record<string, unknown>;\n handlerCode: string;\n reindex?: boolean;\n}\n\nexport const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest> = 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.string(), z.unknown()),\n handlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n reindex: z.boolean().optional(),\n});\n\nexport interface DeploySubgraphResponse {\n action: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\";\n subgraphId: string;\n message: string;\n}\n\n// Subgraph API response types\n\nexport interface SubgraphSummary {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n tables: string[];\n createdAt: string;\n}\n\nexport interface SubgraphDetail {\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, { type: string; nullable?: boolean }>;\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 SubgraphQueryParams {\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;AAcO,IAAM,8BAAgE,EAAE,OAAO;AAAA,EACpF,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,OAAO,GAAG,EAAE,QAAQ,CAAC;AAAA,EACxC,aAAa,EAAE,OAAO,EAAE,IAAI,SAAW,gCAAgC;AAAA,EACvE,SAAS,EAAE,QAAQ,EAAE,SAAS;AAChC,CAAC;",
|
|
8
|
+
"debugId": "26911156B2F638FD64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ interface StreamsTable {
|
|
|
35
35
|
status: Generated<string>;
|
|
36
36
|
filters: unknown;
|
|
37
37
|
options: Generated<unknown>;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
endpoint_url: string;
|
|
39
|
+
signing_secret: string | null;
|
|
40
40
|
api_key_id: string | null;
|
|
41
41
|
created_at: Generated<Date>;
|
|
42
42
|
updated_at: Generated<Date>;
|
package/dist/src/types.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
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
1
|
|
|
13
|
-
//# debugId=
|
|
2
|
+
//# debugId=F2B76011AEAE140064756E2164756E21
|
|
14
3
|
//# sourceMappingURL=types.js.map
|
package/dist/src/types.js.map
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
|
|
3
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
|
+
await db.schema
|
|
5
|
+
.createTable("waitlist")
|
|
6
|
+
.addColumn("id", "uuid", (col) =>
|
|
7
|
+
col.primaryKey().defaultTo(db.fn("gen_random_uuid")),
|
|
8
|
+
)
|
|
9
|
+
.addColumn("email", "text", (col) => col.notNull().unique())
|
|
10
|
+
.addColumn("source", "text", (col) => col.defaultTo("website"))
|
|
11
|
+
.addColumn("created_at", "timestamptz", (col) =>
|
|
12
|
+
col.notNull().defaultTo(db.fn("now")),
|
|
13
|
+
)
|
|
14
|
+
.execute();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
18
|
+
await db.schema.dropTable("waitlist").execute();
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
|
|
3
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
|
+
await db.schema
|
|
5
|
+
.alterTable("waitlist")
|
|
6
|
+
.addColumn("status", "text", (col) => col.notNull().defaultTo("pending"))
|
|
7
|
+
.execute();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
11
|
+
await db.schema.alterTable("waitlist").dropColumn("status").execute();
|
|
12
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
|
|
4
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
5
|
+
await db.schema
|
|
6
|
+
.createTable("account_insights")
|
|
7
|
+
.addColumn("id", "uuid", (col) =>
|
|
8
|
+
col.primaryKey().defaultTo(db.fn("gen_random_uuid")),
|
|
9
|
+
)
|
|
10
|
+
.addColumn("account_id", "uuid", (col) =>
|
|
11
|
+
col.notNull().references("accounts.id"),
|
|
12
|
+
)
|
|
13
|
+
.addColumn("category", "text", (col) => col.notNull())
|
|
14
|
+
.addColumn("insight_type", "text", (col) => col.notNull())
|
|
15
|
+
.addColumn("resource_id", "text")
|
|
16
|
+
.addColumn("severity", "text", (col) => col.notNull())
|
|
17
|
+
.addColumn("title", "text", (col) => col.notNull())
|
|
18
|
+
.addColumn("body", "text", (col) => col.notNull())
|
|
19
|
+
.addColumn("data", "jsonb")
|
|
20
|
+
.addColumn("dismissed_at", "timestamptz")
|
|
21
|
+
.addColumn("expires_at", "timestamptz")
|
|
22
|
+
.addColumn("created_at", "timestamptz", (col) =>
|
|
23
|
+
col.notNull().defaultTo(db.fn("now")),
|
|
24
|
+
)
|
|
25
|
+
.execute();
|
|
26
|
+
|
|
27
|
+
await db.schema
|
|
28
|
+
.createIndex("idx_account_insights_account")
|
|
29
|
+
.on("account_insights")
|
|
30
|
+
.column("account_id")
|
|
31
|
+
.execute();
|
|
32
|
+
|
|
33
|
+
await db.schema
|
|
34
|
+
.createTable("account_agent_runs")
|
|
35
|
+
.addColumn("id", "uuid", (col) =>
|
|
36
|
+
col.primaryKey().defaultTo(db.fn("gen_random_uuid")),
|
|
37
|
+
)
|
|
38
|
+
.addColumn("account_id", "uuid", (col) =>
|
|
39
|
+
col.notNull().references("accounts.id"),
|
|
40
|
+
)
|
|
41
|
+
.addColumn("started_at", "timestamptz", (col) =>
|
|
42
|
+
col.notNull().defaultTo(db.fn("now")),
|
|
43
|
+
)
|
|
44
|
+
.addColumn("completed_at", "timestamptz")
|
|
45
|
+
.addColumn("status", "text", (col) => col.notNull().defaultTo("running"))
|
|
46
|
+
.addColumn("input_tokens", "integer", (col) => col.defaultTo(0))
|
|
47
|
+
.addColumn("output_tokens", "integer", (col) => col.defaultTo(0))
|
|
48
|
+
.addColumn("cost_usd", sql`numeric(10,6)`, (col) => col.defaultTo(0))
|
|
49
|
+
.addColumn("insights_created", "integer", (col) => col.defaultTo(0))
|
|
50
|
+
.addColumn("error", "text")
|
|
51
|
+
.execute();
|
|
52
|
+
|
|
53
|
+
await db.schema
|
|
54
|
+
.createIndex("idx_account_agent_runs_account")
|
|
55
|
+
.on("account_agent_runs")
|
|
56
|
+
.column("account_id")
|
|
57
|
+
.execute();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
61
|
+
await db.schema.dropTable("account_agent_runs").execute();
|
|
62
|
+
await db.schema.dropTable("account_insights").execute();
|
|
63
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
|
|
3
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
|
+
await db.schema
|
|
5
|
+
.createTable("view_health_snapshots")
|
|
6
|
+
.addColumn("id", "uuid", (col) =>
|
|
7
|
+
col.primaryKey().defaultTo(db.fn("gen_random_uuid")),
|
|
8
|
+
)
|
|
9
|
+
.addColumn("view_id", "uuid", (col) =>
|
|
10
|
+
col.notNull().references("views.id").onDelete("cascade"),
|
|
11
|
+
)
|
|
12
|
+
.addColumn("total_processed", "bigint", (col) => col.notNull())
|
|
13
|
+
.addColumn("total_errors", "bigint", (col) => col.notNull())
|
|
14
|
+
.addColumn("last_processed_block", "integer")
|
|
15
|
+
.addColumn("captured_at", "timestamptz", (col) =>
|
|
16
|
+
col.notNull().defaultTo(db.fn("now")),
|
|
17
|
+
)
|
|
18
|
+
.execute();
|
|
19
|
+
|
|
20
|
+
await db.schema
|
|
21
|
+
.createIndex("idx_view_health_snapshots_view_captured")
|
|
22
|
+
.on("view_health_snapshots")
|
|
23
|
+
.columns(["view_id", "captured_at"])
|
|
24
|
+
.execute();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
28
|
+
await db.schema.dropTable("view_health_snapshots").execute();
|
|
29
|
+
}
|