@ericminassian/platform-core 0.2.0 → 0.3.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 +947 -209
- package/dist/api.js +335 -1
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +19 -0
- package/dist/auth.js +29 -0
- package/dist/auth.js.map +1 -1
- package/dist/bindings.d.ts +8 -2
- package/dist/bindings.js.map +1 -1
- package/dist/cloudfront-function.js +6 -0
- package/dist/cloudfront-function.js.map +1 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js.map +1 -1
- package/dist/manifest.d.ts +96 -92
- package/dist/manifest.js +96 -66
- package/dist/manifest.js.map +1 -1
- package/dist/naming.d.ts +13 -2
- package/dist/naming.js +12 -1
- package/dist/naming.js.map +1 -1
- package/dist/platform-api.d.ts +5337 -0
- package/dist/platform-api.js +343 -0
- package/dist/platform-api.js.map +1 -0
- package/dist/router/decide.d.ts +5 -1
- package/dist/router/decide.js +7 -2
- package/dist/router.d.ts +1 -1
- package/dist/telemetry.d.ts +236 -74
- package/dist/telemetry.js +97 -0
- package/dist/telemetry.js.map +1 -1
- package/package.json +10 -2
- package/src/api.ts +427 -231
- package/src/auth.ts +33 -0
- package/src/bindings.ts +8 -2
- package/src/cloudfront-function.ts +6 -0
- package/src/config.ts +3 -1
- package/src/constants.ts +12 -0
- package/src/manifest.ts +145 -87
- package/src/naming.ts +13 -2
- package/src/platform-api.ts +504 -0
- package/src/router/decide.d.ts +5 -1
- package/src/router/decide.js +7 -2
- package/src/router.ts +1 -1
- package/src/telemetry.ts +107 -85
package/src/api.ts
CHANGED
|
@@ -1,250 +1,446 @@
|
|
|
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
|
+
|
|
15
|
+
const optional = Schema.optional;
|
|
11
16
|
|
|
12
17
|
// ---------------------------------------------------------------------------
|
|
13
18
|
// Records
|
|
14
19
|
// ---------------------------------------------------------------------------
|
|
15
20
|
|
|
16
|
-
export
|
|
17
|
-
name:
|
|
21
|
+
export const AppRecord = Schema.Struct({
|
|
22
|
+
name: Schema.String,
|
|
18
23
|
/** GitHub `owner/name` allowed to deploy this app from CI. */
|
|
19
|
-
repo:
|
|
20
|
-
description
|
|
24
|
+
repo: Schema.String,
|
|
25
|
+
description: optional(Schema.String),
|
|
21
26
|
/** 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
|
-
|
|
27
|
+
owners: Schema.Array(Schema.String),
|
|
28
|
+
createdBy: Schema.String,
|
|
29
|
+
createdAt: Schema.String,
|
|
30
|
+
});
|
|
31
|
+
export type AppRecord = typeof AppRecord.Type;
|
|
32
|
+
|
|
33
|
+
export const StageStatus = Schema.Literals(['active', 'deploying', 'failed', 'destroying', 'destroyed']);
|
|
34
|
+
export type StageStatus = typeof StageStatus.Type;
|
|
35
|
+
|
|
36
|
+
export const StageRecord = Schema.Struct({
|
|
37
|
+
app: Schema.String,
|
|
38
|
+
stage: Schema.String,
|
|
39
|
+
host: Schema.String,
|
|
40
|
+
url: Schema.String,
|
|
41
|
+
status: StageStatus,
|
|
42
|
+
preview: Schema.Boolean,
|
|
43
|
+
currentDeployment: optional(Schema.String),
|
|
44
|
+
previousDeployment: optional(Schema.String),
|
|
38
45
|
/** Web Function revision ids, for instant rollback. */
|
|
39
|
-
currentRevision
|
|
40
|
-
previousRevision
|
|
41
|
-
createdAt:
|
|
42
|
-
updatedAt:
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
currentRevision: optional(Schema.String),
|
|
47
|
+
previousRevision: optional(Schema.String),
|
|
48
|
+
createdAt: Schema.String,
|
|
49
|
+
updatedAt: Schema.String,
|
|
50
|
+
});
|
|
51
|
+
export type StageRecord = typeof StageRecord.Type;
|
|
52
|
+
|
|
53
|
+
export const DeploymentStatus = Schema.Literals([
|
|
54
|
+
'awaiting_upload',
|
|
55
|
+
'queued',
|
|
56
|
+
'running',
|
|
57
|
+
'succeeded',
|
|
58
|
+
'failed',
|
|
59
|
+
'rolled_back',
|
|
60
|
+
]);
|
|
61
|
+
export type DeploymentStatus = typeof DeploymentStatus.Type;
|
|
62
|
+
|
|
63
|
+
export const DeploymentEventEntry = Schema.Struct({
|
|
64
|
+
ts: Schema.Finite,
|
|
65
|
+
level: Schema.Literals(['info', 'warn', 'error']),
|
|
66
|
+
msg: Schema.String,
|
|
57
67
|
/** Resource the step acted on, e.g. `table foo--prod`. */
|
|
58
|
-
resource
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
resource: optional(Schema.String),
|
|
69
|
+
});
|
|
70
|
+
export type DeploymentEventEntry = typeof DeploymentEventEntry.Type;
|
|
71
|
+
|
|
72
|
+
export const DeploymentRecord = Schema.Struct({
|
|
73
|
+
id: Schema.String,
|
|
74
|
+
app: Schema.String,
|
|
75
|
+
stage: Schema.String,
|
|
76
|
+
status: DeploymentStatus,
|
|
66
77
|
/** GitHub username, or `ci:<repo>` for OIDC deploys. */
|
|
67
|
-
actor:
|
|
68
|
-
commit
|
|
69
|
-
ref
|
|
70
|
-
message
|
|
71
|
-
manifest
|
|
72
|
-
url
|
|
73
|
-
error
|
|
74
|
-
events: DeploymentEventEntry
|
|
75
|
-
createdAt:
|
|
76
|
-
startedAt
|
|
77
|
-
finishedAt
|
|
78
|
-
}
|
|
78
|
+
actor: Schema.String,
|
|
79
|
+
commit: optional(Schema.String),
|
|
80
|
+
ref: optional(Schema.String),
|
|
81
|
+
message: optional(Schema.String),
|
|
82
|
+
manifest: optional(ResolvedManifest),
|
|
83
|
+
url: optional(Schema.String),
|
|
84
|
+
error: optional(Schema.String),
|
|
85
|
+
events: Schema.Array(DeploymentEventEntry),
|
|
86
|
+
createdAt: Schema.String,
|
|
87
|
+
startedAt: optional(Schema.String),
|
|
88
|
+
finishedAt: optional(Schema.String),
|
|
89
|
+
});
|
|
90
|
+
export type DeploymentRecord = typeof DeploymentRecord.Type;
|
|
79
91
|
|
|
80
92
|
// ---------------------------------------------------------------------------
|
|
81
|
-
//
|
|
93
|
+
// Session
|
|
82
94
|
// ---------------------------------------------------------------------------
|
|
83
95
|
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
role: MemberRole;
|
|
87
|
-
}
|
|
96
|
+
export const MeResponse = Schema.Struct({ github: Schema.String, role: MemberRole });
|
|
97
|
+
export type MeResponse = typeof MeResponse.Type;
|
|
88
98
|
|
|
89
|
-
export
|
|
99
|
+
export const CliLoginRequest = Schema.Struct({
|
|
90
100
|
/** 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
|
-
|
|
101
|
+
githubToken: Schema.String.check(Schema.isNonEmpty({ message: 'githubToken is required' })),
|
|
102
|
+
});
|
|
103
|
+
export type CliLoginRequest = typeof CliLoginRequest.Type;
|
|
104
|
+
|
|
105
|
+
export const CliLoginResponse = Schema.Struct({
|
|
106
|
+
token: Schema.String,
|
|
107
|
+
github: Schema.String,
|
|
108
|
+
role: MemberRole,
|
|
109
|
+
expiresAt: Schema.String,
|
|
110
|
+
});
|
|
111
|
+
export type CliLoginResponse = typeof CliLoginResponse.Type;
|
|
112
|
+
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// Apps
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
/** GitHub `owner/name`. */
|
|
118
|
+
export const REPO_PATTERN = /^[A-Za-z0-9-]{1,39}\/[A-Za-z0-9._-]{1,100}$/;
|
|
119
|
+
const Repo = Schema.Trim.check(Schema.isPattern(REPO_PATTERN, { message: 'repo must be "owner/name"' }));
|
|
120
|
+
/** Longer descriptions are cut to 200 characters rather than refused. */
|
|
121
|
+
const Description = Schema.String.pipe(
|
|
122
|
+
Schema.decode({
|
|
123
|
+
decode: SchemaGetter.transform((s: string) => s.slice(0, 200)),
|
|
124
|
+
encode: SchemaGetter.transform((s: string) => s),
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
export const CreateAppRequest = Schema.Struct({
|
|
129
|
+
/** Checked against the naming rules and reserved names by the server. */
|
|
130
|
+
name: Schema.Trim,
|
|
131
|
+
repo: Repo,
|
|
132
|
+
description: optional(Description),
|
|
133
|
+
});
|
|
134
|
+
export type CreateAppRequest = typeof CreateAppRequest.Type;
|
|
135
|
+
|
|
136
|
+
export const UpdateAppRequest = Schema.Struct({
|
|
137
|
+
description: optional(Description),
|
|
138
|
+
repo: optional(Repo),
|
|
139
|
+
/** The server removes duplicates. */
|
|
140
|
+
owners: optional(
|
|
141
|
+
Schema.Array(Schema.String).check(Schema.isMinLength(1, { message: 'owners must be a non-empty list' })),
|
|
142
|
+
),
|
|
143
|
+
});
|
|
144
|
+
export type UpdateAppRequest = typeof UpdateAppRequest.Type;
|
|
145
|
+
|
|
146
|
+
export const AppHealth = Schema.Struct({
|
|
147
|
+
up: Schema.NullOr(Schema.Boolean),
|
|
148
|
+
reqPerMin: Schema.Finite,
|
|
149
|
+
errorRate: Schema.Finite,
|
|
150
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
151
|
+
});
|
|
152
|
+
export type AppHealth = typeof AppHealth.Type;
|
|
153
|
+
|
|
154
|
+
export const AppSummary = Schema.Struct({
|
|
155
|
+
app: AppRecord,
|
|
156
|
+
stages: Schema.Array(StageRecord),
|
|
132
157
|
/** 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
|
-
export
|
|
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
|
-
export
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
export
|
|
204
|
-
ts:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
export
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
export
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
158
|
+
health: Schema.NullOr(AppHealth),
|
|
159
|
+
costMonthToDateUsd: optional(Schema.Finite),
|
|
160
|
+
lastDeployment: optional(DeploymentRecord),
|
|
161
|
+
});
|
|
162
|
+
export type AppSummary = typeof AppSummary.Type;
|
|
163
|
+
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
// Stages and deployments
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
export const ArtifactFile = Schema.Literals(['manifest.json', 'server.zip', 'worker.zip', 'static.zip']);
|
|
169
|
+
export type ArtifactFile = typeof ArtifactFile.Type;
|
|
170
|
+
|
|
171
|
+
export const PresignedPost = Schema.Struct({
|
|
172
|
+
url: Schema.String,
|
|
173
|
+
fields: Schema.Record(Schema.String, Schema.String),
|
|
174
|
+
});
|
|
175
|
+
export type PresignedPost = typeof PresignedPost.Type;
|
|
176
|
+
|
|
177
|
+
export const CreateDeploymentRequest = Schema.Struct({
|
|
178
|
+
stage: Schema.String,
|
|
179
|
+
/**
|
|
180
|
+
* The evaluated `plat.config.ts` (`ManifestInput`). The server validates it
|
|
181
|
+
* with `parseManifest` and answers 422 with every issue when it's invalid.
|
|
182
|
+
*/
|
|
183
|
+
manifest: Schema.Unknown,
|
|
184
|
+
/** Which artifacts the CLI will upload (manifest.json is always uploaded). */
|
|
185
|
+
files: optional(Schema.Array(ArtifactFile)),
|
|
186
|
+
commit: optional(Schema.String),
|
|
187
|
+
ref: optional(Schema.String),
|
|
188
|
+
message: optional(Schema.String),
|
|
189
|
+
});
|
|
190
|
+
export type CreateDeploymentRequest = typeof CreateDeploymentRequest.Encoded;
|
|
191
|
+
|
|
192
|
+
export const CreateDeploymentResponse = Schema.Struct({
|
|
193
|
+
deployment: DeploymentRecord,
|
|
194
|
+
/** A form for each artifact the request listed, plus `manifest.json`. */
|
|
195
|
+
uploads: Schema.Struct({
|
|
196
|
+
'manifest.json': optional(PresignedPost),
|
|
197
|
+
'server.zip': optional(PresignedPost),
|
|
198
|
+
'worker.zip': optional(PresignedPost),
|
|
199
|
+
'static.zip': optional(PresignedPost),
|
|
200
|
+
}),
|
|
201
|
+
});
|
|
202
|
+
export type CreateDeploymentResponse = typeof CreateDeploymentResponse.Type;
|
|
203
|
+
|
|
204
|
+
export const RollbackRequest = Schema.Struct({
|
|
205
|
+
/** Default: the stage's previous deployment. */
|
|
206
|
+
deploymentId: optional(Schema.String),
|
|
207
|
+
});
|
|
208
|
+
export type RollbackRequest = typeof RollbackRequest.Type;
|
|
209
|
+
|
|
210
|
+
export const RollbackResponse = Schema.Struct({
|
|
211
|
+
/** The deployment the stage routes to now. */
|
|
212
|
+
currentDeployment: Schema.String,
|
|
213
|
+
url: Schema.String,
|
|
214
|
+
});
|
|
215
|
+
export type RollbackResponse = typeof RollbackResponse.Type;
|
|
216
|
+
|
|
217
|
+
/** Answered with 202: the stage is being torn down. */
|
|
218
|
+
export const StageDestroying = Schema.Struct({ status: Schema.Literal('destroying') });
|
|
219
|
+
/** Answered with 200: there was nothing left to destroy. */
|
|
220
|
+
export const StageDestroyed = Schema.Struct({ status: Schema.Literal('destroyed') });
|
|
221
|
+
export const DestroyStageResponse = Schema.Union([StageDestroying, StageDestroyed]);
|
|
222
|
+
export type DestroyStageResponse = typeof DestroyStageResponse.Type;
|
|
223
|
+
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
// Observability
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
|
|
228
|
+
export const MetricsPoint = Schema.Struct({
|
|
229
|
+
ts: Schema.String,
|
|
230
|
+
req: Schema.Finite,
|
|
231
|
+
s2xx: Schema.Finite,
|
|
232
|
+
s3xx: Schema.Finite,
|
|
233
|
+
s4xx: Schema.Finite,
|
|
234
|
+
s5xx: Schema.Finite,
|
|
235
|
+
p50: Schema.NullOr(Schema.Finite),
|
|
236
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
237
|
+
p99: Schema.NullOr(Schema.Finite),
|
|
238
|
+
cold: Schema.Finite,
|
|
239
|
+
});
|
|
240
|
+
export type MetricsPoint = typeof MetricsPoint.Type;
|
|
241
|
+
|
|
242
|
+
export const MetricsResponse = Schema.Struct({
|
|
243
|
+
app: Schema.String,
|
|
244
|
+
stage: Schema.String,
|
|
245
|
+
res: Resolution,
|
|
246
|
+
points: Schema.Array(MetricsPoint),
|
|
247
|
+
});
|
|
248
|
+
export type MetricsResponse = typeof MetricsResponse.Type;
|
|
249
|
+
|
|
250
|
+
export const RouteStats = Schema.Struct({
|
|
251
|
+
route: Schema.String,
|
|
252
|
+
method: Schema.String,
|
|
253
|
+
req: Schema.Finite,
|
|
254
|
+
s5xx: Schema.Finite,
|
|
255
|
+
s4xx: Schema.Finite,
|
|
256
|
+
p50: Schema.NullOr(Schema.Finite),
|
|
257
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
258
|
+
});
|
|
259
|
+
export type RouteStats = typeof RouteStats.Type;
|
|
260
|
+
|
|
261
|
+
export const JobKind = Schema.Literals(['queue', 'event', 'cron', 'invoke']);
|
|
262
|
+
export type JobKind = typeof JobKind.Type;
|
|
263
|
+
|
|
264
|
+
export const JobStats = Schema.Struct({
|
|
265
|
+
kind: JobKind,
|
|
266
|
+
name: Schema.String,
|
|
267
|
+
ok: Schema.Finite,
|
|
268
|
+
error: Schema.Finite,
|
|
269
|
+
p95: Schema.NullOr(Schema.Finite),
|
|
270
|
+
lastRun: optional(Schema.String),
|
|
271
|
+
});
|
|
272
|
+
export type JobStats = typeof JobStats.Type;
|
|
273
|
+
|
|
274
|
+
export const JobsResponse = Schema.Struct({
|
|
275
|
+
jobs: Schema.Array(JobStats),
|
|
276
|
+
crons: Schema.Array(Schema.Struct({ name: Schema.String, schedule: Schema.String })),
|
|
277
|
+
});
|
|
278
|
+
export type JobsResponse = typeof JobsResponse.Type;
|
|
279
|
+
|
|
280
|
+
export const QueueStats = Schema.Struct({
|
|
281
|
+
name: Schema.String,
|
|
282
|
+
visible: Schema.Finite,
|
|
283
|
+
inFlight: Schema.Finite,
|
|
284
|
+
deadLetter: Schema.Finite,
|
|
285
|
+
oldestAgeSeconds: Schema.NullOr(Schema.Finite),
|
|
286
|
+
});
|
|
287
|
+
export type QueueStats = typeof QueueStats.Type;
|
|
288
|
+
|
|
289
|
+
export const ErrorStatus = Schema.Literals(['open', 'resolved', 'ignored']);
|
|
290
|
+
export type ErrorStatus = typeof ErrorStatus.Type;
|
|
291
|
+
|
|
292
|
+
export const ErrorGroup = Schema.Struct({
|
|
293
|
+
fingerprint: Schema.String,
|
|
294
|
+
stage: Schema.String,
|
|
295
|
+
name: Schema.String,
|
|
296
|
+
message: Schema.String,
|
|
297
|
+
source: Schema.String,
|
|
298
|
+
count: Schema.Finite,
|
|
299
|
+
firstSeen: Schema.String,
|
|
300
|
+
lastSeen: Schema.String,
|
|
301
|
+
status: ErrorStatus,
|
|
302
|
+
sample: Schema.Struct({
|
|
303
|
+
stack: optional(Schema.String),
|
|
304
|
+
route: optional(Schema.String),
|
|
305
|
+
job: optional(Schema.String),
|
|
306
|
+
trace: optional(Schema.String),
|
|
307
|
+
rev: optional(Schema.String),
|
|
308
|
+
}),
|
|
309
|
+
});
|
|
310
|
+
export type ErrorGroup = typeof ErrorGroup.Type;
|
|
311
|
+
|
|
312
|
+
export const UpdateErrorRequest = Schema.Struct({ status: ErrorStatus });
|
|
313
|
+
export type UpdateErrorRequest = typeof UpdateErrorRequest.Type;
|
|
314
|
+
|
|
315
|
+
export const LogLine = Schema.Struct({
|
|
316
|
+
ts: Schema.String,
|
|
317
|
+
stream: Schema.Literals(['web', 'worker']),
|
|
318
|
+
level: optional(Schema.String),
|
|
319
|
+
message: Schema.String,
|
|
320
|
+
trace: optional(Schema.String),
|
|
321
|
+
event: optional(TelemetryEvent),
|
|
322
|
+
});
|
|
323
|
+
export type LogLine = typeof LogLine.Type;
|
|
324
|
+
|
|
325
|
+
export const LogsResponse = Schema.Struct({
|
|
326
|
+
lines: Schema.Array(LogLine),
|
|
327
|
+
nextToken: optional(Schema.String),
|
|
328
|
+
});
|
|
329
|
+
export type LogsResponse = typeof LogsResponse.Type;
|
|
330
|
+
|
|
331
|
+
export const TraceResponse = Schema.Struct({
|
|
332
|
+
trace: Schema.String,
|
|
333
|
+
events: Schema.Array(TelemetryEvent),
|
|
334
|
+
});
|
|
335
|
+
export type TraceResponse = typeof TraceResponse.Type;
|
|
336
|
+
|
|
337
|
+
export const UptimePoint = Schema.Struct({
|
|
338
|
+
ts: Schema.String,
|
|
339
|
+
ok: Schema.Boolean,
|
|
340
|
+
status: Schema.Finite,
|
|
341
|
+
ms: Schema.Finite,
|
|
342
|
+
});
|
|
343
|
+
export type UptimePoint = typeof UptimePoint.Type;
|
|
344
|
+
|
|
345
|
+
export const CostResponse = Schema.Struct({
|
|
346
|
+
app: Schema.String,
|
|
347
|
+
currency: Schema.Literal('USD'),
|
|
348
|
+
days: Schema.Array(Schema.Struct({ date: Schema.String, usd: Schema.Finite })),
|
|
349
|
+
monthToDateUsd: Schema.Finite,
|
|
350
|
+
});
|
|
351
|
+
export type CostResponse = typeof CostResponse.Type;
|
|
352
|
+
|
|
353
|
+
// ---------------------------------------------------------------------------
|
|
354
|
+
// Data, storage, secrets, job controls
|
|
355
|
+
// ---------------------------------------------------------------------------
|
|
356
|
+
|
|
357
|
+
export const SecretInfo = Schema.Struct({
|
|
358
|
+
name: Schema.String,
|
|
359
|
+
scope: Schema.Literals(['stage', 'shared']),
|
|
360
|
+
stage: optional(Schema.String),
|
|
361
|
+
updatedAt: optional(Schema.String),
|
|
362
|
+
});
|
|
363
|
+
export type SecretInfo = typeof SecretInfo.Type;
|
|
364
|
+
|
|
365
|
+
export const SecretsResponse = Schema.Struct({
|
|
366
|
+
secrets: Schema.Array(SecretInfo),
|
|
367
|
+
/** Names `plat.config.ts` declares on the live deployment. */
|
|
368
|
+
declared: Schema.Array(Schema.String),
|
|
369
|
+
missing: Schema.Array(Schema.String),
|
|
370
|
+
});
|
|
371
|
+
export type SecretsResponse = typeof SecretsResponse.Type;
|
|
372
|
+
|
|
373
|
+
export const PutSecretRequest = Schema.Struct({
|
|
374
|
+
value: Schema.String.check(
|
|
375
|
+
Schema.isNonEmpty({ message: 'value is required' }),
|
|
376
|
+
Schema.isMaxLength(4096, { message: 'secret values are limited to 4 KB' }),
|
|
377
|
+
),
|
|
378
|
+
});
|
|
379
|
+
export type PutSecretRequest = typeof PutSecretRequest.Type;
|
|
380
|
+
|
|
381
|
+
/** `GET /v1/apps/:app/data/collections`. */
|
|
382
|
+
export const DataCollections = Schema.Struct({
|
|
383
|
+
/**
|
|
384
|
+
* Whether the stage has a table. False when `db` is off in plat.config.ts or
|
|
385
|
+
* the stage was never deployed; a table kept after turning `db` off counts.
|
|
386
|
+
*/
|
|
387
|
+
database: Schema.Boolean,
|
|
388
|
+
/** Item counts come from a bounded scan sample, so large collections are undercounted. */
|
|
389
|
+
collections: Schema.Array(Schema.Struct({ name: Schema.String, sampled: Schema.Finite })),
|
|
390
|
+
});
|
|
391
|
+
export type DataCollections = typeof DataCollections.Type;
|
|
392
|
+
|
|
393
|
+
export const DataPage = Schema.Struct({
|
|
394
|
+
items: Schema.Array(Schema.Record(Schema.String, Schema.Unknown)),
|
|
395
|
+
cursor: optional(Schema.String),
|
|
396
|
+
});
|
|
397
|
+
export type DataPage = typeof DataPage.Type;
|
|
398
|
+
|
|
399
|
+
export const StoredObjectInfo = Schema.Struct({
|
|
400
|
+
key: Schema.String,
|
|
401
|
+
size: Schema.Finite,
|
|
402
|
+
lastModified: optional(Schema.String),
|
|
403
|
+
});
|
|
404
|
+
export type StoredObjectInfo = typeof StoredObjectInfo.Type;
|
|
405
|
+
|
|
406
|
+
/** `GET /v1/apps/:app/storage`: the declared stores without `?store=`, a listing with it. */
|
|
407
|
+
export const StorageResponse = Schema.Union([
|
|
408
|
+
Schema.Struct({ stores: Schema.Array(Schema.String) }),
|
|
409
|
+
Schema.Struct({ objects: Schema.Array(StoredObjectInfo), cursor: optional(Schema.String) }),
|
|
410
|
+
]);
|
|
411
|
+
export type StorageResponse = typeof StorageResponse.Type;
|
|
412
|
+
|
|
413
|
+
export const UrlResponse = Schema.Struct({ url: Schema.String });
|
|
414
|
+
export type UrlResponse = typeof UrlResponse.Type;
|
|
415
|
+
|
|
416
|
+
export const CronRunResponse = Schema.Struct({ started: Schema.String });
|
|
417
|
+
export type CronRunResponse = typeof CronRunResponse.Type;
|
|
418
|
+
|
|
419
|
+
export const RedriveResponse = Schema.Struct({ taskHandle: Schema.String });
|
|
420
|
+
export type RedriveResponse = typeof RedriveResponse.Type;
|
|
421
|
+
|
|
422
|
+
// ---------------------------------------------------------------------------
|
|
423
|
+
// Admin
|
|
424
|
+
// ---------------------------------------------------------------------------
|
|
425
|
+
|
|
426
|
+
export const AdminOverview = Schema.Struct({
|
|
427
|
+
members: Schema.Array(Schema.Struct({ github: Schema.String, role: MemberRole })),
|
|
428
|
+
limits: Schema.Struct({ appsPerMember: Schema.Finite, stagesPerApp: Schema.Finite }),
|
|
429
|
+
apps: Schema.Finite,
|
|
430
|
+
stages: Schema.Finite,
|
|
431
|
+
previews: Schema.Finite,
|
|
432
|
+
/** Apps with a stage whose uptime check is failing. */
|
|
433
|
+
down: Schema.Array(Schema.String),
|
|
434
|
+
cost: Schema.Struct({ total: Schema.NullOr(CostResponse), shared: Schema.NullOr(CostResponse) }),
|
|
435
|
+
});
|
|
436
|
+
export type AdminOverview = typeof AdminOverview.Type;
|
|
437
|
+
|
|
438
|
+
// ---------------------------------------------------------------------------
|
|
439
|
+
// Errors
|
|
440
|
+
// ---------------------------------------------------------------------------
|
|
441
|
+
|
|
442
|
+
/** Body of every API error, whatever the status. */
|
|
443
|
+
export const ApiErrorBody = Schema.Struct({
|
|
444
|
+
error: Schema.Struct({ code: Schema.String, message: Schema.String }),
|
|
445
|
+
});
|
|
446
|
+
export type ApiErrorBody = typeof ApiErrorBody.Type;
|