@ericminassian/platform-core 0.3.0 → 0.4.1
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 +1225 -45
- package/dist/api.js +471 -13
- package/dist/api.js.map +1 -1
- package/dist/auth.js +5 -2
- 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 +62 -12
- 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 +64 -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 +18 -0
- package/dist/config.js +9 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +56 -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/explore.d.ts +365 -0
- package/dist/explore.js +440 -0
- package/dist/explore.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 +7 -0
- package/dist/index.js +7 -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 +270 -29
- package/dist/manifest.js +190 -22
- package/dist/manifest.js.map +1 -1
- package/dist/naming.d.ts +83 -7
- package/dist/naming.js +89 -8
- package/dist/naming.js.map +1 -1
- package/dist/platform-api.d.ts +5897 -1672
- package/dist/platform-api.js +218 -8
- package/dist/platform-api.js.map +1 -1
- 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 +2 -0
- package/dist/router/decide.js +38 -6
- 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 +65 -0
- package/dist/storage.js +122 -0
- package/dist/storage.js.map +1 -0
- package/dist/telemetry.d.ts +135 -20
- package/dist/telemetry.js +108 -22
- 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 +19 -7
- package/src/api.ts +564 -15
- package/src/auth.ts +6 -2
- package/src/base64url.ts +13 -0
- package/src/bindings.ts +67 -6
- package/src/cloudfront-function.ts +64 -2
- package/src/compute.ts +86 -0
- package/src/config.ts +31 -1
- package/src/constants.ts +64 -1
- package/src/email.ts +168 -0
- package/src/explore.ts +504 -0
- package/src/fingerprint.ts +20 -0
- package/src/index.ts +7 -0
- package/src/jobs.ts +281 -0
- package/src/manifest.ts +415 -45
- package/src/naming.ts +93 -9
- package/src/platform-api.ts +249 -8
- package/src/realtime.ts +298 -0
- package/src/router/decide.d.ts +2 -0
- package/src/router/decide.js +38 -6
- package/src/router.ts +33 -13
- package/src/runtime-config.ts +70 -0
- package/src/storage.ts +131 -0
- package/src/telemetry.ts +115 -22
- package/src/web-compute.ts +342 -0
package/dist/explore.js
ADDED
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The explorer's query model. The control plane answers it (the series
|
|
3
|
+
* endpoint) and evaluates alert rules with it; the console builds charts and
|
|
4
|
+
* alert rules from it; the CLI sends it.
|
|
5
|
+
*
|
|
6
|
+
* Every metric is read from the rollups the telemetry processor writes
|
|
7
|
+
* (`telemetryKeys`), except `realtime` and `service`, which come from
|
|
8
|
+
* CloudWatch on demand and so can't be watched by alert rules.
|
|
9
|
+
*/
|
|
10
|
+
import { Schema } from 'effect';
|
|
11
|
+
const optional = Schema.optional;
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Resolution
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Bucket sizes a query can ask for. `1m`, `1h` and `1d` are stored; the
|
|
17
|
+
* others are sums of 1-minute rollups (latency histograms add), so they
|
|
18
|
+
* reach back only as far as minute rollups are kept.
|
|
19
|
+
*/
|
|
20
|
+
export const QueryResolution = Schema.Literals(['1m', '5m', '10m', '15m', '30m', '1h', '1d']);
|
|
21
|
+
export const QUERY_RESOLUTION_MS = {
|
|
22
|
+
'1m': 60_000,
|
|
23
|
+
'5m': 300_000,
|
|
24
|
+
'10m': 600_000,
|
|
25
|
+
'15m': 900_000,
|
|
26
|
+
'30m': 1_800_000,
|
|
27
|
+
'1h': 3_600_000,
|
|
28
|
+
'1d': 86_400_000,
|
|
29
|
+
};
|
|
30
|
+
/** About this many buckets per chart when the caller doesn't pick a resolution. */
|
|
31
|
+
export const TARGET_POINTS = 150;
|
|
32
|
+
/**
|
|
33
|
+
* The smallest resolution that keeps `from`..`to` near `TARGET_POINTS`
|
|
34
|
+
* buckets, given how far back minute rollups reach (`minuteHorizonMs` before
|
|
35
|
+
* `now`): a range starting before that horizon can't be built from 1-minute
|
|
36
|
+
* rows, so it uses hours (or days past 14 days).
|
|
37
|
+
*/
|
|
38
|
+
export function autoQueryResolution(from, to, now, minuteHorizonMs) {
|
|
39
|
+
const span = Math.max(to - from, 60_000);
|
|
40
|
+
const minuteOk = from >= now - minuteHorizonMs;
|
|
41
|
+
const ladder = minuteOk
|
|
42
|
+
? ['1m', '5m', '10m', '15m', '30m', '1h', '1d']
|
|
43
|
+
: ['1h', '1d'];
|
|
44
|
+
for (const res of ladder)
|
|
45
|
+
if (span / QUERY_RESOLUTION_MS[res] <= TARGET_POINTS * 1.5)
|
|
46
|
+
return res;
|
|
47
|
+
return '1d';
|
|
48
|
+
}
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Queries
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
/**
|
|
53
|
+
* What a query measures:
|
|
54
|
+
* - `requests`: HTTP requests (stage-wide, or of routes)
|
|
55
|
+
* - `latency`: their duration
|
|
56
|
+
* - `cold_starts`: requests served by a fresh server process
|
|
57
|
+
* - `jobs`: queue, event, cron, invoke and service runs
|
|
58
|
+
* - `job_duration`: their duration
|
|
59
|
+
* - `custom`: the app's `Metrics.count`/`value` series
|
|
60
|
+
* - `rate_limit`: `RateLimits` checks
|
|
61
|
+
* - `realtime`: AppSync Events activity (CloudWatch)
|
|
62
|
+
* - `service`: long-running services' CPU and memory (CloudWatch)
|
|
63
|
+
*/
|
|
64
|
+
export const SeriesMetric = Schema.Literals([
|
|
65
|
+
'requests',
|
|
66
|
+
'latency',
|
|
67
|
+
'cold_starts',
|
|
68
|
+
'jobs',
|
|
69
|
+
'job_duration',
|
|
70
|
+
'custom',
|
|
71
|
+
'rate_limit',
|
|
72
|
+
'realtime',
|
|
73
|
+
'service',
|
|
74
|
+
]);
|
|
75
|
+
/**
|
|
76
|
+
* How each bucket is summarized:
|
|
77
|
+
* - `count`: how many (requests, runs, checks, recorded values)
|
|
78
|
+
* - `rate`: `count` per second
|
|
79
|
+
* - `percent`: the share, 0–100, of the metric's events that match the
|
|
80
|
+
* status or outcome filter, among all of them in the bucket (5xx % of
|
|
81
|
+
* requests, failed % of runs, denied % of checks)
|
|
82
|
+
* - `sum`, `avg`, `max`: of recorded values (custom metrics, realtime, service)
|
|
83
|
+
* - `p50`…`p99`: latency percentiles, from the rollups' fixed-bucket histograms
|
|
84
|
+
* (each is the upper bound of the bucket holding it)
|
|
85
|
+
* - `histogram`: every latency bucket's count, for heatmaps
|
|
86
|
+
*/
|
|
87
|
+
export const SeriesStat = Schema.Literals([
|
|
88
|
+
'count',
|
|
89
|
+
'rate',
|
|
90
|
+
'percent',
|
|
91
|
+
'sum',
|
|
92
|
+
'avg',
|
|
93
|
+
'max',
|
|
94
|
+
'p50',
|
|
95
|
+
'p90',
|
|
96
|
+
'p95',
|
|
97
|
+
'p99',
|
|
98
|
+
'histogram',
|
|
99
|
+
]);
|
|
100
|
+
export const StatusClass = Schema.Literals(['2xx', '3xx', '4xx', '5xx']);
|
|
101
|
+
export const STATUS_CLASSES = ['2xx', '3xx', '4xx', '5xx'];
|
|
102
|
+
/** Splits a query into one line per value of this dimension. */
|
|
103
|
+
export const SeriesGroupBy = Schema.Literals(['status', 'route', 'job', 'outcome', 'name']);
|
|
104
|
+
export const SeriesOutcome = Schema.Literals(['ok', 'error', 'allowed', 'denied']);
|
|
105
|
+
const nonEmpty = Schema.String.check(Schema.isNonEmpty());
|
|
106
|
+
export const SeriesFilter = Schema.Struct({
|
|
107
|
+
/** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
|
|
108
|
+
routes: optional(Schema.Array(nonEmpty)),
|
|
109
|
+
/** `requests` only. */
|
|
110
|
+
status: optional(Schema.Array(StatusClass)),
|
|
111
|
+
/** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
|
|
112
|
+
jobs: optional(Schema.Array(nonEmpty)),
|
|
113
|
+
/** Custom metric names, rate limit names, or service names. */
|
|
114
|
+
names: optional(Schema.Array(nonEmpty)),
|
|
115
|
+
/** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
|
|
116
|
+
outcome: optional(SeriesOutcome),
|
|
117
|
+
/** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
|
|
118
|
+
measure: optional(nonEmpty),
|
|
119
|
+
});
|
|
120
|
+
export const SeriesQuery = Schema.Struct({
|
|
121
|
+
metric: SeriesMetric,
|
|
122
|
+
stat: SeriesStat,
|
|
123
|
+
filter: optional(SeriesFilter),
|
|
124
|
+
groupBy: optional(SeriesGroupBy),
|
|
125
|
+
/** Another stage than the page's. */
|
|
126
|
+
stage: optional(nonEmpty),
|
|
127
|
+
});
|
|
128
|
+
/** The statistics each metric answers; the first is its default. */
|
|
129
|
+
export const METRIC_STATS = {
|
|
130
|
+
requests: ['count', 'rate', 'percent'],
|
|
131
|
+
latency: ['p95', 'p50', 'p90', 'p99', 'histogram'],
|
|
132
|
+
cold_starts: ['count', 'percent'],
|
|
133
|
+
jobs: ['count', 'rate', 'percent'],
|
|
134
|
+
job_duration: ['p95', 'p50', 'p90', 'p99', 'histogram'],
|
|
135
|
+
custom: ['sum', 'avg', 'count', 'max'],
|
|
136
|
+
rate_limit: ['count', 'percent'],
|
|
137
|
+
realtime: ['sum'],
|
|
138
|
+
service: ['avg', 'max'],
|
|
139
|
+
};
|
|
140
|
+
/** The dimensions each metric can be grouped by. */
|
|
141
|
+
export const METRIC_GROUP_BY = {
|
|
142
|
+
requests: ['status', 'route'],
|
|
143
|
+
latency: ['route'],
|
|
144
|
+
cold_starts: [],
|
|
145
|
+
jobs: ['job', 'outcome'],
|
|
146
|
+
job_duration: ['job'],
|
|
147
|
+
custom: ['name'],
|
|
148
|
+
rate_limit: ['name', 'outcome'],
|
|
149
|
+
realtime: [],
|
|
150
|
+
service: ['name'],
|
|
151
|
+
};
|
|
152
|
+
/** Metrics alert rules can watch: those read from rollups. */
|
|
153
|
+
export const ALERT_METRICS = [
|
|
154
|
+
'requests',
|
|
155
|
+
'latency',
|
|
156
|
+
'cold_starts',
|
|
157
|
+
'jobs',
|
|
158
|
+
'job_duration',
|
|
159
|
+
'custom',
|
|
160
|
+
'rate_limit',
|
|
161
|
+
];
|
|
162
|
+
export const REALTIME_MEASURES = ['events', 'publishes', 'subscribes', 'errors'];
|
|
163
|
+
export const SERVICE_MEASURES = ['cpu', 'memory'];
|
|
164
|
+
/**
|
|
165
|
+
* Why a query can't be answered, or undefined when it can. `alert` also
|
|
166
|
+
* refuses what an alert rule can't watch: CloudWatch metrics, histograms,
|
|
167
|
+
* groups, and another stage than the rule's.
|
|
168
|
+
*/
|
|
169
|
+
export function checkSeriesQuery(q, options = {}) {
|
|
170
|
+
if (!METRIC_STATS[q.metric].includes(q.stat)) {
|
|
171
|
+
return `${q.metric} answers ${METRIC_STATS[q.metric].join(', ')}, not ${q.stat}`;
|
|
172
|
+
}
|
|
173
|
+
if (q.groupBy && !METRIC_GROUP_BY[q.metric].includes(q.groupBy)) {
|
|
174
|
+
const groups = METRIC_GROUP_BY[q.metric];
|
|
175
|
+
return groups.length
|
|
176
|
+
? `${q.metric} can be grouped by ${groups.join(' or ')}, not ${q.groupBy}`
|
|
177
|
+
: `${q.metric} can't be grouped`;
|
|
178
|
+
}
|
|
179
|
+
const f = q.filter ?? {};
|
|
180
|
+
if (f.status?.length && q.metric !== 'requests')
|
|
181
|
+
return 'only requests filter by status';
|
|
182
|
+
if (f.routes?.length && q.metric !== 'requests' && q.metric !== 'latency' && q.metric !== 'cold_starts') {
|
|
183
|
+
return 'only requests, latency and cold starts filter by route';
|
|
184
|
+
}
|
|
185
|
+
if (f.jobs?.length && q.metric !== 'jobs' && q.metric !== 'job_duration')
|
|
186
|
+
return 'only jobs filter by job';
|
|
187
|
+
if (f.outcome) {
|
|
188
|
+
const allowed = q.metric === 'jobs' ? ['ok', 'error'] : q.metric === 'rate_limit' ? ['allowed', 'denied'] : [];
|
|
189
|
+
if (!allowed.includes(f.outcome)) {
|
|
190
|
+
return allowed.length
|
|
191
|
+
? `${q.metric} outcomes are ${allowed.join(' or ')}`
|
|
192
|
+
: `${q.metric} doesn't filter by outcome`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (f.names?.length && q.metric !== 'custom' && q.metric !== 'rate_limit' && q.metric !== 'service') {
|
|
196
|
+
return 'only custom metrics, rate limits and services filter by name';
|
|
197
|
+
}
|
|
198
|
+
if (q.metric === 'custom' && !f.names?.length && q.groupBy !== 'name') {
|
|
199
|
+
return 'a custom metric query names its metric, or groups by name';
|
|
200
|
+
}
|
|
201
|
+
if (q.metric === 'realtime' && !REALTIME_MEASURES.some((m) => m === f.measure)) {
|
|
202
|
+
return `realtime measures one of ${REALTIME_MEASURES.join(', ')}`;
|
|
203
|
+
}
|
|
204
|
+
if (q.metric === 'service' && !SERVICE_MEASURES.some((m) => m === f.measure)) {
|
|
205
|
+
return `service measures ${SERVICE_MEASURES.join(' or ')}`;
|
|
206
|
+
}
|
|
207
|
+
if (q.metric !== 'realtime' && q.metric !== 'service' && f.measure) {
|
|
208
|
+
return 'only realtime and service queries take a measure';
|
|
209
|
+
}
|
|
210
|
+
if (options.alert) {
|
|
211
|
+
if (!ALERT_METRICS.includes(q.metric))
|
|
212
|
+
return `alert rules can't watch ${q.metric}`;
|
|
213
|
+
if (q.stat === 'histogram')
|
|
214
|
+
return 'alert rules watch one number, not a histogram';
|
|
215
|
+
if (q.groupBy)
|
|
216
|
+
return 'alert rules watch one series; filter instead of grouping';
|
|
217
|
+
if (q.stage)
|
|
218
|
+
return "an alert rule's query reads the rule's own stage";
|
|
219
|
+
}
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
/** The unit a query's values are in (a custom metric's own unit comes with its series). */
|
|
223
|
+
const STAT_UNIT = {
|
|
224
|
+
count: 'count',
|
|
225
|
+
rate: 'per_second',
|
|
226
|
+
percent: 'percent',
|
|
227
|
+
sum: 'count',
|
|
228
|
+
avg: 'count',
|
|
229
|
+
max: 'count',
|
|
230
|
+
p50: 'ms',
|
|
231
|
+
p90: 'ms',
|
|
232
|
+
p95: 'ms',
|
|
233
|
+
p99: 'ms',
|
|
234
|
+
histogram: 'ms',
|
|
235
|
+
};
|
|
236
|
+
export function seriesUnit(q) {
|
|
237
|
+
const unit = STAT_UNIT[q.stat];
|
|
238
|
+
// Service CPU and memory are percentages of what the task reserved.
|
|
239
|
+
return unit === 'count' && q.metric === 'service' ? 'percent' : unit;
|
|
240
|
+
}
|
|
241
|
+
const METRIC_NOUN = {
|
|
242
|
+
requests: 'requests',
|
|
243
|
+
latency: 'latency',
|
|
244
|
+
cold_starts: 'cold starts',
|
|
245
|
+
jobs: 'job runs',
|
|
246
|
+
job_duration: 'job duration',
|
|
247
|
+
custom: 'custom metric',
|
|
248
|
+
rate_limit: 'rate limit checks',
|
|
249
|
+
realtime: 'realtime',
|
|
250
|
+
service: 'service',
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* A short label for a query, as charts, alert emails and the CLI show it:
|
|
254
|
+
* `5xx % of requests`, `p95 latency of GET /api/x`, `failed % of job runs`.
|
|
255
|
+
*/
|
|
256
|
+
export function describeQuery(q) {
|
|
257
|
+
const f = q.filter ?? {};
|
|
258
|
+
const noun = METRIC_NOUN[q.metric];
|
|
259
|
+
const scope = [
|
|
260
|
+
f.routes?.length ? (f.routes.length === 1 ? f.routes[0] : `${f.routes.length} routes`) : undefined,
|
|
261
|
+
f.jobs?.length ? (f.jobs.length === 1 ? f.jobs[0] : `${f.jobs.length} jobs`) : undefined,
|
|
262
|
+
].filter(Boolean);
|
|
263
|
+
const of = scope.length ? ` of ${scope.join(', ')}` : '';
|
|
264
|
+
const by = q.groupBy ? ` by ${q.groupBy}` : '';
|
|
265
|
+
const where = q.stage ? ` (${q.stage})` : '';
|
|
266
|
+
const subset = f.status?.length
|
|
267
|
+
? f.status.join('+')
|
|
268
|
+
: f.outcome === 'error'
|
|
269
|
+
? 'failed'
|
|
270
|
+
: f.outcome
|
|
271
|
+
? f.outcome
|
|
272
|
+
: undefined;
|
|
273
|
+
const generic = () => {
|
|
274
|
+
if (q.stat === 'percent')
|
|
275
|
+
return `${subset ?? 'all'} % of ${noun}`;
|
|
276
|
+
if (q.stat === 'rate')
|
|
277
|
+
return `${subset ? `${subset} ` : ''}${noun} per second`;
|
|
278
|
+
if (q.stat === 'count')
|
|
279
|
+
return `${subset ? `${subset} ` : ''}${noun}`;
|
|
280
|
+
if (q.stat === 'histogram')
|
|
281
|
+
return `${noun} distribution`;
|
|
282
|
+
return `${q.stat} ${noun}`;
|
|
283
|
+
};
|
|
284
|
+
let head;
|
|
285
|
+
switch (q.metric) {
|
|
286
|
+
case 'custom':
|
|
287
|
+
head = `${q.stat} of ${f.names?.length ? f.names.join(', ') : 'custom metrics'}`;
|
|
288
|
+
break;
|
|
289
|
+
case 'realtime':
|
|
290
|
+
head = `realtime ${f.measure ?? 'events'}`;
|
|
291
|
+
break;
|
|
292
|
+
case 'service':
|
|
293
|
+
head = `${q.stat} ${f.measure ?? 'cpu'}${f.names?.length ? ` of ${f.names.join(', ')}` : ''}`;
|
|
294
|
+
break;
|
|
295
|
+
case 'rate_limit':
|
|
296
|
+
head =
|
|
297
|
+
q.stat === 'percent'
|
|
298
|
+
? `${subset ?? 'denied'} % of rate limit checks`
|
|
299
|
+
: `${subset ? `${subset} ` : ''}rate limit checks`;
|
|
300
|
+
if (f.names?.length)
|
|
301
|
+
head += ` (${f.names.join(', ')})`;
|
|
302
|
+
break;
|
|
303
|
+
case 'requests':
|
|
304
|
+
case 'latency':
|
|
305
|
+
case 'cold_starts':
|
|
306
|
+
case 'jobs':
|
|
307
|
+
case 'job_duration':
|
|
308
|
+
head = generic();
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
return `${head}${of}${by}${where}`;
|
|
312
|
+
}
|
|
313
|
+
// ---------------------------------------------------------------------------
|
|
314
|
+
// Charts and filters
|
|
315
|
+
// ---------------------------------------------------------------------------
|
|
316
|
+
/** A query of an explorer chart, with the id expressions refer to it by (`a`, `b`, …). */
|
|
317
|
+
export const NamedSeriesQuery = Schema.Struct({
|
|
318
|
+
id: Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9]{0,7}$/)),
|
|
319
|
+
...SeriesQuery.fields,
|
|
320
|
+
label: optional(Schema.String),
|
|
321
|
+
/** Charted only through expressions. */
|
|
322
|
+
hidden: optional(Schema.Boolean),
|
|
323
|
+
});
|
|
324
|
+
/** Arithmetic over other queries' values in the same bucket, e.g. `100 * a / b` (evaluated by the console). */
|
|
325
|
+
export const SeriesExpression = Schema.Struct({
|
|
326
|
+
id: Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9]{0,7}$/)),
|
|
327
|
+
expr: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)),
|
|
328
|
+
label: optional(Schema.String),
|
|
329
|
+
hidden: optional(Schema.Boolean),
|
|
330
|
+
});
|
|
331
|
+
export const ChartKind = Schema.Literals(['line', 'area', 'bar', 'heatmap']);
|
|
332
|
+
export const MetricsView = Schema.Struct({
|
|
333
|
+
kind: Schema.Literal('metrics'),
|
|
334
|
+
queries: Schema.Array(NamedSeriesQuery).check(Schema.isMinLength(1), Schema.isMaxLength(8)),
|
|
335
|
+
expressions: optional(Schema.Array(SeriesExpression).check(Schema.isMaxLength(8))),
|
|
336
|
+
chart: ChartKind,
|
|
337
|
+
scale: optional(Schema.Literals(['linear', 'log'])),
|
|
338
|
+
/** A line drawn across the chart, e.g. an alert threshold. */
|
|
339
|
+
threshold: optional(Schema.Finite),
|
|
340
|
+
});
|
|
341
|
+
export const LogLevelName = Schema.Literals(['error', 'warn', 'info', 'debug', 'system']);
|
|
342
|
+
/**
|
|
343
|
+
* Structured log filters. Any of them makes a search run on Logs Insights
|
|
344
|
+
* (CloudWatch filter patterns can't combine text with JSON fields).
|
|
345
|
+
*/
|
|
346
|
+
export const LogFilters = Schema.Struct({
|
|
347
|
+
levels: optional(Schema.Array(LogLevelName)),
|
|
348
|
+
/** `web`, `worker` or `service:<name>`. */
|
|
349
|
+
streams: optional(Schema.Array(nonEmpty)),
|
|
350
|
+
/** Route patterns (without the method), e.g. `/api/items/:id`. */
|
|
351
|
+
routes: optional(Schema.Array(nonEmpty)),
|
|
352
|
+
status: optional(Schema.Array(StatusClass)),
|
|
353
|
+
/** Deployment ids. */
|
|
354
|
+
revs: optional(Schema.Array(nonEmpty)),
|
|
355
|
+
trace: optional(nonEmpty),
|
|
356
|
+
});
|
|
357
|
+
export const TraceFilters = Schema.Struct({
|
|
358
|
+
kind: optional(Schema.Literals(['req', 'job'])),
|
|
359
|
+
/** `METHOD /pattern`. */
|
|
360
|
+
routes: optional(Schema.Array(nonEmpty)),
|
|
361
|
+
/** `kind:name`. */
|
|
362
|
+
jobs: optional(Schema.Array(nonEmpty)),
|
|
363
|
+
/** `error`: 5xx requests and failed jobs; `ok`: the rest. */
|
|
364
|
+
outcome: optional(Schema.Literals(['ok', 'error'])),
|
|
365
|
+
minMs: optional(Schema.Finite),
|
|
366
|
+
/** Only traces whose spans were written (failed, slow or sampled). */
|
|
367
|
+
recorded: optional(Schema.Boolean),
|
|
368
|
+
});
|
|
369
|
+
// ---------------------------------------------------------------------------
|
|
370
|
+
// Alert rules
|
|
371
|
+
// ---------------------------------------------------------------------------
|
|
372
|
+
export const AlertState = Schema.Literals(['ok', 'alarm', 'no_data']);
|
|
373
|
+
/** Minutes an alert rule's window can cover. */
|
|
374
|
+
export const ALERT_WINDOWS = [1, 5, 10, 15, 30, 60];
|
|
375
|
+
/** How long the evaluator waits for a minute's telemetry to arrive before reading it. */
|
|
376
|
+
export const ALERT_LAG_MINUTES = 2;
|
|
377
|
+
export const MAX_ALERT_RULES_PER_APP = 25;
|
|
378
|
+
/** How long alert state changes are kept. */
|
|
379
|
+
export const ALERT_HISTORY_DAYS = 90;
|
|
380
|
+
const name = Schema.Trim.check(Schema.isNonEmpty(), Schema.isMaxLength(80));
|
|
381
|
+
export const AlertCondition = Schema.Struct({
|
|
382
|
+
op: Schema.Literals(['above', 'below']),
|
|
383
|
+
threshold: Schema.Finite,
|
|
384
|
+
/** The query is summarized over the last this many minutes (sums, shares and histograms of the window). */
|
|
385
|
+
minutes: Schema.Literals(ALERT_WINDOWS),
|
|
386
|
+
});
|
|
387
|
+
/**
|
|
388
|
+
* A window with no data (no requests behind a percentage or percentile, no
|
|
389
|
+
* values of a custom metric): `ok` and `alarm` treat it as that state,
|
|
390
|
+
* `keep` keeps the current one. Counts are never missing: no events is 0.
|
|
391
|
+
*/
|
|
392
|
+
export const AlertMissingData = Schema.Literals(['ok', 'alarm', 'keep']);
|
|
393
|
+
export const AlertRuleInput = Schema.Struct({
|
|
394
|
+
name,
|
|
395
|
+
stage: nonEmpty,
|
|
396
|
+
query: SeriesQuery,
|
|
397
|
+
condition: AlertCondition,
|
|
398
|
+
missing: AlertMissingData,
|
|
399
|
+
/** Email the platform's alerts topic when the rule fires and when it recovers. */
|
|
400
|
+
notify: Schema.Boolean,
|
|
401
|
+
enabled: Schema.Boolean,
|
|
402
|
+
});
|
|
403
|
+
export const AlertRule = Schema.Struct({
|
|
404
|
+
id: Schema.String,
|
|
405
|
+
app: Schema.String,
|
|
406
|
+
...AlertRuleInput.fields,
|
|
407
|
+
state: AlertState,
|
|
408
|
+
/** When `state` last changed. */
|
|
409
|
+
stateSince: optional(Schema.String),
|
|
410
|
+
/** The window's value at the last evaluation (null: no data). */
|
|
411
|
+
value: optional(Schema.NullOr(Schema.Finite)),
|
|
412
|
+
evaluatedAt: optional(Schema.String),
|
|
413
|
+
createdBy: Schema.String,
|
|
414
|
+
createdAt: Schema.String,
|
|
415
|
+
updatedAt: Schema.String,
|
|
416
|
+
});
|
|
417
|
+
export const AlertEvent = Schema.Struct({
|
|
418
|
+
ts: Schema.String,
|
|
419
|
+
rule: Schema.String,
|
|
420
|
+
name: Schema.String,
|
|
421
|
+
stage: Schema.String,
|
|
422
|
+
from: AlertState,
|
|
423
|
+
to: AlertState,
|
|
424
|
+
value: Schema.NullOr(Schema.Finite),
|
|
425
|
+
threshold: Schema.Finite,
|
|
426
|
+
});
|
|
427
|
+
export const AlertHistoryResponse = Schema.Struct({ events: Schema.Array(AlertEvent) });
|
|
428
|
+
export const breaches = (value, c) => c.op === 'above' ? value > c.threshold : value < c.threshold;
|
|
429
|
+
/** The state a rule moves to given its window's value (null: no data). */
|
|
430
|
+
export function nextAlertState(current, value, rule) {
|
|
431
|
+
if (value === null) {
|
|
432
|
+
if (rule.missing === 'ok')
|
|
433
|
+
return 'ok';
|
|
434
|
+
if (rule.missing === 'alarm')
|
|
435
|
+
return 'alarm';
|
|
436
|
+
return current === 'alarm' || current === 'ok' ? current : 'no_data';
|
|
437
|
+
}
|
|
438
|
+
return breaches(value, rule.condition) ? 'alarm' : 'ok';
|
|
439
|
+
}
|
|
440
|
+
//# sourceMappingURL=explore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explore.js","sourceRoot":"","sources":["../src/explore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEjC,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAG9F,MAAM,CAAC,MAAM,mBAAmB,GAAoC;IAClE,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,EAAU,EACV,GAAW,EACX,eAAuB;IAEvB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAI,IAAI,GAAG,GAAG,eAAe,CAAC;IAC/C,MAAM,MAAM,GAA+B,QAAQ;QACjD,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC;QAC/C,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAA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AC9F,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,SAAS,CAAC;AAE/D,0EAA0E;AAC1E,MAAM,UAAU,cAAc,CAC5B,OAAmB,EACnB,KAAoB,EACpB,IAAgF;IAEhF,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACvC,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC;QAC7C,OAAO,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACvE,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable short hashes (FNV-1a 32-bit): no crypto dependency so the SDK stays
|
|
3
|
+
* tiny. Their own module so naming (and the `./naming` subpath) doesn't pull
|
|
4
|
+
* in Effect through telemetry.
|
|
5
|
+
*/
|
|
6
|
+
/** FNV-1a of `s`'s code points, as an unsigned 32-bit integer. */
|
|
7
|
+
export declare function fnv1a(s: string): number;
|
|
8
|
+
/** `fnv1a` of the parts joined with `|`, as 8 hex digits. */
|
|
9
|
+
export declare function fingerprint(parts: readonly string[]): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable short hashes (FNV-1a 32-bit): no crypto dependency so the SDK stays
|
|
3
|
+
* tiny. Their own module so naming (and the `./naming` subpath) doesn't pull
|
|
4
|
+
* in Effect through telemetry.
|
|
5
|
+
*/
|
|
6
|
+
/** FNV-1a of `s`'s code points, as an unsigned 32-bit integer. */
|
|
7
|
+
export function fnv1a(s) {
|
|
8
|
+
let h = 0x811c9dc5;
|
|
9
|
+
for (const ch of s) {
|
|
10
|
+
h ^= ch.codePointAt(0);
|
|
11
|
+
h = Math.imul(h, 0x01000193) >>> 0;
|
|
12
|
+
}
|
|
13
|
+
return h;
|
|
14
|
+
}
|
|
15
|
+
/** `fnv1a` of the parts joined with `|`, as 8 hex digits. */
|
|
16
|
+
export function fingerprint(parts) {
|
|
17
|
+
return fnv1a(parts.join('|')).toString(16).padStart(8, '0');
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kEAAkE;AAClE,MAAM,UAAU,KAAK,CAAC,CAAS;IAC7B,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACnB,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC;QACxB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,WAAW,CAAC,KAAwB;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
export * from './api.ts';
|
|
2
2
|
export * from './auth.ts';
|
|
3
3
|
export * from './bindings.ts';
|
|
4
|
+
export * from './compute.ts';
|
|
4
5
|
export * from './config.ts';
|
|
5
6
|
export * from './constants.ts';
|
|
6
7
|
export * from './cron.ts';
|
|
8
|
+
export * from './email.ts';
|
|
9
|
+
export * from './explore.ts';
|
|
7
10
|
export * from './ids.ts';
|
|
11
|
+
export * from './jobs.ts';
|
|
8
12
|
export * from './manifest.ts';
|
|
9
13
|
export * from './naming.ts';
|
|
14
|
+
export * from './realtime.ts';
|
|
10
15
|
export * from './router.ts';
|
|
11
16
|
export * from './runtime-config.ts';
|
|
17
|
+
export * from './storage.ts';
|
|
12
18
|
export * from './telemetry.ts';
|
|
19
|
+
export * from './web-compute.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
export * from './api.js';
|
|
2
2
|
export * from './auth.js';
|
|
3
3
|
export * from './bindings.js';
|
|
4
|
+
export * from './compute.js';
|
|
4
5
|
export * from './config.js';
|
|
5
6
|
export * from './constants.js';
|
|
6
7
|
export * from './cron.js';
|
|
8
|
+
export * from './email.js';
|
|
9
|
+
export * from './explore.js';
|
|
7
10
|
export * from './ids.js';
|
|
11
|
+
export * from './jobs.js';
|
|
8
12
|
export * from './manifest.js';
|
|
9
13
|
export * from './naming.js';
|
|
14
|
+
export * from './realtime.js';
|
|
10
15
|
export * from './router.js';
|
|
11
16
|
export * from './runtime-config.js';
|
|
17
|
+
export * from './storage.js';
|
|
12
18
|
export * from './telemetry.js';
|
|
19
|
+
export * from './web-compute.js';
|
|
13
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
package/dist/jobs.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { HandlerKind } from './manifest.ts';
|
|
2
|
+
/** Marker on every job payload the platform sends to a worker function. */
|
|
3
|
+
export declare const JOB_MARKER = "job";
|
|
4
|
+
/** What a worker function receives for a queue message, a retry, or a delayed send. */
|
|
5
|
+
export interface JobPayload {
|
|
6
|
+
__platform: typeof JOB_MARKER;
|
|
7
|
+
kind: HandlerKind;
|
|
8
|
+
/** Queue or cron key, or event type. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Stable across retries: the message's id, the event's id, or the cron run's. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Which delivery this is, from 1. */
|
|
13
|
+
attempt: number;
|
|
14
|
+
/** Epoch ms when the message was sent, the event published or the cron fired. */
|
|
15
|
+
sentAt: number;
|
|
16
|
+
/** A queue message's body. */
|
|
17
|
+
body?: unknown;
|
|
18
|
+
/** An event's detail. */
|
|
19
|
+
detail?: unknown;
|
|
20
|
+
trace?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The largest job payload, in bytes of JSON. Retries and delayed sends go
|
|
24
|
+
* through a Scheduler schedule, whose input is capped at 256 KB, and a dead
|
|
25
|
+
* letter wraps the payload with its error, so this leaves room for both.
|
|
26
|
+
*/
|
|
27
|
+
export declare const JOB_PAYLOAD_MAX_BYTES: number;
|
|
28
|
+
/** Attempts per kind when a handler sets none. Lambda retried events and crons twice before. */
|
|
29
|
+
export declare const DEFAULT_ATTEMPTS: Readonly<Record<HandlerKind, number>>;
|
|
30
|
+
export declare const MAX_ATTEMPTS = 100;
|
|
31
|
+
/** The longest delay `send` takes: a one-shot schedule can be any time ahead, a year is plenty. */
|
|
32
|
+
export declare const MAX_JOB_DELAY_SECONDS: number;
|
|
33
|
+
/**
|
|
34
|
+
* Scheduler fires a one-shot schedule within about a minute of its time, and
|
|
35
|
+
* refuses times in the past, so a delayed send or retry is scheduled at least
|
|
36
|
+
* this far ahead.
|
|
37
|
+
*/
|
|
38
|
+
export declare const MIN_SCHEDULE_LEAD_SECONDS = 60;
|
|
39
|
+
/** Seconds before attempt `failed + 1`: 1, 2, 4 … minutes, at most an hour. */
|
|
40
|
+
export declare function retryDelaySeconds(failed: number): number;
|
|
41
|
+
/** `kind:name`, the key bindings use for a handler. */
|
|
42
|
+
export declare const handlerKey: (kind: HandlerKind, name: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Name of the one-shot schedule for a retry or delayed send (≤ 64 chars of
|
|
45
|
+
* Scheduler's alphabet). It leads with `_`, which no cron key (a cron's own
|
|
46
|
+
* schedule) or service stop schedule (`<key>--stop`) starts with, then the
|
|
47
|
+
* kind and queue or cron key, so the console can count what's waiting per
|
|
48
|
+
* queue with a name prefix. Event types can be long and contain `:`, so they
|
|
49
|
+
* are hashed.
|
|
50
|
+
*/
|
|
51
|
+
export declare function jobScheduleName(kind: HandlerKind, name: string, id: string): string;
|
|
52
|
+
export declare function jobSchedulePrefix(kind: HandlerKind, name: string): string;
|
|
53
|
+
export declare const isJobSchedule: (name: string) => boolean;
|
|
54
|
+
/** One-shot schedule expression for `at` (UTC, whole seconds). */
|
|
55
|
+
export declare function atExpression(at: Date): string;
|
|
56
|
+
/** What the SDK writes to the dead-letter queue when a handler failed its last attempt. */
|
|
57
|
+
export interface DeadLetter {
|
|
58
|
+
v: 1;
|
|
59
|
+
job: JobPayload;
|
|
60
|
+
/** Epoch ms. */
|
|
61
|
+
failedAt: number;
|
|
62
|
+
error: {
|
|
63
|
+
name: string;
|
|
64
|
+
message: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** A dead-letter queue message, whoever wrote it, in the terms the console shows. */
|
|
68
|
+
export interface DeadLetterView {
|
|
69
|
+
/** `invoke` is a direct `invokeJob` call that crashed or timed out. */
|
|
70
|
+
kind: HandlerKind | 'invoke';
|
|
71
|
+
name: string;
|
|
72
|
+
/** Deliveries made, when known. */
|
|
73
|
+
attempts: number | null;
|
|
74
|
+
error: {
|
|
75
|
+
name: string;
|
|
76
|
+
message: string;
|
|
77
|
+
};
|
|
78
|
+
/** Epoch ms. */
|
|
79
|
+
failedAt: number | null;
|
|
80
|
+
/** Who gave up: the SDK, Lambda (crash, timeout, too old), Scheduler or EventBridge (couldn't deliver). */
|
|
81
|
+
source: 'sdk' | 'lambda' | 'scheduler' | 'eventbridge';
|
|
82
|
+
/** What redriving sends, to the function the job's handler runs in now. */
|
|
83
|
+
redrive: JobPayload | {
|
|
84
|
+
__platform: 'invoke';
|
|
85
|
+
name: string;
|
|
86
|
+
payload: unknown;
|
|
87
|
+
trace?: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** SQS message attributes as the SDK returns them. */
|
|
91
|
+
type Attributes = Record<string, {
|
|
92
|
+
StringValue?: string;
|
|
93
|
+
} | undefined>;
|
|
94
|
+
/**
|
|
95
|
+
* Normalizes anything a worker function can receive into the job it stands
|
|
96
|
+
* for: a job payload as is, an EventBridge event, or a cron firing. `id` is
|
|
97
|
+
* used when the input carries none (a cron firing). Undefined for anything
|
|
98
|
+
* else, such as a direct `invoke`.
|
|
99
|
+
*/
|
|
100
|
+
export declare function toJob(input: unknown, id: string, now: number): JobPayload | undefined;
|
|
101
|
+
/** Reads a dead-letter queue message; null for one the platform didn't write. */
|
|
102
|
+
export declare function readDeadLetter(body: string, attributes?: Attributes): DeadLetterView | null;
|
|
103
|
+
/**
|
|
104
|
+
* The oldest `@ericminassian/platform` whose bundles this platform deploys:
|
|
105
|
+
* jobs became pushed (bindings v2) in 0.4.0, and an older worker can't read
|
|
106
|
+
* them.
|
|
107
|
+
*/
|
|
108
|
+
export declare const MIN_SDK_VERSION = "0.4.0";
|
|
109
|
+
/** Whether bundles built with SDK `version` can be deployed (undefined: a CLI older than 0.4.0 sent none). */
|
|
110
|
+
export declare function sdkSupported(version: string | undefined): boolean;
|
|
111
|
+
export {};
|