@ericminassian/platform-core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +1847 -212
- package/dist/api.js +694 -1
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +19 -0
- package/dist/auth.js +32 -0
- package/dist/auth.js.map +1 -1
- package/dist/base64url.d.ts +3 -0
- package/dist/base64url.js +15 -0
- package/dist/base64url.js.map +1 -0
- package/dist/bindings.d.ts +69 -13
- package/dist/bindings.js +1 -1
- package/dist/bindings.js.map +1 -1
- package/dist/cloudfront-function.d.ts +5 -1
- package/dist/cloudfront-function.js +70 -2
- package/dist/cloudfront-function.js.map +1 -1
- package/dist/compute.d.ts +52 -0
- package/dist/compute.js +65 -0
- package/dist/compute.js.map +1 -0
- package/dist/config.d.ts +21 -1
- package/dist/config.js +16 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +67 -1
- package/dist/constants.js +56 -1
- package/dist/constants.js.map +1 -1
- package/dist/email.d.ts +84 -0
- package/dist/email.js +111 -0
- package/dist/email.js.map +1 -0
- package/dist/fingerprint.d.ts +9 -0
- package/dist/fingerprint.js +19 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +111 -0
- package/dist/jobs.js +214 -0
- package/dist/jobs.js.map +1 -0
- package/dist/manifest.d.ts +357 -112
- package/dist/manifest.js +270 -72
- package/dist/manifest.js.map +1 -1
- package/dist/naming.d.ts +93 -6
- package/dist/naming.js +98 -6
- package/dist/naming.js.map +1 -1
- package/dist/platform-api.d.ts +7792 -0
- package/dist/platform-api.js +455 -0
- package/dist/platform-api.js.map +1 -0
- package/dist/realtime.d.ts +139 -0
- package/dist/realtime.js +201 -0
- package/dist/realtime.js.map +1 -0
- package/dist/router/decide.d.ts +7 -1
- package/dist/router/decide.js +42 -5
- package/dist/router.d.ts +35 -13
- package/dist/router.js +36 -0
- package/dist/router.js.map +1 -1
- package/dist/runtime-config.d.ts +57 -0
- package/dist/runtime-config.js +12 -0
- package/dist/runtime-config.js.map +1 -1
- package/dist/storage.d.ts +55 -0
- package/dist/storage.js +112 -0
- package/dist/storage.js.map +1 -0
- package/dist/telemetry.d.ts +350 -83
- package/dist/telemetry.js +188 -15
- package/dist/telemetry.js.map +1 -1
- package/dist/web-compute.d.ts +191 -0
- package/dist/web-compute.js +257 -0
- package/dist/web-compute.js.map +1 -0
- package/package.json +28 -8
- package/src/api.ts +864 -238
- package/src/auth.ts +37 -0
- package/src/base64url.ts +13 -0
- package/src/bindings.ts +74 -7
- package/src/cloudfront-function.ts +70 -2
- package/src/compute.ts +86 -0
- package/src/config.ts +34 -2
- package/src/constants.ts +76 -1
- package/src/email.ts +168 -0
- package/src/fingerprint.ts +20 -0
- package/src/index.ts +6 -0
- package/src/jobs.ts +281 -0
- package/src/manifest.ts +542 -114
- package/src/naming.ts +103 -8
- package/src/platform-api.ts +630 -0
- package/src/realtime.ts +298 -0
- package/src/router/decide.d.ts +7 -1
- package/src/router/decide.js +42 -5
- package/src/router.ts +33 -13
- package/src/runtime-config.ts +70 -0
- package/src/storage.ts +120 -0
- package/src/telemetry.ts +198 -93
- package/src/web-compute.ts +342 -0
package/dist/manifest.d.ts
CHANGED
|
@@ -1,76 +1,85 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { type FargateCpu } from './compute.ts';
|
|
3
|
+
import { type WebComputeSetting } from './web-compute.ts';
|
|
2
4
|
/**
|
|
3
5
|
* The app's config file, at the app root. `plat` evaluates it and sends the
|
|
4
6
|
* result to the platform as JSON; the control plane never runs app code.
|
|
5
7
|
*/
|
|
6
8
|
export declare const APP_CONFIG_FILE = "plat.config.ts";
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
9
|
+
export declare const ManifestSchema: Schema.Struct<{
|
|
10
|
+
readonly name: Schema.String;
|
|
11
|
+
readonly description: Schema.optional<Schema.String>;
|
|
12
|
+
readonly web: Schema.optional<Schema.Struct<{
|
|
13
|
+
readonly server: Schema.optional<Schema.String>;
|
|
14
|
+
readonly static: Schema.optional<Schema.String>;
|
|
15
|
+
readonly build: Schema.optional<Schema.String>;
|
|
16
|
+
readonly dev: Schema.optional<Schema.Struct<{
|
|
17
|
+
readonly command: Schema.String;
|
|
18
|
+
readonly port: Schema.optional<Schema.Int>;
|
|
19
|
+
}>>;
|
|
20
|
+
readonly spa: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
21
|
+
readonly serverRoutes: Schema.withDecodingDefault<Schema.$Array<Schema.String>, never>;
|
|
22
|
+
readonly timeoutSeconds: Schema.withDecodingDefault<Schema.Int, never>;
|
|
23
|
+
readonly concurrency: Schema.withDecodingDefault<Schema.Int, never>;
|
|
24
|
+
readonly compute: Schema.withDecodingDefault<Schema.Literals<readonly ["auto", "request", "instance"]>, never>;
|
|
25
|
+
readonly memoryMb: Schema.withDecodingDefault<Schema.Int, never>;
|
|
26
|
+
readonly maxEnvironments: Schema.optional<Schema.Int>;
|
|
27
|
+
}>>;
|
|
28
|
+
readonly worker: Schema.optional<Schema.Struct<{
|
|
29
|
+
readonly entry: Schema.withDecodingDefault<Schema.String, never>;
|
|
30
|
+
readonly timeoutSeconds: Schema.withDecodingDefault<Schema.Int, never>;
|
|
31
|
+
readonly memoryMb: Schema.withDecodingDefault<Schema.Int, never>;
|
|
32
|
+
}>>;
|
|
33
|
+
readonly auth: Schema.withDecodingDefault<Schema.Union<readonly [Schema.Boolean, Schema.Struct<{
|
|
34
|
+
readonly required: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
35
|
+
}>]>, never>;
|
|
36
|
+
readonly db: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
37
|
+
readonly queues: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Struct<{
|
|
38
|
+
readonly timeoutSeconds: Schema.optional<Schema.Int>;
|
|
39
|
+
readonly memoryMb: Schema.optional<Schema.Int>;
|
|
40
|
+
readonly maxAttempts: Schema.withDecodingDefault<Schema.Int, never>;
|
|
41
|
+
readonly concurrency: Schema.optional<Schema.Int>;
|
|
42
|
+
readonly batchSize: Schema.optional<Schema.Unknown>;
|
|
43
|
+
readonly visibilityTimeoutSeconds: Schema.optional<Schema.Unknown>;
|
|
44
|
+
readonly maxReceiveCount: Schema.optional<Schema.Unknown>;
|
|
45
|
+
}>>, never>;
|
|
46
|
+
readonly events: Schema.withDecodingDefault<Schema.Union<readonly [Schema.$Array<Schema.String>, Schema.$Record<Schema.String, Schema.Struct<{
|
|
47
|
+
readonly timeoutSeconds: Schema.optional<Schema.Int>;
|
|
48
|
+
readonly memoryMb: Schema.optional<Schema.Int>;
|
|
49
|
+
readonly maxAttempts: Schema.optional<Schema.Int>;
|
|
50
|
+
}>>]>, never>;
|
|
51
|
+
readonly crons: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
52
|
+
readonly timeoutSeconds: Schema.optional<Schema.Int>;
|
|
53
|
+
readonly memoryMb: Schema.optional<Schema.Int>;
|
|
54
|
+
readonly schedule: Schema.String;
|
|
55
|
+
readonly timezone: Schema.optional<Schema.String>;
|
|
56
|
+
readonly maxAttempts: Schema.optional<Schema.Int>;
|
|
57
|
+
}>]>>, never>;
|
|
58
|
+
readonly storage: Schema.withDecodingDefault<Schema.Union<readonly [Schema.$Array<Schema.String>, Schema.$Record<Schema.String, Schema.Struct<{
|
|
59
|
+
readonly public: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
60
|
+
readonly expireAfterDays: Schema.optional<Schema.Int>;
|
|
61
|
+
}>>]>, never>;
|
|
62
|
+
readonly secrets: Schema.withDecodingDefault<Schema.$Array<Schema.String>, never>;
|
|
63
|
+
readonly env: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.String>, never>;
|
|
64
|
+
readonly realtime: Schema.optional<Schema.Struct<{
|
|
65
|
+
readonly subscribe: Schema.withDecodingDefault<Schema.Literals<readonly ["public", "signed-in"]>, never>;
|
|
66
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Struct<{}>>;
|
|
67
|
+
}>>;
|
|
68
|
+
readonly email: Schema.withDecodingDefault<Schema.Union<readonly [Schema.Boolean, Schema.Struct<{
|
|
69
|
+
readonly name: Schema.optional<Schema.String>;
|
|
70
|
+
readonly dailyLimit: Schema.optional<Schema.Int>;
|
|
71
|
+
}>]>, never>;
|
|
72
|
+
readonly services: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Struct<{
|
|
73
|
+
readonly entry: Schema.String;
|
|
74
|
+
readonly cpu: Schema.withDecodingDefault<Schema.Literals<readonly [0.25, 0.5, 1, 2, 4]>, never>;
|
|
75
|
+
readonly memoryMb: Schema.withDecodingDefault<Schema.Int, never>;
|
|
76
|
+
readonly spot: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
77
|
+
readonly previewMinutes: Schema.withDecodingDefault<Schema.Int, never>;
|
|
78
|
+
}>>, never>;
|
|
79
|
+
}>;
|
|
71
80
|
/** The evaluated config as JSON: what the CLI sends and deployments store. */
|
|
72
|
-
export type ManifestInput =
|
|
73
|
-
export type Manifest =
|
|
81
|
+
export type ManifestInput = typeof ManifestSchema.Encoded;
|
|
82
|
+
export type Manifest = typeof ManifestSchema.Type;
|
|
74
83
|
/** Type-only marker for a queue's message body or an event's detail. Never set at runtime. */
|
|
75
84
|
declare const payloadType: unique symbol;
|
|
76
85
|
type Payload<T> = {
|
|
@@ -79,16 +88,20 @@ type Payload<T> = {
|
|
|
79
88
|
/** The message or detail type declared with `queue<T>()` / `event<T>()`; `unknown` if none. */
|
|
80
89
|
export type PayloadOf<D> = D extends Payload<infer T> ? (unknown extends T ? unknown : T) : unknown;
|
|
81
90
|
export interface WebConfig {
|
|
82
|
-
/** Entry module whose default export is
|
|
91
|
+
/** Entry module whose default export is `toFetchHandler(...)` from `@ericminassian/platform`. */
|
|
83
92
|
server?: string;
|
|
84
93
|
/** Directory of built static assets, served from the edge. */
|
|
85
94
|
static?: string;
|
|
86
95
|
/** Shell command that builds `static` (run by `plat build`). */
|
|
87
96
|
build?: string;
|
|
88
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Dev server for the frontend, proxied by `plat dev` (e.g. Vite). The command
|
|
99
|
+
* listens on the port `plat dev` passes in `PLATFORM_DEV_WEB_PORT` (and `PORT`):
|
|
100
|
+
* `port` when it is free, otherwise any free port.
|
|
101
|
+
*/
|
|
89
102
|
dev?: {
|
|
90
103
|
command: string;
|
|
91
|
-
port
|
|
104
|
+
port?: number;
|
|
92
105
|
};
|
|
93
106
|
/** Serve `index.html` for unknown non-file paths (client-side routing). Default `true`. */
|
|
94
107
|
spa?: boolean;
|
|
@@ -96,35 +109,152 @@ export interface WebConfig {
|
|
|
96
109
|
serverRoutes?: readonly string[];
|
|
97
110
|
/** 3-900. Default 30. */
|
|
98
111
|
timeoutSeconds?: number;
|
|
99
|
-
/** Max concurrent requests per Web Function environment, 1-128. Default 64. */
|
|
112
|
+
/** Max concurrent requests per Web Function environment (instance mode), 1-128. Default 64. */
|
|
100
113
|
concurrency?: number;
|
|
114
|
+
/**
|
|
115
|
+
* How the server runs. `request`: one invocation per request, billed by the
|
|
116
|
+
* millisecond and nothing while idle. `instance`: a Web Function, whose
|
|
117
|
+
* environments serve many requests at once and are billed for their memory
|
|
118
|
+
* while they live (until about five minutes after the last request).
|
|
119
|
+
* `auto` (default): previews run `request`; prod starts on `request` and
|
|
120
|
+
* moves to whichever mode its traffic makes cheaper, checked daily.
|
|
121
|
+
*/
|
|
122
|
+
compute?: WebComputeSetting;
|
|
123
|
+
/** Memory of the server in request mode, 128-10240 MB (CPU grows with it). Default 1024. */
|
|
124
|
+
memoryMb?: number;
|
|
125
|
+
/** Most environments prod's Web Function (instance mode) runs at once, 2-10000. Default 10; previews 2. */
|
|
126
|
+
maxEnvironments?: number;
|
|
101
127
|
}
|
|
102
128
|
export interface WorkerConfig {
|
|
103
129
|
/** Module whose default export is `defineWorker(...)`. Default `src/worker.ts`. */
|
|
104
130
|
entry?: string;
|
|
105
|
-
/** 1-900. Default 60. */
|
|
131
|
+
/** 1-900. Default 60. Handlers can set their own (`HandlerConfig`). */
|
|
132
|
+
timeoutSeconds?: number;
|
|
133
|
+
/** 128-10240. Default 512. Handlers can set their own (`HandlerConfig`). */
|
|
134
|
+
memoryMb?: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A queue, event or cron handler's own Lambda settings, for handlers whose
|
|
138
|
+
* needs differ from the rest (a big parse, a long idle wait). A handler that
|
|
139
|
+
* sets either runs in a function of its own, from the same worker bundle;
|
|
140
|
+
* the one it doesn't set is the worker's.
|
|
141
|
+
*/
|
|
142
|
+
export interface HandlerConfig {
|
|
143
|
+
/** 1-900. Default: the worker's `timeoutSeconds`. */
|
|
106
144
|
timeoutSeconds?: number;
|
|
107
|
-
/** 128-10240. Default
|
|
145
|
+
/** 128-10240. Default: the worker's `memoryMb`. */
|
|
108
146
|
memoryMb?: number;
|
|
109
147
|
}
|
|
110
|
-
/**
|
|
111
|
-
export interface
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
148
|
+
/** How often a failed run is tried again, for every kind of handler. */
|
|
149
|
+
export interface RetryConfig {
|
|
150
|
+
/**
|
|
151
|
+
* Runs before the job goes to the stage's dead-letter queue, 1-100: the
|
|
152
|
+
* first, then retries 1, 2, 4 … minutes apart (at most an hour). Default 5
|
|
153
|
+
* for queues, 3 for events and crons.
|
|
154
|
+
*/
|
|
155
|
+
maxAttempts?: number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Declare one with `queue<Body>({ ... })` to type what is sent and received.
|
|
159
|
+
* Each message is one run of its handler, at least once and in no set order.
|
|
160
|
+
*/
|
|
161
|
+
export interface QueueConfig<Body = unknown> extends Payload<Body>, HandlerConfig, RetryConfig {
|
|
162
|
+
/**
|
|
163
|
+
* At most this many runs at once, 1-1000. Setting it runs the handler in a
|
|
164
|
+
* function of its own with that much reserved Lambda concurrency; messages
|
|
165
|
+
* past it wait (up to six hours) instead of failing.
|
|
166
|
+
*/
|
|
119
167
|
concurrency?: number;
|
|
120
168
|
}
|
|
169
|
+
/** Event handler options. */
|
|
170
|
+
export type EventOptions = HandlerConfig & RetryConfig;
|
|
121
171
|
/** Declare one with `event<Detail>()` to type what is published and handled. */
|
|
122
|
-
export type EventConfig<Detail = unknown> = Payload<Detail
|
|
123
|
-
/**
|
|
124
|
-
|
|
172
|
+
export type EventConfig<Detail = unknown> = Payload<Detail> & EventOptions;
|
|
173
|
+
/**
|
|
174
|
+
* 5-field cron in UTC (`0 3 * * *`) or `rate(5 minutes)`; the object form adds
|
|
175
|
+
* a timezone or the handler's own settings.
|
|
176
|
+
*/
|
|
177
|
+
export type CronConfig = string | CronSchedule;
|
|
178
|
+
export interface CronSchedule extends HandlerConfig, RetryConfig {
|
|
125
179
|
schedule: string;
|
|
180
|
+
/** IANA name, e.g. `America/Los_Angeles`. Default UTC. */
|
|
126
181
|
timezone?: string;
|
|
127
|
-
}
|
|
182
|
+
}
|
|
183
|
+
/** Declare one with `channel<Event>()` to type what is published and received. */
|
|
184
|
+
export type ChannelConfig<Event = unknown> = Payload<Event>;
|
|
185
|
+
/** A file store. `{}` is a private store whose files are kept until deleted. */
|
|
186
|
+
export interface StoreConfig {
|
|
187
|
+
/**
|
|
188
|
+
* Serve the store's files from the edge at `/__platform/storage/<store>/<key>`
|
|
189
|
+
* on the app's host, to anyone with the URL (`auth.required` doesn't cover
|
|
190
|
+
* it), with no server in the path. Files are cached as their `cacheControl`
|
|
191
|
+
* says; without one, browsers revalidate on each use. Default `false`.
|
|
192
|
+
*/
|
|
193
|
+
public?: boolean;
|
|
194
|
+
/** Delete files not written for this many days, 1-3650. Checked daily. Default: kept until deleted. */
|
|
195
|
+
expireAfterDays?: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A long-running process: it holds connections open (WebSocket or
|
|
199
|
+
* server-sent-event sources) and writes what it receives to the db, storage,
|
|
200
|
+
* queues or realtime. One instance per stage, restarted when it crashes and
|
|
201
|
+
* replaced on each deploy. Unlike everything else it is billed while it runs:
|
|
202
|
+
* about $6 a month at the default size on Spot.
|
|
203
|
+
*/
|
|
204
|
+
export interface ServiceConfig {
|
|
205
|
+
/** Module whose default export is `defineService(...)` from `@ericminassian/platform`. */
|
|
206
|
+
entry: string;
|
|
207
|
+
/** vCPUs: 0.25 (default), 0.5, 1, 2 or 4. */
|
|
208
|
+
cpu?: FargateCpu;
|
|
209
|
+
/**
|
|
210
|
+
* Memory in MB, one of the sizes Fargate pairs with `cpu`: 512, 1024 or
|
|
211
|
+
* 2048 for 0.25 vCPU; 1024-4096 for 0.5; 2048-8192 for 1; 4096-16384 for 2;
|
|
212
|
+
* 8192-30720 for 4 (steps of 1024). Default 512.
|
|
213
|
+
*/
|
|
214
|
+
memoryMb?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Run on Fargate Spot, about 70% cheaper. AWS may reclaim it with two
|
|
217
|
+
* minutes' notice (the service gets SIGTERM) and the platform starts a
|
|
218
|
+
* replacement. Default `true`.
|
|
219
|
+
*/
|
|
220
|
+
spot?: boolean;
|
|
221
|
+
/** Minutes a preview stage runs it after each deploy before stopping it; 0 means never. Default 30. */
|
|
222
|
+
previewMinutes?: number;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Live updates pushed to browsers. The server and worker publish; browsers
|
|
226
|
+
* subscribe (they never publish). Events aren't stored: a browser that was
|
|
227
|
+
* away re-reads what it shows after reconnecting.
|
|
228
|
+
*/
|
|
229
|
+
export interface RealtimeConfig {
|
|
230
|
+
/**
|
|
231
|
+
* Who may subscribe: anyone (`public`, the default), or signed-in users of
|
|
232
|
+
* this app (`signed-in`, needs `auth` and `web.server`).
|
|
233
|
+
*/
|
|
234
|
+
subscribe?: 'public' | 'signed-in';
|
|
235
|
+
/**
|
|
236
|
+
* Channels and their event types: `board: channel<BoardEvent>()`, or
|
|
237
|
+
* `'boards/*': channel<BoardEvent>()` for every channel below `boards/`.
|
|
238
|
+
* Names are 1-4 segments of a-z, 0-9 and hyphens. `'user/*'` channels
|
|
239
|
+
* (`user/<user id>/...`) are private to that user (`signed-in` only).
|
|
240
|
+
*/
|
|
241
|
+
channels: {
|
|
242
|
+
readonly [pattern: string]: ChannelConfig;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Transactional email, sent from `<app>@mail.<platform zone>` (previews from
|
|
247
|
+
* `<app>--<stage>@…`). Replies need `replyTo`: the sending address takes no mail.
|
|
248
|
+
*/
|
|
249
|
+
export interface EmailConfig {
|
|
250
|
+
/** Display name recipients see, e.g. `Todo` → `"Todo" <todo@mail…>`. */
|
|
251
|
+
name?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Recipients per UTC day (default 200), up to the platform's
|
|
254
|
+
* `limits.emailsPerDay`. Previews and `plat dev` get at most 50.
|
|
255
|
+
*/
|
|
256
|
+
dailyLimit?: number;
|
|
257
|
+
}
|
|
128
258
|
export interface AppConfig {
|
|
129
259
|
/** 3-30 chars of a-z, 0-9 and single hyphens; also the app's host name. */
|
|
130
260
|
name: string;
|
|
@@ -150,14 +280,29 @@ export interface AppConfig {
|
|
|
150
280
|
crons?: {
|
|
151
281
|
readonly [name: string]: CronConfig;
|
|
152
282
|
};
|
|
153
|
-
/**
|
|
154
|
-
|
|
283
|
+
/**
|
|
284
|
+
* Named file stores: `{ uploads: {}, snapshots: { public: true, expireAfterDays: 7 } }`.
|
|
285
|
+
* A list of names (`['uploads']`) declares private stores. Keys are 1-20
|
|
286
|
+
* chars of a-z, 0-9 and hyphens. A store can't switch between public and
|
|
287
|
+
* private once it has files: declare a new one instead.
|
|
288
|
+
*/
|
|
289
|
+
storage?: readonly string[] | {
|
|
290
|
+
readonly [name: string]: StoreConfig;
|
|
291
|
+
};
|
|
155
292
|
/** Secret names like `STRIPE_KEY`; values are set with `plat secrets set`. */
|
|
156
293
|
secrets?: readonly string[];
|
|
157
294
|
/** Plain, non-secret configuration exposed as environment variables. */
|
|
158
295
|
env?: {
|
|
159
296
|
readonly [name: string]: string;
|
|
160
297
|
};
|
|
298
|
+
/** Live updates pushed to browsers on typed channels. */
|
|
299
|
+
realtime?: RealtimeConfig;
|
|
300
|
+
/** Send email with the SDK's `Email` service: `true`, or `{ name, dailyLimit }`. */
|
|
301
|
+
email?: boolean | EmailConfig;
|
|
302
|
+
/** Long-running processes, e.g. stream ingest. Keys are 1-20 chars of a-z, 0-9 and hyphens. */
|
|
303
|
+
services?: {
|
|
304
|
+
readonly [name: string]: ServiceConfig;
|
|
305
|
+
};
|
|
161
306
|
}
|
|
162
307
|
/**
|
|
163
308
|
* Maps every key `T` has but `Shape` doesn't to `never`, recursively, so a
|
|
@@ -173,38 +318,138 @@ type Exact<T, Shape> = Shape extends readonly (infer S)[] ? T extends readonly (
|
|
|
173
318
|
* store and secret names (and payload types) are checked in app code.
|
|
174
319
|
*/
|
|
175
320
|
export declare function defineApp<const T extends AppConfig>(config: T & Exact<T, AppConfig>): T;
|
|
176
|
-
/** A queue whose messages are `Body`: `queues: { emails: queue<EmailJob>({
|
|
321
|
+
/** A queue whose messages are `Body`: `queues: { emails: queue<EmailJob>({ maxAttempts: 3 }) }`. */
|
|
177
322
|
export declare function queue<Body>(options?: QueueConfig): QueueConfig<Body>;
|
|
178
323
|
/** An event subscription whose detail is `Detail`: `events: { 'todo.created': event<TodoCreated>() }`. */
|
|
179
|
-
export declare function event<Detail>(): EventConfig<Detail>;
|
|
180
|
-
/**
|
|
181
|
-
export
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
324
|
+
export declare function event<Detail>(options?: EventOptions): EventConfig<Detail>;
|
|
325
|
+
/** A realtime channel whose events are `Event`: `realtime: { channels: { board: channel<BoardEvent>() } }`. */
|
|
326
|
+
export declare function channel<Event>(): ChannelConfig<Event>;
|
|
327
|
+
/**
|
|
328
|
+
* Manifest with defaults applied and derived fields normalized: what
|
|
329
|
+
* deployments store. Decoding fills defaults for fields added since a stored
|
|
330
|
+
* manifest was written, so earlier deployments keep decoding.
|
|
331
|
+
*/
|
|
332
|
+
export declare const ResolvedManifest: Schema.Struct<{
|
|
333
|
+
readonly name: Schema.String;
|
|
334
|
+
readonly description: Schema.optional<Schema.String>;
|
|
335
|
+
readonly web: Schema.optional<Schema.Struct<{
|
|
336
|
+
readonly server: Schema.optional<Schema.String>;
|
|
337
|
+
readonly static: Schema.optional<Schema.String>;
|
|
338
|
+
readonly build: Schema.optional<Schema.String>;
|
|
339
|
+
readonly dev: Schema.optional<Schema.Struct<{
|
|
340
|
+
readonly command: Schema.String;
|
|
341
|
+
readonly port: Schema.optional<Schema.Int>;
|
|
342
|
+
}>>;
|
|
343
|
+
readonly spa: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
344
|
+
readonly serverRoutes: Schema.withDecodingDefault<Schema.$Array<Schema.String>, never>;
|
|
345
|
+
readonly timeoutSeconds: Schema.withDecodingDefault<Schema.Int, never>;
|
|
346
|
+
readonly concurrency: Schema.withDecodingDefault<Schema.Int, never>;
|
|
347
|
+
readonly compute: Schema.withDecodingDefault<Schema.Literals<readonly ["auto", "request", "instance"]>, never>;
|
|
348
|
+
readonly memoryMb: Schema.withDecodingDefault<Schema.Int, never>;
|
|
349
|
+
readonly maxEnvironments: Schema.optional<Schema.Int>;
|
|
350
|
+
}>>;
|
|
185
351
|
/** Present when any queue, event subscription or cron exists. */
|
|
186
|
-
worker
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}>;
|
|
195
|
-
events: string[];
|
|
196
|
-
crons: Record<string, {
|
|
197
|
-
schedule: string;
|
|
198
|
-
timezone?: string;
|
|
352
|
+
readonly worker: Schema.optional<Schema.Struct<{
|
|
353
|
+
readonly entry: Schema.withDecodingDefault<Schema.String, never>;
|
|
354
|
+
readonly timeoutSeconds: Schema.withDecodingDefault<Schema.Int, never>;
|
|
355
|
+
readonly memoryMb: Schema.withDecodingDefault<Schema.Int, never>;
|
|
356
|
+
}>>;
|
|
357
|
+
readonly auth: Schema.Struct<{
|
|
358
|
+
readonly enabled: Schema.Boolean;
|
|
359
|
+
readonly required: Schema.Boolean;
|
|
199
360
|
}>;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
361
|
+
readonly db: Schema.Boolean;
|
|
362
|
+
readonly queues: Schema.$Record<Schema.String, Schema.Struct<{
|
|
363
|
+
timeoutSeconds: Schema.optional<Schema.Int>;
|
|
364
|
+
memoryMb: Schema.optional<Schema.Int>;
|
|
365
|
+
maxAttempts: Schema.withDecodingDefault<Schema.Int, never>;
|
|
366
|
+
concurrency: Schema.optional<Schema.Int>;
|
|
367
|
+
}>>;
|
|
368
|
+
readonly events: Schema.$Array<Schema.String>;
|
|
369
|
+
/**
|
|
370
|
+
* Each event handler's own settings, by type. Absent from deployments
|
|
371
|
+
* recorded before handlers had any. A field of its own, so clients that
|
|
372
|
+
* know only `events` keep decoding manifests.
|
|
373
|
+
*/
|
|
374
|
+
readonly eventOptions: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Struct<{
|
|
375
|
+
readonly timeoutSeconds: Schema.optional<Schema.Int>;
|
|
376
|
+
readonly memoryMb: Schema.optional<Schema.Int>;
|
|
377
|
+
readonly maxAttempts: Schema.optional<Schema.Int>;
|
|
378
|
+
}>>, never>;
|
|
379
|
+
readonly crons: Schema.$Record<Schema.String, Schema.Struct<{
|
|
380
|
+
readonly timeoutSeconds: Schema.optional<Schema.Int>;
|
|
381
|
+
readonly memoryMb: Schema.optional<Schema.Int>;
|
|
382
|
+
readonly schedule: Schema.String;
|
|
383
|
+
readonly timezone: Schema.optional<Schema.String>;
|
|
384
|
+
readonly maxAttempts: Schema.optional<Schema.Int>;
|
|
385
|
+
}>>;
|
|
386
|
+
/** Every store's name. */
|
|
387
|
+
readonly storage: Schema.$Array<Schema.String>;
|
|
388
|
+
/**
|
|
389
|
+
* Each store's options, by name. Absent from deployments recorded before
|
|
390
|
+
* stores had any: those stores are private and kept until deleted. A field
|
|
391
|
+
* of its own, so clients that know only `storage` keep decoding manifests.
|
|
392
|
+
*/
|
|
393
|
+
readonly storageOptions: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Struct<{
|
|
394
|
+
readonly public: Schema.Boolean;
|
|
395
|
+
readonly expireAfterDays: Schema.optional<Schema.Finite>;
|
|
396
|
+
}>>, never>;
|
|
397
|
+
readonly secrets: Schema.$Array<Schema.String>;
|
|
398
|
+
readonly env: Schema.$Record<Schema.String, Schema.String>;
|
|
399
|
+
/** Present when the stage has a channel namespace. `channels` are the declared patterns. */
|
|
400
|
+
readonly realtime: Schema.optional<Schema.Struct<{
|
|
401
|
+
readonly subscribe: Schema.Literals<readonly ["public", "signed-in"]>;
|
|
402
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
403
|
+
}>>;
|
|
404
|
+
/** Present when the stage sends email. `dailyLimit` is the declared one (prod's). */
|
|
405
|
+
readonly email: Schema.optional<Schema.Struct<{
|
|
406
|
+
readonly name: Schema.optional<Schema.String>;
|
|
407
|
+
readonly dailyLimit: Schema.Finite;
|
|
408
|
+
}>>;
|
|
409
|
+
/** Long-running services, with defaults applied. */
|
|
410
|
+
readonly services: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Struct<{
|
|
411
|
+
readonly entry: Schema.String;
|
|
412
|
+
readonly cpu: Schema.withDecodingDefault<Schema.Literals<readonly [0.25, 0.5, 1, 2, 4]>, never>;
|
|
413
|
+
readonly memoryMb: Schema.withDecodingDefault<Schema.Int, never>;
|
|
414
|
+
readonly spot: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
415
|
+
readonly previewMinutes: Schema.withDecodingDefault<Schema.Int, never>;
|
|
416
|
+
}>>, never>;
|
|
417
|
+
}>;
|
|
418
|
+
export type ResolvedManifest = typeof ResolvedManifest.Type;
|
|
204
419
|
export declare class ManifestError extends Error {
|
|
205
420
|
readonly issues: string[];
|
|
206
421
|
constructor(issues: string[]);
|
|
207
422
|
}
|
|
208
423
|
export declare function parseManifest(input: unknown): ResolvedManifest;
|
|
209
424
|
export declare function resolveManifest(m: Manifest): ResolvedManifest;
|
|
425
|
+
/** The stores the edge serves (`public: true`). */
|
|
426
|
+
export declare function publicStores(m: Pick<ResolvedManifest, 'storage' | 'storageOptions'>): string[];
|
|
427
|
+
declare const HANDLER_KINDS: readonly ['queue', 'event', 'cron'];
|
|
428
|
+
export type HandlerKind = (typeof HANDLER_KINDS)[number];
|
|
429
|
+
/** A queue, event or cron handler and the settings it runs with. */
|
|
430
|
+
export interface HandlerSettings {
|
|
431
|
+
kind: HandlerKind;
|
|
432
|
+
/** The queue or cron key, or the event type. */
|
|
433
|
+
name: string;
|
|
434
|
+
timeoutSeconds: number;
|
|
435
|
+
memoryMb: number;
|
|
436
|
+
/** Runs before its job is dead-lettered. */
|
|
437
|
+
maxAttempts: number;
|
|
438
|
+
/** Reserved concurrency of its function (queues that set `concurrency`). */
|
|
439
|
+
concurrency?: number;
|
|
440
|
+
/**
|
|
441
|
+
* It sets its own memory, timeout or (a queue) concurrency, so it runs in a
|
|
442
|
+
* function of its own (`names.handlerFunction`).
|
|
443
|
+
*/
|
|
444
|
+
own: boolean;
|
|
445
|
+
}
|
|
446
|
+
type WorkerManifest = Pick<ResolvedManifest, 'worker' | 'queues' | 'eventOptions' | 'crons'>;
|
|
447
|
+
/** A handler's settings: its own, and the worker's for any it doesn't set. */
|
|
448
|
+
export declare function handlerSettings(m: WorkerManifest, kind: HandlerKind, name: string): HandlerSettings;
|
|
449
|
+
/** Every queue, event and cron handler with its settings. */
|
|
450
|
+
export declare function workerHandlers(m: WorkerManifest): HandlerSettings[];
|
|
451
|
+
/** The handlers that run in functions of their own. The worker's function runs the rest. */
|
|
452
|
+
export declare function ownFunctionHandlers(m: WorkerManifest): HandlerSettings[];
|
|
453
|
+
/** The Lambda function a handler runs in: its own, or the worker's. */
|
|
454
|
+
export declare function handlerFunctionName(app: string, stage: string, m: WorkerManifest, kind: HandlerKind, name: string): string;
|
|
210
455
|
export {};
|