@pgxsinkit/pgwasm 0.6.0 → 0.6.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.
- package/README.md +8 -0
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/seam.d.ts.map +1 -1
- package/dist/{chunk-jnmd6w7f.js → chunk-4eb2pcfr.js} +18 -3
- package/dist/chunk-4eb2pcfr.js.map +10 -0
- package/dist/{chunk-garmxqte.js → chunk-82r7js5b.js} +101 -21
- package/dist/chunk-82r7js5b.js.map +16 -0
- package/dist/{chunk-c06zjbcj.js → chunk-cgt5pdan.js} +2 -290
- package/dist/chunk-cgt5pdan.js.map +13 -0
- package/dist/{chunk-cpsnmzrf.js → chunk-jwz46twh.js} +14 -2
- package/dist/chunk-jwz46twh.js.map +10 -0
- package/dist/{chunk-d2kpv98r.js → chunk-rqykg4gj.js} +1 -1
- package/dist/{chunk-10ebj4re.js → chunk-rsenqaz0.js} +2 -2
- package/dist/chunk-ryjxx1c8.js +303 -0
- package/dist/chunk-ryjxx1c8.js.map +10 -0
- package/dist/core/data-dir-archive.d.ts.map +1 -1
- package/dist/core/internals.d.ts.map +1 -1
- package/dist/core/marker.d.ts.map +1 -1
- package/dist/core/mutex.d.ts.map +1 -1
- package/dist/core/names.d.ts.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/pgwasm.d.ts.map +1 -1
- package/dist/core/storage.d.ts.map +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/drizzle/codecs.d.ts.map +1 -1
- package/dist/drizzle/driver.d.ts.map +1 -1
- package/dist/drizzle/index.d.ts.map +1 -1
- package/dist/drizzle/index.js +2 -2
- package/dist/drizzle/session.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/fs/base-filesystem.d.ts.map +1 -1
- package/dist/fs/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/interface.d.ts +4 -1
- package/dist/interface.d.ts.map +1 -1
- package/dist/live/debounce-mutex.d.ts.map +1 -1
- package/dist/live/format-query.d.ts.map +1 -1
- package/dist/live/index.d.ts.map +1 -1
- package/dist/live/index.js +5 -5
- package/dist/live/index.js.map +3 -3
- package/dist/live/interface.d.ts.map +1 -1
- package/dist/opfs/broker/client.d.ts.map +1 -1
- package/dist/opfs/broker/protocol.d.ts.map +1 -1
- package/dist/opfs/broker/server.d.ts.map +1 -1
- package/dist/opfs/core/checksum.d.ts.map +1 -1
- package/dist/opfs/core/codec.d.ts.map +1 -1
- package/dist/opfs/core/errors.d.ts.map +1 -1
- package/dist/opfs/core/limits.d.ts.map +1 -1
- package/dist/opfs/core/memory-port.d.ts.map +1 -1
- package/dist/opfs/core/metadata-store.d.ts.map +1 -1
- package/dist/opfs/core/mounted-vfs.d.ts.map +1 -1
- package/dist/opfs/core/path.d.ts.map +1 -1
- package/dist/opfs/core/port.d.ts.map +1 -1
- package/dist/opfs/core/repacked-vfs.d.ts.map +1 -1
- package/dist/opfs/core/state-machine.d.ts.map +1 -1
- package/dist/opfs/create.d.ts.map +1 -1
- package/dist/opfs/file-port.d.ts.map +1 -1
- package/dist/opfs/index.d.ts.map +1 -1
- package/dist/opfs/index.js +3 -3
- package/dist/opfs/opfs-port.d.ts.map +1 -1
- package/dist/opfs/opfs-repacked-fs.d.ts.map +1 -1
- package/dist/opfs/wasi/preview1.d.ts.map +1 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +6 -4
- package/dist/protocol/index.js.map +2 -2
- package/dist/protocol/wire/buffer-reader.d.ts.map +1 -1
- package/dist/protocol/wire/buffer-writer.d.ts.map +1 -1
- package/dist/protocol/wire/index.d.ts.map +1 -1
- package/dist/protocol/wire/messages.d.ts.map +1 -1
- package/dist/protocol/wire/parser.d.ts.map +1 -1
- package/dist/protocol/wire/serializer.d.ts.map +1 -1
- package/dist/protocol/wire/string-utils.d.ts.map +1 -1
- package/dist/protocol/wire/types.d.ts.map +1 -1
- package/dist/tar/gzip.d.ts.map +1 -1
- package/dist/tar/tar.d.ts.map +1 -1
- package/dist/templating.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/opfs/SKILL.md +1 -1
- package/src/core/pgwasm.ts +101 -14
- package/src/errors.ts +10 -1
- package/src/index.ts +1 -0
- package/src/interface.ts +4 -1
- package/src/live/format-query.ts +2 -1
- package/src/templating.ts +3 -1
- package/src/types.ts +15 -1
- package/dist/chunk-c06zjbcj.js.map +0 -14
- package/dist/chunk-cpsnmzrf.js.map +0 -10
- package/dist/chunk-garmxqte.js.map +0 -16
- package/dist/chunk-jnmd6w7f.js.map +0 -10
- package/dist/chunk-kb3rsr7n.js +0 -19
- package/dist/chunk-kb3rsr7n.js.map +0 -9
- /package/dist/{chunk-d2kpv98r.js.map → chunk-rqykg4gj.js.map} +0 -0
- /package/dist/{chunk-10ebj4re.js.map → chunk-rsenqaz0.js.map} +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Wire-level access to a pgwasm instance, for tools that speak the Postgres protocol themselves\n * (pg_dump, a REPL, a benchmark). Everyday code uses `query`, `exec` and `transaction` instead: the\n * `execProtocol*` calls bypass pgwasm's query locks. A tool whose exchanges must not interleave with\n * anything else runs them inside `runExclusiveSession`, which holds those locks.\n */\n\nimport { protocolAccessOf, type PgwasmProtocol } from \"../core/internals\";\nimport type { Pgwasm } from \"../interface\";\n\nexport type {\n ExecProtocolOptions,\n ExecProtocolResult,\n ExecProtocolStreamOptions,\n PgwasmProtocol,\n} from \"../core/internals\";\nexport { Parser, serialize, messages, Modes } from \"./wire\";\nexport type { BindOpts, ExecOpts, LegalValue, MessageCallback, Mode, ParseOpts, PortalOpts } from \"./wire\";\nexport type { BackendMessage } from \"./wire/messages\";\n\n/** The wire-level methods of a database created by `createPgwasm`. */\nexport function protocol(pg: Pgwasm): PgwasmProtocol {\n return protocolAccessOf(pg);\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;AAqBO,SAAS,QAAQ,CAAC,IAA4B;AAAA,EACnD,OAAO,iBAAiB,EAAE;AAAA;",
|
|
8
|
+
"debugId": "D26D28AA4E01519D64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-reader.d.ts","
|
|
1
|
+
{"version":3,"file":"buffer-reader.d.ts","sources":["../../../src/protocol/wire/buffer-reader.ts"],"names":[],"mappings":"AAMA,sEAAsE;AACtE,qBAAa,YAAY;;IAKvB,YAAY,MAAM,SAAI,EAErB;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAGvD;IAED,KAAK,IAAI,MAAM,CAId;IAED,MAAM,IAAI,MAAM,CAIf;IAED,IAAI,IAAI,MAAM,CAIb;IAED,KAAK,IAAI,MAAM,CAId;IAED,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAgB7B;IAED,OAAO,IAAI,MAAM,CAShB;IAED,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAIhC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-writer.d.ts","
|
|
1
|
+
{"version":3,"file":"buffer-writer.d.ts","sources":["../../../src/protocol/wire/buffer-writer.ts"],"names":[],"mappings":"AAMA,2FAA2F;AAC3F,qBAAa,MAAM;;IAOjB,YAAY,IAAI,SAAM,EAGrB;IAiBD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5B;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5B;IAED,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7B;IAED,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjC;IAED,SAAS,CAAC,MAAM,SAAK,GAAG,MAAM,CAM7B;IAED,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,GAAG,MAAM,CAQtD;IAYD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAK5C;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../../src/protocol/wire/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EACL,SAAS,EACT,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sources":["../../../src/protocol/wire/messages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,MAAM,WAAW,GACnB,eAAe,GACf,cAAc,GACd,eAAe,GACf,QAAQ,GACR,iBAAiB,GACjB,kBAAkB,GAClB,YAAY,GACZ,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,sBAAsB,GACtB,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,SAAS,GACT,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,2BAA2B,GAC3B,iCAAiC,GACjC,oBAA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EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAGtD;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sources":["../../../src/protocol/wire/parser.ts"],"names":[],"mappings":"AAKA,OAAO,EA6BL,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAkCtD,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;AAE5D;;;GAGG;AACH,qBAAa,MAAM;;IAMjB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAgC9D;CAiQF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sources":["../../../src/protocol/wire/serializer.ts"],"names":[],"mappings":"AAyBA,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,IAAI,CAAC;AAIvE,iBAAS,OAA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;AAID,iBAAS,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,CAe3D;AAED,iBAAS,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAQ7E;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AASD,iBAAS,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAG1D;AAED,iBAAS,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAEvD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,GAAG,UAAU,CAAC,WAAW,CAAC,CAE/E;AAED,iBAAS,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAE1D;AAUD,iCAAiC;AACjC,eAAO,MAAM,SAAS;;;;;;;;;;;;iBAYT,UAAU,CAAC,WAAW,CAAC;gBACxB,UAAU,CAAC,WAAW,CAAC;eACxB,UAAU,CAAC,WAAW,CAAC;;oBAElB,UAAU,CAAC,WAAW,CAAC;;;CAGtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-utils.d.ts","
|
|
1
|
+
{"version":3,"file":"string-utils.d.ts","sources":["../../../src/protocol/wire/string-utils.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAalD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","
|
|
1
|
+
{"version":3,"file":"types.d.ts","sources":["../../../src/protocol/wire/types.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK;aAChB,IAAI,EAAE,CAAC;aACP,MAAM,EAAE,CAAC;CACD,CAAC;AAEX,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,eAAe,CAAC"}
|
package/dist/tar/gzip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gzip.d.ts","
|
|
1
|
+
{"version":3,"file":"gzip.d.ts","sources":["../../src/tar/gzip.ts"],"names":[],"mappings":"AAWA,0DAA0D;AAC1D,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEjD;AAED,wBAAsB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAE9E;AAED,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAEhF;AAED,6FAA6F;AAC7F,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/E"}
|
package/dist/tar/tar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tar.d.ts","
|
|
1
|
+
{"version":3,"file":"tar.d.ts","sources":["../../src/tar/tar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,0BAA0B;AAC1B,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAED,sDAAsD;AACtD,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAkB,IAAI,oBAAoB;CAC3C;AAQD,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,GAAG,UAAU,CAajE;AAED,2GAA2G;AAC3G,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,QAAQ,EAAE,CA+DvD"}
|
package/dist/templating.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templating.d.ts","
|
|
1
|
+
{"version":3,"file":"templating.d.ts","sources":["../src/templating.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,YAAY;aAChB,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,WAAW;CACd,CAAC;AAEX,sGAAsG;AACtG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,YAAY,CAAC,IAAI,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,YAAY,CAAC,SAAS,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAED,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAoBD;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAyB1F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAE5F;AAED,kFAAkF;AAClF,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAErF;AAED,wEAAwE;AACxE,wBAAgB,KAAK,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAMzF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type Serializer = (value: unknown) => string;
|
|
|
8
8
|
declare function serializeString(value: unknown): string;
|
|
9
9
|
declare function serializeBoolean(value: unknown): string;
|
|
10
10
|
declare function serializeDate(value: unknown): string;
|
|
11
|
+
declare function parseDate(value: string): Date | number;
|
|
11
12
|
declare function serializeBytea(value: unknown): string;
|
|
12
13
|
declare function parseBytea(value: string): Uint8Array;
|
|
13
14
|
declare function parseBigint(value: string): number | bigint;
|
|
@@ -48,7 +49,7 @@ export declare const types: {
|
|
|
48
49
|
to: number;
|
|
49
50
|
from: number[];
|
|
50
51
|
serialize: typeof serializeDate;
|
|
51
|
-
parse:
|
|
52
|
+
parse: typeof parseDate;
|
|
52
53
|
};
|
|
53
54
|
bytea: {
|
|
54
55
|
to: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","
|
|
1
|
+
{"version":3,"file":"types.d.ts","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,KAAK,EACpB,KAAK,KAAK,EACV,IAAI,KAAK,EACT,IAAI,KAAK,EACT,IAAI,KAAK,EACT,IAAI,KAAK,EACT,OAAO,KAAK,EACZ,IAAI,KAAK,EACT,GAAG,KAAK,EACR,GAAG,KAAK,EACR,GAAG,KAAK,EACR,GAAG,KAAK,EACR,IAAI,MAAM,EACV,GAAG,MAAM,EACT,YAAY,MAAM,EAClB,IAAI,MAAM,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20
|
PgwasmFailedError,
|
|
21
|
+
TransactionAbortedError,
|
|
21
22
|
UnsupportedFeatureError,
|
|
22
23
|
} from "../errors";
|
|
23
24
|
import type {
|
|
@@ -32,6 +33,7 @@ import type {
|
|
|
32
33
|
Transaction,
|
|
33
34
|
} from "../interface";
|
|
34
35
|
import {
|
|
36
|
+
DataRowMessage,
|
|
35
37
|
DatabaseError,
|
|
36
38
|
NoticeMessage,
|
|
37
39
|
NotificationResponseMessage,
|
|
@@ -58,7 +60,7 @@ import {
|
|
|
58
60
|
} from "./internals";
|
|
59
61
|
import { BUILD_MARKER_PATH, checkBuildMarker, encodeBuildMarker, PG_VERSION_PATH } from "./marker";
|
|
60
62
|
import { Mutex } from "./mutex";
|
|
61
|
-
import { quoteIdentifier, toPostgresName } from "./names";
|
|
63
|
+
import { quoteIdentifier, randomId, toPostgresName } from "./names";
|
|
62
64
|
import { parseDescribeStatementResults, parseResults } from "./parse";
|
|
63
65
|
import { backupBaseName, describeStorage } from "./storage";
|
|
64
66
|
|
|
@@ -154,6 +156,8 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
154
156
|
|
|
155
157
|
readonly #parsers: Record<number | string, Parser>;
|
|
156
158
|
readonly #serializers: Record<number | string, Serializer>;
|
|
159
|
+
readonly #domainArrays = new Set<number>();
|
|
160
|
+
#paramTypesStatement: string | undefined;
|
|
157
161
|
#arrayTypesInitialized = false;
|
|
158
162
|
#inTransaction = false;
|
|
159
163
|
|
|
@@ -510,15 +514,93 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
510
514
|
return chunks === undefined ? undefined : new Blob(chunks);
|
|
511
515
|
}
|
|
512
516
|
|
|
513
|
-
#serializeParams(
|
|
517
|
+
async #serializeParams(
|
|
514
518
|
params: readonly unknown[],
|
|
515
519
|
dataTypeIDs: readonly number[],
|
|
516
520
|
options?: QueryOptions,
|
|
517
|
-
): (string | null)[] {
|
|
521
|
+
): Promise<(string | null)[]> {
|
|
522
|
+
if (params.length === 0) return [];
|
|
523
|
+
let unresolved: Set<number> | undefined;
|
|
524
|
+
params.forEach((param, index) => {
|
|
525
|
+
const oid = dataTypeIDs[index] ?? 0;
|
|
526
|
+
if (
|
|
527
|
+
param !== null &&
|
|
528
|
+
param !== undefined &&
|
|
529
|
+
typeof param !== "string" &&
|
|
530
|
+
!options?.serializers?.[oid] &&
|
|
531
|
+
(!this.#serializers[oid] || this.#domainArrays.has(oid))
|
|
532
|
+
) {
|
|
533
|
+
(unresolved ??= new Set()).add(oid);
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
if (unresolved === undefined) {
|
|
538
|
+
return params.map((param, index) => {
|
|
539
|
+
if (param === null || param === undefined) return null;
|
|
540
|
+
const oid = dataTypeIDs[index] ?? 0;
|
|
541
|
+
const serializer = options?.serializers?.[oid] ?? this.#serializers[oid];
|
|
542
|
+
return serializer ? serializer(param) : toText(param);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// Resolve against this transaction's catalog. Caching domain OIDs across a rollback or a
|
|
547
|
+
// dropped/recreated type can retain the wrong base serializer when PostgreSQL reuses an OID.
|
|
548
|
+
const types = new Map<number, { base: number; element: number; domain: boolean; array: boolean }>();
|
|
549
|
+
const name = (this.#paramTypesStatement ??= `pgwasm_param_types_${randomId()}`);
|
|
550
|
+
const text = `
|
|
551
|
+
WITH RECURSIVE types AS (
|
|
552
|
+
SELECT oid, typbasetype, typelem, typtype, typcategory FROM pg_catalog.pg_type
|
|
553
|
+
WHERE oid IN (${[...unresolved].join(",")})
|
|
554
|
+
UNION
|
|
555
|
+
SELECT t.oid, t.typbasetype, t.typelem, t.typtype, t.typcategory
|
|
556
|
+
FROM pg_catalog.pg_type t JOIN types p
|
|
557
|
+
ON t.oid = CASE WHEN p.typtype = 'd' THEN p.typbasetype ELSE p.typelem END
|
|
558
|
+
WHERE p.typtype = 'd' OR p.typcategory = 'A'
|
|
559
|
+
) SELECT oid, typbasetype, typelem, typtype, typcategory FROM types
|
|
560
|
+
`;
|
|
561
|
+
// The caller has parsed its unnamed statement already. Catalog work uses a named
|
|
562
|
+
// statement and portal so its Parse/Bind cannot replace the caller's prepared state.
|
|
563
|
+
for (const message of [
|
|
564
|
+
serialize.close({ type: "S", name }),
|
|
565
|
+
serialize.parse({ name, text }),
|
|
566
|
+
serialize.bind({ statement: name, portal: name }),
|
|
567
|
+
serialize.execute({ portal: name }),
|
|
568
|
+
serialize.close({ type: "P", name }),
|
|
569
|
+
serialize.close({ type: "S", name }),
|
|
570
|
+
]) {
|
|
571
|
+
for (const result of await this.#execNoPersist(message, options)) {
|
|
572
|
+
if (result instanceof DataRowMessage) {
|
|
573
|
+
types.set(Number(result.fields[0]), {
|
|
574
|
+
base: Number(result.fields[1]),
|
|
575
|
+
element: Number(result.fields[2]),
|
|
576
|
+
domain: result.fields[3] === "d",
|
|
577
|
+
array: result.fields[4] === "A",
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
const serializerFor = (oid: number, domainBase = false): Serializer | undefined => {
|
|
583
|
+
const override = options?.serializers?.[oid];
|
|
584
|
+
if (override) return override;
|
|
585
|
+
const type = types.get(oid);
|
|
586
|
+
const serializer = this.#serializers[oid];
|
|
587
|
+
if (serializer && !this.#domainArrays.has(oid)) return serializer;
|
|
588
|
+
if (type?.domain) {
|
|
589
|
+
const baseSerializer = serializerFor(type.base, true);
|
|
590
|
+
return baseSerializer ? (value) => (typeof value === "string" ? value : baseSerializer(value)) : undefined;
|
|
591
|
+
}
|
|
592
|
+
// Ordinary arrays created after boot still require refreshArrayTypes().
|
|
593
|
+
if (type?.array && (domainBase || types.get(type.element)?.domain)) {
|
|
594
|
+
const elementSerializer = serializerFor(type.element);
|
|
595
|
+
return (value) => arraySerializer(value, elementSerializer, oid);
|
|
596
|
+
}
|
|
597
|
+
return serializer;
|
|
598
|
+
};
|
|
599
|
+
|
|
518
600
|
return params.map((param, index) => {
|
|
519
601
|
if (param === null || param === undefined) return null;
|
|
520
602
|
const oid = dataTypeIDs[index] ?? 0;
|
|
521
|
-
const serializer =
|
|
603
|
+
const serializer = serializerFor(oid);
|
|
522
604
|
return serializer ? serializer(param) : toText(param);
|
|
523
605
|
});
|
|
524
606
|
}
|
|
@@ -536,7 +618,7 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
536
618
|
const dataTypeIDs = parseDescribeStatementResults(
|
|
537
619
|
await this.#execNoPersist(serialize.describe({ type: "S" }), options),
|
|
538
620
|
);
|
|
539
|
-
const values = this.#serializeParams(params, dataTypeIDs, options);
|
|
621
|
+
const values = await this.#serializeParams(params, dataTypeIDs, options);
|
|
540
622
|
results = [
|
|
541
623
|
...parsed,
|
|
542
624
|
...(await this.#execNoPersist(serialize.bind({ values }), options)),
|
|
@@ -648,7 +730,15 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
648
730
|
this.#inTransaction = false;
|
|
649
731
|
if (!closed) {
|
|
650
732
|
closed = true;
|
|
651
|
-
await this.#runExec("COMMIT");
|
|
733
|
+
const [commit] = await this.#runExec("COMMIT");
|
|
734
|
+
if (commit?.command === "ROLLBACK") {
|
|
735
|
+
throw makeQueryError({
|
|
736
|
+
error: new TransactionAbortedError(),
|
|
737
|
+
query: "COMMIT",
|
|
738
|
+
params: undefined,
|
|
739
|
+
options: undefined,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
652
742
|
} else {
|
|
653
743
|
// An explicit tx.rollback() ran inside the transaction; persist its outcome now.
|
|
654
744
|
await this.#persistAfterStatement();
|
|
@@ -695,16 +785,13 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
695
785
|
async #initArrayTypes({ force = false } = {}): Promise<void> {
|
|
696
786
|
if (this.#arrayTypesInitialized && !force) return;
|
|
697
787
|
this.#arrayTypesInitialized = true;
|
|
698
|
-
const types = await this.query<{ oid: number; typarray: number }>(`
|
|
699
|
-
SELECT
|
|
700
|
-
FROM pg_catalog.pg_type a
|
|
701
|
-
LEFT JOIN pg_catalog.pg_type b ON b.oid = a.typelem
|
|
702
|
-
WHERE a.typcategory = 'A'
|
|
703
|
-
GROUP BY b.oid, b.typarray
|
|
704
|
-
ORDER BY b.oid
|
|
788
|
+
const types = await this.query<{ oid: number; typarray: number; typtype: string }>(`
|
|
789
|
+
SELECT oid, typarray, typtype FROM pg_catalog.pg_type WHERE typarray <> 0 ORDER BY oid
|
|
705
790
|
`);
|
|
706
791
|
for (const type of types.rows) {
|
|
707
|
-
this.#serializers[type.typarray]
|
|
792
|
+
if (!this.#serializers[type.typarray] && type.typtype === "d") this.#domainArrays.add(type.typarray);
|
|
793
|
+
this.#serializers[type.typarray] ??= (value) =>
|
|
794
|
+
arraySerializer(value, this.#serializers[type.oid], type.typarray);
|
|
708
795
|
this.#parsers[type.typarray] = (value) => arrayParser(value, this.#parsers[type.oid], type.typarray);
|
|
709
796
|
}
|
|
710
797
|
}
|
package/src/errors.ts
CHANGED
|
@@ -4,7 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import type { BuildIdentity, FilesystemKind } from "./build/seam";
|
|
6
6
|
import type { QueryOptions } from "./interface";
|
|
7
|
-
import
|
|
7
|
+
import { DatabaseError } from "./protocol/wire/messages";
|
|
8
|
+
|
|
9
|
+
/** COMMIT ended an aborted transaction with ROLLBACK instead of committing its writes. */
|
|
10
|
+
export class TransactionAbortedError extends DatabaseError {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("Transaction was rolled back instead of committed", 0, "error");
|
|
13
|
+
this.severity = "ERROR";
|
|
14
|
+
this.code = "25P02";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
|
|
9
18
|
/** The base of every error pgwasm itself raises (SQL errors are {@link DatabaseError}). */
|
|
10
19
|
export class PgwasmError extends Error {
|
package/src/index.ts
CHANGED
package/src/interface.ts
CHANGED
|
@@ -159,7 +159,10 @@ export interface Pgwasm extends AsyncDisposable {
|
|
|
159
159
|
sql<T = Row>(sqlStrings: TemplateStringsArray, ...params: unknown[]): Promise<Results<T>>;
|
|
160
160
|
/** Any number of statements, through the simple protocol, without parameters. */
|
|
161
161
|
exec(sql: string, options?: QueryOptions): Promise<Results[]>;
|
|
162
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* Run `callback` in a transaction: COMMIT when it resolves, ROLLBACK when it throws.
|
|
164
|
+
* Rejects with TransactionAbortedError if COMMIT rolls back an aborted transaction.
|
|
165
|
+
*/
|
|
163
166
|
transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>;
|
|
164
167
|
/** Run `fn` while no query or transaction runs. */
|
|
165
168
|
runExclusive<T>(fn: () => Promise<T>): Promise<T>;
|
package/src/live/format-query.ts
CHANGED
|
@@ -34,7 +34,8 @@ export async function formatQuery(
|
|
|
34
34
|
|
|
35
35
|
// $1, $2… become %1$L, %2$L…: the `$` makes format() positional; a bare `%1L` would mean "width 1"
|
|
36
36
|
// and consume arguments in order, binding the wrong value to a repeated or reordered placeholder.
|
|
37
|
-
|
|
37
|
+
// Escape the query's own percent signs before introducing format() placeholders.
|
|
38
|
+
const subbedQuery = query.replaceAll("%", "%%").replace(/\$([0-9]+)/g, (_, num: string) => `%${num}$L`);
|
|
38
39
|
const runner = tx ?? pg;
|
|
39
40
|
const result = await runner.query<{ query: string }>(
|
|
40
41
|
`SELECT format($1, ${params.map((_, i) => `$${i + 2}`).join(", ")}) as query`,
|
package/src/templating.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Began as a copy of `@electric-sql/pglite` (taken under its PostgreSQL License option, © ElectricSQL
|
|
2
2
|
// — see NOTICE). Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.
|
|
3
3
|
|
|
4
|
+
import { quoteIdentifier } from "./core/names";
|
|
5
|
+
|
|
4
6
|
const TemplateType = {
|
|
5
7
|
part: "part",
|
|
6
8
|
container: "container",
|
|
@@ -85,7 +87,7 @@ export function sql(strings: TemplateStringsArray, ...values: unknown[]): Templa
|
|
|
85
87
|
* ```
|
|
86
88
|
*/
|
|
87
89
|
export function identifier(strings: TemplateStringsArray, ...values: unknown[]): TemplatePart {
|
|
88
|
-
return { _templateType: TemplateType.part, str:
|
|
90
|
+
return { _templateType: TemplateType.part, str: quoteIdentifier(String.raw(strings, ...values)) };
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
/** Raw SQL spliced into a template as it is, neither parametrized nor escaped. */
|
package/src/types.ts
CHANGED
|
@@ -106,11 +106,25 @@ function serializeBoolean(value: unknown): string {
|
|
|
106
106
|
|
|
107
107
|
function serializeDate(value: unknown): string {
|
|
108
108
|
if (typeof value === "string") return value;
|
|
109
|
+
if (value === Infinity) return "infinity";
|
|
110
|
+
if (value === -Infinity) return "-infinity";
|
|
109
111
|
if (typeof value === "number") return new Date(value).toISOString();
|
|
110
112
|
if (value instanceof Date) return value.toISOString();
|
|
111
113
|
throw new Error("Invalid input for date type");
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
function parseDate(value: string): Date | number {
|
|
117
|
+
if (value === "infinity") return Infinity;
|
|
118
|
+
if (value === "-infinity") return -Infinity;
|
|
119
|
+
// PostgreSQL separates the date and time with a space and can emit an hour-only UTC offset.
|
|
120
|
+
// Normalize these to ISO so Date does not reinterpret years below 100 with its legacy parser.
|
|
121
|
+
if (value.startsWith("00") && value[4] === "-") {
|
|
122
|
+
const iso = value.replace(" ", "T");
|
|
123
|
+
return new Date(iso === value ? value : iso.replace(/([+-]\d{2})$/, "$1:00"));
|
|
124
|
+
}
|
|
125
|
+
return new Date(value);
|
|
126
|
+
}
|
|
127
|
+
|
|
114
128
|
function serializeBytea(value: unknown): string {
|
|
115
129
|
if (!(value instanceof Uint8Array)) {
|
|
116
130
|
throw new Error("Invalid input for bytea type");
|
|
@@ -152,7 +166,7 @@ export const types = {
|
|
|
152
166
|
to: TIMESTAMPTZ,
|
|
153
167
|
from: [DATE, TIMESTAMP, TIMESTAMPTZ],
|
|
154
168
|
serialize: serializeDate,
|
|
155
|
-
parse:
|
|
169
|
+
parse: parseDate,
|
|
156
170
|
},
|
|
157
171
|
bytea: { to: BYTEA, from: [BYTEA], serialize: serializeBytea, parse: parseBytea },
|
|
158
172
|
} satisfies Record<string, TypeHandler>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/protocol/wire/messages.ts", "../src/protocol/wire/string-utils.ts", "../src/protocol/wire/buffer-writer.ts", "../src/protocol/wire/serializer.ts", "../src/core/internals.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"// Began as a copy of `@electric-sql/pg-protocol`, itself adapted from node-postgres' `pg-protocol`\n// (MIT, © Brian Carlson; ElectricSQL's changes taken under the PostgreSQL License — see NOTICE).\n// Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\nimport type { Mode } from \"./types\";\n\nexport type MessageName =\n | \"parseComplete\"\n | \"bindComplete\"\n | \"closeComplete\"\n | \"noData\"\n | \"portalSuspended\"\n | \"replicationStart\"\n | \"emptyQuery\"\n | \"copyDone\"\n | \"copyData\"\n | \"rowDescription\"\n | \"parameterDescription\"\n | \"parameterStatus\"\n | \"backendKeyData\"\n | \"notification\"\n | \"readyForQuery\"\n | \"commandComplete\"\n | \"dataRow\"\n | \"copyInResponse\"\n | \"copyOutResponse\"\n | \"authenticationOk\"\n | \"authenticationMD5Password\"\n | \"authenticationCleartextPassword\"\n | \"authenticationSASL\"\n | \"authenticationSASLContinue\"\n | \"authenticationSASLFinal\"\n | \"error\"\n | \"notice\";\n\n/** Every backend message: its name and the length its header declared (excluding the type byte). */\nexport interface BackendMessage {\n readonly name: MessageName;\n readonly length: number;\n}\n\nexport const parseComplete: BackendMessage = { name: \"parseComplete\", length: 5 };\nexport const bindComplete: BackendMessage = { name: \"bindComplete\", length: 5 };\nexport const closeComplete: BackendMessage = { name: \"closeComplete\", length: 5 };\nexport const noData: BackendMessage = { name: \"noData\", length: 5 };\nexport const portalSuspended: BackendMessage = { name: \"portalSuspended\", length: 5 };\nexport const replicationStart: BackendMessage = { name: \"replicationStart\", length: 4 };\nexport const emptyQuery: BackendMessage = { name: \"emptyQuery\", length: 4 };\nexport const copyDone: BackendMessage = { name: \"copyDone\", length: 4 };\n\nexport class AuthenticationOk implements BackendMessage {\n readonly name = \"authenticationOk\";\n readonly length: number;\n constructor(length: number) {\n this.length = length;\n }\n}\n\nexport class AuthenticationCleartextPassword implements BackendMessage {\n readonly name = \"authenticationCleartextPassword\";\n readonly length: number;\n constructor(length: number) {\n this.length = length;\n }\n}\n\nexport class AuthenticationMD5Password implements BackendMessage {\n readonly name = \"authenticationMD5Password\";\n readonly length: number;\n readonly salt: Uint8Array;\n constructor(length: number, salt: Uint8Array) {\n this.length = length;\n this.salt = salt;\n }\n}\n\nexport class AuthenticationSASL implements BackendMessage {\n readonly name = \"authenticationSASL\";\n readonly length: number;\n readonly mechanisms: string[];\n constructor(length: number, mechanisms: string[]) {\n this.length = length;\n this.mechanisms = mechanisms;\n }\n}\n\nexport class AuthenticationSASLContinue implements BackendMessage {\n readonly name = \"authenticationSASLContinue\";\n readonly length: number;\n readonly data: string;\n constructor(length: number, data: string) {\n this.length = length;\n this.data = data;\n }\n}\n\nexport class AuthenticationSASLFinal implements BackendMessage {\n readonly name = \"authenticationSASLFinal\";\n readonly length: number;\n readonly data: string;\n constructor(length: number, data: string) {\n this.length = length;\n this.data = data;\n }\n}\n\nexport type AuthenticationMessage =\n | AuthenticationOk\n | AuthenticationCleartextPassword\n | AuthenticationMD5Password\n | AuthenticationSASL\n | AuthenticationSASLContinue\n | AuthenticationSASLFinal;\n\n/** The fields an ErrorResponse and a NoticeResponse share. */\nexport interface NoticeOrError {\n message: string | undefined;\n severity: string | undefined;\n code: string | undefined;\n detail: string | undefined;\n hint: string | undefined;\n position: string | undefined;\n internalPosition: string | undefined;\n internalQuery: string | undefined;\n where: string | undefined;\n schema: string | undefined;\n table: string | undefined;\n column: string | undefined;\n dataType: string | undefined;\n constraint: string | undefined;\n file: string | undefined;\n line: string | undefined;\n routine: string | undefined;\n}\n\n/** An ErrorResponse from Postgres: an SQL error. `code` is the SQLSTATE. */\nexport class DatabaseError extends Error implements NoticeOrError {\n severity: string | undefined;\n code: string | undefined;\n detail: string | undefined;\n hint: string | undefined;\n position: string | undefined;\n internalPosition: string | undefined;\n internalQuery: string | undefined;\n where: string | undefined;\n schema: string | undefined;\n table: string | undefined;\n column: string | undefined;\n dataType: string | undefined;\n constraint: string | undefined;\n file: string | undefined;\n line: string | undefined;\n routine: string | undefined;\n readonly length: number;\n override readonly name: MessageName;\n constructor(message: string, length: number, name: MessageName) {\n super(message);\n this.length = length;\n this.name = name;\n }\n}\n\nexport class CopyDataMessage implements BackendMessage {\n readonly name = \"copyData\";\n readonly length: number;\n readonly chunk: Uint8Array;\n constructor(length: number, chunk: Uint8Array) {\n this.length = length;\n this.chunk = chunk;\n }\n}\n\nexport class CopyResponse implements BackendMessage {\n readonly length: number;\n readonly name: MessageName;\n readonly binary: boolean;\n readonly columnTypes: number[];\n constructor(length: number, name: MessageName, binary: boolean, columnCount: number) {\n this.length = length;\n this.name = name;\n this.binary = binary;\n this.columnTypes = Array.from({ length: columnCount }, () => 0);\n }\n}\n\nexport class Field {\n readonly name: string;\n readonly tableID: number;\n readonly columnID: number;\n readonly dataTypeID: number;\n readonly dataTypeSize: number;\n readonly dataTypeModifier: number;\n readonly format: Mode;\n constructor(\n name: string,\n tableID: number,\n columnID: number,\n dataTypeID: number,\n dataTypeSize: number,\n dataTypeModifier: number,\n format: Mode,\n ) {\n this.name = name;\n this.tableID = tableID;\n this.columnID = columnID;\n this.dataTypeID = dataTypeID;\n this.dataTypeSize = dataTypeSize;\n this.dataTypeModifier = dataTypeModifier;\n this.format = format;\n }\n}\n\nexport class RowDescriptionMessage implements BackendMessage {\n readonly name: MessageName = \"rowDescription\";\n readonly length: number;\n readonly fieldCount: number;\n readonly fields: Field[];\n constructor(length: number, fields: Field[]) {\n this.length = length;\n this.fieldCount = fields.length;\n this.fields = fields;\n }\n}\n\nexport class ParameterDescriptionMessage implements BackendMessage {\n readonly name: MessageName = \"parameterDescription\";\n readonly length: number;\n readonly parameterCount: number;\n readonly dataTypeIDs: number[];\n constructor(length: number, dataTypeIDs: number[]) {\n this.length = length;\n this.parameterCount = dataTypeIDs.length;\n this.dataTypeIDs = dataTypeIDs;\n }\n}\n\nexport class ParameterStatusMessage implements BackendMessage {\n readonly name: MessageName = \"parameterStatus\";\n readonly length: number;\n readonly parameterName: string;\n readonly parameterValue: string;\n constructor(length: number, parameterName: string, parameterValue: string) {\n this.length = length;\n this.parameterName = parameterName;\n this.parameterValue = parameterValue;\n }\n}\n\nexport class BackendKeyDataMessage implements BackendMessage {\n readonly name: MessageName = \"backendKeyData\";\n readonly length: number;\n readonly processID: number;\n readonly secretKey: number;\n constructor(length: number, processID: number, secretKey: number) {\n this.length = length;\n this.processID = processID;\n this.secretKey = secretKey;\n }\n}\n\nexport class NotificationResponseMessage implements BackendMessage {\n readonly name: MessageName = \"notification\";\n readonly length: number;\n readonly processId: number;\n readonly channel: string;\n readonly payload: string;\n constructor(length: number, processId: number, channel: string, payload: string) {\n this.length = length;\n this.processId = processId;\n this.channel = channel;\n this.payload = payload;\n }\n}\n\nexport class ReadyForQueryMessage implements BackendMessage {\n readonly name: MessageName = \"readyForQuery\";\n readonly length: number;\n /** `I` idle, `T` in a transaction block, `E` in a failed transaction block. */\n readonly status: string;\n constructor(length: number, status: string) {\n this.length = length;\n this.status = status;\n }\n}\n\nexport class CommandCompleteMessage implements BackendMessage {\n readonly name: MessageName = \"commandComplete\";\n readonly length: number;\n readonly text: string;\n constructor(length: number, text: string) {\n this.length = length;\n this.text = text;\n }\n}\n\nexport class DataRowMessage implements BackendMessage {\n readonly name: MessageName = \"dataRow\";\n readonly length: number;\n readonly fieldCount: number;\n readonly fields: (string | null)[];\n constructor(length: number, fields: (string | null)[]) {\n this.length = length;\n this.fields = fields;\n this.fieldCount = fields.length;\n }\n}\n\nexport class NoticeMessage implements BackendMessage, NoticeOrError {\n readonly name = \"notice\";\n readonly length: number;\n readonly message: string | undefined;\n severity: string | undefined;\n code: string | undefined;\n detail: string | undefined;\n hint: string | undefined;\n position: string | undefined;\n internalPosition: string | undefined;\n internalQuery: string | undefined;\n where: string | undefined;\n schema: string | undefined;\n table: string | undefined;\n column: string | undefined;\n dataType: string | undefined;\n constraint: string | undefined;\n file: string | undefined;\n line: string | undefined;\n routine: string | undefined;\n constructor(length: number, message: string | undefined) {\n this.length = length;\n this.message = message;\n }\n}\n",
|
|
6
|
-
"// Began as a copy of `@electric-sql/pg-protocol`, itself adapted from node-postgres' `pg-protocol`\n// (MIT, © Brian Carlson; ElectricSQL's changes taken under the PostgreSQL License — see NOTICE).\n// Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\n/**\n * The byte length of a string once UTF-8 encoded.\n * Adapted from https://stackoverflow.com/a/23329386\n */\nexport function byteLengthUtf8(str: string): number {\n let byteLength = str.length;\n for (let i = str.length - 1; i >= 0; i--) {\n const code = str.charCodeAt(i);\n if (code > 0x7f && code <= 0x7ff) byteLength++;\n else if (code > 0x7ff && code <= 0xffff) byteLength += 2;\n if (code >= 0xdc00 && code <= 0xdfff) {\n const previous = str.charCodeAt(i - 1);\n // Only a valid pair shares four bytes; an unpaired surrogate encodes as U+FFFD.\n if (previous >= 0xd800 && previous <= 0xdbff) i--;\n }\n }\n return byteLength;\n}\n",
|
|
7
|
-
"// Began as a copy of `@electric-sql/pg-protocol`, itself adapted from node-postgres' `pg-protocol`\n// (MIT, © Brian Carlson; ElectricSQL's changes taken under the PostgreSQL License — see NOTICE).\n// Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\nimport { byteLengthUtf8 } from \"./string-utils\";\n\n/** Builds frontend messages: a 5-byte header slot (code + length) followed by the body. */\nexport class Writer {\n readonly #size: number;\n #bufferView: DataView<ArrayBuffer>;\n #offset = 5;\n readonly #encoder = new TextEncoder();\n readonly #headerPosition = 0;\n\n constructor(size = 256) {\n this.#size = size;\n this.#bufferView = this.#allocateBuffer(size);\n }\n\n #allocateBuffer(size: number): DataView<ArrayBuffer> {\n return new DataView(new ArrayBuffer(size));\n }\n\n #ensure(size: number): void {\n const remaining = this.#bufferView.byteLength - this.#offset;\n if (remaining < size) {\n const oldBuffer = this.#bufferView.buffer;\n // Grow by ~1.5x (https://stackoverflow.com/questions/2269063/buffer-growth-strategy).\n const newSize = oldBuffer.byteLength + (oldBuffer.byteLength >> 1) + size;\n this.#bufferView = this.#allocateBuffer(newSize);\n new Uint8Array(this.#bufferView.buffer).set(new Uint8Array(oldBuffer));\n }\n }\n\n addInt32(num: number): Writer {\n this.#ensure(4);\n this.#bufferView.setInt32(this.#offset, num, false);\n this.#offset += 4;\n return this;\n }\n\n addInt16(num: number): Writer {\n this.#ensure(2);\n this.#bufferView.setInt16(this.#offset, num, false);\n this.#offset += 2;\n return this;\n }\n\n addUint16(num: number): Writer {\n this.#ensure(2);\n this.#bufferView.setUint16(this.#offset, num, false);\n this.#offset += 2;\n return this;\n }\n\n addCString(string: string): Writer {\n if (string) {\n this.addString(string);\n }\n this.#ensure(1);\n this.#bufferView.setUint8(this.#offset, 0);\n this.#offset++;\n return this;\n }\n\n addString(string = \"\"): Writer {\n const length = byteLengthUtf8(string);\n this.#ensure(length);\n this.#encoder.encodeInto(string, new Uint8Array(this.#bufferView.buffer, this.#offset));\n this.#offset += length;\n return this;\n }\n\n add(otherBuffer: ArrayBuffer | ArrayBufferView): Writer {\n const bytes = ArrayBuffer.isView(otherBuffer)\n ? new Uint8Array(otherBuffer.buffer, otherBuffer.byteOffset, otherBuffer.byteLength)\n : new Uint8Array(otherBuffer);\n this.#ensure(bytes.byteLength);\n new Uint8Array(this.#bufferView.buffer).set(bytes, this.#offset);\n this.#offset += bytes.byteLength;\n return this;\n }\n\n #join(code?: number): ArrayBuffer {\n if (code) {\n this.#bufferView.setUint8(this.#headerPosition, code);\n // The length counts everything in the message but the code byte.\n const length = this.#offset - (this.#headerPosition + 1);\n this.#bufferView.setInt32(this.#headerPosition + 1, length, false);\n }\n return this.#bufferView.buffer.slice(code ? 0 : 5, this.#offset);\n }\n\n flush(code?: number): Uint8Array<ArrayBuffer> {\n const result = this.#join(code);\n this.#offset = 5;\n this.#bufferView = this.#allocateBuffer(this.#size);\n return new Uint8Array(result);\n }\n}\n",
|
|
8
|
-
"// Began as a copy of `@electric-sql/pg-protocol`, itself adapted from node-postgres' `pg-protocol`\n// (MIT, © Brian Carlson; ElectricSQL's changes taken under the PostgreSQL License — see NOTICE).\n// Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\nimport { Writer } from \"./buffer-writer\";\nimport { byteLengthUtf8 } from \"./string-utils\";\n\nconst code = {\n startup: 0x70,\n query: 0x51,\n parse: 0x50,\n bind: 0x42,\n execute: 0x45,\n flush: 0x48,\n sync: 0x53,\n end: 0x58,\n close: 0x43,\n describe: 0x44,\n copyFromChunk: 0x64,\n copyDone: 0x63,\n copyFail: 0x66,\n} as const;\n\ntype Code = (typeof code)[keyof typeof code];\n\n/** A bind parameter: text, raw bytes (sent as binary), or SQL NULL. */\nexport type LegalValue = string | ArrayBuffer | ArrayBufferView | null;\n\nconst writer = new Writer();\n\nfunction startup(opts: Record<string, string>): Uint8Array<ArrayBuffer> {\n // protocol version 3.0\n writer.addInt16(3).addInt16(0);\n for (const [key, value] of Object.entries(opts)) {\n writer.addCString(key).addCString(value);\n }\n writer.addCString(\"client_encoding\").addCString(\"UTF8\");\n // The startup message is sent without a type byte.\n const bodyBuffer = writer.addCString(\"\").flush();\n const length = bodyBuffer.byteLength + 4;\n return new Writer().addInt32(length).add(bodyBuffer).flush();\n}\n\nfunction requestSsl(): Uint8Array<ArrayBuffer> {\n const bufferView = new DataView(new ArrayBuffer(8));\n bufferView.setInt32(0, 8, false);\n bufferView.setInt32(4, 80877103, false);\n return new Uint8Array(bufferView.buffer);\n}\n\nfunction password(value: string): Uint8Array<ArrayBuffer> {\n return writer.addCString(value).flush(code.startup);\n}\n\nfunction sendSASLInitialResponseMessage(mechanism: string, initialResponse: string): Uint8Array<ArrayBuffer> {\n writer.addCString(mechanism).addInt32(byteLengthUtf8(initialResponse)).addString(initialResponse);\n return writer.flush(code.startup);\n}\n\nfunction sendSCRAMClientFinalMessage(additionalData: string): Uint8Array<ArrayBuffer> {\n return writer.addString(additionalData).flush(code.startup);\n}\n\nfunction query(text: string): Uint8Array<ArrayBuffer> {\n return writer.addCString(text).flush(code.query);\n}\n\nexport interface ParseOpts {\n name?: string;\n types?: readonly number[];\n text: string;\n}\n\nconst emptyValueArray: LegalValue[] = [];\n\nfunction assertParameterCount(count: number): void {\n if (count > 65_535) {\n throw new RangeError(`Postgres messages support at most 65535 parameters (received ${count})`);\n }\n}\n\nfunction parse(opts: ParseOpts): Uint8Array<ArrayBuffer> {\n const name = opts.name ?? \"\";\n if (name.length > 63) {\n throw new RangeError(`Postgres statement names are at most 63 characters: \"${name}\" (${name.length})`);\n }\n const typeCount = opts.types?.length ?? 0;\n assertParameterCount(typeCount);\n const buffer = writer.addCString(name).addCString(opts.text).addUint16(typeCount);\n opts.types?.forEach((type) => buffer.addInt32(type));\n return writer.flush(code.parse);\n}\n\ntype ValueMapper = (param: unknown, index: number) => LegalValue;\n\nexport interface BindOpts {\n portal?: string;\n binary?: boolean;\n statement?: string;\n values?: readonly LegalValue[];\n /** Optional map from a JS value to the value sent, per parameter. */\n valueMapper?: ValueMapper;\n}\n\nconst paramWriter = new Writer();\n\nconst ParamType = { STRING: 0, BINARY: 1 } as const;\n\nfunction writeValues(values: readonly LegalValue[], valueMapper?: ValueMapper): void {\n for (let i = 0; i < values.length; i++) {\n const value = values[i] ?? null;\n const mappedVal = valueMapper ? valueMapper(value, i) : value;\n if (mappedVal === null) {\n writer.addInt16(ParamType.STRING);\n // -1 is SQL NULL.\n paramWriter.addInt32(-1);\n } else if (mappedVal instanceof ArrayBuffer || ArrayBuffer.isView(mappedVal)) {\n const byteLength = mappedVal.byteLength;\n writer.addInt16(ParamType.BINARY);\n paramWriter.addInt32(byteLength);\n paramWriter.add(mappedVal);\n } else {\n writer.addInt16(ParamType.STRING);\n paramWriter.addInt32(byteLengthUtf8(mappedVal));\n paramWriter.addString(mappedVal);\n }\n }\n}\n\nfunction bind(config: BindOpts = {}): Uint8Array<ArrayBuffer> {\n const portal = config.portal ?? \"\";\n const statement = config.statement ?? \"\";\n const binary = config.binary ?? false;\n const values = config.values ?? emptyValueArray;\n const len = values.length;\n assertParameterCount(len);\n\n writer.addCString(portal).addCString(statement);\n writer.addUint16(len);\n writeValues(values, config.valueMapper);\n writer.addUint16(len);\n writer.add(paramWriter.flush());\n // result format code\n writer.addInt16(binary ? ParamType.BINARY : ParamType.STRING);\n return writer.flush(code.bind);\n}\n\nexport interface ExecOpts {\n portal?: string;\n rows?: number;\n}\n\nconst emptyExecute = new Uint8Array([code.execute, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00]);\n\nfunction execute(config?: ExecOpts): Uint8Array<ArrayBuffer> {\n if (!config || (!config.portal && !config.rows)) {\n return emptyExecute;\n }\n const portal = config.portal ?? \"\";\n const rows = config.rows ?? 0;\n const portalLength = byteLengthUtf8(portal);\n const len = 4 + portalLength + 1 + 4;\n const bufferView = new DataView(new ArrayBuffer(1 + len));\n bufferView.setUint8(0, code.execute);\n bufferView.setInt32(1, len, false);\n new TextEncoder().encodeInto(portal, new Uint8Array(bufferView.buffer, 5));\n bufferView.setUint8(portalLength + 5, 0); // the portal name's terminator\n bufferView.setUint32(bufferView.byteLength - 4, rows, false);\n return new Uint8Array(bufferView.buffer);\n}\n\nfunction cancel(processID: number, secretKey: number): Uint8Array<ArrayBuffer> {\n const bufferView = new DataView(new ArrayBuffer(16));\n bufferView.setInt32(0, 16, false);\n bufferView.setInt16(4, 1234, false);\n bufferView.setInt16(6, 5678, false);\n bufferView.setInt32(8, processID, false);\n bufferView.setInt32(12, secretKey, false);\n return new Uint8Array(bufferView.buffer);\n}\n\nexport interface PortalOpts {\n type: \"S\" | \"P\";\n name?: string;\n}\n\nfunction cstringMessage(messageCode: Code, string: string): Uint8Array<ArrayBuffer> {\n return new Writer().addCString(string).flush(messageCode);\n}\n\nconst emptyDescribePortal = writer.addCString(\"P\").flush(code.describe);\nconst emptyDescribeStatement = writer.addCString(\"S\").flush(code.describe);\n\nfunction describe(msg: PortalOpts): Uint8Array<ArrayBuffer> {\n if (msg.name) return cstringMessage(code.describe, `${msg.type}${msg.name}`);\n return msg.type === \"P\" ? emptyDescribePortal : emptyDescribeStatement;\n}\n\nfunction close(msg: PortalOpts): Uint8Array<ArrayBuffer> {\n return cstringMessage(code.close, `${msg.type}${msg.name ?? \"\"}`);\n}\n\nfunction copyData(chunk: ArrayBuffer | ArrayBufferView): Uint8Array<ArrayBuffer> {\n return writer.add(chunk).flush(code.copyFromChunk);\n}\n\nfunction copyFail(message: string): Uint8Array<ArrayBuffer> {\n return cstringMessage(code.copyFail, message);\n}\n\nconst codeOnlyBuffer = (messageCode: Code): Uint8Array<ArrayBuffer> =>\n new Uint8Array([messageCode, 0x00, 0x00, 0x00, 0x04]);\n\nconst flushBuffer = codeOnlyBuffer(code.flush);\nconst syncBuffer = codeOnlyBuffer(code.sync);\nconst endBuffer = codeOnlyBuffer(code.end);\nconst copyDoneBuffer = codeOnlyBuffer(code.copyDone);\n\n/** Frontend message builders. */\nexport const serialize = {\n startup,\n password,\n requestSsl,\n sendSASLInitialResponseMessage,\n sendSCRAMClientFinalMessage,\n query,\n parse,\n bind,\n execute,\n describe,\n close,\n flush: (): Uint8Array<ArrayBuffer> => flushBuffer,\n sync: (): Uint8Array<ArrayBuffer> => syncBuffer,\n end: (): Uint8Array<ArrayBuffer> => endBuffer,\n copyData,\n copyDone: (): Uint8Array<ArrayBuffer> => copyDoneBuffer,\n copyFail,\n cancel,\n};\n",
|
|
9
|
-
"/**\n * Wire-level access to a pgwasm instance, kept off its public type. `@pgxsinkit/pgwasm/protocol` and the\n * `live` extension reach it through this registry; pgwasm is bundled with code splitting, so every\n * entry point shares this one module and its map.\n */\n\nimport type { BuildCapabilities } from \"../build/seam\";\nimport type { BackendMessage, NoticeMessage } from \"../protocol/wire/messages\";\n\nexport interface ExecProtocolOptions {\n /** Persist storage after the message, as a statement does. Defaults to `true`. */\n readonly persist?: boolean;\n /** Throw the first ErrorResponse. Defaults to `true`. */\n readonly throwOnError?: boolean;\n readonly onNotice?: (notice: NoticeMessage) => void;\n}\n\nexport interface ExecProtocolStreamOptions {\n /** Persist storage after the message. Defaults to `true`. */\n readonly persist?: boolean;\n /** Every backend byte, as it arrives. A chunk is only valid during the call: copy it to keep it. */\n readonly onRawData: (data: Uint8Array) => void;\n}\n\nexport interface ExecProtocolResult {\n readonly messages: BackendMessage[];\n readonly data: Uint8Array;\n}\n\n/** What `protocol(pg)` returns. */\nexport interface PgwasmProtocol {\n /** Run frontend message bytes; the parsed backend messages and the raw reply. */\n execProtocol(message: Uint8Array, options?: ExecProtocolOptions): Promise<ExecProtocolResult>;\n /** Run frontend message bytes; the parsed backend messages only. */\n execProtocolStream(message: Uint8Array, options?: ExecProtocolOptions): Promise<BackendMessage[]>;\n /** Run frontend message bytes; the raw reply. Notifications and errors are still dispatched. */\n execProtocolRaw(message: Uint8Array, options?: Pick<ExecProtocolOptions, \"persist\">): Promise<Uint8Array>;\n /**\n * Run frontend message bytes and stream the raw reply. When nothing is pending and the build has\n * `synchronousExchange`, the whole reply is delivered before this call returns its promise — what a\n * tool driving it from inside a blocking wasm callback (pg_dump) needs.\n */\n execProtocolRawStream(message: Uint8Array, options: ExecProtocolStreamOptions): Promise<void>;\n /**\n * Run `fn` with the database's session to itself, for a tool whose exchanges must not interleave with\n * anything else (pg_dump). It waits for, then holds, the locks a `transaction()` holds, and the query\n * lock: no query, exec, transaction, listen, live-query refresh or Store backup of this database runs\n * until `fn` settles.\n *\n * What `fn` sends with the `execProtocol*` methods is its own responsibility: no transaction is begun\n * or ended around it, and a message is persisted only as its options say. Inside `fn`, use only these\n * wire methods: the database's query methods wait for the locks `fn` holds, so awaiting one deadlocks.\n */\n runExclusiveSession<T>(fn: () => Promise<T>): Promise<T>;\n /** The build's capabilities, e.g. to check `synchronousExchange` before relying on it. */\n readonly capabilities: BuildCapabilities;\n}\n\nconst registry = new WeakMap<object, PgwasmProtocol>();\n\nexport function registerProtocolAccess(pg: object, access: PgwasmProtocol): void {\n registry.set(pg, access);\n}\n\n/** The wire-level access of a pgwasm instance. Throws for anything else. */\nexport function protocolAccessOf(pg: object): PgwasmProtocol {\n const access = registry.get(pg);\n if (access === undefined) {\n throw new TypeError(\"Not a pgwasm instance (created by createPgwasm).\");\n }\n return access;\n}\n\n/**\n * The strict sync of a database whose data directory is an OPFS-repacked store, registered by\n * `createOpfsPgwasm` and run by `strictSync(pg)` from `@pgxsinkit/pgwasm/opfs`.\n */\nconst strictSyncs = new WeakMap<object, () => void>();\n\nexport function registerStrictSync(pg: object, strictSync: () => void): void {\n strictSyncs.set(pg, strictSync);\n}\n\n/** The registered strict sync of `pg`, or `undefined` when it has none (not an OPFS-repacked store). */\nexport function strictSyncOf(pg: object): (() => void) | undefined {\n return strictSyncs.get(pg);\n}\n"
|
|
10
|
-
],
|
|
11
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCO,IAAM,gBAAgC,EAAE,MAAM,iBAAiB,QAAQ,EAAE;AACzE,IAAM,eAA+B,EAAE,MAAM,gBAAgB,QAAQ,EAAE;AACvE,IAAM,gBAAgC,EAAE,MAAM,iBAAiB,QAAQ,EAAE;AACzE,IAAM,SAAyB,EAAE,MAAM,UAAU,QAAQ,EAAE;AAC3D,IAAM,kBAAkC,EAAE,MAAM,mBAAmB,QAAQ,EAAE;AAC7E,IAAM,mBAAmC,EAAE,MAAM,oBAAoB,QAAQ,EAAE;AAC/E,IAAM,aAA6B,EAAE,MAAM,cAAc,QAAQ,EAAE;AACnE,IAAM,WAA2B,EAAE,MAAM,YAAY,QAAQ,EAAE;AAAA;AAE/D,MAAM,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AA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO,MAA+B;AAAA,EACtC,MAAM,MAA+B;AAAA,EACrC,KAAK,MAA+B;AAAA,EACpC;AAAA,EACA,UAAU,MAA+B;AAAA,EACzC;AAAA,EACA;AACF;;;ACpLA,IAAM,WAAW,IAAI;AAEd,SAAS,sBAAsB,CAAC,IAAY,QAA8B;AAAA,EAC/E,SAAS,IAAI,IAAI,MAAM;AAAA;AAIlB,SAAS,gBAAgB,CAAC,IAA4B;AAAA,EAC3D,MAAM,SAAS,SAAS,IAAI,EAAE;AAAA,EAC9B,IAAI,WAAW,WAAW;AAAA,IACxB,MAAM,IAAI,UAAU,kDAAkD;AAAA,EACxE;AAAA,EACA,OAAO;AAAA;AAOT,IAAM,cAAc,IAAI;AAEjB,SAAS,kBAAkB,CAAC,IAAY,YAA8B;AAAA,EAC3E,YAAY,IAAI,IAAI,UAAU;AAAA;AAIzB,SAAS,YAAY,CAAC,IAAsC;AAAA,EACjE,OAAO,YAAY,IAAI,EAAE;AAAA;",
|
|
12
|
-
"debugId": "A647EE3A8AD5ECE264756E2164756E21",
|
|
13
|
-
"names": []
|
|
14
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/errors.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"// Began as a copy of `@electric-sql/pglite` (taken under its PostgreSQL License option, © ElectricSQL\n// — see NOTICE): `makeQueryError` began as its `makePGliteError`. Owned outright (ADR-0062);\n// compatibility with PGlite is an anti-goal — evolve freely.\n\nimport type { BuildIdentity, FilesystemKind } from \"./build/seam\";\nimport type { QueryOptions } from \"./interface\";\nimport type { DatabaseError } from \"./protocol/wire/messages\";\n\n/** The base of every error pgwasm itself raises (SQL errors are {@link DatabaseError}). */\nexport class PgwasmError extends Error {\n override name = \"PgwasmError\";\n}\n\n/** A `dataDir` pgwasm does not accept: an unknown scheme, a bare path, or `dataDir` with `fs`. */\nexport class UnsupportedDataDirError extends PgwasmError {\n override name = \"UnsupportedDataDirError\";\n readonly dataDir: string;\n\n constructor(dataDir: string, reason: string) {\n super(`Unsupported dataDir \"${dataDir}\": ${reason}`);\n this.dataDir = dataDir;\n }\n}\n\n/** An `opfs-ahp://` dataDir: that filesystem is gone (ADR-0062 decision 6). */\nexport class OpfsAhpRemovedError extends UnsupportedDataDirError {\n override name = \"OpfsAhpRemovedError\";\n /** Where the OPFS store lives now. */\n readonly replacement = \"@pgxsinkit/pgwasm/opfs\";\n\n constructor(dataDir: string) {\n super(\n dataDir,\n \"the opfs-ahp filesystem has been removed; the OPFS store is @pgxsinkit/pgwasm/opfs, passed in \" +\n \"explicitly as the `fs` option\",\n );\n }\n}\n\n/** The build does not mount the requested kind of storage. */\nexport class UnsupportedFilesystemError extends PgwasmError {\n override name = \"UnsupportedFilesystemError\";\n readonly kind: FilesystemKind;\n readonly build: string;\n\n constructor(kind: FilesystemKind, build: BuildIdentity, supported: readonly FilesystemKind[]) {\n super(\n `The \"${build.name}\" Postgres build does not support ${kind} storage (it supports: ${supported.join(\", \")}).`,\n );\n this.kind = kind;\n this.build = build.name;\n }\n}\n\n/** The build needs a cross-origin-isolated context, and this one is not. */\nexport class CrossOriginIsolationRequiredError extends PgwasmError {\n override name = \"CrossOriginIsolationRequiredError\";\n\n constructor(build: BuildIdentity) {\n super(\n `The \"${build.name}\" Postgres build needs a cross-origin-isolated context (SharedArrayBuffer); serve the ` +\n \"page with Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp.\",\n );\n }\n}\n\n/** A server extension compiled for another build. */\nexport class ExtensionBuildMismatchError extends PgwasmError {\n override name = \"ExtensionBuildMismatchError\";\n\n constructor(extension: string, extensionBuild: string, build: BuildIdentity) {\n super(\n `The \"${extension}\" extension was compiled for the \"${extensionBuild}\" Postgres build and cannot load into ` +\n `the \"${build.name}\" build.`,\n );\n }\n}\n\n/** The build a data directory (or a Store backup) records. `\"unmarked\"` predates build markers. */\nexport type RecordedBuild = { readonly build: string; readonly dataFormat: number } | \"unmarked\";\n\nfunction describeRecorded(recorded: RecordedBuild): string {\n return recorded === \"unmarked\"\n ? \"an unmarked data directory (created before builds were recorded, by the C build)\"\n : `the \"${recorded.build}\" Postgres build (data format ${recorded.dataFormat})`;\n}\n\n/**\n * A data directory or Store backup made by another Postgres build. A store's build is fixed when it is\n * created (ADR-0063 build permanence); nothing was written.\n */\nexport class BuildMismatchError extends PgwasmError {\n override name = \"BuildMismatchError\";\n readonly expected: { readonly build: string; readonly dataFormat: number };\n readonly found: RecordedBuild;\n readonly source: \"data-directory\" | \"backup\";\n\n constructor(build: BuildIdentity, found: RecordedBuild, source: \"data-directory\" | \"backup\") {\n const what = source === \"backup\" ? \"This Store backup\" : \"This data directory\";\n super(\n `${what} was created by ${describeRecorded(found)} and cannot be opened with the \"${build.name}\" build. A ` +\n \"store's Postgres build is fixed when it is created: open it with that build, or destroy the store and \" +\n \"re-sync it.\",\n );\n this.expected = { build: build.name, dataFormat: build.dataFormat };\n this.found = found;\n this.source = source;\n }\n}\n\n/** A data directory or backup of the same build in a data format this release does not read. */\nexport class DataFormatMismatchError extends PgwasmError {\n override name = \"DataFormatMismatchError\";\n readonly expected: number;\n readonly found: number;\n readonly source: \"data-directory\" | \"backup\";\n\n constructor(build: BuildIdentity, found: number, source: \"data-directory\" | \"backup\") {\n super(\n `This ${source === \"backup\" ? \"Store backup\" : \"data directory\"} is in data format ${found} of the ` +\n `\"${build.name}\" Postgres build; this release of the build reads format ${build.dataFormat}.`,\n );\n this.expected = build.dataFormat;\n this.found = found;\n this.source = source;\n }\n}\n\n/** A build marker that cannot be read: corrupt, or written by a newer pgwasm. Nothing was written. */\nexport class BuildMarkerUnreadableError extends PgwasmError {\n override name = \"BuildMarkerUnreadableError\";\n readonly raw: string;\n\n constructor(raw: string, reason: string) {\n super(`The data directory's build marker cannot be read (${reason}): ${JSON.stringify(raw)}`);\n this.raw = raw;\n }\n}\n\n/** `loadDataDir` was given for a data directory that already holds a database. */\nexport class DataDirExistsError extends PgwasmError {\n override name = \"DataDirExistsError\";\n\n constructor() {\n super(\"The data directory already holds a database; a Store backup restores only into an empty one.\");\n }\n}\n\n/** A Store backup that cannot be restored: not a tarball, or a member outside the data directory. */\nexport class BackupFormatError extends PgwasmError {\n override name = \"BackupFormatError\";\n}\n\n/** The storage is held by another open database (an IndexedDB store open in another context). */\nexport class StorageInUseError extends PgwasmError {\n override name = \"StorageInUseError\";\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** The database is closing or closed. */\nexport class PgwasmClosedError extends PgwasmError {\n override name = \"PgwasmClosedError\";\n\n constructor(state: \"closing\" | \"closed\") {\n super(`pgwasm is ${state}`);\n }\n}\n\n/**\n * The Postgres build failed underneath a statement (an exception that is not an SQL error: a storage\n * failure thrown into the engine, a PANIC's abort). The instance is failed: every later statement\n * throws this same error, and `close()` releases resources and rejects with it.\n */\nexport class PgwasmFailedError extends PgwasmError {\n override name = \"PgwasmFailedError\";\n}\n\n/** A feature the build does not have (see its capabilities). */\nexport class UnsupportedFeatureError extends PgwasmError {\n override name = \"UnsupportedFeatureError\";\n}\n\n/** An SQL error from a query, with the query that raised it. */\nexport interface QueryError extends DatabaseError {\n query: string | undefined;\n params: readonly unknown[] | undefined;\n queryOptions: QueryOptions | undefined;\n}\n\n/** Attach the query to the SQL error it raised. */\nexport function makeQueryError(data: {\n error: DatabaseError;\n query: string;\n params: readonly unknown[] | undefined;\n options: QueryOptions | undefined;\n}): QueryError {\n return Object.assign(data.error, { query: data.query, params: data.params, queryOptions: data.options });\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;AASO,MAAM,qBAAoB,MAAM;AAAA,EAC5B,OAAO;AAClB;AAAA;AAGO,MAAM,iCAAgC,aAAY;AAAA,EAC9C,OAAO;AAAA,EACP;AAAA,EAET,WAAW,CAAC,SAAiB,QAAgB;AAAA,IAC3C,MAAM,wBAAwB,aAAa,QA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