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