@dads-framework/postgres-access 0.0.0-stage → 0.2.0
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/BENCHMARK.md +275 -0
- package/LICENSE.md +21 -0
- package/README.md +275 -2
- package/dist/compile-access-policy.d.ts +9 -0
- package/dist/compile-access-policy.d.ts.map +1 -0
- package/dist/compile-access-policy.js +77 -0
- package/dist/compile-access-policy.js.map +1 -0
- package/dist/drizzle-executor.d.ts +5 -0
- package/dist/drizzle-executor.d.ts.map +1 -0
- package/dist/drizzle-executor.js +25 -0
- package/dist/drizzle-executor.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/lookup-primary-pool.d.ts +5 -0
- package/dist/lookup-primary-pool.d.ts.map +1 -0
- package/dist/lookup-primary-pool.js +24 -0
- package/dist/lookup-primary-pool.js.map +1 -0
- package/dist/lookup-revision-query.d.ts +7 -0
- package/dist/lookup-revision-query.d.ts.map +1 -0
- package/dist/lookup-revision-query.js +73 -0
- package/dist/lookup-revision-query.js.map +1 -0
- package/dist/lookup-revision-schema.d.ts +10 -0
- package/dist/lookup-revision-schema.d.ts.map +1 -0
- package/dist/lookup-revision-schema.js +75 -0
- package/dist/lookup-revision-schema.js.map +1 -0
- package/dist/lower-permissions.d.ts +8 -0
- package/dist/lower-permissions.d.ts.map +1 -0
- package/dist/lower-permissions.js +76 -0
- package/dist/lower-permissions.js.map +1 -0
- package/dist/policy/compile-linear-batch.d.ts +15 -0
- package/dist/policy/compile-linear-batch.d.ts.map +1 -0
- package/dist/policy/compile-linear-batch.js +34 -0
- package/dist/policy/compile-linear-batch.js.map +1 -0
- package/dist/policy/compile-linear-check.d.ts +5 -0
- package/dist/policy/compile-linear-check.d.ts.map +1 -0
- package/dist/policy/compile-linear-check.js +71 -0
- package/dist/policy/compile-linear-check.js.map +1 -0
- package/dist/policy/compile-postgres-policy.d.ts +28 -0
- package/dist/policy/compile-postgres-policy.d.ts.map +1 -0
- package/dist/policy/compile-postgres-policy.js +189 -0
- package/dist/policy/compile-postgres-policy.js.map +1 -0
- package/dist/policy/compile-reverse-policy.d.ts +5 -0
- package/dist/policy/compile-reverse-policy.d.ts.map +1 -0
- package/dist/policy/compile-reverse-policy.js +60 -0
- package/dist/policy/compile-reverse-policy.js.map +1 -0
- package/dist/policy/compile-shared-point-check.d.ts +18 -0
- package/dist/policy/compile-shared-point-check.d.ts.map +1 -0
- package/dist/policy/compile-shared-point-check.js +126 -0
- package/dist/policy/compile-shared-point-check.js.map +1 -0
- package/dist/policy/policy-model.d.ts +86 -0
- package/dist/policy/policy-model.d.ts.map +1 -0
- package/dist/policy/policy-model.js +2 -0
- package/dist/policy/policy-model.js.map +1 -0
- package/dist/policy/policy-sql.d.ts +20 -0
- package/dist/policy/policy-sql.d.ts.map +1 -0
- package/dist/policy/policy-sql.js +59 -0
- package/dist/policy/policy-sql.js.map +1 -0
- package/dist/postgres-access.tsbuildinfo +1 -0
- package/dist/postgres-authorization.d.ts +35 -0
- package/dist/postgres-authorization.d.ts.map +1 -0
- package/dist/postgres-authorization.js +170 -0
- package/dist/postgres-authorization.js.map +1 -0
- package/dist/postgres-response.d.ts +4 -0
- package/dist/postgres-response.d.ts.map +1 -0
- package/dist/postgres-response.js +13 -0
- package/dist/postgres-response.js.map +1 -0
- package/dist/postgres-serialization-conflict.d.ts +11 -0
- package/dist/postgres-serialization-conflict.d.ts.map +1 -0
- package/dist/postgres-serialization-conflict.js +29 -0
- package/dist/postgres-serialization-conflict.js.map +1 -0
- package/dist/postgres-tuples.d.ts +19 -0
- package/dist/postgres-tuples.d.ts.map +1 -0
- package/dist/postgres-tuples.js +135 -0
- package/dist/postgres-tuples.js.map +1 -0
- package/dist/postgres-types.d.ts +17 -0
- package/dist/postgres-types.d.ts.map +1 -0
- package/dist/postgres-types.js +10 -0
- package/dist/postgres-types.js.map +1 -0
- package/dist/prepared-check-executor.d.ts +12 -0
- package/dist/prepared-check-executor.d.ts.map +1 -0
- package/dist/prepared-check-executor.js +39 -0
- package/dist/prepared-check-executor.js.map +1 -0
- package/dist/protected-authorization-scope.d.ts +10 -0
- package/dist/protected-authorization-scope.d.ts.map +1 -0
- package/dist/protected-authorization-scope.js +41 -0
- package/dist/protected-authorization-scope.js.map +1 -0
- package/dist/relationship-schema.d.ts +11 -0
- package/dist/relationship-schema.d.ts.map +1 -0
- package/dist/relationship-schema.js +36 -0
- package/dist/relationship-schema.js.map +1 -0
- package/dist/revisioned-lookup.d.ts +13 -0
- package/dist/revisioned-lookup.d.ts.map +1 -0
- package/dist/revisioned-lookup.js +129 -0
- package/dist/revisioned-lookup.js.map +1 -0
- package/dist/transactional-access-changes.d.ts +19 -0
- package/dist/transactional-access-changes.d.ts.map +1 -0
- package/dist/transactional-access-changes.js +35 -0
- package/dist/transactional-access-changes.js.map +1 -0
- package/dist/with-protected-postgres-transaction.d.ts +22 -0
- package/dist/with-protected-postgres-transaction.d.ts.map +1 -0
- package/dist/with-protected-postgres-transaction.js +47 -0
- package/dist/with-protected-postgres-transaction.js.map +1 -0
- package/package.json +41 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export const RELATIONSHIP_TABLE = "dad_authorization_relationship";
|
|
3
|
+
const relationshipSchemaSql = `
|
|
4
|
+
CREATE TABLE IF NOT EXISTS dad_authorization_relationship (
|
|
5
|
+
namespace text NOT NULL,
|
|
6
|
+
resource_kind text NOT NULL,
|
|
7
|
+
resource_id text NOT NULL,
|
|
8
|
+
relation text NOT NULL,
|
|
9
|
+
subject_kind text NOT NULL,
|
|
10
|
+
subject_id text NOT NULL DEFAULT '',
|
|
11
|
+
subject_relation text NOT NULL DEFAULT '',
|
|
12
|
+
subject_is_wildcard boolean NOT NULL DEFAULT false,
|
|
13
|
+
CONSTRAINT dad_authorization_relationship_subject_shape CHECK (
|
|
14
|
+
(subject_is_wildcard = false AND subject_id <> '') OR
|
|
15
|
+
(subject_is_wildcard = true AND subject_id = '' AND subject_relation = '')
|
|
16
|
+
),
|
|
17
|
+
PRIMARY KEY (
|
|
18
|
+
namespace, resource_kind, resource_id, relation,
|
|
19
|
+
subject_kind, subject_id, subject_relation, subject_is_wildcard
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
CREATE INDEX IF NOT EXISTS dad_authorization_relationship_subject_lookup
|
|
23
|
+
ON dad_authorization_relationship (
|
|
24
|
+
namespace, subject_kind, subject_id, resource_kind, resource_id, relation
|
|
25
|
+
);
|
|
26
|
+
`.trim();
|
|
27
|
+
/** Application-applied migration for the tuple store and its reverse lookup index. */
|
|
28
|
+
export const relationshipSchemaMigration = Object.freeze({
|
|
29
|
+
adapter: "postgres-access",
|
|
30
|
+
version: 1,
|
|
31
|
+
id: "dad-authorization-relationship-v1",
|
|
32
|
+
checksum: createHash("sha256").update(relationshipSchemaSql).digest("hex"),
|
|
33
|
+
sql: relationshipSchemaSql,
|
|
34
|
+
advisoryLockSql: "SELECT pg_advisory_xact_lock(hashtext($1))",
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=relationship-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship-schema.js","sourceRoot":"","sources":["../src/relationship-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAEnE,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;CAuB7B,CAAC,IAAI,EAAE,CAAC;AAET,sFAAsF;AACtF,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,MAAM,CAAC;IACvD,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,CAAC;IACV,EAAE,EAAE,mCAAmC;IACvC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAC1E,GAAG,EAAE,qBAAqB;IAC1B,eAAe,EAAE,4CAA4C;CAC9D,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ResourceLookup } from "@dads-framework/access/runtime";
|
|
2
|
+
import type { PostgresQuery, PostgresRow } from "./postgres-types.js";
|
|
3
|
+
type ReadRows = (query: PostgresQuery) => Promise<readonly PostgresRow[]>;
|
|
4
|
+
/** Per adapter instance. The instance owns exactly one compiled model, namespace and pool. */
|
|
5
|
+
export declare class RevisionedLookup {
|
|
6
|
+
#private;
|
|
7
|
+
private readonly namespace;
|
|
8
|
+
private readonly readRows;
|
|
9
|
+
constructor(namespace: string, readRows: ReadRows);
|
|
10
|
+
lookup(input: ResourceLookup, compile: () => PostgresQuery): Promise<readonly string[]>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=revisioned-lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revisioned-lookup.d.ts","sourceRoot":"","sources":["../src/revisioned-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAOrE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AActE,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC;AAE1E,8FAA8F;AAC9F,qBAAa,gBAAgB;;IAQzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAF3B,YACmB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EACjC;IAEE,MAAM,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,MAAM,aAAa,GAC3B,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CA0B5B;CAsFF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { lookupRevisionQuery, lookupWithRevision, readLookupRevision, readRevisionedIds, } from "./lookup-revision-query.js";
|
|
2
|
+
const MAX_ENTRIES = 32;
|
|
3
|
+
const MAX_IDS = 32_768;
|
|
4
|
+
const MAX_ENTRY_IDS = 8_192;
|
|
5
|
+
const MAX_BYTES = 2 * 1024 * 1024;
|
|
6
|
+
const MAX_IN_FLIGHT = 16;
|
|
7
|
+
const MAX_IN_FLIGHT_KEY_UNITS = 2_048;
|
|
8
|
+
/** Per adapter instance. The instance owns exactly one compiled model, namespace and pool. */
|
|
9
|
+
export class RevisionedLookup {
|
|
10
|
+
namespace;
|
|
11
|
+
readRows;
|
|
12
|
+
#entries = new Map();
|
|
13
|
+
#pending = new Map();
|
|
14
|
+
#bytes = 0;
|
|
15
|
+
#ids = 0;
|
|
16
|
+
#generation = 0;
|
|
17
|
+
constructor(namespace, readRows) {
|
|
18
|
+
this.namespace = namespace;
|
|
19
|
+
this.readRows = readRows;
|
|
20
|
+
}
|
|
21
|
+
async lookup(input, compile) {
|
|
22
|
+
const key = JSON.stringify([
|
|
23
|
+
input.resourceType,
|
|
24
|
+
input.permission,
|
|
25
|
+
input.subject.type,
|
|
26
|
+
input.subject.id,
|
|
27
|
+
input.subject.relation ?? "",
|
|
28
|
+
input.consistencyToken ?? "",
|
|
29
|
+
]);
|
|
30
|
+
const previouslyLoaded = this.#entries.get(key);
|
|
31
|
+
if (previouslyLoaded !== undefined) {
|
|
32
|
+
if ((await this.#currentStamp()) === previouslyLoaded.stamp)
|
|
33
|
+
return previouslyLoaded.ids;
|
|
34
|
+
if (this.#entries.get(key) === previouslyLoaded)
|
|
35
|
+
this.#remove(key);
|
|
36
|
+
}
|
|
37
|
+
// A caller may have entered after the pending SQL read's snapshot. It
|
|
38
|
+
// must validate the result on its own before reusing it, including empty
|
|
39
|
+
// lists. The initiating operation already observed its own snapshot.
|
|
40
|
+
const pending = this.#pending.get(key);
|
|
41
|
+
if (pending !== undefined) {
|
|
42
|
+
const result = await pending;
|
|
43
|
+
if ((await this.#currentStamp()) === result.stamp)
|
|
44
|
+
return result.ids;
|
|
45
|
+
return (await this.#fill(key, compile)).ids;
|
|
46
|
+
}
|
|
47
|
+
return (await this.#fill(key, compile)).ids;
|
|
48
|
+
}
|
|
49
|
+
async #currentStamp() {
|
|
50
|
+
try {
|
|
51
|
+
const rows = await this.readRows(lookupRevisionQuery(this.namespace));
|
|
52
|
+
return readLookupRevision(rows[0]);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.#invalidate();
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async #fill(key, compile) {
|
|
60
|
+
const previous = this.#entries.get(key);
|
|
61
|
+
const generation = this.#generation;
|
|
62
|
+
const read = this.#read(compile());
|
|
63
|
+
const share = key.length <= MAX_IN_FLIGHT_KEY_UNITS &&
|
|
64
|
+
!this.#pending.has(key) &&
|
|
65
|
+
this.#pending.size < MAX_IN_FLIGHT;
|
|
66
|
+
if (share)
|
|
67
|
+
this.#pending.set(key, read);
|
|
68
|
+
try {
|
|
69
|
+
const result = await read;
|
|
70
|
+
// An older or slower load may not replace a newer fill.
|
|
71
|
+
if (this.#generation === generation &&
|
|
72
|
+
this.#entries.get(key) === previous)
|
|
73
|
+
this.#retain(key, result);
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.#invalidate();
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
if (share && this.#pending.get(key) === read)
|
|
82
|
+
this.#pending.delete(key);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async #read(query) {
|
|
86
|
+
const rows = await this.readRows(lookupWithRevision(query, this.namespace));
|
|
87
|
+
return {
|
|
88
|
+
stamp: readLookupRevision(rows[0]),
|
|
89
|
+
ids: readRevisionedIds(rows[0]),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
#retain(key, result) {
|
|
93
|
+
if (result.ids.length > MAX_ENTRY_IDS)
|
|
94
|
+
return;
|
|
95
|
+
const bytes = (key.length + result.stamp.length) * 2 +
|
|
96
|
+
128 +
|
|
97
|
+
result.ids.reduce((sum, id) => sum + id.length * 2 + 32, 0);
|
|
98
|
+
if (bytes > MAX_BYTES)
|
|
99
|
+
return;
|
|
100
|
+
this.#remove(key);
|
|
101
|
+
while (this.#entries.size >= MAX_ENTRIES ||
|
|
102
|
+
this.#bytes + bytes > MAX_BYTES ||
|
|
103
|
+
this.#ids + result.ids.length > MAX_IDS) {
|
|
104
|
+
const oldest = this.#entries.keys().next();
|
|
105
|
+
if (oldest.done)
|
|
106
|
+
break;
|
|
107
|
+
this.#remove(oldest.value);
|
|
108
|
+
}
|
|
109
|
+
this.#entries.set(key, { ...result, bytes });
|
|
110
|
+
this.#bytes += bytes;
|
|
111
|
+
this.#ids += result.ids.length;
|
|
112
|
+
}
|
|
113
|
+
#invalidate() {
|
|
114
|
+
this.#generation++;
|
|
115
|
+
this.#entries.clear();
|
|
116
|
+
this.#pending.clear();
|
|
117
|
+
this.#bytes = 0;
|
|
118
|
+
this.#ids = 0;
|
|
119
|
+
}
|
|
120
|
+
#remove(key) {
|
|
121
|
+
const entry = this.#entries.get(key);
|
|
122
|
+
if (entry === undefined)
|
|
123
|
+
return;
|
|
124
|
+
this.#entries.delete(key);
|
|
125
|
+
this.#bytes -= entry.bytes;
|
|
126
|
+
this.#ids -= entry.ids.length;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=revisioned-lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revisioned-lookup.js","sourceRoot":"","sources":["../src/revisioned-lookup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GACl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AAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ApplyAccessChangesAfterCommit, EnqueueAccessChanges, type AccessChange } from "@dads-framework/access/runtime";
|
|
2
|
+
import type { DrizzleHandle } from "@dads-framework/postgres";
|
|
3
|
+
import type { PostgresAuthorization } from "./postgres-authorization.js";
|
|
4
|
+
type OutboxTx = Pick<DrizzleHandle, "insert" | "update"> & Partial<Pick<DrizzleHandle, "execute">>;
|
|
5
|
+
/** Binds the existing relationship-fact port to the same transaction as the business write. */
|
|
6
|
+
export declare class TransactionalAccessChanges extends EnqueueAccessChanges<OutboxTx> {
|
|
7
|
+
private readonly authorization;
|
|
8
|
+
private readonly database;
|
|
9
|
+
constructor(authorization: PostgresAuthorization, database: Pick<DrizzleHandle, "transaction">);
|
|
10
|
+
enqueue(entries: readonly AccessChange[], tx: OutboxTx): Promise<void>;
|
|
11
|
+
enqueueReplacingOpposite(entries: readonly AccessChange[], tx: OutboxTx): Promise<void>;
|
|
12
|
+
append(entries: readonly AccessChange[]): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/** The row and its access facts are already committed when this port runs. */
|
|
15
|
+
export declare class AlreadyAppliedAccessChanges extends ApplyAccessChangesAfterCommit {
|
|
16
|
+
dispatch(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=transactional-access-changes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactional-access-changes.d.ts","sourceRoot":"","sources":["../src/transactional-access-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,KAAK,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;AAE1C,+FAA+F;AAC/F,qBAAa,0BAA2B,SAAQ,oBAAoB,CAAC,QAAQ,CAAC;IAE1E,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAF3B,YACmB,aAAa,EAAE,qBAAqB,EACpC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,EAG9D;IAEQ,OAAO,CACd,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,EAAE,EAAE,QAAQ,GACX,OAAO,CAAC,IAAI,CAAC,CAQf;IAEQ,wBAAwB,CAC/B,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,EAAE,EAAE,QAAQ,GACX,OAAO,CAAC,IAAI,CAAC,CAGf;IAEQ,MAAM,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/D;CACF;AAED,8EAA8E;AAC9E,qBAAa,2BAA4B,SAAQ,6BAA6B;IACnE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAEjC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ApplyAccessChangesAfterCommit, EnqueueAccessChanges, } from "@dads-framework/access/runtime";
|
|
2
|
+
import { is } from "drizzle-orm";
|
|
3
|
+
import { PgTransaction } from "drizzle-orm/pg-core";
|
|
4
|
+
/** Binds the existing relationship-fact port to the same transaction as the business write. */
|
|
5
|
+
export class TransactionalAccessChanges extends EnqueueAccessChanges {
|
|
6
|
+
authorization;
|
|
7
|
+
database;
|
|
8
|
+
constructor(authorization, database) {
|
|
9
|
+
super();
|
|
10
|
+
this.authorization = authorization;
|
|
11
|
+
this.database = database;
|
|
12
|
+
}
|
|
13
|
+
enqueue(entries, tx) {
|
|
14
|
+
if (entries.length === 0)
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
if (tx.execute === undefined || !is(tx, PgTransaction)) {
|
|
17
|
+
throw new Error("Postgres access changes require the caller's Drizzle transaction");
|
|
18
|
+
}
|
|
19
|
+
return this.authorization.inDrizzleTransaction(tx).applyChanges(entries);
|
|
20
|
+
}
|
|
21
|
+
enqueueReplacingOpposite(entries, tx) {
|
|
22
|
+
// There are no queued facts to supersede. Apply this change in the caller's transaction.
|
|
23
|
+
return this.enqueue(entries, tx);
|
|
24
|
+
}
|
|
25
|
+
append(entries) {
|
|
26
|
+
return this.database.transaction((tx) => this.enqueue(entries, tx));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** The row and its access facts are already committed when this port runs. */
|
|
30
|
+
export class AlreadyAppliedAccessChanges extends ApplyAccessChangesAfterCommit {
|
|
31
|
+
dispatch() {
|
|
32
|
+
return Promise.resolve();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=transactional-access-changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactional-access-changes.js","sourceRoot":"","sources":["../src/transactional-access-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,+FAA+F;AAC/F,MAAM,OAAO,0BAA2B,SAAQ,oBAA8B;IAEzD,aAAa;IACb,QAAQ;IAF3B,YACmB,aAAoC,EACpC,QAA4C;QAE7D,KAAK,EAAE,CAAC;6BAHS,aAAa;wBACb,QAAQ;IAG3B,CAAC;IAEQ,OAAO,CACd,OAAgC,EAChC,EAAY;QAEZ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QACnD,IAAI,EAAE,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3E,CAAC;IAEQ,wBAAwB,CAC/B,OAAgC,EAChC,EAAY;QAEZ,yFAAyF;QACzF,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACnC,CAAC;IAEQ,MAAM,CAAC,OAAgC;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;CACF;AAED,8EAA8E;AAC9E,MAAM,OAAO,2BAA4B,SAAQ,6BAA6B;IACnE,QAAQ;QACf,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DrizzleHandle } from "@dads-framework/postgres";
|
|
2
|
+
import type { PostgresAuthorization } from "./postgres-authorization.js";
|
|
3
|
+
type Schema = Record<string, unknown>;
|
|
4
|
+
type Database<TSchema extends Schema> = Pick<DrizzleHandle<TSchema>, "transaction">;
|
|
5
|
+
type Transaction<TSchema extends Schema> = Parameters<Parameters<Database<TSchema>["transaction"]>[0]>[0];
|
|
6
|
+
export type ProtectedPostgresTransactionOptions<TSchema extends Schema = Schema> = {
|
|
7
|
+
readonly authorization: PostgresAuthorization;
|
|
8
|
+
} & ({
|
|
9
|
+
readonly database: Database<TSchema>;
|
|
10
|
+
readonly transaction?: never;
|
|
11
|
+
} | {
|
|
12
|
+
readonly transaction: Transaction<TSchema>;
|
|
13
|
+
readonly database?: never;
|
|
14
|
+
});
|
|
15
|
+
export type ProtectedPostgresTransaction<TSchema extends Schema = Schema> = {
|
|
16
|
+
readonly tx: Transaction<TSchema>;
|
|
17
|
+
readonly authorization: PostgresAuthorization;
|
|
18
|
+
};
|
|
19
|
+
/** Run one protected write with authorization and application data on the same client. */
|
|
20
|
+
export declare function withProtectedPostgresTransaction<TSchema extends Schema, Result>(options: ProtectedPostgresTransactionOptions<TSchema>, work: (scope: ProtectedPostgresTransaction<TSchema>) => Promise<Result>): Promise<Result>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=with-protected-postgres-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-protected-postgres-transaction.d.ts","sourceRoot":"","sources":["../src/with-protected-postgres-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAGzE,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtC,KAAK,QAAQ,CAAC,OAAO,SAAS,MAAM,IAAI,IAAI,CAC1C,aAAa,CAAC,OAAO,CAAC,EACtB,aAAa,CACd,CAAC;AACF,KAAK,WAAW,CAAC,OAAO,SAAS,MAAM,IAAI,UAAU,CACnD,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAChD,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,mCAAmC,CAC7C,OAAO,SAAS,MAAM,GAAG,MAAM,IAC7B;IACF,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;CAC/C,GAAG,CACA;IAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAC5E,CAAC;AAEF,MAAM,MAAM,4BAA4B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IAAI;IAC1E,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;CAC/C,CAAC;AAEF,0FAA0F;AAC1F,wBAAsB,gCAAgC,CACpD,OAAO,SAAS,MAAM,EACtB,MAAM,EAEN,OAAO,EAAE,mCAAmC,CAAC,OAAO,CAAC,EACrD,IAAI,EAAE,CAAC,KAAK,EAAE,4BAA4B,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GACtE,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { is, sql } from "drizzle-orm";
|
|
2
|
+
import { PgTransaction } from "drizzle-orm/pg-core";
|
|
3
|
+
import { assertProtectedAuthorizationCanJoin, openProtectedAuthorization, } from "./protected-authorization-scope.js";
|
|
4
|
+
import { readPostgresSerializationConflict } from "./postgres-serialization-conflict.js";
|
|
5
|
+
/** Run one protected write with authorization and application data on the same client. */
|
|
6
|
+
export async function withProtectedPostgresTransaction(options, work) {
|
|
7
|
+
try {
|
|
8
|
+
assertProtectedAuthorizationCanJoin(options.authorization, options.transaction);
|
|
9
|
+
if (options.transaction !== undefined) {
|
|
10
|
+
return await runProtectedWork(options.transaction, options.authorization, work);
|
|
11
|
+
}
|
|
12
|
+
if (is(options.database, PgTransaction)) {
|
|
13
|
+
throw new Error("Pass an existing Postgres transaction as transaction");
|
|
14
|
+
}
|
|
15
|
+
let started = false;
|
|
16
|
+
return await options.database.transaction((tx) => {
|
|
17
|
+
if (started)
|
|
18
|
+
throw new Error("Protected Postgres callbacks cannot be replayed");
|
|
19
|
+
started = true;
|
|
20
|
+
return runProtectedWork(tx, options.authorization, work);
|
|
21
|
+
}, { isolationLevel: "serializable" });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const conflict = readPostgresSerializationConflict(error);
|
|
25
|
+
if (conflict !== undefined)
|
|
26
|
+
throw conflict;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function runProtectedWork(tx, authorization, work) {
|
|
31
|
+
if (!is(tx, PgTransaction)) {
|
|
32
|
+
throw new Error("Protected Postgres writes require a Drizzle transaction");
|
|
33
|
+
}
|
|
34
|
+
// A SELECT takes the transaction snapshot, so isolation cannot later be lowered.
|
|
35
|
+
const isolation = await tx.execute(sql `select current_setting('transaction_isolation') as isolation`);
|
|
36
|
+
if (isolation.rows[0]?.isolation !== "serializable") {
|
|
37
|
+
throw new Error("Protected Postgres writes require serializable isolation");
|
|
38
|
+
}
|
|
39
|
+
const scope = openProtectedAuthorization(authorization, tx);
|
|
40
|
+
try {
|
|
41
|
+
return await work({ tx, authorization: scope.authorization });
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
scope.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=with-protected-postgres-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-protected-postgres-transaction.js","sourceRoot":"","sources":["../src/with-protected-postgres-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,C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B,CAC7B,EAAwB,EACxB,aAAoC,EACpC,IAAuE;IAEvE,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,iFAAiF;IACjF,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,OAAO,CAChC,GAAG,CAAA,8DAA8D,CAClE,CAAC;IACF,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,cAAc,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,KAAK,GAAG,0BAA0B,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAC5D,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;IAChE,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dads-framework/postgres-access",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"BENCHMARK.md"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@dads-framework/access": "0.2.0",
|
|
21
|
+
"@dads-framework/postgres": "0.2.0",
|
|
22
|
+
"drizzle-orm": "^0.45.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@dads-framework/authorization": "0.2.0",
|
|
26
|
+
"vitest": "~4.1.0",
|
|
27
|
+
"zod": "^4.4.3"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prepublishOnly": "node ../../../scripts/verify-prepublish.mjs",
|
|
31
|
+
"build": "tsc -b",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"typecheck": "tsc -b --pretty false",
|
|
34
|
+
"test:integration": "VITEST_TIER=integration vitest run",
|
|
35
|
+
"benchmark": "VITEST_TIER=benchmark vitest run"
|
|
36
|
+
},
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/brytoncooper/dads-framework.git",
|
|
41
|
+
"directory": "packages/server/postgres-access"
|
|
42
|
+
}
|
|
43
|
+
}
|