@ericminassian/platform-core 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/api.d.ts +1847 -212
  2. package/dist/api.js +694 -1
  3. package/dist/api.js.map +1 -1
  4. package/dist/auth.d.ts +19 -0
  5. package/dist/auth.js +32 -0
  6. package/dist/auth.js.map +1 -1
  7. package/dist/base64url.d.ts +3 -0
  8. package/dist/base64url.js +15 -0
  9. package/dist/base64url.js.map +1 -0
  10. package/dist/bindings.d.ts +69 -13
  11. package/dist/bindings.js +1 -1
  12. package/dist/bindings.js.map +1 -1
  13. package/dist/cloudfront-function.d.ts +5 -1
  14. package/dist/cloudfront-function.js +70 -2
  15. package/dist/cloudfront-function.js.map +1 -1
  16. package/dist/compute.d.ts +52 -0
  17. package/dist/compute.js +65 -0
  18. package/dist/compute.js.map +1 -0
  19. package/dist/config.d.ts +21 -1
  20. package/dist/config.js +16 -0
  21. package/dist/config.js.map +1 -1
  22. package/dist/constants.d.ts +67 -1
  23. package/dist/constants.js +56 -1
  24. package/dist/constants.js.map +1 -1
  25. package/dist/email.d.ts +84 -0
  26. package/dist/email.js +111 -0
  27. package/dist/email.js.map +1 -0
  28. package/dist/fingerprint.d.ts +9 -0
  29. package/dist/fingerprint.js +19 -0
  30. package/dist/fingerprint.js.map +1 -0
  31. package/dist/index.d.ts +6 -0
  32. package/dist/index.js +6 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/jobs.d.ts +111 -0
  35. package/dist/jobs.js +214 -0
  36. package/dist/jobs.js.map +1 -0
  37. package/dist/manifest.d.ts +357 -112
  38. package/dist/manifest.js +270 -72
  39. package/dist/manifest.js.map +1 -1
  40. package/dist/naming.d.ts +93 -6
  41. package/dist/naming.js +98 -6
  42. package/dist/naming.js.map +1 -1
  43. package/dist/platform-api.d.ts +7792 -0
  44. package/dist/platform-api.js +455 -0
  45. package/dist/platform-api.js.map +1 -0
  46. package/dist/realtime.d.ts +139 -0
  47. package/dist/realtime.js +201 -0
  48. package/dist/realtime.js.map +1 -0
  49. package/dist/router/decide.d.ts +7 -1
  50. package/dist/router/decide.js +42 -5
  51. package/dist/router.d.ts +35 -13
  52. package/dist/router.js +36 -0
  53. package/dist/router.js.map +1 -1
  54. package/dist/runtime-config.d.ts +57 -0
  55. package/dist/runtime-config.js +12 -0
  56. package/dist/runtime-config.js.map +1 -1
  57. package/dist/storage.d.ts +55 -0
  58. package/dist/storage.js +112 -0
  59. package/dist/storage.js.map +1 -0
  60. package/dist/telemetry.d.ts +350 -83
  61. package/dist/telemetry.js +188 -15
  62. package/dist/telemetry.js.map +1 -1
  63. package/dist/web-compute.d.ts +191 -0
  64. package/dist/web-compute.js +257 -0
  65. package/dist/web-compute.js.map +1 -0
  66. package/package.json +28 -8
  67. package/src/api.ts +864 -238
  68. package/src/auth.ts +37 -0
  69. package/src/base64url.ts +13 -0
  70. package/src/bindings.ts +74 -7
  71. package/src/cloudfront-function.ts +70 -2
  72. package/src/compute.ts +86 -0
  73. package/src/config.ts +34 -2
  74. package/src/constants.ts +76 -1
  75. package/src/email.ts +168 -0
  76. package/src/fingerprint.ts +20 -0
  77. package/src/index.ts +6 -0
  78. package/src/jobs.ts +281 -0
  79. package/src/manifest.ts +542 -114
  80. package/src/naming.ts +103 -8
  81. package/src/platform-api.ts +630 -0
  82. package/src/realtime.ts +298 -0
  83. package/src/router/decide.d.ts +7 -1
  84. package/src/router/decide.js +42 -5
  85. package/src/router.ts +33 -13
  86. package/src/runtime-config.ts +70 -0
  87. package/src/storage.ts +120 -0
  88. package/src/telemetry.ts +198 -93
  89. package/src/web-compute.ts +342 -0
