@secondlayer/shared 6.38.0 → 6.39.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/index.d.ts +182 -1
- package/package.json +5 -2
package/dist/src/index.d.ts
CHANGED
|
@@ -2872,4 +2872,185 @@ interface ChainReorgRollbackEnvelope {
|
|
|
2872
2872
|
}
|
|
2873
2873
|
/** Any chain-subscription webhook body. Discriminate on `action`. */
|
|
2874
2874
|
type ChainWebhookEnvelope = ChainApplyEnvelope | ChainReorgRollbackEnvelope;
|
|
2875
|
-
|
|
2875
|
+
/** `event.data` for a `stx_transfer` delivery. */
|
|
2876
|
+
interface ChainStxTransferData {
|
|
2877
|
+
sender?: string;
|
|
2878
|
+
recipient?: string;
|
|
2879
|
+
amount: string;
|
|
2880
|
+
/** Always present; `""` when the transfer carried no memo. */
|
|
2881
|
+
memo: string;
|
|
2882
|
+
}
|
|
2883
|
+
/** `event.data` for a `stx_mint` delivery. */
|
|
2884
|
+
interface ChainStxMintData {
|
|
2885
|
+
recipient?: string;
|
|
2886
|
+
amount: string;
|
|
2887
|
+
}
|
|
2888
|
+
/** `event.data` for a `stx_burn` delivery. */
|
|
2889
|
+
interface ChainStxBurnData {
|
|
2890
|
+
sender?: string;
|
|
2891
|
+
amount: string;
|
|
2892
|
+
}
|
|
2893
|
+
/** `event.data` for a `stx_lock` delivery. */
|
|
2894
|
+
interface ChainStxLockData {
|
|
2895
|
+
locked_address: string;
|
|
2896
|
+
locked_amount: string;
|
|
2897
|
+
unlock_height: string | null;
|
|
2898
|
+
}
|
|
2899
|
+
/** `event.data` for an `ft_transfer` delivery. */
|
|
2900
|
+
interface ChainFtTransferData {
|
|
2901
|
+
asset_identifier: string;
|
|
2902
|
+
sender?: string;
|
|
2903
|
+
recipient?: string;
|
|
2904
|
+
amount: string;
|
|
2905
|
+
}
|
|
2906
|
+
/** `event.data` for an `ft_mint` delivery. */
|
|
2907
|
+
interface ChainFtMintData {
|
|
2908
|
+
asset_identifier: string;
|
|
2909
|
+
recipient?: string;
|
|
2910
|
+
amount: string;
|
|
2911
|
+
}
|
|
2912
|
+
/** `event.data` for an `ft_burn` delivery. */
|
|
2913
|
+
interface ChainFtBurnData {
|
|
2914
|
+
asset_identifier: string;
|
|
2915
|
+
sender?: string;
|
|
2916
|
+
amount: string;
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* `event.data` for an `nft_transfer` delivery. Unlike Streams' `NftTransferPayload`,
|
|
2920
|
+
* there is no decoded `value` field — only the canonical hex of the token-id
|
|
2921
|
+
* Clarity value (`raw_value`).
|
|
2922
|
+
*/
|
|
2923
|
+
interface ChainNftTransferData {
|
|
2924
|
+
asset_identifier: string;
|
|
2925
|
+
sender?: string;
|
|
2926
|
+
recipient?: string;
|
|
2927
|
+
raw_value: string;
|
|
2928
|
+
}
|
|
2929
|
+
/** `event.data` for an `nft_mint` delivery. See {@link ChainNftTransferData}. */
|
|
2930
|
+
interface ChainNftMintData {
|
|
2931
|
+
asset_identifier: string;
|
|
2932
|
+
recipient?: string;
|
|
2933
|
+
raw_value: string;
|
|
2934
|
+
}
|
|
2935
|
+
/** `event.data` for an `nft_burn` delivery. See {@link ChainNftTransferData}. */
|
|
2936
|
+
interface ChainNftBurnData {
|
|
2937
|
+
asset_identifier: string;
|
|
2938
|
+
sender?: string;
|
|
2939
|
+
raw_value: string;
|
|
2940
|
+
}
|
|
2941
|
+
/**
|
|
2942
|
+
* `event.data` for a `print_event` delivery. Note the field is
|
|
2943
|
+
* `contract_identifier` — Streams' `PrintPayload` uses `contract_id` for the
|
|
2944
|
+
* same contract, which is NOT the field name delivered here.
|
|
2945
|
+
*/
|
|
2946
|
+
interface ChainPrintEventData {
|
|
2947
|
+
topic: string | null;
|
|
2948
|
+
contract_identifier: string;
|
|
2949
|
+
value: unknown;
|
|
2950
|
+
raw_value: string | null;
|
|
2951
|
+
}
|
|
2952
|
+
/**
|
|
2953
|
+
* Wrapper around an event-level trigger's matched event. `type` is the node's
|
|
2954
|
+
* suffixed event-kind (`"stx_transfer_event"`, `"ft_mint_event"`, …) — EXCEPT
|
|
2955
|
+
* `print_event` triggers, whose `event.type` is `"contract_event"` (the node's
|
|
2956
|
+
* raw name for a print event), not `"print_event_event"`.
|
|
2957
|
+
*/
|
|
2958
|
+
interface ChainEventEnvelope<
|
|
2959
|
+
TType extends string,
|
|
2960
|
+
TData
|
|
2961
|
+
> {
|
|
2962
|
+
tx_id: string;
|
|
2963
|
+
type: TType;
|
|
2964
|
+
event_index: number;
|
|
2965
|
+
data: TData;
|
|
2966
|
+
}
|
|
2967
|
+
/**
|
|
2968
|
+
* A tx-level trigger's matched event (`contract_call` / `contract_deploy`) —
|
|
2969
|
+
* flat, no nested `data` key. `function_args` are RAW (undecoded) Clarity-value
|
|
2970
|
+
* hex strings in call order, not decoded values.
|
|
2971
|
+
*/
|
|
2972
|
+
interface ChainTxLevelEvent {
|
|
2973
|
+
tx_id: string;
|
|
2974
|
+
/** Stacks tx type, e.g. `"contract_call"` for a `contract_call` trigger or
|
|
2975
|
+
* `"smart_contract"` for a `contract_deploy` trigger — NOT `"contract_deploy"`. */
|
|
2976
|
+
type: string;
|
|
2977
|
+
sender: string;
|
|
2978
|
+
status: string;
|
|
2979
|
+
contract_id: string | null;
|
|
2980
|
+
function_name: string | null;
|
|
2981
|
+
/** Raw (undecoded) Clarity-value hex strings, in call order. */
|
|
2982
|
+
function_args: string[] | null;
|
|
2983
|
+
/** Raw hex of the tx's Clarity return value. */
|
|
2984
|
+
result_hex: string | null;
|
|
2985
|
+
}
|
|
2986
|
+
/** One `apply` envelope, generic over its trigger literal + matched-event shape. */
|
|
2987
|
+
interface ChainApplyEnvelopeOf<
|
|
2988
|
+
TTrigger extends ChainTrigger["type"],
|
|
2989
|
+
TEvent
|
|
2990
|
+
> {
|
|
2991
|
+
action: "apply";
|
|
2992
|
+
block_hash: string;
|
|
2993
|
+
block_height: number;
|
|
2994
|
+
tx_id: string;
|
|
2995
|
+
canonical: true;
|
|
2996
|
+
trigger: TTrigger;
|
|
2997
|
+
event: TEvent;
|
|
2998
|
+
}
|
|
2999
|
+
type ChainApplyDeliveryOf<
|
|
3000
|
+
TTrigger extends ChainTrigger["type"],
|
|
3001
|
+
TEvent
|
|
3002
|
+
> = {
|
|
3003
|
+
type: `chain.${TTrigger}.apply`
|
|
3004
|
+
timestamp: string
|
|
3005
|
+
data: ChainApplyEnvelopeOf<TTrigger, TEvent>
|
|
3006
|
+
};
|
|
3007
|
+
/** Delivered once per affected subscription on a reorg (`type: "chain.reorg.rollback"`). */
|
|
3008
|
+
interface ChainReorgRollbackDelivery {
|
|
3009
|
+
type: "chain.reorg.rollback";
|
|
3010
|
+
timestamp: string;
|
|
3011
|
+
data: ChainReorgRollbackEnvelope;
|
|
3012
|
+
}
|
|
3013
|
+
/** The `POST /subscriptions/:id/test` ping (`type: "chain.test.apply"`) — not a real chain event. */
|
|
3014
|
+
interface ChainTestDelivery {
|
|
3015
|
+
type: "chain.test.apply";
|
|
3016
|
+
timestamp: string;
|
|
3017
|
+
data: {
|
|
3018
|
+
test: true
|
|
3019
|
+
message: string
|
|
3020
|
+
subscription_id: string
|
|
3021
|
+
sent_at: string
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
3024
|
+
/**
|
|
3025
|
+
* The full wire body of a chain-subscription webhook delivery, as sent to a
|
|
3026
|
+
* `format: "standard-webhooks"` subscription (the default) — `{ type,
|
|
3027
|
+
* timestamp, data }`. Discriminate on `data.trigger` (or the top-level `type`)
|
|
3028
|
+
* to narrow `data.event`:
|
|
3029
|
+
*
|
|
3030
|
+
* ```ts
|
|
3031
|
+
* const delivery = decodeChainWebhook(rawBody);
|
|
3032
|
+
* if (delivery.data.action === "apply") {
|
|
3033
|
+
* switch (delivery.data.trigger) {
|
|
3034
|
+
* case "stx_transfer":
|
|
3035
|
+
* delivery.data.event.data.amount; // typed
|
|
3036
|
+
* break;
|
|
3037
|
+
* case "contract_call":
|
|
3038
|
+
* delivery.data.event.function_name; // typed, flat (no nested `.data`)
|
|
3039
|
+
* break;
|
|
3040
|
+
* }
|
|
3041
|
+
* }
|
|
3042
|
+
* ```
|
|
3043
|
+
*
|
|
3044
|
+
* NOTE: this is the DELIVERED webhook body, not a Streams/Index event — those
|
|
3045
|
+
* have an unrelated `{ event_type, payload }` shape (see `StreamsEvent` in
|
|
3046
|
+
* `@secondlayer/sdk`). Do not parse a chain-subscription delivery as a Streams
|
|
3047
|
+
* event or vice versa — mixing them up is the exact bug this type exists to
|
|
3048
|
+
* prevent.
|
|
3049
|
+
*
|
|
3050
|
+
* Other subscription `format`s (`raw`, `cloudevents`, `inngest`, `trigger`,
|
|
3051
|
+
* `cloudflare`) carry the same `data` value (a `ChainApplyEnvelope` /
|
|
3052
|
+
* `ChainReorgRollbackEnvelope`) under a different outer envelope — see the
|
|
3053
|
+
* "Chain subscription webhook payloads" doc.
|
|
3054
|
+
*/
|
|
3055
|
+
type ChainWebhookDelivery = ChainApplyDeliveryOf<"stx_transfer", ChainEventEnvelope<"stx_transfer_event", ChainStxTransferData>> | ChainApplyDeliveryOf<"stx_mint", ChainEventEnvelope<"stx_mint_event", ChainStxMintData>> | ChainApplyDeliveryOf<"stx_burn", ChainEventEnvelope<"stx_burn_event", ChainStxBurnData>> | ChainApplyDeliveryOf<"stx_lock", ChainEventEnvelope<"stx_lock_event", ChainStxLockData>> | ChainApplyDeliveryOf<"ft_transfer", ChainEventEnvelope<"ft_transfer_event", ChainFtTransferData>> | ChainApplyDeliveryOf<"ft_mint", ChainEventEnvelope<"ft_mint_event", ChainFtMintData>> | ChainApplyDeliveryOf<"ft_burn", ChainEventEnvelope<"ft_burn_event", ChainFtBurnData>> | ChainApplyDeliveryOf<"nft_transfer", ChainEventEnvelope<"nft_transfer_event", ChainNftTransferData>> | ChainApplyDeliveryOf<"nft_mint", ChainEventEnvelope<"nft_mint_event", ChainNftMintData>> | ChainApplyDeliveryOf<"nft_burn", ChainEventEnvelope<"nft_burn_event", ChainNftBurnData>> | ChainApplyDeliveryOf<"print_event", ChainEventEnvelope<"contract_event", ChainPrintEventData>> | ChainApplyDeliveryOf<"contract_call", ChainTxLevelEvent> | ChainApplyDeliveryOf<"contract_deploy", ChainTxLevelEvent> | ChainApplyDeliveryOf<"sbtc_deposit", SbtcDepositEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_create", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_accept", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_reject", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_swept_confirmed", SbtcWithdrawalSweptConfirmedEvent> | ChainReorgRollbackDelivery | ChainTestDelivery;
|
|
3056
|
+
export { validateSubscriptionFilterForTable, sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, logger, jsonb, isPox4DecoderEnabled, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getErrorMessage, getEnv, getDbSplitStatus, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatSubscriptionSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, closeDb, assertDbSplit, X402PaymentsTable, X402BalancesTable, VersionConflictError, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantSuspendedError, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, TABLE_TO_DB, 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, SubgraphAggregateResponse, SubgraphAggregateParams, SubgraphAgentSchema, Subgraph, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, StreamsEventType, StreamsDbEventType, StreamsCursor, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalEvent, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SbtcDepositEvent, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, STREAMS_TO_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_DB_EVENT_TYPES, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, RotateSecretResponse, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, ReindexResponse, RateLimitError, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, PrintEventFilterSchema, PrintEventFilter, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PaymentRequiredError, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, NumericAsText, NotFoundError, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, KeyRotatedError, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountCredits, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, ForbiddenError, EventsTable, EventsArchiveTable, EventFilterSchema, EventFilter, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecoderCheckpointsTable, DecodedEventsTable, DecodedEventType, DeadRow, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, DECODED_EVENT_TYPES, DB_TO_STREAMS_EVENT_TYPE, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, ContractsTable, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, Contract, ClaimTokensTable, ClaimToken, ChainWebhookEnvelope, ChainWebhookDelivery, ChainTxLevelEvent, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgsTable, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, CODE_TO_STATUS, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS, ByoBreakingChangeDetails, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountCreditsTable, AccountCredits, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/shared",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.39.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -153,7 +153,10 @@
|
|
|
153
153
|
"import": "./dist/src/node/archive-client.js"
|
|
154
154
|
}
|
|
155
155
|
},
|
|
156
|
-
"files": [
|
|
156
|
+
"files": [
|
|
157
|
+
"dist",
|
|
158
|
+
"migrations"
|
|
159
|
+
],
|
|
157
160
|
"scripts": {
|
|
158
161
|
"build": "bunup",
|
|
159
162
|
"dev": "bunup --watch",
|