@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.
- package/README.md +19 -0
- package/dist/src/crypto/hmac.d.ts +26 -0
- package/dist/src/crypto/hmac.js +75 -0
- package/dist/src/crypto/hmac.js.map +10 -0
- package/dist/src/db/index.d.ts +227 -0
- package/dist/src/db/index.js +75 -0
- package/dist/src/db/index.js.map +11 -0
- package/dist/src/db/jsonb.d.ts +13 -0
- package/dist/src/db/jsonb.js +35 -0
- package/dist/src/db/jsonb.js.map +10 -0
- package/dist/src/db/queries/accounts.d.ts +179 -0
- package/dist/src/db/queries/accounts.js +39 -0
- package/dist/src/db/queries/accounts.js.map +10 -0
- package/dist/src/db/queries/integrity.d.ts +178 -0
- package/dist/src/db/queries/integrity.js +68 -0
- package/dist/src/db/queries/integrity.js.map +10 -0
- package/dist/src/db/queries/metrics.d.ts +179 -0
- package/dist/src/db/queries/metrics.js +51 -0
- package/dist/src/db/queries/metrics.js.map +10 -0
- package/dist/src/db/queries/usage.d.ts +205 -0
- package/dist/src/db/queries/usage.js +117 -0
- package/dist/src/db/queries/usage.js.map +11 -0
- package/dist/src/db/queries/views.d.ts +191 -0
- package/dist/src/db/queries/views.js +111 -0
- package/dist/src/db/queries/views.js.map +11 -0
- package/dist/src/db/schema.d.ts +207 -0
- package/dist/src/db/schema.js +3 -0
- package/dist/src/db/schema.js.map +9 -0
- package/dist/src/env.d.ts +7 -0
- package/dist/src/env.js +60 -0
- package/dist/src/env.js.map +10 -0
- package/dist/src/errors.d.ts +51 -0
- package/dist/src/errors.js +103 -0
- package/dist/src/errors.js.map +10 -0
- package/dist/src/index.d.ts +464 -0
- package/dist/src/index.js +642 -0
- package/dist/src/index.js.map +19 -0
- package/dist/src/lib/plans.d.ts +10 -0
- package/dist/src/lib/plans.js +34 -0
- package/dist/src/lib/plans.js.map +10 -0
- package/dist/src/logger.d.ts +2 -0
- package/dist/src/logger.js +130 -0
- package/dist/src/logger.js.map +11 -0
- package/dist/src/node/client.d.ts +35 -0
- package/dist/src/node/client.js +56 -0
- package/dist/src/node/client.js.map +10 -0
- package/dist/src/node/hiro-client.d.ts +186 -0
- package/dist/src/node/hiro-client.js +410 -0
- package/dist/src/node/hiro-client.js.map +12 -0
- package/dist/src/queue/index.d.ts +50 -0
- package/dist/src/queue/index.js +176 -0
- package/dist/src/queue/index.js.map +12 -0
- package/dist/src/queue/listener.d.ts +20 -0
- package/dist/src/queue/listener.js +63 -0
- package/dist/src/queue/listener.js.map +10 -0
- package/dist/src/queue/recovery.d.ts +14 -0
- package/dist/src/queue/recovery.js +100 -0
- package/dist/src/queue/recovery.js.map +12 -0
- package/dist/src/schemas/filters.d.ts +30 -0
- package/dist/src/schemas/filters.js +133 -0
- package/dist/src/schemas/filters.js.map +10 -0
- package/dist/src/schemas/index.d.ts +109 -0
- package/dist/src/schemas/index.js +228 -0
- package/dist/src/schemas/index.js.map +12 -0
- package/dist/src/schemas/views.d.ts +51 -0
- package/dist/src/schemas/views.js +29 -0
- package/dist/src/schemas/views.js.map +10 -0
- package/dist/src/types.d.ts +102 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +9 -0
- package/migrations/0001_initial.ts +182 -0
- package/migrations/0002_api_keys.ts +38 -0
- package/migrations/0003_tenant_isolation.ts +114 -0
- package/migrations/0004_accounts_and_usage.ts +90 -0
- package/migrations/0005_sessions.ts +42 -0
- package/package.json +128 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { Generated, Insertable, Selectable, Updateable } 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 StreamMetricsTable {
|
|
44
|
+
stream_id: string;
|
|
45
|
+
last_triggered_at: Date | null;
|
|
46
|
+
last_triggered_block: number | null;
|
|
47
|
+
total_deliveries: Generated<number>;
|
|
48
|
+
failed_deliveries: Generated<number>;
|
|
49
|
+
error_message: string | null;
|
|
50
|
+
}
|
|
51
|
+
interface JobsTable {
|
|
52
|
+
id: Generated<string>;
|
|
53
|
+
stream_id: string;
|
|
54
|
+
block_height: number;
|
|
55
|
+
status: Generated<string>;
|
|
56
|
+
attempts: Generated<number>;
|
|
57
|
+
locked_at: Date | null;
|
|
58
|
+
locked_by: string | null;
|
|
59
|
+
error: string | null;
|
|
60
|
+
backfill: Generated<boolean>;
|
|
61
|
+
created_at: Generated<Date>;
|
|
62
|
+
completed_at: Date | null;
|
|
63
|
+
}
|
|
64
|
+
interface IndexProgressTable {
|
|
65
|
+
network: string;
|
|
66
|
+
last_indexed_block: Generated<number>;
|
|
67
|
+
last_contiguous_block: Generated<number>;
|
|
68
|
+
highest_seen_block: Generated<number>;
|
|
69
|
+
updated_at: Generated<Date>;
|
|
70
|
+
}
|
|
71
|
+
interface DeliveriesTable {
|
|
72
|
+
id: Generated<string>;
|
|
73
|
+
stream_id: string;
|
|
74
|
+
job_id: string | null;
|
|
75
|
+
block_height: number;
|
|
76
|
+
status: string;
|
|
77
|
+
status_code: number | null;
|
|
78
|
+
response_time_ms: number | null;
|
|
79
|
+
attempts: Generated<number>;
|
|
80
|
+
error: string | null;
|
|
81
|
+
payload: unknown;
|
|
82
|
+
created_at: Generated<Date>;
|
|
83
|
+
}
|
|
84
|
+
interface ViewsTable {
|
|
85
|
+
id: Generated<string>;
|
|
86
|
+
name: string;
|
|
87
|
+
version: Generated<string>;
|
|
88
|
+
status: Generated<string>;
|
|
89
|
+
definition: unknown;
|
|
90
|
+
schema_hash: string;
|
|
91
|
+
handler_path: string;
|
|
92
|
+
schema_name: string | null;
|
|
93
|
+
last_processed_block: Generated<number>;
|
|
94
|
+
last_error: string | null;
|
|
95
|
+
last_error_at: Date | null;
|
|
96
|
+
total_processed: Generated<number>;
|
|
97
|
+
total_errors: Generated<number>;
|
|
98
|
+
api_key_id: string | null;
|
|
99
|
+
created_at: Generated<Date>;
|
|
100
|
+
updated_at: Generated<Date>;
|
|
101
|
+
}
|
|
102
|
+
interface ApiKeysTable {
|
|
103
|
+
id: Generated<string>;
|
|
104
|
+
key_hash: string;
|
|
105
|
+
key_prefix: string;
|
|
106
|
+
name: string | null;
|
|
107
|
+
status: Generated<string>;
|
|
108
|
+
rate_limit: Generated<number>;
|
|
109
|
+
ip_address: string;
|
|
110
|
+
account_id: string;
|
|
111
|
+
last_used_at: Date | null;
|
|
112
|
+
revoked_at: Date | null;
|
|
113
|
+
created_at: Generated<Date>;
|
|
114
|
+
}
|
|
115
|
+
interface AccountsTable {
|
|
116
|
+
id: Generated<string>;
|
|
117
|
+
email: string;
|
|
118
|
+
plan: Generated<string>;
|
|
119
|
+
created_at: Generated<Date>;
|
|
120
|
+
}
|
|
121
|
+
interface SessionsTable {
|
|
122
|
+
id: Generated<string>;
|
|
123
|
+
token_hash: string;
|
|
124
|
+
token_prefix: string;
|
|
125
|
+
account_id: string;
|
|
126
|
+
ip_address: string;
|
|
127
|
+
expires_at: Generated<Date>;
|
|
128
|
+
revoked_at: Date | null;
|
|
129
|
+
last_used_at: Date | null;
|
|
130
|
+
created_at: Generated<Date>;
|
|
131
|
+
}
|
|
132
|
+
interface MagicLinksTable {
|
|
133
|
+
id: Generated<string>;
|
|
134
|
+
email: string;
|
|
135
|
+
token: string;
|
|
136
|
+
expires_at: Date;
|
|
137
|
+
used_at: Date | null;
|
|
138
|
+
created_at: Generated<Date>;
|
|
139
|
+
}
|
|
140
|
+
interface UsageDailyTable {
|
|
141
|
+
account_id: string;
|
|
142
|
+
date: string;
|
|
143
|
+
api_requests: Generated<number>;
|
|
144
|
+
deliveries: Generated<number>;
|
|
145
|
+
}
|
|
146
|
+
interface UsageSnapshotsTable {
|
|
147
|
+
id: Generated<string>;
|
|
148
|
+
account_id: string;
|
|
149
|
+
measured_at: Generated<Date>;
|
|
150
|
+
storage_bytes: Generated<number>;
|
|
151
|
+
}
|
|
152
|
+
interface Database {
|
|
153
|
+
blocks: BlocksTable;
|
|
154
|
+
transactions: TransactionsTable;
|
|
155
|
+
events: EventsTable;
|
|
156
|
+
streams: StreamsTable;
|
|
157
|
+
stream_metrics: StreamMetricsTable;
|
|
158
|
+
jobs: JobsTable;
|
|
159
|
+
index_progress: IndexProgressTable;
|
|
160
|
+
deliveries: DeliveriesTable;
|
|
161
|
+
views: ViewsTable;
|
|
162
|
+
api_keys: ApiKeysTable;
|
|
163
|
+
accounts: AccountsTable;
|
|
164
|
+
sessions: SessionsTable;
|
|
165
|
+
magic_links: MagicLinksTable;
|
|
166
|
+
usage_daily: UsageDailyTable;
|
|
167
|
+
usage_snapshots: UsageSnapshotsTable;
|
|
168
|
+
}
|
|
169
|
+
type Block = Selectable<BlocksTable>;
|
|
170
|
+
type InsertBlock = Insertable<BlocksTable>;
|
|
171
|
+
type UpdateBlock = Updateable<BlocksTable>;
|
|
172
|
+
type Transaction = Selectable<TransactionsTable>;
|
|
173
|
+
type InsertTransaction = Insertable<TransactionsTable>;
|
|
174
|
+
type UpdateTransaction = Updateable<TransactionsTable>;
|
|
175
|
+
type Event = Selectable<EventsTable>;
|
|
176
|
+
type InsertEvent = Insertable<EventsTable>;
|
|
177
|
+
type UpdateEvent = Updateable<EventsTable>;
|
|
178
|
+
type Stream = Selectable<StreamsTable>;
|
|
179
|
+
type InsertStream = Insertable<StreamsTable>;
|
|
180
|
+
type UpdateStreamRow = Updateable<StreamsTable>;
|
|
181
|
+
type StreamMetrics = Selectable<StreamMetricsTable>;
|
|
182
|
+
type InsertStreamMetrics = Insertable<StreamMetricsTable>;
|
|
183
|
+
type UpdateStreamMetrics = Updateable<StreamMetricsTable>;
|
|
184
|
+
type Job = Selectable<JobsTable>;
|
|
185
|
+
type InsertJob = Insertable<JobsTable>;
|
|
186
|
+
type UpdateJob = Updateable<JobsTable>;
|
|
187
|
+
type IndexProgress = Selectable<IndexProgressTable>;
|
|
188
|
+
type InsertIndexProgress = Insertable<IndexProgressTable>;
|
|
189
|
+
type UpdateIndexProgress = Updateable<IndexProgressTable>;
|
|
190
|
+
type Delivery = Selectable<DeliveriesTable>;
|
|
191
|
+
type InsertDelivery = Insertable<DeliveriesTable>;
|
|
192
|
+
type UpdateDelivery = Updateable<DeliveriesTable>;
|
|
193
|
+
type View = Selectable<ViewsTable>;
|
|
194
|
+
type InsertView = Insertable<ViewsTable>;
|
|
195
|
+
type UpdateView = Updateable<ViewsTable>;
|
|
196
|
+
type ApiKey = Selectable<ApiKeysTable>;
|
|
197
|
+
type InsertApiKey = Insertable<ApiKeysTable>;
|
|
198
|
+
type UpdateApiKey = Updateable<ApiKeysTable>;
|
|
199
|
+
type Account = Selectable<AccountsTable>;
|
|
200
|
+
type InsertAccount = Insertable<AccountsTable>;
|
|
201
|
+
type MagicLink = Selectable<MagicLinksTable>;
|
|
202
|
+
type InsertMagicLink = Insertable<MagicLinksTable>;
|
|
203
|
+
type Session = Selectable<SessionsTable>;
|
|
204
|
+
type InsertSession = Insertable<SessionsTable>;
|
|
205
|
+
type UsageDaily = Selectable<UsageDailyTable>;
|
|
206
|
+
type UsageSnapshot = Selectable<UsageSnapshotsTable>;
|
|
207
|
+
import { z } from "zod";
|
|
208
|
+
declare const envSchema: unknown;
|
|
209
|
+
type Env = z.infer<typeof envSchema> & {
|
|
210
|
+
enabledNetworks: ("mainnet" | "testnet")[]
|
|
211
|
+
};
|
|
212
|
+
declare function getEnv(): Env;
|
|
213
|
+
interface QueueStats {
|
|
214
|
+
pending: number;
|
|
215
|
+
processing: number;
|
|
216
|
+
completed: number;
|
|
217
|
+
failed: number;
|
|
218
|
+
total: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Safely encode a JS value as a JSONB literal for Kysely inserts/updates.
|
|
222
|
+
* Kysely + postgres.js double-encodes JSON when using parameterized queries
|
|
223
|
+
* with ::jsonb casts. This uses sql.raw to inline a properly escaped literal.
|
|
224
|
+
*/
|
|
225
|
+
declare function jsonb(value: unknown);
|
|
226
|
+
/**
|
|
227
|
+
* Safely parse a JSONB value from the database.
|
|
228
|
+
* Handles double-encoded strings where postgres.js returns a JSON string
|
|
229
|
+
* instead of a parsed object.
|
|
230
|
+
*/
|
|
231
|
+
declare function parseJsonb<T = unknown>(value: unknown): T;
|
|
232
|
+
import { Kysely } from "kysely";
|
|
233
|
+
import postgres from "postgres";
|
|
234
|
+
import { sql } from "kysely";
|
|
235
|
+
declare function getDb(connectionString?: string): Kysely<Database>;
|
|
236
|
+
/** Raw postgres.js client for dynamic schema DDL (CREATE SCHEMA, DROP, etc.) */
|
|
237
|
+
declare function getRawClient(): ReturnType<typeof postgres>;
|
|
238
|
+
/** Close the DB connection pool. Call in CLI commands to allow process exit. */
|
|
239
|
+
declare function closeDb(): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Base error class for all Stacks Streams errors
|
|
242
|
+
*/
|
|
243
|
+
declare class StreamsError extends Error {
|
|
244
|
+
code: string;
|
|
245
|
+
cause?: unknown;
|
|
246
|
+
constructor(code: string, message: string, cause?: unknown);
|
|
247
|
+
toJSON(): {};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Stream not found error
|
|
251
|
+
*/
|
|
252
|
+
declare class StreamNotFoundError extends StreamsError {
|
|
253
|
+
constructor(streamId: string);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Validation error for invalid input
|
|
257
|
+
*/
|
|
258
|
+
declare class ValidationError extends StreamsError {
|
|
259
|
+
constructor(message: string, cause?: unknown);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Database operation error
|
|
263
|
+
*/
|
|
264
|
+
declare class DatabaseError extends StreamsError {
|
|
265
|
+
constructor(message: string, cause?: unknown);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Webhook delivery error
|
|
269
|
+
*/
|
|
270
|
+
declare class WebhookDeliveryError extends StreamsError {
|
|
271
|
+
statusCode?: number;
|
|
272
|
+
constructor(message: string, statusCode?: number, cause?: unknown);
|
|
273
|
+
toJSON(): {};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Filter evaluation error
|
|
277
|
+
*/
|
|
278
|
+
declare class FilterEvaluationError extends StreamsError {
|
|
279
|
+
constructor(message: string, cause?: unknown);
|
|
280
|
+
}
|
|
281
|
+
declare class AuthenticationError extends StreamsError {
|
|
282
|
+
constructor(message: string);
|
|
283
|
+
}
|
|
284
|
+
declare class AuthorizationError extends StreamsError {
|
|
285
|
+
constructor(message: string);
|
|
286
|
+
}
|
|
287
|
+
declare class RateLimitError extends StreamsError {
|
|
288
|
+
constructor(message: string);
|
|
289
|
+
}
|
|
290
|
+
declare const logger: unknown;
|
|
291
|
+
declare namespace exports_queue {
|
|
292
|
+
export { stats, getWorkerId, fail, enqueue, complete, claim, WORKER_ID, QueueStats2 as QueueStats };
|
|
293
|
+
}
|
|
294
|
+
interface QueueStats2 {
|
|
295
|
+
pending: number;
|
|
296
|
+
processing: number;
|
|
297
|
+
completed: number;
|
|
298
|
+
failed: number;
|
|
299
|
+
total: number;
|
|
300
|
+
}
|
|
301
|
+
declare const WORKER_ID: unknown;
|
|
302
|
+
/**
|
|
303
|
+
* Enqueue a new job for stream evaluation
|
|
304
|
+
*/
|
|
305
|
+
declare function enqueue(streamId: string, blockHeight: number, backfill?: boolean): Promise<string>;
|
|
306
|
+
/**
|
|
307
|
+
* Claim a pending job using SKIP LOCKED to prevent concurrent access
|
|
308
|
+
* Returns null if no jobs available
|
|
309
|
+
*/
|
|
310
|
+
declare function claim(): Promise<Job | null>;
|
|
311
|
+
/**
|
|
312
|
+
* Mark a job as completed
|
|
313
|
+
*/
|
|
314
|
+
declare function complete(jobId: string): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Mark a job as failed
|
|
317
|
+
* Re-queues if under max attempts, otherwise marks as permanently failed
|
|
318
|
+
*/
|
|
319
|
+
declare function fail(jobId: string, error: string, maxAttempts?: number): Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Get queue statistics
|
|
322
|
+
*/
|
|
323
|
+
declare function stats(): Promise<QueueStats2>;
|
|
324
|
+
/**
|
|
325
|
+
* Get worker ID for this process
|
|
326
|
+
*/
|
|
327
|
+
declare function getWorkerId(): string;
|
|
328
|
+
import { z as z2 } from "zod";
|
|
329
|
+
declare const StxTransferFilterSchema: unknown;
|
|
330
|
+
declare const StxMintFilterSchema: unknown;
|
|
331
|
+
declare const StxBurnFilterSchema: unknown;
|
|
332
|
+
declare const StxLockFilterSchema: unknown;
|
|
333
|
+
declare const FtTransferFilterSchema: unknown;
|
|
334
|
+
declare const FtMintFilterSchema: unknown;
|
|
335
|
+
declare const FtBurnFilterSchema: unknown;
|
|
336
|
+
declare const NftTransferFilterSchema: unknown;
|
|
337
|
+
declare const NftMintFilterSchema: unknown;
|
|
338
|
+
declare const NftBurnFilterSchema: unknown;
|
|
339
|
+
declare const ContractCallFilterSchema: unknown;
|
|
340
|
+
declare const ContractDeployFilterSchema: unknown;
|
|
341
|
+
declare const PrintEventFilterSchema: unknown;
|
|
342
|
+
declare const StreamFilterSchema: unknown;
|
|
343
|
+
type StxTransferFilter = z2.infer<typeof StxTransferFilterSchema>;
|
|
344
|
+
type StxMintFilter = z2.infer<typeof StxMintFilterSchema>;
|
|
345
|
+
type StxBurnFilter = z2.infer<typeof StxBurnFilterSchema>;
|
|
346
|
+
type StxLockFilter = z2.infer<typeof StxLockFilterSchema>;
|
|
347
|
+
type FtTransferFilter = z2.infer<typeof FtTransferFilterSchema>;
|
|
348
|
+
type FtMintFilter = z2.infer<typeof FtMintFilterSchema>;
|
|
349
|
+
type FtBurnFilter = z2.infer<typeof FtBurnFilterSchema>;
|
|
350
|
+
type NftTransferFilter = z2.infer<typeof NftTransferFilterSchema>;
|
|
351
|
+
type NftMintFilter = z2.infer<typeof NftMintFilterSchema>;
|
|
352
|
+
type NftBurnFilter = z2.infer<typeof NftBurnFilterSchema>;
|
|
353
|
+
type ContractCallFilter = z2.infer<typeof ContractCallFilterSchema>;
|
|
354
|
+
type ContractDeployFilter = z2.infer<typeof ContractDeployFilterSchema>;
|
|
355
|
+
type PrintEventFilter = z2.infer<typeof PrintEventFilterSchema>;
|
|
356
|
+
type StreamFilter = z2.infer<typeof StreamFilterSchema>;
|
|
357
|
+
import { z as z3 } from "zod";
|
|
358
|
+
declare const DeployViewRequestSchema: unknown;
|
|
359
|
+
type DeployViewRequest = z3.infer<typeof DeployViewRequestSchema>;
|
|
360
|
+
interface DeployViewResponse {
|
|
361
|
+
action: "created" | "unchanged" | "updated" | "reindexed";
|
|
362
|
+
viewId: string;
|
|
363
|
+
message: string;
|
|
364
|
+
}
|
|
365
|
+
interface ViewSummary {
|
|
366
|
+
name: string;
|
|
367
|
+
version: string;
|
|
368
|
+
status: string;
|
|
369
|
+
lastProcessedBlock: number;
|
|
370
|
+
tables: string[];
|
|
371
|
+
createdAt: string;
|
|
372
|
+
}
|
|
373
|
+
interface ViewDetail {
|
|
374
|
+
name: string;
|
|
375
|
+
version: string;
|
|
376
|
+
status: string;
|
|
377
|
+
lastProcessedBlock: number;
|
|
378
|
+
health: {
|
|
379
|
+
totalProcessed: number
|
|
380
|
+
totalErrors: number
|
|
381
|
+
errorRate: number
|
|
382
|
+
lastError: string | null
|
|
383
|
+
lastErrorAt: string | null
|
|
384
|
+
};
|
|
385
|
+
tables: Record<string, {
|
|
386
|
+
endpoint: string
|
|
387
|
+
columns: Record<string, string>
|
|
388
|
+
rowCount: number
|
|
389
|
+
example: string
|
|
390
|
+
}>;
|
|
391
|
+
createdAt: string;
|
|
392
|
+
updatedAt: string;
|
|
393
|
+
}
|
|
394
|
+
interface ReindexResponse {
|
|
395
|
+
message: string;
|
|
396
|
+
fromBlock: number;
|
|
397
|
+
toBlock: number | string;
|
|
398
|
+
}
|
|
399
|
+
interface ViewQueryParams {
|
|
400
|
+
sort?: string;
|
|
401
|
+
order?: string;
|
|
402
|
+
limit?: number;
|
|
403
|
+
offset?: number;
|
|
404
|
+
fields?: string;
|
|
405
|
+
filters?: Record<string, string>;
|
|
406
|
+
}
|
|
407
|
+
import { z as z4 } from "zod";
|
|
408
|
+
declare const StreamOptionsSchema: unknown;
|
|
409
|
+
declare const CreateStreamSchema: unknown;
|
|
410
|
+
declare const UpdateStreamSchema: unknown;
|
|
411
|
+
declare const WebhookPayloadSchema: unknown;
|
|
412
|
+
declare const StreamMetricsSchema: unknown;
|
|
413
|
+
declare const StreamResponseSchema: unknown;
|
|
414
|
+
type StreamOptions = z4.infer<typeof StreamOptionsSchema>;
|
|
415
|
+
type CreateStream = z4.infer<typeof CreateStreamSchema>;
|
|
416
|
+
type UpdateStream = z4.infer<typeof UpdateStreamSchema>;
|
|
417
|
+
type WebhookPayload = z4.infer<typeof WebhookPayloadSchema>;
|
|
418
|
+
type StreamResponse = z4.infer<typeof StreamResponseSchema>;
|
|
419
|
+
type StreamMetricsResponse = z4.infer<typeof StreamMetricsSchema>;
|
|
420
|
+
interface CreateStreamResponse {
|
|
421
|
+
stream: StreamResponse;
|
|
422
|
+
webhookSecret: string;
|
|
423
|
+
}
|
|
424
|
+
interface ListStreamsResponse {
|
|
425
|
+
streams: StreamResponse[];
|
|
426
|
+
total: number;
|
|
427
|
+
}
|
|
428
|
+
interface BulkPauseResponse {
|
|
429
|
+
paused: number;
|
|
430
|
+
streams: StreamResponse[];
|
|
431
|
+
}
|
|
432
|
+
interface BulkResumeResponse {
|
|
433
|
+
resumed: number;
|
|
434
|
+
streams: StreamResponse[];
|
|
435
|
+
}
|
|
436
|
+
declare namespace exports_hmac {
|
|
437
|
+
export { verifySignatureHeader, verifySignature, signPayload, generateSecret, createSignatureHeader };
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Generate a random secret for webhook signing
|
|
441
|
+
* Returns 32 bytes as a 64-character hex string
|
|
442
|
+
*/
|
|
443
|
+
declare function generateSecret(): string;
|
|
444
|
+
/**
|
|
445
|
+
* Sign a payload with HMAC-SHA256
|
|
446
|
+
* Returns the signature as a hex string
|
|
447
|
+
*/
|
|
448
|
+
declare function signPayload(payload: string, secret: string): string;
|
|
449
|
+
/**
|
|
450
|
+
* Verify an HMAC signature
|
|
451
|
+
* Uses constant-time comparison to prevent timing attacks
|
|
452
|
+
*/
|
|
453
|
+
declare function verifySignature(payload: string, signature: string, secret: string): boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Create a Stripe-style signature header
|
|
456
|
+
* Format: t=timestamp,v1=signature
|
|
457
|
+
*/
|
|
458
|
+
declare function createSignatureHeader(payload: string, secret: string, timestamp?: number): string;
|
|
459
|
+
/**
|
|
460
|
+
* Parse and verify a Stripe-style signature header
|
|
461
|
+
* Returns true if valid, false otherwise
|
|
462
|
+
*/
|
|
463
|
+
declare function verifySignatureHeader(payload: string, header: string, secret: string, toleranceSeconds?: number): boolean;
|
|
464
|
+
export { sql, exports_queue as queue, parseJsonb, logger, jsonb, getRawClient, getEnv, getDb, exports_hmac as crypto, closeDb, WebhookPayloadSchema, WebhookPayload, WebhookDeliveryError, ViewsTable, ViewSummary, ViewQueryParams, ViewDetail, View, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateView, UpdateTransaction, UpdateStreamSchema, UpdateStreamRow, UpdateStreamMetrics, UpdateStream, UpdateJob, UpdateIndexProgress, UpdateEvent, UpdateDelivery, UpdateBlock, UpdateApiKey, TransactionsTable, Transaction, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, StreamsTable, StreamsError, StreamResponseSchema, StreamResponse, StreamOptionsSchema, StreamOptions, StreamNotFoundError, StreamMetricsTable, StreamMetricsSchema, StreamMetricsResponse, StreamMetrics, StreamFilterSchema, StreamFilter, Stream, SessionsTable, Session, ReindexResponse, RateLimitError, QueueStats, PrintEventFilterSchema, PrintEventFilter, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MagicLinksTable, MagicLink, ListStreamsResponse, JobsTable, Job, InsertView, InsertTransaction, InsertStreamMetrics, InsertStream, InsertSession, InsertMagicLink, InsertJob, InsertIndexProgress, InsertEvent, InsertDelivery, InsertBlock, InsertApiKey, InsertAccount, IndexProgressTable, IndexProgress, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, FilterEvaluationError, EventsTable, Event, Env, DeployViewResponse, DeployViewRequestSchema, DeployViewRequest, Delivery, DeliveriesTable, DatabaseError, Database, CreateStreamSchema, CreateStreamResponse, CreateStream, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, BulkResumeResponse, BulkPauseResponse, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, Account };
|