@terrascale/sdk 0.0.0-stage → 0.0.2

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/LICENSE +202 -0
  3. package/README.md +202 -2
  4. package/package.json +152 -4
  5. package/sdk-v1-route-manifest.json +2330 -0
  6. package/src/admin.js +9 -0
  7. package/src/better-auth.js +14 -0
  8. package/src/config.js +121 -0
  9. package/src/database-codec.js +845 -0
  10. package/src/database-types.js +237 -0
  11. package/src/database-view.js +423 -0
  12. package/src/database.js +2 -0
  13. package/src/http.js +898 -0
  14. package/src/index.js +62 -0
  15. package/src/local/authentication.js +47 -0
  16. package/src/local/better-auth.js +517 -0
  17. package/src/local/cli.js +51 -0
  18. package/src/local/context.js +23 -0
  19. package/src/local/environment.js +109 -0
  20. package/src/local/index.js +206 -0
  21. package/src/local/legacy-client.js +411 -0
  22. package/src/local/router.js +999 -0
  23. package/src/local/server.js +664 -0
  24. package/src/local/store.js +530 -0
  25. package/src/local/test-environment.js +74 -0
  26. package/src/management-contracts.js +72 -0
  27. package/src/management.js +12 -0
  28. package/src/native-origin.js +75 -0
  29. package/src/postgres.js +496 -0
  30. package/src/react/core.js +743 -0
  31. package/src/react/index.js +99 -0
  32. package/src/result.js +251 -0
  33. package/src/schema.js +366 -0
  34. package/src/sql.js +996 -0
  35. package/src/svelte/index.js +129 -0
  36. package/src/tanstack/index.js +512 -0
  37. package/src/ts-auth-discovery.js +207 -0
  38. package/src/ts-auth.js +3498 -0
  39. package/src/v1/decode.js +118 -0
  40. package/src/v1/errors.js +185 -0
  41. package/src/v1/filter.js +230 -0
  42. package/src/v1/ids.js +119 -0
  43. package/src/v1/json.js +335 -0
  44. package/src/v1/routes.js +57 -0
  45. package/src/v1/shapes.js +145 -0
  46. package/src/v1/terrabase-v1.js +722 -0
  47. package/src/v1/transport.js +324 -0
  48. package/types/admin.d.ts +6 -0
  49. package/types/better-auth.d.ts +8 -0
  50. package/types/config.d.ts +58 -0
  51. package/types/database-codec.d.ts +111 -0
  52. package/types/database-types.d.ts +213 -0
  53. package/types/database-view.d.ts +184 -0
  54. package/types/database.d.ts +2 -0
  55. package/types/http.d.ts +47 -0
  56. package/types/index.d.ts +43 -0
  57. package/types/local/authentication.d.ts +11 -0
  58. package/types/local/better-auth.d.ts +33 -0
  59. package/types/local/cli.d.ts +2 -0
  60. package/types/local/context.d.ts +14 -0
  61. package/types/local/environment.d.ts +23 -0
  62. package/types/local/index.d.ts +96 -0
  63. package/types/local/legacy-client.d.ts +94 -0
  64. package/types/local/router.d.ts +66 -0
  65. package/types/local/server.d.ts +54 -0
  66. package/types/local/store.d.ts +106 -0
  67. package/types/local/test-environment.d.ts +25 -0
  68. package/types/management-contracts.d.ts +44 -0
  69. package/types/management.d.ts +6 -0
  70. package/types/native-origin.d.ts +23 -0
  71. package/types/postgres.d.ts +124 -0
  72. package/types/react/core.d.ts +366 -0
  73. package/types/react/index.d.ts +54 -0
  74. package/types/result.d.ts +161 -0
  75. package/types/schema.d.ts +145 -0
  76. package/types/sql.d.ts +288 -0
  77. package/types/svelte/index.d.ts +81 -0
  78. package/types/tanstack/index.d.ts +166 -0
  79. package/types/ts-auth-discovery.d.ts +19 -0
  80. package/types/ts-auth.d.ts +1826 -0
  81. package/types/v1/decode.d.ts +119 -0
  82. package/types/v1/errors.d.ts +107 -0
  83. package/types/v1/filter.d.ts +148 -0
  84. package/types/v1/ids.d.ts +44 -0
  85. package/types/v1/json.d.ts +92 -0
  86. package/types/v1/routes.d.ts +26 -0
  87. package/types/v1/shapes.d.ts +78 -0
  88. package/types/v1/terrabase-v1.d.ts +374 -0
  89. package/types/v1/transport.d.ts +117 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @param {TerraBaseClientConfig} config
