@ericminassian/platform-engine 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/clients.d.ts +8 -0
- package/dist/clients.js +22 -1
- package/dist/clients.js.map +1 -1
- package/dist/compat.d.ts +21 -9
- package/dist/compat.js +27 -7
- package/dist/compat.js.map +1 -1
- package/dist/drivers/appsync.d.ts +49 -0
- package/dist/drivers/appsync.js +155 -0
- package/dist/drivers/appsync.js.map +1 -0
- package/dist/drivers/ecr.d.ts +109 -0
- package/dist/drivers/ecr.js +303 -0
- package/dist/drivers/ecr.js.map +1 -0
- package/dist/drivers/ecs.d.ts +163 -0
- package/dist/drivers/ecs.js +447 -0
- package/dist/drivers/ecs.js.map +1 -0
- package/dist/drivers/events.d.ts +10 -0
- package/dist/drivers/events.js +13 -1
- package/dist/drivers/events.js.map +1 -1
- package/dist/drivers/index.d.ts +5 -0
- package/dist/drivers/index.js +5 -0
- package/dist/drivers/index.js.map +1 -1
- package/dist/drivers/kvs.d.ts +3 -0
- package/dist/drivers/kvs.js +14 -7
- package/dist/drivers/kvs.js.map +1 -1
- package/dist/drivers/lambda.d.ts +22 -0
- package/dist/drivers/lambda.js +74 -3
- package/dist/drivers/lambda.js.map +1 -1
- package/dist/drivers/request-function.d.ts +60 -0
- package/dist/drivers/request-function.js +167 -0
- package/dist/drivers/request-function.js.map +1 -0
- package/dist/drivers/s3.d.ts +7 -0
- package/dist/drivers/s3.js +31 -0
- package/dist/drivers/s3.js.map +1 -1
- package/dist/drivers/scheduler.d.ts +24 -0
- package/dist/drivers/scheduler.js +60 -5
- package/dist/drivers/scheduler.js.map +1 -1
- package/dist/drivers/ses.d.ts +77 -0
- package/dist/drivers/ses.js +181 -0
- package/dist/drivers/ses.js.map +1 -0
- package/dist/drivers/sqs.d.ts +11 -0
- package/dist/drivers/sqs.js +67 -1
- package/dist/drivers/sqs.js.map +1 -1
- package/dist/drivers/ssm.d.ts +1 -0
- package/dist/drivers/ssm.js +23 -3
- package/dist/drivers/ssm.js.map +1 -1
- package/dist/drivers/web-function.d.ts +41 -11
- package/dist/drivers/web-function.js +62 -8
- package/dist/drivers/web-function.js.map +1 -1
- package/dist/emulator.js.map +1 -1
- package/dist/images.d.ts +104 -0
- package/dist/images.js +182 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +132 -7
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/local.js +222 -7
- package/dist/local.js.map +1 -1
- package/dist/policy.d.ts +47 -4
- package/dist/policy.js +369 -15
- package/dist/policy.js.map +1 -1
- package/dist/services.d.ts +155 -0
- package/dist/services.js +464 -0
- package/dist/services.js.map +1 -0
- package/dist/stage.d.ts +44 -4
- package/dist/stage.js +681 -138
- package/dist/stage.js.map +1 -1
- package/dist/static.d.ts +1 -1
- package/dist/static.js +2 -36
- package/dist/static.js.map +1 -1
- package/dist/util.d.ts +22 -0
- package/dist/util.js +18 -2
- package/dist/util.js.map +1 -1
- package/package.json +20 -14
- package/src/clients.ts +25 -1
- package/src/compat.ts +34 -11
- package/src/drivers/appsync.ts +220 -0
- package/src/drivers/ecr.ts +457 -0
- package/src/drivers/ecs.ts +661 -0
- package/src/drivers/events.ts +29 -2
- package/src/drivers/index.ts +5 -0
- package/src/drivers/kvs.ts +21 -12
- package/src/drivers/lambda.ts +103 -2
- package/src/drivers/request-function.ts +295 -0
- package/src/drivers/s3.ts +46 -0
- package/src/drivers/scheduler.ts +88 -5
- package/src/drivers/ses.ts +267 -0
- package/src/drivers/sqs.ts +95 -0
- package/src/drivers/ssm.ts +23 -2
- package/src/drivers/web-function.ts +108 -17
- package/src/emulator.ts +3 -3
- package/src/images.ts +254 -0
- package/src/index.ts +131 -8
- package/src/local.ts +251 -7
- package/src/policy.ts +450 -26
- package/src/services.ts +663 -0
- package/src/stage.ts +839 -153
- package/src/static.ts +2 -37
- package/src/util.ts +38 -4
package/dist/index.d.ts
CHANGED
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
* CONTRACT: the exported names and types below are used by the CLI, the
|
|
14
14
|
* control plane and the foundation. Keep them stable.
|
|
15
15
|
*/
|
|
16
|
-
import type { Bindings, PlatformRuntimeConfig, ResolvedManifest, RouteRecord } from '@ericminassian/platform-core';
|
|
16
|
+
import type { Bindings, PlatformRuntimeConfig, RealtimeEdgeEntry, ResolvedManifest, RouteRecord, WebCompute } from '@ericminassian/platform-core';
|
|
17
17
|
import type { EngineContext } from './util.ts';
|
|
18
18
|
export type { AwsClients } from './clients.ts';
|
|
19
19
|
export * from './drivers/index.ts';
|
|
20
20
|
export * from './emulator.ts';
|
|
21
|
+
export * as images from './images.ts';
|
|
21
22
|
export * as policies from './policy.ts';
|
|
23
|
+
export { ServiceNotFoundError } from './services.ts';
|
|
22
24
|
export { hostFor } from './stage.ts';
|
|
23
25
|
export { cacheControlFor, contentTypeFor } from './static.ts';
|
|
24
26
|
export type { EngineContext, PolicyDocument, PolicyStatement } from './util.ts';
|
|
@@ -58,11 +60,15 @@ export interface DeployStageInput {
|
|
|
58
60
|
stage: string;
|
|
59
61
|
deploymentId: string;
|
|
60
62
|
platform: PlatformRuntimeConfig;
|
|
61
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Uploaded build artifacts (zips) in the artifacts bucket. `services` is
|
|
65
|
+
* `services.zip`: `<service>/index.mjs` (+ `.map`) for each declared service.
|
|
66
|
+
*/
|
|
62
67
|
artifacts: {
|
|
63
68
|
server?: S3Location;
|
|
64
69
|
worker?: S3Location;
|
|
65
70
|
static?: S3Location;
|
|
71
|
+
services?: S3Location;
|
|
66
72
|
};
|
|
67
73
|
/**
|
|
68
74
|
* `function`: create/update the Lambda Web Function + route record (AWS).
|
|
@@ -70,6 +76,20 @@ export interface DeployStageInput {
|
|
|
70
76
|
* the emulator does not serve Web Function endpoints yet.
|
|
71
77
|
*/
|
|
72
78
|
webMode?: 'function' | 'external';
|
|
79
|
+
/**
|
|
80
|
+
* How the server runs with `webMode: 'function'` (core `webComputeFor`
|
|
81
|
+
* decides it): `instance`, a Lambda Web Function (the default), or
|
|
82
|
+
* `request`, a Lambda function per request behind function URLs. A deploy
|
|
83
|
+
* builds only this one; the stage keeps the other mode's (it costs nothing
|
|
84
|
+
* idle) until the manifest drops `web.server` or the stage is destroyed.
|
|
85
|
+
*/
|
|
86
|
+
webCompute?: WebCompute;
|
|
87
|
+
/**
|
|
88
|
+
* `ecs`: build each service's image and run it on ECS (AWS; the default).
|
|
89
|
+
* `external`: skip images and ECS; `plat dev` runs services as local
|
|
90
|
+
* processes. Their log groups are created either way.
|
|
91
|
+
*/
|
|
92
|
+
servicesMode?: 'ecs' | 'external';
|
|
73
93
|
/** Use this role instead of creating the per-stage role (the control plane runs privileged). */
|
|
74
94
|
roleArn?: string;
|
|
75
95
|
/** Extra environment variables for web + worker (merged over manifest `env`). */
|
|
@@ -77,7 +97,7 @@ export interface DeployStageInput {
|
|
|
77
97
|
logRetentionDays?: number;
|
|
78
98
|
}
|
|
79
99
|
export interface ResourceRef {
|
|
80
|
-
/** `role`, `table`, `queue`, `bus`, `rule`, `schedule-group`, `schedule`, `log-group`, `web-function`, `function
|
|
100
|
+
/** `role`, `table`, `queue`, `bus`, `rule`, `schedule-group`, `schedule`, `log-group`, `web-function`, `function` (worker, a handler's own, or the request-mode server), `esm`, `user-pool-client`, `channel-namespace`, `email-tenant`, `configuration-set`, `route`, `static`, `image`, `task-definition`, `ecs-service` */
|
|
81
101
|
type: string;
|
|
82
102
|
name: string;
|
|
83
103
|
arn?: string;
|
|
@@ -87,25 +107,99 @@ export interface DeployStageResult {
|
|
|
87
107
|
host: string;
|
|
88
108
|
url: string;
|
|
89
109
|
route?: RouteRecord;
|
|
110
|
+
/** How the server runs, when the stage has one. */
|
|
111
|
+
compute?: WebCompute;
|
|
112
|
+
/** The server in instance mode. */
|
|
90
113
|
webFunction?: {
|
|
91
114
|
name: string;
|
|
92
115
|
endpointDomain: string;
|
|
93
116
|
revisionId: string;
|
|
94
117
|
};
|
|
118
|
+
/** The server in request mode: the version this deploy published, behind `urlDomain`. */
|
|
119
|
+
requestFunction?: {
|
|
120
|
+
name: string;
|
|
121
|
+
urlDomain: string;
|
|
122
|
+
version: string;
|
|
123
|
+
};
|
|
95
124
|
workerFunction?: {
|
|
96
125
|
name: string;
|
|
97
126
|
arn: string;
|
|
98
127
|
};
|
|
128
|
+
/** Services the deploy rolled out (`servicesMode: 'ecs'`). */
|
|
129
|
+
services?: DeployedService[];
|
|
99
130
|
resources: ResourceRef[];
|
|
100
131
|
}
|
|
132
|
+
export interface DeployedService {
|
|
133
|
+
/** The key in plat.config.ts (`ais`). */
|
|
134
|
+
name: string;
|
|
135
|
+
/** `<repositoryUri>@sha256:…`. */
|
|
136
|
+
image: string;
|
|
137
|
+
taskDefinitionArn: string;
|
|
138
|
+
/** 1 running, 0 when a preview doesn't run it. */
|
|
139
|
+
desired: number;
|
|
140
|
+
/** A preview's stop schedule. */
|
|
141
|
+
stopsAt?: string;
|
|
142
|
+
}
|
|
101
143
|
export interface RollbackStageInput {
|
|
102
144
|
app: string;
|
|
103
145
|
stage: string;
|
|
104
146
|
platform: PlatformRuntimeConfig;
|
|
105
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Route record of the deployment to go back to, in its compute mode. The
|
|
149
|
+
* engine picks the endpoint or function URL (`o`) itself.
|
|
150
|
+
*/
|
|
106
151
|
route: RouteRecord;
|
|
107
|
-
/** Web Function revision
|
|
152
|
+
/** That deployment's Web Function revision (instance mode). */
|
|
108
153
|
revisionId?: string;
|
|
154
|
+
/** That deployment's function version (request mode). */
|
|
155
|
+
version?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Services that deployment declared. Each one the stage still runs is
|
|
158
|
+
* pointed back at that deployment's build; the rollback is refused if a
|
|
159
|
+
* build was cleaned up since.
|
|
160
|
+
*/
|
|
161
|
+
services?: readonly string[];
|
|
162
|
+
}
|
|
163
|
+
export interface StageServicesInput {
|
|
164
|
+
app: string;
|
|
165
|
+
stage: string;
|
|
166
|
+
platform: PlatformRuntimeConfig;
|
|
167
|
+
}
|
|
168
|
+
/** One service as ECS reports it right now. */
|
|
169
|
+
export interface ServiceRuntimeState {
|
|
170
|
+
name: string;
|
|
171
|
+
desired: number;
|
|
172
|
+
running: number;
|
|
173
|
+
pending: number;
|
|
174
|
+
/** The newest ECS deployment's rollout (`COMPLETED`, `IN_PROGRESS`, `FAILED`). */
|
|
175
|
+
rollout?: 'completed' | 'in_progress' | 'failed';
|
|
176
|
+
/** Deployment whose build the newest ECS deployment runs (its task definition's tag). */
|
|
177
|
+
deploymentId?: string;
|
|
178
|
+
/** When the current task started. */
|
|
179
|
+
startedAt?: string;
|
|
180
|
+
/** When a stop schedule scales it to zero. */
|
|
181
|
+
stopsAt?: string;
|
|
182
|
+
/** The task that stopped most recently. */
|
|
183
|
+
lastStop?: {
|
|
184
|
+
at: string;
|
|
185
|
+
reason: string;
|
|
186
|
+
exitCode?: number;
|
|
187
|
+
};
|
|
188
|
+
/** Recent ECS service events, newest first (at most 10). */
|
|
189
|
+
events: Array<{
|
|
190
|
+
at: string;
|
|
191
|
+
message: string;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
194
|
+
export interface ControlServiceInput extends StageServicesInput {
|
|
195
|
+
name: string;
|
|
196
|
+
/**
|
|
197
|
+
* `start`: desired 1, stopping again after `minutes` when given (replacing
|
|
198
|
+
* any stop schedule). `stop`: desired 0 (and no stop schedule). `restart`:
|
|
199
|
+
* a fresh task on the same build.
|
|
200
|
+
*/
|
|
201
|
+
action: 'start' | 'stop' | 'restart';
|
|
202
|
+
minutes?: number;
|
|
109
203
|
}
|
|
110
204
|
export interface DestroyStageInput {
|
|
111
205
|
app: string;
|
|
@@ -114,24 +208,55 @@ export interface DestroyStageInput {
|
|
|
114
208
|
/** Keep the table and storage objects (default false; prod should pass true). */
|
|
115
209
|
keepData?: boolean;
|
|
116
210
|
}
|
|
211
|
+
export interface ExpireStorageInput {
|
|
212
|
+
app: string;
|
|
213
|
+
stage: string;
|
|
214
|
+
platform: PlatformRuntimeConfig;
|
|
215
|
+
/** The live deployment's: its stores' `expireAfterDays` and where their files are. */
|
|
216
|
+
manifest: Pick<ResolvedManifest, 'storage' | 'storageOptions'>;
|
|
217
|
+
/** Default: the current time. */
|
|
218
|
+
now?: Date;
|
|
219
|
+
}
|
|
117
220
|
export interface Engine {
|
|
118
221
|
readonly region: string;
|
|
119
222
|
readonly target: 'aws' | 'emulator';
|
|
120
223
|
accountId(): Promise<string>;
|
|
121
224
|
deployStage(input: DeployStageInput): Promise<DeployStageResult>;
|
|
122
|
-
|
|
225
|
+
/** Returns the route record it wrote. */
|
|
226
|
+
rollbackStage(input: RollbackStageInput): Promise<RouteRecord>;
|
|
123
227
|
destroyStage(input: DestroyStageInput): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* Delete the files of the stage's stores that set `expireAfterDays` and
|
|
230
|
+
* weren't written for that many days. Answers how many, by store. The
|
|
231
|
+
* control plane runs it daily for every live stage.
|
|
232
|
+
*/
|
|
233
|
+
expireStorage(input: ExpireStorageInput): Promise<Record<string, number>>;
|
|
124
234
|
/** Everything the engine owns for a stage (found by name + tags). */
|
|
125
235
|
listStageResources(app: string, stage: string): Promise<ResourceRef[]>;
|
|
126
236
|
/** Upload a local file/buffer into the artifacts bucket (used by `plat dev`). */
|
|
127
237
|
putArtifact(platform: PlatformRuntimeConfig, key: string, body: Uint8Array): Promise<S3Location>;
|
|
238
|
+
/**
|
|
239
|
+
* Keep realtime usable platform-wide: the public subscribe key exists and is far from expiry,
|
|
240
|
+
* and the router's realtime entry is current (written only when the platform has a route
|
|
241
|
+
* store). Returns that entry, or undefined when the platform has no realtime API. The control
|
|
242
|
+
* plane runs it nightly; `plat dev` serves the entry from its local router.
|
|
243
|
+
*/
|
|
244
|
+
ensureRealtimePlatform(platform: PlatformRuntimeConfig): Promise<RealtimeEdgeEntry | undefined>;
|
|
245
|
+
/** The stage's long-running services as ECS runs them now (none without container compute). */
|
|
246
|
+
describeServices(input: StageServicesInput): Promise<ServiceRuntimeState[]>;
|
|
247
|
+
/** Start, stop or restart one of the stage's services. */
|
|
248
|
+
controlService(input: ControlServiceInput): Promise<{
|
|
249
|
+
desired: number;
|
|
250
|
+
stopsAt?: string;
|
|
251
|
+
}>;
|
|
128
252
|
}
|
|
129
253
|
export declare function createEngine(opts: EngineOptions): Engine;
|
|
130
254
|
/** Driver-level access (clients, logger) for advanced callers such as `foundation/`. */
|
|
131
255
|
export declare function engineContext(engine: Engine): EngineContext;
|
|
132
256
|
/**
|
|
133
257
|
* Shared resources `plat dev` needs inside a fresh emulator (buckets, tables,
|
|
134
|
-
* user pool) and the matching runtime config
|
|
258
|
+
* user pool, realtime API, mail domain) and the matching runtime config
|
|
259
|
+
* (`target: 'emulator'`).
|
|
135
260
|
*/
|
|
136
261
|
export declare function ensureLocalPlatform(engine: Engine, opts: {
|
|
137
262
|
domain?: string;
|
package/dist/index.js
CHANGED
|
@@ -15,12 +15,16 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { GetCallerIdentityCommand } from '@aws-sdk/client-sts';
|
|
17
17
|
import { createClients } from './clients.js';
|
|
18
|
+
import { ensureRealtimePlatform } from './drivers/appsync.js';
|
|
18
19
|
import { putObject } from './drivers/s3.js';
|
|
19
20
|
import { ensureLocal } from './local.js';
|
|
20
|
-
import {
|
|
21
|
+
import { controlService, describeServices } from './services.js';
|
|
22
|
+
import { deployStage, destroyStage, expireStorage, listStageResources, rollbackStage } from './stage.js';
|
|
21
23
|
export * from './drivers/index.js';
|
|
22
24
|
export * from './emulator.js';
|
|
25
|
+
export * as images from './images.js';
|
|
23
26
|
export * as policies from './policy.js';
|
|
27
|
+
export { ServiceNotFoundError } from './services.js';
|
|
24
28
|
export { hostFor } from './stage.js';
|
|
25
29
|
export { cacheControlFor, contentTypeFor } from './static.js';
|
|
26
30
|
export { errorName, isNotFound, isNotImplemented, platformTags, retry, stageTags, waitFor } from './util.js';
|
|
@@ -33,8 +37,12 @@ export function createEngine(opts) {
|
|
|
33
37
|
deployStage: (input) => deployStage(ctx, input),
|
|
34
38
|
rollbackStage: (input) => rollbackStage(ctx, input),
|
|
35
39
|
destroyStage: (input) => destroyStage(ctx, input),
|
|
40
|
+
expireStorage: (input) => expireStorage(ctx, input),
|
|
36
41
|
listStageResources: (app, stage) => listStageResources(ctx, app, stage),
|
|
37
42
|
putArtifact: (platform, key, body) => putObject(ctx, { bucket: platform.artifactsBucket, key, body }),
|
|
43
|
+
ensureRealtimePlatform: (platform) => ensureRealtimePlatform(ctx, platform),
|
|
44
|
+
describeServices: (input) => describeServices(ctx, input),
|
|
45
|
+
controlService: (input) => controlService(ctx, input),
|
|
38
46
|
};
|
|
39
47
|
contexts.set(engine, ctx);
|
|
40
48
|
return engine;
|
|
@@ -64,7 +72,8 @@ function createContext(opts) {
|
|
|
64
72
|
}
|
|
65
73
|
/**
|
|
66
74
|
* Shared resources `plat dev` needs inside a fresh emulator (buckets, tables,
|
|
67
|
-
* user pool) and the matching runtime config
|
|
75
|
+
* user pool, realtime API, mail domain) and the matching runtime config
|
|
76
|
+
* (`target: 'emulator'`).
|
|
68
77
|
*/
|
|
69
78
|
export async function ensureLocalPlatform(engine, opts) {
|
|
70
79
|
return ensureLocal(engineContext(engine), opts);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAS/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CA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AI,CAAC,MAAM;QACnB,MAAM;QACN,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5F,SAAS,EAAE,GAAG,EAAE;YACd,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,wBAAwB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAQ,CAAC,CAAC;YACvF,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAc,EACd,IAA4D;IAE5D,OAAO,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/local.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateApiCommand } from '@aws-sdk/client-appsync';
|
|
2
|
+
import { CreateFunctionCommand, GetFunctionConfigurationCommand } from '@aws-sdk/client-lambda';
|
|
3
|
+
import { emailDomain, NODE_RUNTIME, platformNames, } from '@ericminassian/platform-core';
|
|
4
|
+
import { Hash } from '@smithy/hash-node';
|
|
5
|
+
import { SignatureV4 } from '@smithy/signature-v4';
|
|
6
|
+
import { strToU8, zipSync } from 'fflate';
|
|
7
|
+
import { findEventApi } from './drivers/appsync.js';
|
|
2
8
|
import { ensureUserPool } from './drivers/cognito.js';
|
|
3
9
|
import { ensureTable } from './drivers/dynamodb.js';
|
|
10
|
+
import { ensureRepository } from './drivers/ecr.js';
|
|
11
|
+
import { ensureCluster } from './drivers/ecs.js';
|
|
12
|
+
import { ensureRole } from './drivers/iam.js';
|
|
4
13
|
import { ensureBucket } from './drivers/s3.js';
|
|
5
|
-
import {
|
|
14
|
+
import { ensureEmailIdentity } from './drivers/ses.js';
|
|
15
|
+
import { containerExecutionPolicy, containerSchedulerPolicy, serviceTrustPolicy } from './policy.js';
|
|
16
|
+
import { ignoreNotFound, platformTags, sendRaw, waitFor } from './util.js';
|
|
6
17
|
/**
|
|
7
18
|
* Inside a fresh AWS Emulator, create the shared resources a stage deploy
|
|
8
19
|
* expects (the ones the foundation stack holds in AWS, minus CloudFront, DNS,
|
|
@@ -17,6 +28,7 @@ export async function ensureLocal(ctx, opts) {
|
|
|
17
28
|
const artifactsBucket = platformNames.artifactsBucket(accountId, region);
|
|
18
29
|
const sitesBucket = platformNames.sitesBucket(accountId, region);
|
|
19
30
|
const storageBucket = platformNames.storageBucket(accountId, region);
|
|
31
|
+
const domain = opts.domain ?? 'localhost';
|
|
20
32
|
await ensureBucket(ctx, { name: artifactsBucket, versioned: true, tags });
|
|
21
33
|
await ensureBucket(ctx, { name: sitesBucket, tags });
|
|
22
34
|
await ensureBucket(ctx, {
|
|
@@ -24,10 +36,7 @@ export async function ensureLocal(ctx, opts) {
|
|
|
24
36
|
tags,
|
|
25
37
|
cors: [
|
|
26
38
|
{
|
|
27
|
-
AllowedOrigins: [
|
|
28
|
-
`http://*.${opts.domain ?? 'localhost'}:${opts.port}`,
|
|
29
|
-
`http://localhost:${opts.port}`,
|
|
30
|
-
],
|
|
39
|
+
AllowedOrigins: [`http://*.${domain}:${opts.port}`, `http://localhost:${opts.port}`],
|
|
31
40
|
AllowedMethods: ['GET', 'PUT', 'POST', 'HEAD'],
|
|
32
41
|
AllowedHeaders: ['*'],
|
|
33
42
|
ExposeHeaders: ['ETag'],
|
|
@@ -50,12 +59,18 @@ export async function ensureLocal(ctx, opts) {
|
|
|
50
59
|
tags,
|
|
51
60
|
});
|
|
52
61
|
const userPoolId = await ensureUserPool(ctx, { name: platformNames.userPool, tags });
|
|
62
|
+
const realtime = await ensureLocalRealtime(ctx, tags);
|
|
63
|
+
// Stages get real tenants and configuration sets in the emulator, so the domain they're
|
|
64
|
+
// associated with must exist. It never verifies and nothing is sent: local stages hand
|
|
65
|
+
// their mail to the CLI (`email.mode: 'local'`).
|
|
66
|
+
const mail = await ensureEmailIdentity(ctx, { domain: emailDomain(domain), tags });
|
|
67
|
+
const containers = await ensureLocalContainers(ctx, tags);
|
|
53
68
|
return {
|
|
54
69
|
v: 1,
|
|
55
70
|
target: 'emulator',
|
|
56
71
|
accountId,
|
|
57
72
|
region,
|
|
58
|
-
domain
|
|
73
|
+
domain,
|
|
59
74
|
publicScheme: 'http',
|
|
60
75
|
publicPort: opts.port,
|
|
61
76
|
artifactsBucket,
|
|
@@ -66,6 +81,206 @@ export async function ensureLocal(ctx, opts) {
|
|
|
66
81
|
userPoolId,
|
|
67
82
|
loginUrl: `http://localhost:${opts.port}`,
|
|
68
83
|
jwksBaseUrl: opts.jwksBaseUrl,
|
|
84
|
+
realtime,
|
|
85
|
+
email: { domain: mail.domain, identityArn: mail.arn },
|
|
86
|
+
containers,
|
|
69
87
|
};
|
|
70
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Container compute inside the emulator, like the foundation's: a Fargate
|
|
91
|
+
* cluster, the image repository, public subnets with a security group, and
|
|
92
|
+
* the execution and scheduler roles. The emulator's ECS runs tasks
|
|
93
|
+
* (simulated: it pulls nothing and runs no code) only when their subnet
|
|
94
|
+
* routes to an internet gateway, which its default VPC lacks; this adds one.
|
|
95
|
+
*/
|
|
96
|
+
async function ensureLocalContainers(ctx, tags) {
|
|
97
|
+
const accountId = await ctx.accountId();
|
|
98
|
+
const cluster = platformNames.containerCluster;
|
|
99
|
+
await ensureCluster(ctx, { name: cluster, tags });
|
|
100
|
+
const repository = await ensureRepository(ctx, { name: platformNames.containerRepository, tags });
|
|
101
|
+
const execution = await ensureRole(ctx, {
|
|
102
|
+
name: platformNames.containerExecutionRole,
|
|
103
|
+
trust: serviceTrustPolicy('ecs-tasks.amazonaws.com'),
|
|
104
|
+
description: 'plat dev: pulls platform container images and writes their logs',
|
|
105
|
+
inlinePolicies: {
|
|
106
|
+
execution: containerExecutionPolicy({ region: ctx.region, accountId, repository: repository.name }),
|
|
107
|
+
},
|
|
108
|
+
tags,
|
|
109
|
+
});
|
|
110
|
+
const scheduler = await ensureRole(ctx, {
|
|
111
|
+
name: platformNames.containerSchedulerRole,
|
|
112
|
+
trust: serviceTrustPolicy('scheduler.amazonaws.com'),
|
|
113
|
+
description: "plat dev: scales stages' containers (preview stop schedules)",
|
|
114
|
+
inlinePolicies: { scale: containerSchedulerPolicy({ region: ctx.region, accountId, cluster }) },
|
|
115
|
+
tags,
|
|
116
|
+
});
|
|
117
|
+
const network = await ensureLocalNetwork(ctx);
|
|
118
|
+
return {
|
|
119
|
+
cluster,
|
|
120
|
+
subnets: network.subnets,
|
|
121
|
+
securityGroups: [network.securityGroup],
|
|
122
|
+
repository: repository.name,
|
|
123
|
+
// The emulator's CreateRepository answers with its own host and port, but its ECS only
|
|
124
|
+
// resolves images named the way AWS names them.
|
|
125
|
+
repositoryUri: `${repository.registryId}.dkr.ecr.${ctx.region}.amazonaws.com/${repository.name}`,
|
|
126
|
+
executionRoleArn: execution.arn,
|
|
127
|
+
schedulerRoleArn: scheduler.arn,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The default VPC's subnets, made public (an internet gateway and a default
|
|
132
|
+
* route, which AWS's default VPCs come with), and the containers' security
|
|
133
|
+
* group in it.
|
|
134
|
+
*/
|
|
135
|
+
async function ensureLocalNetwork(ctx) {
|
|
136
|
+
const vpcs = await ec2(ctx, 'DescribeVpcs', { 'Filter.1.Name': 'is-default', 'Filter.1.Value.1': 'true' });
|
|
137
|
+
const vpcId = xmlValues(vpcs, 'vpcId')[0];
|
|
138
|
+
if (!vpcId)
|
|
139
|
+
throw new Error('the AWS Emulator has no default VPC');
|
|
140
|
+
const inVpc = { 'Filter.1.Name': 'vpc-id', 'Filter.1.Value.1': vpcId };
|
|
141
|
+
const subnets = [...new Set(xmlValues(await ec2(ctx, 'DescribeSubnets', inVpc), 'subnetId'))].toSorted();
|
|
142
|
+
if (!subnets.length)
|
|
143
|
+
throw new Error(`the AWS Emulator's default VPC ${vpcId} has no subnets`);
|
|
144
|
+
const gateways = await ec2(ctx, 'DescribeInternetGateways', {
|
|
145
|
+
'Filter.1.Name': 'attachment.vpc-id',
|
|
146
|
+
'Filter.1.Value.1': vpcId,
|
|
147
|
+
});
|
|
148
|
+
let gateway = xmlValues(gateways, 'internetGatewayId')[0];
|
|
149
|
+
if (!gateway) {
|
|
150
|
+
gateway = xmlValues(await ec2(ctx, 'CreateInternetGateway', {}), 'internetGatewayId')[0];
|
|
151
|
+
await ec2(ctx, 'AttachInternetGateway', { InternetGatewayId: gateway, VpcId: vpcId });
|
|
152
|
+
}
|
|
153
|
+
const tables = await ec2(ctx, 'DescribeRouteTables', {
|
|
154
|
+
...inVpc,
|
|
155
|
+
'Filter.2.Name': 'association.main',
|
|
156
|
+
'Filter.2.Value.1': 'true',
|
|
157
|
+
});
|
|
158
|
+
const table = xmlValues(tables, 'routeTableId')[0];
|
|
159
|
+
if (table && !xmlValues(tables, 'destinationCidrBlock').includes('0.0.0.0/0')) {
|
|
160
|
+
await ec2(ctx, 'CreateRoute', {
|
|
161
|
+
RouteTableId: table,
|
|
162
|
+
DestinationCidrBlock: '0.0.0.0/0',
|
|
163
|
+
GatewayId: gateway,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const groups = await ec2(ctx, 'DescribeSecurityGroups', {
|
|
167
|
+
...inVpc,
|
|
168
|
+
'Filter.2.Name': 'group-name',
|
|
169
|
+
'Filter.2.Value.1': platformNames.containerNetwork,
|
|
170
|
+
});
|
|
171
|
+
const securityGroup = xmlValues(groups, 'groupId')[0] ??
|
|
172
|
+
xmlValues(await ec2(ctx, 'CreateSecurityGroup', {
|
|
173
|
+
GroupName: platformNames.containerNetwork,
|
|
174
|
+
GroupDescription: 'Platform containers: no inbound traffic, all outbound',
|
|
175
|
+
VpcId: vpcId,
|
|
176
|
+
}), 'groupId')[0];
|
|
177
|
+
return { subnets, securityGroup };
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* One EC2 Query API call against the emulator, signed with the SDK's SigV4
|
|
181
|
+
* signer and sent through an SDK client's endpoint, credentials and HTTP
|
|
182
|
+
* handler. These few VPC calls are the engine's only EC2 calls, which
|
|
183
|
+
* doesn't warrant the SDK's EC2 client, one of its largest.
|
|
184
|
+
*/
|
|
185
|
+
async function ec2(ctx, action, params) {
|
|
186
|
+
const client = ctx.clients.sts;
|
|
187
|
+
const endpoint = await client.config.endpoint();
|
|
188
|
+
const body = new URLSearchParams({ Action: action, Version: '2016-11-15', ...params }).toString();
|
|
189
|
+
const signer = new SignatureV4({
|
|
190
|
+
service: 'ec2',
|
|
191
|
+
region: ctx.region,
|
|
192
|
+
credentials: client.config.credentials,
|
|
193
|
+
sha256: Hash.bind(null, 'sha256'),
|
|
194
|
+
});
|
|
195
|
+
const request = await signer.sign({
|
|
196
|
+
method: 'POST',
|
|
197
|
+
protocol: endpoint.protocol,
|
|
198
|
+
hostname: endpoint.hostname,
|
|
199
|
+
...(endpoint.port ? { port: endpoint.port } : {}),
|
|
200
|
+
path: '/',
|
|
201
|
+
query: {},
|
|
202
|
+
headers: {
|
|
203
|
+
'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
|
|
204
|
+
host: endpoint.port ? `${endpoint.hostname}:${endpoint.port}` : endpoint.hostname,
|
|
205
|
+
'content-length': String(Buffer.byteLength(body)),
|
|
206
|
+
},
|
|
207
|
+
body,
|
|
208
|
+
});
|
|
209
|
+
const res = await sendRaw(client, request);
|
|
210
|
+
const xml = new TextDecoder().decode(res.body);
|
|
211
|
+
if (res.statusCode !== 200) {
|
|
212
|
+
const [code] = xmlValues(xml, 'Code');
|
|
213
|
+
const [message] = xmlValues(xml, 'Message');
|
|
214
|
+
throw new Error(`EC2 ${action} failed in the AWS Emulator: ${code ?? res.statusCode} ${message ?? xml}`);
|
|
215
|
+
}
|
|
216
|
+
return xml;
|
|
217
|
+
}
|
|
218
|
+
function xmlValues(xml, element) {
|
|
219
|
+
return [...xml.matchAll(new RegExp(`<${element}>([^<]*)</${element}>`, 'g'))].map((m) => m[1]);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The emulator never invokes an Event API's Lambda authorizer (it accepts any
|
|
223
|
+
* token), but the API still needs one to accept the AWS_LAMBDA mode signed-in
|
|
224
|
+
* namespaces use. So this one only satisfies the API's configuration.
|
|
225
|
+
*/
|
|
226
|
+
const STUB_AUTHORIZER = `// plat dev: the AWS Emulator doesn't invoke Event API authorizers, so subscribe tokens
|
|
227
|
+
// aren't checked locally. The platform's real authorizer runs in AWS.
|
|
228
|
+
export const handler = async () => ({ isAuthorized: true });
|
|
229
|
+
`;
|
|
230
|
+
/**
|
|
231
|
+
* The platform's Event API inside the emulator, configured like the
|
|
232
|
+
* foundation's (same auth providers and defaults). The emulator serves its
|
|
233
|
+
* HTTP and realtime endpoints on local ports (`dns` is `127.0.0.1:<port>`).
|
|
234
|
+
*/
|
|
235
|
+
async function ensureLocalRealtime(ctx, tags) {
|
|
236
|
+
let api = await findEventApi(ctx, platformNames.realtimeApi);
|
|
237
|
+
if (!api) {
|
|
238
|
+
const authorizerArn = await ensureStubAuthorizer(ctx, tags);
|
|
239
|
+
const res = await ctx.clients.appsync.send(new CreateApiCommand({
|
|
240
|
+
name: platformNames.realtimeApi,
|
|
241
|
+
tags,
|
|
242
|
+
eventConfig: {
|
|
243
|
+
authProviders: [
|
|
244
|
+
{ authType: 'API_KEY' },
|
|
245
|
+
{ authType: 'AWS_IAM' },
|
|
246
|
+
{ authType: 'AWS_LAMBDA', lambdaAuthorizerConfig: { authorizerUri: authorizerArn } },
|
|
247
|
+
],
|
|
248
|
+
connectionAuthModes: [{ authType: 'API_KEY' }, { authType: 'AWS_LAMBDA' }],
|
|
249
|
+
defaultPublishAuthModes: [{ authType: 'AWS_IAM' }],
|
|
250
|
+
defaultSubscribeAuthModes: [{ authType: 'AWS_LAMBDA' }],
|
|
251
|
+
},
|
|
252
|
+
}));
|
|
253
|
+
api = res.api;
|
|
254
|
+
}
|
|
255
|
+
const httpDomain = api?.dns?.HTTP;
|
|
256
|
+
const realtimeDomain = api?.dns?.REALTIME;
|
|
257
|
+
if (!api?.apiId || !httpDomain || !realtimeDomain)
|
|
258
|
+
throw new Error('the AWS Emulator returned an Event API without endpoints');
|
|
259
|
+
return { apiId: api.apiId, httpDomain, realtimeDomain };
|
|
260
|
+
}
|
|
261
|
+
async function ensureStubAuthorizer(ctx, tags) {
|
|
262
|
+
const name = platformNames.realtimeAuthorizer;
|
|
263
|
+
const existing = await ignoreNotFound(ctx.clients.lambda.send(new GetFunctionConfigurationCommand({ FunctionName: name })));
|
|
264
|
+
if (existing?.FunctionArn)
|
|
265
|
+
return existing.FunctionArn;
|
|
266
|
+
const role = await ensureRole(ctx, {
|
|
267
|
+
name,
|
|
268
|
+
trust: serviceTrustPolicy('lambda.amazonaws.com'),
|
|
269
|
+
description: 'plat dev stub realtime authorizer',
|
|
270
|
+
tags,
|
|
271
|
+
});
|
|
272
|
+
const res = await ctx.clients.lambda.send(new CreateFunctionCommand({
|
|
273
|
+
FunctionName: name,
|
|
274
|
+
Role: role.arn,
|
|
275
|
+
Runtime: NODE_RUNTIME,
|
|
276
|
+
Handler: 'index.handler',
|
|
277
|
+
Code: { ZipFile: zipSync({ 'index.mjs': strToU8(STUB_AUTHORIZER) }) },
|
|
278
|
+
Tags: tags,
|
|
279
|
+
}));
|
|
280
|
+
await waitFor(`${name} to become active`, async () => {
|
|
281
|
+
const c = await ctx.clients.lambda.send(new GetFunctionConfigurationCommand({ FunctionName: name }));
|
|
282
|
+
return c.State === 'Active';
|
|
283
|
+
});
|
|
284
|
+
return res.FunctionArn;
|
|
285
|
+
}
|
|
71
286
|
//# sourceMappingURL=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O,QAAQ,CAAC,WAAW,CAAC;IACvD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE;QACjC,IAAI;QACJ,KAAK,EAAE,kBAAkB,CAAC,sBAAsB,CAAC;QACjD,WAAW,EAAE,mCAAmC;QAChD,IAAI;KACL,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CACvC,IAAI,qBAAqB,CAAC;QACxB,YAAY,EAAE,IAAI;QAClB,IAAI,EAAE,IAAI,CAAC,GAAG;QACd,OAAO,EAAE,YAAY;QACrB,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE;QACrE,IAAI,EAAE,IAAI;KACX,CAAC,CACH,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,IAAI,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,+BAA+B,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACrG,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,WAAY,CAAC;AAC1B,CAAC"}
|
package/dist/policy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PlatformRuntimeConfig, type ResolvedManifest } from '@ericminassian/platform-core';
|
|
1
|
+
import { type EmailRuntimeConfig, type ContainersRuntimeConfig, type PlatformRuntimeConfig, type ResolvedManifest } from '@ericminassian/platform-core';
|
|
2
2
|
import { type PolicyDocument } from './util.ts';
|
|
3
3
|
export interface StagePolicyInput {
|
|
4
4
|
app: string;
|
|
@@ -6,9 +6,18 @@ export interface StagePolicyInput {
|
|
|
6
6
|
region: string;
|
|
7
7
|
accountId: string;
|
|
8
8
|
manifest: ResolvedManifest;
|
|
9
|
-
platform: Pick<PlatformRuntimeConfig, 'storageBucket'>;
|
|
9
|
+
platform: Pick<PlatformRuntimeConfig, 'storageBucket' | 'telemetryTable' | 'realtime' | 'email'>;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/** A channel namespace's ARN in the platform's Event API. */
|
|
12
|
+
export declare function channelNamespaceArn(region: string, accountId: string, apiId: string, namespace: string): string;
|
|
13
|
+
/** An SES configuration set's ARN (each stage's is `names.emailTenant`). */
|
|
14
|
+
export declare function configurationSetArn(region: string, accountId: string, name: string): string;
|
|
15
|
+
/** An SES identity's ARN (the platform's is its mail domain). */
|
|
16
|
+
export declare function emailIdentityArn(region: string, accountId: string, identity: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Trust for per-stage roles: the worker and Web Function (Lambda), schedules
|
|
19
|
+
* (Scheduler) and long-running services (ECS tasks).
|
|
20
|
+
*/
|
|
12
21
|
export declare function stageTrustPolicy(): PolicyDocument;
|
|
13
22
|
/**
|
|
14
23
|
* Exactly what the runtime SDK needs for one stage, nothing more. Every
|
|
@@ -26,6 +35,16 @@ export declare function boundaryPolicy(input: {
|
|
|
26
35
|
region: string;
|
|
27
36
|
accountId: string;
|
|
28
37
|
storageBucket: string;
|
|
38
|
+
/** The platform's Event API; stage roles may publish to its stage namespaces. */
|
|
39
|
+
realtimeApiId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The platform's mail domain and the table holding usage counters; stage roles may send as
|
|
42
|
+
* a stage tenant and count what they send.
|
|
43
|
+
*/
|
|
44
|
+
email?: {
|
|
45
|
+
identityArn: string;
|
|
46
|
+
usageTable: string;
|
|
47
|
+
};
|
|
29
48
|
}): PolicyDocument;
|
|
30
49
|
/**
|
|
31
50
|
* The control plane (API + deployer + telemetry) manages every stage's
|
|
@@ -35,7 +54,31 @@ export declare function boundaryPolicy(input: {
|
|
|
35
54
|
export declare function controlPlanePolicy(input: {
|
|
36
55
|
region: string;
|
|
37
56
|
accountId: string;
|
|
38
|
-
runtime: Pick<PlatformRuntimeConfig, 'artifactsBucket' | 'sitesBucket' | 'storageBucket' | 'kvsArn' | 'userPoolId' | 'boundaryPolicyArn' | 'alertsTopicArn'
|
|
57
|
+
runtime: Pick<PlatformRuntimeConfig, 'artifactsBucket' | 'sitesBucket' | 'storageBucket' | 'kvsArn' | 'userPoolId' | 'boundaryPolicyArn' | 'alertsTopicArn' | 'distributionArn'> & {
|
|
58
|
+
realtime?: Pick<NonNullable<PlatformRuntimeConfig['realtime']>, 'apiId'>;
|
|
59
|
+
email?: Pick<EmailRuntimeConfig, 'identityArn'>;
|
|
60
|
+
containers?: Pick<ContainersRuntimeConfig, 'cluster' | 'repository' | 'executionRoleArn' | 'schedulerRoleArn'>;
|
|
61
|
+
};
|
|
62
|
+
}): PolicyDocument;
|
|
63
|
+
/**
|
|
64
|
+
* What ECS needs to start a platform container: pull its image and ship its
|
|
65
|
+
* logs to the stage's service log groups (created by the engine). The app's
|
|
66
|
+
* own code runs as the stage role, never as this one.
|
|
67
|
+
*/
|
|
68
|
+
export declare function containerExecutionPolicy(input: {
|
|
69
|
+
region: string;
|
|
70
|
+
accountId: string;
|
|
71
|
+
repository: string;
|
|
72
|
+
}): PolicyDocument;
|
|
73
|
+
/**
|
|
74
|
+
* Assumed by EventBridge Scheduler for the one-shot schedules that stop a
|
|
75
|
+
* preview's services. It can only change a stage service's desired count
|
|
76
|
+
* (the schedule's input is fixed by the engine); app code never holds it.
|
|
77
|
+
*/
|
|
78
|
+
export declare function containerSchedulerPolicy(input: {
|
|
79
|
+
region: string;
|
|
80
|
+
accountId: string;
|
|
81
|
+
cluster: string;
|
|
39
82
|
}): PolicyDocument;
|
|
40
83
|
export declare function serviceTrustPolicy(...services: string[]): PolicyDocument;
|
|
41
84
|
export declare const BOUNDARY_POLICY_NAME: "platform-app-boundary";
|