@secondlayer/shared 0.2.3 → 0.4.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 +23 -0
- package/dist/src/db/index.d.ts +3 -1
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/jsonb.d.ts +2 -1
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/accounts.d.ts +2 -1
- package/dist/src/db/queries/accounts.js.map +2 -2
- package/dist/src/db/queries/integrity.d.ts +1 -0
- package/dist/src/db/queries/metrics.d.ts +6 -4
- package/dist/src/db/queries/metrics.js.map +2 -2
- package/dist/src/db/queries/usage.d.ts +1 -0
- package/dist/src/db/queries/views.d.ts +10 -8
- package/dist/src/db/queries/views.js.map +3 -3
- package/dist/src/db/schema.d.ts +1 -0
- package/dist/src/env.d.ts +9 -2
- package/dist/src/env.js.map +2 -2
- package/dist/src/errors.d.ts +19 -3
- package/dist/src/errors.js +14 -2
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index.d.ts +221 -55
- package/dist/src/index.js +19 -6
- package/dist/src/index.js.map +10 -10
- package/dist/src/logger.d.ts +4 -4
- package/dist/src/logger.js.map +3 -3
- package/dist/src/node/client.d.ts +1 -0
- package/dist/src/node/client.js +13 -1
- package/dist/src/node/client.js.map +3 -3
- package/dist/src/node/hiro-client.js +4 -4
- package/dist/src/node/hiro-client.js.map +5 -5
- package/dist/src/node/local-client.d.ts +212 -0
- package/dist/src/node/local-client.js +70 -0
- package/dist/src/node/local-client.js.map +10 -0
- package/dist/src/queue/index.d.ts +1 -1
- package/dist/src/queue/index.js.map +3 -3
- package/dist/src/queue/recovery.js.map +2 -2
- package/dist/src/schemas/filters.d.ts +92 -28
- package/dist/src/schemas/filters.js.map +2 -2
- package/dist/src/schemas/index.d.ts +186 -43
- package/dist/src/schemas/index.js +6 -5
- package/dist/src/schemas/index.js.map +5 -5
- package/dist/src/schemas/views.d.ts +14 -3
- package/dist/src/schemas/views.js.map +2 -2
- package/dist/src/types.d.ts +9 -3
- package/dist/src/types.js +12 -1
- package/dist/src/types.js.map +1 -1
- package/migrations/0006_tx_index.ts +9 -0
- package/migrations/0007_contracts.ts +58 -0
- package/migrations/0008_drop_contracts.ts +28 -0
- package/package.json +10 -3
package/dist/src/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ interface BlocksTable {
|
|
|
11
11
|
interface TransactionsTable {
|
|
12
12
|
tx_id: string;
|
|
13
13
|
block_height: number;
|
|
14
|
+
tx_index: Generated<number>;
|
|
14
15
|
type: string;
|
|
15
16
|
sender: string;
|
|
16
17
|
status: string;
|
|
@@ -204,9 +205,14 @@ type Session = Selectable<SessionsTable>;
|
|
|
204
205
|
type InsertSession = Insertable<SessionsTable>;
|
|
205
206
|
type UsageDaily = Selectable<UsageDailyTable>;
|
|
206
207
|
type UsageSnapshot = Selectable<UsageSnapshotsTable>;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
interface EnvSchemaOutput {
|
|
209
|
+
DATABASE_URL?: string;
|
|
210
|
+
NETWORK?: "mainnet" | "testnet";
|
|
211
|
+
NETWORKS?: ("mainnet" | "testnet")[];
|
|
212
|
+
LOG_LEVEL: "debug" | "info" | "warn" | "error";
|
|
213
|
+
NODE_ENV: "development" | "production" | "test";
|
|
214
|
+
}
|
|
215
|
+
type Env = EnvSchemaOutput & {
|
|
210
216
|
enabledNetworks: ("mainnet" | "testnet")[]
|
|
211
217
|
};
|
|
212
218
|
declare function getEnv(): Env;
|
|
@@ -217,12 +223,13 @@ interface QueueStats {
|
|
|
217
223
|
failed: number;
|
|
218
224
|
total: number;
|
|
219
225
|
}
|
|
226
|
+
import { RawBuilder } from "kysely";
|
|
220
227
|
/**
|
|
221
228
|
* Safely encode a JS value as a JSONB literal for Kysely inserts/updates.
|
|
222
229
|
* Kysely + postgres.js double-encodes JSON when using parameterized queries
|
|
223
230
|
* with ::jsonb casts. This uses sql.raw to inline a properly escaped literal.
|
|
224
231
|
*/
|
|
225
|
-
declare function jsonb(value: unknown)
|
|
232
|
+
declare function jsonb(value: unknown): RawBuilder<unknown>;
|
|
226
233
|
/**
|
|
227
234
|
* Safely parse a JSONB value from the database.
|
|
228
235
|
* Handles double-encoded strings where postgres.js returns a JSON string
|
|
@@ -244,7 +251,13 @@ declare class StreamsError extends Error {
|
|
|
244
251
|
code: string;
|
|
245
252
|
cause?: unknown;
|
|
246
253
|
constructor(code: string, message: string, cause?: unknown);
|
|
247
|
-
toJSON(): {
|
|
254
|
+
toJSON(): {
|
|
255
|
+
name: string
|
|
256
|
+
code: string
|
|
257
|
+
message: string
|
|
258
|
+
stack: string | undefined
|
|
259
|
+
cause: unknown
|
|
260
|
+
};
|
|
248
261
|
}
|
|
249
262
|
/**
|
|
250
263
|
* Stream not found error
|
|
@@ -270,7 +283,14 @@ declare class DatabaseError extends StreamsError {
|
|
|
270
283
|
declare class WebhookDeliveryError extends StreamsError {
|
|
271
284
|
statusCode?: number;
|
|
272
285
|
constructor(message: string, statusCode?: number, cause?: unknown);
|
|
273
|
-
toJSON(): {
|
|
286
|
+
toJSON(): {
|
|
287
|
+
name: string
|
|
288
|
+
code: string
|
|
289
|
+
message: string
|
|
290
|
+
stack: string | undefined
|
|
291
|
+
cause: unknown
|
|
292
|
+
statusCode: number | undefined
|
|
293
|
+
};
|
|
274
294
|
}
|
|
275
295
|
/**
|
|
276
296
|
* Filter evaluation error
|
|
@@ -287,6 +307,9 @@ declare class AuthorizationError extends StreamsError {
|
|
|
287
307
|
declare class RateLimitError extends StreamsError {
|
|
288
308
|
constructor(message: string);
|
|
289
309
|
}
|
|
310
|
+
declare class ForbiddenError extends StreamsError {
|
|
311
|
+
constructor(message?: string);
|
|
312
|
+
}
|
|
290
313
|
/**
|
|
291
314
|
* Safely extract error message from unknown error value
|
|
292
315
|
*/
|
|
@@ -300,10 +323,10 @@ declare class Logger {
|
|
|
300
323
|
private get isProduction();
|
|
301
324
|
private shouldLog;
|
|
302
325
|
private formatMessage;
|
|
303
|
-
debug(message: string, meta?: Record<string, any>);
|
|
304
|
-
info(message: string, meta?: Record<string, any>);
|
|
305
|
-
warn(message: string, meta?: Record<string, any>);
|
|
306
|
-
error(message: string, meta?: Record<string, any>);
|
|
326
|
+
debug(message: string, meta?: Record<string, any>): void;
|
|
327
|
+
info(message: string, meta?: Record<string, any>): void;
|
|
328
|
+
warn(message: string, meta?: Record<string, any>): void;
|
|
329
|
+
error(message: string, meta?: Record<string, any>): void;
|
|
307
330
|
}
|
|
308
331
|
declare const logger: Logger;
|
|
309
332
|
declare namespace exports_queue {
|
|
@@ -316,7 +339,7 @@ interface QueueStats2 {
|
|
|
316
339
|
failed: number;
|
|
317
340
|
total: number;
|
|
318
341
|
}
|
|
319
|
-
declare const WORKER_ID:
|
|
342
|
+
declare const WORKER_ID: string;
|
|
320
343
|
/**
|
|
321
344
|
* Enqueue a new job for stream evaluation
|
|
322
345
|
*/
|
|
@@ -344,37 +367,109 @@ declare function stats(): Promise<QueueStats2>;
|
|
|
344
367
|
*/
|
|
345
368
|
declare function getWorkerId(): string;
|
|
346
369
|
import { z as z2 } from "zod";
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
type
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
type
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
interface StxTransferFilter {
|
|
371
|
+
type: "stx_transfer";
|
|
372
|
+
sender?: string;
|
|
373
|
+
recipient?: string;
|
|
374
|
+
minAmount?: number;
|
|
375
|
+
maxAmount?: number;
|
|
376
|
+
}
|
|
377
|
+
interface StxMintFilter {
|
|
378
|
+
type: "stx_mint";
|
|
379
|
+
recipient?: string;
|
|
380
|
+
minAmount?: number;
|
|
381
|
+
}
|
|
382
|
+
interface StxBurnFilter {
|
|
383
|
+
type: "stx_burn";
|
|
384
|
+
sender?: string;
|
|
385
|
+
minAmount?: number;
|
|
386
|
+
}
|
|
387
|
+
interface StxLockFilter {
|
|
388
|
+
type: "stx_lock";
|
|
389
|
+
lockedAddress?: string;
|
|
390
|
+
minAmount?: number;
|
|
391
|
+
}
|
|
392
|
+
interface FtTransferFilter {
|
|
393
|
+
type: "ft_transfer";
|
|
394
|
+
sender?: string;
|
|
395
|
+
recipient?: string;
|
|
396
|
+
assetIdentifier?: string;
|
|
397
|
+
minAmount?: number;
|
|
398
|
+
}
|
|
399
|
+
interface FtMintFilter {
|
|
400
|
+
type: "ft_mint";
|
|
401
|
+
recipient?: string;
|
|
402
|
+
assetIdentifier?: string;
|
|
403
|
+
minAmount?: number;
|
|
404
|
+
}
|
|
405
|
+
interface FtBurnFilter {
|
|
406
|
+
type: "ft_burn";
|
|
407
|
+
sender?: string;
|
|
408
|
+
assetIdentifier?: string;
|
|
409
|
+
minAmount?: number;
|
|
410
|
+
}
|
|
411
|
+
interface NftTransferFilter {
|
|
412
|
+
type: "nft_transfer";
|
|
413
|
+
sender?: string;
|
|
414
|
+
recipient?: string;
|
|
415
|
+
assetIdentifier?: string;
|
|
416
|
+
tokenId?: string;
|
|
417
|
+
}
|
|
418
|
+
interface NftMintFilter {
|
|
419
|
+
type: "nft_mint";
|
|
420
|
+
recipient?: string;
|
|
421
|
+
assetIdentifier?: string;
|
|
422
|
+
tokenId?: string;
|
|
423
|
+
}
|
|
424
|
+
interface NftBurnFilter {
|
|
425
|
+
type: "nft_burn";
|
|
426
|
+
sender?: string;
|
|
427
|
+
assetIdentifier?: string;
|
|
428
|
+
tokenId?: string;
|
|
429
|
+
}
|
|
430
|
+
interface ContractCallFilter {
|
|
431
|
+
type: "contract_call";
|
|
432
|
+
contractId?: string;
|
|
433
|
+
functionName?: string;
|
|
434
|
+
caller?: string;
|
|
435
|
+
}
|
|
436
|
+
interface ContractDeployFilter {
|
|
437
|
+
type: "contract_deploy";
|
|
438
|
+
deployer?: string;
|
|
439
|
+
contractName?: string;
|
|
440
|
+
}
|
|
441
|
+
interface PrintEventFilter {
|
|
442
|
+
type: "print_event";
|
|
443
|
+
contractId?: string;
|
|
444
|
+
topic?: string;
|
|
445
|
+
contains?: string;
|
|
446
|
+
}
|
|
447
|
+
type StreamFilter = StxTransferFilter | StxMintFilter | StxBurnFilter | StxLockFilter | FtTransferFilter | FtMintFilter | FtBurnFilter | NftTransferFilter | NftMintFilter | NftBurnFilter | ContractCallFilter | ContractDeployFilter | PrintEventFilter;
|
|
448
|
+
declare const StxTransferFilterSchema: z2.ZodType<StxTransferFilter>;
|
|
449
|
+
declare const StxMintFilterSchema: z2.ZodType<StxMintFilter>;
|
|
450
|
+
declare const StxBurnFilterSchema: z2.ZodType<StxBurnFilter>;
|
|
451
|
+
declare const StxLockFilterSchema: z2.ZodType<StxLockFilter>;
|
|
452
|
+
declare const FtTransferFilterSchema: z2.ZodType<FtTransferFilter>;
|
|
453
|
+
declare const FtMintFilterSchema: z2.ZodType<FtMintFilter>;
|
|
454
|
+
declare const FtBurnFilterSchema: z2.ZodType<FtBurnFilter>;
|
|
455
|
+
declare const NftTransferFilterSchema: z2.ZodType<NftTransferFilter>;
|
|
456
|
+
declare const NftMintFilterSchema: z2.ZodType<NftMintFilter>;
|
|
457
|
+
declare const NftBurnFilterSchema: z2.ZodType<NftBurnFilter>;
|
|
458
|
+
declare const ContractCallFilterSchema: z2.ZodType<ContractCallFilter>;
|
|
459
|
+
declare const ContractDeployFilterSchema: z2.ZodType<ContractDeployFilter>;
|
|
460
|
+
declare const PrintEventFilterSchema: z2.ZodType<PrintEventFilter>;
|
|
461
|
+
declare const StreamFilterSchema: z2.ZodType<StreamFilter>;
|
|
375
462
|
import { z as z3 } from "zod";
|
|
376
|
-
|
|
377
|
-
|
|
463
|
+
interface DeployViewRequest {
|
|
464
|
+
name: string;
|
|
465
|
+
version?: string;
|
|
466
|
+
description?: string;
|
|
467
|
+
sources: string[];
|
|
468
|
+
schema: Record<string, unknown>;
|
|
469
|
+
handlerCode: string;
|
|
470
|
+
reindex?: boolean;
|
|
471
|
+
}
|
|
472
|
+
declare const DeployViewRequestSchema: z3.ZodType<DeployViewRequest>;
|
|
378
473
|
interface DeployViewResponse {
|
|
379
474
|
action: "created" | "unchanged" | "updated" | "reindexed";
|
|
380
475
|
viewId: string;
|
|
@@ -402,7 +497,10 @@ interface ViewDetail {
|
|
|
402
497
|
};
|
|
403
498
|
tables: Record<string, {
|
|
404
499
|
endpoint: string
|
|
405
|
-
columns: Record<string,
|
|
500
|
+
columns: Record<string, {
|
|
501
|
+
type: string
|
|
502
|
+
nullable?: boolean
|
|
503
|
+
}>
|
|
406
504
|
rowCount: number
|
|
407
505
|
example: string
|
|
408
506
|
}>;
|
|
@@ -423,18 +521,86 @@ interface ViewQueryParams {
|
|
|
423
521
|
filters?: Record<string, string>;
|
|
424
522
|
}
|
|
425
523
|
import { z as z4 } from "zod";
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
524
|
+
interface StreamOptions {
|
|
525
|
+
decodeClarityValues: boolean;
|
|
526
|
+
includeRawTx: boolean;
|
|
527
|
+
includeBlockMetadata: boolean;
|
|
528
|
+
rateLimit: number;
|
|
529
|
+
timeoutMs: number;
|
|
530
|
+
maxRetries: number;
|
|
531
|
+
}
|
|
532
|
+
interface CreateStream {
|
|
533
|
+
name: string;
|
|
534
|
+
webhookUrl: string;
|
|
535
|
+
filters: StreamFilter[];
|
|
536
|
+
options?: StreamOptions;
|
|
537
|
+
startBlock?: number;
|
|
538
|
+
endBlock?: number;
|
|
539
|
+
}
|
|
540
|
+
interface UpdateStream {
|
|
541
|
+
name?: string;
|
|
542
|
+
webhookUrl?: string;
|
|
543
|
+
filters?: StreamFilter[];
|
|
544
|
+
options?: Partial<StreamOptions>;
|
|
545
|
+
}
|
|
546
|
+
interface WebhookPayload {
|
|
547
|
+
streamId: string;
|
|
548
|
+
streamName: string;
|
|
549
|
+
block: {
|
|
550
|
+
height: number
|
|
551
|
+
hash: string
|
|
552
|
+
parentHash: string
|
|
553
|
+
burnBlockHeight: number
|
|
554
|
+
timestamp: number
|
|
555
|
+
};
|
|
556
|
+
matches: {
|
|
557
|
+
transactions: Array<{
|
|
558
|
+
txId: string
|
|
559
|
+
type: string
|
|
560
|
+
sender: string
|
|
561
|
+
status: string
|
|
562
|
+
contractId: string | null
|
|
563
|
+
functionName: string | null
|
|
564
|
+
rawTx?: string
|
|
565
|
+
}>
|
|
566
|
+
events: Array<{
|
|
567
|
+
txId: string
|
|
568
|
+
eventIndex: number
|
|
569
|
+
type: string
|
|
570
|
+
data?: any
|
|
571
|
+
}>
|
|
572
|
+
};
|
|
573
|
+
isBackfill: boolean;
|
|
574
|
+
deliveredAt: string;
|
|
575
|
+
}
|
|
576
|
+
interface StreamMetricsResponse {
|
|
577
|
+
totalDeliveries: number;
|
|
578
|
+
failedDeliveries: number;
|
|
579
|
+
lastTriggeredAt: string | null;
|
|
580
|
+
lastTriggeredBlock: number | null;
|
|
581
|
+
errorMessage: string | null;
|
|
582
|
+
}
|
|
583
|
+
interface StreamResponse {
|
|
584
|
+
id: string;
|
|
585
|
+
name: string;
|
|
586
|
+
status: "inactive" | "active" | "paused" | "failed";
|
|
587
|
+
webhookUrl: string;
|
|
588
|
+
filters: StreamFilter[];
|
|
589
|
+
options: StreamOptions;
|
|
590
|
+
totalDeliveries: number;
|
|
591
|
+
failedDeliveries: number;
|
|
592
|
+
lastTriggeredAt?: string | null;
|
|
593
|
+
lastTriggeredBlock?: number | null;
|
|
594
|
+
errorMessage?: string | null;
|
|
595
|
+
createdAt: string;
|
|
596
|
+
updatedAt: string;
|
|
597
|
+
}
|
|
598
|
+
declare const StreamOptionsSchema: z4.ZodType<StreamOptions>;
|
|
599
|
+
declare const CreateStreamSchema: z4.ZodType<CreateStream>;
|
|
600
|
+
declare const UpdateStreamSchema: z4.ZodType<UpdateStream>;
|
|
601
|
+
declare const WebhookPayloadSchema: z4.ZodType<WebhookPayload>;
|
|
602
|
+
declare const StreamMetricsSchema: z4.ZodType<StreamMetricsResponse>;
|
|
603
|
+
declare const StreamResponseSchema: z4.ZodType<StreamResponse>;
|
|
438
604
|
interface CreateStreamResponse {
|
|
439
605
|
stream: StreamResponse;
|
|
440
606
|
webhookSecret: string;
|
|
@@ -479,4 +645,4 @@ declare function createSignatureHeader(payload: string, secret: string, timestam
|
|
|
479
645
|
* Returns true if valid, false otherwise
|
|
480
646
|
*/
|
|
481
647
|
declare function verifySignatureHeader(payload: string, header: string, secret: string, toleranceSeconds?: number): boolean;
|
|
482
|
-
export { sql, exports_queue as queue, parseJsonb, logger, jsonb, getRawClient, getErrorMessage, 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 };
|
|
648
|
+
export { sql, exports_queue as queue, parseJsonb, logger, jsonb, getRawClient, getErrorMessage, 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, ForbiddenError, 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 };
|
package/dist/src/index.js
CHANGED
|
@@ -108,8 +108,13 @@ class WebhookDeliveryError extends StreamsError {
|
|
|
108
108
|
this.statusCode = statusCode;
|
|
109
109
|
}
|
|
110
110
|
toJSON() {
|
|
111
|
+
const base = super.toJSON();
|
|
111
112
|
return {
|
|
112
|
-
|
|
113
|
+
name: base.name,
|
|
114
|
+
code: base.code,
|
|
115
|
+
message: base.message,
|
|
116
|
+
stack: base.stack,
|
|
117
|
+
cause: base.cause,
|
|
113
118
|
statusCode: this.statusCode
|
|
114
119
|
};
|
|
115
120
|
}
|
|
@@ -138,6 +143,12 @@ class RateLimitError extends StreamsError {
|
|
|
138
143
|
super("RATE_LIMIT_ERROR", message);
|
|
139
144
|
}
|
|
140
145
|
}
|
|
146
|
+
|
|
147
|
+
class ForbiddenError extends StreamsError {
|
|
148
|
+
constructor(message = "Forbidden") {
|
|
149
|
+
super("FORBIDDEN", message);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
141
152
|
function getErrorMessage(err) {
|
|
142
153
|
return err instanceof Error ? err.message : String(err);
|
|
143
154
|
}
|
|
@@ -472,7 +483,7 @@ var DeployViewRequestSchema = z3.object({
|
|
|
472
483
|
});
|
|
473
484
|
// src/schemas/stream.ts
|
|
474
485
|
import { z as z4 } from "zod";
|
|
475
|
-
var
|
|
486
|
+
var streamOptionsShape = z4.object({
|
|
476
487
|
decodeClarityValues: z4.boolean().default(true),
|
|
477
488
|
includeRawTx: z4.boolean().default(false),
|
|
478
489
|
includeBlockMetadata: z4.boolean().default(true),
|
|
@@ -480,11 +491,12 @@ var StreamOptionsSchema = z4.object({
|
|
|
480
491
|
timeoutMs: z4.number().int().positive().max(30000).default(1e4),
|
|
481
492
|
maxRetries: z4.number().int().min(0).max(10).default(3)
|
|
482
493
|
});
|
|
494
|
+
var StreamOptionsSchema = streamOptionsShape;
|
|
483
495
|
var CreateStreamSchema = z4.object({
|
|
484
496
|
name: z4.string().min(1).max(255),
|
|
485
497
|
webhookUrl: z4.string().url(),
|
|
486
498
|
filters: z4.array(StreamFilterSchema).min(1),
|
|
487
|
-
options:
|
|
499
|
+
options: streamOptionsShape.optional().default({}),
|
|
488
500
|
startBlock: z4.number().int().positive().optional(),
|
|
489
501
|
endBlock: z4.number().int().positive().optional()
|
|
490
502
|
});
|
|
@@ -492,7 +504,7 @@ var UpdateStreamSchema = z4.object({
|
|
|
492
504
|
name: z4.string().min(1).max(255).optional(),
|
|
493
505
|
webhookUrl: z4.string().url().optional(),
|
|
494
506
|
filters: z4.array(StreamFilterSchema).min(1).optional(),
|
|
495
|
-
options:
|
|
507
|
+
options: streamOptionsShape.partial().optional()
|
|
496
508
|
}).refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided for update" });
|
|
497
509
|
var WebhookPayloadSchema = z4.object({
|
|
498
510
|
streamId: z4.string().uuid(),
|
|
@@ -537,7 +549,7 @@ var StreamResponseSchema = z4.object({
|
|
|
537
549
|
status: z4.enum(["inactive", "active", "paused", "failed"]),
|
|
538
550
|
webhookUrl: z4.string().url(),
|
|
539
551
|
filters: z4.array(StreamFilterSchema),
|
|
540
|
-
options:
|
|
552
|
+
options: streamOptionsShape,
|
|
541
553
|
totalDeliveries: z4.number().int().default(0),
|
|
542
554
|
failedDeliveries: z4.number().int().default(0),
|
|
543
555
|
lastTriggeredAt: z4.string().datetime().nullable().optional(),
|
|
@@ -633,6 +645,7 @@ export {
|
|
|
633
645
|
FtTransferFilterSchema,
|
|
634
646
|
FtMintFilterSchema,
|
|
635
647
|
FtBurnFilterSchema,
|
|
648
|
+
ForbiddenError,
|
|
636
649
|
FilterEvaluationError,
|
|
637
650
|
DeployViewRequestSchema,
|
|
638
651
|
DatabaseError,
|
|
@@ -643,5 +656,5 @@ export {
|
|
|
643
656
|
AuthenticationError
|
|
644
657
|
};
|
|
645
658
|
|
|
646
|
-
//# debugId=
|
|
659
|
+
//# debugId=543E03ECF9A94C8C64756E2164756E21
|
|
647
660
|
//# sourceMappingURL=index.js.map
|