deepline 0.3.491 → 0.3.493
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/bundling-sources/sdk/src/client-core.ts +11 -5
- package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +6 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +25 -9
- package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
- package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +54 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +5 -4
- package/dist/bundling-sources/shared_libs/play-runtime/crustdata-company-identify-batching.ts +162 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +19 -3
- package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +5 -3
- package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +17 -23
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +28 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +293 -110
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-placement-policy.ts +75 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +412 -59
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +38 -10
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +19 -11
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +165 -12
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +358 -0
- package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +104 -2
- package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +7 -2
- package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +4 -0
- package/dist/bundling-sources/shared_libs/product-notifications/content.ts +13 -0
- package/dist/bundling-sources/shared_libs/product-notifications/email.ts +49 -10
- package/dist/bundling-sources/shared_libs/product-notifications/events.ts +22 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +6 -1
- package/dist/cli/{auth-FXAC472Y.mjs → auth-3NAY3AST.mjs} +5 -5
- package/dist/cli/auth-KYQLDI6V.js +43 -0
- package/dist/cli/{billing-PDOA3KZ3.js → billing-FSB4BBBO.js} +80 -80
- package/dist/cli/{billing-UM4LE33K.mjs → billing-SBWQCC7B.mjs} +7 -7
- package/dist/cli/{chunk-HSJK6EMU.mjs → chunk-2BRTYIAH.mjs} +23 -9
- package/dist/cli/{chunk-B2TXKEED.js → chunk-2H4OFVR5.js} +5 -5
- package/dist/cli/{chunk-BCKIBVEJ.js → chunk-2I7VN65H.js} +10 -10
- package/dist/cli/{chunk-LMG7O6XJ.mjs → chunk-2IHGVAGT.mjs} +2 -2
- package/dist/cli/{chunk-5KMGKG4B.js → chunk-2NGIBJM2.js} +8 -8
- package/dist/cli/{chunk-2MW6TGNZ.mjs → chunk-3QGUWB6E.mjs} +4 -4
- package/dist/cli/{chunk-ORKLMANE.mjs → chunk-4IJFQV3O.mjs} +1 -1
- package/dist/cli/{chunk-PIPEPCRL.mjs → chunk-4NIGNT7X.mjs} +1 -1
- package/dist/cli/{chunk-H6UIS36S.mjs → chunk-5DIZ2G74.mjs} +2 -2
- package/dist/cli/{chunk-TKLDKIJU.mjs → chunk-5JPKRDFC.mjs} +7 -5
- package/dist/cli/{chunk-FTXIJTV2.mjs → chunk-5WOPBX3H.mjs} +1 -1
- package/dist/cli/{chunk-KGJVDR4Q.mjs → chunk-67ZG7XZV.mjs} +3 -3
- package/dist/cli/{chunk-DUFRH43S.js → chunk-7HABWOMB.js} +261 -261
- package/dist/cli/{chunk-MN6DCV63.js → chunk-AGTXL6LZ.js} +5 -5
- package/dist/cli/{chunk-Q7G7CU4W.js → chunk-AWMCZAUR.js} +3 -3
- package/dist/cli/{chunk-HHTVRICE.js → chunk-C2MRDPA5.js} +17 -17
- package/dist/cli/{chunk-ONONSV2Q.mjs → chunk-DVQHG6AM.mjs} +1 -0
- package/dist/cli/{chunk-O3K22ZC7.js → chunk-DWJ4RXSA.js} +34 -11
- package/dist/cli/{chunk-MAM6ZOVS.mjs → chunk-DYP27IWC.mjs} +99 -24
- package/dist/cli/{chunk-NUOKAKZW.mjs → chunk-E5ILCMKQ.mjs} +1 -1
- package/dist/cli/{chunk-OLHWZM4A.mjs → chunk-EBAS3UT2.mjs} +6 -6
- package/dist/cli/{chunk-74H5OTRM.js → chunk-EFO5GVYS.js} +1 -1
- package/dist/cli/{chunk-X7YOVJBC.js → chunk-EYG336YV.js} +132 -57
- package/dist/cli/{chunk-YV4DP6KQ.mjs → chunk-GSC35TPZ.mjs} +2 -2
- package/dist/cli/{chunk-EPD7NSDJ.mjs → chunk-HLM2UFQ5.mjs} +13 -5
- package/dist/cli/{chunk-IG3GSBBE.js → chunk-HTUSTPP4.js} +32 -32
- package/dist/cli/{chunk-CFPFTS3A.mjs → chunk-IJJ6D5WL.mjs} +12 -12
- package/dist/cli/{chunk-TH7JLR5D.js → chunk-IJOHWGPF.js} +6 -6
- package/dist/cli/{chunk-RFSXXDH7.js → chunk-IOBPR2VO.js} +17 -17
- package/dist/cli/{chunk-HNG2U3IG.js → chunk-IOMEJKGK.js} +2 -2
- package/dist/cli/{chunk-A7ZMG2QZ.mjs → chunk-IRDYBMA7.mjs} +34 -11
- package/dist/cli/{chunk-ZEZ3CZ3X.js → chunk-JO2JZUBR.js} +3 -3
- package/dist/cli/{chunk-4IP5MLWU.js → chunk-JO5FFSR7.js} +6 -1
- package/dist/cli/{chunk-SJOHQ2WW.js → chunk-KCDZWS2B.js} +56 -56
- package/dist/cli/{chunk-CGDUFVNE.mjs → chunk-KGDDQMI7.mjs} +2 -2
- package/dist/cli/{chunk-OYJTLEB4.mjs → chunk-KKSKYZO4.mjs} +1 -1
- package/dist/cli/{chunk-TMAS3WH3.js → chunk-LGTZYI5B.js} +21 -21
- package/dist/cli/{chunk-SUMKWA53.js → chunk-MLEUOTEQ.js} +73 -59
- package/dist/cli/{chunk-3WRWPNHE.mjs → chunk-NALJJTPS.mjs} +5 -5
- package/dist/cli/{chunk-27MRSV6O.js → chunk-NPNAEPY4.js} +26 -26
- package/dist/cli/{chunk-AEKJZJ4R.js → chunk-NWIDPT7H.js} +4 -4
- package/dist/cli/{chunk-AUQQVDAB.js → chunk-PKV5CD3W.js} +1 -0
- package/dist/cli/{chunk-3FMU6F6E.js → chunk-QTPS5RLG.js} +15 -15
- package/dist/cli/{chunk-4OLXMJ2L.js → chunk-RLX5ZFNX.js} +8 -6
- package/dist/cli/{chunk-DEJIN4DF.mjs → chunk-SAW3FBCA.mjs} +5 -0
- package/dist/cli/{chunk-S4CYM4EC.mjs → chunk-SXD2EYAH.mjs} +6 -6
- package/dist/cli/{chunk-YNWET57Z.js → chunk-TIFRRLZT.js} +7 -7
- package/dist/cli/{chunk-6PMM7VJN.mjs → chunk-TNQOR6XQ.mjs} +1 -1
- package/dist/cli/{chunk-6UARNRXT.js → chunk-UCMY2SO2.js} +23 -15
- package/dist/cli/{chunk-X75ONMDJ.mjs → chunk-VFHIYWMC.mjs} +5 -5
- package/dist/cli/{chunk-ZX2FXZJN.js → chunk-WCZFCOMZ.js} +7 -7
- package/dist/cli/{chunk-IIO7UOVW.mjs → chunk-WTFI7BVH.mjs} +3 -3
- package/dist/cli/{chunk-I64PYCTB.js → chunk-XLE7KXE7.js} +2 -2
- package/dist/cli/{chunk-CRBBGKRH.js → chunk-XQX476QK.js} +14 -14
- package/dist/cli/{chunk-WCWVXN3R.mjs → chunk-Y3NN2UAF.mjs} +2 -2
- package/dist/cli/{chunk-3K4IAV7I.mjs → chunk-ZQH4TXM2.mjs} +2 -2
- package/dist/cli/{chunk-VC3SH4QW.mjs → chunk-ZVW7EWTC.mjs} +7 -7
- package/dist/cli/{chunk-QBOE5LEH.mjs → chunk-ZVXB7OU7.mjs} +1 -1
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-IGPAPAES.js → csv-DKYZE2KM.js} +13 -13
- package/dist/cli/{csv-RNMQHECI.mjs → csv-XR22YQXT.mjs} +4 -4
- package/dist/cli/{db-CKMVVGXJ.mjs → db-EOKG36YN.mjs} +7 -7
- package/dist/cli/{db-32OXM3TO.js → db-RNYRTCMV.js} +28 -28
- package/dist/cli/describe-ICFXOQBW.mjs +50 -0
- package/dist/cli/describe-RS75I33X.js +50 -0
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/describe-core.js +4 -4
- package/dist/cli/describe-core.mjs +3 -3
- package/dist/cli/{executions-S4M4JMCU.mjs → executions-3RAOACNS.mjs} +7 -7
- package/dist/cli/{executions-PCZS7B2M.js → executions-OBWPSWH7.js} +9 -9
- package/dist/cli/{feedback-FGUJVCBS.mjs → feedback-6EQRVBKF.mjs} +4 -4
- package/dist/cli/{feedback-6EGKPZ3U.js → feedback-6GPEUBLF.js} +8 -8
- package/dist/cli/getting-started.d.mts +12 -10
- package/dist/cli/getting-started.d.ts +12 -10
- package/dist/cli/getting-started.js +4 -2
- package/dist/cli/getting-started.mjs +3 -1
- package/dist/cli/{git-LR4ARG5H.mjs → git-CVQ24DTR.mjs} +5 -5
- package/dist/cli/git-DEFE4SSB.js +25 -0
- package/dist/cli/index.js +143 -143
- package/dist/cli/index.mjs +43 -43
- package/dist/cli/{legacy-noops-S37PJ7OJ.mjs → legacy-noops-QULJZYNH.mjs} +5 -5
- package/dist/cli/{legacy-noops-VX4JEQR6.js → legacy-noops-XPOATG5V.js} +8 -8
- package/dist/cli/{monitors-H3AX6CZG.mjs → monitors-AFT5YJPZ.mjs} +49 -9
- package/dist/cli/{monitors-ADASJI72.js → monitors-OJ4CMREE.js} +169 -129
- package/dist/cli/{org-ZRJ3C56J.js → org-RKT52CSL.js} +73 -73
- package/dist/cli/{org-D3F5LUDW.mjs → org-WHKNXANG.mjs} +7 -7
- package/dist/cli/{pages-PSHU366M.mjs → pages-EEAQFGVD.mjs} +7 -7
- package/dist/cli/{pages-5TKO3644.js → pages-SOE3R667.js} +18 -18
- package/dist/cli/{play-AUDDK7XB.mjs → play-LXFWHUBP.mjs} +147 -52
- package/dist/cli/{play-VDAETQDI.js → play-OTJJ4E4T.js} +661 -566
- package/dist/cli/{providers-IURPWRWD.js → providers-RU4HIAT3.js} +10 -10
- package/dist/cli/{providers-X7YMZSKQ.mjs → providers-U3CPKTMM.mjs} +7 -7
- package/dist/cli/{quickstart-6AGWVFNX.mjs → quickstart-75AO2AJC.mjs} +5 -5
- package/dist/cli/{quickstart-Y6GFXLDV.js → quickstart-N72IVA2Y.js} +13 -13
- package/dist/cli/{run-TG7J45NS.mjs → run-IGWFL6WH.mjs} +29 -28
- package/dist/cli/{run-TQFGOXNT.js → run-MMYES3IW.js} +44 -43
- package/dist/cli/search-EQURI7SZ.js +32 -0
- package/dist/cli/{search-3G4J2GC6.mjs → search-FIYESBLZ.mjs} +8 -8
- package/dist/cli/{search-output-NPZICK5C.js → search-output-2FXN4ZWD.js} +9 -6
- package/dist/cli/{search-output-ZGNHDCLL.mjs → search-output-3I5KSW36.mjs} +7 -4
- package/dist/cli/{secrets-KTTHT4ZG.js → secrets-HCZQ6JNP.js} +16 -16
- package/dist/cli/{secrets-EAWJBRUD.mjs → secrets-O7IUQ3VT.mjs} +7 -7
- package/dist/cli/{sessions-S4YVBPAW.js → sessions-5AYTT4IW.js} +6 -6
- package/dist/cli/{sessions-D4Q3LCEQ.mjs → sessions-KY7A3EZO.mjs} +5 -5
- package/dist/cli/{settings-BAK3VOWW.js → settings-P4VFYWJK.js} +80 -80
- package/dist/cli/{settings-JUORW6NL.mjs → settings-WSMRR2GS.mjs} +13 -13
- package/dist/cli/{setup-NJPHTW32.js → setup-J7CA3EJL.js} +57 -57
- package/dist/cli/{setup-AXFGCXJE.mjs → setup-YTVKVQC7.mjs} +13 -13
- package/dist/cli/skills-KKPEGLAR.js +36 -0
- package/dist/cli/{skills-SKJVDJEF.mjs → skills-W5WY764N.mjs} +10 -10
- package/dist/cli/tools-65Y4QTW6.js +57 -0
- package/dist/cli/{tools-63THJVJZ.mjs → tools-YECI6N3N.mjs} +20 -20
- package/dist/cli/{update-KSID5F74.mjs → update-BIFBIEII.mjs} +10 -10
- package/dist/cli/update-WDG7VFOW.js +34 -0
- package/dist/cli/{workflow-BLSMWBKW.js → workflow-D2TUFFH6.js} +18 -18
- package/dist/cli/{workflow-C4B54X2Z.mjs → workflow-XZVDNARC.mjs} +8 -8
- package/dist/{client-CQgGFxAH.d.ts → client-BDB_VbE4.d.ts} +1 -1
- package/dist/{client-B4R1scm2.d.mts → client-CNzJ1LTF.d.mts} +1 -1
- package/dist/{client-core-DMvHWjub.d.mts → client-core-CSv3DlPD.d.mts} +76 -5
- package/dist/{client-core-BUNjKBKq.d.ts → client-core-xEa9x3pl.d.ts} +76 -5
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/index.mjs +7 -7
- package/dist/install-integrity.json +115 -114
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/plays/run-request.js +2 -2
- package/dist/plays/run-request.mjs +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +6 -6
- package/dist/server.mjs +4 -4
- package/package.json +1 -1
- package/dist/cli/auth-QIDL3YCW.js +0 -43
- package/dist/cli/describe-67GMIEIO.js +0 -50
- package/dist/cli/describe-QR7I3VOF.mjs +0 -50
- package/dist/cli/git-PIH5Z5LN.js +0 -25
- package/dist/cli/search-VC43NUY7.js +0 -32
- package/dist/cli/skills-4NQZISNK.js +0 -36
- package/dist/cli/tools-BAHK33FQ.js +0 -57
- package/dist/cli/update-EMIGRGJ7.js +0 -34
|
@@ -6,6 +6,364 @@ export type WorkReceiptStateStatus =
|
|
|
6
6
|
| 'failed'
|
|
7
7
|
| 'skipped';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The receipt status machine, declared once for both receipt stores.
|
|
11
|
+
*
|
|
12
|
+
* Every SQL write of a receipt's status takes its allowed-from set from the
|
|
13
|
+
* tables below (`status = ANY($from)`), so the legal moves live here and not
|
|
14
|
+
* in each statement. `absent` is the source of an INSERT: no row exists yet.
|
|
15
|
+
*
|
|
16
|
+
* The two stores hold different machines and this module keeps both, side by
|
|
17
|
+
* side, so a change to one is a visible decision about the other:
|
|
18
|
+
*
|
|
19
|
+
* - The Postgres scheduler (`runtime_scheduler.receipts.status`, text) keeps
|
|
20
|
+
* `pending` (released, free to claim) apart from `queued` (marked by its
|
|
21
|
+
* live owner).
|
|
22
|
+
* - The customer-database store (`status smallint`) stores both as code 0,
|
|
23
|
+
* named `queued` here.
|
|
24
|
+
*
|
|
25
|
+
* `SCHEDULER_TENANT_WORK_RECEIPT_DIFFERENCES` lists where they disagree.
|
|
26
|
+
*/
|
|
27
|
+
export const WORK_RECEIPT_STATUSES = [
|
|
28
|
+
'queued',
|
|
29
|
+
'pending',
|
|
30
|
+
'running',
|
|
31
|
+
'completed',
|
|
32
|
+
'failed',
|
|
33
|
+
'skipped',
|
|
34
|
+
] as const satisfies readonly WorkReceiptStateStatus[];
|
|
35
|
+
|
|
36
|
+
/** Statuses the customer-database store can hold; `pending` is stored as `queued`. */
|
|
37
|
+
export const TENANT_WORK_RECEIPT_STATUSES = [
|
|
38
|
+
'queued',
|
|
39
|
+
'running',
|
|
40
|
+
'completed',
|
|
41
|
+
'failed',
|
|
42
|
+
'skipped',
|
|
43
|
+
] as const satisfies readonly WorkReceiptStateStatus[];
|
|
44
|
+
|
|
45
|
+
export const WORK_RECEIPT_TERMINAL_STATUSES = [
|
|
46
|
+
'completed',
|
|
47
|
+
'failed',
|
|
48
|
+
'skipped',
|
|
49
|
+
] as const satisfies readonly WorkReceiptStateStatus[];
|
|
50
|
+
|
|
51
|
+
/** Terminal receipts whose output later runs reuse instead of executing. */
|
|
52
|
+
export const WORK_RECEIPT_REUSABLE_STATUSES = [
|
|
53
|
+
'completed',
|
|
54
|
+
'skipped',
|
|
55
|
+
] as const satisfies readonly WorkReceiptStateStatus[];
|
|
56
|
+
|
|
57
|
+
/** Live receipts: claimed by an owner run that has not finished the work. */
|
|
58
|
+
export const WORK_RECEIPT_LIVE_STATUSES = [
|
|
59
|
+
'queued',
|
|
60
|
+
'running',
|
|
61
|
+
] as const satisfies readonly WorkReceiptStateStatus[];
|
|
62
|
+
|
|
63
|
+
export const WORK_RECEIPT_ABSENT = 'absent';
|
|
64
|
+
export type WorkReceiptTransitionSource =
|
|
65
|
+
| WorkReceiptStateStatus
|
|
66
|
+
| typeof WORK_RECEIPT_ABSENT;
|
|
67
|
+
|
|
68
|
+
export type WorkReceiptTransitionSpec = {
|
|
69
|
+
/** Statuses (or `absent`, for an INSERT) the write may start from. */
|
|
70
|
+
readonly from: readonly WorkReceiptTransitionSource[];
|
|
71
|
+
/** Statuses the write may produce. */
|
|
72
|
+
readonly to: readonly WorkReceiptStateStatus[];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* `runtime_scheduler.receipts.status`. Each entry is one write in
|
|
77
|
+
* `scheduler-backends/postgres.ts`; the row-level fences (owner run, attempt,
|
|
78
|
+
* lease) stay in that SQL and narrow these sets further.
|
|
79
|
+
*/
|
|
80
|
+
export const SCHEDULER_WORK_RECEIPT_TRANSITIONS = {
|
|
81
|
+
/** claimPostgresSchedulerReceipt(s). A live owner is taken over only when its run is terminal. */
|
|
82
|
+
claim: {
|
|
83
|
+
from: [WORK_RECEIPT_ABSENT, 'pending', 'failed', 'queued', 'running'],
|
|
84
|
+
to: ['running'],
|
|
85
|
+
},
|
|
86
|
+
/** Claim with `reclaimRunning`: an expired or unleased running receipt may be taken over. */
|
|
87
|
+
claim_reclaim_running: {
|
|
88
|
+
from: [WORK_RECEIPT_ABSENT, 'pending', 'failed', 'running'],
|
|
89
|
+
to: ['running'],
|
|
90
|
+
},
|
|
91
|
+
/** Claim with `forceRefresh`: a different run may replace reusable output. */
|
|
92
|
+
claim_force_refresh: {
|
|
93
|
+
from: [
|
|
94
|
+
WORK_RECEIPT_ABSENT,
|
|
95
|
+
'pending',
|
|
96
|
+
'failed',
|
|
97
|
+
'running',
|
|
98
|
+
'completed',
|
|
99
|
+
'skipped',
|
|
100
|
+
],
|
|
101
|
+
to: ['running'],
|
|
102
|
+
},
|
|
103
|
+
/** Leased completion by the running owner and attempt. */
|
|
104
|
+
complete: { from: ['running'], to: ['completed'] },
|
|
105
|
+
/**
|
|
106
|
+
* Immutable cache publication (`COMPLETED_RECEIPT_CACHE_INSERT_LEASE_ID`).
|
|
107
|
+
* It ignores leases: a publisher never waits on a peer, and a live owner's
|
|
108
|
+
* later leased completion matches no row and reads the published value.
|
|
109
|
+
*/
|
|
110
|
+
publish_completed: {
|
|
111
|
+
from: [WORK_RECEIPT_ABSENT, 'queued', 'pending', 'running', 'failed'],
|
|
112
|
+
to: ['completed'],
|
|
113
|
+
},
|
|
114
|
+
fail: { from: ['running'], to: ['failed'] },
|
|
115
|
+
/** Exact release by the owner; `pending` is claimable by the next run. */
|
|
116
|
+
release: { from: ['running'], to: ['pending'] },
|
|
117
|
+
/** Attempt cleanup returns every receipt the attempt still holds. */
|
|
118
|
+
release_attempt: { from: ['queued', 'running'], to: ['pending'] },
|
|
119
|
+
mark_running: { from: ['queued', 'running'], to: ['running'] },
|
|
120
|
+
mark_queued: { from: ['queued', 'running'], to: ['queued'] },
|
|
121
|
+
skip: {
|
|
122
|
+
from: [WORK_RECEIPT_ABSENT, 'pending', 'failed', 'running'],
|
|
123
|
+
to: ['skipped'],
|
|
124
|
+
},
|
|
125
|
+
} as const satisfies Record<string, WorkReceiptTransitionSpec>;
|
|
126
|
+
|
|
127
|
+
export type SchedulerWorkReceiptTransition =
|
|
128
|
+
keyof typeof SCHEDULER_WORK_RECEIPT_TRANSITIONS;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Customer-database receipts (`apps/deepline-api` store-impl, SQL from
|
|
132
|
+
* `receipt-sql.ts`). A lease-aware claim produces `queued`, an unleased one
|
|
133
|
+
* `running`.
|
|
134
|
+
*/
|
|
135
|
+
export const TENANT_WORK_RECEIPT_TRANSITIONS = {
|
|
136
|
+
claim: {
|
|
137
|
+
from: [WORK_RECEIPT_ABSENT, 'queued', 'failed'],
|
|
138
|
+
to: ['queued', 'running'],
|
|
139
|
+
},
|
|
140
|
+
claim_reclaim_running: {
|
|
141
|
+
from: [WORK_RECEIPT_ABSENT, 'queued', 'running', 'failed'],
|
|
142
|
+
to: ['queued', 'running'],
|
|
143
|
+
},
|
|
144
|
+
claim_force_refresh: {
|
|
145
|
+
from: [WORK_RECEIPT_ABSENT, 'queued', 'failed', 'completed', 'skipped'],
|
|
146
|
+
to: ['queued', 'running'],
|
|
147
|
+
},
|
|
148
|
+
claim_force_refresh_reclaim_running: {
|
|
149
|
+
from: [
|
|
150
|
+
WORK_RECEIPT_ABSENT,
|
|
151
|
+
'queued',
|
|
152
|
+
'failed',
|
|
153
|
+
'running',
|
|
154
|
+
'completed',
|
|
155
|
+
'skipped',
|
|
156
|
+
],
|
|
157
|
+
to: ['queued', 'running'],
|
|
158
|
+
},
|
|
159
|
+
complete: { from: ['queued', 'running'], to: ['completed'] },
|
|
160
|
+
publish_completed: {
|
|
161
|
+
from: [WORK_RECEIPT_ABSENT, 'queued', 'running', 'failed'],
|
|
162
|
+
to: ['completed'],
|
|
163
|
+
},
|
|
164
|
+
fail: { from: ['queued', 'running'], to: ['failed'] },
|
|
165
|
+
release: { from: ['queued', 'running'], to: ['queued'] },
|
|
166
|
+
mark_running: { from: ['queued', 'running'], to: ['running'] },
|
|
167
|
+
mark_queued: { from: ['queued', 'running'], to: ['queued'] },
|
|
168
|
+
skip: { from: ['queued', 'running'], to: ['skipped'] },
|
|
169
|
+
} as const satisfies Record<string, WorkReceiptTransitionSpec>;
|
|
170
|
+
|
|
171
|
+
export type TenantWorkReceiptTransition =
|
|
172
|
+
keyof typeof TENANT_WORK_RECEIPT_TRANSITIONS;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Every move out of a terminal status, by name. A transition table entry that
|
|
176
|
+
* leaves a terminal status without a row here fails the conformance test, so a
|
|
177
|
+
* new exit is always a named, reviewed decision.
|
|
178
|
+
*/
|
|
179
|
+
export const WORK_RECEIPT_TERMINAL_EXITS = [
|
|
180
|
+
{
|
|
181
|
+
store: 'scheduler',
|
|
182
|
+
transition: 'claim',
|
|
183
|
+
from: 'failed',
|
|
184
|
+
why: 'Failed work is not reusable: another run, or the same run with forceFailedRefresh, retries it.',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
store: 'scheduler',
|
|
188
|
+
transition: 'claim_reclaim_running',
|
|
189
|
+
from: 'failed',
|
|
190
|
+
why: 'As claim.',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
store: 'scheduler',
|
|
194
|
+
transition: 'claim_force_refresh',
|
|
195
|
+
from: 'failed',
|
|
196
|
+
why: 'As claim.',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
store: 'scheduler',
|
|
200
|
+
transition: 'claim_force_refresh',
|
|
201
|
+
from: 'completed',
|
|
202
|
+
why: 'Force refresh from a different run replaces reusable output (seedForcedRuntimeStepReceipts).',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
store: 'scheduler',
|
|
206
|
+
transition: 'claim_force_refresh',
|
|
207
|
+
from: 'skipped',
|
|
208
|
+
why: 'As completed.',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
store: 'scheduler',
|
|
212
|
+
transition: 'publish_completed',
|
|
213
|
+
from: 'failed',
|
|
214
|
+
why: 'A successful re-execution publishes over a non-reusable failure.',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
store: 'scheduler',
|
|
218
|
+
transition: 'skip',
|
|
219
|
+
from: 'failed',
|
|
220
|
+
why: 'The same run (or an unowned row) records a skip over its own failure.',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
store: 'tenant',
|
|
224
|
+
transition: 'claim',
|
|
225
|
+
from: 'failed',
|
|
226
|
+
why: 'As the scheduler claim.',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
store: 'tenant',
|
|
230
|
+
transition: 'claim_reclaim_running',
|
|
231
|
+
from: 'failed',
|
|
232
|
+
why: 'As claim.',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
store: 'tenant',
|
|
236
|
+
transition: 'claim_force_refresh',
|
|
237
|
+
from: 'failed',
|
|
238
|
+
why: 'As claim.',
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
store: 'tenant',
|
|
242
|
+
transition: 'claim_force_refresh',
|
|
243
|
+
from: 'completed',
|
|
244
|
+
why: 'As the scheduler force refresh.',
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
store: 'tenant',
|
|
248
|
+
transition: 'claim_force_refresh',
|
|
249
|
+
from: 'skipped',
|
|
250
|
+
why: 'As the scheduler force refresh.',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
store: 'tenant',
|
|
254
|
+
transition: 'claim_force_refresh_reclaim_running',
|
|
255
|
+
from: 'failed',
|
|
256
|
+
why: 'As claim.',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
store: 'tenant',
|
|
260
|
+
transition: 'claim_force_refresh_reclaim_running',
|
|
261
|
+
from: 'completed',
|
|
262
|
+
why: 'As the scheduler force refresh.',
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
store: 'tenant',
|
|
266
|
+
transition: 'claim_force_refresh_reclaim_running',
|
|
267
|
+
from: 'skipped',
|
|
268
|
+
why: 'As the scheduler force refresh.',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
store: 'tenant',
|
|
272
|
+
transition: 'publish_completed',
|
|
273
|
+
from: 'failed',
|
|
274
|
+
why: 'As the scheduler publication.',
|
|
275
|
+
},
|
|
276
|
+
] as const;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Where the two stores' tables disagree, by transition name, after reading the
|
|
280
|
+
* scheduler's `pending` as the customer store's `queued` (both mean free to
|
|
281
|
+
* claim). These predate the shared table and are kept as they are. The
|
|
282
|
+
* conformance test compares the tables and fails when this list no longer
|
|
283
|
+
* names exactly the transitions that differ.
|
|
284
|
+
*/
|
|
285
|
+
export const SCHEDULER_TENANT_WORK_RECEIPT_DIFFERENCES = {
|
|
286
|
+
claim:
|
|
287
|
+
'The scheduler always claims to running and may take over a live (queued or running) receipt once its owner run is terminal. A lease-aware customer claim produces queued, and the customer store claims running only with reclaimRunning.',
|
|
288
|
+
claim_reclaim_running:
|
|
289
|
+
'The target differs, as for claim. The scheduler also refuses an owner-marked queued receipt, which the customer store cannot tell apart from a free one.',
|
|
290
|
+
claim_force_refresh:
|
|
291
|
+
'The scheduler admits running on every force refresh, and refuses owner-marked queued; the customer store admits running only when reclaimRunning is also set (claim_force_refresh_reclaim_running).',
|
|
292
|
+
claim_force_refresh_reclaim_running:
|
|
293
|
+
'Customer store only: the scheduler ignores reclaimRunning when forceRefresh is set.',
|
|
294
|
+
complete:
|
|
295
|
+
'The scheduler requires running. The customer store also accepts queued, because its lease-aware claim produces queued.',
|
|
296
|
+
fail: 'As complete.',
|
|
297
|
+
release:
|
|
298
|
+
'The scheduler releases running only; the customer store releases queued or running.',
|
|
299
|
+
release_attempt:
|
|
300
|
+
'Scheduler only: attempt cleanup returns every receipt the attempt holds to pending.',
|
|
301
|
+
skip: 'The scheduler upserts a skip over an absent, pending, failed or running row; the customer store updates only a live owned row.',
|
|
302
|
+
} as const;
|
|
303
|
+
|
|
304
|
+
/** The SQL `status = ANY($from)` set for a scheduler transition (no `absent`). */
|
|
305
|
+
export function schedulerWorkReceiptFromStatuses(
|
|
306
|
+
transition: SchedulerWorkReceiptTransition,
|
|
307
|
+
): WorkReceiptStateStatus[] {
|
|
308
|
+
return existingFromStatuses(SCHEDULER_WORK_RECEIPT_TRANSITIONS[transition]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** The status the scheduler transition writes. */
|
|
312
|
+
export function schedulerWorkReceiptTargetStatus(
|
|
313
|
+
transition: SchedulerWorkReceiptTransition,
|
|
314
|
+
): WorkReceiptStateStatus {
|
|
315
|
+
const [to] = SCHEDULER_WORK_RECEIPT_TRANSITIONS[transition].to;
|
|
316
|
+
return to;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** The scheduler claim transition for a claim's flags. */
|
|
320
|
+
export function schedulerWorkReceiptClaimTransition(input: {
|
|
321
|
+
forceRefresh?: boolean;
|
|
322
|
+
reclaimRunning?: boolean;
|
|
323
|
+
}): Extract<
|
|
324
|
+
SchedulerWorkReceiptTransition,
|
|
325
|
+
'claim' | 'claim_reclaim_running' | 'claim_force_refresh'
|
|
326
|
+
> {
|
|
327
|
+
if (input.forceRefresh === true) return 'claim_force_refresh';
|
|
328
|
+
if (input.reclaimRunning === true) return 'claim_reclaim_running';
|
|
329
|
+
return 'claim';
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** The customer-database `status = ANY($from)` set (no `absent`). */
|
|
333
|
+
export function tenantWorkReceiptFromStatuses(
|
|
334
|
+
transition: TenantWorkReceiptTransition,
|
|
335
|
+
): WorkReceiptStateStatus[] {
|
|
336
|
+
return existingFromStatuses(TENANT_WORK_RECEIPT_TRANSITIONS[transition]);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** The customer-database claim transition for a claim's flags. */
|
|
340
|
+
export function tenantWorkReceiptClaimTransition(input: {
|
|
341
|
+
forceRefresh?: boolean;
|
|
342
|
+
reclaimRunning?: boolean;
|
|
343
|
+
}): Extract<
|
|
344
|
+
TenantWorkReceiptTransition,
|
|
345
|
+
| 'claim'
|
|
346
|
+
| 'claim_reclaim_running'
|
|
347
|
+
| 'claim_force_refresh'
|
|
348
|
+
| 'claim_force_refresh_reclaim_running'
|
|
349
|
+
> {
|
|
350
|
+
if (input.forceRefresh === true) {
|
|
351
|
+
return input.reclaimRunning === true
|
|
352
|
+
? 'claim_force_refresh_reclaim_running'
|
|
353
|
+
: 'claim_force_refresh';
|
|
354
|
+
}
|
|
355
|
+
return input.reclaimRunning === true ? 'claim_reclaim_running' : 'claim';
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function existingFromStatuses(
|
|
359
|
+
spec: WorkReceiptTransitionSpec,
|
|
360
|
+
): WorkReceiptStateStatus[] {
|
|
361
|
+
return spec.from.filter(
|
|
362
|
+
(status): status is WorkReceiptStateStatus =>
|
|
363
|
+
status !== WORK_RECEIPT_ABSENT,
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
|
|
9
367
|
export type WorkReceiptStateInput = {
|
|
10
368
|
status: WorkReceiptStateStatus;
|
|
11
369
|
runId?: string | null;
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ProductNotificationRepeatMode,
|
|
5
5
|
ProductNotificationTrigger,
|
|
6
6
|
} from './configuration';
|
|
7
|
+
import { INCLUDED_ALLOWANCE_RULE_KEY } from './configuration';
|
|
7
8
|
import { PRODUCT_NOTIFICATION_EVENT_CATALOG } from './contract';
|
|
8
9
|
import {
|
|
9
10
|
ProductNotificationEvent,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
type ProductNotificationEventName,
|
|
14
15
|
} from './events';
|
|
15
16
|
import { legacySlackNotificationType } from './legacy-slack';
|
|
16
|
-
import type { NotificationText } from './content';
|
|
17
|
+
import type { NotificationText, NotificationUsageMeter } from './content';
|
|
17
18
|
import {
|
|
18
19
|
BILLING_PURCHASE_LATE_RULE_KEY,
|
|
19
20
|
BILLING_RENEWAL_LATE_RULE_KEY,
|
|
@@ -83,7 +84,8 @@ export type ProductNotificationPresentation = {
|
|
|
83
84
|
subjectId: string;
|
|
84
85
|
severity?: ProductNotificationSeverity;
|
|
85
86
|
/** Selects an alternate email layout; absent means the standard one. */
|
|
86
|
-
emailFormat?: 'thank_you';
|
|
87
|
+
emailFormat?: 'thank_you' | 'included_allowance';
|
|
88
|
+
usageMeters?: NotificationUsageMeter[];
|
|
87
89
|
playRun?: import('./content').PlayRunEmailContent;
|
|
88
90
|
};
|
|
89
91
|
|
|
@@ -931,6 +933,106 @@ const PRODUCT_NOTIFICATION_TYPE_REGISTRY = [
|
|
|
931
933
|
}),
|
|
932
934
|
},
|
|
933
935
|
},
|
|
936
|
+
{
|
|
937
|
+
id: 'billing.included_usage.exhausted',
|
|
938
|
+
eventName: ProductNotificationEvent.BillingIncludedUsageExhausted,
|
|
939
|
+
requiredFilter: {},
|
|
940
|
+
allowedTriggers: ['each_match'],
|
|
941
|
+
catalog: {
|
|
942
|
+
name: 'Included usage exhausted',
|
|
943
|
+
category: 'credits',
|
|
944
|
+
description:
|
|
945
|
+
'Email workspace owners when included people search, Play compute, or managed storage is used up.',
|
|
946
|
+
allowMultiple: false,
|
|
947
|
+
editor: { kind: 'none' },
|
|
948
|
+
},
|
|
949
|
+
rule: {
|
|
950
|
+
default: {
|
|
951
|
+
ruleKey: INCLUDED_ALLOWANCE_RULE_KEY,
|
|
952
|
+
groupKey: 'default',
|
|
953
|
+
},
|
|
954
|
+
create: (_input, base) => ({
|
|
955
|
+
...base,
|
|
956
|
+
repeatMode: 'every_match',
|
|
957
|
+
trigger: { kind: 'each_match' },
|
|
958
|
+
}),
|
|
959
|
+
present: ({ payload }) => {
|
|
960
|
+
const allowance = String(payload.allowance);
|
|
961
|
+
const storage = allowance === 'Managed storage';
|
|
962
|
+
const compute = allowance === 'Play compute';
|
|
963
|
+
const benefit = storage
|
|
964
|
+
? 'storage'
|
|
965
|
+
: compute
|
|
966
|
+
? allowance
|
|
967
|
+
: allowance.toLowerCase();
|
|
968
|
+
const overage = compute
|
|
969
|
+
? 'additional Play runtime'
|
|
970
|
+
: 'Deepline-native searches';
|
|
971
|
+
const resetDate = new Date(Number(payload.resetsAt)).toLocaleString(
|
|
972
|
+
'en-US',
|
|
973
|
+
{
|
|
974
|
+
month: 'long',
|
|
975
|
+
day: 'numeric',
|
|
976
|
+
year: 'numeric',
|
|
977
|
+
hour: '2-digit',
|
|
978
|
+
minute: '2-digit',
|
|
979
|
+
hourCycle: 'h23',
|
|
980
|
+
timeZone: 'UTC',
|
|
981
|
+
},
|
|
982
|
+
);
|
|
983
|
+
const hasUpgrade =
|
|
984
|
+
typeof payload.nextPlan === 'string' &&
|
|
985
|
+
typeof payload.nextIncluded === 'number' &&
|
|
986
|
+
payload.nextIncluded > 0;
|
|
987
|
+
const unit = compute
|
|
988
|
+
? 'standard-equivalent hours'
|
|
989
|
+
: String(payload.unit);
|
|
990
|
+
const unitsPerDisplayUnit = compute ? 60 : 1;
|
|
991
|
+
const meter = {
|
|
992
|
+
used: Number(payload.used) / unitsPerDisplayUnit,
|
|
993
|
+
included: Number(payload.included) / unitsPerDisplayUnit,
|
|
994
|
+
unit,
|
|
995
|
+
};
|
|
996
|
+
return {
|
|
997
|
+
title: storage
|
|
998
|
+
? 'Your included Deepline storage is used up'
|
|
999
|
+
: `${allowance} allowance used up`,
|
|
1000
|
+
summary: [
|
|
1001
|
+
'Your ',
|
|
1002
|
+
{ workspace: true },
|
|
1003
|
+
storage
|
|
1004
|
+
? ' has used all its included storage, which means you’ll start paying to store your enrichment data and Play outputs in the Deepline database beyond that limit.'
|
|
1005
|
+
: ` has used all its included ${benefit}, which means you’ll start paying for ${overage}.`,
|
|
1006
|
+
],
|
|
1007
|
+
details: [
|
|
1008
|
+
[
|
|
1009
|
+
storage
|
|
1010
|
+
? `Storage is measured daily. Additional storage costs ${payload.overageRate}.`
|
|
1011
|
+
: `Your allowance resets on ${resetDate} (UTC). Additional usage costs ${payload.overageRate}.`,
|
|
1012
|
+
...(compute
|
|
1013
|
+
? [' Larger sandboxes use more compute per hour.']
|
|
1014
|
+
: []),
|
|
1015
|
+
...(hasUpgrade
|
|
1016
|
+
? [
|
|
1017
|
+
` If you’d like more included ${benefit}, `,
|
|
1018
|
+
{
|
|
1019
|
+
link: String(payload.nextPlan),
|
|
1020
|
+
href: 'https://deepline.com/pricing',
|
|
1021
|
+
},
|
|
1022
|
+
` includes ${formatCredits(Number(payload.nextIncluded) / unitsPerDisplayUnit)} ${unit}.`,
|
|
1023
|
+
]
|
|
1024
|
+
: []),
|
|
1025
|
+
],
|
|
1026
|
+
],
|
|
1027
|
+
usageMeters: [{ ...meter, label: `${allowance} · Your plan` }],
|
|
1028
|
+
emailFormat: 'included_allowance',
|
|
1029
|
+
targetUrl: String(payload.targetUrl),
|
|
1030
|
+
subjectKind: 'workspace',
|
|
1031
|
+
subjectId: String(payload.accountId),
|
|
1032
|
+
};
|
|
1033
|
+
},
|
|
1034
|
+
},
|
|
1035
|
+
},
|
|
934
1036
|
{
|
|
935
1037
|
id: 'internal.billing.credit_purchase',
|
|
936
1038
|
eventName: ProductNotificationEvent.CreditsPurchaseCompleted,
|
|
@@ -9,9 +9,12 @@ import type {
|
|
|
9
9
|
ProductNotificationDefaultRule,
|
|
10
10
|
ProductNotificationGroupDraft,
|
|
11
11
|
} from './configuration';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
INCLUDED_ALLOWANCE_RULE_KEY,
|
|
14
|
+
normalizeProductNotificationEmailList,
|
|
15
|
+
productNotificationValuesEqual,
|
|
16
|
+
} from './configuration';
|
|
13
17
|
import { PRODUCT_NOTIFICATION_SHADOW_TYPES } from './catalog';
|
|
14
|
-
import { normalizeProductNotificationEmailList } from './configuration';
|
|
15
18
|
export {
|
|
16
19
|
createProductNotificationRule,
|
|
17
20
|
type ProductNotificationPlayFailureSettings as PlayFailureOptions,
|
|
@@ -322,6 +325,8 @@ export function buildProductNotificationGroupOperations(
|
|
|
322
325
|
for (const rule of savedRules) {
|
|
323
326
|
if (draft.rules.some((candidate) => candidate.ruleKey === rule.ruleKey))
|
|
324
327
|
continue;
|
|
328
|
+
// Older editors omit this rule. Its single-rule toggle sends an explicit setting.
|
|
329
|
+
if (rule.ruleKey === INCLUDED_ALLOWANCE_RULE_KEY) continue;
|
|
325
330
|
if (
|
|
326
331
|
rule.configMode === 'default' ||
|
|
327
332
|
rule.configMode === 'replace_default'
|
|
@@ -4,6 +4,8 @@ export type ProductNotificationFacts = Record<
|
|
|
4
4
|
ProductNotificationFactValue
|
|
5
5
|
>;
|
|
6
6
|
|
|
7
|
+
export const INCLUDED_ALLOWANCE_RULE_KEY = 'default.included_usage_exhausted';
|
|
8
|
+
|
|
7
9
|
const PRODUCT_NOTIFICATION_EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
8
10
|
|
|
9
11
|
/** Normalize an email destination consistently across API, CLI, and delivery. */
|
|
@@ -543,6 +545,8 @@ export function resolveEffectiveProductNotificationConfiguration(input: {
|
|
|
543
545
|
>({
|
|
544
546
|
defaults: input.policy.rules.filter(
|
|
545
547
|
(rule) =>
|
|
548
|
+
// An existing group snapshot predates this newly added default.
|
|
549
|
+
rule.ruleKey === INCLUDED_ALLOWANCE_RULE_KEY ||
|
|
546
550
|
!replacedDefaultGroupKeys.has(rule.groupKey) ||
|
|
547
551
|
ruleOverrides.has(rule.ruleKey),
|
|
548
552
|
),
|
|
@@ -13,6 +13,19 @@ export type NotificationText =
|
|
|
13
13
|
|
|
14
14
|
export type NotificationIcon = 'calendar' | 'book-open';
|
|
15
15
|
|
|
16
|
+
export type NotificationUsageMeter = {
|
|
17
|
+
label: string;
|
|
18
|
+
unit: string;
|
|
19
|
+
used: number;
|
|
20
|
+
included: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function notificationUsageMeterText(meter: NotificationUsageMeter) {
|
|
24
|
+
const format = (amount: number) =>
|
|
25
|
+
amount.toLocaleString('en-US', { maximumFractionDigits: 2 });
|
|
26
|
+
return `${meter.label} · ${format(meter.used)} of ${format(meter.included)} included ${meter.unit}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
16
29
|
export type PlayRunEmailContent = {
|
|
17
30
|
name: string;
|
|
18
31
|
description?: string;
|