@@ -0,0 +1,257 @@
1
+ /**
2
+ * How a stage's server runs, and what each way costs. Shared by the manifest
3
+ * schema, the engine, the router, the SDK and the control plane's daily
4
+ * chooser.
5
+ *
6
+ * - `request`: a regular Lambda function (arm64) behind a function URL. Each
7
+ * request is an invocation, billed by the millisecond (a cold start's INIT
8
+ * too) and by the request, from the account's monthly free tier first.
9
+ * Nothing is billed while no request runs.
10
+ * - `instance`: a Lambda Web Function. An environment serves many requests at
11
+ * once and is billed for the memory it uses for as long as it lives (until
12
+ * about five minutes after its last request), plus vCPU while it works.
13
+ *
14
+ * Request mode costs less until a stage is busy about a quarter of the time,
15
+ * so quiet stages run it and the chooser moves a busy prod stage to instance
16
+ * mode (and back) by `simulateWebCompute`.
17
+ */
18
+ import { base64url, fromBase64url } from './base64url.js';
19
+ import { HOURS_PER_MONTH } from './compute.js';
20
+ import { PROD_STAGE } from './constants.js';
21
+ export const WEB_COMPUTE = ['request', 'instance'];
22
+ /** `web.compute` in plat.config.ts. */
23
+ export const WEB_COMPUTE_SETTINGS = ['auto', ...WEB_COMPUTE];
24
+ /**
25
+ * Memory of a request-mode server unless `web.memoryMb` says otherwise, from
26
+ * the template app's server bundle (2.1 MB, measured 2026-11-16). INIT took
27
+ * 460–650 ms at 512, 1024 and 1769 MB alike, but Lambda gives the handler CPU
28
+ * in proportion to memory: the first request after INIT took ~115 ms at
29
+ * 512 MB, ~60 ms at 1024 and ~40 ms at 1769, and warm requests 12–148 ms at
30
+ * 512 against 5–11 ms at the other two. So 1024 MB answers faster than 512 and
31
+ * costs less per warm request (the shorter time more than pays for the
32
+ * doubled rate); 1769 MB only costs more. Each environment used ~140 MB.
33
+ */
34
+ export const WEB_REQUEST_MEMORY_MB = 1024;
35
+ /**
36
+ * Most environments a Web Function endpoint runs at once. Lambda keeps
37
+ * spare, billed environments next to busy ones (CI bursts ran 9–25), so this
38
+ * also caps that headroom. Prod takes `web.maxEnvironments`.
39
+ */
40
+ export const WEB_MAX_ENVIRONMENTS = { preview: 2, prod: 10 };
41
+ /** The first `@ericminassian/platform` whose server bundle also runs as a request-mode handler. */
42
+ export const REQUEST_MODE_MIN_SDK = '0.4.0';
43
+ /** Whether a bundle built with this SDK version can run in request mode. */
44
+ export function supportsRequestMode(sdk) {
45
+ const v = sdk ? /^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(sdk.trim()) : null;
46
+ if (!v)
47
+ return false;
48
+ const min = REQUEST_MODE_MIN_SDK.split('.').map(Number);
49
+ const got = [Number(v[1]), Number(v[2]), Number(v[3])];
50
+ for (let i = 0; i < 3; i++)
51
+ if (got[i] !== min[i])
52
+ return got[i] > min[i];
53
+ // A prerelease of the minimum predates it.
54
+ return v[4] === undefined;
55
+ }
56
+ /**
57
+ * The account Lambda concurrency `auto` needs before it runs request mode.
58
+ * Request-mode servers share the account's concurrency with every worker; a
59
+ * new account's limit is 10, which one burst of browser tests on a preview
60
+ * can exceed, and Lambda answers throttled requests with errors. Web
61
+ * Functions scale on their own quota. AWS keeps 100 unreserved at the usual
62
+ * 1,000.
63
+ */
64
+ export const REQUEST_MODE_MIN_ACCOUNT_CONCURRENCY = 100;
65
+ /** Why `auto` keeps a server off request mode on this account, or undefined when it needn't. */
66
+ export function requestModeBlocked(accountConcurrency) {
67
+ if (accountConcurrency === undefined || accountConcurrency >= REQUEST_MODE_MIN_ACCOUNT_CONCURRENCY)
68
+ return undefined;
69
+ return (`the account's Lambda concurrency limit is ${accountConcurrency}, and request mode needs ` +
70
+ `${REQUEST_MODE_MIN_ACCOUNT_CONCURRENCY} (raise "Concurrent executions" in Service Quotas)`);
71
+ }
72
+ /**
73
+ * The mode a deploy runs the server in. `auto` runs request mode everywhere
74
+ * but prod, where a stage keeps the mode it has (the chooser changes it) and
75
+ * starts in request mode. A bundle built with an SDK older than
76
+ * `REQUEST_MODE_MIN_SDK` only runs as a Web Function, and so does `auto` on an
77
+ * account without the Lambda concurrency request mode needs
78
+ * (`requestModeBlocked`); `note` then says why.
79
+ */
80
+ export function webComputeFor(input) {
81
+ const capable = supportsRequestMode(input.sdk);
82
+ if (input.setting === 'instance')
83
+ return { compute: 'instance' };
84
+ const blocked = requestModeBlocked(input.accountConcurrency);
85
+ if (input.setting === 'request') {
86
+ if (!capable)
87
+ return {
88
+ error: `web.compute is 'request', but this build's @ericminassian/platform is ${input.sdk ?? 'unknown'}: request mode needs ${REQUEST_MODE_MIN_SDK} or later`,
89
+ };
90
+ // Asked for by name: it runs, with the warning.
91
+ return blocked
92
+ ? { compute: 'request', note: `request mode can be throttled: ${blocked}` }
93
+ : { compute: 'request' };
94
+ }
95
+ if (!capable)
96
+ return { compute: 'instance' };
97
+ const wanted = input.stage === PROD_STAGE ? (input.current ?? 'request') : 'request';
98
+ if (wanted === 'request' && blocked)
99
+ return { compute: 'instance', note: `instance mode: ${blocked}` };
100
+ return { compute: wanted };
101
+ }
102
+ /** `maxEnvironments` of a stage's Web Function endpoints. */
103
+ export function webMaxEnvironments(web, stage) {
104
+ return stage === PROD_STAGE
105
+ ? (web.maxEnvironments ?? WEB_MAX_ENVIRONMENTS.prod)
106
+ : WEB_MAX_ENVIRONMENTS.preview;
107
+ }
108
+ // ---------------------------------------------------------------------------
109
+ // The origin secret
110
+ const ORIGIN_SECRET_INFO = 'platform:origin:v1';
111
+ /**
112
+ * What the router sends a stage's request-mode server in `ORIGIN_HEADER`:
113
+ * HKDF of the stage key, so the engine (which writes it into the route) and
114
+ * the SDK (which checks it) agree without storing another secret.
115
+ */
116
+ export async function originSecret(stageKey) {
117
+ const raw = await crypto.subtle.importKey('raw', fromBase64url(stageKey), 'HKDF', false, ['deriveBits']);
118
+ const bits = await crypto.subtle.deriveBits({
119
+ name: 'HKDF',
120
+ hash: 'SHA-256',
121
+ salt: new Uint8Array(0),
122
+ info: new TextEncoder().encode(ORIGIN_SECRET_INFO),
123
+ }, raw, 256);
124
+ return base64url(new Uint8Array(bits));
125
+ }
126
+ // ---------------------------------------------------------------------------
127
+ // Cost
128
+ /**
129
+ * Prices behind the estimates, us-east-1, checked 2026-11-16. Request mode is
130
+ * Lambda on arm64; its INIT is billed like duration. Web Functions bill the
131
+ * memory an environment uses (not what it may use) for its whole life, vCPU
132
+ * per second it works, and requests. Neither estimate subtracts the free
133
+ * tier: the account's workers draw on it too.
134
+ */
135
+ export const WEB_COMPUTE_PRICES_USD = {
136
+ request: { gbSecond: 0.0000133334, perMillionRequests: 0.2 },
137
+ instance: { gbSecond: 0.000003667, vcpuSecond: 0.0000277, perMillionRequests: 0.3 },
138
+ };
139
+ /** How long a Web Function environment lives after its last request (measured: ~290 s). */
140
+ export const INSTANCE_IDLE_SECONDS = 290;
141
+ /**
142
+ * How long Lambda keeps an idle request-mode environment for the next
143
+ * request. Undocumented; observed to be several minutes, so the simulation
144
+ * assumes the short end.
145
+ */
146
+ export const REQUEST_IDLE_MINUTES = 5;
147
+ /** A Web Function environment's memory when CloudWatch has none for the stage (measured: ~250 MB). */
148
+ export const INSTANCE_DEFAULT_MEMORY_MB = 256;
149
+ /**
150
+ * A cold start's INIT when the stage reported none (`env` lines' `initMs`,
151
+ * which came within ~30 ms of Lambda's own figure). Measured: 460–650 ms for
152
+ * the template app's server.
153
+ */
154
+ export const DEFAULT_INIT_MS = 550;
155
+ const MINUTE = 60_000;
156
+ /** Environment lifetimes are tracked in slots of this many seconds. */
157
+ const SLOT_SECONDS = 10;
158
+ /**
159
+ * Both modes' monthly cost for the traffic in `minutes`, extrapolated from
160
+ * `from`..`to`. Minute data only has averages, so a minute's concurrency is
161
+ * its handling time over 60 s:
162
+ *
163
+ * - request: handling time × memory, cold starts × INIT × memory, requests.
164
+ * A minute needs as many environments as its concurrency (at least one);
165
+ * environments idle longer than `REQUEST_IDLE_MINUTES` are gone.
166
+ * - instance: environments alive from each busy minute until
167
+ * `INSTANCE_IDLE_SECONDS` after it, as many as its concurrency over
168
+ * `maxConcurrencyPerEnvironment` (at least one), × memory; vCPU for the
169
+ * time an environment has a request in flight; requests.
170
+ *
171
+ * Overlapping requests are what instance mode bills once and request mode
172
+ * bills each, so a stage busy enough to keep requests overlapping is the one
173
+ * that moves to instance mode.
174
+ */
175
+ export function simulateWebCompute(input) {
176
+ const span = Math.max(input.to - input.from, MINUTE);
177
+ const perMonth = (HOURS_PER_MONTH * 3_600_000) / span;
178
+ const minutes = input.minutes
179
+ .filter((m) => m.req > 0 && m.ts >= input.from && m.ts < input.to)
180
+ .toSorted((a, b) => a.ts - b.ts);
181
+ const prices = WEB_COMPUTE_PRICES_USD;
182
+ let requests = 0;
183
+ let durationSeconds = 0;
184
+ let coldStarts = 0;
185
+ let warm = 0;
186
+ let lastBusy = Number.NEGATIVE_INFINITY;
187
+ let vcpuSeconds = 0;
188
+ const alive = new Map();
189
+ const lifeSlots = Math.ceil((60 + INSTANCE_IDLE_SECONDS) / SLOT_SECONDS);
190
+ for (const m of minutes) {
191
+ requests += m.req;
192
+ durationSeconds += m.durMs / 1000;
193
+ const concurrency = m.durMs / MINUTE;
194
+ if (m.ts - lastBusy > REQUEST_IDLE_MINUTES * MINUTE)
195
+ warm = 0;
196
+ const needed = Math.max(1, Math.ceil(concurrency));
197
+ if (needed > warm) {
198
+ coldStarts += needed - warm;
199
+ warm = needed;
200
+ }
201
+ lastBusy = m.ts;
202
+ const environments = Math.max(1, Math.ceil(concurrency / input.maxConcurrencyPerEnvironment));
203
+ const first = Math.floor(m.ts / 1000 / SLOT_SECONDS);
204
+ for (let s = first; s < first + lifeSlots; s++)
205
+ alive.set(s, Math.max(alive.get(s) ?? 0, environments));
206
+ // vCPU bills the seconds an environment has a request in flight, once however many overlap.
207
+ // With requests arriving at random, that share of the minute is 1 - e^(-concurrency).
208
+ vcpuSeconds += 60 * environments * (1 - Math.exp(-concurrency / environments));
209
+ }
210
+ const requestGb = input.requestMemoryMb / 1024;
211
+ const requestUsd = (durationSeconds + (coldStarts * input.initMs) / 1000) * requestGb * prices.request.gbSecond +
212
+ (requests * prices.request.perMillionRequests) / 1e6;
213
+ let environmentSeconds = 0;
214
+ for (const n of alive.values())
215
+ environmentSeconds += n * SLOT_SECONDS;
216
+ const instanceUsd = environmentSeconds * (input.instanceMemoryMb / 1024) * prices.instance.gbSecond +
217
+ vcpuSeconds * prices.instance.vcpuSecond +
218
+ (requests * prices.instance.perMillionRequests) / 1e6;
219
+ return {
220
+ request: {
221
+ monthlyUsd: round4(requestUsd * perMonth),
222
+ coldStartsPerMonth: Math.round(coldStarts * perMonth),
223
+ },
224
+ instance: {
225
+ monthlyUsd: round4(instanceUsd * perMonth),
226
+ environmentHoursPerMonth: Math.round(((environmentSeconds * perMonth) / 3600) * 10) / 10,
227
+ },
228
+ requestsPerMonth: Math.round(requests * perMonth),
229
+ days: Math.round((span / 86_400_000) * 100) / 100,
230
+ };
231
+ }
232
+ // ---------------------------------------------------------------------------
233
+ // Switching
234
+ /** The other mode must cost this much less (a share of the current one's cost), this many days running. */
235
+ export const COMPUTE_SWITCH_RULE = { cheaperBy: 0.25, days: 3 };
236
+ /**
237
+ * Today's step of the switching rule: the streak to keep, and the mode to
238
+ * switch to once the other mode has been `COMPUTE_SWITCH_RULE.cheaperBy`
239
+ * cheaper `COMPUTE_SWITCH_RULE.days` days running. A second run on the same
240
+ * day changes nothing; a day the other mode wasn't cheaper enough, or a day
241
+ * without a run, starts the count over.
242
+ */
243
+ export function nextComputeStreak(input) {
244
+ const other = input.current === 'request' ? 'instance' : 'request';
245
+ const current = input.estimate[input.current].monthlyUsd;
246
+ const cheaper = input.estimate[other].monthlyUsd <= current * (1 - COMPUTE_SWITCH_RULE.cheaperBy);
247
+ if (!cheaper || current <= 0)
248
+ return {};
249
+ const prev = input.streak?.to === other ? input.streak : undefined;
250
+ const days = prev?.day === input.day ? prev.days : prev?.day === previousDay(input.day) ? prev.days + 1 : 1;
251
+ if (days >= COMPUTE_SWITCH_RULE.days)
252
+ return { switchTo: other };
253
+ return { streak: { to: other, days, day: input.day } };
254
+ }
255
+ const previousDay = (day) => new Date(Date.parse(`${day}T00:00:00Z`) - 86_400_000).toISOString().slice(0, 10);
256
+ const round4 = (n) => Math.round(n * 10_000) / 10_000;
257
+ //# sourceMappingURL=web-compute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-compute.js","sourceRoot":"","sources":["../src/web-compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO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,IAAI,EAAE,GAAG,KAAK,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5G,IAAI,IAAI,IAAI,mBAAmB,CAAC,IAAI;QAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACjE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAClC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAEnF,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,34 +1,54 @@
1
1
  {
2
2
  "name": "@ericminassian/platform-core",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shared contracts for the platform: naming, manifest schema, bindings, telemetry, routing.",
5
- "type": "module",
6
5
  "license": "MIT",
7
6
  "repository": {
8
7
  "type": "git",
9
8
  "url": "git+https://github.com/eric-minassian/platform.git",
10
9
  "directory": "packages/core"
11
10
  },
11
+ "files": [
12
+ "dist",
13
+ "src"
14
+ ],
15
+ "type": "module",
12
16
  "exports": {
13
17
  ".": {
14
18
  "types": "./dist/index.d.ts",
15
19
  "default": "./dist/index.js"
16
20
  },
21
+ "./auth": {
22
+ "types": "./dist/auth.d.ts",
23
+ "default": "./dist/auth.js"
24
+ },
17
25
  "./cloudfront-function": {
18
26
  "types": "./dist/cloudfront-function.d.ts",
19
27
  "default": "./dist/cloudfront-function.js"
20
28
  },
21
- "./router/decide.js": "./dist/router/decide.js"
29
+ "./naming": {
30
+ "types": "./dist/naming.d.ts",
31
+ "default": "./dist/naming.js"
32
+ },
33
+ "./platform-api": {
34
+ "types": "./dist/platform-api.d.ts",
35
+ "default": "./dist/platform-api.js"
36
+ },
37
+ "./realtime": {
38
+ "types": "./dist/realtime.d.ts",
39
+ "default": "./dist/realtime.js"
40
+ },
41
+ "./router/decide.js": "./dist/router/decide.js",
42
+ "./storage": {
43
+ "types": "./dist/storage.d.ts",
44
+ "default": "./dist/storage.js"
45
+ }
22
46
  },
23
47
  "publishConfig": {
24
48
  "access": "public"
25
49
  },
26
- "files": [
27
- "dist",
28
- "src"
29
- ],
30
50
  "dependencies": {
31
- "zod": "^4.6.7"
51
+ "effect": "^4.1.4"
32
52
  },
33
53
  "scripts": {
34
54
  "build": "tsc -p tsconfig.build.json && mkdir -p dist/router && cp src/router/decide.js src/router/decide.d.ts dist/router/",