@secondlayer/shared 6.14.1 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/db/index.d.ts +28 -5
- package/dist/src/db/queries/chain-reorgs.d.ts +26 -4
- package/dist/src/db/queries/contracts.d.ts +26 -4
- package/dist/src/db/queries/integrity.d.ts +26 -4
- package/dist/src/db/queries/subgraph-gaps.d.ts +26 -4
- package/dist/src/db/queries/subgraph-operations.d.ts +26 -4
- package/dist/src/db/queries/subgraphs.d.ts +26 -4
- package/dist/src/db/queries/subscriptions.d.ts +41 -7
- package/dist/src/db/queries/subscriptions.js +10 -3
- package/dist/src/db/queries/subscriptions.js.map +3 -3
- package/dist/src/db/schema.d.ts +28 -5
- package/dist/src/index-http.d.ts +110 -0
- package/dist/src/index-http.js +93 -0
- package/dist/src/index-http.js.map +11 -0
- package/dist/src/index-internal-auth.d.ts +3 -0
- package/dist/src/index-internal-auth.js +29 -0
- package/dist/src/index-internal-auth.js.map +10 -0
- package/dist/src/index.d.ts +110 -10
- package/dist/src/index.js +177 -4
- package/dist/src/index.js.map +3 -3
- package/dist/src/node/local-client.d.ts +26 -4
- package/dist/src/schemas/index.d.ts +82 -5
- package/dist/src/schemas/index.js +177 -4
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subscriptions.d.ts +117 -6
- package/dist/src/schemas/subscriptions.js +182 -5
- package/dist/src/schemas/subscriptions.js.map +3 -3
- package/migrations/0088_chain_subscriptions.ts +86 -0
- package/package.json +9 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -635,6 +635,7 @@ interface Database {
|
|
|
635
635
|
subscriptions: SubscriptionsTable;
|
|
636
636
|
subscription_outbox: SubscriptionOutboxTable;
|
|
637
637
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
638
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
638
639
|
decoded_events: DecodedEventsTable;
|
|
639
640
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
640
641
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -803,6 +804,10 @@ type UpdateChatSession = Updateable<ChatSessionsTable>;
|
|
|
803
804
|
type ChatMessage = Selectable<ChatMessagesTable>;
|
|
804
805
|
type InsertChatMessage = Insertable<ChatMessagesTable>;
|
|
805
806
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
807
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
808
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
809
|
+
* clock (no subgraph). See migration 0088. */
|
|
810
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
806
811
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
807
812
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
808
813
|
interface SubscriptionsTable {
|
|
@@ -811,8 +816,15 @@ interface SubscriptionsTable {
|
|
|
811
816
|
project_id: string | null;
|
|
812
817
|
name: string;
|
|
813
818
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
814
|
-
|
|
815
|
-
|
|
819
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
820
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
821
|
+
subgraph_name: string | null;
|
|
822
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
823
|
+
table_name: string | null;
|
|
824
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
825
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
826
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
827
|
+
triggers: unknown | null;
|
|
816
828
|
filter: Generated<unknown>;
|
|
817
829
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
818
830
|
runtime: SubscriptionRuntime | null;
|
|
@@ -837,8 +849,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
837
849
|
interface SubscriptionOutboxTable {
|
|
838
850
|
id: Generated<string>;
|
|
839
851
|
subscription_id: string;
|
|
840
|
-
|
|
841
|
-
|
|
852
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
853
|
+
/** Null for chain-subscription rows. */
|
|
854
|
+
subgraph_name: string | null;
|
|
855
|
+
/** Null for chain-subscription rows. */
|
|
856
|
+
table_name: string | null;
|
|
842
857
|
block_height: number | bigint;
|
|
843
858
|
tx_id: string | null;
|
|
844
859
|
row_pk: unknown;
|
|
@@ -874,6 +889,14 @@ interface SubscriptionDeliveriesTable {
|
|
|
874
889
|
}
|
|
875
890
|
type SubscriptionDelivery = Selectable<SubscriptionDeliveriesTable>;
|
|
876
891
|
type InsertSubscriptionDelivery = Insertable<SubscriptionDeliveriesTable>;
|
|
892
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
893
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
894
|
+
interface TriggerEvaluatorStateTable {
|
|
895
|
+
id: Generated<boolean>;
|
|
896
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
897
|
+
updated_at: Generated<Date>;
|
|
898
|
+
}
|
|
899
|
+
type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
|
|
877
900
|
interface EnvSchemaOutput {
|
|
878
901
|
DATABASE_URL?: string;
|
|
879
902
|
/**
|
|
@@ -1293,6 +1316,8 @@ declare const CreateSubscriptionRequestSchema: z4.ZodType<ParsedCreateSubscripti
|
|
|
1293
1316
|
declare const UpdateSubscriptionRequestSchema: z4.ZodType<UpdateSubscriptionRequest>;
|
|
1294
1317
|
declare const ReplaySubscriptionRequestSchema: z4.ZodType<ReplaySubscriptionRequest>;
|
|
1295
1318
|
type SubscriptionStatus2 = (typeof SUBSCRIPTION_STATUSES)[number];
|
|
1319
|
+
/** Polymorphic subscription mode (mirrors db/types `SubscriptionKind`). */
|
|
1320
|
+
type SubscriptionKind2 = "subgraph" | "chain";
|
|
1296
1321
|
type SubscriptionFormat2 = (typeof SUBSCRIPTION_FORMATS)[number];
|
|
1297
1322
|
type SubscriptionRuntime2 = (typeof SUBSCRIPTION_RUNTIMES)[number];
|
|
1298
1323
|
type SubscriptionFilterPrimitive = string | number | boolean;
|
|
@@ -1313,12 +1338,82 @@ type SubscriptionFilterOperator = {
|
|
|
1313
1338
|
};
|
|
1314
1339
|
type SubscriptionFilterClause = SubscriptionFilterPrimitive | SubscriptionFilterOperator;
|
|
1315
1340
|
type SubscriptionFilter = Record<string, SubscriptionFilterClause>;
|
|
1341
|
+
/** Non-negative integer amount over JSON (string for uint128 safety, or number). */
|
|
1342
|
+
type ChainTriggerAmount = string | number;
|
|
1343
|
+
interface TraitScoped {
|
|
1344
|
+
trait?: string;
|
|
1345
|
+
}
|
|
1346
|
+
/** JSON mirror of the subgraph runtime's `SubgraphFilter` union. */
|
|
1347
|
+
type ChainTrigger = {
|
|
1348
|
+
type: "stx_transfer"
|
|
1349
|
+
sender?: string
|
|
1350
|
+
recipient?: string
|
|
1351
|
+
minAmount?: ChainTriggerAmount
|
|
1352
|
+
maxAmount?: ChainTriggerAmount
|
|
1353
|
+
} | {
|
|
1354
|
+
type: "stx_mint"
|
|
1355
|
+
recipient?: string
|
|
1356
|
+
minAmount?: ChainTriggerAmount
|
|
1357
|
+
} | {
|
|
1358
|
+
type: "stx_burn"
|
|
1359
|
+
sender?: string
|
|
1360
|
+
minAmount?: ChainTriggerAmount
|
|
1361
|
+
} | {
|
|
1362
|
+
type: "stx_lock"
|
|
1363
|
+
lockedAddress?: string
|
|
1364
|
+
minAmount?: ChainTriggerAmount
|
|
1365
|
+
} | ({
|
|
1366
|
+
type: "ft_transfer"
|
|
1367
|
+
assetIdentifier?: string
|
|
1368
|
+
sender?: string
|
|
1369
|
+
recipient?: string
|
|
1370
|
+
minAmount?: ChainTriggerAmount
|
|
1371
|
+
} & TraitScoped) | ({
|
|
1372
|
+
type: "ft_mint"
|
|
1373
|
+
assetIdentifier?: string
|
|
1374
|
+
recipient?: string
|
|
1375
|
+
minAmount?: ChainTriggerAmount
|
|
1376
|
+
} & TraitScoped) | ({
|
|
1377
|
+
type: "ft_burn"
|
|
1378
|
+
assetIdentifier?: string
|
|
1379
|
+
sender?: string
|
|
1380
|
+
minAmount?: ChainTriggerAmount
|
|
1381
|
+
} & TraitScoped) | ({
|
|
1382
|
+
type: "nft_transfer"
|
|
1383
|
+
assetIdentifier?: string
|
|
1384
|
+
sender?: string
|
|
1385
|
+
recipient?: string
|
|
1386
|
+
} & TraitScoped) | ({
|
|
1387
|
+
type: "nft_mint"
|
|
1388
|
+
assetIdentifier?: string
|
|
1389
|
+
recipient?: string
|
|
1390
|
+
} & TraitScoped) | ({
|
|
1391
|
+
type: "nft_burn"
|
|
1392
|
+
assetIdentifier?: string
|
|
1393
|
+
sender?: string
|
|
1394
|
+
} & TraitScoped) | ({
|
|
1395
|
+
type: "contract_call"
|
|
1396
|
+
contractId?: string
|
|
1397
|
+
functionName?: string
|
|
1398
|
+
caller?: string
|
|
1399
|
+
} & TraitScoped) | {
|
|
1400
|
+
type: "contract_deploy"
|
|
1401
|
+
deployer?: string
|
|
1402
|
+
contractName?: string
|
|
1403
|
+
} | ({
|
|
1404
|
+
type: "print_event"
|
|
1405
|
+
contractId?: string
|
|
1406
|
+
topic?: string
|
|
1407
|
+
} & TraitScoped);
|
|
1316
1408
|
interface CreateSubscriptionRequest {
|
|
1317
1409
|
name: string;
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1410
|
+
/** Subgraph mode. */
|
|
1411
|
+
subgraphName?: string;
|
|
1412
|
+
tableName?: string;
|
|
1321
1413
|
filter?: SubscriptionFilter;
|
|
1414
|
+
/** Chain mode. */
|
|
1415
|
+
triggers?: ChainTrigger[];
|
|
1416
|
+
url: string;
|
|
1322
1417
|
format?: SubscriptionFormat2;
|
|
1323
1418
|
runtime?: SubscriptionRuntime2 | null;
|
|
1324
1419
|
authConfig?: Record<string, unknown>;
|
|
@@ -1351,8 +1446,11 @@ interface SubscriptionSummary {
|
|
|
1351
1446
|
id: string;
|
|
1352
1447
|
name: string;
|
|
1353
1448
|
status: SubscriptionStatus2;
|
|
1354
|
-
|
|
1355
|
-
|
|
1449
|
+
kind: SubscriptionKind2;
|
|
1450
|
+
/** Null for chain subscriptions. */
|
|
1451
|
+
subgraphName: string | null;
|
|
1452
|
+
/** Null for chain subscriptions. */
|
|
1453
|
+
tableName: string | null;
|
|
1356
1454
|
format: SubscriptionFormat2;
|
|
1357
1455
|
runtime: SubscriptionRuntime2 | null;
|
|
1358
1456
|
url: string;
|
|
@@ -1363,6 +1461,8 @@ interface SubscriptionSummary {
|
|
|
1363
1461
|
}
|
|
1364
1462
|
interface SubscriptionDetail extends SubscriptionSummary {
|
|
1365
1463
|
filter: Record<string, unknown>;
|
|
1464
|
+
/** Chain-trigger filters (chain subscriptions only). */
|
|
1465
|
+
triggers: ChainTrigger[] | null;
|
|
1366
1466
|
authConfig: Record<string, unknown>;
|
|
1367
1467
|
maxRetries: number;
|
|
1368
1468
|
timeoutMs: number;
|
|
@@ -1558,4 +1658,4 @@ declare function publicKeyPemFromPrivate(privateKeyPem: string): string;
|
|
|
1558
1658
|
declare function ed25519KeyId(publicKeyPem: string): string;
|
|
1559
1659
|
declare function signEd25519(payload: string, privateKey: KeyObject): string;
|
|
1560
1660
|
declare function verifyEd25519(payload: string, signatureBase64: string, publicKey: KeyObject): boolean;
|
|
1561
|
-
export { validateSubscriptionFilterForTable, sql, parseJsonb, logger, jsonb, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getErrorMessage, getEnv, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatSubscriptionSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, closeDb, VersionConflictError, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantSuspendedError, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionStatus, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionFormatSchema, SubscriptionFormat, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphSpecOptions, SubgraphSpecFormat, SubgraphResourceWarning, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, SubgraphAgentSchema, Subgraph, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, StreamsCursor, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcEventsTable, SbtcEventTopic, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, RotateSecretResponse, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, ReindexResponse, RateLimitError, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, PrintEventFilterSchema, PrintEventFilter, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, NotFoundError, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, L2DecoderCheckpointsTable, KeyRotatedError, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertChatSession, InsertChatMessage, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, ForbiddenError, EventsTable, EventsArchiveTable, EventFilterSchema, EventFilter, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecodedEventsTable, DeadRow, DeadLetterEventsTable, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, ContractsTable, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, Contract, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, ChainReorgsTable, CODE_TO_STATUS, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
|
1661
|
+
export { validateSubscriptionFilterForTable, sql, parseJsonb, logger, jsonb, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getErrorMessage, getEnv, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatSubscriptionSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, closeDb, VersionConflictError, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantSuspendedError, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionStatus, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormatSchema, SubscriptionFormat, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphSpecOptions, SubgraphSpecFormat, SubgraphResourceWarning, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, SubgraphAgentSchema, Subgraph, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, StreamsCursor, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcEventsTable, SbtcEventTopic, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, RotateSecretResponse, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, ReindexResponse, RateLimitError, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, PrintEventFilterSchema, PrintEventFilter, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, NotFoundError, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, L2DecoderCheckpointsTable, KeyRotatedError, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertChatSession, InsertChatMessage, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, ForbiddenError, EventsTable, EventsArchiveTable, EventFilterSchema, EventFilter, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecodedEventsTable, DeadRow, DeadLetterEventsTable, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, ContractsTable, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, Contract, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, ChainReorgsTable, CODE_TO_STATUS, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/dist/src/index.js
CHANGED
|
@@ -542,18 +542,137 @@ var SubscriptionFilterClauseSchema = z4.union([
|
|
|
542
542
|
SubscriptionFilterOperatorSchema
|
|
543
543
|
]);
|
|
544
544
|
var SubscriptionFilterSchema = z4.record(z4.string().min(1), SubscriptionFilterClauseSchema);
|
|
545
|
+
var CHAIN_TRIGGER_TYPES = [
|
|
546
|
+
"stx_transfer",
|
|
547
|
+
"stx_mint",
|
|
548
|
+
"stx_burn",
|
|
549
|
+
"stx_lock",
|
|
550
|
+
"ft_transfer",
|
|
551
|
+
"ft_mint",
|
|
552
|
+
"ft_burn",
|
|
553
|
+
"nft_transfer",
|
|
554
|
+
"nft_mint",
|
|
555
|
+
"nft_burn",
|
|
556
|
+
"contract_call",
|
|
557
|
+
"contract_deploy",
|
|
558
|
+
"print_event"
|
|
559
|
+
];
|
|
560
|
+
var triggerAmount = z4.union([
|
|
561
|
+
z4.string().trim().regex(/^\d+$/, "must be a non-negative integer string"),
|
|
562
|
+
z4.number().int().nonnegative()
|
|
563
|
+
]);
|
|
564
|
+
var triggerPattern = z4.string().trim().min(1);
|
|
565
|
+
var trait = z4.string().trim().min(1);
|
|
566
|
+
var ChainTriggerSchema = z4.discriminatedUnion("type", [
|
|
567
|
+
z4.object({
|
|
568
|
+
type: z4.literal("stx_transfer"),
|
|
569
|
+
sender: triggerPattern.optional(),
|
|
570
|
+
recipient: triggerPattern.optional(),
|
|
571
|
+
minAmount: triggerAmount.optional(),
|
|
572
|
+
maxAmount: triggerAmount.optional()
|
|
573
|
+
}).strict(),
|
|
574
|
+
z4.object({
|
|
575
|
+
type: z4.literal("stx_mint"),
|
|
576
|
+
recipient: triggerPattern.optional(),
|
|
577
|
+
minAmount: triggerAmount.optional()
|
|
578
|
+
}).strict(),
|
|
579
|
+
z4.object({
|
|
580
|
+
type: z4.literal("stx_burn"),
|
|
581
|
+
sender: triggerPattern.optional(),
|
|
582
|
+
minAmount: triggerAmount.optional()
|
|
583
|
+
}).strict(),
|
|
584
|
+
z4.object({
|
|
585
|
+
type: z4.literal("stx_lock"),
|
|
586
|
+
lockedAddress: triggerPattern.optional(),
|
|
587
|
+
minAmount: triggerAmount.optional()
|
|
588
|
+
}).strict(),
|
|
589
|
+
z4.object({
|
|
590
|
+
type: z4.literal("ft_transfer"),
|
|
591
|
+
assetIdentifier: triggerPattern.optional(),
|
|
592
|
+
sender: triggerPattern.optional(),
|
|
593
|
+
recipient: triggerPattern.optional(),
|
|
594
|
+
minAmount: triggerAmount.optional(),
|
|
595
|
+
trait: trait.optional()
|
|
596
|
+
}).strict(),
|
|
597
|
+
z4.object({
|
|
598
|
+
type: z4.literal("ft_mint"),
|
|
599
|
+
assetIdentifier: triggerPattern.optional(),
|
|
600
|
+
recipient: triggerPattern.optional(),
|
|
601
|
+
minAmount: triggerAmount.optional(),
|
|
602
|
+
trait: trait.optional()
|
|
603
|
+
}).strict(),
|
|
604
|
+
z4.object({
|
|
605
|
+
type: z4.literal("ft_burn"),
|
|
606
|
+
assetIdentifier: triggerPattern.optional(),
|
|
607
|
+
sender: triggerPattern.optional(),
|
|
608
|
+
minAmount: triggerAmount.optional(),
|
|
609
|
+
trait: trait.optional()
|
|
610
|
+
}).strict(),
|
|
611
|
+
z4.object({
|
|
612
|
+
type: z4.literal("nft_transfer"),
|
|
613
|
+
assetIdentifier: triggerPattern.optional(),
|
|
614
|
+
sender: triggerPattern.optional(),
|
|
615
|
+
recipient: triggerPattern.optional(),
|
|
616
|
+
trait: trait.optional()
|
|
617
|
+
}).strict(),
|
|
618
|
+
z4.object({
|
|
619
|
+
type: z4.literal("nft_mint"),
|
|
620
|
+
assetIdentifier: triggerPattern.optional(),
|
|
621
|
+
recipient: triggerPattern.optional(),
|
|
622
|
+
trait: trait.optional()
|
|
623
|
+
}).strict(),
|
|
624
|
+
z4.object({
|
|
625
|
+
type: z4.literal("nft_burn"),
|
|
626
|
+
assetIdentifier: triggerPattern.optional(),
|
|
627
|
+
sender: triggerPattern.optional(),
|
|
628
|
+
trait: trait.optional()
|
|
629
|
+
}).strict(),
|
|
630
|
+
z4.object({
|
|
631
|
+
type: z4.literal("contract_call"),
|
|
632
|
+
contractId: triggerPattern.optional(),
|
|
633
|
+
functionName: triggerPattern.optional(),
|
|
634
|
+
caller: triggerPattern.optional(),
|
|
635
|
+
trait: trait.optional()
|
|
636
|
+
}).strict(),
|
|
637
|
+
z4.object({
|
|
638
|
+
type: z4.literal("contract_deploy"),
|
|
639
|
+
deployer: triggerPattern.optional(),
|
|
640
|
+
contractName: triggerPattern.optional()
|
|
641
|
+
}).strict(),
|
|
642
|
+
z4.object({
|
|
643
|
+
type: z4.literal("print_event"),
|
|
644
|
+
contractId: triggerPattern.optional(),
|
|
645
|
+
topic: triggerPattern.optional(),
|
|
646
|
+
trait: trait.optional()
|
|
647
|
+
}).strict()
|
|
648
|
+
]);
|
|
649
|
+
var ChainTriggersSchema = z4.array(ChainTriggerSchema).min(1).max(50);
|
|
545
650
|
var CreateSubscriptionRequestSchema = z4.object({
|
|
546
651
|
name,
|
|
547
|
-
subgraphName: resourceName,
|
|
548
|
-
tableName: resourceName,
|
|
549
|
-
url: webhookUrl,
|
|
652
|
+
subgraphName: resourceName.optional(),
|
|
653
|
+
tableName: resourceName.optional(),
|
|
550
654
|
filter: SubscriptionFilterSchema.optional(),
|
|
655
|
+
triggers: ChainTriggersSchema.optional(),
|
|
656
|
+
url: webhookUrl,
|
|
551
657
|
format: SubscriptionFormatSchema.default("standard-webhooks"),
|
|
552
658
|
runtime: SubscriptionRuntimeSchema.nullable().optional(),
|
|
553
659
|
authConfig: z4.record(z4.string(), z4.unknown()).optional(),
|
|
554
660
|
maxRetries: z4.number().int().min(0).max(100).optional(),
|
|
555
661
|
timeoutMs: z4.number().int().min(100).max(300000).optional(),
|
|
556
662
|
concurrency: z4.number().int().min(1).max(100).optional()
|
|
663
|
+
}).refine((v) => {
|
|
664
|
+
const subgraphMode = v.subgraphName !== undefined || v.tableName !== undefined;
|
|
665
|
+
const chainMode = v.triggers !== undefined;
|
|
666
|
+
if (chainMode && subgraphMode)
|
|
667
|
+
return false;
|
|
668
|
+
if (chainMode)
|
|
669
|
+
return true;
|
|
670
|
+
return v.subgraphName !== undefined && v.tableName !== undefined;
|
|
671
|
+
}, {
|
|
672
|
+
message: "provide either { subgraphName, tableName } for a subgraph subscription OR { triggers } for a chain subscription — not both"
|
|
673
|
+
}).refine((v) => v.filter === undefined || v.triggers === undefined, {
|
|
674
|
+
message: "`filter` applies to subgraph subscriptions; chain subscriptions use `triggers`",
|
|
675
|
+
path: ["filter"]
|
|
557
676
|
});
|
|
558
677
|
var UpdateSubscriptionRequestSchema = z4.object({
|
|
559
678
|
name: name.optional(),
|
|
@@ -576,6 +695,60 @@ var ReplaySubscriptionRequestSchema = z4.object({
|
|
|
576
695
|
message: "fromBlock must be less than or equal to toBlock",
|
|
577
696
|
path: ["toBlock"]
|
|
578
697
|
});
|
|
698
|
+
var on = {
|
|
699
|
+
stxTransfer: (f = {}) => ({
|
|
700
|
+
type: "stx_transfer",
|
|
701
|
+
...f
|
|
702
|
+
}),
|
|
703
|
+
stxMint: (f = {}) => ({
|
|
704
|
+
type: "stx_mint",
|
|
705
|
+
...f
|
|
706
|
+
}),
|
|
707
|
+
stxBurn: (f = {}) => ({
|
|
708
|
+
type: "stx_burn",
|
|
709
|
+
...f
|
|
710
|
+
}),
|
|
711
|
+
stxLock: (f = {}) => ({
|
|
712
|
+
type: "stx_lock",
|
|
713
|
+
...f
|
|
714
|
+
}),
|
|
715
|
+
ftTransfer: (f = {}) => ({
|
|
716
|
+
type: "ft_transfer",
|
|
717
|
+
...f
|
|
718
|
+
}),
|
|
719
|
+
ftMint: (f = {}) => ({
|
|
720
|
+
type: "ft_mint",
|
|
721
|
+
...f
|
|
722
|
+
}),
|
|
723
|
+
ftBurn: (f = {}) => ({
|
|
724
|
+
type: "ft_burn",
|
|
725
|
+
...f
|
|
726
|
+
}),
|
|
727
|
+
nftTransfer: (f = {}) => ({
|
|
728
|
+
type: "nft_transfer",
|
|
729
|
+
...f
|
|
730
|
+
}),
|
|
731
|
+
nftMint: (f = {}) => ({
|
|
732
|
+
type: "nft_mint",
|
|
733
|
+
...f
|
|
734
|
+
}),
|
|
735
|
+
nftBurn: (f = {}) => ({
|
|
736
|
+
type: "nft_burn",
|
|
737
|
+
...f
|
|
738
|
+
}),
|
|
739
|
+
contractCall: (f = {}) => ({
|
|
740
|
+
type: "contract_call",
|
|
741
|
+
...f
|
|
742
|
+
}),
|
|
743
|
+
contractDeploy: (f = {}) => ({
|
|
744
|
+
type: "contract_deploy",
|
|
745
|
+
...f
|
|
746
|
+
}),
|
|
747
|
+
printEvent: (f = {}) => ({
|
|
748
|
+
type: "print_event",
|
|
749
|
+
...f
|
|
750
|
+
})
|
|
751
|
+
};
|
|
579
752
|
var SCALAR_COLUMN_TYPES = new Set([
|
|
580
753
|
"text",
|
|
581
754
|
"uint",
|
|
@@ -1176,5 +1349,5 @@ export {
|
|
|
1176
1349
|
AuthenticationError
|
|
1177
1350
|
};
|
|
1178
1351
|
|
|
1179
|
-
//# debugId=
|
|
1352
|
+
//# debugId=4BE5ABD7435A3A0E64756E2164756E21
|
|
1180
1353
|
//# sourceMappingURL=index.js.map
|