@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/dist/api.js
CHANGED
|
@@ -1,2 +1,695 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Control plane API records and payloads, as schemas: the control plane
|
|
3
|
+
* encodes responses and decodes requests with them, the console and the CLI
|
|
4
|
+
* read the same shapes. The endpoints themselves are `PlatformApi`
|
|
5
|
+
* (`@ericminassian/platform-core/platform-api`). All routes live under `/v1`.
|
|
6
|
+
*
|
|
7
|
+
* Optional fields accept `undefined`, so a record built with spreads of
|
|
8
|
+
* possibly-missing values encodes; JSON drops them either way.
|
|
9
|
+
*/
|
|
10
|
+
import { Schema, SchemaGetter } from 'effect';
|
|
11
|
+
import { MemberRole } from './config.js';
|
|
12
|
+
import { ResolvedManifest } from './manifest.js';
|
|
13
|
+
import { Resolution, TelemetryEvent } from './telemetry.js';
|
|
14
|
+
import { WEB_COMPUTE, WEB_COMPUTE_SETTINGS } from './web-compute.js';
|
|
15
|
+
const optional = Schema.optional;
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Records
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
export const AppRecord = Schema.Struct({
|
|
20
|
+
name: Schema.String,
|
|
21
|
+
/** GitHub `owner/name` allowed to deploy this app from CI. */
|
|
22
|
+
repo: Schema.String,
|
|
23
|
+
description: optional(Schema.String),
|
|
24
|
+
/** GitHub usernames who can manage the app (admins can manage everything). */
|
|
25
|
+
owners: Schema.Array(Schema.String),
|
|
26
|
+
createdBy: Schema.String,
|
|
27
|
+
createdAt: Schema.String,
|
|
28
|
+
});
|
|
29
|
+
export const StageStatus = Schema.Literals(['active', 'deploying', 'failed', 'destroying', 'destroyed']);
|
|
30
|
+
/** How a server runs (`WebCompute`). */
|
|
31
|
+
export const WebComputeMode = Schema.Literals(WEB_COMPUTE);
|
|
32
|
+
/** Days in a row the other mode was cheaper enough to switch to (`ComputeStreak`). */
|
|
33
|
+
export const ComputeStreakSchema = Schema.Struct({
|
|
34
|
+
to: WebComputeMode,
|
|
35
|
+
days: Schema.Finite,
|
|
36
|
+
day: Schema.String,
|
|
37
|
+
});
|
|
38
|
+
/** A prod stage's monthly cost in each mode, estimated daily from its traffic (`simulateWebCompute`). */
|
|
39
|
+
export const ComputeEstimate = Schema.Struct({
|
|
40
|
+
at: Schema.String,
|
|
41
|
+
request: Schema.Struct({ monthlyUsd: Schema.Finite, coldStartsPerMonth: Schema.Finite }),
|
|
42
|
+
instance: Schema.Struct({ monthlyUsd: Schema.Finite, environmentHoursPerMonth: Schema.Finite }),
|
|
43
|
+
requestsPerMonth: Schema.Finite,
|
|
44
|
+
/** Days of traffic the month is extrapolated from. */
|
|
45
|
+
days: Schema.Finite,
|
|
46
|
+
});
|
|
47
|
+
export const StageRecord = Schema.Struct({
|
|
48
|
+
app: Schema.String,
|
|
49
|
+
stage: Schema.String,
|
|
50
|
+
host: Schema.String,
|
|
51
|
+
url: Schema.String,
|
|
52
|
+
status: StageStatus,
|
|
53
|
+
preview: Schema.Boolean,
|
|
54
|
+
currentDeployment: optional(Schema.String),
|
|
55
|
+
previousDeployment: optional(Schema.String),
|
|
56
|
+
/** The server builds: Web Function revision ids, or request-mode function versions. */
|
|
57
|
+
currentRevision: optional(Schema.String),
|
|
58
|
+
previousRevision: optional(Schema.String),
|
|
59
|
+
/** How the live deployment's server runs. */
|
|
60
|
+
compute: optional(WebComputeMode),
|
|
61
|
+
/** Prod stages with a server: what each mode would cost a month. */
|
|
62
|
+
computeEstimate: optional(ComputeEstimate),
|
|
63
|
+
/** Set while the other mode is cheaper enough; at three days the platform switches. */
|
|
64
|
+
computeStreak: optional(ComputeStreakSchema),
|
|
65
|
+
createdAt: Schema.String,
|
|
66
|
+
updatedAt: Schema.String,
|
|
67
|
+
});
|
|
68
|
+
export const DeploymentStatus = Schema.Literals([
|
|
69
|
+
'awaiting_upload',
|
|
70
|
+
'queued',
|
|
71
|
+
'running',
|
|
72
|
+
'succeeded',
|
|
73
|
+
'failed',
|
|
74
|
+
'rolled_back',
|
|
75
|
+
]);
|
|
76
|
+
export const DeploymentEventEntry = Schema.Struct({
|
|
77
|
+
ts: Schema.Finite,
|
|
78
|
+
level: Schema.Literals(['info', 'warn', 'error']),
|
|
79
|
+
msg: Schema.String,
|
|
80
|
+
/** Resource the step acted on, e.g. `table foo--prod`. */
|
|
81
|
+
resource: optional(Schema.String),
|
|
82
|
+
});
|
|
83
|
+
export const DeploymentRecord = Schema.Struct({
|
|
84
|
+
id: Schema.String,
|
|
85
|
+
app: Schema.String,
|
|
86
|
+
stage: Schema.String,
|
|
87
|
+
status: DeploymentStatus,
|
|
88
|
+
/** GitHub username, `ci:<repo>` for OIDC deploys, or `platform` for a compute switch. */
|
|
89
|
+
actor: Schema.String,
|
|
90
|
+
commit: optional(Schema.String),
|
|
91
|
+
ref: optional(Schema.String),
|
|
92
|
+
message: optional(Schema.String),
|
|
93
|
+
/** The `@ericminassian/platform` version its bundles were built with; absent before 0.4.0. */
|
|
94
|
+
sdk: optional(Schema.String),
|
|
95
|
+
manifest: optional(ResolvedManifest),
|
|
96
|
+
/** How it runs the server. */
|
|
97
|
+
compute: optional(WebComputeMode),
|
|
98
|
+
/**
|
|
99
|
+
* A switch of the server's mode that the platform made (actor `platform`):
|
|
100
|
+
* the deployment whose build this one runs again, in `compute`.
|
|
101
|
+
*/
|
|
102
|
+
computeSwitchOf: optional(Schema.String),
|
|
103
|
+
url: optional(Schema.String),
|
|
104
|
+
error: optional(Schema.String),
|
|
105
|
+
events: Schema.Array(DeploymentEventEntry),
|
|
106
|
+
createdAt: Schema.String,
|
|
107
|
+
startedAt: optional(Schema.String),
|
|
108
|
+
finishedAt: optional(Schema.String),
|
|
109
|
+
});
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
// Session
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
export const MeResponse = Schema.Struct({ github: Schema.String, role: MemberRole });
|
|
114
|
+
export const CliLoginRequest = Schema.Struct({
|
|
115
|
+
/** A GitHub token for the user (e.g. `gh auth token`); used once to identify them. */
|
|
116
|
+
githubToken: Schema.String.check(Schema.isNonEmpty({ message: 'githubToken is required' })),
|
|
117
|
+
});
|
|
118
|
+
export const CliLoginResponse = Schema.Struct({
|
|
119
|
+
token: Schema.String,
|
|
120
|
+
github: Schema.String,
|
|
121
|
+
role: MemberRole,
|
|
122
|
+
expiresAt: Schema.String,
|
|
123
|
+
});
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// Apps
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
/** GitHub `owner/name`. */
|
|
128
|
+
export const REPO_PATTERN = /^[A-Za-z0-9-]{1,39}\/[A-Za-z0-9._-]{1,100}$/;
|
|
129
|
+
const Repo = Schema.Trim.check(Schema.isPattern(REPO_PATTERN, { message: 'repo must be "owner/name"' }));
|
|
130
|
+
/** Longer descriptions are cut to 200 characters rather than refused. */
|
|
131
|
+
const Description = Schema.String.pipe(Schema.decode({
|
|
132
|
+
decode: SchemaGetter.transform((s) => s.slice(0, 200)),
|
|
133
|
+
encode: SchemaGetter.transform((s) => s),
|
|
134
|
+
}));
|
|
135
|
+
export const CreateAppRequest = Schema.Struct({
|
|
136
|
+
/** Checked against the naming rules and reserved names by the server. */
|
|
137
|
+
name: Schema.Trim,
|
|
138
|
+
repo: Repo,
|
|
139
|
+
description: optional(Description),
|
|
140
|
+
});
|
|
141
|
+
export const UpdateAppRequest = Schema.Struct({
|
|
142
|
+
description: optional(Description),
|
|
143
|
+
repo: optional(Repo),
|
|
144
|
+
/** The server removes duplicates. */
|
|
145
|
+
owners: optional(Schema.Array(Schema.String).check(Schema.isMinLength(1, { message: 'owners must be a non-empty list' }))),
|
|
146
|
+
});
|
|
147
|
+
export const AppHealth = Schema.Struct({
|
|
148
|
+
up: Schema.NullOr(Schema.Boolean),
|
|
149
|
+
reqPerMin: Schema.Finite,
|
|
150
|
+
errorRate: Schema.Finite,
|
|
151
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
152
|
+
});
|
|
153
|
+
export const AppSummary = Schema.Struct({
|
|
154
|
+
app: AppRecord,
|
|
155
|
+
stages: Schema.Array(StageRecord),
|
|
156
|
+
/** Prod health over the last hour (null when there is no prod stage). */
|
|
157
|
+
health: Schema.NullOr(AppHealth),
|
|
158
|
+
costMonthToDateUsd: optional(Schema.Finite),
|
|
159
|
+
lastDeployment: optional(DeploymentRecord),
|
|
160
|
+
});
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// Stages and deployments
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
/** `services.zip` holds `<service>/index.mjs` (+ `.map`) for each long-running service. */
|
|
165
|
+
export const ArtifactFile = Schema.Literals([
|
|
166
|
+
'manifest.json',
|
|
167
|
+
'server.zip',
|
|
168
|
+
'worker.zip',
|
|
169
|
+
'static.zip',
|
|
170
|
+
'services.zip',
|
|
171
|
+
]);
|
|
172
|
+
export const PresignedPost = Schema.Struct({
|
|
173
|
+
url: Schema.String,
|
|
174
|
+
fields: Schema.Record(Schema.String, Schema.String),
|
|
175
|
+
});
|
|
176
|
+
export const CreateDeploymentRequest = Schema.Struct({
|
|
177
|
+
stage: Schema.String,
|
|
178
|
+
/**
|
|
179
|
+
* The evaluated `plat.config.ts` (`ManifestInput`). The server validates it
|
|
180
|
+
* with `parseManifest` and answers 422 with every issue when it's invalid.
|
|
181
|
+
*/
|
|
182
|
+
manifest: Schema.Unknown,
|
|
183
|
+
/** Which artifacts the CLI will upload (manifest.json is always uploaded). */
|
|
184
|
+
files: optional(Schema.Array(ArtifactFile)),
|
|
185
|
+
commit: optional(Schema.String),
|
|
186
|
+
ref: optional(Schema.String),
|
|
187
|
+
message: optional(Schema.String),
|
|
188
|
+
/** The `@ericminassian/platform` version the bundles were built with (`MIN_SDK_VERSION`). */
|
|
189
|
+
sdk: optional(Schema.String),
|
|
190
|
+
});
|
|
191
|
+
export const CreateDeploymentResponse = Schema.Struct({
|
|
192
|
+
deployment: DeploymentRecord,
|
|
193
|
+
/** A form for each artifact the request listed, plus `manifest.json`. */
|
|
194
|
+
uploads: Schema.Struct({
|
|
195
|
+
'manifest.json': optional(PresignedPost),
|
|
196
|
+
'server.zip': optional(PresignedPost),
|
|
197
|
+
'worker.zip': optional(PresignedPost),
|
|
198
|
+
'static.zip': optional(PresignedPost),
|
|
199
|
+
'services.zip': optional(PresignedPost),
|
|
200
|
+
}),
|
|
201
|
+
});
|
|
202
|
+
export const RollbackRequest = Schema.Struct({
|
|
203
|
+
/** Default: the stage's previous deployment. */
|
|
204
|
+
deploymentId: optional(Schema.String),
|
|
205
|
+
});
|
|
206
|
+
export const RollbackResponse = Schema.Struct({
|
|
207
|
+
/** The deployment the stage routes to now. */
|
|
208
|
+
currentDeployment: Schema.String,
|
|
209
|
+
url: Schema.String,
|
|
210
|
+
});
|
|
211
|
+
/** Answered with 202: the stage is being torn down. */
|
|
212
|
+
export const StageDestroying = Schema.Struct({ status: Schema.Literal('destroying') });
|
|
213
|
+
/** Answered with 200: there was nothing left to destroy. */
|
|
214
|
+
export const StageDestroyed = Schema.Struct({ status: Schema.Literal('destroyed') });
|
|
215
|
+
export const DestroyStageResponse = Schema.Union([StageDestroying, StageDestroyed]);
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
// Observability
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
export const MetricsPoint = Schema.Struct({
|
|
220
|
+
ts: Schema.String,
|
|
221
|
+
req: Schema.Finite,
|
|
222
|
+
s2xx: Schema.Finite,
|
|
223
|
+
s3xx: Schema.Finite,
|
|
224
|
+
s4xx: Schema.Finite,
|
|
225
|
+
s5xx: Schema.Finite,
|
|
226
|
+
p50: Schema.NullOr(Schema.Finite),
|
|
227
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
228
|
+
p99: Schema.NullOr(Schema.Finite),
|
|
229
|
+
cold: Schema.Finite,
|
|
230
|
+
});
|
|
231
|
+
export const MetricsResponse = Schema.Struct({
|
|
232
|
+
app: Schema.String,
|
|
233
|
+
stage: Schema.String,
|
|
234
|
+
res: Resolution,
|
|
235
|
+
points: Schema.Array(MetricsPoint),
|
|
236
|
+
});
|
|
237
|
+
export const RouteStats = Schema.Struct({
|
|
238
|
+
route: Schema.String,
|
|
239
|
+
method: Schema.String,
|
|
240
|
+
req: Schema.Finite,
|
|
241
|
+
s5xx: Schema.Finite,
|
|
242
|
+
s4xx: Schema.Finite,
|
|
243
|
+
p50: Schema.NullOr(Schema.Finite),
|
|
244
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
245
|
+
});
|
|
246
|
+
export const JobKind = Schema.Literals(['queue', 'event', 'cron', 'invoke', 'service']);
|
|
247
|
+
export const JobStats = Schema.Struct({
|
|
248
|
+
kind: JobKind,
|
|
249
|
+
name: Schema.String,
|
|
250
|
+
ok: Schema.Finite,
|
|
251
|
+
error: Schema.Finite,
|
|
252
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
253
|
+
lastRun: optional(Schema.String),
|
|
254
|
+
});
|
|
255
|
+
export const JobsResponse = Schema.Struct({
|
|
256
|
+
jobs: Schema.Array(JobStats),
|
|
257
|
+
crons: Schema.Array(Schema.Struct({ name: Schema.String, schedule: Schema.String })),
|
|
258
|
+
});
|
|
259
|
+
/** A queue's jobs that aren't running: waiting for their time, and given up on. */
|
|
260
|
+
export const QueueStats = Schema.Struct({
|
|
261
|
+
name: Schema.String,
|
|
262
|
+
/** Retries and delayed sends scheduled for later. */
|
|
263
|
+
scheduled: Schema.Finite,
|
|
264
|
+
/** Its messages in the stage's dead-letter queue (of those `deadLetters` reads). */
|
|
265
|
+
deadLetter: Schema.Finite,
|
|
266
|
+
});
|
|
267
|
+
/** One message in the stage's dead-letter queue (core `readDeadLetter`). */
|
|
268
|
+
export const DeadLetterItem = Schema.Struct({
|
|
269
|
+
/** The SQS message id: what redrive and discard take. */
|
|
270
|
+
id: Schema.String,
|
|
271
|
+
/** `unknown`: a message the platform didn't write; it can only be discarded. */
|
|
272
|
+
kind: Schema.Literals(['queue', 'event', 'cron', 'invoke', 'unknown']),
|
|
273
|
+
name: Schema.String,
|
|
274
|
+
attempts: Schema.NullOr(Schema.Finite),
|
|
275
|
+
error: Schema.Struct({ name: Schema.String, message: Schema.String }),
|
|
276
|
+
/** ISO time, when the writer recorded one. */
|
|
277
|
+
failedAt: Schema.NullOr(Schema.String),
|
|
278
|
+
/** Who gave up on it: the SDK, Lambda, Scheduler or EventBridge. */
|
|
279
|
+
source: Schema.Literals(['sdk', 'lambda', 'scheduler', 'eventbridge', 'unknown']),
|
|
280
|
+
/** The message body, event detail or invoke payload, as JSON, cut to a few hundred chars. */
|
|
281
|
+
preview: Schema.String,
|
|
282
|
+
});
|
|
283
|
+
export const DeadLettersResponse = Schema.Struct({
|
|
284
|
+
/** Messages in the queue (SQS's approximate count). */
|
|
285
|
+
total: Schema.Finite,
|
|
286
|
+
/** Up to `DEAD_LETTERS_READ` of them. */
|
|
287
|
+
items: Schema.Array(DeadLetterItem),
|
|
288
|
+
});
|
|
289
|
+
/** How many dead letters the API reads for a list. */
|
|
290
|
+
export const DEAD_LETTERS_READ = 100;
|
|
291
|
+
/** Redrive or discard: the given dead letters, or (no `ids`) all of them. */
|
|
292
|
+
export const DeadLetterAction = Schema.Struct({ ids: Schema.optional(Schema.Array(Schema.String)) });
|
|
293
|
+
export const DeadLetterActionResponse = Schema.Struct({ count: Schema.Finite });
|
|
294
|
+
/** Per-namespace AppSync Events counts in one bucket (CloudWatch `Sum`s). */
|
|
295
|
+
export const RealtimePoint = Schema.Struct({
|
|
296
|
+
ts: Schema.String,
|
|
297
|
+
/** Events published (`InboundMessages`; each 5 KB counts once). */
|
|
298
|
+
events: Schema.Finite,
|
|
299
|
+
/** Successful publish requests (up to 5 events each). */
|
|
300
|
+
publishes: Schema.Finite,
|
|
301
|
+
/** Successful subscribes. */
|
|
302
|
+
subscribes: Schema.Finite,
|
|
303
|
+
/** Publishes and subscribes refused or failed (client and server errors). */
|
|
304
|
+
errors: Schema.Finite,
|
|
305
|
+
});
|
|
306
|
+
/**
|
|
307
|
+
* A stage's realtime activity. AppSync reports deliveries (`OutboundMessages`)
|
|
308
|
+
* and connections only for the whole Event API, not per namespace, so they
|
|
309
|
+
* can't be shown per app.
|
|
310
|
+
*/
|
|
311
|
+
export const RealtimeStatsResponse = Schema.Struct({
|
|
312
|
+
app: Schema.String,
|
|
313
|
+
stage: Schema.String,
|
|
314
|
+
/** False when the live deployment declares no `realtime`; the rest is then empty. */
|
|
315
|
+
enabled: Schema.Boolean,
|
|
316
|
+
subscribe: optional(Schema.Literals(['public', 'signed-in'])),
|
|
317
|
+
channels: Schema.Array(Schema.String),
|
|
318
|
+
res: Resolution,
|
|
319
|
+
totals: Schema.Struct({
|
|
320
|
+
events: Schema.Finite,
|
|
321
|
+
publishes: Schema.Finite,
|
|
322
|
+
subscribes: Schema.Finite,
|
|
323
|
+
errors: Schema.Finite,
|
|
324
|
+
}),
|
|
325
|
+
points: Schema.Array(RealtimePoint),
|
|
326
|
+
});
|
|
327
|
+
/** One custom metric (`Metrics.count`/`value`) in one bucket: how many values, and their sum. */
|
|
328
|
+
export const CustomMetricPoint = Schema.Struct({
|
|
329
|
+
ts: Schema.String,
|
|
330
|
+
count: Schema.Finite,
|
|
331
|
+
sum: Schema.Finite,
|
|
332
|
+
});
|
|
333
|
+
/**
|
|
334
|
+
* A custom metric over the range. `Metrics.count(name, n)` records `n` with
|
|
335
|
+
* unit `count`, so `sum` is the total; for `Metrics.value`, `sum / count` is
|
|
336
|
+
* the average.
|
|
337
|
+
*/
|
|
338
|
+
export const CustomMetricStats = Schema.Struct({
|
|
339
|
+
name: Schema.String,
|
|
340
|
+
unit: optional(Schema.String),
|
|
341
|
+
count: Schema.Finite,
|
|
342
|
+
sum: Schema.Finite,
|
|
343
|
+
/** One per bucket in the range, zero-filled. */
|
|
344
|
+
points: Schema.Array(CustomMetricPoint),
|
|
345
|
+
});
|
|
346
|
+
/** A stage's custom metrics recorded in the range, by name. */
|
|
347
|
+
export const CustomMetricsResponse = Schema.Struct({
|
|
348
|
+
app: Schema.String,
|
|
349
|
+
stage: Schema.String,
|
|
350
|
+
res: Resolution,
|
|
351
|
+
metrics: Schema.Array(CustomMetricStats),
|
|
352
|
+
});
|
|
353
|
+
/** One rate limit's checks in one bucket. */
|
|
354
|
+
export const LimitPoint = Schema.Struct({
|
|
355
|
+
ts: Schema.String,
|
|
356
|
+
allowed: Schema.Finite,
|
|
357
|
+
denied: Schema.Finite,
|
|
358
|
+
});
|
|
359
|
+
/** A rate limit's checks over the range, by its name in `RateLimits`. */
|
|
360
|
+
export const LimitStats = Schema.Struct({
|
|
361
|
+
name: Schema.String,
|
|
362
|
+
allowed: Schema.Finite,
|
|
363
|
+
denied: Schema.Finite,
|
|
364
|
+
/** One per bucket in the range, zero-filled. */
|
|
365
|
+
points: Schema.Array(LimitPoint),
|
|
366
|
+
});
|
|
367
|
+
/** A stage's rate limits that were checked in the range, most denied first. */
|
|
368
|
+
export const LimitsResponse = Schema.Struct({
|
|
369
|
+
app: Schema.String,
|
|
370
|
+
stage: Schema.String,
|
|
371
|
+
res: Resolution,
|
|
372
|
+
limits: Schema.Array(LimitStats),
|
|
373
|
+
});
|
|
374
|
+
/** Per-tenant SES counts in one bucket (CloudWatch `Sum`s of `AWS/SES` by tenant). */
|
|
375
|
+
export const EmailPoint = Schema.Struct({
|
|
376
|
+
ts: Schema.String,
|
|
377
|
+
sends: Schema.Finite,
|
|
378
|
+
deliveries: Schema.Finite,
|
|
379
|
+
bounces: Schema.Finite,
|
|
380
|
+
complaints: Schema.Finite,
|
|
381
|
+
});
|
|
382
|
+
/**
|
|
383
|
+
* Whether SES lets a stage send. `paused` comes with who paused it: `policy`
|
|
384
|
+
* (the tenant's reputation policy, after bad bounce or complaint rates),
|
|
385
|
+
* `manual` (someone changed it in SES), or `aws` (only AWS Support can lift
|
|
386
|
+
* that one).
|
|
387
|
+
*/
|
|
388
|
+
export const EmailSending = Schema.Struct({
|
|
389
|
+
status: Schema.Literals(['enabled', 'paused']),
|
|
390
|
+
pausedBy: optional(Schema.Literals(['policy', 'manual', 'aws'])),
|
|
391
|
+
/** SES's reason, when paused. */
|
|
392
|
+
cause: optional(Schema.String),
|
|
393
|
+
since: optional(Schema.String),
|
|
394
|
+
});
|
|
395
|
+
/** A stage's email: its sender, whether it can send, today's usage and SES's counts over the range. */
|
|
396
|
+
export const EmailStatsResponse = Schema.Struct({
|
|
397
|
+
app: Schema.String,
|
|
398
|
+
stage: Schema.String,
|
|
399
|
+
/** False when the live deployment declares no `email`; the rest is then empty. */
|
|
400
|
+
enabled: Schema.Boolean,
|
|
401
|
+
/** `"Todo" <todo@mail…>`. */
|
|
402
|
+
from: optional(Schema.String),
|
|
403
|
+
sending: optional(EmailSending),
|
|
404
|
+
/** Recipients sent today (UTC) and the stage's daily limit. */
|
|
405
|
+
today: optional(Schema.Struct({ sent: Schema.Finite, limit: Schema.Finite })),
|
|
406
|
+
res: Resolution,
|
|
407
|
+
totals: Schema.Struct({
|
|
408
|
+
sends: Schema.Finite,
|
|
409
|
+
deliveries: Schema.Finite,
|
|
410
|
+
bounces: Schema.Finite,
|
|
411
|
+
complaints: Schema.Finite,
|
|
412
|
+
}),
|
|
413
|
+
points: Schema.Array(EmailPoint),
|
|
414
|
+
});
|
|
415
|
+
/** An address on a stage's suppression list: SES no longer sends to it from this stage. */
|
|
416
|
+
export const SuppressedAddress = Schema.Struct({
|
|
417
|
+
address: Schema.String,
|
|
418
|
+
reason: Schema.Literals(['bounce', 'complaint']),
|
|
419
|
+
since: Schema.String,
|
|
420
|
+
});
|
|
421
|
+
export const SuppressedResponse = Schema.Struct({
|
|
422
|
+
items: Schema.Array(SuppressedAddress),
|
|
423
|
+
next: optional(Schema.String),
|
|
424
|
+
});
|
|
425
|
+
export const ErrorStatus = Schema.Literals(['open', 'resolved', 'ignored']);
|
|
426
|
+
export const ErrorGroup = Schema.Struct({
|
|
427
|
+
fingerprint: Schema.String,
|
|
428
|
+
stage: Schema.String,
|
|
429
|
+
name: Schema.String,
|
|
430
|
+
message: Schema.String,
|
|
431
|
+
source: Schema.String,
|
|
432
|
+
count: Schema.Finite,
|
|
433
|
+
firstSeen: Schema.String,
|
|
434
|
+
lastSeen: Schema.String,
|
|
435
|
+
status: ErrorStatus,
|
|
436
|
+
sample: Schema.Struct({
|
|
437
|
+
stack: optional(Schema.String),
|
|
438
|
+
route: optional(Schema.String),
|
|
439
|
+
job: optional(Schema.String),
|
|
440
|
+
trace: optional(Schema.String),
|
|
441
|
+
rev: optional(Schema.String),
|
|
442
|
+
}),
|
|
443
|
+
});
|
|
444
|
+
export const UpdateErrorRequest = Schema.Struct({ status: ErrorStatus });
|
|
445
|
+
/** Log stream of a line: `web`, `worker`, or `service:<name>` for a long-running service. */
|
|
446
|
+
export const LogStream = Schema.String;
|
|
447
|
+
export const LogLine = Schema.Struct({
|
|
448
|
+
ts: Schema.String,
|
|
449
|
+
stream: LogStream,
|
|
450
|
+
level: optional(Schema.String),
|
|
451
|
+
message: Schema.String,
|
|
452
|
+
trace: optional(Schema.String),
|
|
453
|
+
event: optional(TelemetryEvent),
|
|
454
|
+
});
|
|
455
|
+
export const LogsResponse = Schema.Struct({
|
|
456
|
+
lines: Schema.Array(LogLine),
|
|
457
|
+
nextToken: optional(Schema.String),
|
|
458
|
+
});
|
|
459
|
+
export const TraceResponse = Schema.Struct({
|
|
460
|
+
trace: Schema.String,
|
|
461
|
+
events: Schema.Array(TelemetryEvent),
|
|
462
|
+
});
|
|
463
|
+
/** A GET of the stage's health path, for a stage that served nothing lately or has no server. */
|
|
464
|
+
export const UptimeCheck = Schema.Struct({
|
|
465
|
+
ts: Schema.String,
|
|
466
|
+
ok: Schema.Boolean,
|
|
467
|
+
source: Schema.Literal('check'),
|
|
468
|
+
/** The HTTP status; 0 when nothing answered within 10 s. */
|
|
469
|
+
status: Schema.Finite,
|
|
470
|
+
ms: Schema.Finite,
|
|
471
|
+
});
|
|
472
|
+
/** The stage's own requests in the 10 minutes before `ts`: down when at least 3, half of them 5xx. */
|
|
473
|
+
export const UptimeTraffic = Schema.Struct({
|
|
474
|
+
ts: Schema.String,
|
|
475
|
+
ok: Schema.Boolean,
|
|
476
|
+
source: Schema.Literal('traffic'),
|
|
477
|
+
req: Schema.Finite,
|
|
478
|
+
s5xx: Schema.Finite,
|
|
479
|
+
});
|
|
480
|
+
export const UptimePoint = Schema.Union([UptimeCheck, UptimeTraffic]);
|
|
481
|
+
/** Monthly cost of one container if it runs all month (`estimateContainerCost`). */
|
|
482
|
+
export const MonthlyContainerCost = Schema.Struct({
|
|
483
|
+
computeUsd: Schema.Finite,
|
|
484
|
+
publicIpv4Usd: Schema.Finite,
|
|
485
|
+
totalUsd: Schema.Finite,
|
|
486
|
+
});
|
|
487
|
+
/**
|
|
488
|
+
* Something billed for as long as it runs, estimated from its size because
|
|
489
|
+
* Cost Explorer lags a day and doesn't attribute every part of it to the
|
|
490
|
+
* app (a container's public IPv4 address).
|
|
491
|
+
*/
|
|
492
|
+
export const AlwaysOnCost = Schema.Struct({
|
|
493
|
+
stage: Schema.String,
|
|
494
|
+
kind: Schema.Literal('service'),
|
|
495
|
+
name: Schema.String,
|
|
496
|
+
/** `0.25 vCPU · 512 MB · Spot`. */
|
|
497
|
+
detail: Schema.String,
|
|
498
|
+
monthly: MonthlyContainerCost,
|
|
499
|
+
});
|
|
500
|
+
/** A non-preview stage's server: how it runs, and (prod) what each mode would cost. */
|
|
501
|
+
export const StageCompute = Schema.Struct({
|
|
502
|
+
stage: Schema.String,
|
|
503
|
+
/** `web.compute` of the live deployment. */
|
|
504
|
+
setting: Schema.Literals(WEB_COMPUTE_SETTINGS),
|
|
505
|
+
compute: WebComputeMode,
|
|
506
|
+
estimate: optional(ComputeEstimate),
|
|
507
|
+
streak: optional(ComputeStreakSchema),
|
|
508
|
+
});
|
|
509
|
+
export const CostResponse = Schema.Struct({
|
|
510
|
+
app: Schema.String,
|
|
511
|
+
currency: Schema.Literal('USD'),
|
|
512
|
+
days: Schema.Array(Schema.Struct({ date: Schema.String, usd: Schema.Finite })),
|
|
513
|
+
monthToDateUsd: Schema.Finite,
|
|
514
|
+
/** Services of the app's non-preview stages (previews run theirs for minutes after a deploy). */
|
|
515
|
+
alwaysOn: optional(Schema.Array(AlwaysOnCost)),
|
|
516
|
+
/** Servers of the app's non-preview stages (previews run request mode). */
|
|
517
|
+
compute: optional(Schema.Array(StageCompute)),
|
|
518
|
+
});
|
|
519
|
+
// ---------------------------------------------------------------------------
|
|
520
|
+
// Data, storage, secrets, job controls
|
|
521
|
+
// ---------------------------------------------------------------------------
|
|
522
|
+
export const SecretInfo = Schema.Struct({
|
|
523
|
+
name: Schema.String,
|
|
524
|
+
scope: Schema.Literals(['stage', 'shared']),
|
|
525
|
+
stage: optional(Schema.String),
|
|
526
|
+
updatedAt: optional(Schema.String),
|
|
527
|
+
});
|
|
528
|
+
export const SecretsResponse = Schema.Struct({
|
|
529
|
+
secrets: Schema.Array(SecretInfo),
|
|
530
|
+
/** Names `plat.config.ts` declares on the live deployment. */
|
|
531
|
+
declared: Schema.Array(Schema.String),
|
|
532
|
+
missing: Schema.Array(Schema.String),
|
|
533
|
+
});
|
|
534
|
+
export const PutSecretRequest = Schema.Struct({
|
|
535
|
+
value: Schema.String.check(Schema.isNonEmpty({ message: 'value is required' }), Schema.isMaxLength(4096, { message: 'secret values are limited to 4 KB' })),
|
|
536
|
+
});
|
|
537
|
+
/** `GET /v1/apps/:app/data/collections`. */
|
|
538
|
+
export const DataCollections = Schema.Struct({
|
|
539
|
+
/**
|
|
540
|
+
* Whether the stage has a table. False when `db` is off in plat.config.ts or
|
|
541
|
+
* the stage was never deployed; a table kept after turning `db` off counts.
|
|
542
|
+
*/
|
|
543
|
+
database: Schema.Boolean,
|
|
544
|
+
/** Item counts come from a bounded scan sample, so large collections are undercounted. */
|
|
545
|
+
collections: Schema.Array(Schema.Struct({ name: Schema.String, sampled: Schema.Finite })),
|
|
546
|
+
});
|
|
547
|
+
export const DataPage = Schema.Struct({
|
|
548
|
+
items: Schema.Array(Schema.Record(Schema.String, Schema.Unknown)),
|
|
549
|
+
cursor: optional(Schema.String),
|
|
550
|
+
});
|
|
551
|
+
export const StoredObjectInfo = Schema.Struct({
|
|
552
|
+
key: Schema.String,
|
|
553
|
+
size: Schema.Finite,
|
|
554
|
+
lastModified: optional(Schema.String),
|
|
555
|
+
});
|
|
556
|
+
/**
|
|
557
|
+
* `GET /v1/apps/:app/storage`: the declared stores (and which of them the
|
|
558
|
+
* edge serves) without `?store=`, a listing with it.
|
|
559
|
+
*/
|
|
560
|
+
export const StorageResponse = Schema.Union([
|
|
561
|
+
Schema.Struct({ stores: Schema.Array(Schema.String), public: optional(Schema.Array(Schema.String)) }),
|
|
562
|
+
Schema.Struct({ objects: Schema.Array(StoredObjectInfo), cursor: optional(Schema.String) }),
|
|
563
|
+
]);
|
|
564
|
+
export const UrlResponse = Schema.Struct({ url: Schema.String });
|
|
565
|
+
export const CronRunResponse = Schema.Struct({ started: Schema.String });
|
|
566
|
+
// ---------------------------------------------------------------------------
|
|
567
|
+
// Long-running services
|
|
568
|
+
// ---------------------------------------------------------------------------
|
|
569
|
+
/**
|
|
570
|
+
* - `running`: every desired task is up and the latest rollout finished
|
|
571
|
+
* - `starting`: a rollout or replacement is under way
|
|
572
|
+
* - `failing`: tasks keep stopping before they settle, or the last rollout failed
|
|
573
|
+
* - `stopped`: scaled to zero (a preview past its minutes, or `plat services stop`)
|
|
574
|
+
*/
|
|
575
|
+
export const ServiceState = Schema.Literals(['running', 'starting', 'failing', 'stopped']);
|
|
576
|
+
export const ServiceInfo = Schema.Struct({
|
|
577
|
+
name: Schema.String,
|
|
578
|
+
/** Size and capacity the live deployment declares. */
|
|
579
|
+
cpu: Schema.Finite,
|
|
580
|
+
memoryMb: Schema.Finite,
|
|
581
|
+
spot: Schema.Boolean,
|
|
582
|
+
state: ServiceState,
|
|
583
|
+
desired: Schema.Finite,
|
|
584
|
+
running: Schema.Finite,
|
|
585
|
+
pending: Schema.Finite,
|
|
586
|
+
/** Deployment whose build the service runs. */
|
|
587
|
+
deployment: optional(Schema.String),
|
|
588
|
+
/** When the current task started. */
|
|
589
|
+
startedAt: optional(Schema.String),
|
|
590
|
+
/** When a preview's stop schedule scales it to zero. */
|
|
591
|
+
stopsAt: optional(Schema.String),
|
|
592
|
+
/** The task that stopped most recently (ECS keeps stopped tasks for about an hour). */
|
|
593
|
+
lastStop: optional(Schema.Struct({ at: Schema.String, reason: Schema.String, exitCode: optional(Schema.Finite) })),
|
|
594
|
+
/** Recent ECS service events, newest first. */
|
|
595
|
+
events: Schema.Array(Schema.Struct({ at: Schema.String, message: Schema.String })),
|
|
596
|
+
/** Containers started in the range: deploys, crashes, Spot replacements. */
|
|
597
|
+
starts: Schema.Finite,
|
|
598
|
+
/** Runs of `run` that failed and were rerun in the same container, in the range. */
|
|
599
|
+
failedRuns: Schema.Finite,
|
|
600
|
+
/** CPU and memory use, % of the task's size (ECS's per-service CloudWatch metrics). */
|
|
601
|
+
points: Schema.Array(Schema.Struct({
|
|
602
|
+
ts: Schema.String,
|
|
603
|
+
cpu: Schema.NullOr(Schema.Finite),
|
|
604
|
+
memory: Schema.NullOr(Schema.Finite),
|
|
605
|
+
})),
|
|
606
|
+
/** If it ran all month. */
|
|
607
|
+
monthly: MonthlyContainerCost,
|
|
608
|
+
});
|
|
609
|
+
export const ServicesResponse = Schema.Struct({
|
|
610
|
+
app: Schema.String,
|
|
611
|
+
stage: Schema.String,
|
|
612
|
+
res: Resolution,
|
|
613
|
+
services: Schema.Array(ServiceInfo),
|
|
614
|
+
});
|
|
615
|
+
export const StartServiceRequest = Schema.Struct({
|
|
616
|
+
/** Stop it again after this many minutes. Previews default to the service's `previewMinutes`. */
|
|
617
|
+
minutes: optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1440 }))),
|
|
618
|
+
});
|
|
619
|
+
export const ServiceActionResponse = Schema.Struct({
|
|
620
|
+
name: Schema.String,
|
|
621
|
+
/** Tasks the service now asks for (1 running, 0 stopped). */
|
|
622
|
+
desired: Schema.Finite,
|
|
623
|
+
stopsAt: optional(Schema.String),
|
|
624
|
+
});
|
|
625
|
+
// ---------------------------------------------------------------------------
|
|
626
|
+
// Admin
|
|
627
|
+
// ---------------------------------------------------------------------------
|
|
628
|
+
export const AdminOverview = Schema.Struct({
|
|
629
|
+
members: Schema.Array(Schema.Struct({ github: Schema.String, role: MemberRole })),
|
|
630
|
+
limits: Schema.Struct({
|
|
631
|
+
appsPerMember: Schema.Finite,
|
|
632
|
+
stagesPerApp: Schema.Finite,
|
|
633
|
+
emailsPerDay: Schema.Finite,
|
|
634
|
+
edgeRequestsPerMinute: optional(Schema.Finite),
|
|
635
|
+
edgeFloorAt: optional(Schema.Finite),
|
|
636
|
+
servicesPerApp: Schema.Finite,
|
|
637
|
+
}),
|
|
638
|
+
apps: Schema.Finite,
|
|
639
|
+
stages: Schema.Finite,
|
|
640
|
+
previews: Schema.Finite,
|
|
641
|
+
/** Apps with a stage whose uptime check is failing. */
|
|
642
|
+
down: Schema.Array(Schema.String),
|
|
643
|
+
cost: Schema.Struct({ total: Schema.NullOr(CostResponse), shared: Schema.NullOr(CostResponse) }),
|
|
644
|
+
});
|
|
645
|
+
/** Requests the edge's web ACL handled in one bucket (CloudWatch `Sum`s). */
|
|
646
|
+
export const EdgeFloorPoint = Schema.Struct({
|
|
647
|
+
ts: Schema.String,
|
|
648
|
+
/** Blocked by the per-client floor. */
|
|
649
|
+
blocked: Schema.Finite,
|
|
650
|
+
/** Let through (every request the web ACL saw and allowed). */
|
|
651
|
+
allowed: Schema.Finite,
|
|
652
|
+
});
|
|
653
|
+
/** A request the floor blocked, from WAF's sample of the last three hours. */
|
|
654
|
+
export const EdgeFloorSample = Schema.Struct({
|
|
655
|
+
at: Schema.String,
|
|
656
|
+
host: Schema.String,
|
|
657
|
+
client: Schema.String,
|
|
658
|
+
country: optional(Schema.String),
|
|
659
|
+
method: Schema.String,
|
|
660
|
+
path: Schema.String,
|
|
661
|
+
});
|
|
662
|
+
/** Whether the edge floor is on, since when, and why it turned on or off. */
|
|
663
|
+
export const EdgeFloorState = Schema.Struct({
|
|
664
|
+
on: Schema.Boolean,
|
|
665
|
+
/** Absent until it first turns on. */
|
|
666
|
+
since: optional(Schema.String),
|
|
667
|
+
why: optional(Schema.String),
|
|
668
|
+
});
|
|
669
|
+
/**
|
|
670
|
+
* The edge's per-client request floor across every app: on only while the
|
|
671
|
+
* whole edge is busy (`limits.edgeFloorAt`), then `limits.edgeRequestsPerMinute`
|
|
672
|
+
* per client and host. Counts cover the range whether or not it was on then.
|
|
673
|
+
*/
|
|
674
|
+
export const EdgeFloorResponse = Schema.Struct({
|
|
675
|
+
/** False when the platform has no floor; the rest is then empty. */
|
|
676
|
+
enabled: Schema.Boolean,
|
|
677
|
+
state: EdgeFloorState,
|
|
678
|
+
/** Requests per client per host per minute while it's on. */
|
|
679
|
+
limit: optional(Schema.Finite),
|
|
680
|
+
/** Requests per minute across the edge that turn it on. */
|
|
681
|
+
threshold: optional(Schema.Finite),
|
|
682
|
+
res: Resolution,
|
|
683
|
+
totals: Schema.Struct({ blocked: Schema.Finite, allowed: Schema.Finite }),
|
|
684
|
+
points: Schema.Array(EdgeFloorPoint),
|
|
685
|
+
/** Newest first. WAF samples a share of requests, so counts here undercount. */
|
|
686
|
+
samples: Schema.Array(EdgeFloorSample),
|
|
687
|
+
});
|
|
688
|
+
// ---------------------------------------------------------------------------
|
|
689
|
+
// Errors
|
|
690
|
+
// ---------------------------------------------------------------------------
|
|
691
|
+
/** Body of every API error, whatever the status. */
|
|
692
|
+
export const ApiErrorBody = Schema.Struct({
|
|
693
|
+
error: Schema.Struct({ code: Schema.String, message: Schema.String }),
|
|
694
|
+
});
|
|
2
695
|
//# sourceMappingURL=api.js.map
|