3
+ * @returns {TerraBaseClient}
4
+ */
5
+ export function createTerraBaseClient(config: TerraBaseClientConfig): TerraBaseClient;
6
+ /** Current scoped document client. All mutations are server commits in one declared shard. */
7
+ export class TerraBaseClient {
8
+ /** @param {TerraBaseClientConfig} config */
9
+ constructor(config: TerraBaseClientConfig);
10
+ /** @returns {DatabaseScope} */
11
+ get scope(): DatabaseScope;
12
+ /**
13
+ * @param {string} collection
14
+ * @param {string} document
15
+ * @param {DatabaseRequestOptions} [options]
16
+ * @returns {Promise<DatabaseResult<DatabasePoint>>}
17
+ */
18
+ read(collection: string, document: string, options?: DatabaseRequestOptions): Promise<DatabaseResult<DatabasePoint>>;
19
+ /**
20
+ * @param {string} collection
21
+ * @param {DatabaseQuery} query
22
+ * @param {DatabaseRequestOptions} [options]
23
+ * @returns {Promise<DatabaseResult<DatabaseQueryPage>>}
24
+ */
25
+ query(collection: string, query: DatabaseQuery, options?: DatabaseRequestOptions): Promise<DatabaseResult<DatabaseQueryPage>>;
26
+ /**
27
+ * @param {string} collection
28
+ * @param {DatabaseSubscriptionRequest} request
29
+ * @param {DatabaseRequestOptions} [options]
30
+ * @returns {Promise<DatabaseResult<DatabaseSubscriptionResponse>>}
31
+ */
32
+ subscription(collection: string, request: DatabaseSubscriptionRequest, options?: DatabaseRequestOptions): Promise<DatabaseResult<DatabaseSubscriptionResponse>>;
33
+ /**
34
+ * Prepare once and retain this identity for exact retry and durable status resolution.
35
+ * @param {DatabaseCommit} commit
36
+ * @returns {Promise<PreparedDatabaseCommit>}
37
+ */
38
+ prepareCommit(commit: DatabaseCommit): Promise<PreparedDatabaseCommit>;
39
+ /**
40
+ * @param {PreparedDatabaseCommit} prepared
41
+ * @param {DatabaseRequestOptions} [options]
42
+ * @returns {Promise<DatabaseResult<DatabaseCommitReceipt>>}
43
+ */
44
+ commit(prepared: PreparedDatabaseCommit, options?: DatabaseRequestOptions): Promise<DatabaseResult<DatabaseCommitReceipt>>;
45
+ /**
46
+ * Unknown, pending and expired outcomes remain unresolved; an absent document proves no abort.
47
+ * @param {DatabaseTransactionIdentity} identity
48
+ * @param {DatabaseRequestOptions} [options]
49
+ * @returns {Promise<DatabaseResult<DatabaseTransactionStatus>>}
50
+ */
51
+ transactionStatus(identity: DatabaseTransactionIdentity, options?: DatabaseRequestOptions): Promise<DatabaseResult<DatabaseTransactionStatus>>;
52
+ #private;
53
+ }
54
+ /**
55
+ * Internal options for the deprecated local emulator. Remote origins are refused.
56
+ */
57
+ export type TerraBaseClientConfig = DatabaseScope & {
58
+ readonly apiKey: string | (() => string | Promise<string>);
59
+ readonly endpoint?: string;
60
+ readonly discoveryTimeoutMs?: number;
61
+ readonly requestTimeoutMs?: number;
62
+ readonly fetch?: FetchLike;
63
+ };
64
+ export type DatabaseRequestOptions = {
65
+ readonly signal?: AbortSignal;
66
+ };
67
+ export type PreparedDatabaseCommit = DatabaseTransactionIdentity & {
68
+ readonly [preparedBrand]: true;
69
+ };
70
+ import type { DatabaseScope } from "../database-types.js";
71
+ import type { DatabasePoint } from "../database-types.js";
72
+ import type { DatabaseResult } from "../database-types.js";
73
+ import type { DatabaseQuery } from "../database-types.js";
74
+ import type { DatabaseQueryPage } from "../database-types.js";
75
+ import type { DatabaseSubscriptionRequest } from "../database-types.js";
76
+ import type { DatabaseSubscriptionResponse } from "../database-types.js";
77
+ import type { DatabaseCommit } from "../database-types.js";
78
+ import type { DatabaseCommitReceipt } from "../database-types.js";
79
+ import type { DatabaseTransactionIdentity } from "../database-types.js";
80
+ import type { DatabaseTransactionStatus } from "../database-types.js";
81
+ import type { FetchLike } from "../config.js";
82
+ /**
83
+ * Internal options for the deprecated local emulator. Remote origins are refused.
84
+ * @typedef {DatabaseScope & {
85
+ * readonly apiKey: string | (() => string | Promise<string>);
86
+ * readonly endpoint?: string;
87
+ * readonly discoveryTimeoutMs?: number;
88
+ * readonly requestTimeoutMs?: number;
89
+ * readonly fetch?: FetchLike;
90
+ * }} TerraBaseClientConfig
91
+ */
92
+ /** @typedef {{ readonly signal?: AbortSignal }} DatabaseRequestOptions */
93
+ declare const preparedBrand: unique symbol;
94
+ export {};
@@ -0,0 +1,66 @@
1
+ /** Development implementation of the admitted native grammar, never producer qualification. */
2
+ export class TerraScaleLocalRouter {
3
+ /**
4
+ * @param {TerraScaleSqliteStore} store
5
+ * @param {DatabaseScope} scope
6
+ * @param {{
7
+ * readonly authentication: LocalAuthenticationMode;
8
+ * readonly bearerToken?: string;
9
+ * }} options
10
+ */
11
+ constructor(store: TerraScaleSqliteStore, scope: DatabaseScope, options: {
12
+ readonly authentication: LocalAuthenticationMode;
13
+ readonly bearerToken?: string;
14
+ });
15
+ get authority(): Readonly<{
16
+ mode: "single_writer";
17
+ generation: 1n;
18
+ writer: {
19
+ readonly replica: string;
20
+ readonly incarnation: string;
21
+ };
22
+ }>;
23
+ /**
24
+ * @param {CollectionBinding} binding
25
+ * @returns {void}
26
+ */
27
+ bindCollection(binding: CollectionBinding): void;
28
+ /**
29
+ * @readonly
30
+ * @type {FetchLike}
31
+ */
32
+ readonly fetch: FetchLike;
33
+ /**
34
+ * @param {Request} request
35
+ * @returns {Promise<Response>}
36
+ */
37
+ handle(request: Request): Promise<Response>;
38
+ #private;
39
+ }
40
+ export type JsonObject = Record<string, unknown>;
41
+ export type WirePoint = JsonObject;
42
+ export type Change = {
43
+ readonly sequence: string;
44
+ readonly entries: readonly {
45
+ readonly collection: string;
46
+ readonly document: string;
47
+ readonly before: WirePoint;
48
+ readonly after: WirePoint;
49
+ }[];
50
+ };
51
+ export type Snapshot = {
52
+ readonly route: string;
53
+ readonly predicate: string;
54
+ readonly limit: number;
55
+ readonly sequence: string;
56
+ readonly rows: readonly {
57
+ readonly document: string;
58
+ readonly point: WirePoint;
59
+ }[];
60
+ readonly expires: number;
61
+ };
62
+ import type { CollectionBinding } from "../database-types.js";
63
+ import type { FetchLike } from "../config.js";
64
+ import type { TerraScaleSqliteStore } from "./store.js";
65
+ import type { DatabaseScope } from "../database-types.js";
66
+ import type { LocalAuthenticationMode } from "./context.js";
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The local HTTP endpoint exposed by a running server.
3
+ *
4
+ * @typedef {Readonly<{
5
+ * readonly origin: string;
6
+ * readonly host: string;
7
+ * readonly port: number;
8
+ * }>} LocalServerAddress
9
+ */
10
+ /** @typedef {(request: Request) => Promise<Response>} LocalRequestHandler */
11
+ /** @typedef {Readonly<{ host?: string; port?: number }>} StartOptions */
12
+ /** @typedef {boolean | Readonly<{ allowRemote?: boolean }>} ConstructorOptions */
13
+ /** @typedef {ReturnType<typeof createServer>} ServerLike */
14
+ /**
15
+ * A small Node-only bridge for handlers that speak the Fetch API.
16
+ *
17
+ * The handler is deliberately the sole routing authority. In particular, this
18
+ * adapter does not reserve a health route (or any other private route).
19
+ */
20
+ export class TerraScaleLocalHttpServer {
21
+ /**
22
+ * @param {LocalRequestHandler} handler
23
+ * @param {ConstructorOptions} [options]
24
+ */
25
+ constructor(handler: LocalRequestHandler, options?: ConstructorOptions);
26
+ /** @returns {LocalServerAddress | undefined} */
27
+ get address(): LocalServerAddress | undefined;
28
+ /**
29
+ * @param {StartOptions} [options]
30
+ * @returns {Promise<LocalServerAddress>}
31
+ */
32
+ start(options?: StartOptions): Promise<LocalServerAddress>;
33
+ /** @returns {Promise<void>} */
34
+ close(): Promise<void>;
35
+ #private;
36
+ }
37
+ /**
38
+ * The local HTTP endpoint exposed by a running server.
39
+ */
40
+ export type LocalServerAddress = Readonly<{
41
+ readonly origin: string;
42
+ readonly host: string;
43
+ readonly port: number;
44
+ }>;
45
+ export type LocalRequestHandler = (request: Request) => Promise<Response>;
46
+ export type StartOptions = Readonly<{
47
+ host?: string;
48
+ port?: number;
49
+ }>;
50
+ export type ConstructorOptions = boolean | Readonly<{
51
+ allowRemote?: boolean;
52
+ }>;
53
+ export type ServerLike = ReturnType<typeof createServer>;
54
+ import { createServer } from "node:http";
@@ -0,0 +1,106 @@
1
+ /**
2
+ * A small synchronous JSON record store for Node local adapters.
3
+ *
4
+ * This module intentionally imports node:sqlite and must not be used from a
5
+ * browser bundle. The database handle is kept private so consumers cannot
6
+ * bypass the store's serialization and transaction invariants.
7
+ */
8
+ export class TerraScaleSqliteStore {
9
+ /**
10
+ * @param {string} databasePath
11
+ */
12
+ constructor(databasePath: string);
13
+ /**
14
+ * @readonly
15
+ * @type {string}
16
+ */
17
+ readonly databasePath: string;
18
+ /** @returns {void} */
19
+ close(): void;
20
+ /** @returns {void} */
21
+ reset(): void;
22
+ /**
23
+ * @template T
24
+ * @param {string} namespace
25
+ * @param {string} scope
26
+ * @param {string} id
27
+ * @returns {T | undefined}
28
+ */
29
+ get<T>(namespace: string, scope: string, id: string): T | undefined;
30
+ /**
31
+ * @template T
32
+ * @param {string} namespace
33
+ * @param {string} scope
34
+ * @returns {T[]}
35
+ */
36
+ list<T>(namespace: string, scope: string): T[];
37
+ /**
38
+ * @template T
39
+ * @param {string} namespace
40
+ * @returns {readonly {
41
+ * readonly scope: string;
42
+ * readonly id: string;
43
+ * readonly value: T;
44
+ * }[]}
45
+ */
46
+ listNamespace<T>(namespace: string): readonly {
47
+ readonly scope: string;
48
+ readonly id: string;
49
+ readonly value: T;
50
+ }[];
51
+ /**
52
+ * @template T
53
+ * @param {string} namespace
54
+ * @param {string} scope
55
+ * @param {string} id
56
+ * @param {T} value
57
+ * @returns {void}
58
+ */
59
+ put<T>(namespace: string, scope: string, id: string, value: T): void;
60
+ /**
61
+ * @param {string} namespace
62
+ * @param {string} scope
63
+ * @param {string} id
64
+ * @returns {boolean}
65
+ */
66
+ delete(namespace: string, scope: string, id: string): boolean;
67
+ /**
68
+ * @param {string} namespace
69
+ * @returns {void}
70
+ */
71
+ clearNamespace(namespace: string): void;
72
+ /**
73
+ * @template T
74
+ * @param {string} key
75
+ * @returns {T | undefined}
76
+ */
77
+ getMeta<T>(key: string): T | undefined;
78
+ /**
79
+ * @template T
80
+ * @param {string} key
81
+ * @param {T} value
82
+ * @returns {void}
83
+ */
84
+ setMeta<T>(key: string, value: T): void;
85
+ /**
86
+ * Serialize local native requests and async auth callbacks on this connection.
87
+ *
88
+ * @template T
89
+ * @param {() => Promise<T> | T} work
90
+ * @returns {Promise<T>}
91
+ */
92
+ exclusive<T>(work: () => Promise<T> | T): Promise<T>;
93
+ /**
94
+ * @template T
95
+ * @param {() => Promise<T>} work
96
+ * @returns {Promise<T>}
97
+ */
98
+ transactionAsync<T>(work: () => Promise<T>): Promise<T>;
99
+ /**
100
+ * @template T
101
+ * @param {() => T} work
102
+ * @returns {T}
103
+ */
104
+ transaction<T>(work: () => T): T;
105
+ #private;
106
+ }
@@ -0,0 +1,25 @@
1
+ /** @import { TerraScaleSqliteRuntimeOptions } from "./index.js" */
2
+ /** @import { DatabaseCommit, DatabaseField, DatabasePoint } from "../database-types.js" */
3
+ /**
4
+ * @param {Omit<TerraScaleSqliteRuntimeOptions, "sqlite">} [options]
5
+ */
6
+ export function localFixture(options?: Omit<TerraScaleSqliteRuntimeOptions, "sqlite">): Promise<{
7
+ runtime: import("./index.js").TerraScaleSqliteRuntime;
8
+ client: import("./legacy-client.js").TerraBaseClient;
9
+ collection: `${string}-${string}-${string}-${string}-${string}`;
10
+ binding: {
11
+ collection: `${string}-${string}-${string}-${string}-${string}`;
12
+ schema_generation: bigint;
13
+ schema_digest: string;
14
+ };
15
+ directory: string;
16
+ databasePath: string;
17
+ commit: (document: string, fields: readonly DatabaseField[], point?: DatabasePoint) => DatabaseCommit;
18
+ close: () => Promise<void>;
19
+ }>;
20
+ /** Local development tests never relax CI/deployment/qualification guards. */
21
+ export const localSqliteUnitTestsAllowed: boolean;
22
+ import type { TerraScaleSqliteRuntimeOptions } from "./index.js";
23
+ import type { DatabaseField } from "../database-types.js";
24
+ import type { DatabasePoint } from "../database-types.js";
25
+ import type { DatabaseCommit } from "../database-types.js";
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @param {TerraScaleBlockedCapability} capability
3
+ * @returns {never}
4
+ */
5
+ export function requireTerraScaleCapability(capability: TerraScaleBlockedCapability): never;
6
+ /** Required capabilities whose producer/runtime admission is still open. */
7
+ export const terraScaleReleaseBlockers: Readonly<{
8
+ management: Readonly<{
9
+ code: "management_contract_unavailable";
10
+ owner: "C06/C07 regional management service";
11
+ required: readonly string[];
12
+ }>;
13
+ betterAuth: Readonly<{
14
+ code: "security_authority_unavailable";
15
+ owner: "native single-writer security admission and C06/C07";
16
+ required: readonly string[];
17
+ }>;
18
+ qualification: Readonly<{
19
+ code: "runtime_qualification_unavailable";
20
+ owner: "real producer allocation and deployed customer application";
21
+ required: readonly string[];
22
+ }>;
23
+ }>;
24
+ /** @typedef {keyof typeof terraScaleReleaseBlockers} TerraScaleBlockedCapability */
25
+ export class TerraScaleCapabilityUnavailableError extends Error {
26
+ /** @param {TerraScaleBlockedCapability} capability */
27
+ constructor(capability: TerraScaleBlockedCapability);
28
+ /**
29
+ * @readonly
30
+ * @type {string}
31
+ */
32
+ readonly code: string;
33
+ /**
34
+ * @readonly
35
+ * @type {TerraScaleBlockedCapability}
36
+ */
37
+ readonly capability: TerraScaleBlockedCapability;
38
+ /**
39
+ * @readonly
40
+ * @type {readonly string[]}
41
+ */
42
+ readonly required: readonly string[];
43
+ }
44
+ export type TerraScaleBlockedCapability = keyof typeof terraScaleReleaseBlockers;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Required public management support remains closed until C06/C07 route admission.
3
+ * @returns {never}
4
+ */
5
+ export function requireTerraScaleManagement(): never;
6
+ export { terraScaleReleaseBlockers, TerraScaleCapabilityUnavailableError } from "./management-contracts.js";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @param {unknown} value
3
+ * @returns {string}
4
+ */
5
+ export function requireNativeRegion(value: unknown): string;
6
+ /**
7
+ * @param {unknown} code
8
+ * @returns {string}
9
+ */
10
+ export function nativeRegionalOrigin(code: unknown): string;
11
+ /**
12
+ * Hosted identity refuses database API origins, without using native admission.
13
+ * @param {string} hostname
14
+ * @returns {boolean}
15
+ */
16
+ export function isDataApiHostname(hostname: string): boolean;
17
+ /**
18
+ * @param {string} raw
19
+ * @returns {string}
20
+ */
21
+ export function nativeServiceOrigin(raw: string): string;
22
+ /** Internal admission policy shared by native clients and qualification configuration. */
23
+ export const terraScaleServiceDomain: "terrascale.tech";
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Validate and clone a builder descriptor without converting or interpolating values.
3
+ *
4
+ * @param {string} statement
5
+ * @param {readonly unknown[]} [parameters]
6
+ * @returns {PostgresBoundQuery}
7
+ */
8
+ export function postgresQuery(statement: string, parameters?: readonly unknown[]): PostgresBoundQuery;
9
+ /** @typedef {bigint | string} PostgresParameter */
10
+ /**
11
+ * @typedef {{
12
+ * readonly statement: string;
13
+ * readonly parameters: readonly unknown[];
14
+ * }} PostgresQuery
15
+ */
16
+ /**
17
+ * @typedef {{
18
+ * readonly statement: string;
19
+ * readonly parameters: readonly PostgresParameter[];
20
+ * }} PostgresBoundQuery
21
+ */
22
+ /**
23
+ * @typedef {{
24
+ * readonly host: string;
25
+ * readonly port: number;
26
+ * readonly tlsServerName: string;
27
+ * readonly caCertificatePem: string;
28
+ * readonly database: string;
29
+ * readonly keyId: string;
30
+ * readonly password: string;
31
+ * readonly connectTimeoutMs?: number;
32
+ * }} PostgresConfig
33
+ */
34
+ /**
35
+ * @typedef {{
36
+ * readonly name: string;
37
+ * readonly oid: 20 | 25;
38
+ * }} PostgresColumn
39
+ */
40
+ /**
41
+ * @typedef {{
42
+ * readonly command: string;
43
+ * readonly affectedRows: number;
44
+ * readonly columns: readonly PostgresColumn[];
45
+ * readonly rows: readonly (readonly PostgresParameter[])[];
46
+ * }} PostgresResult
47
+ */
48
+ /** Diagnostics retain SQLSTATE, but never driver messages, SQL or passwords. */
49
+ export class PostgresError extends Error {
50
+ /**
51
+ * @param {"configuration" | "query" | "connection" | "database" | "protocol"} kind
52
+ * @param {string} [sqlState]
53
+ */
54
+ constructor(kind: "configuration" | "query" | "connection" | "database" | "protocol", sqlState?: string);
55
+ /**
56
+ * @override
57
+ * @readonly
58
+ */
59
+ override readonly name: "PostgresError";
60
+ /**
61
+ * @readonly
62
+ * @type {"configuration" | "query" | "connection" | "database" | "protocol"}
63
+ */
64
+ readonly kind: "configuration" | "query" | "connection" | "database" | "protocol";
65
+ /**
66
+ * @readonly
67
+ * @type {string | undefined}
68
+ */
69
+ readonly sqlState: string | undefined;
70
+ }
71
+ /** One driver connection; no automatic reconnect, mutation retry or callback replay. */
72
+ /** @deprecated The C# TerraBase has no PostgreSQL listener. */
73
+ export class PostgresClient {
74
+ /**
75
+ * @param {PostgresConfig} input
76
+ * @returns {Promise<PostgresClient>}
77
+ */
78
+ static connect(input: PostgresConfig): Promise<PostgresClient>;
79
+ /**
80
+ * @private
81
+ * @param {DriverClient} driver
82
+ * @param {typeof DatabaseError} databaseError
83
+ */
84
+ private constructor();
85
+ /**
86
+ * @param {PostgresQuery} input
87
+ * @returns {Promise<PostgresResult>}
88
+ */
89
+ query(input: PostgresQuery): Promise<PostgresResult>;
90
+ /**
91
+ * @returns {Promise<void>}
92
+ */
93
+ close(): Promise<void>;
94
+ #private;
95
+ }
96
+ export type PostgresParameter = bigint | string;
97
+ export type PostgresQuery = {
98
+ readonly statement: string;
99
+ readonly parameters: readonly unknown[];
100
+ };
101
+ export type PostgresBoundQuery = {
102
+ readonly statement: string;
103
+ readonly parameters: readonly PostgresParameter[];
104
+ };
105
+ export type PostgresConfig = {
106
+ readonly host: string;
107
+ readonly port: number;
108
+ readonly tlsServerName: string;
109
+ readonly caCertificatePem: string;
110
+ readonly database: string;
111
+ readonly keyId: string;
112
+ readonly password: string;
113
+ readonly connectTimeoutMs?: number;
114
+ };
115
+ export type PostgresColumn = {
116
+ readonly name: string;
117
+ readonly oid: 20 | 25;
118
+ };
119
+ export type PostgresResult = {
120
+ readonly command: string;
121
+ readonly affectedRows: number;
122
+ readonly columns: readonly PostgresColumn[];
123
+ readonly rows: readonly (readonly PostgresParameter[])[];
124
+ };