@ericminassian/platform-core 0.3.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.
- package/dist/api.d.ts +942 -45
- package/dist/api.js +372 -13
- package/dist/api.js.map +1 -1
- package/dist/auth.js +5 -2
- package/dist/auth.js.map +1 -1
- package/dist/base64url.d.ts +3 -0
- package/dist/base64url.js +15 -0
- package/dist/base64url.js.map +1 -0
- package/dist/bindings.d.ts +62 -12
- package/dist/bindings.js +1 -1
- package/dist/bindings.js.map +1 -1
- package/dist/cloudfront-function.d.ts +5 -1
- package/dist/cloudfront-function.js +64 -2
- package/dist/cloudfront-function.js.map +1 -1
- package/dist/compute.d.ts +52 -0
- package/dist/compute.js +65 -0
- package/dist/compute.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +9 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +56 -1
- package/dist/constants.js +56 -1
- package/dist/constants.js.map +1 -1
- package/dist/email.d.ts +84 -0
- package/dist/email.js +111 -0
- package/dist/email.js.map +1 -0
- package/dist/fingerprint.d.ts +9 -0
- package/dist/fingerprint.js +19 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +111 -0
- package/dist/jobs.js +214 -0
- package/dist/jobs.js.map +1 -0
- package/dist/manifest.d.ts +270 -29
- package/dist/manifest.js +190 -22
- package/dist/manifest.js.map +1 -1
- package/dist/naming.d.ts +83 -7
- package/dist/naming.js +89 -8
- package/dist/naming.js.map +1 -1
- package/dist/platform-api.d.ts +3733 -1278
- package/dist/platform-api.js +120 -8
- package/dist/platform-api.js.map +1 -1
- package/dist/realtime.d.ts +139 -0
- package/dist/realtime.js +201 -0
- package/dist/realtime.js.map +1 -0
- package/dist/router/decide.d.ts +2 -0
- package/dist/router/decide.js +38 -6
- package/dist/router.d.ts +35 -13
- package/dist/router.js +36 -0
- package/dist/router.js.map +1 -1
- package/dist/runtime-config.d.ts +57 -0
- package/dist/runtime-config.js +12 -0
- package/dist/runtime-config.js.map +1 -1
- package/dist/storage.d.ts +55 -0
- package/dist/storage.js +112 -0
- package/dist/storage.js.map +1 -0
- package/dist/telemetry.d.ts +124 -19
- package/dist/telemetry.js +97 -21
- package/dist/telemetry.js.map +1 -1
- package/dist/web-compute.d.ts +191 -0
- package/dist/web-compute.js +257 -0
- package/dist/web-compute.js.map +1 -0
- package/package.json +19 -7
- package/src/api.ts +445 -15
- package/src/auth.ts +6 -2
- package/src/base64url.ts +13 -0
- package/src/bindings.ts +67 -6
- package/src/cloudfront-function.ts +64 -2
- package/src/compute.ts +86 -0
- package/src/config.ts +31 -1
- package/src/constants.ts +64 -1
- package/src/email.ts +168 -0
- package/src/fingerprint.ts +20 -0
- package/src/index.ts +6 -0
- package/src/jobs.ts +281 -0
- package/src/manifest.ts +415 -45
- package/src/naming.ts +93 -9
- package/src/platform-api.ts +134 -8
- package/src/realtime.ts +298 -0
- package/src/router/decide.d.ts +2 -0
- package/src/router/decide.js +38 -6
- package/src/router.ts +33 -13
- package/src/runtime-config.ts +70 -0
- package/src/storage.ts +120 -0
- package/src/telemetry.ts +104 -21
- package/src/web-compute.ts +342 -0
package/dist/bindings.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const BINDINGS_ENV = "PLATFORM_BINDINGS";
|
|
8
8
|
export interface Bindings {
|
|
9
|
-
|
|
9
|
+
/** 2 since jobs were pushed (SDK 0.4.0): `queues` gave way to `jobs`. */
|
|
10
|
+
v: 2;
|
|
10
11
|
app: string;
|
|
11
12
|
stage: string;
|
|
12
13
|
/** Public hostname, e.g. `foo.ericminassian.com` or `foo.localhost:3000`. */
|
|
@@ -16,29 +17,26 @@ export interface Bindings {
|
|
|
16
17
|
/** Deployment id currently running. */
|
|
17
18
|
revision: string;
|
|
18
19
|
region: string;
|
|
20
|
+
/** Account id, so the SDK can build ARNs from the names below. */
|
|
21
|
+
account: string;
|
|
19
22
|
/** DynamoDB table backing `db` (present when `db: true`). */
|
|
20
23
|
table?: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
arn: string;
|
|
24
|
-
}>;
|
|
24
|
+
/** Queues, events and crons (present when the stage has a worker). */
|
|
25
|
+
jobs?: JobBindings;
|
|
25
26
|
bus?: {
|
|
26
27
|
name: string;
|
|
27
28
|
arn: string;
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
-
storage?: {
|
|
31
|
-
bucket: string;
|
|
32
|
-
prefix: string;
|
|
33
|
-
stores: readonly string[];
|
|
34
|
-
};
|
|
30
|
+
storage?: StorageBindings;
|
|
35
31
|
secrets: {
|
|
36
32
|
path: string;
|
|
37
33
|
sharedPath: string;
|
|
38
34
|
names: readonly string[];
|
|
39
35
|
};
|
|
40
36
|
auth?: AuthBindings;
|
|
41
|
-
|
|
37
|
+
realtime?: RealtimeBindings;
|
|
38
|
+
email?: EmailBindings;
|
|
39
|
+
/** Worker function name: direct `invoke` jobs, and every handler not in `jobs.fns`. */
|
|
42
40
|
worker?: string;
|
|
43
41
|
/**
|
|
44
42
|
* The stage's secret (32 random bytes, base64url), kept in SSM at
|
|
@@ -47,6 +45,25 @@ export interface Bindings {
|
|
|
47
45
|
*/
|
|
48
46
|
stageKey?: string;
|
|
49
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Where jobs go and how often they're tried. Handlers are keyed `kind:name`
|
|
50
|
+
* (`handlerKey`); only what differs from the default is listed, since Lambda
|
|
51
|
+
* caps a function's environment at 4 KB.
|
|
52
|
+
*/
|
|
53
|
+
export interface JobBindings {
|
|
54
|
+
/** Declared queues. */
|
|
55
|
+
queues: readonly string[];
|
|
56
|
+
/** Handlers that run in a function of their own, by key: its name. The rest run on `worker`. */
|
|
57
|
+
fns: Record<string, string>;
|
|
58
|
+
/** Handlers whose attempts aren't their kind's `DEFAULT_ATTEMPTS`, by key. */
|
|
59
|
+
attempts: Record<string, number>;
|
|
60
|
+
/** The stage's dead-letter queue's URL (`names.deadLetters`). */
|
|
61
|
+
dead: string;
|
|
62
|
+
/** The stage's schedule group, where retries and delayed sends are one-shot schedules. */
|
|
63
|
+
group: string;
|
|
64
|
+
/** The role Scheduler invokes them as: the stage's own. */
|
|
65
|
+
role: string;
|
|
66
|
+
}
|
|
50
67
|
export interface AuthBindings {
|
|
51
68
|
/** `cognito` in AWS; `local` under `plat dev` (local sign-in page, emulator Cognito). */
|
|
52
69
|
mode: 'cognito' | 'local';
|
|
@@ -60,5 +77,38 @@ export interface AuthBindings {
|
|
|
60
77
|
loginUrl: string;
|
|
61
78
|
required: boolean;
|
|
62
79
|
}
|
|
80
|
+
/** The shared storage bucket: a private store is `prefix + <name>/`, a public one `publicPrefix + <name>/`. */
|
|
81
|
+
export interface StorageBindings {
|
|
82
|
+
bucket: string;
|
|
83
|
+
prefix: string;
|
|
84
|
+
/** Every store's name. */
|
|
85
|
+
stores: readonly string[];
|
|
86
|
+
/** The stores the edge serves at `STORAGE_PATH` (absent on stages deployed before there were any). */
|
|
87
|
+
public?: readonly string[];
|
|
88
|
+
publicPrefix?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface RealtimeBindings {
|
|
91
|
+
/** The stage's channel namespace. */
|
|
92
|
+
namespace: string;
|
|
93
|
+
/** AppSync's HTTP publish endpoint (`https://<domain>/event`; `http://127.0.0.1:<port>/event` locally). */
|
|
94
|
+
publishUrl: string;
|
|
95
|
+
subscribe: 'public' | 'signed-in';
|
|
96
|
+
/** Declared channel patterns (`board`, `boards/*`): the SDK publishes only to these. */
|
|
97
|
+
channels: readonly string[];
|
|
98
|
+
}
|
|
99
|
+
export interface EmailBindings {
|
|
100
|
+
/** `ses` when deployed; `local` under `plat dev` / `plat test`, where the CLI captures mail and nothing is sent. */
|
|
101
|
+
mode: 'ses' | 'local';
|
|
102
|
+
/** The stage's address, e.g. `todo@mail.platform.ericminassian.com`. */
|
|
103
|
+
from: string;
|
|
104
|
+
/** Display name (`email.name`). */
|
|
105
|
+
name?: string;
|
|
106
|
+
/** SES tenant and configuration set (both `names.emailTenant`). */
|
|
107
|
+
tenant: string;
|
|
108
|
+
/** Recipients per UTC day. */
|
|
109
|
+
dailyLimit: number;
|
|
110
|
+
/** Table holding the stage's usage rows (the platform's telemetry table; `telemetryKeys.email`). */
|
|
111
|
+
usageTable: string;
|
|
112
|
+
}
|
|
63
113
|
export declare function encodeBindings(b: Bindings): string;
|
|
64
114
|
export declare function decodeBindings(raw: string | undefined): Bindings;
|
package/dist/bindings.js
CHANGED
|
@@ -13,7 +13,7 @@ export function decodeBindings(raw) {
|
|
|
13
13
|
throw new Error(`${BINDINGS_ENV} is not set. This code must run on the platform (deployed, or under \`plat dev\` / \`plat test\`).`);
|
|
14
14
|
}
|
|
15
15
|
const b = JSON.parse(raw);
|
|
16
|
-
if (b.v !==
|
|
16
|
+
if (b.v !== 2)
|
|
17
17
|
throw new Error(`Unsupported ${BINDINGS_ENV} version ${String(b.v)}`);
|
|
18
18
|
return b;
|
|
19
19
|
}
|
package/dist/bindings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AA0GhD,MAAM,UAAU,cAAc,CAAC,CAAW;IACxC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAuB;IACpD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,GAAG,YAAY,oGAAoG,CACpH,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAa,CAAC;IACtC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,eAAe,YAAY,YAAY,MAAM,CAAE,CAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1G,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* Builds the CloudFront Function (JavaScript runtime 2.0) that routes every
|
|
3
3
|
* request on `*.<domain>`: look up the host in the KeyValueStore, then either
|
|
4
4
|
* rewrite the URI into the sites bucket (the distribution's default S3 origin)
|
|
5
|
-
* or switch the origin to the stage's Lambda Web Function with OAC
|
|
5
|
+
* or switch the origin to the stage's server: a Lambda Web Function with OAC
|
|
6
|
+
* signing, or a request-mode function URL with the stage's origin secret.
|
|
7
|
+
* `REALTIME_PATH` is answered here (the browser's config) or passed to the
|
|
8
|
+
* AppSync realtime endpoint (a WebSocket). The `STORAGE_PATH` behavior runs
|
|
9
|
+
* it too: a public store's file is rewritten into that behavior's origin.
|
|
6
10
|
*/
|
|
7
11
|
export declare function buildRouterFunctionCode(opts: {
|
|
8
12
|
kvsId: string;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { HOST_HEADER } from './constants.js';
|
|
2
|
+
import { HOST_HEADER, ORIGIN_HEADER } from './constants.js';
|
|
3
|
+
import { APPSYNC_REALTIME_PATH, REALTIME_KVS_KEY } from './realtime.js';
|
|
4
|
+
import { PUBLIC_STORAGE_ROOT, STORAGE_CACHE_HOST, STORAGE_PATH } from './storage.js';
|
|
3
5
|
/**
|
|
4
6
|
* Builds the CloudFront Function (JavaScript runtime 2.0) that routes every
|
|
5
7
|
* request on `*.<domain>`: look up the host in the KeyValueStore, then either
|
|
6
8
|
* rewrite the URI into the sites bucket (the distribution's default S3 origin)
|
|
7
|
-
* or switch the origin to the stage's Lambda Web Function with OAC
|
|
9
|
+
* or switch the origin to the stage's server: a Lambda Web Function with OAC
|
|
10
|
+
* signing, or a request-mode function URL with the stage's origin secret.
|
|
11
|
+
* `REALTIME_PATH` is answered here (the browser's config) or passed to the
|
|
12
|
+
* AppSync realtime endpoint (a WebSocket). The `STORAGE_PATH` behavior runs
|
|
13
|
+
* it too: a public store's file is rewritten into that behavior's origin.
|
|
8
14
|
*/
|
|
9
15
|
export function buildRouterFunctionCode(opts) {
|
|
10
16
|
const decideSrc = readFileSync(new URL('./router/decide.js', import.meta.url), 'utf8')
|
|
@@ -22,6 +28,36 @@ function health(rec) {
|
|
|
22
28
|
return { statusCode: 200, statusDescription: 'OK', headers: { 'content-type': { value: 'application/json' }, 'cache-control': { value: 'no-store' } }, body: body };
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
function json(body) {
|
|
32
|
+
return { statusCode: 200, statusDescription: 'OK', headers: { 'content-type': { value: 'application/json' }, 'cache-control': { value: 'no-store' } }, body: JSON.stringify(body) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function realtime(req, rec) {
|
|
36
|
+
var raw;
|
|
37
|
+
try { raw = await kvs.get(${JSON.stringify(REALTIME_KVS_KEY)}); } catch (e) { return notFound(); }
|
|
38
|
+
var rt;
|
|
39
|
+
try { rt = JSON.parse(raw); } catch (e) { return notFound(); }
|
|
40
|
+
// CloudFront drops Upgrade and Connection before functions run; a WebSocket
|
|
41
|
+
// handshake still carries Sec-WebSocket-Key.
|
|
42
|
+
if (req.headers['sec-websocket-key']) {
|
|
43
|
+
req.uri = ${JSON.stringify(APPSYNC_REALTIME_PATH)};
|
|
44
|
+
req.querystring = {};
|
|
45
|
+
req.cookies = {};
|
|
46
|
+
delete req.headers['authorization'];
|
|
47
|
+
// AppSync authenticates the subprotocol header, not a signature: no OAC.
|
|
48
|
+
cf.updateRequestOrigin({
|
|
49
|
+
domainName: rt.o,
|
|
50
|
+
originAccessControlConfig: { enabled: false },
|
|
51
|
+
customOriginConfig: { port: 443, protocol: 'https', sslProtocols: ['TLSv1.2'] },
|
|
52
|
+
timeouts: { readTimeout: ${readTimeout} }
|
|
53
|
+
});
|
|
54
|
+
return req;
|
|
55
|
+
}
|
|
56
|
+
var cfg = { v: 1, host: rt.h, namespace: rec.rt.n, subscribe: rec.rt.m === 's' ? 'signed-in' : 'public' };
|
|
57
|
+
if (rec.rt.m !== 's') cfg.apiKey = rt.k;
|
|
58
|
+
return json(cfg);
|
|
59
|
+
}
|
|
60
|
+
|
|
25
61
|
function notFound() {
|
|
26
62
|
return { statusCode: 404, statusDescription: 'Not Found', headers: { 'content-type': { value: 'text/plain' }, 'cache-control': { value: 'no-store' } }, body: 'Nothing is deployed here.' };
|
|
27
63
|
}
|
|
@@ -37,6 +73,7 @@ async function handler(event) {
|
|
|
37
73
|
var d = decide(rec, req.uri);
|
|
38
74
|
if (d.t === 'notfound') return notFound();
|
|
39
75
|
if (d.t === 'health') return health(rec);
|
|
76
|
+
if (d.t === 'realtime') return await realtime(req, rec);
|
|
40
77
|
req.headers[${JSON.stringify(HOST_HEADER)}] = { value: host };
|
|
41
78
|
if (d.t === 'static') {
|
|
42
79
|
req.uri = d.key;
|
|
@@ -44,6 +81,31 @@ async function handler(event) {
|
|
|
44
81
|
delete req.headers['authorization'];
|
|
45
82
|
return req;
|
|
46
83
|
}
|
|
84
|
+
// Only on the ${STORAGE_PATH}* behavior, whose origin is the storage bucket under ${PUBLIC_STORAGE_ROOT}.
|
|
85
|
+
// Its own cache key (STORAGE_CACHE_HOST in core). No query string: the OAC-signed request would
|
|
86
|
+
// pass S3's response-* overrides through.
|
|
87
|
+
if (d.t === 'storage') {
|
|
88
|
+
req.headers[${JSON.stringify(HOST_HEADER)}] = { value: ${JSON.stringify(STORAGE_CACHE_HOST)} };
|
|
89
|
+
req.uri = d.key;
|
|
90
|
+
req.querystring = {};
|
|
91
|
+
req.cookies = {};
|
|
92
|
+
delete req.headers['authorization'];
|
|
93
|
+
return req;
|
|
94
|
+
}
|
|
95
|
+
// A viewer's copy of the origin header never reaches a server.
|
|
96
|
+
delete req.headers[${JSON.stringify(ORIGIN_HEADER)}];
|
|
97
|
+
if (rec.c === 'r') {
|
|
98
|
+
// Request mode: a function URL, which anyone may call, so the server only answers requests
|
|
99
|
+
// carrying the stage's secret. OAC would make clients hash POST bodies (x-amz-content-sha256).
|
|
100
|
+
cf.updateRequestOrigin({
|
|
101
|
+
domainName: rec.o,
|
|
102
|
+
originAccessControlConfig: { enabled: false },
|
|
103
|
+
customOriginConfig: { port: 443, protocol: 'https', sslProtocols: ['TLSv1.2'] },
|
|
104
|
+
customHeaders: { ${JSON.stringify(ORIGIN_HEADER)}: rec.k },
|
|
105
|
+
timeouts: { readTimeout: ${readTimeout} }
|
|
106
|
+
});
|
|
107
|
+
return req;
|
|
108
|
+
}
|
|
47
109
|
cf.updateRequestOrigin({
|
|
48
110
|
domainName: rec.o,
|
|
49
111
|
originAccessControlConfig: { enabled: true, signingBehavior: 'always-amz-auth', signingProtocol: 'sigv4', originType: 'lambda' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudfront-function.js","sourceRoot":"","sources":["../src/cloudfront-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"cloudfront-function.js","sourceRoot":"","sources":["../src/cloudfront-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAErF;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAA0D;IAChG,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;SACnF,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;SACzB,OAAO,CAAC,0BAA0B,EAAE,iBAAiB,CAAC;SACtD,IAAI,EAAE,CAAC;IACV,MAAM,WAAW,GAAG,IAAI,CAAC,wBAAwB,IAAI,EAAE,CAAC;IACxD,OAAO;qBACY,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;;EAE7C,SAAS;;;;;;;;;;;;;8BAamB,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;;;;;;gBAM9C,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC;;;;;;;;;iCASpB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;gBAyB5B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;;;;;;;mBAOxB,YAAY,wDAAwD,mBAAmB;;;;kBAIxF,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;;;;;;;;uBAQxE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;;;;;;;;yBAQ3B,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;iCACrB,WAAW;;;;;;;;+BAQb,WAAW;;;;CAIzC,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container compute (ECS on Fargate): the sizes a container may have and
|
|
3
|
+
* what one costs while it runs. Shared by the manifest schema, the engine,
|
|
4
|
+
* the console's cost page and `plat deploy`.
|
|
5
|
+
*/
|
|
6
|
+
/** vCPUs a Fargate task may have (the platform caps it at 4). */
|
|
7
|
+
export declare const FARGATE_CPUS: readonly [0.25, 0.5, 1, 2, 4];
|
|
8
|
+
export type FargateCpu = (typeof FARGATE_CPUS)[number];
|
|
9
|
+
/** Memory (MB) Fargate allows for each vCPU size. */
|
|
10
|
+
export declare function fargateMemoryOptions(cpu: FargateCpu): number[];
|
|
11
|
+
/** Why `cpu`/`memoryMb` isn't a size Fargate runs, or null when it is. */
|
|
12
|
+
export declare function fargateSizeIssue(cpu: number, memoryMb: number): string | null;
|
|
13
|
+
/** ECS task-definition units: 1024 per vCPU. */
|
|
14
|
+
export declare function fargateCpuUnits(cpu: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Prices behind the estimates: us-east-1, Linux on ARM (Graviton), checked
|
|
17
|
+
* 2026-11-15. Spot prices move with supply and demand, so Spot estimates are
|
|
18
|
+
* approximate. Every task gets a public IPv4 address (there is no NAT), which
|
|
19
|
+
* AWS bills by the hour whatever the capacity.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CONTAINER_PRICES_USD: {
|
|
22
|
+
readonly onDemand: {
|
|
23
|
+
readonly vcpuHour: 0.03238;
|
|
24
|
+
readonly gbHour: 0.00356;
|
|
25
|
+
};
|
|
26
|
+
readonly spot: {
|
|
27
|
+
readonly vcpuHour: 0.00995;
|
|
28
|
+
readonly gbHour: 0.00109;
|
|
29
|
+
};
|
|
30
|
+
readonly publicIpv4Hour: 0.005;
|
|
31
|
+
};
|
|
32
|
+
/** Hours AWS bills a month of always-on capacity for. */
|
|
33
|
+
export declare const HOURS_PER_MONTH = 730;
|
|
34
|
+
export interface ContainerCostEstimate {
|
|
35
|
+
/** vCPU and memory, per month. */
|
|
36
|
+
computeUsd: number;
|
|
37
|
+
/** The task's public IPv4 address, per month. */
|
|
38
|
+
publicIpv4Usd: number;
|
|
39
|
+
totalUsd: number;
|
|
40
|
+
}
|
|
41
|
+
/** What one container of this size costs a month if it runs all the time. */
|
|
42
|
+
export declare function estimateContainerCost(size: {
|
|
43
|
+
cpu: number;
|
|
44
|
+
memoryMb: number;
|
|
45
|
+
spot: boolean;
|
|
46
|
+
}): ContainerCostEstimate;
|
|
47
|
+
/** `0.25 vCPU · 512 MB · Spot`. */
|
|
48
|
+
export declare function describeContainerSize(size: {
|
|
49
|
+
cpu: number;
|
|
50
|
+
memoryMb: number;
|
|
51
|
+
spot: boolean;
|
|
52
|
+
}): string;
|
package/dist/compute.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container compute (ECS on Fargate): the sizes a container may have and
|
|
3
|
+
* what one costs while it runs. Shared by the manifest schema, the engine,
|
|
4
|
+
* the console's cost page and `plat deploy`.
|
|
5
|
+
*/
|
|
6
|
+
/** vCPUs a Fargate task may have (the platform caps it at 4). */
|
|
7
|
+
export const FARGATE_CPUS = [0.25, 0.5, 1, 2, 4];
|
|
8
|
+
/** Memory (MB) Fargate allows for each vCPU size. */
|
|
9
|
+
export function fargateMemoryOptions(cpu) {
|
|
10
|
+
if (cpu === 0.25)
|
|
11
|
+
return [512, 1024, 2048];
|
|
12
|
+
const [from, to] = MEMORY_RANGES[cpu];
|
|
13
|
+
return Array.from({ length: (to - from) / 1024 + 1 }, (_, i) => from + i * 1024);
|
|
14
|
+
}
|
|
15
|
+
/** Above 0.25 vCPU, memory goes from..to in steps of 1024 MB. */
|
|
16
|
+
const MEMORY_RANGES = {
|
|
17
|
+
0.5: [1024, 4096],
|
|
18
|
+
1: [2048, 8192],
|
|
19
|
+
2: [4096, 16384],
|
|
20
|
+
4: [8192, 30720],
|
|
21
|
+
};
|
|
22
|
+
/** Why `cpu`/`memoryMb` isn't a size Fargate runs, or null when it is. */
|
|
23
|
+
export function fargateSizeIssue(cpu, memoryMb) {
|
|
24
|
+
if (!FARGATE_CPUS.includes(cpu)) {
|
|
25
|
+
return `cpu must be one of ${FARGATE_CPUS.join(', ')}`;
|
|
26
|
+
}
|
|
27
|
+
const options = fargateMemoryOptions(cpu);
|
|
28
|
+
if (options.includes(memoryMb))
|
|
29
|
+
return null;
|
|
30
|
+
const allowed = cpu === 0.25 ? options.join(', ') : `${options[0]}-${options[options.length - 1]} in steps of 1024`;
|
|
31
|
+
return `memoryMb ${memoryMb} doesn't fit ${cpu} vCPU: use ${allowed}`;
|
|
32
|
+
}
|
|
33
|
+
/** ECS task-definition units: 1024 per vCPU. */
|
|
34
|
+
export function fargateCpuUnits(cpu) {
|
|
35
|
+
return Math.round(cpu * 1024);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Prices behind the estimates: us-east-1, Linux on ARM (Graviton), checked
|
|
39
|
+
* 2026-11-15. Spot prices move with supply and demand, so Spot estimates are
|
|
40
|
+
* approximate. Every task gets a public IPv4 address (there is no NAT), which
|
|
41
|
+
* AWS bills by the hour whatever the capacity.
|
|
42
|
+
*/
|
|
43
|
+
export const CONTAINER_PRICES_USD = {
|
|
44
|
+
onDemand: { vcpuHour: 0.03238, gbHour: 0.00356 },
|
|
45
|
+
spot: { vcpuHour: 0.00995, gbHour: 0.00109 },
|
|
46
|
+
publicIpv4Hour: 0.005,
|
|
47
|
+
};
|
|
48
|
+
/** Hours AWS bills a month of always-on capacity for. */
|
|
49
|
+
export const HOURS_PER_MONTH = 730;
|
|
50
|
+
/** What one container of this size costs a month if it runs all the time. */
|
|
51
|
+
export function estimateContainerCost(size) {
|
|
52
|
+
const price = size.spot ? CONTAINER_PRICES_USD.spot : CONTAINER_PRICES_USD.onDemand;
|
|
53
|
+
const hourly = size.cpu * price.vcpuHour + (size.memoryMb / 1024) * price.gbHour;
|
|
54
|
+
const computeUsd = round2(hourly * HOURS_PER_MONTH);
|
|
55
|
+
const publicIpv4Usd = round2(CONTAINER_PRICES_USD.publicIpv4Hour * HOURS_PER_MONTH);
|
|
56
|
+
return { computeUsd, publicIpv4Usd, totalUsd: round2(computeUsd + publicIpv4Usd) };
|
|
57
|
+
}
|
|
58
|
+
/** `0.25 vCPU · 512 MB · Spot`. */
|
|
59
|
+
export function describeContainerSize(size) {
|
|
60
|
+
return `${size.cpu} vCPU · ${size.memoryMb} MB · ${size.spot ? 'Spot' : 'on-demand'}`;
|
|
61
|
+
}
|
|
62
|
+
function round2(n) {
|
|
63
|
+
return Math.round(n * 100) / 100;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=compute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute.js","sourceRoot":"","sources":["../src/compute.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAG1D,qDAAqD;AACrD,MAAM,UAAU,oBAAoB,CAAC,GAAe;IAClD,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACnF,CAAC;AAED,iEAAiE;AACjE,MAAM,aAAa,GAAiE;IAClF,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;IACjB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;IACf,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;IAChB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,QAAgB;IAC5D,IAAI,CAAE,YAAkC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,OAAO,sBAAsB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACzD,CAAC;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AC,CAAC;IACpD,MAAM,aAAa,GAAG,MAAM,CAAC,oBAAoB,CAAC,cAAc,GAAG,eAAe,CAAC,CAAC;IACpF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,aAAa,CAAC,EAAE,CAAC;AACrF,CAAC;AAED,mCAAmC;AACnC,MAAM,UAAU,qBAAqB,CAAC,IAAsD;IAC1F,OAAO,GAAG,IAAI,CAAC,GAAG,WAAW,IAAI,CAAC,QAAQ,SAAS,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AACxF,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACnC,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -40,6 +40,24 @@ export interface PlatformConfig {
|
|
|
40
40
|
limits: {
|
|
41
41
|
appsPerMember: number;
|
|
42
42
|
stagesPerApp: number;
|
|
43
|
+
/** Highest `email.dailyLimit` an app may declare (recipients per UTC day). */
|
|
44
|
+
emailsPerDay: number;
|
|
45
|
+
/**
|
|
46
|
+
* The edge floor's limit for every app: requests one client (IP address)
|
|
47
|
+
* may send one host per minute before the edge answers 429 for a while.
|
|
48
|
+
* Enforced only while the floor is on (`edgeFloorAt`); apps set finer
|
|
49
|
+
* limits with `RateLimits`.
|
|
50
|
+
*/
|
|
51
|
+
edgeRequestsPerMinute?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Requests per minute across the whole edge, every app together, that
|
|
54
|
+
* turn the floor on: the control plane attaches an AWS WAF web ACL with
|
|
55
|
+
* the `edgeRequestsPerMinute` rule, and removes it after an hour under
|
|
56
|
+
* this rate. Set both or neither; without them there is no floor.
|
|
57
|
+
*/
|
|
58
|
+
edgeFloorAt?: number;
|
|
59
|
+
/** Long-running services one stage's plat.config.ts may declare: the one resource billed while idle. */
|
|
60
|
+
servicesPerApp: number;
|
|
43
61
|
};
|
|
44
62
|
telemetry: {
|
|
45
63
|
logRetentionDays: {
|
package/dist/config.js
CHANGED
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
import { Schema } from 'effect';
|
|
7
7
|
export const MemberRole = Schema.Literals(['admin', 'member']);
|
|
8
8
|
export function definePlatformConfig(config) {
|
|
9
|
+
const { edgeRequestsPerMinute: perClient, edgeFloorAt: at } = config.limits;
|
|
10
|
+
// WAF's rate-based rules count from 10 requests.
|
|
11
|
+
if (perClient !== undefined && (!Number.isSafeInteger(perClient) || perClient < 10))
|
|
12
|
+
throw new Error(`limits.edgeRequestsPerMinute must be an integer of at least 10, not ${perClient}`);
|
|
13
|
+
if (at !== undefined && (!Number.isSafeInteger(at) || at < 1))
|
|
14
|
+
throw new Error(`limits.edgeFloorAt must be a positive integer, not ${at}`);
|
|
15
|
+
// One without the other is a floor that never turns on, or one with no limit to enforce.
|
|
16
|
+
if ((perClient === undefined) !== (at === undefined))
|
|
17
|
+
throw new Error('limits.edgeRequestsPerMinute and limits.edgeFloorAt are set together, or neither');
|
|
9
18
|
const seen = new Set();
|
|
10
19
|
for (const m of config.members) {
|
|
11
20
|
const key = m.github.toLowerCase();
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,C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,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AACrF,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -33,15 +33,70 @@ export interface HealthResponse {
|
|
|
33
33
|
export declare const HOST_HEADER = "x-platform-host";
|
|
34
34
|
/** Trace propagation header (W3C traceparent is also honored). */
|
|
35
35
|
export declare const TRACE_HEADER = "x-platform-trace";
|
|
36
|
+
/**
|
|
37
|
+
* The secret the router sends a request-mode server (a function URL anyone
|
|
38
|
+
* can call) with each request: the stage's `originSecret`. The SDK answers
|
|
39
|
+
* 403 to a request without it before any app code runs.
|
|
40
|
+
*/
|
|
41
|
+
export declare const ORIGIN_HEADER = "x-platform-origin";
|
|
42
|
+
/**
|
|
43
|
+
* The client's `ip:port` as the edge saw the connection; IPv6 is unbracketed
|
|
44
|
+
* (`2001:db8::7:51234`). CloudFront sets it and replaces any copy a client
|
|
45
|
+
* sends (so does `plat dev`), and servers only take requests from the edge
|
|
46
|
+
* (Web Function endpoints signed ones, request-mode servers those carrying
|
|
47
|
+
* `ORIGIN_HEADER`), so apps can trust it.
|
|
48
|
+
*/
|
|
49
|
+
export declare const VIEWER_ADDRESS_HEADER = "cloudfront-viewer-address";
|
|
50
|
+
/** The client's country (ISO 3166-1 alpha-2), from the edge; absent locally. */
|
|
51
|
+
export declare const VIEWER_COUNTRY_HEADER = "cloudfront-viewer-country";
|
|
52
|
+
/**
|
|
53
|
+
* Partition-key prefix of the SDK's rate-limit counters in a stage's table
|
|
54
|
+
* (`_rl#<limit>#<key>`). Collection names start with a letter, so no
|
|
55
|
+
* document shares it; the data browser leaves these items out.
|
|
56
|
+
*/
|
|
57
|
+
export declare const RATE_LIMIT_PK_PREFIX = "_rl#";
|
|
58
|
+
/** How long the edge's request floor asks a client over it to wait: WAF counts the last minute. */
|
|
59
|
+
export declare const EDGE_RETRY_AFTER_SECONDS = 60;
|
|
60
|
+
/**
|
|
61
|
+
* The control plane worker's invoke job that the edge floor's alarm runs when
|
|
62
|
+
* it goes off (an EventBridge rule in the foundation stack): it turns the floor on.
|
|
63
|
+
*/
|
|
64
|
+
export declare const EDGE_FLOOR_JOB = "edge-floor";
|
|
65
|
+
/**
|
|
66
|
+
* The body of the edge floor's 429 (`limits.edgeRequestsPerMinute`): the SDK's
|
|
67
|
+
* `RateLimited`, so a generated web client decodes it like an app's own 429.
|
|
68
|
+
*/
|
|
69
|
+
export declare const EDGE_RATE_LIMITED_BODY: {
|
|
70
|
+
readonly _tag: 'RateLimited';
|
|
71
|
+
readonly message: "Too many requests. Try again in 60 seconds.";
|
|
72
|
+
readonly retryAfter: 60;
|
|
73
|
+
};
|
|
36
74
|
/** Tags on every AWS resource the engine creates. */
|
|
37
75
|
export declare const TAGS: {
|
|
38
76
|
readonly managed: 'platform:managed';
|
|
39
77
|
readonly app: 'platform:app';
|
|
40
78
|
readonly stage: 'platform:stage';
|
|
79
|
+
/** On resources built per deployment (a service's task definition), so it can be found again. */
|
|
80
|
+
readonly deployment: 'platform:deployment';
|
|
41
81
|
};
|
|
42
82
|
/** The production stage. Its host has no stage suffix. */
|
|
43
83
|
export declare const PROD_STAGE = "prod";
|
|
44
84
|
/** Stage name used by `plat dev` against the AWS Emulator. */
|
|
45
85
|
export declare const LOCAL_STAGE = "local";
|
|
46
|
-
/** Lambda runtime for
|
|
86
|
+
/** Lambda runtime for Web Functions, request-mode servers and worker (Event) Functions. */
|
|
47
87
|
export declare const NODE_RUNTIME = "nodejs24.x";
|
|
88
|
+
/**
|
|
89
|
+
* Base of every container image the platform builds: Node.js 24 on Debian
|
|
90
|
+
* slim, linux/arm64, pinned to one image manifest (not the multi-platform
|
|
91
|
+
* index). The engine copies it from ECR Public into the platform's
|
|
92
|
+
* repository the first time a deploy needs it, so bumping it is a deliberate
|
|
93
|
+
* change: look up the arm64 entry of the tag's index and update both fields.
|
|
94
|
+
*/
|
|
95
|
+
export declare const CONTAINER_BASE_IMAGE: {
|
|
96
|
+
readonly registry: 'public.ecr.aws';
|
|
97
|
+
readonly repository: 'docker/library/node';
|
|
98
|
+
readonly tag: '24-slim';
|
|
99
|
+
readonly digest: 'sha256:5f8fabfed57b75127de2f584593d67a9e8c90e6b0f65652871f9ef0f759c0299';
|
|
100
|
+
};
|
|
101
|
+
/** Environment variable naming the service a container runs (`ais`). */
|
|
102
|
+
export declare const SERVICE_ENV = "PLATFORM_SERVICE";
|
package/dist/constants.js
CHANGED
|
@@ -22,16 +22,71 @@ export const HEALTH_PATH = '/__platform/health';
|
|
|
22
22
|
export const HOST_HEADER = 'x-platform-host';
|
|
23
23
|
/** Trace propagation header (W3C traceparent is also honored). */
|
|
24
24
|
export const TRACE_HEADER = 'x-platform-trace';
|
|
25
|
+
/**
|
|
26
|
+
* The secret the router sends a request-mode server (a function URL anyone
|
|
27
|
+
* can call) with each request: the stage's `originSecret`. The SDK answers
|
|
28
|
+
* 403 to a request without it before any app code runs.
|
|
29
|
+
*/
|
|
30
|
+
export const ORIGIN_HEADER = 'x-platform-origin';
|
|
31
|
+
/**
|
|
32
|
+
* The client's `ip:port` as the edge saw the connection; IPv6 is unbracketed
|
|
33
|
+
* (`2001:db8::7:51234`). CloudFront sets it and replaces any copy a client
|
|
34
|
+
* sends (so does `plat dev`), and servers only take requests from the edge
|
|
35
|
+
* (Web Function endpoints signed ones, request-mode servers those carrying
|
|
36
|
+
* `ORIGIN_HEADER`), so apps can trust it.
|
|
37
|
+
*/
|
|
38
|
+
export const VIEWER_ADDRESS_HEADER = 'cloudfront-viewer-address';
|
|
39
|
+
/** The client's country (ISO 3166-1 alpha-2), from the edge; absent locally. */
|
|
40
|
+
export const VIEWER_COUNTRY_HEADER = 'cloudfront-viewer-country';
|
|
41
|
+
/**
|
|
42
|
+
* Partition-key prefix of the SDK's rate-limit counters in a stage's table
|
|
43
|
+
* (`_rl#<limit>#<key>`). Collection names start with a letter, so no
|
|
44
|
+
* document shares it; the data browser leaves these items out.
|
|
45
|
+
*/
|
|
46
|
+
export const RATE_LIMIT_PK_PREFIX = '_rl#';
|
|
47
|
+
/** How long the edge's request floor asks a client over it to wait: WAF counts the last minute. */
|
|
48
|
+
export const EDGE_RETRY_AFTER_SECONDS = 60;
|
|
49
|
+
/**
|
|
50
|
+
* The control plane worker's invoke job that the edge floor's alarm runs when
|
|
51
|
+
* it goes off (an EventBridge rule in the foundation stack): it turns the floor on.
|
|
52
|
+
*/
|
|
53
|
+
export const EDGE_FLOOR_JOB = 'edge-floor';
|
|
54
|
+
/**
|
|
55
|
+
* The body of the edge floor's 429 (`limits.edgeRequestsPerMinute`): the SDK's
|
|
56
|
+
* `RateLimited`, so a generated web client decodes it like an app's own 429.
|
|
57
|
+
*/
|
|
58
|
+
export const EDGE_RATE_LIMITED_BODY = {
|
|
59
|
+
_tag: 'RateLimited',
|
|
60
|
+
message: `Too many requests. Try again in ${EDGE_RETRY_AFTER_SECONDS} seconds.`,
|
|
61
|
+
retryAfter: EDGE_RETRY_AFTER_SECONDS,
|
|
62
|
+
};
|
|
25
63
|
/** Tags on every AWS resource the engine creates. */
|
|
26
64
|
export const TAGS = {
|
|
27
65
|
managed: 'platform:managed',
|
|
28
66
|
app: 'platform:app',
|
|
29
67
|
stage: 'platform:stage',
|
|
68
|
+
/** On resources built per deployment (a service's task definition), so it can be found again. */
|
|
69
|
+
deployment: 'platform:deployment',
|
|
30
70
|
};
|
|
31
71
|
/** The production stage. Its host has no stage suffix. */
|
|
32
72
|
export const PROD_STAGE = 'prod';
|
|
33
73
|
/** Stage name used by `plat dev` against the AWS Emulator. */
|
|
34
74
|
export const LOCAL_STAGE = 'local';
|
|
35
|
-
/** Lambda runtime for
|
|
75
|
+
/** Lambda runtime for Web Functions, request-mode servers and worker (Event) Functions. */
|
|
36
76
|
export const NODE_RUNTIME = 'nodejs24.x';
|
|
77
|
+
/**
|
|
78
|
+
* Base of every container image the platform builds: Node.js 24 on Debian
|
|
79
|
+
* slim, linux/arm64, pinned to one image manifest (not the multi-platform
|
|
80
|
+
* index). The engine copies it from ECR Public into the platform's
|
|
81
|
+
* repository the first time a deploy needs it, so bumping it is a deliberate
|
|
82
|
+
* change: look up the arm64 entry of the tag's index and update both fields.
|
|
83
|
+
*/
|
|
84
|
+
export const CONTAINER_BASE_IMAGE = {
|
|
85
|
+
registry: 'public.ecr.aws',
|
|
86
|
+
repository: 'docker/library/node',
|
|
87
|
+
tag: '24-slim',
|
|
88
|
+
digest: 'sha256:5f8fabfed57b75127de2f584593d67a9e8c90e6b0f65652871f9ef0f759c0299',
|
|
89
|
+
};
|
|
90
|
+
/** Environment variable naming the service a container runs (`ais`). */
|
|
91
|
+
export const SERVICE_ENV = 'PLATFORM_SERVICE';
|
|
37
92
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,kFAAkF;IAClF,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,WAAW;IACnB,oCAAoC;IACpC,MAAM,EAAE,oCAAoC;IAC5C,8DAA8D;IAC9D,YAAY,EAAE,oCAAoC;IAClD,4EAA4E;IAC5E,WAAW,EAAE,WAAW;IACxB,SAAS,EAAE,IAAI;CACP,CAAC;AAEX,6EAA6E;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAC;AACnD,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAchD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAC7C,kEAAkE;AAClE,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,qDAAqD;AACrD,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,OAAO,EAAE,kBAAkB;IAC3B,GAAG,EAAE,cAAc;IACnB,KAAK,EAAE,gBAAgB;
|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