@encore.dev/sdk 2.0.0-beta.13 → 2.0.0-beta.15
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/README.md +48 -4
- package/config/config.test.ts +47 -13
- package/config/secrets.ts +6 -2
- package/cron/mod.test.ts +12 -0
- package/cron/mod.ts +18 -2
- package/dist/config/secrets.d.ts +4 -2
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +3 -0
- package/dist/config/secrets.js.map +1 -1
- package/dist/cron/mod.d.ts +17 -2
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +3 -2
- package/dist/cron/mod.js.map +1 -1
- package/dist/internal/otel/http.d.ts +4 -2
- package/dist/internal/otel/http.d.ts.map +1 -1
- package/dist/internal/otel/http.js +32 -5
- package/dist/internal/otel/http.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +6 -5
- package/dist/internal/runtime/napi/napi.d.cts +48 -13
- package/dist/redaction/mod.d.ts +62 -0
- package/dist/redaction/mod.d.ts.map +1 -0
- package/dist/redaction/mod.js +102 -0
- package/dist/redaction/mod.js.map +1 -0
- package/dist/storage/objects/bucket.d.ts +78 -22
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +95 -42
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/mod.d.ts +1 -1
- package/dist/storage/objects/mod.d.ts.map +1 -1
- package/dist/storage/objects/mod.js.map +1 -1
- package/dist/storage/objects/refs.d.ts +2 -5
- package/dist/storage/objects/refs.d.ts.map +1 -1
- package/dist/storage/objects/refs.js.map +1 -1
- package/dist/tracing/http.d.ts +2 -1
- package/dist/tracing/http.d.ts.map +1 -1
- package/dist/tracing/http.js +2 -1
- package/dist/tracing/http.js.map +1 -1
- package/dist/tracing/node.d.ts.map +1 -1
- package/dist/tracing/node.js +1 -1
- package/dist/tracing/node.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/internal/otel/http.test.ts +50 -0
- package/internal/otel/http.ts +40 -5
- package/internal/runtime/napi/napi.cjs +6 -5
- package/internal/runtime/napi/napi.d.cts +48 -13
- package/package.json +6 -1
- package/redaction/bridge.test.ts +99 -0
- package/redaction/mod.test.ts +188 -0
- package/redaction/mod.ts +226 -0
- package/storage/objects/bucket.test.ts +168 -16
- package/storage/objects/bucket.ts +181 -62
- package/storage/objects/mod.ts +1 -0
- package/storage/objects/refs.ts +2 -5
- package/tracing/http.ts +2 -1
- package/tracing/native.test.ts +158 -8
- package/tracing/node.ts +1 -0
package/README.md
CHANGED
|
@@ -3,6 +3,43 @@
|
|
|
3
3
|
This package contains the Encore JavaScript/TypeScript SDK, it is intended for you to use in your applications to develop
|
|
4
4
|
against the Encore API.
|
|
5
5
|
|
|
6
|
+
## Telemetry redaction
|
|
7
|
+
|
|
8
|
+
`redactor()` applies the deployed policy to copies without emitting telemetry.
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import {redactor} from '@encore.dev/sdk/redaction';
|
|
12
|
+
|
|
13
|
+
const redact = redactor();
|
|
14
|
+
const http = redact.http('POST', '/orders/private?token=secret');
|
|
15
|
+
const {route, path, query} = http.requestUrl();
|
|
16
|
+
const request = http.request({headers: wireHeaders, body: requestBytes});
|
|
17
|
+
const response = http.response({headers: responseHeaders, body: responseBytes});
|
|
18
|
+
|
|
19
|
+
// method is a real @bufbuild/protobuf DescMethod.
|
|
20
|
+
const grpc = redact.grpc(method);
|
|
21
|
+
const safeRequest = grpc.request({metadata, message: protobufBytes});
|
|
22
|
+
const safeResponse = grpc.response({
|
|
23
|
+
metadata,
|
|
24
|
+
message: protobufBytes,
|
|
25
|
+
trailers,
|
|
26
|
+
});
|
|
27
|
+
const published = redact.topic('submitted').publish(jsonBytes);
|
|
28
|
+
const delivered = redact.topic('submitted').delivery('worker', jsonBytes);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Headers, metadata, and trailers are iterables of `[string, string]` pairs.
|
|
32
|
+
gRPC binary metadata uses base64 wire
|
|
33
|
+
values. HTTP exchanges return `{headers, body?}`; gRPC exchanges return
|
|
34
|
+
`{metadata, message?}` and preserve supplied response trailers as `trailers`.
|
|
35
|
+
Omitting body/message skips payload capture; empty bytes still request capture.
|
|
36
|
+
Payloads retain the `omit`, `withheld`, or `recorded` tags; only `recorded`
|
|
37
|
+
contains safe `body` bytes and a `truncated` flag.
|
|
38
|
+
|
|
39
|
+
`requestUrl()` returns nullable `route`, `path`, and `query` strings. Query has
|
|
40
|
+
no leading `?`. Never replace null fields or omitted/withheld payloads with
|
|
41
|
+
original values. Server spans use these safe URL fields without raw fallbacks.
|
|
42
|
+
|
|
6
43
|
## Postgres handles
|
|
7
44
|
|
|
8
45
|
```typescript
|
|
@@ -186,10 +223,10 @@ runs the handler with an Encore-owned SERVER span active. Nested spans, logs,
|
|
|
186
223
|
metrics and service calls inherit it. Extra handler arguments and `this` are
|
|
187
224
|
preserved; no OTel globals are registered or replaced.
|
|
188
225
|
|
|
189
|
-
Span names
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
226
|
+
Span names are `METHOD /template` when deployed policy supplies a route,
|
|
227
|
+
otherwise `METHOD` with no `http.route`. Unknown methods use `HTTP`.
|
|
228
|
+
Recorded URL paths, queries, and user agents come only from deployed policy. Response status is recorded; 5xx responses and thrown errors
|
|
229
|
+
mark the span ERROR. Exceptions are rethrown.
|
|
193
230
|
The original response and its body are untouched: the span ends when the
|
|
194
231
|
handler returns a response, not when a streaming body finishes. Handlers must
|
|
195
232
|
return a `Response`; WebSocket upgrades need a runtime-specific adapter.
|
|
@@ -225,6 +262,13 @@ Failures before headers are sent have no recorded HTTP response status.
|
|
|
225
262
|
Synchronous return values are preserved; PromiseLike results become Promises.
|
|
226
263
|
HTTP upgrade and CONNECT events require separate instrumentation.
|
|
227
264
|
|
|
265
|
+
### Framework instrumentation
|
|
266
|
+
|
|
267
|
+
The Node and Fetch wrappers use the deployed route template, or just the
|
|
268
|
+
method if no route matches. For framework-specific routes, use the framework's
|
|
269
|
+
OpenTelemetry instrumentation with Encore's providers instead. Do not install
|
|
270
|
+
two server tracers for the same requests.
|
|
271
|
+
|
|
228
272
|
## Formatting and linting
|
|
229
273
|
|
|
230
274
|
Use Node.js 24 LTS for SDK development and install dependencies with `npm ci`.
|
package/config/config.test.ts
CHANGED
|
@@ -158,12 +158,16 @@ describe('config', () => {
|
|
|
158
158
|
const dir = mkdtempSync(join(tmpdir(), 'encore-config-test-'));
|
|
159
159
|
const live = join(dir, 'configs.json');
|
|
160
160
|
|
|
161
|
-
// Each probe is given its own config source, `live` unless told otherwise
|
|
162
|
-
|
|
161
|
+
// Each probe is given its own config source, `live` unless told otherwise,
|
|
162
|
+
// in a runtime on `cloud`, local unless told otherwise.
|
|
163
|
+
const run = (probe: string, source = live, cloud = CLOUD_LOCAL) => {
|
|
163
164
|
const proc = Bun.spawnSync({
|
|
164
165
|
cmd: [process.execPath, '-e', probe],
|
|
165
166
|
cwd: import.meta.dir,
|
|
166
|
-
env: {
|
|
167
|
+
env: {
|
|
168
|
+
...process.env,
|
|
169
|
+
ENCORE_RUNTIME_CONFIG: runtimeConfig(source, cloud),
|
|
170
|
+
},
|
|
167
171
|
});
|
|
168
172
|
const stdout = proc.stdout.toString();
|
|
169
173
|
if (proc.exitCode !== 0) {
|
|
@@ -187,8 +191,7 @@ describe('config', () => {
|
|
|
187
191
|
const flags = config("flags", { scope: "shared" });
|
|
188
192
|
const missing = config("nothing");
|
|
189
193
|
const a = checkout(), b = checkout();
|
|
190
|
-
|
|
191
|
-
try { secret("Unset")(); } catch (e) { unset = e.message; }
|
|
194
|
+
const unset = secret("Unset")();
|
|
192
195
|
console.log(JSON.stringify({
|
|
193
196
|
maxItems: a.max_items,
|
|
194
197
|
timeout: a.timeout instanceof Duration ? a.timeout.seconds : null,
|
|
@@ -222,12 +225,34 @@ describe('config', () => {
|
|
|
222
225
|
flagKey: 'shared-flag-key',
|
|
223
226
|
missing: {},
|
|
224
227
|
name: 'checkout',
|
|
225
|
-
//
|
|
226
|
-
unset: '
|
|
228
|
+
// Locally a secret lacks a value until it is set: it reads as empty.
|
|
229
|
+
unset: '',
|
|
227
230
|
});
|
|
228
231
|
expect(out[1]).toEqual({changed: 7, timeout: 60, now: 7});
|
|
229
232
|
});
|
|
230
233
|
|
|
234
|
+
test.skipIf(!lib)(
|
|
235
|
+
'fails a read of an unset secret where the app is not local',
|
|
236
|
+
() => {
|
|
237
|
+
const mod = JSON.stringify(`${import.meta.dir}/mod`);
|
|
238
|
+
const out = run(
|
|
239
|
+
`
|
|
240
|
+
import { secret } from ${mod};
|
|
241
|
+
let unset;
|
|
242
|
+
try { secret("Unset")(); } catch (e) { unset = e.message; }
|
|
243
|
+
console.log(JSON.stringify({ key: secret("FlagKey")(), unset }));
|
|
244
|
+
`,
|
|
245
|
+
live,
|
|
246
|
+
CLOUD_AWS,
|
|
247
|
+
);
|
|
248
|
+
// A deploy gives each service every secret it uses.
|
|
249
|
+
expect(out[0]).toEqual({
|
|
250
|
+
key: 'shared-flag-key',
|
|
251
|
+
unset: 'secret Unset is not set',
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
);
|
|
255
|
+
|
|
231
256
|
test.skipIf(!lib)(
|
|
232
257
|
'calls a listener once with the latest of rapid changes',
|
|
233
258
|
() => {
|
|
@@ -292,12 +317,16 @@ describe('config', () => {
|
|
|
292
317
|
);
|
|
293
318
|
});
|
|
294
319
|
|
|
320
|
+
/** `encore.runtime.v1.Environment.Cloud`'s values the tests run on. */
|
|
321
|
+
const CLOUD_LOCAL = 1;
|
|
322
|
+
const CLOUD_AWS = 3;
|
|
323
|
+
|
|
295
324
|
/**
|
|
296
|
-
* A serialized `encore.runtime.v1.RuntimeConfig` hosting service `orders
|
|
297
|
-
* with two configs, the secrets their fields read, and `live` as the
|
|
298
|
-
* source. Hand-encoded, as in app_meta.test.ts.
|
|
325
|
+
* A serialized `encore.runtime.v1.RuntimeConfig` hosting service `orders` on
|
|
326
|
+
* `cloud`, with two configs, the secrets their fields read, and `live` as the
|
|
327
|
+
* config source. Hand-encoded, as in app_meta.test.ts.
|
|
299
328
|
*/
|
|
300
|
-
function runtimeConfig(live: string): string {
|
|
329
|
+
function runtimeConfig(live: string, cloud: number): string {
|
|
301
330
|
const varint = (n: number): number[] => {
|
|
302
331
|
const out: number[] = [];
|
|
303
332
|
for (;;) {
|
|
@@ -377,8 +406,13 @@ function runtimeConfig(live: string): string {
|
|
|
377
406
|
const infra = msg(1, resources);
|
|
378
407
|
// Deployment{deploy_id=1, hosted_services=5}
|
|
379
408
|
const deployment = [...str(1, 'deploy-1'), ...msg(5, str(1, 'orders'))];
|
|
380
|
-
// Environment{app_id=1, env_name=4}
|
|
381
|
-
const environment = [
|
|
409
|
+
// Environment{app_id=1, env_name=4, cloud=6}
|
|
410
|
+
const environment = [
|
|
411
|
+
...str(1, 'app'),
|
|
412
|
+
...str(4, 'local'),
|
|
413
|
+
...tag(6, 0),
|
|
414
|
+
...varint(cloud),
|
|
415
|
+
];
|
|
382
416
|
const cfg = [...msg(1, environment), ...msg(2, infra), ...msg(3, deployment)];
|
|
383
417
|
return Buffer.from(Uint8Array.from(cfg)).toString('base64');
|
|
384
418
|
}
|
package/config/secrets.ts
CHANGED
|
@@ -25,8 +25,10 @@ export interface Secret<Name extends string, T extends string = string> {
|
|
|
25
25
|
* The value is read once per process and does not change while it runs:
|
|
26
26
|
* a new value reaches a service when it restarts.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* Locally (`encore run`, `encore test`), a secret with no value reads as
|
|
29
|
+
* `""`, like one set empty: a secret lacks a value there until it is set.
|
|
30
|
+
* So `if (!apiKey())` skips an integration that isn't configured yet.
|
|
31
|
+
* Anywhere else it throws an `Error` naming the secret.
|
|
30
32
|
*/
|
|
31
33
|
(): T;
|
|
32
34
|
|
|
@@ -156,6 +158,8 @@ function makeSecret<S extends AnySecret>(
|
|
|
156
158
|
const override = testMode ? lookupScope()?.native.secret(name) : null;
|
|
157
159
|
if (override != null) return override.toString('utf8');
|
|
158
160
|
if (impl === null) {
|
|
161
|
+
// Unset locally: it reads as one set empty.
|
|
162
|
+
if (runtime.RT.unsetSecretsReadEmpty()) return '';
|
|
159
163
|
throw new Error(`secret ${name} is not set`);
|
|
160
164
|
}
|
|
161
165
|
return impl.cached();
|
package/cron/mod.test.ts
CHANGED
|
@@ -17,6 +17,18 @@ describe('CronJob', () => {
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
test('keeps where it runs', () => {
|
|
21
|
+
const job = new CronJob('refresh', {
|
|
22
|
+
every: '30m',
|
|
23
|
+
path: '/internal/refresh',
|
|
24
|
+
runIn: {local: true},
|
|
25
|
+
});
|
|
26
|
+
expect(job.cfg.runIn).toEqual({local: true});
|
|
27
|
+
expect(
|
|
28
|
+
new CronJob('cleanup', {every: '24h', path: '/c'}).cfg.runIn,
|
|
29
|
+
).toBeUndefined();
|
|
30
|
+
});
|
|
31
|
+
|
|
20
32
|
// Encore requests the declared path: a route from a changed one would
|
|
21
33
|
// never be called. `tsc` refuses the writes (below); an app run without it
|
|
22
34
|
// has them throw.
|
package/cron/mod.ts
CHANGED
|
@@ -14,8 +14,9 @@ import {DurationString} from '../types/mod';
|
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* Only Encore sends it: a gateway removes it from the requests it takes from
|
|
17
|
-
* clients. `encore cron trigger <name>` runs a job locally, as Encore runs
|
|
18
|
-
* when it is due
|
|
17
|
+
* clients. `encore cron trigger <name>` runs a job locally now, as Encore runs
|
|
18
|
+
* it when it is due; one declared with `runIn: {local: true}` also runs on
|
|
19
|
+
* schedule while the app has a session open.
|
|
19
20
|
*/
|
|
20
21
|
export const IDEMPOTENCY_KEY_HEADER = 'x-encore-cron-execution';
|
|
21
22
|
|
|
@@ -59,4 +60,19 @@ export type CronJobConfig = {
|
|
|
59
60
|
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
60
61
|
*/
|
|
61
62
|
tags?: Record<string, string>;
|
|
63
|
+
/** The kinds of environment the job is scheduled in. */
|
|
64
|
+
runIn?: CronJobRunIn;
|
|
62
65
|
} & ({every: DurationString} | {schedule: string});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The kinds of environment a cron job is scheduled in. Wherever the app is
|
|
69
|
+
* deployed, it is; locally only when `local` says so.
|
|
70
|
+
*/
|
|
71
|
+
export type CronJobRunIn = {
|
|
72
|
+
/**
|
|
73
|
+
* Whether the job is scheduled on a developer's machine too, while the
|
|
74
|
+
* app has a session open there (as `encore run` keeps one). False unless
|
|
75
|
+
* set; a developer can override it for their checkout either way.
|
|
76
|
+
*/
|
|
77
|
+
local?: boolean;
|
|
78
|
+
};
|
package/dist/config/secrets.d.ts
CHANGED
|
@@ -22,8 +22,10 @@ export interface Secret<Name extends string, T extends string = string> {
|
|
|
22
22
|
* The value is read once per process and does not change while it runs:
|
|
23
23
|
* a new value reaches a service when it restarts.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* Locally (`encore run`, `encore test`), a secret with no value reads as
|
|
26
|
+
* `""`, like one set empty: a secret lacks a value there until it is set.
|
|
27
|
+
* So `if (!apiKey())` skips an integration that isn't configured yet.
|
|
28
|
+
* Anywhere else it throws an `Error` naming the secret.
|
|
27
29
|
*/
|
|
28
30
|
(): T;
|
|
29
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IACpE
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IACpE;;;;;;;;;;OAUG;IACH,IAAI,CAAC,CAAC;IAEN;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB;;;;;;;;OAQG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAExC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,MAAM,EACxC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAIzB,IAAI,CAAC,EAAE,aAAa,GACnB,MAAM,CAAC,IAAI,CAAC,CAEd;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAErD"}
|
package/dist/config/secrets.js
CHANGED
|
@@ -57,6 +57,9 @@ function makeSecret(name, impl) {
|
|
|
57
57
|
if (override != null)
|
|
58
58
|
return override.toString('utf8');
|
|
59
59
|
if (impl === null) {
|
|
60
|
+
// Unset locally: it reads as one set empty.
|
|
61
|
+
if (runtime.RT.unsetSecretsReadEmpty())
|
|
62
|
+
return '';
|
|
60
63
|
throw new Error(`secret ${name} is not set`);
|
|
61
64
|
}
|
|
62
65
|
return impl.cached();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AAgGhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,MAAM,CACpB,IAAyB;AACzB,sEAAsE;AACtE,8DAA8D;AAC9D,6DAA6D;AAC7D,IAAoB;IAEpB,OAAO,UAAU,CAAe,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,UAAU,CAAY,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CACjB,IAAY,EACZ,IAA0C;IAE1C,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,iDAAiD;QACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACtE,IAAI,QAAQ,IAAI,IAAI;YAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,4CAA4C;YAC5C,IAAI,OAAO,CAAC,EAAE,CAAC,qBAAqB,EAAE;gBAAE,OAAO,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,aAAa,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC,CAAC;IAEF,SAAS,CAAC,QAAQ,GAAG,GAAG,EAAE;QACxB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,OAAO,UAAU,IAAI,YAAY,CAAC;QACpC,CAAC;QACD,OAAO,UAAU,IAAI,cAAc,CAAC;IACtC,CAAC,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;IAExD,OAAO,SAAyB,CAAC;AACnC,CAAC"}
|
package/dist/cron/mod.d.ts
CHANGED
|
@@ -13,8 +13,9 @@ import { DurationString } from '../types/mod.js';
|
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
15
|
* Only Encore sends it: a gateway removes it from the requests it takes from
|
|
16
|
-
* clients. `encore cron trigger <name>` runs a job locally, as Encore runs
|
|
17
|
-
* when it is due
|
|
16
|
+
* clients. `encore cron trigger <name>` runs a job locally now, as Encore runs
|
|
17
|
+
* it when it is due; one declared with `runIn: {local: true}` also runs on
|
|
18
|
+
* schedule while the app has a session open.
|
|
18
19
|
*/
|
|
19
20
|
export declare const IDEMPOTENCY_KEY_HEADER = "x-encore-cron-execution";
|
|
20
21
|
/**
|
|
@@ -49,9 +50,23 @@ export type CronJobConfig = {
|
|
|
49
50
|
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
50
51
|
*/
|
|
51
52
|
tags?: Record<string, string>;
|
|
53
|
+
/** The kinds of environment the job is scheduled in. */
|
|
54
|
+
runIn?: CronJobRunIn;
|
|
52
55
|
} & ({
|
|
53
56
|
every: DurationString;
|
|
54
57
|
} | {
|
|
55
58
|
schedule: string;
|
|
56
59
|
});
|
|
60
|
+
/**
|
|
61
|
+
* The kinds of environment a cron job is scheduled in. Wherever the app is
|
|
62
|
+
* deployed, it is; locally only when `local` says so.
|
|
63
|
+
*/
|
|
64
|
+
export type CronJobRunIn = {
|
|
65
|
+
/**
|
|
66
|
+
* Whether the job is scheduled on a developer's machine too, while the
|
|
67
|
+
* app has a session open there (as `encore run` keeps one). False unless
|
|
68
|
+
* set; a developer can override it for their checkout either way.
|
|
69
|
+
*/
|
|
70
|
+
local?: boolean;
|
|
71
|
+
};
|
|
57
72
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/cron/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../cron/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../cron/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,cAAc,0BAA0B,CAAC;AAEtD,qBAAa,OAAO;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;gBAC1B,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa;CAO7C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,wDAAwD;IACxD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,GAAG,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAC,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC"}
|
package/dist/cron/mod.js
CHANGED
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
14
|
* Only Encore sends it: a gateway removes it from the requests it takes from
|
|
15
|
-
* clients. `encore cron trigger <name>` runs a job locally, as Encore runs
|
|
16
|
-
* when it is due
|
|
15
|
+
* clients. `encore cron trigger <name>` runs a job locally now, as Encore runs
|
|
16
|
+
* it when it is due; one declared with `runIn: {local: true}` also runs on
|
|
17
|
+
* schedule while the app has a session open.
|
|
17
18
|
*/
|
|
18
19
|
export const IDEMPOTENCY_KEY_HEADER = 'x-encore-cron-execution';
|
|
19
20
|
/**
|
package/dist/cron/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../cron/mod.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../cron/mod.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAEtD,MAAM,OAAO,OAAO;IACT,IAAI,CAAS;IACtB;;;OAGG;IACM,GAAG,CAA0B;IACtC,YAAY,IAAY,EAAE,GAAkB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,uEAAuE;QACvE,kCAAkC;QAClC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAC,GAAG,GAAG,EAAC,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { type Span, type TextMapGetter } from '@opentelemetry/api';
|
|
2
|
+
import { type Attributes, type Span, type TextMapGetter } from '@opentelemetry/api';
|
|
3
3
|
import { type HeaderSource } from '../../reqctx/mod.js';
|
|
4
|
-
|
|
4
|
+
/** Record only request values approved by the deployed route policy. */
|
|
5
|
+
export declare function recordSafeHTTPRequest(attributes: Attributes, method: string, target: string, userAgent?: string): void;
|
|
6
|
+
export declare function startHTTPSpan<Headers extends HeaderSource>(headers: Headers, getter: TextMapGetter<Headers>, requestMethod: string, url: URL, target?: string): {
|
|
5
7
|
span: Span;
|
|
6
8
|
context: import("@opentelemetry/api").Context;
|
|
7
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../internal/otel/http.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../internal/otel/http.ts"],"names":[],"mappings":";AAAA,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAU,KAAK,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAiB5D,wEAAwE;AACxE,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAeN;AAED,wBAAgB,aAAa,CAAC,OAAO,SAAS,YAAY,EACxD,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,GAAG,EACR,MAAM,SAA4B;;;EAsCnC;AAOD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAMjE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAYhE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAG3D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ROOT_CONTEXT, SpanKind, SpanStatusCode, trace, } from '@opentelemetry/api';
|
|
2
2
|
import { tracerProvider } from '../../otel.js';
|
|
3
|
+
import { redactor } from '../../redaction/mod.js';
|
|
3
4
|
import { extract } from '../../reqctx/mod.js';
|
|
4
5
|
import { W3CPropagator } from './propagator.js';
|
|
5
6
|
const propagator = new W3CPropagator();
|
|
@@ -15,7 +16,29 @@ const methods = new Set([
|
|
|
15
16
|
'QUERY',
|
|
16
17
|
'TRACE',
|
|
17
18
|
]);
|
|
18
|
-
|
|
19
|
+
/** Record only request values approved by the deployed route policy. */
|
|
20
|
+
export function recordSafeHTTPRequest(attributes, method, target, userAgent) {
|
|
21
|
+
try {
|
|
22
|
+
const http = redactor().http(method, target);
|
|
23
|
+
const { route, path, query } = http.requestUrl();
|
|
24
|
+
if (route !== null)
|
|
25
|
+
attributes['http.route'] = route;
|
|
26
|
+
if (path !== null)
|
|
27
|
+
attributes['url.path'] = path;
|
|
28
|
+
if (query)
|
|
29
|
+
attributes['url.query'] = query;
|
|
30
|
+
if (userAgent) {
|
|
31
|
+
const { headers } = http.request({ headers: [['user-agent', userAgent]] });
|
|
32
|
+
const safe = headers.find(([name]) => name === 'user-agent')?.[1];
|
|
33
|
+
if (safe)
|
|
34
|
+
attributes['user_agent.original'] = safe;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Invalid or unavailable policy must not fall back to raw values.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function startHTTPSpan(headers, getter, requestMethod, url, target = url.pathname + url.search) {
|
|
19
42
|
const parent = extract(headers, propagator.extract(ROOT_CONTEXT, headers, getter));
|
|
20
43
|
const method = methods.has(requestMethod) ? requestMethod : '_OTHER';
|
|
21
44
|
const attributes = {
|
|
@@ -32,14 +55,18 @@ export function startHTTPSpan(headers, getter, requestMethod, url) {
|
|
|
32
55
|
(url.protocol === 'https:' ? '443' : url.protocol === 'http:' ? '80' : '');
|
|
33
56
|
if (port)
|
|
34
57
|
attributes['server.port'] = Number(port);
|
|
58
|
+
const agent = getter.get(headers, 'user-agent');
|
|
59
|
+
recordSafeHTTPRequest(attributes, requestMethod, target, Array.isArray(agent) ? agent[0] : agent);
|
|
60
|
+
const route = attributes['http.route'];
|
|
35
61
|
const span = tracerProvider()
|
|
36
62
|
.getTracer('encore')
|
|
37
|
-
.startSpan(method
|
|
38
|
-
kind: SpanKind.SERVER,
|
|
39
|
-
attributes,
|
|
40
|
-
}, parent);
|
|
63
|
+
.startSpan(httpSpanName(method, route), { kind: SpanKind.SERVER, attributes }, parent);
|
|
41
64
|
return { span, context: trace.setSpan(parent, span) };
|
|
42
65
|
}
|
|
66
|
+
function httpSpanName(method, route) {
|
|
67
|
+
const name = method === '_OTHER' ? 'HTTP' : method;
|
|
68
|
+
return route === undefined ? name : `${name} ${route}`;
|
|
69
|
+
}
|
|
43
70
|
export function recordHTTPStatus(span, status) {
|
|
44
71
|
span.setAttribute('http.response.status_code', status);
|
|
45
72
|
if (status >= 500 && status <= 599) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../internal/otel/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,KAAK,GAIN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAoB,MAAM,kBAAkB,CAAC;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C,IAAI,EAAE,cAAc,CAAC,KAAK,EAAC,CAAC,CAAC;IAC7C,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The version of the runtime this JS bundle was generated for.
|
|
2
|
-
const version = "v2.0.0-beta.
|
|
2
|
+
const version = "v2.0.0-beta.15";
|
|
3
3
|
|
|
4
4
|
// Load the native module. ENCORE_RUNTIME_LIB overrides the location; by
|
|
5
5
|
// default the library is found by walking up from this file (which the
|
|
@@ -188,7 +188,7 @@ const {
|
|
|
188
188
|
ConfigWatch,
|
|
189
189
|
Cursor,
|
|
190
190
|
Decimal,
|
|
191
|
-
|
|
191
|
+
Download,
|
|
192
192
|
EnvironmentType,
|
|
193
193
|
GatewayHeaders,
|
|
194
194
|
GatewayView,
|
|
@@ -247,7 +247,7 @@ module.exports = {
|
|
|
247
247
|
ConfigWatch,
|
|
248
248
|
Cursor,
|
|
249
249
|
Decimal,
|
|
250
|
-
|
|
250
|
+
Download,
|
|
251
251
|
EnvironmentType,
|
|
252
252
|
GatewayHeaders,
|
|
253
253
|
GatewayView,
|
|
@@ -301,8 +301,9 @@ if (version !== Runtime.version() && installedRuntimeLib) {
|
|
|
301
301
|
);
|
|
302
302
|
}
|
|
303
303
|
if (version !== Runtime.version()) {
|
|
304
|
-
|
|
304
|
+
const runtimeVersion = Runtime.version().replace(/^v/, "");
|
|
305
|
+
console.warn(`⚠️ WARNING: this @encore.dev/sdk was built for the Encore runtime ${version}, but it is running in the Encore runtime ${Runtime.version()}.
|
|
305
306
|
This may cause unexpected behaviour in your application.
|
|
306
307
|
|
|
307
|
-
To resolve this,
|
|
308
|
+
To resolve this, install the SDK of the runtime's version: "npm install @encore.dev/sdk@${runtimeVersion}" (and "@encore.dev/framework@${runtimeVersion}" if you use the API framework). If the SDK is the newer, upgrade Encore with "encore version upgrade" instead.`);
|
|
308
309
|
}
|
|
@@ -45,9 +45,12 @@ export class BucketObject {
|
|
|
45
45
|
extendRetention(until: number, options?: ExtendRetentionOptions | undefined | null, source?: Buffer | undefined | null): Promise<ObjectAttrs | TypedObjectError>
|
|
46
46
|
signedUploadUrl(options?: UploadUrlOptions | undefined | null, source?: Buffer | undefined | null): Promise<SignedUploadUrl | TypedObjectError>
|
|
47
47
|
signedDownloadUrl(options?: DownloadUrlOptions | undefined | null, source?: Buffer | undefined | null): Promise<SignedDownloadUrl | TypedObjectError>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Begins a download: resolves once the provider has answered, with what
|
|
50
|
+
* it says of the object and its bytes still to come. A missing object
|
|
51
|
+
* fails here, before any bytes.
|
|
52
|
+
*/
|
|
53
|
+
download(options?: DownloadOptions | undefined | null, source?: Buffer | undefined | null): Promise<Download | TypedObjectError>
|
|
51
54
|
delete(options?: DeleteOptions | undefined | null, source?: Buffer | undefined | null): Promise<TypedObjectError | null>
|
|
52
55
|
publicUrl(): string
|
|
53
56
|
}
|
|
@@ -56,9 +59,14 @@ export interface BuildMeta {
|
|
|
56
59
|
revision: string
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
/**
|
|
63
|
+
* `length` bytes from `offset` (to the end of the object without a
|
|
64
|
+
* length), or the object's last `last` bytes.
|
|
65
|
+
*/
|
|
59
66
|
export interface ByteRange {
|
|
60
|
-
offset
|
|
67
|
+
offset?: number
|
|
61
68
|
length?: number
|
|
69
|
+
last?: number
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
/** Which of a database's users a call is made as. See [`clickhouse::Access`]. */
|
|
@@ -224,22 +232,40 @@ export interface DeployMeta {
|
|
|
224
232
|
worker?: string
|
|
225
233
|
}
|
|
226
234
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
235
|
+
/**
|
|
236
|
+
* A download under way: what the provider said of the object, and its
|
|
237
|
+
* bytes, read whole or one chunk at a time.
|
|
238
|
+
*/
|
|
239
|
+
export class Download {
|
|
240
|
+
get info(): DownloadInfo
|
|
241
|
+
/** The rest of the download, in one piece. It closes the download. */
|
|
242
|
+
bytes(): Promise<Buffer | TypedObjectError>
|
|
234
243
|
/**
|
|
235
|
-
* The next chunk, or null at the end. The
|
|
236
|
-
* on an error.
|
|
244
|
+
* The next chunk, or null at the end. The download closes at the end
|
|
245
|
+
* and on an error.
|
|
237
246
|
*/
|
|
238
247
|
next(): Promise<Buffer | null | TypedObjectError>
|
|
239
248
|
/** Stops the download, which ends its span. */
|
|
240
249
|
close(): Promise<void>
|
|
241
250
|
}
|
|
242
251
|
|
|
252
|
+
/** What a download's response says of the object being read. */
|
|
253
|
+
export interface DownloadInfo {
|
|
254
|
+
/** With `version`, the revision the bytes are of. */
|
|
255
|
+
etag: string
|
|
256
|
+
version?: string
|
|
257
|
+
/** The size of the whole object, also when a range of it is read. */
|
|
258
|
+
size: number
|
|
259
|
+
contentType?: string
|
|
260
|
+
/** Milliseconds since the Unix epoch. */
|
|
261
|
+
lastModified?: number
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface DownloadOptions {
|
|
265
|
+
version?: string
|
|
266
|
+
range?: ByteRange
|
|
267
|
+
}
|
|
268
|
+
|
|
243
269
|
export interface DownloadUrlOptions {
|
|
244
270
|
ttl?: number
|
|
245
271
|
}
|
|
@@ -407,6 +433,8 @@ export interface ListEntry {
|
|
|
407
433
|
name: string
|
|
408
434
|
size: number
|
|
409
435
|
etag: string
|
|
436
|
+
/** Milliseconds since the Unix epoch. None for a prefix. */
|
|
437
|
+
lastModified?: number
|
|
410
438
|
/** A common prefix of a delimited listing rather than an object. */
|
|
411
439
|
isPrefix: boolean
|
|
412
440
|
}
|
|
@@ -756,12 +784,19 @@ export class Runtime {
|
|
|
756
784
|
* a name has one scope across the app.
|
|
757
785
|
*/
|
|
758
786
|
secret(encoreName: string): Secret | null
|
|
787
|
+
/**
|
|
788
|
+
* Whether a secret [`secret`](Self::secret) has no value of reads as `""`
|
|
789
|
+
* rather than failing: only where the app runs locally, as `encore run`
|
|
790
|
+
* and `encore test` do, where a secret lacks a value until it is set.
|
|
791
|
+
*/
|
|
792
|
+
unsetSecretsReadEmpty(): boolean
|
|
759
793
|
/** The telemetry pipeline's span lifecycle calls. */
|
|
760
794
|
telemetry(): Pipeline
|
|
761
795
|
/** The meter provider's instrument calls. */
|
|
762
796
|
meters(): Meters
|
|
763
797
|
/** Returns the version of the Encore runtime being used */
|
|
764
798
|
static version(): string
|
|
799
|
+
redact(spec: string, payload: Buffer): string
|
|
765
800
|
appMeta(): AppMeta
|
|
766
801
|
runtimeConfig(): RuntimeConfig
|
|
767
802
|
}
|