@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.17
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 +111 -101
- package/app_meta.ts +56 -54
- package/config/config.ts +60 -57
- package/config/secrets.ts +45 -52
- package/config/value.ts +23 -26
- package/cron/mod.ts +28 -29
- package/dist/app_meta.d.ts +52 -50
- package/dist/app_meta.d.ts.map +1 -1
- package/dist/app_meta.js +2 -2
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +58 -55
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +8 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/secrets.d.ts +45 -52
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +8 -9
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +20 -23
- package/dist/config/value.d.ts.map +1 -1
- package/dist/config/value.js +20 -23
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +26 -27
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -14
- package/dist/cron/mod.js.map +1 -1
- package/dist/frontends/mod.d.ts +20 -19
- package/dist/frontends/mod.d.ts.map +1 -1
- package/dist/frontends/mod.js +20 -19
- package/dist/frontends/mod.js.map +1 -1
- package/dist/gateway/errors.d.ts +28 -30
- package/dist/gateway/errors.d.ts.map +1 -1
- package/dist/gateway/errors.js +29 -31
- package/dist/gateway/errors.js.map +1 -1
- package/dist/gateway/match.d.ts +54 -54
- package/dist/gateway/match.d.ts.map +1 -1
- package/dist/gateway/match.js +56 -56
- package/dist/gateway/match.js.map +1 -1
- package/dist/gateway/middleware.d.ts +62 -64
- package/dist/gateway/middleware.d.ts.map +1 -1
- package/dist/gateway/middleware.js +1 -1
- package/dist/gateway/middleware.js.map +1 -1
- package/dist/gateway/mod.d.ts +64 -67
- package/dist/gateway/mod.d.ts.map +1 -1
- package/dist/gateway/mod.js +72 -76
- package/dist/gateway/mod.js.map +1 -1
- package/dist/gateway/request.d.ts +138 -134
- package/dist/gateway/request.d.ts.map +1 -1
- package/dist/gateway/request.js +117 -108
- package/dist/gateway/request.js.map +1 -1
- package/dist/gateway/serve.d.ts +29 -34
- package/dist/gateway/serve.d.ts.map +1 -1
- package/dist/gateway/serve.js +51 -56
- package/dist/gateway/serve.js.map +1 -1
- package/dist/gateways/mod.d.ts +23 -21
- package/dist/gateways/mod.d.ts.map +1 -1
- package/dist/gateways/mod.js +25 -23
- package/dist/gateways/mod.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +1 -1
- package/dist/internal/runtime/napi/napi.d.cts +10 -3
- package/dist/internal/runtime/shutdown.d.ts +75 -57
- package/dist/internal/runtime/shutdown.d.ts.map +1 -1
- package/dist/internal/runtime/shutdown.js +88 -84
- package/dist/internal/runtime/shutdown.js.map +1 -1
- package/dist/log/logger.d.ts +43 -37
- package/dist/log/logger.d.ts.map +1 -1
- package/dist/log/logger.js +26 -25
- package/dist/log/logger.js.map +1 -1
- package/dist/metrics/mod.d.ts +133 -114
- package/dist/metrics/mod.d.ts.map +1 -1
- package/dist/metrics/mod.js +109 -101
- package/dist/metrics/mod.js.map +1 -1
- package/dist/otel.d.ts +6 -3
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +6 -3
- package/dist/otel.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +88 -116
- package/dist/pubsub/subscription.d.ts.map +1 -1
- package/dist/pubsub/subscription.js +14 -17
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +86 -113
- package/dist/pubsub/topic.d.ts.map +1 -1
- package/dist/pubsub/topic.js +68 -82
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/reqctx/mod.d.ts +83 -86
- package/dist/reqctx/mod.d.ts.map +1 -1
- package/dist/reqctx/mod.js +39 -41
- package/dist/reqctx/mod.js.map +1 -1
- package/dist/services/index.d.ts +76 -75
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +73 -71
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +26 -25
- package/dist/shutdown/mod.d.ts.map +1 -1
- package/dist/shutdown/mod.js +26 -25
- package/dist/shutdown/mod.js.map +1 -1
- package/dist/storage/clickhouse/database.d.ts +113 -115
- package/dist/storage/clickhouse/database.d.ts.map +1 -1
- package/dist/storage/clickhouse/database.js +65 -79
- package/dist/storage/clickhouse/database.js.map +1 -1
- package/dist/storage/clickhouse/errors.d.ts +25 -26
- package/dist/storage/clickhouse/errors.d.ts.map +1 -1
- package/dist/storage/clickhouse/errors.js +15 -17
- package/dist/storage/clickhouse/errors.js.map +1 -1
- package/dist/storage/clickhouse/mod.d.ts +10 -10
- package/dist/storage/clickhouse/mod.js +10 -10
- package/dist/storage/objects/bucket.d.ts +196 -225
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +71 -84
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +4 -4
- package/dist/storage/objects/error.js +4 -4
- package/dist/storage/postgres/database.d.ts +124 -149
- package/dist/storage/postgres/database.d.ts.map +1 -1
- package/dist/storage/postgres/database.js +98 -135
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts +42 -48
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +44 -51
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/interval.d.ts +19 -19
- package/dist/storage/postgres/interval.d.ts.map +1 -1
- package/dist/storage/postgres/interval.js +21 -21
- package/dist/storage/postgres/interval.js.map +1 -1
- package/dist/storage/redis/bitfield.d.ts +48 -23
- package/dist/storage/redis/bitfield.d.ts.map +1 -1
- package/dist/storage/redis/bitfield.js +38 -19
- package/dist/storage/redis/bitfield.js.map +1 -1
- package/dist/storage/redis/command.d.ts +16 -12
- package/dist/storage/redis/command.d.ts.map +1 -1
- package/dist/storage/redis/command.js +16 -12
- package/dist/storage/redis/command.js.map +1 -1
- package/dist/storage/redis/commands.d.ts +99 -100
- package/dist/storage/redis/commands.d.ts.map +1 -1
- package/dist/storage/redis/commands.js +84 -85
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +138 -122
- package/dist/storage/redis/database.d.ts.map +1 -1
- package/dist/storage/redis/database.js +120 -101
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +52 -48
- package/dist/storage/redis/mod.d.ts.map +1 -1
- package/dist/storage/redis/mod.js +52 -48
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/options.d.ts +26 -24
- package/dist/storage/redis/options.d.ts.map +1 -1
- package/dist/storage/redis/options.js.map +1 -1
- package/dist/storage/redis/pubsub.d.ts +16 -16
- package/dist/storage/redis/pubsub.d.ts.map +1 -1
- package/dist/storage/redis/pubsub.js +14 -14
- package/dist/storage/redis/pubsub.js.map +1 -1
- package/dist/storage/redis/reply.d.ts +80 -72
- package/dist/storage/redis/reply.d.ts.map +1 -1
- package/dist/storage/redis/reply.js +53 -46
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +4 -4
- package/dist/storage/redis/scan.d.ts.map +1 -1
- package/dist/storage/redis/scan.js +6 -6
- package/dist/storage/redis/scan.js.map +1 -1
- package/dist/storage/redis/script.d.ts +28 -21
- package/dist/storage/redis/script.d.ts.map +1 -1
- package/dist/storage/redis/script.js +29 -22
- package/dist/storage/redis/script.js.map +1 -1
- package/dist/storage/redis/target.d.ts +17 -1
- package/dist/storage/redis/target.d.ts.map +1 -1
- package/dist/storage/redis/target.js +30 -1
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +6 -6
- package/dist/storage/redis/wire.d.ts.map +1 -1
- package/dist/storage/redis/wire.js +6 -6
- package/dist/storage/redis/wire.js.map +1 -1
- package/dist/testing/mod.d.ts +83 -88
- package/dist/testing/mod.d.ts.map +1 -1
- package/dist/testing/mod.js +75 -81
- package/dist/testing/mod.js.map +1 -1
- package/dist/testing/playwright.d.ts +28 -32
- package/dist/testing/playwright.d.ts.map +1 -1
- package/dist/testing/playwright.js +22 -27
- package/dist/testing/playwright.js.map +1 -1
- package/dist/testing/puppeteer.d.ts +11 -12
- package/dist/testing/puppeteer.d.ts.map +1 -1
- package/dist/testing/puppeteer.js +17 -18
- package/dist/testing/puppeteer.js.map +1 -1
- package/dist/testing/system.d.ts +72 -90
- package/dist/testing/system.d.ts.map +1 -1
- package/dist/testing/system.js +90 -107
- package/dist/testing/system.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/frontends/mod.test.ts +6 -2
- package/frontends/mod.ts +20 -19
- package/gateway/errors.ts +30 -32
- package/gateway/match.ts +61 -57
- package/gateway/middleware.ts +62 -64
- package/gateway/mod.ts +73 -76
- package/gateway/request.ts +143 -140
- package/gateway/serve.ts +58 -63
- package/gateways/mod.ts +25 -23
- package/internal/runtime/napi/napi.cjs +1 -1
- package/internal/runtime/napi/napi.d.cts +10 -3
- package/internal/runtime/shutdown.ts +113 -101
- package/log/logger.test.ts +8 -0
- package/log/logger.ts +48 -45
- package/metrics/mod.ts +138 -122
- package/otel.ts +6 -3
- package/package.json +1 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- package/reqctx/mod.ts +83 -86
- package/services/index.ts +78 -78
- package/shutdown/mod.ts +26 -25
- package/storage/clickhouse/database.ts +115 -129
- package/storage/clickhouse/errors.ts +27 -29
- package/storage/clickhouse/mod.ts +10 -10
- package/storage/objects/bucket.ts +209 -239
- package/storage/objects/error.ts +4 -4
- package/storage/postgres/database.ts +131 -164
- package/storage/postgres/errors.ts +45 -52
- package/storage/postgres/interval.ts +21 -21
- package/storage/redis/bitfield.ts +51 -26
- package/storage/redis/command.ts +16 -12
- package/storage/redis/commands.ts +99 -100
- package/storage/redis/database.ts +145 -123
- package/storage/redis/mod.ts +52 -48
- package/storage/redis/options.ts +26 -24
- package/storage/redis/pubsub.ts +14 -14
- package/storage/redis/redis.test.ts +17 -2
- package/storage/redis/reply.ts +85 -77
- package/storage/redis/scan.ts +6 -6
- package/storage/redis/script.ts +29 -22
- package/storage/redis/target.ts +34 -1
- package/storage/redis/wire.ts +8 -8
- package/testing/mod.ts +99 -105
- package/testing/playwright.ts +32 -37
- package/testing/puppeteer.ts +22 -23
- package/testing/system.ts +117 -133
package/dist/shutdown/mod.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Graceful shutdown on SIGTERM or SIGINT
|
|
2
|
+
* Graceful shutdown on `SIGTERM` or `SIGINT`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and telemetry, and exits
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* When a shutdown signal arrives, Encore stops accepting new Pub/Sub messages,
|
|
5
|
+
* waits for in-flight message handlers and application work to finish, closes
|
|
6
|
+
* managed resources, flushes metrics and telemetry, and exits. If cleanup
|
|
7
|
+
* finishes within the shutdown deadline, the process exits with
|
|
8
|
+
* `process.exitCode` (0 unless set by the application); otherwise it exits
|
|
9
|
+
* with 1. A second `SIGINT` (Ctrl-C) skips waiting for application work and
|
|
10
|
+
* forces immediate cleanup.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
* {@link onShutdown} callback:
|
|
12
|
+
* Use {@link onShutdown} to drain servers or close frameworks cleanly:
|
|
12
13
|
*
|
|
13
14
|
* ```typescript
|
|
14
15
|
* import { onShutdown } from "@encore.dev/sdk/shutdown";
|
|
@@ -17,17 +18,17 @@
|
|
|
17
18
|
* onShutdown(() => new Promise((resolve) => server.close(() => resolve())));
|
|
18
19
|
* ```
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `enableShutdownHooks()
|
|
21
|
+
* If your framework has its own shutdown hooks, invoke them inside
|
|
22
|
+
* `onShutdown` instead of registering separate signal handlers. For example,
|
|
23
|
+
* with NestJS (instead of `enableShutdownHooks()`):
|
|
23
24
|
*
|
|
24
25
|
* ```typescript
|
|
25
26
|
* onShutdown(() => app.close());
|
|
26
27
|
* ```
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
-
* {@link
|
|
30
|
-
*
|
|
29
|
+
* For in-flight background work that isn't a shutdown callback, delay cleanup
|
|
30
|
+
* with {@link hold} or {@link waitUntil}. With `using`, a hold is released
|
|
31
|
+
* automatically when the block exits:
|
|
31
32
|
*
|
|
32
33
|
* ```typescript
|
|
33
34
|
* import * as shutdown from "@encore.dev/sdk/shutdown";
|
|
@@ -38,19 +39,19 @@
|
|
|
38
39
|
* }
|
|
39
40
|
* ```
|
|
40
41
|
*
|
|
41
|
-
* Encore
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Encore begins resource cleanup once all holds are released or the shutdown
|
|
43
|
+
* deadline expires, whichever comes first. {@link signal} aborts when shutdown
|
|
44
|
+
* starts; each callback's `ctx.signal` aborts when cleanup starts.
|
|
44
45
|
*
|
|
45
|
-
*
|
|
46
|
-
* `enableShutdownHooks()`
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
46
|
+
* If an application registers its own signal listener without using Encore's
|
|
47
|
+
* shutdown APIs (such as NestJS's `enableShutdownHooks()`), Encore stops
|
|
48
|
+
* taking new work immediately and waits for the application to re-raise the
|
|
49
|
+
* signal, exit, or drain its event loop before cleaning up. The process then
|
|
50
|
+
* exits with the application's own exit code, or with 1 if the shutdown
|
|
51
|
+
* deadline expires first.
|
|
51
52
|
*
|
|
52
|
-
*
|
|
53
|
-
* stay open until the
|
|
53
|
+
* Database connections owned by third-party pools (such as `pg` or Drizzle)
|
|
54
|
+
* stay open until the application closes them or the process exits.
|
|
54
55
|
*
|
|
55
56
|
* @module
|
|
56
57
|
*/
|
package/dist/shutdown/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../shutdown/mod.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../shutdown/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,SAAS,EACT,aAAa,GACd,MAAM,8BAA8B,CAAC"}
|
|
@@ -4,186 +4,185 @@ import * as runtime from '../../internal/runtime/mod.js';
|
|
|
4
4
|
import { StringLiteral } from '../../internal/utils/constraints.js';
|
|
5
5
|
import { Decimal } from '../../types/mod.js';
|
|
6
6
|
/**
|
|
7
|
-
* Configuration for a ClickHouse
|
|
7
|
+
* Configuration for a ClickHouse {@link Database}.
|
|
8
8
|
*/
|
|
9
9
|
export interface DatabaseConfig {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* back.
|
|
11
|
+
* Path to the migrations directory relative to the declaring file (containing
|
|
12
|
+
* files such as `1_create_events.up.sql` and optional `.down.sql` files).
|
|
13
|
+
* Statements in each file run sequentially; because ClickHouse cannot roll
|
|
14
|
+
* back DDL, a failed migration leaves the schema version dirty.
|
|
16
15
|
*/
|
|
17
16
|
migrations?: string;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
18
|
+
* Static string-literal tags that classify the database for policy checks
|
|
19
|
+
* (e.g. `{data: "pci"}`). Keys and values may contain lowercase letters,
|
|
20
|
+
* digits, `_`, and `-`, up to 63 characters. Keys must start with a letter
|
|
21
|
+
* and cannot start with the reserved prefix `encore`. At most 32 tags.
|
|
23
22
|
*/
|
|
24
23
|
tags?: Record<string, string>;
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
|
-
* A
|
|
26
|
+
* A single query result row, keyed by column name.
|
|
28
27
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* - `
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* - `
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
28
|
+
* Column types map to JavaScript values as follows:
|
|
29
|
+
* - Integers and floats decode to `number`, except 64-bit integers outside the
|
|
30
|
+
* safe integer range (±(2^53−1)) and `Int128`/`UInt128`/`Int256`/`UInt256`,
|
|
31
|
+
* which decode to `bigint` to avoid precision loss.
|
|
32
|
+
* - `Decimal` decodes to its exact string representation (e.g. `'12.30'`).
|
|
33
|
+
* - `String` decodes to `string` (invalid UTF-8 replaced); non-UTF-8
|
|
34
|
+
* `FixedString` decodes to `Buffer`.
|
|
35
|
+
* - `UUID`, `Enum`, `IPv4`, and `IPv6` decode to `string`.
|
|
36
|
+
* - `Date`/`Date32` decode to `'YYYY-MM-DD'`, `DateTime`/`DateTime64` to
|
|
37
|
+
* `Date` (millisecond precision), and `Time`/`Time64` to seconds (`number`).
|
|
38
|
+
* - `Array` and `Tuple` decode to arrays; `Map` with string keys decodes to a
|
|
39
|
+
* plain object (other key types decode to `Map`); `JSON` decodes to its
|
|
40
|
+
* parsed value.
|
|
41
|
+
* - `NULL` decodes to `null`.
|
|
41
42
|
*/
|
|
42
43
|
export type Row = Record<string, any>;
|
|
43
44
|
/**
|
|
44
|
-
* A value a query parameter or
|
|
45
|
-
*
|
|
45
|
+
* A value accepted as a query parameter or inserted column. In tagged-template
|
|
46
|
+
* queries, the ClickHouse parameter type is inferred automatically:
|
|
46
47
|
*
|
|
47
|
-
* - `boolean
|
|
48
|
-
* -
|
|
49
|
-
* - `bigint
|
|
50
|
-
* - `string
|
|
51
|
-
* - `Date
|
|
52
|
-
* - `Decimal
|
|
53
|
-
* -
|
|
54
|
-
*
|
|
55
|
-
* -
|
|
56
|
-
*
|
|
57
|
-
* - `null`/`undefined`: `Nullable(String)`, `NULL`
|
|
48
|
+
* - `boolean` → `Bool`
|
|
49
|
+
* - safe integer `number` → `Int64`; other `number` → `Float64`
|
|
50
|
+
* - `bigint` → `Int64`, or `UInt64` (and wider types up to 256 bits) as needed
|
|
51
|
+
* - `string`, `Buffer`, `Uint8Array` → `String`
|
|
52
|
+
* - `Date` → `DateTime64(6, 'UTC')`
|
|
53
|
+
* - `Decimal` → `Decimal(76, s)` where `s` is the decimal scale
|
|
54
|
+
* - array → `Array(T)` inferred from the first non-null element (`Nullable(T)`
|
|
55
|
+
* if the array contains `null`)
|
|
56
|
+
* - plain object or `Map` → `Map(K, V)`
|
|
57
|
+
* - `null`/`undefined` → `Nullable(String)` (`NULL`)
|
|
58
58
|
*
|
|
59
|
-
* Wrap a value
|
|
59
|
+
* Wrap a value with {@link typed} to specify an explicit ClickHouse type.
|
|
60
60
|
*/
|
|
61
61
|
export type Param = string | number | bigint | boolean | Date | Buffer | Uint8Array | Decimal | Typed | null | undefined | readonly Param[] | Map<Param, Param> | {
|
|
62
62
|
[key: string]: Param;
|
|
63
63
|
};
|
|
64
|
-
/**
|
|
64
|
+
/** ClickHouse query setting value (booleans are sent as `1` or `0`). */
|
|
65
65
|
export type SettingValue = string | number | boolean;
|
|
66
|
-
/**
|
|
66
|
+
/** Per-call options for ClickHouse queries and statements. */
|
|
67
67
|
export interface QueryOptions {
|
|
68
68
|
/**
|
|
69
|
-
* ClickHouse settings
|
|
70
|
-
* or `{async_insert: true}
|
|
71
|
-
*
|
|
72
|
-
*
|
|
69
|
+
* ClickHouse settings applied only to this call (e.g.
|
|
70
|
+
* `{max_execution_time: 5}` or `{async_insert: true}`). Because calls are
|
|
71
|
+
* stateless, `SET` does not carry over between calls. Unknown settings cause
|
|
72
|
+
* a server error.
|
|
73
73
|
*/
|
|
74
74
|
settings?: Record<string, SettingValue>;
|
|
75
|
-
/**
|
|
75
|
+
/** Custom server query ID for `system.query_log` (auto-generated if omitted). */
|
|
76
76
|
queryId?: string;
|
|
77
77
|
}
|
|
78
|
-
/**
|
|
78
|
+
/** Execution statistics returned by ClickHouse for a statement or insert. */
|
|
79
79
|
export interface ExecResult {
|
|
80
|
-
/**
|
|
80
|
+
/** Number of rows written. */
|
|
81
81
|
rowsWritten: number;
|
|
82
|
-
/**
|
|
82
|
+
/** Number of uncompressed bytes written. */
|
|
83
83
|
bytesWritten: number;
|
|
84
|
-
/**
|
|
84
|
+
/** Number of rows read. */
|
|
85
85
|
rowsRead: number;
|
|
86
|
-
/**
|
|
86
|
+
/** Server-assigned or caller-provided query ID. */
|
|
87
87
|
queryId: string;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
90
|
+
* Wraps a query parameter value with an explicit ClickHouse type (see
|
|
91
|
+
* {@link typed}).
|
|
91
92
|
*/
|
|
92
93
|
export declare class Typed<T = unknown> {
|
|
93
|
-
/** The value. */
|
|
94
|
+
/** The parameter value. */
|
|
94
95
|
readonly value: T;
|
|
95
|
-
/**
|
|
96
|
+
/** Explicit ClickHouse type name (e.g. `'UUID'` or `'Array(UInt32)'`). */
|
|
96
97
|
readonly type: string;
|
|
97
98
|
/** @internal */
|
|
98
99
|
constructor(
|
|
99
|
-
/** The value. */
|
|
100
|
+
/** The parameter value. */
|
|
100
101
|
value: T,
|
|
101
|
-
/**
|
|
102
|
+
/** Explicit ClickHouse type name (e.g. `'UUID'` or `'Array(UInt32)'`). */
|
|
102
103
|
type: string);
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
|
-
* Binds `value` as the ClickHouse type `type`
|
|
106
|
-
*
|
|
107
|
-
* `{p0:UUID}
|
|
108
|
-
* `Date` or `Date32
|
|
106
|
+
* Binds `value` as the explicit ClickHouse type `type` instead of inferring
|
|
107
|
+
* one in tagged-template queries (e.g. `` ${typed(id, 'UUID')} `` emits
|
|
108
|
+
* `{p0:UUID}`). A `Date` bound as `DateTime` truncates to whole seconds; bound
|
|
109
|
+
* as `Date` or `Date32`, it uses the UTC calendar date.
|
|
109
110
|
*
|
|
110
111
|
* @example
|
|
111
112
|
* await db.queryAll`SELECT * FROM events WHERE user_id = ${typed(userId, 'UUID')}`;
|
|
112
113
|
*/
|
|
113
114
|
export declare function typed<T>(value: T, type: string): Typed<T>;
|
|
114
|
-
/**
|
|
115
|
+
/** Native ClickHouse handle or lazy test-scoped resolver. */
|
|
115
116
|
type Handle = runtime.ClickHouseDatabase | (() => runtime.ClickHouseDatabase);
|
|
116
|
-
/** Base class
|
|
117
|
+
/** Base class providing shared ClickHouse query and execution methods. */
|
|
117
118
|
declare class BaseQueryExecutor {
|
|
118
119
|
private readonly handle;
|
|
119
120
|
private readonly access;
|
|
120
121
|
/** @internal */
|
|
121
122
|
constructor(handle: Handle, access: runtime.ClickHouseAccess);
|
|
122
|
-
/**
|
|
123
|
+
/** Native database handle (resolves to the current test's instance in test mode). */
|
|
123
124
|
protected get impl(): runtime.ClickHouseDatabase;
|
|
124
125
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
126
|
+
* HTTP connection string (`http://user:password@host:port/database`) scoped
|
|
127
|
+
* to this handle's access level, compatible with `@clickhouse/client`'s `url`
|
|
128
|
+
* option.
|
|
128
129
|
*/
|
|
129
130
|
get connectionString(): string;
|
|
130
131
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* `` query`SELECT * FROM events WHERE id = ${id}` ``
|
|
134
|
-
* events WHERE id = {p0:Int64}`.
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* It streams the rows: iterate it with `for await`.
|
|
132
|
+
* Streams rows from a tagged-template query, binding each `${value}` as a
|
|
133
|
+
* typed server parameter (see {@link Param}). For example,
|
|
134
|
+
* `` query`SELECT * FROM events WHERE id = ${id}` `` sends
|
|
135
|
+
* `SELECT * FROM events WHERE id = {p0:Int64}`. Use {@link typed} to
|
|
136
|
+
* override the inferred type. Iterate results with `for await`.
|
|
138
137
|
*/
|
|
139
138
|
query<T extends Row = Record<string, any>>(strings: TemplateStringsArray, ...params: Param[]): AsyncGenerator<T>;
|
|
140
139
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
140
|
+
* Streams rows from a raw SQL query with named typed placeholders (such as
|
|
141
|
+
* `{id:UInt64}`) and matching entries in `params`. Iterate results with
|
|
142
|
+
* `for await`.
|
|
143
143
|
*
|
|
144
144
|
* ```ts
|
|
145
145
|
* db.rawQuery('SELECT * FROM events WHERE id = {id:UInt64}', {id: 5});
|
|
146
146
|
* ```
|
|
147
|
-
*
|
|
148
|
-
* It streams the rows: iterate it with `for await`.
|
|
149
147
|
*/
|
|
150
148
|
rawQuery<T extends Row = Record<string, any>>(sql: string, params?: Record<string, Param>, options?: QueryOptions): AsyncGenerator<T>;
|
|
151
|
-
/** {@link query}
|
|
149
|
+
/** Runs a tagged-template query (like {@link query}) and collects all rows into an array. */
|
|
152
150
|
queryAll<T extends Row = Record<string, any>>(strings: TemplateStringsArray, ...params: Param[]): Promise<T[]>;
|
|
153
|
-
/** {@link rawQuery}
|
|
151
|
+
/** Runs a raw query (like {@link rawQuery}) and collects all rows into an array. */
|
|
154
152
|
rawQueryAll<T extends Row = Record<string, any>>(sql: string, params?: Record<string, Param>, options?: QueryOptions): Promise<T[]>;
|
|
155
153
|
/**
|
|
156
|
-
* {@link query}
|
|
157
|
-
*
|
|
154
|
+
* Runs a tagged-template query (like {@link query}) expecting at most one
|
|
155
|
+
* row. Returns `null` if no rows match, or throws {@link TooManyRowsError}
|
|
156
|
+
* if more than one row is returned.
|
|
158
157
|
*/
|
|
159
158
|
queryRow<T extends Row = Record<string, any>>(strings: TemplateStringsArray, ...params: Param[]): Promise<T | null>;
|
|
160
159
|
/**
|
|
161
|
-
* {@link rawQuery}
|
|
162
|
-
* {@link TooManyRowsError} if
|
|
160
|
+
* Runs a raw query (like {@link rawQuery}) expecting at most one row.
|
|
161
|
+
* Returns `null` if no rows match, or throws {@link TooManyRowsError} if
|
|
162
|
+
* more than one row is returned.
|
|
163
163
|
*/
|
|
164
164
|
rawQueryRow<T extends Row = Record<string, any>>(sql: string, params?: Record<string, Param>, options?: QueryOptions): Promise<T | null>;
|
|
165
165
|
/**
|
|
166
|
-
*
|
|
167
|
-
* {@link query}
|
|
166
|
+
* Executes a tagged-template statement (binding `${value}` placeholders like
|
|
167
|
+
* {@link query}) and discards any returned rows.
|
|
168
168
|
*
|
|
169
169
|
* @example
|
|
170
170
|
* await db.exec`ALTER TABLE events DELETE WHERE user_id = ${id}`;
|
|
171
171
|
*/
|
|
172
172
|
exec(strings: TemplateStringsArray, ...params: Param[]): Promise<ExecResult>;
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
175
|
-
* and discards any rows
|
|
174
|
+
* Executes a raw statement with named typed parameters (like
|
|
175
|
+
* {@link rawQuery}) and discards any returned rows.
|
|
176
176
|
*/
|
|
177
177
|
rawExec(sql: string, params?: Record<string, Param>, options?: QueryOptions): Promise<ExecResult>;
|
|
178
178
|
/**
|
|
179
|
-
*
|
|
180
|
-
* an object
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* a column that isn't `Nullable` also takes as its default.
|
|
179
|
+
* Bulk-inserts `rows` into `table` (`table` or `database.table`). Each row
|
|
180
|
+
* is an object or `Map` keyed by column name. Omitted or `undefined` fields
|
|
181
|
+
* use the column's default; `null` inserts `NULL` (or the column default for
|
|
182
|
+
* non-`Nullable` columns).
|
|
184
183
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
184
|
+
* Rows are serialized as JSON, so non-UTF-8 binary strings are not preserved
|
|
185
|
+
* — use a parameterized `INSERT ... VALUES` statement for binary data.
|
|
187
186
|
*
|
|
188
187
|
* @example
|
|
189
188
|
* await db.insert('events', [
|
|
@@ -199,39 +198,38 @@ declare class BaseQueryExecutor {
|
|
|
199
198
|
private run;
|
|
200
199
|
}
|
|
201
200
|
/**
|
|
202
|
-
* A query handle
|
|
203
|
-
* with `read()`, `write()
|
|
204
|
-
*
|
|
201
|
+
* A scoped query handle safe to pass into application or library code. Obtain
|
|
202
|
+
* one with `read()`, `write()`, or `admin()`. {@link Database} deliberately
|
|
203
|
+
* does not extend `Queryable`.
|
|
205
204
|
*/
|
|
206
205
|
export declare abstract class Queryable extends BaseQueryExecutor {
|
|
207
206
|
private readonly queryableBrand;
|
|
208
207
|
}
|
|
209
208
|
/**
|
|
210
|
-
* A handle to a
|
|
211
|
-
*
|
|
209
|
+
* A ClickHouse database handle scoped to a specific access level recorded by
|
|
210
|
+
* Encore's parser where it is created:
|
|
212
211
|
*
|
|
213
|
-
* - `read()`: `SELECT` and `SHOW
|
|
214
|
-
* grants
|
|
215
|
-
*
|
|
216
|
-
* - `write()`: reads, and `INSERT`, `ALTER … UPDATE/DELETE` and lightweight
|
|
212
|
+
* - `read()`: `SELECT` and `SHOW` only (writes are rejected by the user's
|
|
213
|
+
* grants or the `readonly` setting).
|
|
214
|
+
* - `write()`: reads plus `INSERT`, `ALTER ... UPDATE/DELETE`, and lightweight
|
|
217
215
|
* `DELETE`.
|
|
218
|
-
* - `admin()`:
|
|
216
|
+
* - `admin()`: full access including DDL, `TRUNCATE`, and `OPTIMIZE`.
|
|
219
217
|
*
|
|
220
|
-
* Each level
|
|
221
|
-
* with
|
|
218
|
+
* Each access level uses its own ClickHouse user, so `connectionString`
|
|
219
|
+
* connects with matching grants.
|
|
222
220
|
*/
|
|
223
221
|
export declare class DatabaseRef extends Queryable {
|
|
224
222
|
/** @internal */
|
|
225
223
|
constructor(handle: Handle, access: runtime.ClickHouseAccess);
|
|
226
224
|
}
|
|
227
225
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
226
|
+
* Declares a ClickHouse database. Encore provisions the database, runs its
|
|
227
|
+
* migrations, and returns this handle. Methods called directly on `Database`
|
|
228
|
+
* run with write access; call `read()`, `write()`, or `admin()` to obtain a
|
|
229
|
+
* handle with a specific access level.
|
|
232
230
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
231
|
+
* To reference an existing database without declaring a duplicate, use
|
|
232
|
+
* {@link Database.named}.
|
|
235
233
|
*
|
|
236
234
|
* @example
|
|
237
235
|
* import { Database } from "@encore.dev/sdk/storage/clickhouse";
|
|
@@ -246,15 +244,15 @@ export declare class Database extends BaseQueryExecutor {
|
|
|
246
244
|
private readonly refs;
|
|
247
245
|
constructor(name: string, _cfg?: DatabaseConfig);
|
|
248
246
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
247
|
+
* References an existing ClickHouse database by name. Use
|
|
248
|
+
* `new Database(name)` to declare a new database.
|
|
251
249
|
*/
|
|
252
250
|
static named<name extends string>(name: StringLiteral<name>): Database;
|
|
253
|
-
/**
|
|
251
|
+
/** Returns a read-only handle (`SELECT` and `SHOW`). */
|
|
254
252
|
read(): DatabaseRef;
|
|
255
|
-
/**
|
|
253
|
+
/** Returns a read-write handle (`SELECT`, `INSERT`, and mutations). */
|
|
256
254
|
write(): DatabaseRef;
|
|
257
|
-
/**
|
|
255
|
+
/** Returns an admin handle with full access (including DDL). */
|
|
258
256
|
admin(): DatabaseRef;
|
|
259
257
|
private ref;
|
|
260
258
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../storage/clickhouse/database.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAGxC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../storage/clickhouse/database.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,OAAO,MAAM,4BAA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