@oliphaunt/wasix-ts 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +55 -32
- package/CHANGELOG.md +38 -0
- package/README.md +19 -387
- package/THIRD_PARTY_NOTICES.md +5 -5
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +6 -0
- package/lib/{database.d.ts → core/database.d.ts} +4 -4
- package/lib/{database.js → core/database.js} +1 -1
- package/lib/core/open-config.d.ts +5 -0
- package/lib/core/open-config.js +28 -0
- package/lib/{public.d.ts → core/public.d.ts} +3 -3
- package/lib/{public.js → core/public.js} +2 -2
- package/lib/{types.d.ts → core/types.d.ts} +19 -43
- package/lib/direct.node.d.ts +2 -2
- package/lib/direct.node.js +2 -2
- package/lib/host/index.d.mts +1 -1
- package/lib/host/index.mjs +1 -1
- package/lib/host/provenance.json +1 -1
- package/lib/host/wasmer_js_bg.wasm +0 -0
- package/lib/hosts/browser/browser-public.d.ts +8 -0
- package/lib/hosts/browser/browser-public.js +1 -0
- package/lib/{client-common.d.ts → hosts/browser/client-common.d.ts} +3 -3
- package/lib/hosts/browser/client-common.js +17 -0
- package/lib/{client.d.ts → hosts/browser/client.d.ts} +1 -1
- package/lib/{client.js → hosts/browser/client.js} +5 -3
- package/lib/{direct-client-common.d.ts → hosts/browser/direct-client-common.d.ts} +9 -8
- package/lib/{direct-client-common.js → hosts/browser/direct-client-common.js} +17 -31
- package/lib/hosts/browser/initialize.d.ts +5 -0
- package/lib/hosts/browser/initialize.js +67 -0
- package/lib/{internal-common.d.ts → hosts/browser/internal-common.d.ts} +3 -3
- package/lib/{internal-common.js → hosts/browser/internal-common.js} +3 -3
- package/lib/{tool-worker-common.d.ts → hosts/browser/tool-worker-common.d.ts} +3 -3
- package/lib/{tool-worker-common.js → hosts/browser/tool-worker-common.js} +2 -2
- package/lib/{tool-worker.js → hosts/browser/tool-worker.js} +1 -1
- package/lib/{wasix-runtime.d.ts → hosts/browser/wasix-runtime.d.ts} +3 -3
- package/lib/{wasix-runtime.js → hosts/browser/wasix-runtime.js} +41 -25
- package/lib/{worker-client.d.ts → hosts/browser/worker-client.d.ts} +1 -1
- package/lib/{worker-client.js → hosts/browser/worker-client.js} +5 -4
- package/lib/{worker.js → hosts/browser/worker.js} +2 -2
- package/lib/{direct-client.d.ts → hosts/node-api/direct-client.d.ts} +1 -1
- package/lib/{direct-client.js → hosts/node-api/direct-client.js} +1 -1
- package/lib/{native-addon.d.ts → hosts/node-api/native-addon.d.ts} +28 -6
- package/lib/{native-addon.js → hosts/node-api/native-addon.js} +4 -5
- package/lib/hosts/node-api/native-public.d.ts +8 -0
- package/lib/hosts/node-api/native-public.js +1 -0
- package/lib/{native-server.d.ts → hosts/node-api/native-server.d.ts} +1 -1
- package/lib/{native-server.js → hosts/node-api/native-server.js} +3 -2
- package/lib/{native-session.d.ts → hosts/node-api/native-session.d.ts} +14 -4
- package/lib/{native-session.js → hosts/node-api/native-session.js} +93 -108
- package/lib/{node-actor.d.ts → hosts/node-api/node-actor.d.ts} +2 -2
- package/lib/{node-actor.js → hosts/node-api/node-actor.js} +1 -1
- package/lib/{node-client-common.d.ts → hosts/node-api/node-client-common.d.ts} +3 -3
- package/lib/{node-client-common.js → hosts/node-api/node-client-common.js} +4 -4
- package/lib/{node-client.d.ts → hosts/node-api/node-client.d.ts} +1 -1
- package/lib/{node-client.js → hosts/node-api/node-client.js} +1 -1
- package/lib/{node-direct.d.ts → hosts/node-api/node-direct.d.ts} +2 -2
- package/lib/{node-direct.js → hosts/node-api/node-direct.js} +1 -1
- package/lib/{node-worker-port.d.ts → hosts/node-api/node-worker-port.d.ts} +1 -1
- package/lib/{node-worker.js → hosts/node-api/node-worker.js} +1 -1
- package/lib/{worker-node-client.d.ts → hosts/node-api/worker-node-client.d.ts} +1 -1
- package/lib/{worker-node-client.js → hosts/node-api/worker-node-client.js} +5 -18
- package/lib/index.bun.d.ts +2 -2
- package/lib/index.bun.js +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.deno.d.ts +2 -2
- package/lib/index.deno.js +2 -2
- package/lib/index.js +2 -2
- package/lib/index.node.d.ts +2 -2
- package/lib/index.node.js +2 -2
- package/lib/internal.d.ts +4 -4
- package/lib/internal.js +24 -4
- package/lib/internal.node.d.ts +4 -4
- package/lib/internal.node.js +2 -2
- package/lib/native-only.d.ts +1 -0
- package/lib/native-only.js +2 -0
- package/lib/protocol/protocol.d.ts +1 -0
- package/lib/protocol/protocol.js +1 -0
- package/lib/protocol/query.d.ts +1 -0
- package/lib/protocol/query.js +1 -0
- package/lib/{archive.d.ts → resources/archive.d.ts} +1 -1
- package/lib/{descriptor-validation.d.ts → resources/descriptor-validation.d.ts} +2 -2
- package/lib/{descriptor-validation.js → resources/descriptor-validation.js} +1 -1
- package/lib/{extension-descriptor.d.ts → resources/extension-descriptor.d.ts} +2 -2
- package/lib/{extensions.d.ts → resources/extensions.d.ts} +13 -6
- package/lib/{extensions.js → resources/extensions.js} +80 -155
- package/lib/resources/icu-descriptor.d.ts +3 -0
- package/lib/resources/icu-descriptor.js +16 -0
- package/lib/{runtime-descriptor.d.ts → resources/runtime-descriptor.d.ts} +1 -1
- package/lib/{runtime-descriptor.js → resources/runtime-descriptor.js} +1 -24
- package/lib/{tool-runtime.d.ts → resources/tool-runtime.d.ts} +8 -2
- package/lib/server.node.d.ts +1 -1
- package/lib/server.node.js +1 -1
- package/lib/{database-root.d.ts → storage/database-root.d.ts} +8 -0
- package/lib/{database-root.js → storage/database-root.js} +6 -0
- package/lib/storage/incremental-storage.d.ts +3 -3
- package/lib/storage/incremental-storage.js +2 -2
- package/lib/storage/indexed-db-provider.d.ts +2 -2
- package/lib/storage/indexed-db-provider.js +3 -3
- package/lib/storage/indexed-db.d.ts +2 -2
- package/lib/storage/indexed-db.js +1 -1
- package/lib/storage/node.d.ts +2 -2
- package/lib/storage/node.js +1 -1
- package/lib/storage/opfs-pool.d.ts +2 -2
- package/lib/storage/opfs-pool.js +4 -4
- package/lib/storage/opfs-provider.d.ts +2 -2
- package/lib/storage/opfs-provider.js +1 -1
- package/lib/storage/opfs.d.ts +2 -2
- package/lib/storage/opfs.js +1 -1
- package/lib/{physical-archive.js → storage/physical-archive.js} +4 -4
- package/lib/storage/restore-cleanup.d.ts +1 -1
- package/lib/storage/restore-cleanup.js +1 -1
- package/lib/{storage-provider.d.ts → storage/storage-provider.d.ts} +5 -11
- package/lib/{storage-provider.js → storage/storage-provider.js} +8 -13
- package/lib/{storage-snapshot.d.ts → storage/storage-snapshot.d.ts} +2 -2
- package/lib/{storage.d.ts → storage/types.d.ts} +8 -7
- package/lib/storage/web-lock.js +1 -1
- package/lib/worker-entry.bun.d.ts +2 -2
- package/lib/worker-entry.bun.js +2 -2
- package/lib/worker-entry.d.ts +2 -2
- package/lib/worker-entry.deno.d.ts +2 -2
- package/lib/worker-entry.deno.js +2 -2
- package/lib/worker-entry.js +2 -2
- package/lib/worker-entry.node.d.ts +2 -2
- package/lib/worker-entry.node.js +2 -2
- package/lib/{rpc.d.ts → workers/rpc.d.ts} +14 -34
- package/lib/{rpc.js → workers/rpc.js} +4 -4
- package/lib/{worker-dispatch.d.ts → workers/worker-dispatch.d.ts} +1 -1
- package/lib/{worker-dispatch.js → workers/worker-dispatch.js} +2 -2
- package/lib/{worker-rpc.d.ts → workers/worker-rpc.d.ts} +3 -3
- package/lib/{worker-rpc.js → workers/worker-rpc.js} +8 -12
- package/package.json +66 -30
- package/lib/client-common.js +0 -36
- package/lib/icu-descriptor.d.ts +0 -3
- package/lib/icu-descriptor.js +0 -92
- package/lib/protocol.d.ts +0 -1
- package/lib/protocol.js +0 -1
- package/lib/query.d.ts +0 -1
- package/lib/query.js +0 -1
- package/node_modules/@oliphaunt/js-core/README.md +0 -7
- package/node_modules/@oliphaunt/js-core/dist/commonjs/protocol.d.ts +0 -1
- package/node_modules/@oliphaunt/js-core/dist/commonjs/protocol.js +0 -22
- package/node_modules/@oliphaunt/js-core/dist/commonjs/query.d.ts +0 -255
- package/node_modules/@oliphaunt/js-core/dist/commonjs/query.js +0 -2068
- package/node_modules/@oliphaunt/js-core/dist/module/package.json +0 -3
- package/node_modules/@oliphaunt/js-core/dist/module/protocol.d.ts +0 -1
- package/node_modules/@oliphaunt/js-core/dist/module/protocol.js +0 -19
- package/node_modules/@oliphaunt/js-core/dist/module/query.d.ts +0 -255
- package/node_modules/@oliphaunt/js-core/dist/module/query.js +0 -2039
- package/node_modules/@oliphaunt/js-core/package.json +0 -21
- /package/lib/{errors.d.ts → core/errors.d.ts} +0 -0
- /package/lib/{errors.js → core/errors.js} +0 -0
- /package/lib/{startup-config.d.ts → core/startup-config.d.ts} +0 -0
- /package/lib/{startup-config.js → core/startup-config.js} +0 -0
- /package/lib/{types.js → core/types.js} +0 -0
- /package/lib/{tool-worker.d.ts → hosts/browser/tool-worker.d.ts} +0 -0
- /package/lib/{worker.d.ts → hosts/browser/worker.d.ts} +0 -0
- /package/lib/{host-runtime.d.ts → hosts/node-api/host-runtime.d.ts} +0 -0
- /package/lib/{host-runtime.js → hosts/node-api/host-runtime.js} +0 -0
- /package/lib/{node-worker-options.d.ts → hosts/node-api/node-worker-options.d.ts} +0 -0
- /package/lib/{node-worker-options.js → hosts/node-api/node-worker-options.js} +0 -0
- /package/lib/{node-worker-port.js → hosts/node-api/node-worker-port.js} +0 -0
- /package/lib/{node-worker.d.ts → hosts/node-api/node-worker.d.ts} +0 -0
- /package/lib/{byte-channel.d.ts → protocol/byte-channel.d.ts} +0 -0
- /package/lib/{byte-channel.js → protocol/byte-channel.js} +0 -0
- /package/lib/{pgwire-connection.d.ts → protocol/pgwire-connection.d.ts} +0 -0
- /package/lib/{pgwire-connection.js → protocol/pgwire-connection.js} +0 -0
- /package/lib/{pgwire.d.ts → protocol/pgwire.d.ts} +0 -0
- /package/lib/{pgwire.js → protocol/pgwire.js} +0 -0
- /package/lib/{archive.js → resources/archive.js} +0 -0
- /package/lib/{asset-source.d.ts → resources/asset-source.d.ts} +0 -0
- /package/lib/{asset-source.js → resources/asset-source.js} +0 -0
- /package/lib/{extension-descriptor.js → resources/extension-descriptor.js} +0 -0
- /package/lib/{tool-runtime.js → resources/tool-runtime.js} +0 -0
- /package/lib/{zstd.d.ts → resources/zstd.d.ts} +0 -0
- /package/lib/{zstd.js → resources/zstd.js} +0 -0
- /package/lib/{physical-archive.d.ts → storage/physical-archive.d.ts} +0 -0
- /package/lib/{storage-snapshot.js → storage/storage-snapshot.js} +0 -0
- /package/lib/{storage.js → storage/types.js} +0 -0
- /package/lib/{worker-transfer.d.ts → workers/worker-transfer.d.ts} +0 -0
- /package/lib/{worker-transfer.js → workers/worker-transfer.js} +0 -0
package/lib/icu-descriptor.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { requireAssetSource, requireExactObject, requireSafeRelativeAssetPath, requireSha256, requireSize, requireVersion, serializeAssetSource, } from './descriptor-validation.js';
|
|
2
|
-
const DESCRIPTOR_FIELDS = [
|
|
3
|
-
'clusterSeedArchive',
|
|
4
|
-
'clusterSeedManifest',
|
|
5
|
-
'compatibility',
|
|
6
|
-
'dataArchive',
|
|
7
|
-
'product',
|
|
8
|
-
'runtime',
|
|
9
|
-
'schema',
|
|
10
|
-
'version',
|
|
11
|
-
];
|
|
12
|
-
const COMPATIBILITY_FIELDS = [
|
|
13
|
-
'compatibilityKey',
|
|
14
|
-
'dataForm',
|
|
15
|
-
'dataTreeSha256',
|
|
16
|
-
'dataVersion',
|
|
17
|
-
'physicalFormat',
|
|
18
|
-
'postgresMajor',
|
|
19
|
-
'runtimeProduct',
|
|
20
|
-
'runtimeVersion',
|
|
21
|
-
];
|
|
22
|
-
const ARCHIVE_FIELDS = ['archive', 'sha256', 'size', 'source'];
|
|
23
|
-
const MANIFEST_FIELDS = ['sha256', 'size', 'source'];
|
|
24
|
-
/** Validate an explicitly imported ICU carrier before bytes cross a worker boundary. */
|
|
25
|
-
export function serializeWasixIcuDescriptor(value) {
|
|
26
|
-
validateWasixIcuDescriptor(value, 'WASIX ICU descriptor');
|
|
27
|
-
return {
|
|
28
|
-
schema: value.schema,
|
|
29
|
-
runtime: value.runtime,
|
|
30
|
-
product: value.product,
|
|
31
|
-
version: value.version,
|
|
32
|
-
compatibility: { ...value.compatibility },
|
|
33
|
-
dataArchive: serializeArchive(value.dataArchive),
|
|
34
|
-
clusterSeedArchive: serializeArchive(value.clusterSeedArchive),
|
|
35
|
-
clusterSeedManifest: serializeManifest(value.clusterSeedManifest),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function validateWasixIcuDescriptor(value, label) {
|
|
39
|
-
const descriptor = requireExactObject(value, DESCRIPTOR_FIELDS, label);
|
|
40
|
-
if (descriptor.schema !== 'oliphaunt-wasix-icu-v1')
|
|
41
|
-
throw new Error(`${label} has unsupported schema`);
|
|
42
|
-
if (descriptor.runtime !== 'wasix')
|
|
43
|
-
throw new Error(`${label} must target runtime 'wasix'`);
|
|
44
|
-
if (descriptor.product !== 'oliphaunt-icu')
|
|
45
|
-
throw new Error(`${label} product must be 'oliphaunt-icu'`);
|
|
46
|
-
requireVersion(descriptor.version, `${label} version`);
|
|
47
|
-
const compatibility = requireExactObject(descriptor.compatibility, COMPATIBILITY_FIELDS, `${label} compatibility`);
|
|
48
|
-
if (compatibility.runtimeProduct !== 'liboliphaunt-wasix' ||
|
|
49
|
-
compatibility.postgresMajor !== '18' ||
|
|
50
|
-
compatibility.physicalFormat !== 'wasix-pg18-v1' ||
|
|
51
|
-
compatibility.compatibilityKey !== 'wasix-pg18-datum32-v1' ||
|
|
52
|
-
compatibility.dataVersion !== '76.1' ||
|
|
53
|
-
compatibility.dataForm !== 'files-le') {
|
|
54
|
-
throw new Error(`${label} has an incompatible WASIX/ICU identity`);
|
|
55
|
-
}
|
|
56
|
-
requireVersion(compatibility.runtimeVersion, `${label} compatible runtime version`);
|
|
57
|
-
requireSha256(compatibility.dataTreeSha256, `${label} ICU data tree SHA-256`);
|
|
58
|
-
validateArchive(descriptor.dataArchive, `${label} ICU data archive`);
|
|
59
|
-
validateArchive(descriptor.clusterSeedArchive, `${label} ICU cluster seed archive`);
|
|
60
|
-
validateManifest(descriptor.clusterSeedManifest, `${label} ICU cluster seed manifest`);
|
|
61
|
-
if (descriptor.dataArchive.archive === descriptor.clusterSeedArchive.archive) {
|
|
62
|
-
throw new Error(`${label} ICU data and cluster seed archives must have distinct paths`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function validateArchive(value, label) {
|
|
66
|
-
const archive = requireExactObject(value, ARCHIVE_FIELDS, label);
|
|
67
|
-
requireSafeRelativeAssetPath(archive.archive, `${label} path`);
|
|
68
|
-
requireSha256(archive.sha256, `${label} SHA-256`);
|
|
69
|
-
const size = requireSize(archive.size, `${label} size`);
|
|
70
|
-
requireAssetSource(archive.source, `${label} source`, size);
|
|
71
|
-
}
|
|
72
|
-
function validateManifest(value, label) {
|
|
73
|
-
const manifest = requireExactObject(value, MANIFEST_FIELDS, label);
|
|
74
|
-
requireSha256(manifest.sha256, `${label} SHA-256`);
|
|
75
|
-
const size = requireSize(manifest.size, `${label} size`);
|
|
76
|
-
requireAssetSource(manifest.source, `${label} source`, size);
|
|
77
|
-
}
|
|
78
|
-
function serializeArchive(archive) {
|
|
79
|
-
return {
|
|
80
|
-
archive: archive.archive,
|
|
81
|
-
sha256: archive.sha256,
|
|
82
|
-
size: archive.size,
|
|
83
|
-
source: serializeAssetSource(archive.source),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function serializeManifest(manifest) {
|
|
87
|
-
return {
|
|
88
|
-
sha256: manifest.sha256,
|
|
89
|
-
size: manifest.size,
|
|
90
|
-
source: serializeAssetSource(manifest.source),
|
|
91
|
-
};
|
|
92
|
-
}
|
package/lib/protocol.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@oliphaunt/js-core/protocol';
|
package/lib/protocol.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@oliphaunt/js-core/protocol';
|
package/lib/query.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@oliphaunt/js-core/query';
|
package/lib/query.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@oliphaunt/js-core/query';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Shared JavaScript Core
|
|
2
|
-
|
|
3
|
-
Canonical TypeScript helpers shared by the JavaScript, React Native, and WASIX
|
|
4
|
-
TypeScript SDKs through the private `@oliphaunt/js-core` workspace package.
|
|
5
|
-
|
|
6
|
-
Moon builds its ESM and CommonJS exports once. Published SDKs bundle that
|
|
7
|
-
minimal private package so registry consumers do not need another dependency.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function simpleQuery(sql: string): Uint8Array;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.simpleQuery = simpleQuery;
|
|
4
|
-
const encoder = new TextEncoder();
|
|
5
|
-
function simpleQuery(sql) {
|
|
6
|
-
if (sql.includes('\0')) {
|
|
7
|
-
throw new Error('simple query SQL must not contain NUL bytes');
|
|
8
|
-
}
|
|
9
|
-
const body = encoder.encode(sql);
|
|
10
|
-
const packet = new Uint8Array(body.length + 6);
|
|
11
|
-
packet[0] = 'Q'.charCodeAt(0);
|
|
12
|
-
writeI32(packet, 1, body.length + 5);
|
|
13
|
-
packet.set(body, 5);
|
|
14
|
-
packet[packet.length - 1] = 0;
|
|
15
|
-
return packet;
|
|
16
|
-
}
|
|
17
|
-
function writeI32(bytes, offset, value) {
|
|
18
|
-
bytes[offset] = (value >>> 24) & 0xff;
|
|
19
|
-
bytes[offset + 1] = (value >>> 16) & 0xff;
|
|
20
|
-
bytes[offset + 2] = (value >>> 8) & 0xff;
|
|
21
|
-
bytes[offset + 3] = value & 0xff;
|
|
22
|
-
}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { simpleQuery } from './protocol.js';
|
|
2
|
-
export type QueryBinaryInput = ArrayBuffer | ArrayBufferView | Uint8Array;
|
|
3
|
-
export type ByteInput = QueryBinaryInput | ReadonlyArray<number>;
|
|
4
|
-
/** Stable PostgreSQL OIDs used by the built-in JavaScript codecs. */
|
|
5
|
-
export declare const postgresOids: Readonly<{
|
|
6
|
-
readonly bool: 16;
|
|
7
|
-
readonly bytea: 17;
|
|
8
|
-
readonly char: 18;
|
|
9
|
-
readonly name: 19;
|
|
10
|
-
readonly int8: 20;
|
|
11
|
-
readonly int2: 21;
|
|
12
|
-
readonly int4: 23;
|
|
13
|
-
readonly text: 25;
|
|
14
|
-
readonly oid: 26;
|
|
15
|
-
readonly json: 114;
|
|
16
|
-
readonly xml: 142;
|
|
17
|
-
readonly float4: 700;
|
|
18
|
-
readonly float8: 701;
|
|
19
|
-
readonly unknown: 705;
|
|
20
|
-
readonly bpchar: 1042;
|
|
21
|
-
readonly varchar: 1043;
|
|
22
|
-
readonly date: 1082;
|
|
23
|
-
readonly time: 1083;
|
|
24
|
-
readonly timestamp: 1114;
|
|
25
|
-
readonly timestamptz: 1184;
|
|
26
|
-
readonly interval: 1186;
|
|
27
|
-
readonly timetz: 1266;
|
|
28
|
-
readonly numeric: 1700;
|
|
29
|
-
readonly uuid: 2950;
|
|
30
|
-
readonly jsonb: 3802;
|
|
31
|
-
readonly boolArray: 1000;
|
|
32
|
-
readonly byteaArray: 1001;
|
|
33
|
-
readonly charArray: 1002;
|
|
34
|
-
readonly nameArray: 1003;
|
|
35
|
-
readonly int2Array: 1005;
|
|
36
|
-
readonly int4Array: 1007;
|
|
37
|
-
readonly textArray: 1009;
|
|
38
|
-
readonly bpcharArray: 1014;
|
|
39
|
-
readonly varcharArray: 1015;
|
|
40
|
-
readonly int8Array: 1016;
|
|
41
|
-
readonly float4Array: 1021;
|
|
42
|
-
readonly float8Array: 1022;
|
|
43
|
-
readonly oidArray: 1028;
|
|
44
|
-
readonly dateArray: 1182;
|
|
45
|
-
readonly timeArray: 1183;
|
|
46
|
-
readonly timestampArray: 1115;
|
|
47
|
-
readonly timestamptzArray: 1185;
|
|
48
|
-
readonly intervalArray: 1187;
|
|
49
|
-
readonly numericArray: 1231;
|
|
50
|
-
readonly timetzArray: 1270;
|
|
51
|
-
readonly jsonArray: 199;
|
|
52
|
-
readonly xmlArray: 143;
|
|
53
|
-
readonly uuidArray: 2951;
|
|
54
|
-
readonly jsonbArray: 3807;
|
|
55
|
-
}>;
|
|
56
|
-
declare const encodedQueryParameterBrand: unique symbol;
|
|
57
|
-
type EncodedQueryParameterBrand = {
|
|
58
|
-
readonly [encodedQueryParameterBrand]: true;
|
|
59
|
-
};
|
|
60
|
-
export type TextQueryParameter = Readonly<EncodedQueryParameterBrand & {
|
|
61
|
-
format: 'text';
|
|
62
|
-
value: string;
|
|
63
|
-
typeOid?: number;
|
|
64
|
-
}>;
|
|
65
|
-
export type BinaryQueryParameter = Readonly<EncodedQueryParameterBrand & {
|
|
66
|
-
format: 'binary';
|
|
67
|
-
value: QueryBinaryInput;
|
|
68
|
-
typeOid?: number;
|
|
69
|
-
}>;
|
|
70
|
-
export type NullQueryParameter = Readonly<EncodedQueryParameterBrand & {
|
|
71
|
-
format: 'null';
|
|
72
|
-
typeOid: number;
|
|
73
|
-
}>;
|
|
74
|
-
export type EncodedQueryParameter = TextQueryParameter | BinaryQueryParameter | NullQueryParameter;
|
|
75
|
-
export type QueryParam = null | string | number | bigint | boolean | Date | QueryBinaryInput | Readonly<Record<string, unknown>> | ReadonlyArray<unknown> | EncodedQueryParameter;
|
|
76
|
-
export type QueryParameterEncoder = (value: QueryParam, typeOid: number) => EncodedQueryParameter;
|
|
77
|
-
export type QueryFormat = 'text' | 'binary' | {
|
|
78
|
-
code: number;
|
|
79
|
-
kind: 'other';
|
|
80
|
-
};
|
|
81
|
-
export type QueryField = {
|
|
82
|
-
name: string;
|
|
83
|
-
tableOid: number;
|
|
84
|
-
tableAttribute: number;
|
|
85
|
-
typeOid: number;
|
|
86
|
-
typeSize: number;
|
|
87
|
-
typeModifier: number;
|
|
88
|
-
format: QueryFormat;
|
|
89
|
-
};
|
|
90
|
-
export type RawQueryRow = {
|
|
91
|
-
values: Array<Uint8Array | null>;
|
|
92
|
-
text(column: number): string | null;
|
|
93
|
-
};
|
|
94
|
-
export type PostgresNotice = {
|
|
95
|
-
severity?: string;
|
|
96
|
-
localizedSeverity?: string;
|
|
97
|
-
nonlocalizedSeverity?: string;
|
|
98
|
-
sqlstate?: string;
|
|
99
|
-
message: string;
|
|
100
|
-
detail?: string;
|
|
101
|
-
hint?: string;
|
|
102
|
-
position?: string;
|
|
103
|
-
internalPosition?: string;
|
|
104
|
-
internalQuery?: string;
|
|
105
|
-
whereText?: string;
|
|
106
|
-
schemaName?: string;
|
|
107
|
-
tableName?: string;
|
|
108
|
-
columnName?: string;
|
|
109
|
-
dataTypeName?: string;
|
|
110
|
-
constraintName?: string;
|
|
111
|
-
file?: string;
|
|
112
|
-
line?: string;
|
|
113
|
-
routine?: string;
|
|
114
|
-
fields: PostgresErrorField[];
|
|
115
|
-
};
|
|
116
|
-
export type RawQueryResult = {
|
|
117
|
-
kind: 'command' | 'rows';
|
|
118
|
-
fields: QueryField[];
|
|
119
|
-
rows: RawQueryRow[];
|
|
120
|
-
commandTag?: string;
|
|
121
|
-
rowCount: number | null;
|
|
122
|
-
notices: PostgresNotice[];
|
|
123
|
-
getText(row: number, column: string): string | null;
|
|
124
|
-
};
|
|
125
|
-
export type QueryValue = null | string | number | boolean | Uint8Array | QueryValue[] | {
|
|
126
|
-
[key: string]: unknown;
|
|
127
|
-
};
|
|
128
|
-
export type QueryObjectRow<Value = QueryValue> = Record<string, Value>;
|
|
129
|
-
export type QueryArrayRow<Value = QueryValue> = Value[];
|
|
130
|
-
export type QueryResult<Row = QueryObjectRow> = {
|
|
131
|
-
kind: 'command' | 'rows';
|
|
132
|
-
fields: QueryField[];
|
|
133
|
-
rows: Row[];
|
|
134
|
-
commandTag?: string;
|
|
135
|
-
rowCount: number | null;
|
|
136
|
-
notices: PostgresNotice[];
|
|
137
|
-
};
|
|
138
|
-
export type QueryValueDecoder<Value = unknown> = (value: string, field: QueryField) => Value;
|
|
139
|
-
export type QueryDecoderMap = Readonly<Record<number, QueryValueDecoder>>;
|
|
140
|
-
export type QueryRowMode = 'object' | 'array';
|
|
141
|
-
export type QueryOptions<RowMode extends QueryRowMode = QueryRowMode, Decoders extends QueryDecoderMap | undefined = QueryDecoderMap | undefined> = Readonly<{
|
|
142
|
-
rowMode?: RowMode;
|
|
143
|
-
valueMode?: 'decoded' | 'text';
|
|
144
|
-
decoders?: Decoders;
|
|
145
|
-
encoders?: Readonly<Record<number, QueryParameterEncoder>>;
|
|
146
|
-
}>;
|
|
147
|
-
type QueryModeFromOptions<Options> = Options extends {
|
|
148
|
-
readonly rowMode?: infer Mode;
|
|
149
|
-
} ? Extract<Mode, QueryRowMode> extends never ? 'object' : Extract<Mode, QueryRowMode> : 'object';
|
|
150
|
-
type QueryDecoderOutput<Options> = Options extends {
|
|
151
|
-
readonly decoders?: infer Decoders;
|
|
152
|
-
} ? Decoders extends QueryDecoderMap ? Decoders[keyof Decoders] extends QueryValueDecoder<infer Value> ? Value : never : never : never;
|
|
153
|
-
type QueryRowForMode<Mode extends QueryRowMode, Value> = Mode extends 'array' ? QueryArrayRow<Value> : QueryObjectRow<Value>;
|
|
154
|
-
/** Infer the runtime row shape from `rowMode` and custom decoder return types. */
|
|
155
|
-
export type InferQueryRow<Options, ExplicitRow = never> = [ExplicitRow] extends [never] ? QueryRowForMode<QueryModeFromOptions<Options>, QueryValue | QueryDecoderOutput<Options>> : ExplicitRow;
|
|
156
|
-
export type ParameterOptions = Readonly<{
|
|
157
|
-
encoders?: Readonly<Record<number, QueryParameterEncoder>>;
|
|
158
|
-
}>;
|
|
159
|
-
export type CommandResult = {
|
|
160
|
-
commandTag?: string;
|
|
161
|
-
rowCount: number | null;
|
|
162
|
-
notices: PostgresNotice[];
|
|
163
|
-
};
|
|
164
|
-
export type ExecResult<Row = QueryObjectRow> = {
|
|
165
|
-
statements: QueryResult<Row>[];
|
|
166
|
-
notices: PostgresNotice[];
|
|
167
|
-
};
|
|
168
|
-
export type DescribeResult = {
|
|
169
|
-
parameterTypeOids: number[];
|
|
170
|
-
fields?: QueryField[];
|
|
171
|
-
notices: PostgresNotice[];
|
|
172
|
-
};
|
|
173
|
-
export type TransactionStatus = 'idle' | 'transaction' | 'failed';
|
|
174
|
-
export { simpleQuery };
|
|
175
|
-
export type PostgresErrorField = {
|
|
176
|
-
code: number;
|
|
177
|
-
value: string;
|
|
178
|
-
};
|
|
179
|
-
export declare class PostgresError extends Error {
|
|
180
|
-
readonly severity?: string;
|
|
181
|
-
readonly localizedSeverity?: string;
|
|
182
|
-
readonly nonlocalizedSeverity?: string;
|
|
183
|
-
readonly sqlstate?: string;
|
|
184
|
-
readonly detail?: string;
|
|
185
|
-
readonly hint?: string;
|
|
186
|
-
readonly position?: string;
|
|
187
|
-
readonly internalPosition?: string;
|
|
188
|
-
readonly internalQuery?: string;
|
|
189
|
-
readonly whereText?: string;
|
|
190
|
-
readonly schemaName?: string;
|
|
191
|
-
readonly tableName?: string;
|
|
192
|
-
readonly columnName?: string;
|
|
193
|
-
readonly dataTypeName?: string;
|
|
194
|
-
readonly constraintName?: string;
|
|
195
|
-
readonly file?: string;
|
|
196
|
-
readonly line?: string;
|
|
197
|
-
readonly routine?: string;
|
|
198
|
-
readonly fields: PostgresErrorField[];
|
|
199
|
-
readonly notices: PostgresNotice[];
|
|
200
|
-
constructor(fields: PostgresErrorField[], notices?: PostgresNotice[]);
|
|
201
|
-
}
|
|
202
|
-
/** @internal Preserve query-scoped notices on caller codec failures. */
|
|
203
|
-
export declare function errorWithNotices(error: unknown, notices: ReadonlyArray<PostgresNotice>): unknown;
|
|
204
|
-
export declare function text(value: string | number | bigint | boolean | Date, typeOid?: number): TextQueryParameter;
|
|
205
|
-
export declare function binary(value: QueryBinaryInput, typeOid?: number): BinaryQueryParameter;
|
|
206
|
-
export declare function typedNull(typeOid: number): NullQueryParameter;
|
|
207
|
-
export declare function json(value: unknown, typeOid?: number): TextQueryParameter;
|
|
208
|
-
export declare function array(values: ReadonlyArray<unknown>, typeOid?: number): TextQueryParameter;
|
|
209
|
-
export type QueryPlan = Readonly<{
|
|
210
|
-
kind: 'complete';
|
|
211
|
-
input: Uint8Array;
|
|
212
|
-
}> | Readonly<{
|
|
213
|
-
kind: 'describe';
|
|
214
|
-
input: Uint8Array;
|
|
215
|
-
bind(parameterTypeOids: ReadonlyArray<number>): Uint8Array;
|
|
216
|
-
}>;
|
|
217
|
-
export declare function planQuery(sql: string, parameters?: ReadonlyArray<QueryParam>, options?: ParameterOptions): QueryPlan;
|
|
218
|
-
/** Encode a one-exchange query. Untyped values require planQuery() instead. */
|
|
219
|
-
export declare function extendedQuery(sql: string, parameters: ReadonlyArray<QueryParam>, options?: ParameterOptions): Uint8Array;
|
|
220
|
-
export declare function describeQuery(sql: string, parameterTypeOids?: ReadonlyArray<number>): Uint8Array;
|
|
221
|
-
export declare function responseTransactionStatus(value: object): TransactionStatus | undefined;
|
|
222
|
-
/**
|
|
223
|
-
* Validate the complete backend framing and return the one terminal
|
|
224
|
-
* ReadyForQuery status without interpreting result values.
|
|
225
|
-
*
|
|
226
|
-
* Structured clients call this immediately after transport completion so a
|
|
227
|
-
* custom decoder or higher-level result assertion cannot obscure whether the
|
|
228
|
-
* physical PostgreSQL session reached a reusable boundary.
|
|
229
|
-
*/
|
|
230
|
-
export declare function inspectReadyForQuery(bytes: Uint8Array): TransactionStatus;
|
|
231
|
-
/**
|
|
232
|
-
* Validate a structured callback-transaction response before high-level
|
|
233
|
-
* parsing can discard earlier command tags after a later ErrorResponse.
|
|
234
|
-
*/
|
|
235
|
-
export declare function inspectManagedTransactionResponse(bytes: Uint8Array): TransactionStatus;
|
|
236
|
-
export declare function parseQueryRawResponse(bytes: Uint8Array): RawQueryResult;
|
|
237
|
-
export declare function parseSimpleQueryRawResponse(bytes: Uint8Array): RawQueryResult;
|
|
238
|
-
export declare function decodeQueryResult<Row = never, const Options extends QueryOptions = {}>(raw: RawQueryResult, options?: Options & QueryOptions): QueryResult<InferQueryRow<Options, Row>>;
|
|
239
|
-
export declare function parseExecResponse<Row = never, const Options extends Omit<QueryOptions, 'encoders'> = {}>(bytes: Uint8Array, options?: Options & Omit<QueryOptions, 'encoders'>): ExecResult<InferQueryRow<Options, Row>>;
|
|
240
|
-
export declare function parseCommandResponse(bytes: Uint8Array): CommandResult;
|
|
241
|
-
export declare function parseDescribeResponse(bytes: Uint8Array): DescribeResult;
|
|
242
|
-
export declare function assertSuccessfulQueryResponse(bytes: Uint8Array): void;
|
|
243
|
-
export declare function assertNoTopLevelCopy(sql: string): void;
|
|
244
|
-
/**
|
|
245
|
-
* Reject transaction commands whose response boundary cannot prove that the
|
|
246
|
-
* callback still owns the transaction it started. PostgreSQL reports both
|
|
247
|
-
* `ROLLBACK TO SAVEPOINT` and `ROLLBACK AND CHAIN` as command tag `ROLLBACK`
|
|
248
|
-
* with ReadyForQuery status `transaction`, so the latter must be rejected
|
|
249
|
-
* before execution rather than inferred from the backend response.
|
|
250
|
-
*/
|
|
251
|
-
export declare function assertNoTransactionChain(sql: string): void;
|
|
252
|
-
export declare function structuredSimpleQuery(sql: string): Uint8Array;
|
|
253
|
-
export declare function containsTopLevelCopy(sql: string): boolean;
|
|
254
|
-
export declare function containsTransactionChain(sql: string): boolean;
|
|
255
|
-
export declare function toUint8Array(input: ByteInput): Uint8Array;
|