@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.
- package/dist/api.d.ts +1847 -212
- package/dist/api.js +694 -1
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +19 -0
- package/dist/auth.js +32 -0
- 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 +69 -13
- 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 +70 -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 +21 -1
- package/dist/config.js +16 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +67 -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 +357 -112
- package/dist/manifest.js +270 -72
- package/dist/manifest.js.map +1 -1
- package/dist/naming.d.ts +93 -6
- package/dist/naming.js +98 -6
- package/dist/naming.js.map +1 -1
- package/dist/platform-api.d.ts +7792 -0
- package/dist/platform-api.js +455 -0
- package/dist/platform-api.js.map +1 -0
- 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 +7 -1
- package/dist/router/decide.js +42 -5
- 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 +350 -83
- package/dist/telemetry.js +188 -15
- 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 +28 -8
- package/src/api.ts +864 -238
- package/src/auth.ts +37 -0
- package/src/base64url.ts +13 -0
- package/src/bindings.ts +74 -7
- package/src/cloudfront-function.ts +70 -2
- package/src/compute.ts +86 -0
- package/src/config.ts +34 -2
- package/src/constants.ts +76 -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 +542 -114
- package/src/naming.ts +103 -8
- package/src/platform-api.ts +630 -0
- package/src/realtime.ts +298 -0
- package/src/router/decide.d.ts +7 -1
- package/src/router/decide.js +42 -5
- package/src/router.ts +33 -13
- package/src/runtime-config.ts +70 -0
- package/src/storage.ts +120 -0
- package/src/telemetry.ts +198 -93
- package/src/web-compute.ts +342 -0
package/src/naming.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PROD_STAGE } from './constants.ts';
|
|
2
|
-
import { fingerprint } from './
|
|
2
|
+
import { fingerprint } from './fingerprint.ts';
|
|
3
|
+
import { PUBLIC_STORAGE_ROOT } from './storage.ts';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* App names: 3-30 chars, lowercase letters/digits/single hyphens, starting with
|
|
@@ -93,29 +94,91 @@ export function parseStageHost(host: string, domain: string): { app: string; sta
|
|
|
93
94
|
export const names = {
|
|
94
95
|
base: (app: string, stage: string) => `${app}--${stage}`,
|
|
95
96
|
table: (app: string, stage: string) => `${app}--${stage}`,
|
|
97
|
+
/** The server's Lambda Web Function (instance mode). */
|
|
96
98
|
webFunction: (app: string, stage: string) => `${app}--${stage}`,
|
|
97
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The server's Lambda function in request mode. Not a worker function,
|
|
101
|
+
* though it shares their `<app>--<stage>--` prefix: a handler's own
|
|
102
|
+
* function is `…--worker--…`, or a cut of that ending in `-<hash>`.
|
|
103
|
+
*/
|
|
104
|
+
requestFunction: (app: string, stage: string) => `${app}--${stage}--web`,
|
|
105
|
+
/**
|
|
106
|
+
* The Web Function's two endpoints, and the request-mode function's two
|
|
107
|
+
* aliases (each with a function URL), each pinned to one revision or
|
|
108
|
+
* version. Neither name means "current": a deploy uses whichever the live
|
|
109
|
+
* route doesn't (`live` predates the second one).
|
|
110
|
+
*/
|
|
111
|
+
webEndpoints: () => ['live', 'live-b'] as const,
|
|
98
112
|
workerFunction: (app: string, stage: string) => `${app}--${stage}--worker`,
|
|
113
|
+
/**
|
|
114
|
+
* The function a queue, event or cron handler with its own memory or timeout
|
|
115
|
+
* runs in, from the worker's bundle. Function names are ≤ 64 chars of
|
|
116
|
+
* A-Z, a-z, 0-9, `-` and `_`: long names are hashed, and an event type's
|
|
117
|
+
* `.` becomes `_` (which no event type contains). `:` has no such stand-in,
|
|
118
|
+
* so a type with one always carries a hash of the type.
|
|
119
|
+
*/
|
|
120
|
+
handlerFunction: (app: string, stage: string, kind: 'queue' | 'event' | 'cron', name: string) => {
|
|
121
|
+
const full = `${app}--${stage}--worker--${kind}-${name}`;
|
|
122
|
+
const safe = full.replaceAll('.', '_').replaceAll(':', '_');
|
|
123
|
+
return name.includes(':') ? `${safe.slice(0, 55)}-${fingerprint([full])}` : fit(safe, 64);
|
|
124
|
+
},
|
|
99
125
|
/** IAM role name; created under {@link IAM_APP_PATH}. */
|
|
100
126
|
role: (app: string, stage: string) => `${app}--${stage}`,
|
|
101
|
-
|
|
102
|
-
|
|
127
|
+
/**
|
|
128
|
+
* The stage's dead-letter queue (SQS, never polled): every job that failed
|
|
129
|
+
* its last attempt. Queue keys can't contain `--` and the old dead-letter
|
|
130
|
+
* queues end in `--dlq`, so this can't be a pre-0.4.0 queue's name.
|
|
131
|
+
*/
|
|
132
|
+
deadLetters: (app: string, stage: string) => `${app}--${stage}--jobs--dead`,
|
|
133
|
+
/** The SQS queue `plat dev` points the stage's event rules at, to run events in the local worker. */
|
|
134
|
+
devEventTap: (app: string, stage: string) => `${app}--${stage}--plat-dev-events`,
|
|
135
|
+
/** A queue's SQS queue and its dead-letter queue, before queues were pushed (0.4.0). */
|
|
136
|
+
legacyQueue: (app: string, stage: string, key: string) => `${app}--${stage}--${key}`,
|
|
137
|
+
legacyDeadLetterQueue: (app: string, stage: string, key: string) => `${app}--${stage}--${key}--dlq`,
|
|
103
138
|
eventBus: (app: string, stage: string) => `${app}--${stage}`,
|
|
104
139
|
/** EventBridge rule names are ≤ 64 chars; long event types are hashed. */
|
|
105
140
|
eventRule: (app: string, stage: string, eventType: string) =>
|
|
106
141
|
fit(`${app}--${stage}--${eventType.replace(/[^A-Za-z0-9._-]/g, '_')}`, 64),
|
|
107
142
|
scheduleGroup: (app: string, stage: string) => `${app}--${stage}`,
|
|
108
143
|
schedule: (cronKey: string) => cronKey,
|
|
144
|
+
/**
|
|
145
|
+
* A long-running service's ECS service and task definition family (ECS
|
|
146
|
+
* names are their own namespace, so `worker` can't clash with the Lambda).
|
|
147
|
+
*/
|
|
148
|
+
service: (app: string, stage: string, key: string) => `${app}--${stage}--${key}`,
|
|
149
|
+
serviceLogGroup: (app: string, stage: string, key: string) =>
|
|
150
|
+
`/platform/apps/${app}/${stage}/services/${key}`,
|
|
151
|
+
/** Tag of a service's image for one deployment in the container repository (≤ 103 of ECR's 128 chars). */
|
|
152
|
+
serviceImageTag: (app: string, stage: string, key: string, deploymentId: string) =>
|
|
153
|
+
`${app}--${stage}--${key}--${deploymentId}`,
|
|
154
|
+
/**
|
|
155
|
+
* One-shot schedule, in the stage's schedule group, that stops a preview's
|
|
156
|
+
* service. Cron keys can't contain `--`, so it never clashes with a cron.
|
|
157
|
+
*/
|
|
158
|
+
serviceStopSchedule: (key: string) => `${key}--stop`,
|
|
109
159
|
userPoolClient: (app: string, stage: string) => `${app}--${stage}`,
|
|
110
|
-
|
|
160
|
+
/** SES tenant and its configuration set (≤ 64 chars each; the base is ≤ 52). */
|
|
161
|
+
emailTenant: (app: string, stage: string) => `${app}--${stage}`,
|
|
162
|
+
/** AppSync Events channel namespace; names are ≤ 50 chars, so long ones are hashed. */
|
|
163
|
+
realtimeNamespace: (app: string, stage: string) => fit(`${app}--${stage}`, 50),
|
|
164
|
+
/**
|
|
165
|
+
* A stage's log groups. Lambda also writes a Web Function's environments to
|
|
166
|
+
* `<web group>.local`, so the engine creates that one too.
|
|
167
|
+
*/
|
|
168
|
+
logGroup: (app: string, stage: string, component: 'web' | 'web.local' | 'worker') =>
|
|
111
169
|
`/platform/apps/${app}/${stage}/${component}`,
|
|
112
170
|
logGroupPrefix: (app: string, stage?: string) =>
|
|
113
171
|
stage ? `/platform/apps/${app}/${stage}/` : `/platform/apps/${app}/`,
|
|
114
172
|
secretsPath: (app: string, stage: string) => `/platform/apps/${app}/${stage}/secrets/`,
|
|
115
173
|
sharedSecretsPath: (app: string) => `/platform/apps/${app}/_shared/secrets/`,
|
|
116
|
-
/**
|
|
117
|
-
|
|
118
|
-
|
|
174
|
+
/** SSM SecureString holding the stage key (see `Bindings.stageKey`); outside the secrets path. */
|
|
175
|
+
stageKeyParameter: (app: string, stage: string) => `/platform/apps/${app}/${stage}/stage-key`,
|
|
176
|
+
/** A private store's prefix in the shared storage bucket: `<app>/<stage>/<store>/`. */
|
|
177
|
+
storagePrefix: (app: string, stage: string, store?: string) =>
|
|
178
|
+
store ? `${app}/${stage}/${store}/` : `${app}/${stage}/`,
|
|
179
|
+
/** A public store's prefix in the shared storage bucket: `_public/<app>/<stage>/<store>/` (see `storage.ts`). */
|
|
180
|
+
publicStoragePrefix: (app: string, stage: string, store?: string) =>
|
|
181
|
+
`${PUBLIC_STORAGE_ROOT}${names.storagePrefix(app, stage, store)}`,
|
|
119
182
|
/** Prefix inside the shared sites bucket for one deployment's static files. */
|
|
120
183
|
sitePrefix: (app: string, stage: string, deploymentId: string) => `${app}/${stage}/${deploymentId}`,
|
|
121
184
|
artifactKey: (app: string, stage: string, deploymentId: string, file: string) =>
|
|
@@ -136,9 +199,41 @@ export const platformNames = {
|
|
|
136
199
|
routerFunction: 'platform-router',
|
|
137
200
|
userPool: 'platform-users',
|
|
138
201
|
boundaryPolicy: 'platform-app-boundary',
|
|
202
|
+
/** The AppSync Event API every stage's channel namespace lives in. */
|
|
203
|
+
realtimeApi: 'platform-realtime',
|
|
204
|
+
/** Its Lambda authorizer (signed-in subscribe tokens). */
|
|
205
|
+
realtimeAuthorizer: 'platform-realtime-authorizer',
|
|
206
|
+
/** ECS cluster every stage's containers run in (long-running services). */
|
|
207
|
+
containerCluster: 'platform',
|
|
208
|
+
/** VPC and security group containers run in: public subnets, no NAT, egress only. */
|
|
209
|
+
containerNetwork: 'platform-containers',
|
|
210
|
+
/** ECR repository of every container image the platform builds; tags name app, stage and deployment. */
|
|
211
|
+
containerRepository: 'platform-containers',
|
|
212
|
+
/** Role ECS uses to pull images and ship container logs (the app's code runs as its stage role). */
|
|
213
|
+
containerExecutionRole: 'platform-container-execution',
|
|
214
|
+
/** Role EventBridge Scheduler uses to scale containers (a preview's stop schedule). */
|
|
215
|
+
containerSchedulerRole: 'platform-container-scheduler',
|
|
216
|
+
/** Description of the API's subscribe-only key for `public` stages (how the control plane finds it). */
|
|
217
|
+
realtimePublicKey: 'platform-public-subscribe',
|
|
218
|
+
/** The control plane's own app name (services/control-plane/plat.config.ts), stage prod. */
|
|
219
|
+
controlPlaneApp: 'platform',
|
|
139
220
|
controlPlaneRole: 'platform-control-plane',
|
|
140
221
|
ciRole: 'platform-ci',
|
|
141
222
|
alertsTopic: 'platform-alerts',
|
|
223
|
+
/**
|
|
224
|
+
* The edge floor's AWS WAF web ACL, which the control plane creates and attaches to the router
|
|
225
|
+
* while the floor is on; also its CloudWatch metric name. Not `platform-edge`, the always-on web
|
|
226
|
+
* ACL the foundation stack used to own: the stack deletes that one only after updating the
|
|
227
|
+
* distribution, so the two names can't collide while it goes.
|
|
228
|
+
*/
|
|
229
|
+
edgeWebAcl: 'platform-edge-floor',
|
|
230
|
+
/** Its rate-based rule, and that rule's metric name. */
|
|
231
|
+
edgeFloorRule: 'requests-per-client',
|
|
232
|
+
/**
|
|
233
|
+
* The CloudWatch alarm on the router's requests per minute (`limits.edgeFloorAt`) that turns the
|
|
234
|
+
* floor on, and the EventBridge rule that tells the control plane when it goes off.
|
|
235
|
+
*/
|
|
236
|
+
edgeFloorAlarm: 'platform-edge-floor',
|
|
142
237
|
runtimeConfigParameter: '/platform/config/runtime',
|
|
143
238
|
sessionKeyParameter: '/platform/config/session-key',
|
|
144
239
|
githubAppParameterPrefix: '/platform/config/github-app/',
|