@secondlayer/shared 15.0.3 → 15.1.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.
Files changed (35) hide show
  1. package/dist/src/archive/range-digest.d.ts +27 -0
  2. package/dist/src/archive/semantic-digest-builder.d.ts +27 -0
  3. package/dist/src/coverage/index.d.ts +27 -0
  4. package/dist/src/db/index.d.ts +32 -1
  5. package/dist/src/db/index.js +24 -12
  6. package/dist/src/db/index.js.map +6 -5
  7. package/dist/src/db/queries/chain-reorgs.d.ts +27 -0
  8. package/dist/src/db/queries/chain-reorgs.js +24 -12
  9. package/dist/src/db/queries/chain-reorgs.js.map +6 -5
  10. package/dist/src/db/queries/contracts.d.ts +27 -0
  11. package/dist/src/db/queries/instance.d.ts +27 -0
  12. package/dist/src/db/queries/integrity.d.ts +27 -0
  13. package/dist/src/db/queries/subgraph-gaps.d.ts +27 -0
  14. package/dist/src/db/queries/subgraph-operations.d.ts +27 -0
  15. package/dist/src/db/queries/subgraphs.d.ts +27 -0
  16. package/dist/src/db/queries/sync-scope.d.ts +27 -0
  17. package/dist/src/db/queries/webhook-replays.d.ts +27 -0
  18. package/dist/src/db/queries/webhooks.d.ts +27 -0
  19. package/dist/src/db/schema.d.ts +30 -1
  20. package/dist/src/email/index.d.ts +39 -1
  21. package/dist/src/email/index.js +68 -10
  22. package/dist/src/email/index.js.map +6 -5
  23. package/dist/src/index.d.ts +32 -1
  24. package/dist/src/index.js +24 -12
  25. package/dist/src/index.js.map +6 -5
  26. package/dist/src/insights/index.d.ts +29 -0
  27. package/dist/src/insights/index.js +2 -2
  28. package/dist/src/insights/index.js.map +3 -3
  29. package/dist/src/leader.js +22 -12
  30. package/dist/src/leader.js.map +5 -4
  31. package/dist/src/node/local-client.d.ts +27 -0
  32. package/dist/src/queue/listener.js +24 -12
  33. package/dist/src/queue/listener.js.map +6 -5
  34. package/migrations/0183_update_subscribers.ts +55 -0
  35. package/package.json +1 -1
