@dbx-tools/postgres 0.9.95 → 0.9.105
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 +21 -11
- package/index.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,14 +3,25 @@
|
|
|
3
3
|
Connection-correct PostgreSQL primitives for Node.js: advisory locks that hold the
|
|
4
4
|
connection they lock, and a structured topic bus over `LISTEN`/`NOTIFY`.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
or parallel message envelopes so Node and Python services remain compatible.
|
|
6
|
+
The package provides advisory locks, a typed topic bus, optional message
|
|
7
|
+
persistence, sender identity, and connection helpers for Node services.
|
|
9
8
|
|
|
10
9
|
Both work against a plain `pg.Pool` or anything structurally compatible with one,
|
|
11
10
|
including the pool AppKit's Lakebase plugin exports — so a Databricks App gets
|
|
12
11
|
them without a second database client or connection pool.
|
|
13
12
|
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Run protected work on the same PostgreSQL connection that holds the lock:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { withAdvisoryLock } from "@dbx-tools/postgres";
|
|
19
|
+
|
|
20
|
+
await withAdvisoryLock(pool, ["invoice", invoiceId], async (client) => {
|
|
21
|
+
await client.query("UPDATE invoices SET status = 'sent' WHERE id = $1", [invoiceId]);
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
14
25
|
## Key Features
|
|
15
26
|
|
|
16
27
|
- Converts an arbitrary structured key (string, array, object, `Date`, or an
|
|
@@ -59,7 +70,7 @@ service-principal and per-user OBO pools. Every login identity that can reach th
|
|
|
59
70
|
pool must therefore be a member of the configured role, or otherwise have
|
|
60
71
|
permission to `SET ROLE`, before the pool can connect successfully.
|
|
61
72
|
|
|
62
|
-
##
|
|
73
|
+
## Use With AppKit Lakebase
|
|
63
74
|
|
|
64
75
|
Use AppKit `lakebase()` to obtain and refresh the PostgreSQL pool. This package
|
|
65
76
|
does not replace that plugin. Add it when work needs connection-correct advisory
|
|
@@ -241,7 +252,7 @@ a listener can never be told about a row it cannot yet read.
|
|
|
241
252
|
|
|
242
253
|
| Option | Default | Behavior |
|
|
243
254
|
| ------------------ | ----------------- | -------------------------------------------------------------- |
|
|
244
|
-
| `schema` | `dbx_message_bus` | Schema
|
|
255
|
+
| `schema` | `dbx_message_bus` | Schema used for message persistence. |
|
|
245
256
|
| `scope` | `open` | Which tier's table publishes and history read by default. |
|
|
246
257
|
| `tables` | `*_messages` | Override a tier's table name for a managed installation. |
|
|
247
258
|
| `ttl` | `24 hours` | Per-message expiry. `false` keeps messages until deleted. |
|
|
@@ -314,18 +325,17 @@ shared `dbx_tools_topic_bus` channel.
|
|
|
314
325
|
`identity.channelName(parts)` exposes the derivation without constructing a bus,
|
|
315
326
|
which is useful for configuration checks and cross-runtime contract tests.
|
|
316
327
|
|
|
317
|
-
##
|
|
328
|
+
## Connection Lifecycles
|
|
318
329
|
|
|
319
330
|
Advisory locks are connection-scoped, and that is easy to get wrong invisibly:
|
|
320
331
|
taking the lock with `pool.query()` and doing the protected work with another
|
|
321
332
|
`pool.query()` can use two different connections, so the lock protects nothing and
|
|
322
333
|
the code looks correct. The same applies to `LISTEN`, which is session state a
|
|
323
|
-
pooled query cannot hold.
|
|
324
|
-
|
|
325
|
-
message bus, an AppKit runtime, or a queue extension.
|
|
334
|
+
pooled query cannot hold. These helpers keep both lifecycles on dedicated
|
|
335
|
+
connections and depend only on `pg`.
|
|
326
336
|
|
|
327
|
-
AppKit
|
|
328
|
-
|
|
337
|
+
AppKit supplies the Lakebase pool; these helpers add locks and cross-instance
|
|
338
|
+
message delivery on top of it.
|
|
329
339
|
|
|
330
340
|
## Module Map
|
|
331
341
|
|
package/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export const PACKAGE_IDENTIFIER = "@dbx-tools/postgres";
|
|
6
|
-
export const PACKAGE_VERSION = "0.9.
|
|
6
|
+
export const PACKAGE_VERSION = "0.9.105";
|
|
7
7
|
export * as advisoryLock from "./src/advisory-lock.ts";
|
|
8
8
|
export * as bindings from "./src/bindings.ts";
|
|
9
9
|
export * as identity from "./src/identity.ts";
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const PACKAGE_IDENTIFIER = "@dbx-tools/postgres";
|
|
2
|
-
export declare const PACKAGE_VERSION = "0.9.
|
|
2
|
+
export declare const PACKAGE_VERSION = "0.9.105";
|
|
3
3
|
export * as advisoryLock from "./src/advisory-lock.ts";
|
|
4
4
|
export * as bindings from "./src/bindings.ts";
|
|
5
5
|
export * as identity from "./src/identity.ts";
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
3
|
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
4
|
export const PACKAGE_IDENTIFIER = "@dbx-tools/postgres";
|
|
5
|
-
export const PACKAGE_VERSION = "0.9.
|
|
5
|
+
export const PACKAGE_VERSION = "0.9.105";
|
|
6
6
|
export * as advisoryLock from "./src/advisory-lock.js";
|
|
7
7
|
export * as bindings from "./src/bindings.js";
|
|
8
8
|
export * as identity from "./src/identity.js";
|
|
@@ -12,4 +12,4 @@ export * as topicBus from "./src/topic-bus.js";
|
|
|
12
12
|
export { POINTER_VERSION } from "./src/persistence.js";
|
|
13
13
|
export { PostgresTopicBus } from "./src/topic-bus.js";
|
|
14
14
|
export * from "./exports.js";
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lc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J0cy50c1wiO1xuIl19
|
package/package.json
CHANGED
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@databricks/appkit": "0.81.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@dbx-tools/lakebase": "^0.9.
|
|
32
|
-
"@dbx-tools/shared-core": "^0.9.
|
|
31
|
+
"@dbx-tools/lakebase": "^0.9.105",
|
|
32
|
+
"@dbx-tools/shared-core": "^0.9.105",
|
|
33
33
|
"pg": "^8.22.0"
|
|
34
34
|
},
|
|
35
35
|
"main": "./lib/index.js",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"./package.json": "./package.json"
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
"version": "0.9.
|
|
73
|
+
"version": "0.9.105",
|
|
74
74
|
"types": "./lib/index.d.ts",
|
|
75
75
|
"dbxToolsConfig": {
|
|
76
76
|
"tags": [
|