@encore.dev/sdk 2.0.0-beta.7 → 2.0.0-beta.8
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 +55 -0
- package/app_meta.ts +8 -0
- package/config/config.test.ts +10 -3
- package/config/config.ts +75 -21
- package/config/mod.ts +4 -3
- package/config/secrets.ts +72 -55
- package/cron/mod.ts +32 -0
- package/dist/app_meta.d.ts +7 -0
- package/dist/app_meta.d.ts.map +1 -0
- package/dist/app_meta.js +1 -0
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +44 -18
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +43 -18
- package/dist/config/config.js.map +1 -1
- package/dist/config/mod.d.ts +5 -4
- package/dist/config/mod.d.ts.map +1 -0
- package/dist/config/mod.js +2 -2
- package/dist/config/mod.js.map +1 -1
- package/dist/config/secrets.d.ts +62 -39
- package/dist/config/secrets.d.ts.map +1 -0
- package/dist/config/secrets.js +21 -37
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +1 -0
- package/dist/config/value.d.ts.map +1 -0
- package/dist/cron/mod.d.ts +31 -0
- package/dist/cron/mod.d.ts.map +1 -0
- package/dist/cron/mod.js +23 -0
- package/dist/cron/mod.js.map +1 -1
- package/dist/gateway/errors.d.ts +101 -0
- package/dist/gateway/errors.d.ts.map +1 -0
- package/dist/gateway/errors.js +146 -0
- package/dist/gateway/errors.js.map +1 -0
- package/dist/gateway/match.d.ts +127 -0
- package/dist/gateway/match.d.ts.map +1 -0
- package/dist/gateway/match.js +206 -0
- package/dist/gateway/match.js.map +1 -0
- package/dist/gateway/middleware.d.ts +108 -0
- package/dist/gateway/middleware.d.ts.map +1 -0
- package/dist/gateway/middleware.js +9 -0
- package/dist/gateway/middleware.js.map +1 -0
- package/dist/gateway/mod.d.ts +129 -0
- package/dist/gateway/mod.d.ts.map +1 -0
- package/dist/gateway/mod.js +187 -0
- package/dist/gateway/mod.js.map +1 -0
- package/dist/gateway/request.d.ts +304 -0
- package/dist/gateway/request.d.ts.map +1 -0
- package/dist/gateway/request.js +403 -0
- package/dist/gateway/request.js.map +1 -0
- package/dist/gateway/serve.d.ts +114 -0
- package/dist/gateway/serve.d.ts.map +1 -0
- package/dist/gateway/serve.js +510 -0
- package/dist/gateway/serve.js.map +1 -0
- package/dist/internal/clients/call.d.ts +147 -0
- package/dist/internal/clients/call.d.ts.map +1 -0
- package/dist/internal/clients/call.js +274 -0
- package/dist/internal/clients/call.js.map +1 -0
- package/dist/internal/clients/grpc.d.ts +90 -0
- package/dist/internal/clients/grpc.d.ts.map +1 -0
- package/dist/internal/clients/grpc.js +355 -0
- package/dist/internal/clients/grpc.js.map +1 -0
- package/dist/internal/clients/mod.d.ts +81 -0
- package/dist/internal/clients/mod.d.ts.map +1 -0
- package/dist/internal/clients/mod.js +237 -0
- package/dist/internal/clients/mod.js.map +1 -0
- package/dist/internal/fetch.d.ts +54 -0
- package/dist/internal/fetch.d.ts.map +1 -0
- package/dist/internal/fetch.js +240 -0
- package/dist/internal/fetch.js.map +1 -0
- package/dist/internal/otel/backend.d.ts +2 -0
- package/dist/internal/otel/backend.d.ts.map +1 -0
- package/dist/internal/otel/context.d.ts +1 -0
- package/dist/internal/otel/context.d.ts.map +1 -0
- package/dist/internal/otel/context_manager.d.ts +1 -0
- package/dist/internal/otel/context_manager.d.ts.map +1 -0
- package/dist/internal/otel/encode.d.ts +2 -0
- package/dist/internal/otel/encode.d.ts.map +1 -0
- package/dist/internal/otel/index.d.ts +2 -2
- package/dist/internal/otel/index.d.ts.map +1 -0
- package/dist/internal/otel/index.js +1 -2
- package/dist/internal/otel/index.js.map +1 -1
- package/dist/internal/otel/meter.d.ts +1 -0
- package/dist/internal/otel/meter.d.ts.map +1 -0
- package/dist/internal/otel/propagator.d.ts +1 -0
- package/dist/internal/otel/propagator.d.ts.map +1 -0
- package/dist/internal/otel/provider.d.ts +1 -0
- package/dist/internal/otel/provider.d.ts.map +1 -0
- package/dist/internal/otel/span.d.ts +4 -0
- package/dist/internal/otel/span.d.ts.map +1 -0
- package/dist/internal/otel/span.js +5 -0
- package/dist/internal/otel/span.js.map +1 -1
- package/dist/internal/otel/tracer.d.ts +1 -0
- package/dist/internal/otel/tracer.d.ts.map +1 -0
- package/dist/internal/otel/tracer.js +11 -5
- package/dist/internal/otel/tracer.js.map +1 -1
- package/dist/internal/reqfields.d.ts +150 -0
- package/dist/internal/reqfields.d.ts.map +1 -0
- package/dist/internal/reqfields.js +312 -0
- package/dist/internal/reqfields.js.map +1 -0
- package/dist/internal/runtime/meter.d.ts +1 -0
- package/dist/internal/runtime/meter.d.ts.map +1 -0
- package/dist/internal/runtime/mod.d.ts +6 -0
- package/dist/internal/runtime/mod.d.ts.map +1 -0
- package/dist/internal/runtime/mod.js +32 -2
- package/dist/internal/runtime/mod.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +160 -16
- package/dist/internal/runtime/napi/napi.d.cts +474 -29
- package/dist/internal/runtime/shutdown.d.ts +5 -0
- package/dist/internal/runtime/shutdown.d.ts.map +1 -0
- package/dist/internal/runtime/shutdown.js +9 -1
- package/dist/internal/runtime/shutdown.js.map +1 -1
- package/dist/internal/testing/runner.d.ts +2 -0
- package/dist/internal/testing/runner.d.ts.map +1 -0
- package/dist/internal/testing/runner.js +10 -0
- package/dist/internal/testing/runner.js.map +1 -0
- package/dist/internal/testing/scope.d.ts +81 -0
- package/dist/internal/testing/scope.d.ts.map +1 -0
- package/dist/internal/testing/scope.js +237 -0
- package/dist/internal/testing/scope.js.map +1 -0
- package/dist/internal/utils/constraints.d.ts +1 -0
- package/dist/internal/utils/constraints.d.ts.map +1 -0
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/logger.d.ts +2 -0
- package/dist/log/logger.d.ts.map +1 -0
- package/dist/log/runtime.d.ts +2 -0
- package/dist/log/runtime.d.ts.map +1 -0
- package/dist/log/stderr.d.ts +1 -0
- package/dist/log/stderr.d.ts.map +1 -0
- package/dist/metrics/mod.d.ts +45 -118
- package/dist/metrics/mod.d.ts.map +1 -0
- package/dist/metrics/mod.js +44 -179
- package/dist/metrics/mod.js.map +1 -1
- package/dist/mod.d.ts +1 -2
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +0 -1
- package/dist/mod.js.map +1 -1
- package/dist/otel.d.ts +1 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/pubsub/encoding.d.ts +5 -0
- package/dist/pubsub/encoding.d.ts.map +1 -0
- package/dist/pubsub/encoding.js +10 -2
- package/dist/pubsub/encoding.js.map +1 -1
- package/dist/pubsub/mod.d.ts +4 -3
- package/dist/pubsub/mod.d.ts.map +1 -0
- package/dist/pubsub/mod.js +2 -2
- package/dist/pubsub/mod.js.map +1 -1
- package/dist/pubsub/refs.d.ts +8 -0
- package/dist/pubsub/refs.d.ts.map +1 -0
- package/dist/pubsub/refs.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +104 -10
- package/dist/pubsub/subscription.d.ts.map +1 -0
- package/dist/pubsub/subscription.js +98 -16
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +87 -23
- package/dist/pubsub/topic.d.ts.map +1 -0
- package/dist/pubsub/topic.js +143 -40
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/reqctx/mod.d.ts +191 -0
- package/dist/reqctx/mod.d.ts.map +1 -0
- package/dist/reqctx/mod.js +160 -0
- package/dist/reqctx/mod.js.map +1 -0
- package/dist/services/index.d.ts +145 -4
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +155 -8
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +1 -0
- package/dist/shutdown/mod.d.ts.map +1 -0
- package/dist/storage/objects/bucket.d.ts +312 -7
- package/dist/storage/objects/bucket.d.ts.map +1 -0
- package/dist/storage/objects/bucket.js +305 -15
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +10 -0
- package/dist/storage/objects/error.d.ts.map +1 -0
- package/dist/storage/objects/error.js +25 -1
- package/dist/storage/objects/error.js.map +1 -1
- package/dist/storage/objects/mod.d.ts +4 -3
- package/dist/storage/objects/mod.d.ts.map +1 -0
- package/dist/storage/objects/mod.js +1 -1
- package/dist/storage/objects/mod.js.map +1 -1
- package/dist/storage/objects/refs.d.ts +20 -4
- package/dist/storage/objects/refs.d.ts.map +1 -0
- package/dist/storage/objects/refs.js +6 -0
- package/dist/storage/objects/refs.js.map +1 -1
- package/dist/storage/postgres/database.d.ts +81 -25
- package/dist/storage/postgres/database.d.ts.map +1 -0
- package/dist/storage/postgres/database.js +125 -37
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts +120 -0
- package/dist/storage/postgres/errors.d.ts.map +1 -0
- package/dist/storage/postgres/errors.js +162 -0
- package/dist/storage/postgres/errors.js.map +1 -0
- package/dist/storage/postgres/interval.d.ts +44 -0
- package/dist/storage/postgres/interval.d.ts.map +1 -0
- package/dist/storage/postgres/interval.js +153 -0
- package/dist/storage/postgres/interval.js.map +1 -0
- package/dist/storage/postgres/mod.d.ts +4 -1
- package/dist/storage/postgres/mod.d.ts.map +1 -0
- package/dist/storage/postgres/mod.js +2 -0
- package/dist/storage/postgres/mod.js.map +1 -1
- package/dist/storage/redis/bitfield.d.ts +67 -0
- package/dist/storage/redis/bitfield.d.ts.map +1 -0
- package/dist/storage/redis/bitfield.js +114 -0
- package/dist/storage/redis/bitfield.js.map +1 -0
- package/dist/storage/redis/command.d.ts +45 -0
- package/dist/storage/redis/command.d.ts.map +1 -0
- package/dist/storage/redis/command.js +78 -0
- package/dist/storage/redis/command.js.map +1 -0
- package/dist/storage/redis/commands.d.ts +223 -139
- package/dist/storage/redis/commands.d.ts.map +1 -0
- package/dist/storage/redis/commands.js +128 -6
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +56 -22
- package/dist/storage/redis/database.d.ts.map +1 -0
- package/dist/storage/redis/database.js +62 -0
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +31 -4
- package/dist/storage/redis/mod.d.ts.map +1 -0
- package/dist/storage/redis/mod.js +26 -1
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/native.d.ts +8 -0
- package/dist/storage/redis/native.d.ts.map +1 -0
- package/dist/storage/redis/native.js +10 -0
- package/dist/storage/redis/native.js.map +1 -1
- package/dist/storage/redis/options.d.ts +1 -0
- package/dist/storage/redis/options.d.ts.map +1 -0
- package/dist/storage/redis/pubsub.d.ts +2 -0
- package/dist/storage/redis/pubsub.d.ts.map +1 -0
- package/dist/storage/redis/reply.d.ts +34 -0
- package/dist/storage/redis/reply.d.ts.map +1 -0
- package/dist/storage/redis/reply.js +40 -1
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +1 -0
- package/dist/storage/redis/scan.d.ts.map +1 -0
- package/dist/storage/redis/script.d.ts +1 -0
- package/dist/storage/redis/script.d.ts.map +1 -0
- package/dist/storage/redis/target.d.ts +5 -3
- package/dist/storage/redis/target.d.ts.map +1 -0
- package/dist/storage/redis/target.js +39 -28
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +7 -10
- package/dist/storage/redis/wire.d.ts.map +1 -0
- package/dist/storage/redis/wire.js +8 -32
- package/dist/storage/redis/wire.js.map +1 -1
- package/dist/testing/bun.d.ts +8 -0
- package/dist/testing/bun.d.ts.map +1 -0
- package/dist/testing/bun.js +13 -0
- package/dist/testing/bun.js.map +1 -0
- package/dist/testing/jest.d.ts +8 -0
- package/dist/testing/jest.d.ts.map +1 -0
- package/dist/testing/jest.js +11 -0
- package/dist/testing/jest.js.map +1 -0
- package/dist/testing/mod.d.ts +160 -0
- package/dist/testing/mod.d.ts.map +1 -0
- package/dist/testing/mod.js +227 -0
- package/dist/testing/mod.js.map +1 -0
- package/dist/testing/node.d.ts +9 -0
- package/dist/testing/node.d.ts.map +1 -0
- package/dist/testing/node.js +12 -0
- package/dist/testing/node.js.map +1 -0
- package/dist/testing/vitest.d.ts +8 -0
- package/dist/testing/vitest.d.ts.map +1 -0
- package/dist/testing/vitest.js +13 -0
- package/dist/testing/vitest.js.map +1 -0
- package/dist/tracing/mod.d.ts +19 -0
- package/dist/tracing/mod.d.ts.map +1 -0
- package/dist/tracing/mod.js +46 -0
- package/dist/tracing/mod.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +1 -0
- package/dist/types/mod.d.ts.map +1 -0
- package/gateway/errors.ts +172 -0
- package/gateway/gateway.e2e.test.ts +297 -0
- package/gateway/gateway.test.ts +891 -0
- package/gateway/match.ts +239 -0
- package/gateway/middleware.ts +134 -0
- package/gateway/mod.ts +210 -0
- package/gateway/request.ts +578 -0
- package/gateway/serve.ts +738 -0
- package/internal/clients/call.ts +389 -0
- package/internal/clients/grpc.test.ts +368 -0
- package/internal/clients/grpc.ts +485 -0
- package/internal/clients/mod.test.ts +464 -0
- package/internal/clients/mod.ts +337 -0
- package/internal/fetch.ts +276 -0
- package/internal/otel/index.ts +1 -7
- package/internal/otel/span.ts +6 -0
- package/internal/otel/tracer.test.ts +43 -15
- package/internal/otel/tracer.ts +12 -5
- package/internal/reqfields.ts +390 -0
- package/internal/runtime/mod.ts +41 -2
- package/internal/runtime/napi/napi.cjs +160 -16
- package/internal/runtime/napi/napi.d.cts +474 -29
- package/internal/runtime/shutdown.ts +11 -1
- package/internal/testing/runner.ts +10 -0
- package/internal/testing/scope.ts +273 -0
- package/metrics/mod.test.ts +13 -16
- package/metrics/mod.ts +57 -226
- package/mod.ts +0 -8
- package/otel.test.ts +13 -6
- package/package.json +67 -15
- package/pubsub/encoding.ts +11 -1
- package/pubsub/mod.ts +10 -3
- package/pubsub/pubsub.test.ts +232 -14
- package/pubsub/refs.ts +16 -0
- package/pubsub/subscription.ts +194 -16
- package/pubsub/topic.test.ts +26 -0
- package/pubsub/topic.ts +220 -25
- package/reqctx/mod.ts +284 -0
- package/reqctx/reqctx.test.ts +193 -0
- package/scripts/postprocess-docs.test.ts +48 -0
- package/services/index.test.ts +341 -1
- package/services/index.ts +183 -8
- package/storage/objects/bucket.test.ts +573 -0
- package/storage/objects/bucket.ts +649 -20
- package/storage/objects/error.ts +28 -1
- package/storage/objects/mod.ts +15 -0
- package/storage/objects/refs.ts +51 -3
- package/storage/postgres/database.integration.test.ts +275 -0
- package/storage/postgres/database.test.ts +193 -6
- package/storage/postgres/database.ts +202 -55
- package/storage/postgres/errors.ts +186 -0
- package/storage/postgres/interval.test.ts +72 -0
- package/storage/postgres/interval.ts +170 -0
- package/storage/postgres/mod.ts +4 -0
- package/storage/redis/bitfield.ts +162 -0
- package/storage/redis/command.ts +84 -0
- package/storage/redis/commands.ts +271 -21
- package/storage/redis/database.ts +77 -23
- package/storage/redis/mod.ts +38 -2
- package/storage/redis/native.ts +11 -0
- package/storage/redis/redis.test.ts +170 -10
- package/storage/redis/reply.ts +76 -1
- package/storage/redis/runtime.test.ts +15 -0
- package/storage/redis/target.ts +47 -44
- package/storage/redis/wire.ts +8 -32
- package/testing/bun.ts +13 -0
- package/testing/jest.ts +11 -0
- package/testing/mod.ts +337 -0
- package/testing/node.ts +12 -0
- package/testing/vitest.ts +13 -0
- package/tracing/mod.ts +82 -0
- package/tracing/native.test.ts +170 -0
- package/tracing/tracing.test.ts +317 -0
- package/dist/internal/otel/request_context.d.ts +0 -11
- package/dist/internal/otel/request_context.js +0 -20
- package/dist/internal/otel/request_context.js.map +0 -1
- package/dist/internal/reqtrack/mod.d.ts +0 -6
- package/dist/internal/reqtrack/mod.js +0 -28
- package/dist/internal/reqtrack/mod.js.map +0 -1
- package/dist/req_meta.d.ts +0 -47
- package/dist/req_meta.js +0 -26
- package/dist/req_meta.js.map +0 -1
- package/internal/otel/request_context.ts +0 -32
- package/internal/reqtrack/mod.ts +0 -39
- package/req_meta.ts +0 -75
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import * as runtime from '../../internal/runtime/mod.js';
|
|
4
5
|
import { StringLiteral } from '../../internal/utils/constraints.js';
|
|
6
|
+
import type { Interval } from './interval.js';
|
|
5
7
|
/**
|
|
6
8
|
* Configures how database migrations are managed for a `Database`.
|
|
7
9
|
*/
|
|
@@ -14,22 +16,42 @@ export interface MigrationsConfig {
|
|
|
14
16
|
*/
|
|
15
17
|
export interface DatabaseConfig {
|
|
16
18
|
migrations?: string | MigrationsConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Tags that classify the database, for policies to read: written out as
|
|
21
|
+
* string literals, as in `{data: "pci"}`. Keys and values are lowercase
|
|
22
|
+
* letters, digits, `_` and `-`, at most 63 characters; a key starts with a
|
|
23
|
+
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
24
|
+
*/
|
|
25
|
+
tags?: Record<string, string>;
|
|
17
26
|
}
|
|
18
27
|
/**
|
|
19
|
-
* Represents a single row from a query result
|
|
28
|
+
* Represents a single row from a query result, keyed by column name.
|
|
29
|
+
*
|
|
30
|
+
* Integers and floats are numbers, except an `int8` beyond what a number
|
|
31
|
+
* holds exactly (±(2^53−1)), which is a `bigint` so it is never rounded.
|
|
32
|
+
* `numeric` is a `Decimal`, `interval` a string in ISO 8601's form
|
|
33
|
+
* (`'P1Y2M3DT4H5M6.5S'`; see {@link Interval}), `timestamp`/`timestamptz` a
|
|
34
|
+
* `Date`, and `bytea` an `ArrayBuffer`. A type the SDK doesn't decode (`money`, `timetz`, ranges,
|
|
35
|
+
* `bit`, `xml`, `tsvector`, an extension's) is a string in the server's text
|
|
36
|
+
* form, and an array of one an array of such strings; a parameter of such a
|
|
37
|
+
* type takes a string, which the server parses.
|
|
20
38
|
*/
|
|
21
39
|
export type Row = Record<string, any>;
|
|
22
40
|
/** Represents a type that can be used in query template literals */
|
|
23
|
-
export type Primitive = string | string[] | number | number[] | boolean | boolean[] | Buffer | Date | Date[] | Record<string, any> | Record<string, any>[] | BigInt | BigInt[] | null | undefined;
|
|
41
|
+
export type Primitive = string | string[] | number | number[] | boolean | boolean[] | Buffer | Date | Date[] | Interval | Interval[] | Record<string, any> | Record<string, any>[] | BigInt | BigInt[] | null | undefined;
|
|
24
42
|
type SQLQueryExecutor = runtime.SQLConn | runtime.SQLDatabase | runtime.Transaction;
|
|
25
43
|
/** The number of affected rows, represented exactly even beyond Number.MAX_SAFE_INTEGER. */
|
|
26
44
|
export interface ExecResult {
|
|
27
45
|
rowsAffected: bigint;
|
|
28
46
|
}
|
|
29
47
|
/** Base class containing shared query functionality */
|
|
30
|
-
declare class BaseQueryExecutor {
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
declare class BaseQueryExecutor<I extends SQLQueryExecutor = SQLQueryExecutor> {
|
|
49
|
+
private readonly handle;
|
|
50
|
+
/** The native handle, or how to find it for each call: a database's is
|
|
51
|
+
* the current test's instance of it, in test mode. */
|
|
52
|
+
constructor(handle: I | (() => I));
|
|
53
|
+
/** The native handle statements run on. */
|
|
54
|
+
protected get impl(): I;
|
|
33
55
|
/**
|
|
34
56
|
* query queries the database using a template string, replacing your placeholders in the template
|
|
35
57
|
* with parametrised values without risking SQL injections.
|
|
@@ -92,7 +114,7 @@ declare class BaseQueryExecutor {
|
|
|
92
114
|
/**
|
|
93
115
|
* queryRow is like query but returns only a single row.
|
|
94
116
|
* If the query selects no rows it returns null.
|
|
95
|
-
* It throws if more than one row matches.
|
|
117
|
+
* It throws a {@link TooManyRowsError} if more than one row matches.
|
|
96
118
|
*
|
|
97
119
|
* @example
|
|
98
120
|
* const email = "foo@example.com";
|
|
@@ -102,7 +124,7 @@ declare class BaseQueryExecutor {
|
|
|
102
124
|
/**
|
|
103
125
|
* rawQueryRow is like rawQuery but returns only a single row.
|
|
104
126
|
* If the query selects no rows, it returns null.
|
|
105
|
-
* It throws if more than one row matches.
|
|
127
|
+
* It throws a {@link TooManyRowsError} if more than one row matches.
|
|
106
128
|
*
|
|
107
129
|
* @example
|
|
108
130
|
* const query = "SELECT id FROM users WHERE email=$1";
|
|
@@ -137,12 +159,33 @@ declare class BaseQueryExecutor {
|
|
|
137
159
|
*/
|
|
138
160
|
rawExec(query: string, ...params: Primitive[]): Promise<ExecResult>;
|
|
139
161
|
}
|
|
162
|
+
/** The isolation level of a transaction. */
|
|
163
|
+
export type IsolationLevel = 'read_committed' | 'repeatable_read' | 'serializable';
|
|
164
|
+
/**
|
|
165
|
+
* How a transaction runs. What isn't set is the database's default:
|
|
166
|
+
* `read_committed`, read-write (read-only on a read handle), not deferrable.
|
|
167
|
+
*/
|
|
168
|
+
export interface TransactionOptions {
|
|
169
|
+
isolation?: IsolationLevel;
|
|
170
|
+
/**
|
|
171
|
+
* Begin the transaction `READ ONLY`, or with `false` `READ WRITE`. A read
|
|
172
|
+
* handle's transactions are read-only whatever this says, so `false`
|
|
173
|
+
* throws a `TypeError` on one.
|
|
174
|
+
*/
|
|
175
|
+
readOnly?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Begin the transaction `DEFERRABLE`, or with `false` `NOT DEFERRABLE`. It
|
|
178
|
+
* matters only to a serializable, read-only transaction, which then waits
|
|
179
|
+
* until it can run without serialization failures.
|
|
180
|
+
*/
|
|
181
|
+
deferrable?: boolean;
|
|
182
|
+
}
|
|
140
183
|
/**
|
|
141
184
|
* A query handle that can be passed to application/library code.
|
|
142
185
|
* Obtain one with read(), write(), or admin(), or use a connection/transaction.
|
|
143
186
|
* A Database declaration deliberately does not implement this interface.
|
|
144
187
|
*/
|
|
145
|
-
export declare abstract class Queryable extends BaseQueryExecutor {
|
|
188
|
+
export declare abstract class Queryable<I extends SQLQueryExecutor = SQLQueryExecutor> extends BaseQueryExecutor<I> {
|
|
146
189
|
private readonly queryableBrand;
|
|
147
190
|
}
|
|
148
191
|
/** Options for selecting read access. */
|
|
@@ -157,10 +200,10 @@ export interface ReadOptions {
|
|
|
157
200
|
* A database handle with access recorded by Encore's parser at its creation site.
|
|
158
201
|
*
|
|
159
202
|
* Handles share the declaration's pool. A read handle runs on read-only
|
|
160
|
-
* connections: a statement that writes fails with `
|
|
161
|
-
* (SQLSTATE 25006), and the transactions it
|
|
162
|
-
* connections it acquires, are read-only. A write
|
|
163
|
-
* read-write.
|
|
203
|
+
* connections: a statement that writes fails with a `DatabaseError` whose
|
|
204
|
+
* code is `read_only_transaction` (SQLSTATE 25006), and the transactions it
|
|
205
|
+
* begins, and those of the connections it acquires, are read-only. A write
|
|
206
|
+
* or admin handle runs read-write.
|
|
164
207
|
*
|
|
165
208
|
* On the database's own pool, which a read handle shares when there is no
|
|
166
209
|
* read-only pool for it, that refuses mistaken writes, not deliberate ones:
|
|
@@ -168,9 +211,8 @@ export interface ReadOptions {
|
|
|
168
211
|
* connection (`SET default_transaction_read_only = off`) lifts it. Against
|
|
169
212
|
* untrusted code, the read-only pool's database role is what refuses writes.
|
|
170
213
|
*/
|
|
171
|
-
export declare class DatabaseRef extends Queryable {
|
|
172
|
-
|
|
173
|
-
constructor(impl: runtime.SQLDatabase);
|
|
214
|
+
export declare class DatabaseRef extends Queryable<runtime.SQLDatabase> {
|
|
215
|
+
constructor(impl: runtime.SQLDatabase | (() => runtime.SQLDatabase));
|
|
174
216
|
/**
|
|
175
217
|
* The connection string to connect to the database with another client.
|
|
176
218
|
* A write or admin handle's connects read-write. A read handle's connects
|
|
@@ -187,7 +229,11 @@ export declare class DatabaseRef extends Queryable {
|
|
|
187
229
|
* See {@link Database.acquire}.
|
|
188
230
|
*/
|
|
189
231
|
acquire(): Promise<Connection>;
|
|
190
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Begins a transaction with this handle's access. See {@link Database.begin}.
|
|
234
|
+
* A read handle's transactions are read-only.
|
|
235
|
+
*/
|
|
236
|
+
begin(options?: TransactionOptions): Promise<Transaction>;
|
|
191
237
|
}
|
|
192
238
|
/**
|
|
193
239
|
* Constructing a new database object will result in Encore provisioning a database with
|
|
@@ -196,11 +242,11 @@ export declare class DatabaseRef extends Queryable {
|
|
|
196
242
|
* If you want to reference an existing database, use `Database.named(name)` as it is a
|
|
197
243
|
* compile error to create duplicate databases.
|
|
198
244
|
*/
|
|
199
|
-
export declare class Database extends BaseQueryExecutor {
|
|
200
|
-
protected readonly impl: runtime.SQLDatabase;
|
|
245
|
+
export declare class Database extends BaseQueryExecutor<runtime.SQLDatabase> {
|
|
201
246
|
/** The read handles, made on first use. */
|
|
202
247
|
private reader?;
|
|
203
248
|
private primaryReader?;
|
|
249
|
+
private readonly dbName;
|
|
204
250
|
constructor(name: string, _cfg?: DatabaseConfig);
|
|
205
251
|
/**
|
|
206
252
|
* Reference an existing database by name, if the database doesn't
|
|
@@ -253,9 +299,16 @@ export declare class Database extends BaseQueryExecutor {
|
|
|
253
299
|
* If you can't use `await using`, make sure to always call `commit`
|
|
254
300
|
* or `rollback` yourself to prevent hanging transactions.
|
|
255
301
|
*
|
|
302
|
+
* `options` sets the transaction's isolation level and whether it is
|
|
303
|
+
* read-only or deferrable:
|
|
304
|
+
*
|
|
305
|
+
* ```ts
|
|
306
|
+
* await using tx = await db.begin({isolation: 'serializable'});
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
256
309
|
* @returns a transaction object that implements `AsyncDisposable`
|
|
257
310
|
*/
|
|
258
|
-
begin(): Promise<Transaction>;
|
|
311
|
+
begin(options?: TransactionOptions): Promise<Transaction>;
|
|
259
312
|
}
|
|
260
313
|
/**
|
|
261
314
|
* Represents a database transaction.
|
|
@@ -274,8 +327,7 @@ export declare class Database extends BaseQueryExecutor {
|
|
|
274
327
|
* If you can't use `await using`, make sure to always call `commit` or
|
|
275
328
|
* `rollback` yourself to prevent hanging transactions.
|
|
276
329
|
*/
|
|
277
|
-
export declare class Transaction extends Queryable implements AsyncDisposable {
|
|
278
|
-
protected readonly impl: runtime.Transaction;
|
|
330
|
+
export declare class Transaction extends Queryable<runtime.Transaction> implements AsyncDisposable {
|
|
279
331
|
private done;
|
|
280
332
|
constructor(impl: runtime.Transaction);
|
|
281
333
|
/**
|
|
@@ -291,11 +343,14 @@ export declare class Transaction extends Queryable implements AsyncDisposable {
|
|
|
291
343
|
/**
|
|
292
344
|
* Represents a dedicated connection to a database.
|
|
293
345
|
*/
|
|
294
|
-
export declare class Connection extends Queryable implements AsyncDisposable {
|
|
295
|
-
protected readonly impl: runtime.SQLConn;
|
|
346
|
+
export declare class Connection extends Queryable<runtime.SQLConn> implements AsyncDisposable {
|
|
296
347
|
constructor(impl: runtime.SQLConn);
|
|
297
|
-
/**
|
|
298
|
-
|
|
348
|
+
/**
|
|
349
|
+
* Begin a transaction that exclusively borrows this connection until
|
|
350
|
+
* completion. See {@link Database.begin}. A connection acquired from a
|
|
351
|
+
* read handle begins read-only transactions.
|
|
352
|
+
*/
|
|
353
|
+
begin(options?: TransactionOptions): Promise<Transaction>;
|
|
299
354
|
[Symbol.asyncDispose](): Promise<void>;
|
|
300
355
|
/**
|
|
301
356
|
* Returns the connection to the database pool.
|
|
@@ -303,3 +358,4 @@ export declare class Connection extends Queryable implements AsyncDisposable {
|
|
|
303
358
|
close(): Promise<void>;
|
|
304
359
|
}
|
|
305
360
|
export {};
|
|
361
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../storage/postgres/database.ts"],"names":[],"mappings":";;;AACA,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAE/D,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;CAC9C;AACD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAA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CAAC,IAAI,CAAC,GAAG,QAAQ;IAItE;;;;OAIG;IACH,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,WAAW;IAO5C,uCAAuC;IACvC,KAAK,IAAI,WAAW;IAIpB,+CAA+C;IAC/C,KAAK,IAAI,WAAW;IAIpB,OAAO,CAAC,GAAG;IAWX;;;;OAIG;IACH,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED;;;;;;;;;;;OAWG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAKpC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;CAGhE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WACX,SAAQ,SAAS,CAAC,OAAO,CAAC,WAAW,CACrC,YAAW,eAAe;IAE1B,OAAO,CAAC,IAAI,CAAkB;gBAElB,IAAI,EAAE,OAAO,CAAC,WAAW;IAIrC;;OAEG;IACG,MAAM;IAQZ;;OAEG;IACG,QAAQ;IAQR,CAAC,MAAM,CAAC,YAAY,CAAC;CAK5B;AAED;;GAEG;AACH,qBAAa,UACX,SAAQ,SAAS,CAAC,OAAO,CAAC,OAAO,CACjC,YAAW,eAAe;gBAEd,IAAI,EAAE,OAAO,CAAC,OAAO;IAIjC;;;;OAIG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzD,CAAC,MAAM,CAAC,YAAY,CAAC;IAI3B;;OAEG;IACG,KAAK;CAGZ"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { activeCtxBytes } from '../../internal/otel/index.js';
|
|
2
2
|
import * as runtime from '../../internal/runtime/mod.js';
|
|
3
|
+
import { currentScope, testMode } from '../../internal/testing/scope.js';
|
|
4
|
+
import { native, TooManyRowsError } from './errors.js';
|
|
3
5
|
/** Base class containing shared query functionality */
|
|
4
6
|
class BaseQueryExecutor {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
handle;
|
|
8
|
+
/** The native handle, or how to find it for each call: a database's is
|
|
9
|
+
* the current test's instance of it, in test mode. */
|
|
10
|
+
constructor(handle) {
|
|
11
|
+
this.handle = handle;
|
|
12
|
+
}
|
|
13
|
+
/** The native handle statements run on. */
|
|
14
|
+
get impl() {
|
|
15
|
+
return typeof this.handle === 'function' ? this.handle() : this.handle;
|
|
8
16
|
}
|
|
9
17
|
/**
|
|
10
18
|
* query queries the database using a template string, replacing your placeholders in the template
|
|
@@ -41,17 +49,17 @@ class BaseQueryExecutor {
|
|
|
41
49
|
* @returns An async generator that yields rows from the query result.
|
|
42
50
|
*/
|
|
43
51
|
async *rawQuery(query, ...params) {
|
|
44
|
-
const cursor = await this.impl.query(query, buildQueryArgs(params), activeCtxBytes());
|
|
52
|
+
const cursor = await native(this.impl.query(query, buildQueryArgs(params), activeCtxBytes()));
|
|
45
53
|
try {
|
|
46
54
|
while (true) {
|
|
47
|
-
const row = await cursor.next();
|
|
55
|
+
const row = await native(cursor.next());
|
|
48
56
|
if (row === null)
|
|
49
57
|
break;
|
|
50
58
|
yield row.values();
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
finally {
|
|
54
|
-
await cursor.close();
|
|
62
|
+
await native(cursor.close());
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
/**
|
|
@@ -90,7 +98,7 @@ class BaseQueryExecutor {
|
|
|
90
98
|
/**
|
|
91
99
|
* queryRow is like query but returns only a single row.
|
|
92
100
|
* If the query selects no rows it returns null.
|
|
93
|
-
* It throws if more than one row matches.
|
|
101
|
+
* It throws a {@link TooManyRowsError} if more than one row matches.
|
|
94
102
|
*
|
|
95
103
|
* @example
|
|
96
104
|
* const email = "foo@example.com";
|
|
@@ -102,7 +110,7 @@ class BaseQueryExecutor {
|
|
|
102
110
|
/**
|
|
103
111
|
* rawQueryRow is like rawQuery but returns only a single row.
|
|
104
112
|
* If the query selects no rows, it returns null.
|
|
105
|
-
* It throws if more than one row matches.
|
|
113
|
+
* It throws a {@link TooManyRowsError} if more than one row matches.
|
|
106
114
|
*
|
|
107
115
|
* @example
|
|
108
116
|
* const query = "SELECT id FROM users WHERE email=$1";
|
|
@@ -118,7 +126,7 @@ class BaseQueryExecutor {
|
|
|
118
126
|
let first = null;
|
|
119
127
|
for await (const row of this.rawQuery(query, ...params)) {
|
|
120
128
|
if (first !== null)
|
|
121
|
-
throw new
|
|
129
|
+
throw new TooManyRowsError();
|
|
122
130
|
first = row;
|
|
123
131
|
}
|
|
124
132
|
return first;
|
|
@@ -146,17 +154,47 @@ class BaseQueryExecutor {
|
|
|
146
154
|
* @returns The affected-row count after the statement completes.
|
|
147
155
|
*/
|
|
148
156
|
async rawExec(query, ...params) {
|
|
149
|
-
const cursor = await this.impl.query(query, buildQueryArgs(params), activeCtxBytes());
|
|
157
|
+
const cursor = await native(this.impl.query(query, buildQueryArgs(params), activeCtxBytes()));
|
|
150
158
|
try {
|
|
151
|
-
while ((await cursor.next()) !== null) {
|
|
159
|
+
while ((await native(cursor.next())) !== null) {
|
|
152
160
|
/* Discard RETURNING rows. */
|
|
153
161
|
}
|
|
154
|
-
return { rowsAffected: await cursor.rowsAffected() };
|
|
162
|
+
return { rowsAffected: await native(cursor.rowsAffected()) };
|
|
155
163
|
}
|
|
156
164
|
finally {
|
|
157
|
-
await cursor.close();
|
|
165
|
+
await native(cursor.close());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const isolationLevels = {
|
|
170
|
+
read_committed: runtime.SQLIsolationLevel.ReadCommitted,
|
|
171
|
+
repeatable_read: runtime.SQLIsolationLevel.RepeatableRead,
|
|
172
|
+
serializable: runtime.SQLIsolationLevel.Serializable,
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Begins a transaction on `impl`, a pool or connection, with `options`.
|
|
176
|
+
* Throws a `TypeError` for an unknown isolation level, or for
|
|
177
|
+
* `readOnly: false` on a read handle's pool or connection.
|
|
178
|
+
*/
|
|
179
|
+
async function beginOn(impl, options) {
|
|
180
|
+
let opts;
|
|
181
|
+
if (options !== undefined) {
|
|
182
|
+
const { isolation, readOnly, deferrable } = options;
|
|
183
|
+
if (isolation !== undefined &&
|
|
184
|
+
!Object.prototype.hasOwnProperty.call(isolationLevels, isolation)) {
|
|
185
|
+
throw new TypeError(`unknown isolation level ${JSON.stringify(isolation)}: ` +
|
|
186
|
+
`expected one of ${Object.keys(isolationLevels).join(', ')}`);
|
|
187
|
+
}
|
|
188
|
+
if (readOnly === false && impl.isReadOnly()) {
|
|
189
|
+
throw new TypeError("a read handle's transactions are read-only: readOnly cannot be false");
|
|
158
190
|
}
|
|
191
|
+
opts = {
|
|
192
|
+
isolation: isolation === undefined ? undefined : isolationLevels[isolation],
|
|
193
|
+
readOnly,
|
|
194
|
+
deferrable,
|
|
195
|
+
};
|
|
159
196
|
}
|
|
197
|
+
return new Transaction(await native(impl.begin(opts, activeCtxBytes())));
|
|
160
198
|
}
|
|
161
199
|
/**
|
|
162
200
|
* A query handle that can be passed to application/library code.
|
|
@@ -170,10 +208,10 @@ export class Queryable extends BaseQueryExecutor {
|
|
|
170
208
|
* A database handle with access recorded by Encore's parser at its creation site.
|
|
171
209
|
*
|
|
172
210
|
* Handles share the declaration's pool. A read handle runs on read-only
|
|
173
|
-
* connections: a statement that writes fails with `
|
|
174
|
-
* (SQLSTATE 25006), and the transactions it
|
|
175
|
-
* connections it acquires, are read-only. A write
|
|
176
|
-
* read-write.
|
|
211
|
+
* connections: a statement that writes fails with a `DatabaseError` whose
|
|
212
|
+
* code is `read_only_transaction` (SQLSTATE 25006), and the transactions it
|
|
213
|
+
* begins, and those of the connections it acquires, are read-only. A write
|
|
214
|
+
* or admin handle runs read-write.
|
|
177
215
|
*
|
|
178
216
|
* On the database's own pool, which a read handle shares when there is no
|
|
179
217
|
* read-only pool for it, that refuses mistaken writes, not deliberate ones:
|
|
@@ -203,10 +241,14 @@ export class DatabaseRef extends Queryable {
|
|
|
203
241
|
* See {@link Database.acquire}.
|
|
204
242
|
*/
|
|
205
243
|
async acquire() {
|
|
206
|
-
return new Connection(await this.impl.acquire());
|
|
244
|
+
return new Connection(await native(this.impl.acquire()));
|
|
207
245
|
}
|
|
208
|
-
|
|
209
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Begins a transaction with this handle's access. See {@link Database.begin}.
|
|
248
|
+
* A read handle's transactions are read-only.
|
|
249
|
+
*/
|
|
250
|
+
async begin(options) {
|
|
251
|
+
return beginOn(this.impl, options);
|
|
210
252
|
}
|
|
211
253
|
}
|
|
212
254
|
/**
|
|
@@ -220,8 +262,10 @@ export class Database extends BaseQueryExecutor {
|
|
|
220
262
|
/** The read handles, made on first use. */
|
|
221
263
|
reader;
|
|
222
264
|
primaryReader;
|
|
265
|
+
dbName;
|
|
223
266
|
constructor(name, _cfg) {
|
|
224
|
-
super(runtime.RT.sqlDatabase(name));
|
|
267
|
+
super(testMode ? testHandle(name) : runtime.RT.sqlDatabase(name));
|
|
268
|
+
this.dbName = name;
|
|
225
269
|
}
|
|
226
270
|
/**
|
|
227
271
|
* Reference an existing database by name, if the database doesn't
|
|
@@ -243,14 +287,23 @@ export class Database extends BaseQueryExecutor {
|
|
|
243
287
|
}
|
|
244
288
|
/** Select reader and writer access. */
|
|
245
289
|
write() {
|
|
246
|
-
return new DatabaseRef(this.impl);
|
|
290
|
+
return new DatabaseRef(testMode ? () => this.impl : this.impl);
|
|
247
291
|
}
|
|
248
292
|
/** Select reader, writer, and admin access. */
|
|
249
293
|
admin() {
|
|
250
|
-
return
|
|
294
|
+
return this.write();
|
|
251
295
|
}
|
|
252
296
|
ref(access) {
|
|
253
|
-
|
|
297
|
+
if (!testMode)
|
|
298
|
+
return new DatabaseRef(this.impl.withAccess(access));
|
|
299
|
+
// The current test's instance, for each call.
|
|
300
|
+
let own;
|
|
301
|
+
return new DatabaseRef(() => {
|
|
302
|
+
const scope = currentScope();
|
|
303
|
+
if (scope !== null)
|
|
304
|
+
return scope.sqlDatabase(this.dbName, access);
|
|
305
|
+
return (own ??= this.impl.withAccess(access));
|
|
306
|
+
});
|
|
254
307
|
}
|
|
255
308
|
/**
|
|
256
309
|
* Returns the connection string for the database, which connects
|
|
@@ -273,7 +326,7 @@ export class Database extends BaseQueryExecutor {
|
|
|
273
326
|
* @returns a new connection to the database
|
|
274
327
|
*/
|
|
275
328
|
async acquire() {
|
|
276
|
-
const impl = await this.impl.acquire();
|
|
329
|
+
const impl = await native(this.impl.acquire());
|
|
277
330
|
return new Connection(impl);
|
|
278
331
|
}
|
|
279
332
|
/**
|
|
@@ -292,12 +345,17 @@ export class Database extends BaseQueryExecutor {
|
|
|
292
345
|
* If you can't use `await using`, make sure to always call `commit`
|
|
293
346
|
* or `rollback` yourself to prevent hanging transactions.
|
|
294
347
|
*
|
|
348
|
+
* `options` sets the transaction's isolation level and whether it is
|
|
349
|
+
* read-only or deferrable:
|
|
350
|
+
*
|
|
351
|
+
* ```ts
|
|
352
|
+
* await using tx = await db.begin({isolation: 'serializable'});
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
295
355
|
* @returns a transaction object that implements `AsyncDisposable`
|
|
296
356
|
*/
|
|
297
|
-
async begin() {
|
|
298
|
-
|
|
299
|
-
const impl = await this.impl.begin(source);
|
|
300
|
-
return new Transaction(impl);
|
|
357
|
+
async begin(options) {
|
|
358
|
+
return beginOn(this.impl, options);
|
|
301
359
|
}
|
|
302
360
|
}
|
|
303
361
|
/**
|
|
@@ -327,7 +385,7 @@ export class Transaction extends Queryable {
|
|
|
327
385
|
*/
|
|
328
386
|
async commit() {
|
|
329
387
|
try {
|
|
330
|
-
await this.impl.commit();
|
|
388
|
+
await native(this.impl.commit());
|
|
331
389
|
}
|
|
332
390
|
finally {
|
|
333
391
|
this.done = this.impl.isClosed();
|
|
@@ -338,7 +396,7 @@ export class Transaction extends Queryable {
|
|
|
338
396
|
*/
|
|
339
397
|
async rollback() {
|
|
340
398
|
try {
|
|
341
|
-
await this.impl.rollback();
|
|
399
|
+
await native(this.impl.rollback());
|
|
342
400
|
}
|
|
343
401
|
finally {
|
|
344
402
|
this.done = this.impl.isClosed();
|
|
@@ -357,9 +415,13 @@ export class Connection extends Queryable {
|
|
|
357
415
|
constructor(impl) {
|
|
358
416
|
super(impl);
|
|
359
417
|
}
|
|
360
|
-
/**
|
|
361
|
-
|
|
362
|
-
|
|
418
|
+
/**
|
|
419
|
+
* Begin a transaction that exclusively borrows this connection until
|
|
420
|
+
* completion. See {@link Database.begin}. A connection acquired from a
|
|
421
|
+
* read handle begins read-only transactions.
|
|
422
|
+
*/
|
|
423
|
+
async begin(options) {
|
|
424
|
+
return beginOn(this.impl, options);
|
|
363
425
|
}
|
|
364
426
|
async [Symbol.asyncDispose]() {
|
|
365
427
|
await this.close();
|
|
@@ -368,9 +430,18 @@ export class Connection extends Queryable {
|
|
|
368
430
|
* Returns the connection to the database pool.
|
|
369
431
|
*/
|
|
370
432
|
async close() {
|
|
371
|
-
await this.impl.close();
|
|
433
|
+
await native(this.impl.close());
|
|
372
434
|
}
|
|
373
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* The handle of the database `name` in test mode, for each call: the current
|
|
438
|
+
* test's instance of it, or the process's own outside any test, made on
|
|
439
|
+
* first use.
|
|
440
|
+
*/
|
|
441
|
+
function testHandle(name) {
|
|
442
|
+
let own;
|
|
443
|
+
return () => currentScope()?.sqlDatabase(name) ?? (own ??= runtime.RT.sqlDatabase(name));
|
|
444
|
+
}
|
|
374
445
|
function buildQuery(strings, expr) {
|
|
375
446
|
let query = '';
|
|
376
447
|
for (let i = 0; i < strings.length; i++) {
|
|
@@ -382,7 +453,24 @@ function buildQuery(strings, expr) {
|
|
|
382
453
|
return query;
|
|
383
454
|
}
|
|
384
455
|
function buildQueryArgs(params) {
|
|
385
|
-
|
|
386
|
-
|
|
456
|
+
return new runtime.QueryArgs(params.map(p => (Array.isArray(p) ? p.map(param) : param(p))));
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* `p` as the native module takes it: null for undefined, and a
|
|
460
|
+
* `Temporal.Duration`'s ISO 8601 string, which Postgres parses as an
|
|
461
|
+
* `interval`.
|
|
462
|
+
*/
|
|
463
|
+
function param(p) {
|
|
464
|
+
if (p === undefined)
|
|
465
|
+
return null;
|
|
466
|
+
if (isTemporalDuration(p))
|
|
467
|
+
return p.toString();
|
|
468
|
+
return p;
|
|
469
|
+
}
|
|
470
|
+
/** Whether `p` is a `Temporal.Duration`, where the runtime has Temporal. */
|
|
471
|
+
function isTemporalDuration(p) {
|
|
472
|
+
return (typeof p === 'object' &&
|
|
473
|
+
p !== null &&
|
|
474
|
+
Object.prototype.toString.call(p) === '[object Temporal.Duration]');
|
|
387
475
|
}
|
|
388
476
|
//# sourceMappingURL=database.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../../storage/postgres/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../../storage/postgres/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAsElD,uDAAuD;AACvD,MAAM,iBAAiB;IAGQ;IAF7B;0DACsD;IACtD,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,2CAA2C;IAC3C,IAAc,IAAI;QAChB,OAAO,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,I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