@@ -1165,6 +1165,8 @@ interface Database {
1165
1165
  waitlists: WaitlistsTable;
1166
1166
  waitlist_signups: WaitlistSignupsTable;
1167
1167
  contact_requests: ContactRequestsTable;
1168
+ update_subscribers: UpdateSubscribersTable;
1169
+ update_sends: UpdateSendsTable;
1168
1170
  api_failed_requests: ApiFailedRequestsTable;
1169
1171
  api_request_log: ApiRequestLogTable;
1170
1172
  insights: InsightsTable;
@@ -1626,6 +1628,31 @@ interface ContactRequestsTable {
1626
1628
  created_at: Generated<Date>;
1627
1629
  }
1628
1630
  /**
1631
+ * A member of the email updates list. `pending` until the emailed link is
1632
+ * confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while
1633
+ * subscribed, `unsubscribed` after an opt-out. `token` is the secret in
1634
+ * confirm and unsubscribe links.
1635
+ */
1636
+ interface UpdateSubscribersTable {
1637
+ id: Generated<string>;
1638
+ email: string;
1639
+ status: Generated<"pending" | "confirmed" | "unsubscribed">;
1640
+ token: string;
1641
+ source_page: string | null;
1642
+ /** Hex sha256 of the client IP, never the address. */
1643
+ ip_hash: string | null;
1644
+ confirm_sent_at: Date | null;
1645
+ confirmed_at: Date | null;
1646
+ unsubscribed_at: Date | null;
1647
+ created_at: Generated<Date>;
1648
+ }
1649
+ /** One broadcast (`send_key`) delivered to one subscriber. */
1650
+ interface UpdateSendsTable {
1651
+ send_key: string;
1652
+ subscriber_id: string;
1653
+ sent_at: Generated<Date>;
1654
+ }
1655
+ /**
1629
1656
  * 24h hosted record of a failed API request, keyed by `request_id` and
1630
1657
  * scoped to the account that made it. `query` is redacted before insert.
1631
1658
  */
@@ -1696,6 +1723,8 @@ type WaitlistSignup = Selectable<WaitlistSignupsTable>;
1696
1723
  type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;
1697
1724
  type ContactRequest = Selectable<ContactRequestsTable>;
1698
1725
  type InsertContactRequest = Insertable<ContactRequestsTable>;
1726
+ type UpdateSubscriber = Selectable<UpdateSubscribersTable>;
1727
+ type InsertUpdateSubscriber = Insertable<UpdateSubscribersTable>;
1699
1728
  interface EnvSchemaOutput {
1700
1729
  DATABASE_URL?: string;
1701
1730
  /**
@@ -2738,6 +2767,8 @@ declare const TABLE_TO_DB: {
2738
2767
  waitlists: string
2739
2768
  waitlist_signups: string
2740
2769
  contact_requests: string
2770
+ update_subscribers: string
2771
+ update_sends: string
2741
2772
  api_failed_requests: string
2742
2773
  api_request_log: string
2743
2774
  insights: string
@@ -3849,4 +3880,4 @@ declare function publicKeyPemFromPrivate(privateKeyPem: string): string;
3849
3880
  declare function ed25519KeyId(publicKeyPem: string): string;
3850
3881
  declare function signEd25519(payload: string, privateKey: KeyObject): string;
3851
3882
  declare function verifyEd25519(payload: string, signatureBase64: string, publicKey: KeyObject): boolean;
3852
- export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeyRevokedError, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, CliDeviceLogin, CliDeviceLoginStatus, CliDeviceLoginsTable, CliDeviceProduct, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, HealthHour, HealthSnapshotPoint, INSIGHT_SEVERITIES, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertApiRequestLogRow, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, Insight, InsightEvidence, InsightEvidenceSchema, InsightListResponse, InsightListResponseSchema, InsightMutesTable, InsightResourceKind, InsightResourceKindSchema, InsightSchema, InsightSeverity, InsightSeveritySchema, InsightsTable, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, OauthClient, OauthClientsTable, OauthCodesTable, OauthGrant, OauthGrantsTable, OauthRefreshRetiredTable, OauthRequestStatus, OauthRequestsTable, OauthTokenKind, OauthTokensTable, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, PushPrefs, PushPrefsTable, PushSentTable, PushSubscription, PushSubscriptionsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SEVERITY_ORDER, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FORMATS, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDeliveryHoursTable, WebhookDetail, WebhookFormat, WebhookFormatSchema, WebhookIncidentAlert, WebhookIncidentAlertsTable, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookReplay, WebhookReplayStatus, WebhookReplaysTable, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, bucketHourly, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
3883
+ export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeyRevokedError, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, AuthenticationError, AuthorizationError, BILLING_PAUSED_PREFIX, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, CHAIN_TRIGGER_FIELDS, CHAIN_TRIGGER_TYPES, CODE_TO_STATUS, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReadCacheTable, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainReorgsTable, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery, ChainWebhookEnvelope, CliDeviceLogin, CliDeviceLoginStatus, CliDeviceLoginsTable, CliDeviceProduct, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, CreateWebhookRequest, CreateWebhookRequestSchema, CreateWebhookResponse, DB_TO_STREAMS_EVENT_TYPE, DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES, DEFAULT_BTC_CONFIRMATIONS, Database, DatabaseError, DbPlane, DbReadRow, DbSplitStatus, DeadLetterEventsTable, DeadRow, DecodedEventType2 as DecodedEventType, DecodedEventsTable, DecoderCheckpointsTable, DeliveryRow, DeploySubgraphRequest, DeploySubgraphRequestSchema, DeploySubgraphResponse, EMPTY_RANGE_EVENT_INDEX_SENTINEL, Env, ErrorCode, ErrorCodes, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, ForbiddenError, HealthHour, HealthSnapshotPoint, INSIGHT_SEVERITIES, IndexColumn, IndexColumnType, IndexPrimaryKey, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertApiRequestLogRow, InsertArchiveFetch, InsertBlock, InsertContactRequest, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUpdateSubscriber, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, Insight, InsightEvidence, InsightEvidenceSchema, InsightListResponse, InsightListResponseSchema, InsightMutesTable, InsightResourceKind, InsightResourceKindSchema, InsightSchema, InsightSeverity, InsightSeveritySchema, InsightsTable, InstancesTable, KeyRotatedError, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, MigrationRole, NativeClock, NotFoundError, NumericAsText, OauthClient, OauthClientsTable, OauthCodesTable, OauthGrant, OauthGrantsTable, OauthRefreshRetiredTable, OauthRequestStatus, OauthRequestsTable, OauthTokenKind, OauthTokensTable, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, ParsedCreateWebhookRequest, ParsedReplayWebhookRequest, ParsedUpdateWebhookRequest, PaymentRequiredError, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, PushPrefs, PushPrefsTable, PushSentTable, PushSubscription, PushSubscriptionsTable, RUNE_EVENT_TYPES, RateLimitError, ReindexResponse, RepairMode, ReplayResult, ReplayWebhookRequest, ReplayWebhookRequestSchema, RetryState, RotateSecretResponse, RunStatus, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneEventType, SEVERITY_ORDER, SOURCE_READ_COLUMNS, SOURCE_READ_PKS, SOURCE_READ_TYPES, STREAMS_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_TO_DB_EVENT_TYPES, SbtcDepositEvent, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent, SecondLayerError, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, StreamsCursor, StreamsDbEventType, StreamsEventType, Subgraph, SubgraphAgentSchema, SubgraphAggregateParams, SubgraphAggregateResponse, SubgraphDetail, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapEntry, SubgraphGapRange, SubgraphGapsResponse, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphQueryParams, SubgraphSpecFormat, SubgraphSpecOptions, SubgraphSummary, SubgraphSyncInfo, SubgraphVerification, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, TABLE_TO_DB, TenantSuspendedError, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSendsTable, UpdateSubgraph, UpdateSubgraphOperation, UpdateSubscriber, UpdateSubscribersTable, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UpdateWebhookRequest, UpdateWebhookRequestSchema, UsageLedgerRow, UsageLedgerTable, VM_EVENT_TYPES, VM_NODE_TO_STORED_TYPE2 as VM_NODE_TO_STORED_TYPE, VM_STORED_TO_NODE_TYPE, ValidationError, VersionConflictError, VmEvent, VmEventType, VmEventsArchiveTable, VmEventsTable, VmNodeEventType, WEBHOOK_FORMATS, WEBHOOK_STATUSES, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDeliveryHoursTable, WebhookDetail, WebhookFormat, WebhookFormatSchema, WebhookIncidentAlert, WebhookIncidentAlertsTable, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookReplay, WebhookReplayStatus, WebhookReplaysTable, WebhookStatus, WebhookStatusSchema, WebhookSummary, WebhooksTable, applicationDatabaseUrl, assertDbSplit, billingPausedCode, blockEndCursor, bucketHourly, closeDb, closeDbOrTimeout, committedHeight, compareStreamsCursor, exports_hmac as crypto, decodeStreamsCursor, describeDbUrl, exports_ed25519 as ed25519, encodeStreamsCursor, finalizedBurnHeight, formatWebhookSchemaErrors, generateSubgraphAgentSchema, generateSubgraphMarkdown, generateSubgraphOpenApi, generateSubgraphSpec, getDb, getDbSplitStatus, getEnv, getErrorMessage, getMigrationRole, getRawClient, getSourceDb, getTargetDb, isBnsDecoderEnabled, isEmptyRangeCursor, isPox4DecoderEnabled, isPox5DecoderEnabled, isSbtcDecoderEnabled, jsonb, logger, onChainPlane, onControlPlane, parseJsonb, resolveSourceUrl, resolveTargetUrl, setMigrationRole, sql };
package/dist/src/index.js CHANGED
@@ -276,6 +276,26 @@ function isWebhookAccountScoped() {
276
276
  return isPlatformMode() || isTestnetWebhookStack();
277
277
  }
278
278
 
279
+ // src/db/tls.ts
280
+ function tlsOptions(url) {
281
+ let parsed = null;
282
+ try {
283
+ parsed = new URL(url);
284
+ } catch {}
285
+ if (parsed?.searchParams.has("sslmode") || parsed?.searchParams.has("ssl")) {
286
+ return {};
287
+ }
288
+ const host = parsed?.hostname ?? "";
289
+ const isLocal = host === "localhost" || host === "127.0.0.1" || !host.includes(".");
290
+ if (isLocal)
291
+ return {};
292
+ return {
293
+ ssl: {
294
+ rejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0"
295
+ }
296
+ };
297
+ }
298
+
279
299
  // src/db/index.ts
280
300
  import { sql as sql2 } from "kysely";
281
301
 
@@ -902,6 +922,8 @@ var TABLE_TO_DB = {
902
922
  waitlists: "target",
903
923
  waitlist_signups: "target",
904
924
  contact_requests: "target",
925
+ update_subscribers: "target",
926
+ update_sends: "target",
905
927
  api_failed_requests: "target",
906
928
  api_request_log: "target",
907
929
  insights: "target",
@@ -1021,22 +1043,12 @@ function getOrCreatePool(url) {
1021
1043
  existing.seq = poolSeq++;
1022
1044
  return existing;
1023
1045
  }
1024
- const host = (() => {
1025
- try {
1026
- return new URL(url).hostname;
1027
- } catch {
1028
- return "";
1029
- }
1030
- })();
1031
- const isLocal = host === "localhost" || host === "127.0.0.1" || !host.includes(".");
1032
1046
  const poolMax = Number.parseInt(process.env.DATABASE_POOL_MAX ?? "20", 10);
1033
1047
  const idleTimeout = Number.parseInt(process.env.DATABASE_IDLE_TIMEOUT ?? "300", 10);
1034
1048
  const rawClient = postgres(url, {
1035
1049
  max: poolMax,
1036
1050
  idle_timeout: idleTimeout,
1037
- ssl: isLocal ? undefined : {
1038
- rejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0"
1039
- }
1051
+ ...tlsOptions(url)
1040
1052
  });
1041
1053
  const db = new Kysely({
1042
1054
  dialect: new PostgresJSDialect({ postgres: rawClient }),
@@ -2436,5 +2448,5 @@ export {
2436
2448
  sql2 as sql
2437
2449
  };
2438
2450
 
2439
- //# debugId=C5F43AB44F076E8464756E2164756E21
2451
+ //# debugId=2E781E743304CE9464756E2164756E21
2440
2452
  //# sourceMappingURL=index.js.map