@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.
- package/dist/src/archive/range-digest.d.ts +27 -0
- package/dist/src/archive/semantic-digest-builder.d.ts +27 -0
- package/dist/src/coverage/index.d.ts +27 -0
- package/dist/src/db/index.d.ts +32 -1
- package/dist/src/db/index.js +24 -12
- package/dist/src/db/index.js.map +6 -5
- package/dist/src/db/queries/chain-reorgs.d.ts +27 -0
- package/dist/src/db/queries/chain-reorgs.js +24 -12
- package/dist/src/db/queries/chain-reorgs.js.map +6 -5
- package/dist/src/db/queries/contracts.d.ts +27 -0
- package/dist/src/db/queries/instance.d.ts +27 -0
- package/dist/src/db/queries/integrity.d.ts +27 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +27 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +27 -0
- package/dist/src/db/queries/subgraphs.d.ts +27 -0
- package/dist/src/db/queries/sync-scope.d.ts +27 -0
- package/dist/src/db/queries/webhook-replays.d.ts +27 -0
- package/dist/src/db/queries/webhooks.d.ts +27 -0
- package/dist/src/db/schema.d.ts +30 -1
- package/dist/src/email/index.d.ts +39 -1
- package/dist/src/email/index.js +68 -10
- package/dist/src/email/index.js.map +6 -5
- package/dist/src/index.d.ts +32 -1
- package/dist/src/index.js +24 -12
- package/dist/src/index.js.map +6 -5
- package/dist/src/insights/index.d.ts +29 -0
- package/dist/src/insights/index.js +2 -2
- package/dist/src/insights/index.js.map +3 -3
- package/dist/src/leader.js +22 -12
- package/dist/src/leader.js.map +5 -4
- package/dist/src/node/local-client.d.ts +27 -0
- package/dist/src/queue/listener.js +24 -12
- package/dist/src/queue/listener.js.map +6 -5
- package/migrations/0183_update_subscribers.ts +55 -0
- package/package.json +1 -1
|
@@ -941,6 +941,8 @@ interface Database {
|
|
|
941
941
|
waitlists: WaitlistsTable;
|
|
942
942
|
waitlist_signups: WaitlistSignupsTable;
|
|
943
943
|
contact_requests: ContactRequestsTable;
|
|
944
|
+
update_subscribers: UpdateSubscribersTable;
|
|
945
|
+
update_sends: UpdateSendsTable;
|
|
944
946
|
api_failed_requests: ApiFailedRequestsTable;
|
|
945
947
|
api_request_log: ApiRequestLogTable;
|
|
946
948
|
insights: InsightsTable;
|
|
@@ -1326,6 +1328,31 @@ interface ContactRequestsTable {
|
|
|
1326
1328
|
created_at: Generated<Date>;
|
|
1327
1329
|
}
|
|
1328
1330
|
/**
|
|
1331
|
+
* A member of the email updates list. `pending` until the emailed link is
|
|
1332
|
+
* confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while
|
|
1333
|
+
* subscribed, `unsubscribed` after an opt-out. `token` is the secret in
|
|
1334
|
+
* confirm and unsubscribe links.
|
|
1335
|
+
*/
|
|
1336
|
+
interface UpdateSubscribersTable {
|
|
1337
|
+
id: Generated<string>;
|
|
1338
|
+
email: string;
|
|
1339
|
+
status: Generated<"pending" | "confirmed" | "unsubscribed">;
|
|
1340
|
+
token: string;
|
|
1341
|
+
source_page: string | null;
|
|
1342
|
+
/** Hex sha256 of the client IP, never the address. */
|
|
1343
|
+
ip_hash: string | null;
|
|
1344
|
+
confirm_sent_at: Date | null;
|
|
1345
|
+
confirmed_at: Date | null;
|
|
1346
|
+
unsubscribed_at: Date | null;
|
|
1347
|
+
created_at: Generated<Date>;
|
|
1348
|
+
}
|
|
1349
|
+
/** One broadcast (`send_key`) delivered to one subscriber. */
|
|
1350
|
+
interface UpdateSendsTable {
|
|
1351
|
+
send_key: string;
|
|
1352
|
+
subscriber_id: string;
|
|
1353
|
+
sent_at: Generated<Date>;
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1329
1356
|
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1330
1357
|
* scoped to the account that made it. `query` is redacted before insert.
|
|
1331
1358
|
*/
|
|
@@ -951,6 +951,8 @@ interface Database {
|
|
|
951
951
|
waitlists: WaitlistsTable;
|
|
952
952
|
waitlist_signups: WaitlistSignupsTable;
|
|
953
953
|
contact_requests: ContactRequestsTable;
|
|
954
|
+
update_subscribers: UpdateSubscribersTable;
|
|
955
|
+
update_sends: UpdateSendsTable;
|
|
954
956
|
api_failed_requests: ApiFailedRequestsTable;
|
|
955
957
|
api_request_log: ApiRequestLogTable;
|
|
956
958
|
insights: InsightsTable;
|
|
@@ -1335,6 +1337,31 @@ interface ContactRequestsTable {
|
|
|
1335
1337
|
created_at: Generated<Date>;
|
|
1336
1338
|
}
|
|
1337
1339
|
/**
|
|
1340
|
+
* A member of the email updates list. `pending` until the emailed link is
|
|
1341
|
+
* confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while
|
|
1342
|
+
* subscribed, `unsubscribed` after an opt-out. `token` is the secret in
|
|
1343
|
+
* confirm and unsubscribe links.
|
|
1344
|
+
*/
|
|
1345
|
+
interface UpdateSubscribersTable {
|
|
1346
|
+
id: Generated<string>;
|
|
1347
|
+
email: string;
|
|
1348
|
+
status: Generated<"pending" | "confirmed" | "unsubscribed">;
|
|
1349
|
+
token: string;
|
|
1350
|
+
source_page: string | null;
|
|
1351
|
+
/** Hex sha256 of the client IP, never the address. */
|
|
1352
|
+
ip_hash: string | null;
|
|
1353
|
+
confirm_sent_at: Date | null;
|
|
1354
|
+
confirmed_at: Date | null;
|
|
1355
|
+
unsubscribed_at: Date | null;
|
|
1356
|
+
created_at: Generated<Date>;
|
|
1357
|
+
}
|
|
1358
|
+
/** One broadcast (`send_key`) delivered to one subscriber. */
|
|
1359
|
+
interface UpdateSendsTable {
|
|
1360
|
+
send_key: string;
|
|
1361
|
+
subscriber_id: string;
|
|
1362
|
+
sent_at: Generated<Date>;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1338
1365
|
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1339
1366
|
* scoped to the account that made it. `query` is redacted before insert.
|
|
1340
1367
|
*/
|
|
@@ -961,6 +961,8 @@ interface Database {
|
|
|
961
961
|
waitlists: WaitlistsTable;
|
|
962
962
|
waitlist_signups: WaitlistSignupsTable;
|
|
963
963
|
contact_requests: ContactRequestsTable;
|
|
964
|
+
update_subscribers: UpdateSubscribersTable;
|
|
965
|
+
update_sends: UpdateSendsTable;
|
|
964
966
|
api_failed_requests: ApiFailedRequestsTable;
|
|
965
967
|
api_request_log: ApiRequestLogTable;
|
|
966
968
|
insights: InsightsTable;
|
|
@@ -1346,6 +1348,31 @@ interface ContactRequestsTable {
|
|
|
1346
1348
|
created_at: Generated<Date>;
|
|
1347
1349
|
}
|
|
1348
1350
|
/**
|
|
1351
|
+
* A member of the email updates list. `pending` until the emailed link is
|
|
1352
|
+
* confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while
|
|
1353
|
+
* subscribed, `unsubscribed` after an opt-out. `token` is the secret in
|
|
1354
|
+
* confirm and unsubscribe links.
|
|
1355
|
+
*/
|
|
1356
|
+
interface UpdateSubscribersTable {
|
|
1357
|
+
id: Generated<string>;
|
|
1358
|
+
email: string;
|
|
1359
|
+
status: Generated<"pending" | "confirmed" | "unsubscribed">;
|
|
1360
|
+
token: string;
|
|
1361
|
+
source_page: string | null;
|
|
1362
|
+
/** Hex sha256 of the client IP, never the address. */
|
|
1363
|
+
ip_hash: string | null;
|
|
1364
|
+
confirm_sent_at: Date | null;
|
|
1365
|
+
confirmed_at: Date | null;
|
|
1366
|
+
unsubscribed_at: Date | null;
|
|
1367
|
+
created_at: Generated<Date>;
|
|
1368
|
+
}
|
|
1369
|
+
/** One broadcast (`send_key`) delivered to one subscriber. */
|
|
1370
|
+
interface UpdateSendsTable {
|
|
1371
|
+
send_key: string;
|
|
1372
|
+
subscriber_id: string;
|
|
1373
|
+
sent_at: Generated<Date>;
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1349
1376
|
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1350
1377
|
* scoped to the account that made it. `query` is redacted before insert.
|
|
1351
1378
|
*/
|
|
@@ -941,6 +941,8 @@ interface Database {
|
|
|
941
941
|
waitlists: WaitlistsTable;
|
|
942
942
|
waitlist_signups: WaitlistSignupsTable;
|
|
943
943
|
contact_requests: ContactRequestsTable;
|
|
944
|
+
update_subscribers: UpdateSubscribersTable;
|
|
945
|
+
update_sends: UpdateSendsTable;
|
|
944
946
|
api_failed_requests: ApiFailedRequestsTable;
|
|
945
947
|
api_request_log: ApiRequestLogTable;
|
|
946
948
|
insights: InsightsTable;
|
|
@@ -1326,6 +1328,31 @@ interface ContactRequestsTable {
|
|
|
1326
1328
|
created_at: Generated<Date>;
|
|
1327
1329
|
}
|
|
1328
1330
|
/**
|
|
1331
|
+
* A member of the email updates list. `pending` until the emailed link is
|
|
1332
|
+
* confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while
|
|
1333
|
+
* subscribed, `unsubscribed` after an opt-out. `token` is the secret in
|
|
1334
|
+
* confirm and unsubscribe links.
|
|
1335
|
+
*/
|
|
1336
|
+
interface UpdateSubscribersTable {
|
|
1337
|
+
id: Generated<string>;
|
|
1338
|
+
email: string;
|
|
1339
|
+
status: Generated<"pending" | "confirmed" | "unsubscribed">;
|
|
1340
|
+
token: string;
|
|
1341
|
+
source_page: string | null;
|
|
1342
|
+
/** Hex sha256 of the client IP, never the address. */
|
|
1343
|
+
ip_hash: string | null;
|
|
1344
|
+
confirm_sent_at: Date | null;
|
|
1345
|
+
confirmed_at: Date | null;
|
|
1346
|
+
unsubscribed_at: Date | null;
|
|
1347
|
+
created_at: Generated<Date>;
|
|
1348
|
+
}
|
|
1349
|
+
/** One broadcast (`send_key`) delivered to one subscriber. */
|
|
1350
|
+
interface UpdateSendsTable {
|
|
1351
|
+
send_key: string;
|
|
1352
|
+
subscriber_id: string;
|
|
1353
|
+
sent_at: Generated<Date>;
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1329
1356
|
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1330
1357
|
* scoped to the account that made it. `query` is redacted before insert.
|
|
1331
1358
|
*/
|
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -940,6 +940,8 @@ interface Database {
|
|
|
940
940
|
waitlists: WaitlistsTable;
|
|
941
941
|
waitlist_signups: WaitlistSignupsTable;
|
|
942
942
|
contact_requests: ContactRequestsTable;
|
|
943
|
+
update_subscribers: UpdateSubscribersTable;
|
|
944
|
+
update_sends: UpdateSendsTable;
|
|
943
945
|
api_failed_requests: ApiFailedRequestsTable;
|
|
944
946
|
api_request_log: ApiRequestLogTable;
|
|
945
947
|
insights: InsightsTable;
|
|
@@ -1401,6 +1403,31 @@ interface ContactRequestsTable {
|
|
|
1401
1403
|
created_at: Generated<Date>;
|
|
1402
1404
|
}
|
|
1403
1405
|
/**
|
|
1406
|
+
* A member of the email updates list. `pending` until the emailed link is
|
|
1407
|
+
* confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while
|
|
1408
|
+
* subscribed, `unsubscribed` after an opt-out. `token` is the secret in
|
|
1409
|
+
* confirm and unsubscribe links.
|
|
1410
|
+
*/
|
|
1411
|
+
interface UpdateSubscribersTable {
|
|
1412
|
+
id: Generated<string>;
|
|
1413
|
+
email: string;
|
|
1414
|
+
status: Generated<"pending" | "confirmed" | "unsubscribed">;
|
|
1415
|
+
token: string;
|
|
1416
|
+
source_page: string | null;
|
|
1417
|
+
/** Hex sha256 of the client IP, never the address. */
|
|
1418
|
+
ip_hash: string | null;
|
|
1419
|
+
confirm_sent_at: Date | null;
|
|
1420
|
+
confirmed_at: Date | null;
|
|
1421
|
+
unsubscribed_at: Date | null;
|
|
1422
|
+
created_at: Generated<Date>;
|
|
1423
|
+
}
|
|
1424
|
+
/** One broadcast (`send_key`) delivered to one subscriber. */
|
|
1425
|
+
interface UpdateSendsTable {
|
|
1426
|
+
send_key: string;
|
|
1427
|
+
subscriber_id: string;
|
|
1428
|
+
sent_at: Generated<Date>;
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1404
1431
|
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1405
1432
|
* scoped to the account that made it. `query` is redacted before insert.
|
|
1406
1433
|
*/
|
|
@@ -1471,4 +1498,6 @@ type WaitlistSignup = Selectable<WaitlistSignupsTable>;
|
|
|
1471
1498
|
type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;
|
|
1472
1499
|
type ContactRequest = Selectable<ContactRequestsTable>;
|
|
1473
1500
|
type InsertContactRequest = Insertable<ContactRequestsTable>;
|
|
1474
|
-
|
|
1501
|
+
type UpdateSubscriber = Selectable<UpdateSubscribersTable>;
|
|
1502
|
+
type InsertUpdateSubscriber = Insertable<UpdateSubscribersTable>;
|
|
1503
|
+
export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ApiRequestLogRow, ApiRequestLogTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, CliDeviceLogin, CliDeviceLoginStatus, CliDeviceLoginsTable, CliDeviceProduct, ContactRequest, ContactRequestsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, 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, InsightMutesTable, InsightsTable, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, NativeClock, OauthClient, OauthClientsTable, OauthCodesTable, OauthGrant, OauthGrantsTable, OauthRefreshRetiredTable, OauthRequestStatus, OauthRequestsTable, OauthTokenKind, OauthTokensTable, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, PushPrefs, PushPrefsTable, PushSentTable, PushSubscription, PushSubscriptionsTable, RepairMode, RetryState, RunStatus, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, Subgraph, SubgraphErrorGroupsTable, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSendsTable, UpdateSubgraph, UpdateSubgraphOperation, UpdateSubscriber, UpdateSubscribersTable, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UsageLedgerRow, UsageLedgerTable, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookDeliveryHoursTable, WebhookFormat, WebhookIncidentAlert, WebhookIncidentAlertsTable, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookReplay, WebhookReplayStatus, WebhookReplaysTable, WebhookStatus, WebhooksTable };
|
|
@@ -41,6 +41,18 @@ interface RenderEmailInput {
|
|
|
41
41
|
cta?: EmailCta;
|
|
42
42
|
/** Why the reader got this email and how to stop it. */
|
|
43
43
|
footnote?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Monospace lines shown in the figure, whitespace kept. `mark`, when set,
|
|
46
|
+
* has its first occurrence highlighted.
|
|
47
|
+
*/
|
|
48
|
+
excerpt?: {
|
|
49
|
+
lines: string
|
|
50
|
+
mark?: string
|
|
51
|
+
};
|
|
52
|
+
/** Plain text at the right of the figure bar when there is no `status`. */
|
|
53
|
+
figureNote?: string;
|
|
54
|
+
/** Adds an "Unsubscribe" link to the footer (list emails only). */
|
|
55
|
+
unsubscribeUrl?: string;
|
|
44
56
|
}
|
|
45
57
|
interface RenderedEmail {
|
|
46
58
|
html: string;
|
|
@@ -60,6 +72,10 @@ interface SendEmailInput {
|
|
|
60
72
|
text: string;
|
|
61
73
|
/** Where a reply goes; omitted, replies go to the From address. */
|
|
62
74
|
replyTo?: string;
|
|
75
|
+
/** Overrides the `EMAIL_FROM` default. */
|
|
76
|
+
from?: string;
|
|
77
|
+
/** Extra message headers, e.g. RFC 8058 `List-Unsubscribe`. */
|
|
78
|
+
headers?: Record<string, string>;
|
|
63
79
|
}
|
|
64
80
|
type SendEmailResult = {
|
|
65
81
|
skipped: true
|
|
@@ -67,4 +83,26 @@ type SendEmailResult = {
|
|
|
67
83
|
skipped: false
|
|
68
84
|
};
|
|
69
85
|
declare function sendEmail(input: SendEmailInput): Promise<SendEmailResult>;
|
|
70
|
-
|
|
86
|
+
/**
|
|
87
|
+
* The email updates list: sender, links and the double opt-in email. Every
|
|
88
|
+
* list email must carry `unsubscribeFor(token)` (footer link plus the
|
|
89
|
+
* RFC 8058 headers Gmail and Yahoo require from bulk senders).
|
|
90
|
+
*/
|
|
91
|
+
declare const UPDATES_FROM = "Secondlayer <dev@secondlayer.tools>";
|
|
92
|
+
declare const UPDATES_SITE_URL = "https://www.secondlayer.tools";
|
|
93
|
+
declare const UPDATES_API_URL = "https://api.secondlayer.tools";
|
|
94
|
+
/** Footer link (a web page that unsubscribes on load) and one-click headers. */
|
|
95
|
+
declare function unsubscribeFor(token: string): {
|
|
96
|
+
url: string
|
|
97
|
+
headers: Record<string, string>
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The double opt-in email. No unsubscribe link or headers: the address is
|
|
101
|
+
* not on the list until it confirms.
|
|
102
|
+
*/
|
|
103
|
+
declare function confirmEmail(token: string): {
|
|
104
|
+
subject: string
|
|
105
|
+
html: string
|
|
106
|
+
text: string
|
|
107
|
+
};
|
|
108
|
+
export { EmailCta, EmailStatus, EmailTone, FactRow, RenderEmailInput, RenderedEmail, SendEmailInput, SendEmailResult, UPDATES_API_URL, UPDATES_FROM, UPDATES_SITE_URL, confirmEmail, renderEmail, sendEmail, unsubscribeFor };
|
package/dist/src/email/index.js
CHANGED
|
@@ -58,19 +58,35 @@ function preheaderHtml(preheader) {
|
|
|
58
58
|
const filler = "͏‌ ".repeat(60);
|
|
59
59
|
return `<div style="display: none; max-height: 0; overflow: hidden; mso-hide: all; opacity: 0; color: transparent;">${escapeHtml(preheader)}${filler}</div>`;
|
|
60
60
|
}
|
|
61
|
+
function hasFigure(input) {
|
|
62
|
+
return Boolean(input.code || input.facts?.length || input.excerpt);
|
|
63
|
+
}
|
|
64
|
+
function excerptHtml(excerpt) {
|
|
65
|
+
let lines = escapeHtml(excerpt.lines);
|
|
66
|
+
if (excerpt.mark) {
|
|
67
|
+
const mark = escapeHtml(excerpt.mark);
|
|
68
|
+
const at = lines.indexOf(mark);
|
|
69
|
+
if (at !== -1) {
|
|
70
|
+
lines = `${lines.slice(0, at)}<span style="background: #ffd200; color: #14110d; padding: 0 2px;">${mark}</span>${lines.slice(at + mark.length)}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return `<tr><td colspan="2" style="padding: 0;"><pre class="sl-ink" style="margin: 0; padding: 12px 14px; font-family: ${MONO}; font-size: 12.5px; line-height: 20px; white-space: pre; overflow-x: auto; color: ${LIGHT.ink};">${lines}</pre></td></tr>`;
|
|
74
|
+
}
|
|
61
75
|
function figureHtml(input) {
|
|
62
|
-
if (!input
|
|
76
|
+
if (!hasFigure(input))
|
|
63
77
|
return "";
|
|
64
|
-
const title = input.figure ?? (input.code ? "sign-in code" : "details");
|
|
78
|
+
const title = input.figure ?? (input.code ? "sign-in code" : input.excerpt ? "excerpt" : "details");
|
|
65
79
|
const line = `border-color: ${LIGHT.line}; border-style: solid; border-width: 0`;
|
|
66
80
|
const bar = `<tr>
|
|
67
81
|
<td class="sl-faint sl-line" style="padding: 8px 14px; ${line}; border-bottom-width: 1px; font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};">${escapeHtml(title)}</td>
|
|
68
|
-
<td class="sl-line" align="right" style="padding: 8px 14px; ${line}; border-bottom-width: 1px;">${input.status ? statusChip(input.status) : ""}</td>
|
|
82
|
+
<td class="sl-line" align="right" style="padding: 8px 14px; ${line}; border-bottom-width: 1px;">${input.status ? statusChip(input.status) : input.figureNote ? `<span class="sl-faint" style="font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};">${escapeHtml(input.figureNote)}</span>` : ""}</td>
|
|
69
83
|
</tr>`;
|
|
70
84
|
let body;
|
|
71
85
|
if (input.code) {
|
|
72
86
|
body = `<tr><td colspan="2" align="center" class="sl-ink" style="padding: 24px 14px 8px; font-family: ${MONO}; font-size: 36px; line-height: 40px; font-weight: 500; letter-spacing: 0.3em; color: ${LIGHT.ink}; -webkit-user-select: all; user-select: all;">${escapeHtml(input.code)}</td></tr>
|
|
73
87
|
<tr><td colspan="2" align="center" class="sl-faint" style="padding: 0 14px 16px; font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};">tap or double-click to select</td></tr>`;
|
|
88
|
+
} else if (input.excerpt && !input.facts?.length) {
|
|
89
|
+
body = excerptHtml(input.excerpt);
|
|
74
90
|
} else {
|
|
75
91
|
const facts = input.facts ?? [];
|
|
76
92
|
body = facts.map((fact, i) => {
|
|
@@ -90,13 +106,15 @@ function figureHtml(input) {
|
|
|
90
106
|
</table>`;
|
|
91
107
|
}
|
|
92
108
|
function renderHtml(input) {
|
|
93
|
-
const
|
|
94
|
-
const statusLine = input.status && !
|
|
109
|
+
const figure = hasFigure(input);
|
|
110
|
+
const statusLine = input.status && !figure ? `<p class="${TONE_CLASS[input.status.tone]}" style="margin: 0 0 12px; font-size: 13px; line-height: 20px; color: ${TONE_COLOR[input.status.tone]};">${dot(input.status.tone)}${escapeHtml(input.status.text)}</p>` : "";
|
|
95
111
|
const paragraphsHtml = input.paragraphs.map((p) => `<p class="sl-sub" style="margin: 0 0 14px; font-size: 15px; line-height: 24px; color: ${LIGHT.sub};">${escapeHtml(p)}</p>`).join(`
|
|
96
112
|
`);
|
|
97
113
|
const quoteHtml = input.quote ? `<p class="sl-ink" style="margin: 0 0 14px; font-size: 15px; line-height: 24px; color: ${LIGHT.ink};">“${escapeHtml(input.quote)}”</p>` : "";
|
|
98
114
|
const ctaHtml = input.cta ? `<table role="presentation" cellpadding="0" cellspacing="0" style="margin: 10px 0 0;"><tr><td class="sl-pri" style="background: ${LIGHT.pri}; border-radius: 4px;"><a href="${escapeHtml(input.cta.url)}" style="display: inline-block; padding: 0 18px; height: 42px; line-height: 42px; font-family: ${SANS}; font-size: 15px; font-weight: 500; color: ${LIGHT.onPri}; text-decoration: none;">${escapeHtml(input.cta.label)}</a></td></tr></table>` : "";
|
|
99
|
-
const
|
|
115
|
+
const unsubscribeLink = input.unsubscribeUrl ? `<a href="${escapeHtml(input.unsubscribeUrl)}" class="sl-sub" style="color: ${LIGHT.sub}; text-decoration: underline;">Unsubscribe</a>` : "";
|
|
116
|
+
const footnoteText = input.footnote ? escapeHtml(input.footnote) : "";
|
|
117
|
+
const footnoteHtml = footnoteText || unsubscribeLink ? `<p class="sl-faint" style="margin: 0 0 6px;">${[footnoteText, unsubscribeLink].filter(Boolean).join(" ")}</p>` : "";
|
|
100
118
|
return `<!doctype html>
|
|
101
119
|
<html lang="en">
|
|
102
120
|
<head>
|
|
@@ -155,11 +173,15 @@ function renderText(input) {
|
|
|
155
173
|
lines.push(`${fact.label}: ${fact.value}`);
|
|
156
174
|
lines.push("");
|
|
157
175
|
}
|
|
176
|
+
if (input.excerpt)
|
|
177
|
+
lines.push(input.excerpt.lines, "");
|
|
158
178
|
if (input.cta)
|
|
159
179
|
lines.push(`${input.cta.label}: ${input.cta.url}`, "");
|
|
160
180
|
lines.push("--");
|
|
161
181
|
if (input.footnote)
|
|
162
182
|
lines.push(input.footnote);
|
|
183
|
+
if (input.unsubscribeUrl)
|
|
184
|
+
lines.push(`Unsubscribe: ${input.unsubscribeUrl}`);
|
|
163
185
|
lines.push(`Secondlayer · ${TAGLINE}`);
|
|
164
186
|
return lines.join(`
|
|
165
187
|
`);
|
|
@@ -306,7 +328,7 @@ async function sendEmail(input) {
|
|
|
306
328
|
});
|
|
307
329
|
return { skipped: true };
|
|
308
330
|
}
|
|
309
|
-
const from = process.env.EMAIL_FROM ?? "secondlayer <noreply@secondlayer.tools>";
|
|
331
|
+
const from = input.from ?? process.env.EMAIL_FROM ?? "secondlayer <noreply@secondlayer.tools>";
|
|
310
332
|
const response = await fetch("https://api.resend.com/emails", {
|
|
311
333
|
method: "POST",
|
|
312
334
|
headers: {
|
|
@@ -319,7 +341,8 @@ async function sendEmail(input) {
|
|
|
319
341
|
subject: input.subject,
|
|
320
342
|
html: input.html,
|
|
321
343
|
text: input.text,
|
|
322
|
-
...input.replyTo ? { reply_to: [input.replyTo] } : {}
|
|
344
|
+
...input.replyTo ? { reply_to: [input.replyTo] } : {},
|
|
345
|
+
...input.headers && Object.keys(input.headers).length > 0 ? { headers: input.headers } : {}
|
|
323
346
|
})
|
|
324
347
|
});
|
|
325
348
|
if (!response.ok) {
|
|
@@ -328,10 +351,45 @@ async function sendEmail(input) {
|
|
|
328
351
|
}
|
|
329
352
|
return { skipped: false };
|
|
330
353
|
}
|
|
354
|
+
// src/email/updates.ts
|
|
355
|
+
var UPDATES_FROM = "Secondlayer <dev@secondlayer.tools>";
|
|
356
|
+
var UPDATES_SITE_URL = "https://www.secondlayer.tools";
|
|
357
|
+
var UPDATES_API_URL = "https://api.secondlayer.tools";
|
|
358
|
+
function unsubscribeFor(token) {
|
|
359
|
+
const t = encodeURIComponent(token);
|
|
360
|
+
return {
|
|
361
|
+
url: `${UPDATES_SITE_URL}/updates/unsubscribe?t=${t}`,
|
|
362
|
+
headers: {
|
|
363
|
+
"List-Unsubscribe": `<${UPDATES_API_URL}/api/public/updates/unsubscribe?t=${t}>`,
|
|
364
|
+
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click"
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function confirmEmail(token) {
|
|
369
|
+
const subject = "Confirm your secondlayer subscription";
|
|
370
|
+
const { html, text } = renderEmail({
|
|
371
|
+
heading: "Confirm your email",
|
|
372
|
+
preheader: "One click and new posts and launches come to this inbox.",
|
|
373
|
+
paragraphs: [
|
|
374
|
+
"Confirm and we'll email you when we publish a post or ship something new. Nothing else, and every email has a one-click unsubscribe."
|
|
375
|
+
],
|
|
376
|
+
cta: {
|
|
377
|
+
label: "Confirm subscription",
|
|
378
|
+
url: `${UPDATES_SITE_URL}/updates/confirm?t=${encodeURIComponent(token)}`
|
|
379
|
+
},
|
|
380
|
+
footnote: "Someone entered this address at secondlayer.tools/blog. If it wasn't you, ignore this email and you won't hear from us. The link works for 7 days."
|
|
381
|
+
});
|
|
382
|
+
return { subject, html, text };
|
|
383
|
+
}
|
|
331
384
|
export {
|
|
385
|
+
UPDATES_API_URL,
|
|
386
|
+
UPDATES_FROM,
|
|
387
|
+
UPDATES_SITE_URL,
|
|
388
|
+
confirmEmail,
|
|
332
389
|
renderEmail,
|
|
333
|
-
sendEmail
|
|
390
|
+
sendEmail,
|
|
391
|
+
unsubscribeFor
|
|
334
392
|
};
|
|
335
393
|
|
|
336
|
-
//# debugId=
|
|
394
|
+
//# debugId=950489062CC4C20564756E2164756E21
|
|
337
395
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/email/render.ts", "../src/env.ts", "../src/logger.ts", "../src/email/send.ts"],
|
|
3
|
+
"sources": ["../src/email/render.ts", "../src/env.ts", "../src/logger.ts", "../src/email/send.ts", "../src/email/updates.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * The one HTML/text layout every customer email renders through, in the\n * brand's \"Figure\" look: logo + wordmark, a 24px heading, muted prose, the\n * code or facts inside a hairline code figure whose bar names it and carries\n * a status chip, one blue button, and a hairline footer.\n *\n * Table-based HTML with inline styles (most clients strip <style>). The head\n * <style> only adds dark mode for clients that honor `prefers-color-scheme`\n * (Apple Mail, iOS); everyone else gets the light palette, which Gmail\n * inverts on its own. Geist loads where web fonts work, the system stack\n * elsewhere. Callers pass content; every color lives here.\n */\n\nexport interface FactRow {\n\tlabel: string;\n\tvalue: string;\n}\n\nexport interface EmailCta {\n\tlabel: string;\n\turl: string;\n}\n\n/** `alarm` only for failures and stops, `ok` only for success. */\nexport type EmailTone = \"neutral\" | \"ok\" | \"alarm\";\n\nexport interface EmailStatus {\n\ttone: EmailTone;\n\ttext: string;\n}\n\nexport interface RenderEmailInput {\n\theading: string;\n\t/** The inbox preview line after the subject. Not shown in the body. */\n\tpreheader?: string;\n\tparagraphs: string[];\n\t/** Someone else's words, quoted (a contact form message). */\n\tquote?: string;\n\t/** A sign-in code, shown as one selectable run of digits in the figure. */\n\tcode?: string;\n\tfacts?: FactRow[];\n\t/** The figure's title bar. Defaults to \"sign-in code\" or \"details\". */\n\tfigure?: string;\n\t/** A chip in the figure bar, or a status line when there is no figure. */\n\tstatus?: EmailStatus;\n\tcta?: EmailCta;\n\t/** Why the reader got this email and how to stop it. */\n\tfootnote?: string;\n}\n\nexport interface RenderedEmail {\n\thtml: string;\n\ttext: string;\n}\n\n// www directly: the apex 307s there, and every image fetch would pay for it.\nconst LOGO_URL = \"https://www.secondlayer.tools/email/logo.png\";\nconst TAGLINE = \"Instant data for apps on Bitcoin\";\n\nconst SANS =\n\t\"Geist, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\nconst MONO =\n\t\"'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\";\n\n// DESIGN.md roles. Light inline; dark via the head <style> classes below.\nconst LIGHT = {\n\tpaper: \"#fbfaf7\",\n\tink: \"#14110d\",\n\tsub: \"#63605c\",\n\tfaint: \"#9d9b97\",\n\tline: \"#e8e6e3\",\n\tpri: \"#1f45e0\",\n\tonPri: \"#fbfaf7\",\n\tok: \"#128a43\",\n\talarm: \"#e3301e\",\n};\n\nconst DARK_STYLE = `\n@media (prefers-color-scheme: dark) {\n .sl-paper { background: #1e1b17 !important; }\n .sl-ink { color: #e8e6e3 !important; }\n .sl-sub { color: #b3b1ad !important; }\n .sl-faint { color: #7c7a76 !important; }\n .sl-line { border-color: #393632 !important; }\n .sl-pri { background: #3a5bff !important; }\n .sl-ok { color: #5cc28f !important; }\n .sl-alarm { color: #ff5a47 !important; }\n .sl-dot-neutral { background: #7c7a76 !important; }\n .sl-dot-ok { background: #5cc28f !important; }\n .sl-dot-alarm { background: #ff5a47 !important; }\n}`.trim();\n\nfunction escapeHtml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n\nconst TONE_COLOR: Record<EmailTone, string> = {\n\tneutral: LIGHT.sub,\n\tok: LIGHT.ok,\n\talarm: LIGHT.alarm,\n};\nconst DOT_COLOR: Record<EmailTone, string> = {\n\tneutral: LIGHT.faint,\n\tok: LIGHT.ok,\n\talarm: LIGHT.alarm,\n};\nconst TONE_CLASS: Record<EmailTone, string> = {\n\tneutral: \"sl-sub\",\n\tok: \"sl-ok\",\n\talarm: \"sl-alarm\",\n};\n\nfunction dot(tone: EmailTone): string {\n\treturn `<span class=\"sl-dot-${tone}\" style=\"display: inline-block; width: 7px; height: 7px; border-radius: 999px; background: ${DOT_COLOR[tone]}; margin-right: 6px; vertical-align: 1px;\"></span>`;\n}\n\nfunction statusChip(status: EmailStatus): string {\n\treturn `<span class=\"sl-line ${TONE_CLASS[status.tone]}\" style=\"display: inline-block; border: 1px solid ${LIGHT.line}; border-radius: 999px; padding: 2px 8px; font-family: ${MONO}; font-size: 12px; line-height: 16px; color: ${TONE_COLOR[status.tone]}; white-space: nowrap;\">${dot(status.tone)}${escapeHtml(status.text)}</span>`;\n}\n\nfunction preheaderHtml(preheader: string | undefined): string {\n\tif (!preheader) return \"\";\n\t// Trailing joiners keep body text from leaking into the preview line.\n\tconst filler = \"͏‌ \".repeat(60);\n\treturn `<div style=\"display: none; max-height: 0; overflow: hidden; mso-hide: all; opacity: 0; color: transparent;\">${escapeHtml(preheader)}${filler}</div>`;\n}\n\nfunction figureHtml(input: RenderEmailInput): string {\n\tif (!input.code && !input.facts?.length) return \"\";\n\tconst title = input.figure ?? (input.code ? \"sign-in code\" : \"details\");\n\tconst line = `border-color: ${LIGHT.line}; border-style: solid; border-width: 0`;\n\n\tconst bar = `<tr>\n <td class=\"sl-faint sl-line\" style=\"padding: 8px 14px; ${line}; border-bottom-width: 1px; font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};\">${escapeHtml(title)}</td>\n <td class=\"sl-line\" align=\"right\" style=\"padding: 8px 14px; ${line}; border-bottom-width: 1px;\">${input.status ? statusChip(input.status) : \"\"}</td>\n </tr>`;\n\n\tlet body: string;\n\tif (input.code) {\n\t\tbody = `<tr><td colspan=\"2\" align=\"center\" class=\"sl-ink\" style=\"padding: 24px 14px 8px; font-family: ${MONO}; font-size: 36px; line-height: 40px; font-weight: 500; letter-spacing: 0.3em; color: ${LIGHT.ink}; -webkit-user-select: all; user-select: all;\">${escapeHtml(input.code)}</td></tr>\n <tr><td colspan=\"2\" align=\"center\" class=\"sl-faint\" style=\"padding: 0 14px 16px; font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};\">tap or double-click to select</td></tr>`;\n\t} else {\n\t\tconst facts = input.facts ?? [];\n\t\tbody = facts\n\t\t\t.map((fact, i) => {\n\t\t\t\tconst top = i === 0 ? 12 : 2;\n\t\t\t\tconst bottom = i === facts.length - 1 ? 12 : 2;\n\t\t\t\tconst cell = `padding: ${top}px 14px ${bottom}px; font-family: ${MONO}; font-size: 13px; line-height: 20px; vertical-align: top;`;\n\t\t\t\treturn `<tr>\n <td class=\"sl-faint\" style=\"${cell} padding-right: 24px; width: 1%; color: ${LIGHT.faint}; white-space: nowrap;\">${escapeHtml(fact.label.toLowerCase())}</td>\n <td class=\"sl-ink\" style=\"${cell} color: ${LIGHT.ink}; word-break: break-word;\">${escapeHtml(fact.value)}</td>\n </tr>`;\n\t\t\t})\n\t\t\t.join(\"\\n \");\n\t}\n\n\treturn `<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" class=\"sl-line\" style=\"width: 100%; border: 1px solid ${LIGHT.line}; border-radius: 8px; border-collapse: separate; border-spacing: 0; margin: 8px 0 24px;\">\n ${bar}\n ${body}\n </table>`;\n}\n\nfunction renderHtml(input: RenderEmailInput): string {\n\tconst hasFigure = Boolean(input.code || input.facts?.length);\n\n\tconst statusLine =\n\t\tinput.status && !hasFigure\n\t\t\t? `<p class=\"${TONE_CLASS[input.status.tone]}\" style=\"margin: 0 0 12px; font-size: 13px; line-height: 20px; color: ${TONE_COLOR[input.status.tone]};\">${dot(input.status.tone)}${escapeHtml(input.status.text)}</p>`\n\t\t\t: \"\";\n\n\tconst paragraphsHtml = input.paragraphs\n\t\t.map(\n\t\t\t(p) =>\n\t\t\t\t`<p class=\"sl-sub\" style=\"margin: 0 0 14px; font-size: 15px; line-height: 24px; color: ${LIGHT.sub};\">${escapeHtml(p)}</p>`,\n\t\t)\n\t\t.join(\"\\n \");\n\n\tconst quoteHtml = input.quote\n\t\t? `<p class=\"sl-ink\" style=\"margin: 0 0 14px; font-size: 15px; line-height: 24px; color: ${LIGHT.ink};\">“${escapeHtml(input.quote)}”</p>`\n\t\t: \"\";\n\n\tconst ctaHtml = input.cta\n\t\t? `<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin: 10px 0 0;\"><tr><td class=\"sl-pri\" style=\"background: ${LIGHT.pri}; border-radius: 4px;\"><a href=\"${escapeHtml(input.cta.url)}\" style=\"display: inline-block; padding: 0 18px; height: 42px; line-height: 42px; font-family: ${SANS}; font-size: 15px; font-weight: 500; color: ${LIGHT.onPri}; text-decoration: none;\">${escapeHtml(input.cta.label)}</a></td></tr></table>`\n\t\t: \"\";\n\n\tconst footnoteHtml = input.footnote\n\t\t? `<p class=\"sl-faint\" style=\"margin: 0 0 6px;\">${escapeHtml(input.footnote)}</p>`\n\t\t: \"\";\n\n\treturn `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<meta name=\"supported-color-schemes\" content=\"light dark\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Geist:wght@400;500&family=Geist+Mono:wght@400;500&display=swap\">\n<style>\n${DARK_STYLE}\n</style>\n</head>\n<body class=\"sl-paper\" style=\"margin: 0; padding: 0; background: ${LIGHT.paper};\">\n${preheaderHtml(input.preheader)}\n<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" class=\"sl-paper\" style=\"width: 100%; background: ${LIGHT.paper};\">\n <tr>\n <td align=\"center\">\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%; max-width: 560px; font-family: ${SANS}; padding: 40px 20px;\">\n <tr>\n <td>\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin: 0 0 32px;\"><tr>\n <td style=\"padding-right: 8px; vertical-align: middle;\"><img src=\"${LOGO_URL}\" width=\"30\" height=\"20\" alt=\"\" style=\"display: block; border: 0;\"></td>\n <td class=\"sl-ink\" style=\"vertical-align: middle; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: ${LIGHT.ink};\">secondlayer</td>\n </tr></table>\n ${statusLine}\n <h1 class=\"sl-ink\" style=\"margin: 0 0 14px; font-size: 24px; line-height: 29px; font-weight: 500; letter-spacing: -0.025em; color: ${LIGHT.ink};\">${escapeHtml(input.heading)}</h1>\n ${paragraphsHtml}\n ${quoteHtml}\n ${figureHtml(input)}\n ${ctaHtml}\n <div class=\"sl-line sl-faint\" style=\"margin: 32px 0 0; padding: 16px 0 0; border-top: 1px solid ${LIGHT.line}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};\">\n ${footnoteHtml}\n <p class=\"sl-faint\" style=\"margin: 0;\"><span class=\"sl-sub\" style=\"color: ${LIGHT.sub}; font-weight: 500;\">Secondlayer</span> · ${TAGLINE}</p>\n </div>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n</table>\n</body>\n</html>`;\n}\n\nfunction renderText(input: RenderEmailInput): string {\n\tconst lines: string[] = [input.heading, \"\"];\n\tfor (const p of input.paragraphs) lines.push(p, \"\");\n\tif (input.quote) lines.push(`\"${input.quote}\"`, \"\");\n\tif (input.status) lines.push(input.status.text, \"\");\n\tif (input.code) lines.push(`Code: ${input.code}`, \"\");\n\tif (input.facts?.length) {\n\t\tfor (const fact of input.facts) lines.push(`${fact.label}: ${fact.value}`);\n\t\tlines.push(\"\");\n\t}\n\tif (input.cta) lines.push(`${input.cta.label}: ${input.cta.url}`, \"\");\n\tlines.push(\"--\");\n\tif (input.footnote) lines.push(input.footnote);\n\tlines.push(`Secondlayer · ${TAGLINE}`);\n\treturn lines.join(\"\\n\");\n}\n\nexport function renderEmail(input: RenderEmailInput): RenderedEmail {\n\treturn { html: renderHtml(input), text: renderText(input) };\n}\n",
|
|
5
|
+
"/**\n * The one HTML/text layout every customer email renders through, in the\n * brand's \"Figure\" look: logo + wordmark, a 24px heading, muted prose, the\n * code or facts inside a hairline code figure whose bar names it and carries\n * a status chip, one blue button, and a hairline footer.\n *\n * Table-based HTML with inline styles (most clients strip <style>). The head\n * <style> only adds dark mode for clients that honor `prefers-color-scheme`\n * (Apple Mail, iOS); everyone else gets the light palette, which Gmail\n * inverts on its own. Geist loads where web fonts work, the system stack\n * elsewhere. Callers pass content; every color lives here.\n */\n\nexport interface FactRow {\n\tlabel: string;\n\tvalue: string;\n}\n\nexport interface EmailCta {\n\tlabel: string;\n\turl: string;\n}\n\n/** `alarm` only for failures and stops, `ok` only for success. */\nexport type EmailTone = \"neutral\" | \"ok\" | \"alarm\";\n\nexport interface EmailStatus {\n\ttone: EmailTone;\n\ttext: string;\n}\n\nexport interface RenderEmailInput {\n\theading: string;\n\t/** The inbox preview line after the subject. Not shown in the body. */\n\tpreheader?: string;\n\tparagraphs: string[];\n\t/** Someone else's words, quoted (a contact form message). */\n\tquote?: string;\n\t/** A sign-in code, shown as one selectable run of digits in the figure. */\n\tcode?: string;\n\tfacts?: FactRow[];\n\t/** The figure's title bar. Defaults to \"sign-in code\" or \"details\". */\n\tfigure?: string;\n\t/** A chip in the figure bar, or a status line when there is no figure. */\n\tstatus?: EmailStatus;\n\tcta?: EmailCta;\n\t/** Why the reader got this email and how to stop it. */\n\tfootnote?: string;\n\t/**\n\t * Monospace lines shown in the figure, whitespace kept. `mark`, when set,\n\t * has its first occurrence highlighted.\n\t */\n\texcerpt?: { lines: string; mark?: string };\n\t/** Plain text at the right of the figure bar when there is no `status`. */\n\tfigureNote?: string;\n\t/** Adds an \"Unsubscribe\" link to the footer (list emails only). */\n\tunsubscribeUrl?: string;\n}\n\nexport interface RenderedEmail {\n\thtml: string;\n\ttext: string;\n}\n\n// www directly: the apex 307s there, and every image fetch would pay for it.\nconst LOGO_URL = \"https://www.secondlayer.tools/email/logo.png\";\nconst TAGLINE = \"Instant data for apps on Bitcoin\";\n\nconst SANS =\n\t\"Geist, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\nconst MONO =\n\t\"'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\";\n\n// DESIGN.md roles. Light inline; dark via the head <style> classes below.\nconst LIGHT = {\n\tpaper: \"#fbfaf7\",\n\tink: \"#14110d\",\n\tsub: \"#63605c\",\n\tfaint: \"#9d9b97\",\n\tline: \"#e8e6e3\",\n\tpri: \"#1f45e0\",\n\tonPri: \"#fbfaf7\",\n\tok: \"#128a43\",\n\talarm: \"#e3301e\",\n};\n\nconst DARK_STYLE = `\n@media (prefers-color-scheme: dark) {\n .sl-paper { background: #1e1b17 !important; }\n .sl-ink { color: #e8e6e3 !important; }\n .sl-sub { color: #b3b1ad !important; }\n .sl-faint { color: #7c7a76 !important; }\n .sl-line { border-color: #393632 !important; }\n .sl-pri { background: #3a5bff !important; }\n .sl-ok { color: #5cc28f !important; }\n .sl-alarm { color: #ff5a47 !important; }\n .sl-dot-neutral { background: #7c7a76 !important; }\n .sl-dot-ok { background: #5cc28f !important; }\n .sl-dot-alarm { background: #ff5a47 !important; }\n}`.trim();\n\nfunction escapeHtml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n\nconst TONE_COLOR: Record<EmailTone, string> = {\n\tneutral: LIGHT.sub,\n\tok: LIGHT.ok,\n\talarm: LIGHT.alarm,\n};\nconst DOT_COLOR: Record<EmailTone, string> = {\n\tneutral: LIGHT.faint,\n\tok: LIGHT.ok,\n\talarm: LIGHT.alarm,\n};\nconst TONE_CLASS: Record<EmailTone, string> = {\n\tneutral: \"sl-sub\",\n\tok: \"sl-ok\",\n\talarm: \"sl-alarm\",\n};\n\nfunction dot(tone: EmailTone): string {\n\treturn `<span class=\"sl-dot-${tone}\" style=\"display: inline-block; width: 7px; height: 7px; border-radius: 999px; background: ${DOT_COLOR[tone]}; margin-right: 6px; vertical-align: 1px;\"></span>`;\n}\n\nfunction statusChip(status: EmailStatus): string {\n\treturn `<span class=\"sl-line ${TONE_CLASS[status.tone]}\" style=\"display: inline-block; border: 1px solid ${LIGHT.line}; border-radius: 999px; padding: 2px 8px; font-family: ${MONO}; font-size: 12px; line-height: 16px; color: ${TONE_COLOR[status.tone]}; white-space: nowrap;\">${dot(status.tone)}${escapeHtml(status.text)}</span>`;\n}\n\nfunction preheaderHtml(preheader: string | undefined): string {\n\tif (!preheader) return \"\";\n\t// Trailing joiners keep body text from leaking into the preview line.\n\tconst filler = \"͏‌ \".repeat(60);\n\treturn `<div style=\"display: none; max-height: 0; overflow: hidden; mso-hide: all; opacity: 0; color: transparent;\">${escapeHtml(preheader)}${filler}</div>`;\n}\n\nfunction hasFigure(input: RenderEmailInput): boolean {\n\treturn Boolean(input.code || input.facts?.length || input.excerpt);\n}\n\nfunction excerptHtml(excerpt: { lines: string; mark?: string }): string {\n\tlet lines = escapeHtml(excerpt.lines);\n\tif (excerpt.mark) {\n\t\tconst mark = escapeHtml(excerpt.mark);\n\t\tconst at = lines.indexOf(mark);\n\t\tif (at !== -1) {\n\t\t\tlines = `${lines.slice(0, at)}<span style=\"background: #ffd200; color: #14110d; padding: 0 2px;\">${mark}</span>${lines.slice(at + mark.length)}`;\n\t\t}\n\t}\n\treturn `<tr><td colspan=\"2\" style=\"padding: 0;\"><pre class=\"sl-ink\" style=\"margin: 0; padding: 12px 14px; font-family: ${MONO}; font-size: 12.5px; line-height: 20px; white-space: pre; overflow-x: auto; color: ${LIGHT.ink};\">${lines}</pre></td></tr>`;\n}\n\nfunction figureHtml(input: RenderEmailInput): string {\n\tif (!hasFigure(input)) return \"\";\n\tconst title =\n\t\tinput.figure ??\n\t\t(input.code ? \"sign-in code\" : input.excerpt ? \"excerpt\" : \"details\");\n\tconst line = `border-color: ${LIGHT.line}; border-style: solid; border-width: 0`;\n\n\tconst bar = `<tr>\n <td class=\"sl-faint sl-line\" style=\"padding: 8px 14px; ${line}; border-bottom-width: 1px; font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};\">${escapeHtml(title)}</td>\n <td class=\"sl-line\" align=\"right\" style=\"padding: 8px 14px; ${line}; border-bottom-width: 1px;\">${input.status ? statusChip(input.status) : input.figureNote ? `<span class=\"sl-faint\" style=\"font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};\">${escapeHtml(input.figureNote)}</span>` : \"\"}</td>\n </tr>`;\n\n\tlet body: string;\n\tif (input.code) {\n\t\tbody = `<tr><td colspan=\"2\" align=\"center\" class=\"sl-ink\" style=\"padding: 24px 14px 8px; font-family: ${MONO}; font-size: 36px; line-height: 40px; font-weight: 500; letter-spacing: 0.3em; color: ${LIGHT.ink}; -webkit-user-select: all; user-select: all;\">${escapeHtml(input.code)}</td></tr>\n <tr><td colspan=\"2\" align=\"center\" class=\"sl-faint\" style=\"padding: 0 14px 16px; font-family: ${MONO}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};\">tap or double-click to select</td></tr>`;\n\t} else if (input.excerpt && !input.facts?.length) {\n\t\tbody = excerptHtml(input.excerpt);\n\t} else {\n\t\tconst facts = input.facts ?? [];\n\t\tbody = facts\n\t\t\t.map((fact, i) => {\n\t\t\t\tconst top = i === 0 ? 12 : 2;\n\t\t\t\tconst bottom = i === facts.length - 1 ? 12 : 2;\n\t\t\t\tconst cell = `padding: ${top}px 14px ${bottom}px; font-family: ${MONO}; font-size: 13px; line-height: 20px; vertical-align: top;`;\n\t\t\t\treturn `<tr>\n <td class=\"sl-faint\" style=\"${cell} padding-right: 24px; width: 1%; color: ${LIGHT.faint}; white-space: nowrap;\">${escapeHtml(fact.label.toLowerCase())}</td>\n <td class=\"sl-ink\" style=\"${cell} color: ${LIGHT.ink}; word-break: break-word;\">${escapeHtml(fact.value)}</td>\n </tr>`;\n\t\t\t})\n\t\t\t.join(\"\\n \");\n\t}\n\n\treturn `<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" class=\"sl-line\" style=\"width: 100%; border: 1px solid ${LIGHT.line}; border-radius: 8px; border-collapse: separate; border-spacing: 0; margin: 8px 0 24px;\">\n ${bar}\n ${body}\n </table>`;\n}\n\nfunction renderHtml(input: RenderEmailInput): string {\n\tconst figure = hasFigure(input);\n\n\tconst statusLine =\n\t\tinput.status && !figure\n\t\t\t? `<p class=\"${TONE_CLASS[input.status.tone]}\" style=\"margin: 0 0 12px; font-size: 13px; line-height: 20px; color: ${TONE_COLOR[input.status.tone]};\">${dot(input.status.tone)}${escapeHtml(input.status.text)}</p>`\n\t\t\t: \"\";\n\n\tconst paragraphsHtml = input.paragraphs\n\t\t.map(\n\t\t\t(p) =>\n\t\t\t\t`<p class=\"sl-sub\" style=\"margin: 0 0 14px; font-size: 15px; line-height: 24px; color: ${LIGHT.sub};\">${escapeHtml(p)}</p>`,\n\t\t)\n\t\t.join(\"\\n \");\n\n\tconst quoteHtml = input.quote\n\t\t? `<p class=\"sl-ink\" style=\"margin: 0 0 14px; font-size: 15px; line-height: 24px; color: ${LIGHT.ink};\">“${escapeHtml(input.quote)}”</p>`\n\t\t: \"\";\n\n\tconst ctaHtml = input.cta\n\t\t? `<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin: 10px 0 0;\"><tr><td class=\"sl-pri\" style=\"background: ${LIGHT.pri}; border-radius: 4px;\"><a href=\"${escapeHtml(input.cta.url)}\" style=\"display: inline-block; padding: 0 18px; height: 42px; line-height: 42px; font-family: ${SANS}; font-size: 15px; font-weight: 500; color: ${LIGHT.onPri}; text-decoration: none;\">${escapeHtml(input.cta.label)}</a></td></tr></table>`\n\t\t: \"\";\n\n\tconst unsubscribeLink = input.unsubscribeUrl\n\t\t? `<a href=\"${escapeHtml(input.unsubscribeUrl)}\" class=\"sl-sub\" style=\"color: ${LIGHT.sub}; text-decoration: underline;\">Unsubscribe</a>`\n\t\t: \"\";\n\tconst footnoteText = input.footnote ? escapeHtml(input.footnote) : \"\";\n\tconst footnoteHtml =\n\t\tfootnoteText || unsubscribeLink\n\t\t\t? `<p class=\"sl-faint\" style=\"margin: 0 0 6px;\">${[footnoteText, unsubscribeLink].filter(Boolean).join(\" \")}</p>`\n\t\t\t: \"\";\n\n\treturn `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<meta name=\"supported-color-schemes\" content=\"light dark\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Geist:wght@400;500&family=Geist+Mono:wght@400;500&display=swap\">\n<style>\n${DARK_STYLE}\n</style>\n</head>\n<body class=\"sl-paper\" style=\"margin: 0; padding: 0; background: ${LIGHT.paper};\">\n${preheaderHtml(input.preheader)}\n<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" class=\"sl-paper\" style=\"width: 100%; background: ${LIGHT.paper};\">\n <tr>\n <td align=\"center\">\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%; max-width: 560px; font-family: ${SANS}; padding: 40px 20px;\">\n <tr>\n <td>\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin: 0 0 32px;\"><tr>\n <td style=\"padding-right: 8px; vertical-align: middle;\"><img src=\"${LOGO_URL}\" width=\"30\" height=\"20\" alt=\"\" style=\"display: block; border: 0;\"></td>\n <td class=\"sl-ink\" style=\"vertical-align: middle; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: ${LIGHT.ink};\">secondlayer</td>\n </tr></table>\n ${statusLine}\n <h1 class=\"sl-ink\" style=\"margin: 0 0 14px; font-size: 24px; line-height: 29px; font-weight: 500; letter-spacing: -0.025em; color: ${LIGHT.ink};\">${escapeHtml(input.heading)}</h1>\n ${paragraphsHtml}\n ${quoteHtml}\n ${figureHtml(input)}\n ${ctaHtml}\n <div class=\"sl-line sl-faint\" style=\"margin: 32px 0 0; padding: 16px 0 0; border-top: 1px solid ${LIGHT.line}; font-size: 12px; line-height: 18px; color: ${LIGHT.faint};\">\n ${footnoteHtml}\n <p class=\"sl-faint\" style=\"margin: 0;\"><span class=\"sl-sub\" style=\"color: ${LIGHT.sub}; font-weight: 500;\">Secondlayer</span> · ${TAGLINE}</p>\n </div>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n</table>\n</body>\n</html>`;\n}\n\nfunction renderText(input: RenderEmailInput): string {\n\tconst lines: string[] = [input.heading, \"\"];\n\tfor (const p of input.paragraphs) lines.push(p, \"\");\n\tif (input.quote) lines.push(`\"${input.quote}\"`, \"\");\n\tif (input.status) lines.push(input.status.text, \"\");\n\tif (input.code) lines.push(`Code: ${input.code}`, \"\");\n\tif (input.facts?.length) {\n\t\tfor (const fact of input.facts) lines.push(`${fact.label}: ${fact.value}`);\n\t\tlines.push(\"\");\n\t}\n\tif (input.excerpt) lines.push(input.excerpt.lines, \"\");\n\tif (input.cta) lines.push(`${input.cta.label}: ${input.cta.url}`, \"\");\n\tlines.push(\"--\");\n\tif (input.footnote) lines.push(input.footnote);\n\tif (input.unsubscribeUrl) lines.push(`Unsubscribe: ${input.unsubscribeUrl}`);\n\tlines.push(`Secondlayer · ${TAGLINE}`);\n\treturn lines.join(\"\\n\");\n}\n\nexport function renderEmail(input: RenderEmailInput): RenderedEmail {\n\treturn { html: renderHtml(input), text: renderText(input) };\n}\n",
|
|
6
6
|
"import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\ntype EnvMap = NodeJS.ProcessEnv;\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n/**\n * PoX-5 print-event decoder is ON by default (mirrors pox-4/sBTC policy).\n * No activation gating needed: pox-5 events cannot exist before the Epoch 4.0\n * hard fork (Bitcoin block 960,230), so pre-activation the decoder idles at\n * tip. Opt out with `POX5_DECODER_ENABLED=false`.\n */\nexport function isPox5DecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.POX5_DECODER_ENABLED !== \"false\";\n}\n\n/** Default ON. Opt out with `SBTC_DECODER_ENABLED=false`. */\nexport function isSbtcDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.SBTC_DECODER_ENABLED !== \"false\";\n}\n\n/** Default OFF. Opt in with `BNS_DECODER_ENABLED=true`. */\nexport function isBnsDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.BNS_DECODER_ENABLED === \"true\";\n}\n\n// Export for testing\nexport { envSchema };\n",
|
|
7
7
|
"import { getEnv } from \"./env.ts\";\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n};\n\nclass Logger {\n\tprivate _level?: LogLevel;\n\tprivate _isProduction?: boolean;\n\tprivate _initialized = false;\n\n\tprivate init() {\n\t\tif (this._initialized) return;\n\t\tthis._initialized = true;\n\t\ttry {\n\t\t\tconst env = getEnv();\n\t\t\tthis._level = env.LOG_LEVEL;\n\t\t\tthis._isProduction = env.NODE_ENV === \"production\";\n\t\t} catch {\n\t\t\t// Fallback when env is unavailable (e.g. tests without DATABASE_URL)\n\t\t\tthis._level = \"info\";\n\t\t\tthis._isProduction = false;\n\t\t}\n\t}\n\n\tprivate get level(): LogLevel {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._level!;\n\t}\n\n\tprivate get isProduction(): boolean {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._isProduction!;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n\t}\n\n\tprivate formatMessage(\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tmeta?: Record<string, any>,\n\t) {\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.isProduction) {\n\t\t\t// JSON output for production\n\t\t\treturn JSON.stringify({\n\t\t\t\ttimestamp,\n\t\t\t\tlevel,\n\t\t\t\tmessage,\n\t\t\t\t...meta,\n\t\t\t});\n\t\t}\n\n\t\t// Human-readable output for development\n\t\tconst metaStr = meta ? ` ${JSON.stringify(meta)}` : \"\";\n\t\treturn `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.debug(this.formatMessage(\"debug\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.info(this.formatMessage(\"info\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.warn(this.formatMessage(\"warn\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"error\", message, meta));\n\t\t}\n\t}\n}\n\n// Export singleton instance\nexport const logger: Logger = new Logger();\n",
|
|
8
|
-
"import { logger } from \"../logger.ts\";\n\n/**\n * The one Resend call every customer email goes through. Never throws when\n * `RESEND_API_KEY` is unset — that's a dev/CI/self-host state, not a send\n * failure — it logs a warning and reports `{ skipped: true }` so a caller\n * can still record its own \"notification sent\" bookkeeping accurately.\n */\n\nexport interface SendEmailInput {\n\tto: string;\n\tsubject: string;\n\thtml: string;\n\ttext: string;\n\t/** Where a reply goes; omitted, replies go to the From address. */\n\treplyTo?: string;\n}\n\nexport type SendEmailResult = { skipped: true } | { skipped: false };\n\nexport async function sendEmail(\n\tinput: SendEmailInput,\n): Promise<SendEmailResult> {\n\tconst apiKey = process.env.RESEND_API_KEY;\n\tif (!apiKey) {\n\t\tlogger.warn(\"RESEND_API_KEY unset — skipping email\", {\n\t\t\tsubject: input.subject,\n\t\t});\n\t\treturn { skipped: true };\n\t}\n\n\tconst from =\n\t\tprocess.env.EMAIL_FROM
|
|
8
|
+
"import { logger } from \"../logger.ts\";\n\n/**\n * The one Resend call every customer email goes through. Never throws when\n * `RESEND_API_KEY` is unset — that's a dev/CI/self-host state, not a send\n * failure — it logs a warning and reports `{ skipped: true }` so a caller\n * can still record its own \"notification sent\" bookkeeping accurately.\n */\n\nexport interface SendEmailInput {\n\tto: string;\n\tsubject: string;\n\thtml: string;\n\ttext: string;\n\t/** Where a reply goes; omitted, replies go to the From address. */\n\treplyTo?: string;\n\t/** Overrides the `EMAIL_FROM` default. */\n\tfrom?: string;\n\t/** Extra message headers, e.g. RFC 8058 `List-Unsubscribe`. */\n\theaders?: Record<string, string>;\n}\n\nexport type SendEmailResult = { skipped: true } | { skipped: false };\n\nexport async function sendEmail(\n\tinput: SendEmailInput,\n): Promise<SendEmailResult> {\n\tconst apiKey = process.env.RESEND_API_KEY;\n\tif (!apiKey) {\n\t\tlogger.warn(\"RESEND_API_KEY unset — skipping email\", {\n\t\t\tsubject: input.subject,\n\t\t});\n\t\treturn { skipped: true };\n\t}\n\n\tconst from =\n\t\tinput.from ??\n\t\tprocess.env.EMAIL_FROM ??\n\t\t\"secondlayer <noreply@secondlayer.tools>\";\n\n\tconst response = await fetch(\"https://api.resend.com/emails\", {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\tfrom,\n\t\t\tto: [input.to],\n\t\t\tsubject: input.subject,\n\t\t\thtml: input.html,\n\t\t\ttext: input.text,\n\t\t\t...(input.replyTo ? { reply_to: [input.replyTo] } : {}),\n\t\t\t...(input.headers && Object.keys(input.headers).length > 0\n\t\t\t\t? { headers: input.headers }\n\t\t\t\t: {}),\n\t\t}),\n\t});\n\n\tif (!response.ok) {\n\t\tconst body = await response.text().catch(() => \"\");\n\t\tthrow new Error(\n\t\t\t`Resend API error (${response.status}): ${body.slice(0, 200)}`,\n\t\t);\n\t}\n\n\treturn { skipped: false };\n}\n",
|
|
9
|
+
"import { renderEmail } from \"./render.ts\";\n\n/**\n * The email updates list: sender, links and the double opt-in email. Every\n * list email must carry `unsubscribeFor(token)` (footer link plus the\n * RFC 8058 headers Gmail and Yahoo require from bulk senders).\n */\n\nexport const UPDATES_FROM = \"Secondlayer <dev@secondlayer.tools>\";\nexport const UPDATES_SITE_URL = \"https://www.secondlayer.tools\";\nexport const UPDATES_API_URL = \"https://api.secondlayer.tools\";\n\n/** Footer link (a web page that unsubscribes on load) and one-click headers. */\nexport function unsubscribeFor(token: string): {\n\turl: string;\n\theaders: Record<string, string>;\n} {\n\tconst t = encodeURIComponent(token);\n\treturn {\n\t\turl: `${UPDATES_SITE_URL}/updates/unsubscribe?t=${t}`,\n\t\theaders: {\n\t\t\t\"List-Unsubscribe\": `<${UPDATES_API_URL}/api/public/updates/unsubscribe?t=${t}>`,\n\t\t\t\"List-Unsubscribe-Post\": \"List-Unsubscribe=One-Click\",\n\t\t},\n\t};\n}\n\n/**\n * The double opt-in email. No unsubscribe link or headers: the address is\n * not on the list until it confirms.\n */\nexport function confirmEmail(token: string): {\n\tsubject: string;\n\thtml: string;\n\ttext: string;\n} {\n\tconst subject = \"Confirm your secondlayer subscription\";\n\tconst { html, text } = renderEmail({\n\t\theading: \"Confirm your email\",\n\t\tpreheader: \"One click and new posts and launches come to this inbox.\",\n\t\tparagraphs: [\n\t\t\t\"Confirm and we'll email you when we publish a post or ship something new. Nothing else, and every email has a one-click unsubscribe.\",\n\t\t],\n\t\tcta: {\n\t\t\tlabel: \"Confirm subscription\",\n\t\t\turl: `${UPDATES_SITE_URL}/updates/confirm?t=${encodeURIComponent(token)}`,\n\t\t},\n\t\tfootnote:\n\t\t\t\"Someone entered this address at secondlayer.tools/blog. If it wasn't you, ignore this email and you won't hear from us. The link works for 7 days.\",\n\t});\n\treturn { subject, html, text };\n}\n"
|
|
9
10
|
],
|
|
10
|
-
"mappings": ";
|
|
11
|
-
"debugId": "
|
|
11
|
+
"mappings": ";AAiEA,IAAM,WAAW;AACjB,IAAM,UAAU;AAEhB,IAAM,OACL;AACD,IAAM,OACL;AAGD,IAAM,QAAQ;AAAA,EACb,OAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,OAAO;AACR;AAEA,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