@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
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The control plane's HTTP API (`/v1`) as an Effect `HttpApi`: the control
|
|
3
|
+
* plane implements it, the console calls it through a client generated from
|
|
4
|
+
* it, and its schemas describe what the CLI sends and reads.
|
|
5
|
+
*
|
|
6
|
+
* Imported from `@ericminassian/platform-core/platform-api`, never from the
|
|
7
|
+
* core index, so app runtimes don't load it.
|
|
8
|
+
*
|
|
9
|
+
* Auth is one of:
|
|
10
|
+
* - `Authorization: Bearer <platform token>` (CLI, from `plat login`)
|
|
11
|
+
* - `Authorization: Bearer <GitHub Actions OIDC token>` (CI deploys only)
|
|
12
|
+
* - the console's session cookie, plus `x-platform-csrf: 1` on writes
|
|
13
|
+
*
|
|
14
|
+
* The wire format predates this definition and published CLIs depend on it:
|
|
15
|
+
* paths, bodies and the `{ error: { code, message } }` error body stay as
|
|
16
|
+
* they are.
|
|
17
|
+
*/
|
|
18
|
+
import { Context, Schema, SchemaGetter } from 'effect';
|
|
19
|
+
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema } from 'effect/http-api';
|
|
20
|
+
import { AdminOverview, ApiErrorBody, AppRecord, AppSummary, CliLoginRequest, CliLoginResponse, CostResponse, CreateAppRequest, CreateDeploymentRequest, CreateDeploymentResponse, CronRunResponse, DeadLetterAction, DeadLetterActionResponse, DeadLettersResponse, CustomMetricsResponse, DataCollections, DataPage, DeploymentRecord, EmailSending, EdgeFloorResponse, EmailStatsResponse, ErrorGroup, ErrorStatus, JobsResponse, LimitsResponse, LogLine, LogsResponse, MeResponse, MetricsResponse, PutSecretRequest, QueueStats, RealtimeStatsResponse, RollbackRequest, RollbackResponse, RouteStats, SecretsResponse, ServiceActionResponse, ServicesResponse, StageDestroyed, StageDestroying, StageRecord, StartServiceRequest, StorageResponse, SuppressedResponse, TraceResponse, UpdateAppRequest, UpdateErrorRequest, UptimePoint, UrlResponse, } from './api.js';
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Errors: one class per status, each encoded as `{ error: { code, message } }`
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
const errorFields = { code: Schema.String, message: Schema.String };
|
|
25
|
+
/** The wire schema for an error class: its `code`/`message` nested under `error`, answered with `status`. */
|
|
26
|
+
const onTheWire = (tag, error, status) => ApiErrorBody.pipe(Schema.decodeTo(error, {
|
|
27
|
+
decode: SchemaGetter.transform((body) => ({ _tag: tag, ...body.error })),
|
|
28
|
+
encode: SchemaGetter.transform(({ code, message }) => ({ error: { code, message } })),
|
|
29
|
+
}), HttpApiSchema.status(status));
|
|
30
|
+
/** 400 `bad_request` (also every request that fails its schema). */
|
|
31
|
+
export class BadRequest extends Schema.TaggedError()('BadRequest', errorFields) {
|
|
32
|
+
static of = (message) => new BadRequest({ code: 'bad_request', message });
|
|
33
|
+
}
|
|
34
|
+
/** 401 `unauthenticated`: no or invalid credentials. */
|
|
35
|
+
export class Unauthenticated extends Schema.TaggedError()('Unauthenticated', errorFields) {
|
|
36
|
+
static of = (message) => new Unauthenticated({ code: 'unauthenticated', message });
|
|
37
|
+
}
|
|
38
|
+
/** 403: `forbidden`, `members_only`, `admins_only`, `not_a_member`, `csrf`. */
|
|
39
|
+
export class Forbidden extends Schema.TaggedError()('Forbidden', errorFields) {
|
|
40
|
+
}
|
|
41
|
+
/** 404 `not_found`. */
|
|
42
|
+
export class NotFound extends Schema.TaggedError()('NotFound', errorFields) {
|
|
43
|
+
static of = (what) => new NotFound({ code: 'not_found', message: `${what} not found` });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 409: `exists`, `dns_conflict`, `has_stages`, `already_started`, `rollback_failed`,
|
|
47
|
+
* `redrive_failed`, `discard_failed`, `paused_by_aws`, `service_action_failed`.
|
|
48
|
+
*/
|
|
49
|
+
export class Conflict extends Schema.TaggedError()('Conflict', errorFields) {
|
|
50
|
+
}
|
|
51
|
+
/** 422 `invalid_manifest`: the deployment's `plat.config.ts` doesn't validate. */
|
|
52
|
+
export class InvalidManifest extends Schema.TaggedError()('InvalidManifest', errorFields) {
|
|
53
|
+
static of = (message) => new InvalidManifest({ code: 'invalid_manifest', message });
|
|
54
|
+
}
|
|
55
|
+
/** 429 `limit`: an app or stage limit from `platform.config.ts`. */
|
|
56
|
+
export class LimitReached extends Schema.TaggedError()('LimitReached', errorFields) {
|
|
57
|
+
static of = (message) => new LimitReached({ code: 'limit', message });
|
|
58
|
+
}
|
|
59
|
+
export const BadRequestError = onTheWire('BadRequest', BadRequest, 400);
|
|
60
|
+
export const UnauthenticatedError = onTheWire('Unauthenticated', Unauthenticated, 401);
|
|
61
|
+
export const ForbiddenError = onTheWire('Forbidden', Forbidden, 403);
|
|
62
|
+
export const NotFoundError = onTheWire('NotFound', NotFound, 404);
|
|
63
|
+
export const ConflictError = onTheWire('Conflict', Conflict, 409);
|
|
64
|
+
export const InvalidManifestError = onTheWire('InvalidManifest', InvalidManifest, 422);
|
|
65
|
+
export const LimitReachedError = onTheWire('LimitReached', LimitReached, 429);
|
|
66
|
+
/** Errors any endpoint may answer with. */
|
|
67
|
+
const errors = [
|
|
68
|
+
BadRequestError,
|
|
69
|
+
UnauthenticatedError,
|
|
70
|
+
ForbiddenError,
|
|
71
|
+
NotFoundError,
|
|
72
|
+
ConflictError,
|
|
73
|
+
InvalidManifestError,
|
|
74
|
+
LimitReachedError,
|
|
75
|
+
];
|
|
76
|
+
/** The caller, provided by `Authenticated`. */
|
|
77
|
+
export class CurrentPrincipal extends Context.Service()('@ericminassian/platform-core/CurrentPrincipal') {
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Requires a platform token, a GitHub Actions OIDC token or the console
|
|
81
|
+
* cookie (with the CSRF header on writes), and provides `CurrentPrincipal`.
|
|
82
|
+
* Endpoints narrow to members or admins themselves.
|
|
83
|
+
*/
|
|
84
|
+
export class Authenticated extends HttpApiMiddleware.Service()('@ericminassian/platform-core/Authenticated', { error: [UnauthenticatedError, ForbiddenError] }) {
|
|
85
|
+
}
|
|
86
|
+
/** Header the console sends on every request; cross-site forms can't set it (CSRF guard). */
|
|
87
|
+
export const CSRF_HEADER = 'x-platform-csrf';
|
|
88
|
+
/**
|
|
89
|
+
* Answers a request whose path, query or body fails its schema with a 400
|
|
90
|
+
* `bad_request` in the API's error body, where Effect would answer an empty
|
|
91
|
+
* 400. Applies to every endpoint.
|
|
92
|
+
*/
|
|
93
|
+
export class RequestValidation extends HttpApiMiddleware.Service()('@ericminassian/platform-core/RequestValidation', { error: BadRequestError }) {
|
|
94
|
+
}
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Endpoints
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
const app = { app: Schema.String };
|
|
99
|
+
const appStage = { app: Schema.String, stage: Schema.String };
|
|
100
|
+
/** `?stage=` defaults to prod; the server validates the name. */
|
|
101
|
+
const stageQuery = { stage: Schema.optional(Schema.String) };
|
|
102
|
+
/** `?range=1h|24h|7d|30d` or `?from=&to=` (epoch ms or ISO), and `?res=1m|1h|1d`. */
|
|
103
|
+
const timeQuery = {
|
|
104
|
+
from: Schema.optional(Schema.String),
|
|
105
|
+
to: Schema.optional(Schema.String),
|
|
106
|
+
range: Schema.optional(Schema.String),
|
|
107
|
+
res: Schema.optional(Schema.String),
|
|
108
|
+
};
|
|
109
|
+
const rangeQuery = { ...stageQuery, ...timeQuery };
|
|
110
|
+
const limit = Schema.optional(Schema.Int);
|
|
111
|
+
export class SessionApi extends HttpApiGroup.make('session').add(
|
|
112
|
+
/** Exchanges a GitHub token for a platform token (`plat login`). */
|
|
113
|
+
HttpApiEndpoint.post('cliLogin', '/auth/cli', {
|
|
114
|
+
payload: CliLoginRequest,
|
|
115
|
+
success: CliLoginResponse,
|
|
116
|
+
error: errors,
|
|
117
|
+
}), HttpApiEndpoint.get('me', '/me', { success: MeResponse, error: errors }).middleware(Authenticated)) {
|
|
118
|
+
}
|
|
119
|
+
export class AppsApi extends HttpApiGroup.make('apps')
|
|
120
|
+
.add(HttpApiEndpoint.get('list', '/apps', { success: Schema.Array(AppSummary), error: errors }), HttpApiEndpoint.post('create', '/apps', {
|
|
121
|
+
payload: CreateAppRequest,
|
|
122
|
+
success: AppRecord.pipe(HttpApiSchema.status(201)),
|
|
123
|
+
error: errors,
|
|
124
|
+
}), HttpApiEndpoint.get('get', '/apps/:app', { params: app, success: AppSummary, error: errors }), HttpApiEndpoint.patch('update', '/apps/:app', {
|
|
125
|
+
params: app,
|
|
126
|
+
payload: UpdateAppRequest,
|
|
127
|
+
success: AppRecord,
|
|
128
|
+
error: errors,
|
|
129
|
+
}),
|
|
130
|
+
/** Refused (409 `has_stages`) while any stage exists. */
|
|
131
|
+
HttpApiEndpoint.delete('remove', '/apps/:app', {
|
|
132
|
+
params: app,
|
|
133
|
+
success: HttpApiSchema.NoContent,
|
|
134
|
+
error: errors,
|
|
135
|
+
}))
|
|
136
|
+
.middleware(Authenticated) {
|
|
137
|
+
}
|
|
138
|
+
export class StagesApi extends HttpApiGroup.make('stages')
|
|
139
|
+
.add(HttpApiEndpoint.get('list', '/apps/:app/stages', {
|
|
140
|
+
params: app,
|
|
141
|
+
success: Schema.Array(StageRecord),
|
|
142
|
+
error: errors,
|
|
143
|
+
}),
|
|
144
|
+
/** 202 while destroying; 200 when there was nothing left. Prod needs `?confirm=<app>`. */
|
|
145
|
+
HttpApiEndpoint.delete('destroy', '/apps/:app/stages/:stage', {
|
|
146
|
+
params: appStage,
|
|
147
|
+
query: { confirm: Schema.optional(Schema.String) },
|
|
148
|
+
success: [
|
|
149
|
+
StageDestroying.pipe(HttpApiSchema.status(202)),
|
|
150
|
+
StageDestroyed.pipe(HttpApiSchema.status(200)),
|
|
151
|
+
],
|
|
152
|
+
error: errors,
|
|
153
|
+
}), HttpApiEndpoint.post('rollback', '/apps/:app/stages/:stage/rollback', {
|
|
154
|
+
params: appStage,
|
|
155
|
+
/** No body rolls back to the previous deployment. */
|
|
156
|
+
payload: [RollbackRequest, Schema.Null],
|
|
157
|
+
success: RollbackResponse,
|
|
158
|
+
error: errors,
|
|
159
|
+
}))
|
|
160
|
+
.middleware(Authenticated) {
|
|
161
|
+
}
|
|
162
|
+
export class DeploymentsApi extends HttpApiGroup.make('deployments')
|
|
163
|
+
.add(
|
|
164
|
+
/** Newest first, without event logs or manifests. */
|
|
165
|
+
HttpApiEndpoint.get('list', '/apps/:app/deployments', {
|
|
166
|
+
params: app,
|
|
167
|
+
query: { stage: Schema.optional(Schema.String), limit },
|
|
168
|
+
success: Schema.Array(DeploymentRecord),
|
|
169
|
+
error: errors,
|
|
170
|
+
}),
|
|
171
|
+
/** Records the deployment and returns presigned upload forms; `start` runs it. */
|
|
172
|
+
HttpApiEndpoint.post('create', '/apps/:app/deployments', {
|
|
173
|
+
params: app,
|
|
174
|
+
payload: CreateDeploymentRequest,
|
|
175
|
+
success: CreateDeploymentResponse.pipe(HttpApiSchema.status(201)),
|
|
176
|
+
error: errors,
|
|
177
|
+
}), HttpApiEndpoint.get('get', '/deployments/:id', {
|
|
178
|
+
params: { id: Schema.String },
|
|
179
|
+
success: DeploymentRecord,
|
|
180
|
+
error: errors,
|
|
181
|
+
}), HttpApiEndpoint.post('start', '/deployments/:id/start', {
|
|
182
|
+
params: { id: Schema.String },
|
|
183
|
+
success: DeploymentRecord.pipe(HttpApiSchema.status(202)),
|
|
184
|
+
error: errors,
|
|
185
|
+
}))
|
|
186
|
+
.middleware(Authenticated) {
|
|
187
|
+
}
|
|
188
|
+
/** A live log line, or the error that ended the tail. */
|
|
189
|
+
export const TailEvent = Schema.Union([
|
|
190
|
+
Schema.Struct({ event: Schema.Literal('line'), data: Schema.fromJsonString(LogLine) }),
|
|
191
|
+
Schema.Struct({ event: Schema.Literal('error'), data: Schema.String }),
|
|
192
|
+
]);
|
|
193
|
+
export class ObserveApi extends HttpApiGroup.make('observe')
|
|
194
|
+
.add(HttpApiEndpoint.get('metrics', '/apps/:app/metrics', {
|
|
195
|
+
params: app,
|
|
196
|
+
query: rangeQuery,
|
|
197
|
+
success: MetricsResponse,
|
|
198
|
+
error: errors,
|
|
199
|
+
}), HttpApiEndpoint.get('routes', '/apps/:app/routes', {
|
|
200
|
+
params: app,
|
|
201
|
+
query: rangeQuery,
|
|
202
|
+
success: Schema.Array(RouteStats),
|
|
203
|
+
error: errors,
|
|
204
|
+
}), HttpApiEndpoint.get('jobs', '/apps/:app/jobs', {
|
|
205
|
+
params: app,
|
|
206
|
+
query: rangeQuery,
|
|
207
|
+
success: JobsResponse,
|
|
208
|
+
error: errors,
|
|
209
|
+
}), HttpApiEndpoint.get('queues', '/apps/:app/queues', {
|
|
210
|
+
params: app,
|
|
211
|
+
query: stageQuery,
|
|
212
|
+
success: Schema.Array(QueueStats),
|
|
213
|
+
error: errors,
|
|
214
|
+
}),
|
|
215
|
+
/** The stage's dead-letter queue: every job that failed its last attempt. */
|
|
216
|
+
HttpApiEndpoint.get('deadLetters', '/apps/:app/dead-letters', {
|
|
217
|
+
params: app,
|
|
218
|
+
query: stageQuery,
|
|
219
|
+
success: DeadLettersResponse,
|
|
220
|
+
error: errors,
|
|
221
|
+
}),
|
|
222
|
+
/** AppSync Events activity of the stage's channel namespace, from CloudWatch. */
|
|
223
|
+
HttpApiEndpoint.get('realtime', '/apps/:app/realtime', {
|
|
224
|
+
params: app,
|
|
225
|
+
query: rangeQuery,
|
|
226
|
+
success: RealtimeStatsResponse,
|
|
227
|
+
error: errors,
|
|
228
|
+
}),
|
|
229
|
+
/** The stage's sender, SES sending status, today's usage, and SES counts for its tenant. */
|
|
230
|
+
HttpApiEndpoint.get('email', '/apps/:app/email', {
|
|
231
|
+
params: app,
|
|
232
|
+
query: rangeQuery,
|
|
233
|
+
success: EmailStatsResponse,
|
|
234
|
+
error: errors,
|
|
235
|
+
}),
|
|
236
|
+
/** `Metrics.count`/`value` series per name, at 1h or 1d. */
|
|
237
|
+
HttpApiEndpoint.get('customMetrics', '/apps/:app/custom-metrics', {
|
|
238
|
+
params: app,
|
|
239
|
+
query: rangeQuery,
|
|
240
|
+
success: CustomMetricsResponse,
|
|
241
|
+
error: errors,
|
|
242
|
+
}),
|
|
243
|
+
/** `RateLimits` checks per limit: allowed and denied, at 1h or 1d. */
|
|
244
|
+
HttpApiEndpoint.get('limits', '/apps/:app/limits', {
|
|
245
|
+
params: app,
|
|
246
|
+
query: rangeQuery,
|
|
247
|
+
success: LimitsResponse,
|
|
248
|
+
error: errors,
|
|
249
|
+
}),
|
|
250
|
+
/** The stage's long-running services: ECS state, CPU and memory, starts and failed runs. */
|
|
251
|
+
HttpApiEndpoint.get('services', '/apps/:app/services', {
|
|
252
|
+
params: app,
|
|
253
|
+
query: rangeQuery,
|
|
254
|
+
success: ServicesResponse,
|
|
255
|
+
error: errors,
|
|
256
|
+
}), HttpApiEndpoint.get('errors', '/apps/:app/errors', {
|
|
257
|
+
params: app,
|
|
258
|
+
query: { ...stageQuery, status: Schema.optional(ErrorStatus) },
|
|
259
|
+
success: Schema.Array(ErrorGroup),
|
|
260
|
+
error: errors,
|
|
261
|
+
}), HttpApiEndpoint.patch('updateError', '/apps/:app/errors/:fingerprint', {
|
|
262
|
+
params: { ...app, fingerprint: Schema.String },
|
|
263
|
+
query: stageQuery,
|
|
264
|
+
payload: UpdateErrorRequest,
|
|
265
|
+
success: UpdateErrorRequest,
|
|
266
|
+
error: errors,
|
|
267
|
+
}), HttpApiEndpoint.get('uptime', '/apps/:app/uptime', {
|
|
268
|
+
params: app,
|
|
269
|
+
query: rangeQuery,
|
|
270
|
+
success: Schema.Array(UptimePoint),
|
|
271
|
+
error: errors,
|
|
272
|
+
}), HttpApiEndpoint.get('cost', '/apps/:app/cost', {
|
|
273
|
+
params: app,
|
|
274
|
+
query: { days: Schema.optional(Schema.Int) },
|
|
275
|
+
success: CostResponse,
|
|
276
|
+
error: errors,
|
|
277
|
+
}),
|
|
278
|
+
/** Logs Insights search; `next` pages on. */
|
|
279
|
+
HttpApiEndpoint.get('logs', '/apps/:app/logs', {
|
|
280
|
+
params: app,
|
|
281
|
+
query: {
|
|
282
|
+
...rangeQuery,
|
|
283
|
+
q: Schema.optional(Schema.String),
|
|
284
|
+
/** `web`, `worker` or `service:<name>`. */
|
|
285
|
+
stream: Schema.optional(Schema.String),
|
|
286
|
+
limit,
|
|
287
|
+
next: Schema.optional(Schema.String),
|
|
288
|
+
},
|
|
289
|
+
success: LogsResponse,
|
|
290
|
+
error: errors,
|
|
291
|
+
}),
|
|
292
|
+
/**
|
|
293
|
+
* Server-sent events: `line` (a `LogLine` as JSON) as logs arrive, `error` if
|
|
294
|
+
* the tail fails. A comment every 20 s keeps the connection open: CloudFront
|
|
295
|
+
* drops origin connections that stay idle.
|
|
296
|
+
*/
|
|
297
|
+
HttpApiEndpoint.get('tail', '/apps/:app/logs/tail', {
|
|
298
|
+
params: app,
|
|
299
|
+
query: {
|
|
300
|
+
...stageQuery,
|
|
301
|
+
q: Schema.optional(Schema.String),
|
|
302
|
+
/** `web`, `worker` or `service:<name>`. */
|
|
303
|
+
stream: Schema.optional(Schema.String),
|
|
304
|
+
},
|
|
305
|
+
success: HttpApiSchema.StreamSse({ events: TailEvent, keepAlive: '20 seconds' }),
|
|
306
|
+
error: errors,
|
|
307
|
+
}), HttpApiEndpoint.get('trace', '/apps/:app/traces/:trace', {
|
|
308
|
+
params: { ...app, trace: Schema.String },
|
|
309
|
+
query: rangeQuery,
|
|
310
|
+
success: TraceResponse,
|
|
311
|
+
error: errors,
|
|
312
|
+
}))
|
|
313
|
+
.middleware(Authenticated) {
|
|
314
|
+
}
|
|
315
|
+
/** `?scope=shared` targets the app-wide secret; otherwise the stage (`?stage=`, default prod). */
|
|
316
|
+
const secretQuery = { ...stageQuery, scope: Schema.optional(Schema.Literals(['shared', 'stage'])) };
|
|
317
|
+
export class ManageApi extends HttpApiGroup.make('manage')
|
|
318
|
+
.add(HttpApiEndpoint.get('collections', '/apps/:app/data/collections', {
|
|
319
|
+
params: app,
|
|
320
|
+
query: stageQuery,
|
|
321
|
+
success: DataCollections,
|
|
322
|
+
error: errors,
|
|
323
|
+
}), HttpApiEndpoint.get('items', '/apps/:app/data/items', {
|
|
324
|
+
params: app,
|
|
325
|
+
query: {
|
|
326
|
+
...stageQuery,
|
|
327
|
+
collection: Schema.String,
|
|
328
|
+
partition: Schema.optional(Schema.String),
|
|
329
|
+
cursor: Schema.optional(Schema.String),
|
|
330
|
+
limit,
|
|
331
|
+
},
|
|
332
|
+
success: DataPage,
|
|
333
|
+
error: errors,
|
|
334
|
+
}), HttpApiEndpoint.get('storage', '/apps/:app/storage', {
|
|
335
|
+
params: app,
|
|
336
|
+
query: {
|
|
337
|
+
...stageQuery,
|
|
338
|
+
store: Schema.optional(Schema.String),
|
|
339
|
+
prefix: Schema.optional(Schema.String),
|
|
340
|
+
cursor: Schema.optional(Schema.String),
|
|
341
|
+
},
|
|
342
|
+
success: StorageResponse,
|
|
343
|
+
error: errors,
|
|
344
|
+
}), HttpApiEndpoint.get('storageUrl', '/apps/:app/storage/url', {
|
|
345
|
+
params: app,
|
|
346
|
+
query: { ...stageQuery, store: Schema.String, key: Schema.String },
|
|
347
|
+
success: UrlResponse,
|
|
348
|
+
error: errors,
|
|
349
|
+
}), HttpApiEndpoint.get('secrets', '/apps/:app/secrets', {
|
|
350
|
+
params: app,
|
|
351
|
+
query: stageQuery,
|
|
352
|
+
success: SecretsResponse,
|
|
353
|
+
error: errors,
|
|
354
|
+
}), HttpApiEndpoint.put('putSecret', '/apps/:app/secrets/:name', {
|
|
355
|
+
params: { ...app, name: Schema.String },
|
|
356
|
+
query: secretQuery,
|
|
357
|
+
payload: PutSecretRequest,
|
|
358
|
+
success: HttpApiSchema.NoContent,
|
|
359
|
+
error: errors,
|
|
360
|
+
}), HttpApiEndpoint.delete('deleteSecret', '/apps/:app/secrets/:name', {
|
|
361
|
+
params: { ...app, name: Schema.String },
|
|
362
|
+
query: secretQuery,
|
|
363
|
+
success: HttpApiSchema.NoContent,
|
|
364
|
+
error: errors,
|
|
365
|
+
}), HttpApiEndpoint.post('runCron', '/apps/:app/crons/:name/run', {
|
|
366
|
+
params: { ...app, name: Schema.String },
|
|
367
|
+
query: stageQuery,
|
|
368
|
+
success: CronRunResponse.pipe(HttpApiSchema.status(202)),
|
|
369
|
+
error: errors,
|
|
370
|
+
}),
|
|
371
|
+
/** The stage's suppression list (its SES tenant's), in SES's order; `next` pages on. */
|
|
372
|
+
HttpApiEndpoint.get('suppressed', '/apps/:app/email/suppressed', {
|
|
373
|
+
params: app,
|
|
374
|
+
query: { ...stageQuery, next: Schema.optional(Schema.String) },
|
|
375
|
+
success: SuppressedResponse,
|
|
376
|
+
error: errors,
|
|
377
|
+
}),
|
|
378
|
+
/** Lets SES send to `address` from this stage again. */
|
|
379
|
+
HttpApiEndpoint.delete('unsuppress', '/apps/:app/email/suppressed/:address', {
|
|
380
|
+
params: { ...app, address: Schema.String },
|
|
381
|
+
query: stageQuery,
|
|
382
|
+
success: HttpApiSchema.NoContent,
|
|
383
|
+
error: errors,
|
|
384
|
+
}),
|
|
385
|
+
/** Resumes sending after a pause by the reputation policy or by hand (not one by AWS). */
|
|
386
|
+
HttpApiEndpoint.post('resumeEmail', '/apps/:app/email/resume', {
|
|
387
|
+
params: app,
|
|
388
|
+
query: stageQuery,
|
|
389
|
+
success: EmailSending,
|
|
390
|
+
error: errors,
|
|
391
|
+
}),
|
|
392
|
+
/** Replaces the service's task with a fresh one on the same build. */
|
|
393
|
+
HttpApiEndpoint.post('restartService', '/apps/:app/services/:name/restart', {
|
|
394
|
+
params: { ...app, name: Schema.String },
|
|
395
|
+
query: stageQuery,
|
|
396
|
+
success: ServiceActionResponse.pipe(HttpApiSchema.status(202)),
|
|
397
|
+
error: errors,
|
|
398
|
+
}),
|
|
399
|
+
/**
|
|
400
|
+
* Runs it (desired 1). It stops again after `minutes` when given; on
|
|
401
|
+
* previews always, by default after its `previewMinutes` (30 when that is 0).
|
|
402
|
+
*/
|
|
403
|
+
HttpApiEndpoint.post('startService', '/apps/:app/services/:name/start', {
|
|
404
|
+
params: { ...app, name: Schema.String },
|
|
405
|
+
query: stageQuery,
|
|
406
|
+
payload: StartServiceRequest,
|
|
407
|
+
success: ServiceActionResponse.pipe(HttpApiSchema.status(202)),
|
|
408
|
+
error: errors,
|
|
409
|
+
}),
|
|
410
|
+
/** Scales it to zero until it is started again or the stage is redeployed. */
|
|
411
|
+
HttpApiEndpoint.post('stopService', '/apps/:app/services/:name/stop', {
|
|
412
|
+
params: { ...app, name: Schema.String },
|
|
413
|
+
query: stageQuery,
|
|
414
|
+
success: ServiceActionResponse.pipe(HttpApiSchema.status(202)),
|
|
415
|
+
error: errors,
|
|
416
|
+
}),
|
|
417
|
+
/** Runs dead letters again from their first attempt, on the function their handler runs in now. */
|
|
418
|
+
HttpApiEndpoint.post('redrive', '/apps/:app/dead-letters/redrive', {
|
|
419
|
+
params: app,
|
|
420
|
+
query: stageQuery,
|
|
421
|
+
payload: DeadLetterAction,
|
|
422
|
+
success: DeadLetterActionResponse,
|
|
423
|
+
error: errors,
|
|
424
|
+
}), HttpApiEndpoint.post('discard', '/apps/:app/dead-letters/discard', {
|
|
425
|
+
params: app,
|
|
426
|
+
query: stageQuery,
|
|
427
|
+
payload: DeadLetterAction,
|
|
428
|
+
success: DeadLetterActionResponse,
|
|
429
|
+
error: errors,
|
|
430
|
+
}))
|
|
431
|
+
.middleware(Authenticated) {
|
|
432
|
+
}
|
|
433
|
+
export class AdminApi extends HttpApiGroup.make('admin')
|
|
434
|
+
.add(HttpApiEndpoint.get('overview', '/admin/overview', { success: AdminOverview, error: errors }))
|
|
435
|
+
/** The edge's per-client request floor: on or off, blocked and allowed requests, recently blocked ones. */
|
|
436
|
+
.add(HttpApiEndpoint.get('edge', '/admin/edge', {
|
|
437
|
+
query: timeQuery,
|
|
438
|
+
success: EdgeFloorResponse,
|
|
439
|
+
error: errors,
|
|
440
|
+
}))
|
|
441
|
+
.middleware(Authenticated) {
|
|
442
|
+
}
|
|
443
|
+
export class PlatformApi extends HttpApi.make('platform')
|
|
444
|
+
.add(SessionApi)
|
|
445
|
+
.add(AppsApi)
|
|
446
|
+
.add(StagesApi)
|
|
447
|
+
.add(DeploymentsApi)
|
|
448
|
+
.add(ObserveApi)
|
|
449
|
+
.add(ManageApi)
|
|
450
|
+
.add(AdminApi)
|
|
451
|
+
.prefix('/v1')
|
|
452
|
+
// After every group: `middleware` only reaches the endpoints added so far.
|
|
453
|
+
.middleware(RequestValidation) {
|
|
454
|
+
}
|
|
455
|
+
//# sourceMappingURL=platform-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-api.js","sourceRoot":"","sources":["../src/platform-api.ts"],"names":[],"mappings":"AAAA;;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Ae,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE;IACzC,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,iBAAiB;IAC1B,KAAK,EAAE,MAAM;CACd,CAAC,CACH;KACA,UAAU,CAAC,aAAa,CAAC;CAAG;AAE/B,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;KACtD,GAAG,CAAC,UAAU,CAAC;KACf,GAAG,CAAC,OAAO,CAAC;KACZ,GAAG,CAAC,SAAS,CAAC;KACd,GAAG,CAAC,cAAc,CAAC;KACnB,GAAG,CAAC,UAAU,CAAC;KACf,GAAG,CAAC,SAAS,CAAC;KACd,GAAG,CAAC,QAAQ,CAAC;KACb,MAAM,CAAC,KAAK,CAAC;IACd,2EAA2E;KAC1E,UAAU,CAAC,iBAAiB,CAAC;CAAG"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** Where browsers connect (WebSocket) and read their `RealtimeClientConfig` (GET). The router answers both. */
|
|
2
|
+
export declare const REALTIME_PATH = "/__platform/realtime";
|
|
3
|
+
/** Where signed-in browsers get a `RealtimeToken`; served by the SDK on the app's server. */
|
|
4
|
+
export declare const REALTIME_TOKEN_PATH = "/__platform/realtime/token";
|
|
5
|
+
/**
|
|
6
|
+
* Key of the platform's realtime entry (`RealtimeEdgeEntry`) in the route
|
|
7
|
+
* store. Not a hostname, so it can never collide with a route record.
|
|
8
|
+
*/
|
|
9
|
+
export declare const REALTIME_KVS_KEY = "__platform/realtime";
|
|
10
|
+
/** AppSync's paths on its HTTP and realtime domains. */
|
|
11
|
+
export declare const APPSYNC_PUBLISH_PATH = "/event";
|
|
12
|
+
export declare const APPSYNC_REALTIME_PATH = "/event/realtime";
|
|
13
|
+
/** Subprotocol every AppSync Events WebSocket offers (the auth header rides in a second one). */
|
|
14
|
+
export declare const APPSYNC_SUBPROTOCOL = "aws-appsync-event-ws";
|
|
15
|
+
/** AppSync accepts at most this many events per publish request. */
|
|
16
|
+
export declare const REALTIME_PUBLISH_BATCH = 5;
|
|
17
|
+
/** AppSync rejects a single event larger than this many bytes. */
|
|
18
|
+
export declare const REALTIME_MAX_EVENT_BYTES: number;
|
|
19
|
+
export type RealtimeSubscribe = 'public' | 'signed-in';
|
|
20
|
+
/**
|
|
21
|
+
* A channel as app code names it: 1-4 segments (`board`, `boards/b1`). The
|
|
22
|
+
* stage's namespace is AppSync's first segment and AppSync allows five.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CHANNEL_PATTERN: RegExp;
|
|
25
|
+
/** A declared channel in `plat.config.ts`: a channel, or a prefix of 1-3 segments ending in `/*`. */
|
|
26
|
+
export declare const CHANNEL_DECLARATION_PATTERN: RegExp;
|
|
27
|
+
export declare const CHANNEL_MESSAGE = "must be 1-4 segments of a-z, 0-9 and hyphens separated by \"/\", optionally ending in \"/*\"";
|
|
28
|
+
/**
|
|
29
|
+
* Channels under `user/<id>` are private to the signed-in user with that id;
|
|
30
|
+
* they can only be declared as `user/*`, and only with `subscribe: 'signed-in'`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const USER_CHANNEL_PREFIX = "user";
|
|
33
|
+
/** Whether `channel` (or a wildcard subscription like `boards/*`) falls under the declared `pattern`. */
|
|
34
|
+
export declare function channelMatches(pattern: string, channel: string): boolean;
|
|
35
|
+
/** The declared pattern a channel (or wildcard subscription) belongs to, if any. */
|
|
36
|
+
export declare function declaredChannel(patterns: readonly string[], channel: string): string | undefined;
|
|
37
|
+
/** A channel app code may publish to: concrete (no wildcard) and well formed. */
|
|
38
|
+
export declare function isChannel(channel: string): boolean;
|
|
39
|
+
/** A channel a browser may subscribe to: a channel, or a declared-style `prefix/*` wildcard. */
|
|
40
|
+
export declare function isSubscription(channel: string): boolean;
|
|
41
|
+
/** AppSync's channel path for an app channel: `/<namespace>/<channel>`. */
|
|
42
|
+
export declare function channelPath(namespace: string, channel: string): string;
|
|
43
|
+
/** The app channel inside an AppSync channel path, or undefined if it's in another namespace. */
|
|
44
|
+
export declare function appChannel(namespace: string, path: string): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Problems with a stage's realtime declaration, as messages for the
|
|
47
|
+
* `realtime` path of `plat.config.ts`. Shared by manifest validation and tests.
|
|
48
|
+
*/
|
|
49
|
+
export declare function realtimeIssues(r: {
|
|
50
|
+
subscribe: RealtimeSubscribe;
|
|
51
|
+
channels: readonly string[];
|
|
52
|
+
auth: boolean;
|
|
53
|
+
server: boolean;
|
|
54
|
+
}): Array<{
|
|
55
|
+
path: string[];
|
|
56
|
+
message: string;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Whether a signed-in user may subscribe to an app channel (or wildcard).
|
|
60
|
+
* Channels under `user/<id>` belong to that user alone; a wildcard that could
|
|
61
|
+
* reach another user's channels (`*`, `user/*`) is refused. Every other
|
|
62
|
+
* channel is open to any signed-in user of the app.
|
|
63
|
+
*/
|
|
64
|
+
export declare function canSubscribe(userId: string, channel: string): boolean;
|
|
65
|
+
/** What the router answers at `REALTIME_PATH` (GET): how a browser connects and subscribes. */
|
|
66
|
+
export interface RealtimeClientConfig {
|
|
67
|
+
v: 1;
|
|
68
|
+
/** AppSync's HTTP domain. Every connection and subscription must name it as `host`. */
|
|
69
|
+
host: string;
|
|
70
|
+
/** The stage's channel namespace; AppSync channels are `/<namespace>/<channel>`. */
|
|
71
|
+
namespace: string;
|
|
72
|
+
subscribe: RealtimeSubscribe;
|
|
73
|
+
/** For `public`: the platform's subscribe-only API key. */
|
|
74
|
+
apiKey?: string;
|
|
75
|
+
}
|
|
76
|
+
/** What the SDK answers at `REALTIME_TOKEN_PATH` for a signed-in user. */
|
|
77
|
+
export interface RealtimeToken {
|
|
78
|
+
token: string;
|
|
79
|
+
/** Epoch milliseconds. */
|
|
80
|
+
expiresAt: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The platform entry in the route store (`REALTIME_KVS_KEY`), written by the
|
|
84
|
+
* control plane: where AppSync is, and the public API key. One entry for every
|
|
85
|
+
* stage, so a replaced key reaches every app at once.
|
|
86
|
+
*/
|
|
87
|
+
export interface RealtimeEdgeEntry {
|
|
88
|
+
v: 1;
|
|
89
|
+
/** Realtime domain (the WebSocket origin). */
|
|
90
|
+
o: string;
|
|
91
|
+
/** HTTP domain (the `host` browsers name). */
|
|
92
|
+
h: string;
|
|
93
|
+
/** Subscribe-only API key for `public` stages. */
|
|
94
|
+
k: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Claims of a subscribe token. Short keys: the token rides in the WebSocket
|
|
98
|
+
* subprotocol header and in every subscribe message.
|
|
99
|
+
*/
|
|
100
|
+
export interface RealtimeClaims {
|
|
101
|
+
/** App and stage: the authorizer finds the stage key and namespace from them. */
|
|
102
|
+
a: string;
|
|
103
|
+
s: string;
|
|
104
|
+
/** User id. */
|
|
105
|
+
u: string;
|
|
106
|
+
/** Expiry, epoch seconds. */
|
|
107
|
+
e: number;
|
|
108
|
+
}
|
|
109
|
+
/** Lets AppSync refuse malformed tokens before invoking the authorizer (`identityValidationExpression`). */
|
|
110
|
+
export declare const REALTIME_TOKEN_PATTERN = "^pt1\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$";
|
|
111
|
+
/** How long a subscribe token lasts. Open subscriptions outlive it; new ones need a fresh token. */
|
|
112
|
+
export declare const REALTIME_TOKEN_TTL_SECONDS: number;
|
|
113
|
+
/** A signed subscribe token: `pt1.<claims>.<HMAC-SHA256>`, all base64url. */
|
|
114
|
+
export declare function signRealtimeToken(stageKey: string, claims: RealtimeClaims): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* The claims of a token, unverified: the authorizer needs `a` and `s` to find
|
|
117
|
+
* the stage key it then verifies with. Undefined when malformed.
|
|
118
|
+
*/
|
|
119
|
+
export declare function peekRealtimeToken(token: string): RealtimeClaims | undefined;
|
|
120
|
+
/** The claims, if the signature is the stage key's and the token hasn't expired. */
|
|
121
|
+
export declare function verifyRealtimeToken(stageKey: string, token: string, nowSeconds: number): Promise<RealtimeClaims | undefined>;
|
|
122
|
+
export type RealtimeOperation = 'EVENT_CONNECT' | 'EVENT_SUBSCRIBE' | 'EVENT_PUBLISH';
|
|
123
|
+
/**
|
|
124
|
+
* The authorizer's decision for a verified token (pure, so it's unit-tested
|
|
125
|
+
* here and the Lambda only adds SSM and AppSync plumbing).
|
|
126
|
+
*
|
|
127
|
+
* - Connect: any valid token.
|
|
128
|
+
* - Subscribe: the stage's own namespace, and `canSubscribe`.
|
|
129
|
+
* - Publish: never; browsers only subscribe (servers publish with IAM).
|
|
130
|
+
*/
|
|
131
|
+
export declare function authorizeRealtime(input: {
|
|
132
|
+
operation: RealtimeOperation;
|
|
133
|
+
claims: RealtimeClaims;
|
|
134
|
+
/** The namespace the token's stage owns (`names.realtimeNamespace(a, s)`). */
|
|
135
|
+
namespace: string;
|
|
136
|
+
/** AppSync's request: namespace name and channel path (null on connect). */
|
|
137
|
+
channelNamespace: string | null;
|
|
138
|
+
channel: string | null;
|
|
139
|
+
}): boolean;
|