okmodel 0.7.0 → 0.8.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/dist/adapters/capabilities.d.ts +32 -0
- package/dist/adapters/failure.d.ts +1 -1
- package/dist/adapters/pg/bun-sql.d.ts +53 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +1 -1
- package/dist/adapters/pg/bunsql.d.ts +1 -1
- package/dist/adapters/pg/neon-extra.d.ts +18 -0
- package/dist/adapters/pg/neon.d.ts +104 -0
- package/dist/adapters/pg/no-inflight-timeout.d.ts +1 -1
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/fn/index.d.ts +39 -1
- package/dist/dialects/pg/fn/index.js +118 -26
- package/dist/dialects/pg/index.d.ts +2 -0
- package/dist/dialects/pg/index.js +393 -18
- package/dist/dialects/pg/introspect.d.ts +11 -0
- package/dist/dialects/pg/operators.d.ts +1 -1
- package/dist/dialects/pg/ops/fragment.d.ts +119 -0
- package/dist/dialects/pg/ops/lane.d.ts +49 -0
- package/dist/dialects/pg/view/client.d.ts +14 -6
- package/dist/dialects/pg/view/index.d.ts +73 -1
- package/dist/dialects/pg/view/index.js +156 -5
- package/dist/dialects/pg/view/scratch.d.ts +8 -5
- package/dist/runtime/otel.d.ts +105 -0
- package/dist/runtime/otel.js +97 -0
- package/dist/runtime/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.d.ts +38 -0
- package/dist/runtime/pg/neon.js +64 -0
- package/dist/runtime/pg/pg.js +4 -4
- package/dist/runtime/pg/pglite.js +4 -4
- package/dist/runtime/pg/postgresjs.js +4 -4
- package/dist/runtime/plan.d.ts +1 -1
- package/dist/runtime/sql-fragment.d.ts +43 -0
- package/dist/runtime/tenancy/index.js +10 -10
- package/dist/runtime/topology.d.ts +1 -1
- package/dist/runtime/traits/index.js +15 -16
- package/dist/runtime/types.d.ts +15 -1
- package/dist/runtime/validate/index.js +4 -4
- package/dist/shared/{mtaszv5a.js → 0wrea3jq.js} +102 -4
- package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
- package/dist/shared/{w79hsckn.js → 14x60fbf.js} +5 -5
- package/dist/shared/{ek2wt2dz.js → 16kvjebh.js} +4 -4
- package/dist/shared/{svncdeh5.js → 195pzzzz.js} +8 -8
- package/dist/shared/{gzaveazc.js → 1d9q9cv2.js} +29 -2
- package/dist/shared/{jvd0mqag.js → 3449rcae.js} +5 -5
- package/dist/shared/{14vx95q4.js → 35q0n9tz.js} +7 -7
- package/dist/shared/3bb7wsqt.js +99 -0
- package/dist/shared/{y6njgyda.js → 3t6kw83m.js} +2 -2
- package/dist/shared/{81ebdx9p.js → 4m6hskg8.js} +4 -4
- package/dist/shared/{xhfsfkgk.js → 4vbf83xx.js} +9 -2
- package/dist/shared/{bg3rym3g.js → 63f4ksbz.js} +2 -2
- package/dist/shared/{pt94kz7f.js → 6m78c8ss.js} +1 -1
- package/dist/shared/{5e3tf63j.js → 760ppr76.js} +14 -6
- package/dist/shared/{zm0ptry0.js → 7ghwamrf.js} +1 -1
- package/dist/shared/{xnxsed62.js → 9dr2qnx7.js} +14 -14
- package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
- package/dist/shared/{q5c6ngn3.js → a62rb2da.js} +1 -1
- package/dist/shared/{kb2sdhfb.js → ae4j5f42.js} +17 -1
- package/dist/shared/agsfb86s.js +233 -0
- package/dist/shared/{7k9grvf6.js → b6d6p0zc.js} +5 -5
- package/dist/shared/{tbrvgw6z.js → bah9nbg3.js} +17 -16
- package/dist/shared/{5fe3kbsh.js → bnby0esn.js} +1 -1
- package/dist/shared/bsek72fg.js +225 -0
- package/dist/shared/{1w508jbr.js → bxas03mq.js} +21 -17
- package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
- package/dist/shared/{tsvww22q.js → dpc2r7rb.js} +7 -7
- package/dist/shared/{vb6qfyve.js → e8zyaqvj.js} +2 -2
- package/dist/shared/{hyh73qk6.js → ecn8mfdq.js} +5 -5
- package/dist/shared/{gs74dbj5.js → f4jy1j7x.js} +27 -14
- package/dist/shared/{ttsqgp4p.js → fjpnhqan.js} +2 -2
- package/dist/shared/{xjk7hnn5.js → g5yc06ka.js} +2 -2
- package/dist/shared/{w72kgg4q.js → hfqmpasr.js} +6 -6
- package/dist/shared/{kr0jzbw2.js → hm5f8jby.js} +7 -7
- package/dist/shared/{dkxgzaqd.js → hqpxf4a4.js} +1 -1
- package/dist/shared/{cn957f8d.js → jebgrkeq.js} +3 -3
- package/dist/shared/{wa07eas9.js → jp36k7dp.js} +11 -11
- package/dist/shared/jx2m62cs.js +96 -0
- package/dist/shared/{sfz1ksn6.js → k86n8vq3.js} +2 -2
- package/dist/shared/{67txcrcw.js → kgwp4jdd.js} +4 -4
- package/dist/shared/{8skf0cam.js → kj9d8maq.js} +1 -1
- package/dist/shared/{aytqh5y2.js → m4xff2a6.js} +2 -2
- package/dist/shared/{zp9fmend.js → mfedzr74.js} +4 -4
- package/dist/shared/{ax7qv55k.js → mkrn359n.js} +60 -11
- package/dist/shared/{m6p12kbr.js → mnvjvqyp.js} +10 -10
- package/dist/shared/{1qa0qajz.js → mtw6jz76.js} +1 -1
- package/dist/shared/{1est4ezg.js → n05z9nwz.js} +3 -3
- package/dist/shared/{pbp1ss85.js → n0jmpgj1.js} +2 -2
- package/dist/shared/{ktz42yez.js → n41w4fbz.js} +5 -5
- package/dist/shared/{n816peh1.js → n454kcnw.js} +1 -1
- package/dist/shared/n7kg8mmx.js +61 -0
- package/dist/shared/{g6evj1j3.js → needfe47.js} +1 -1
- package/dist/shared/{2shdbn8q.js → njga14v4.js} +9 -9
- package/dist/shared/{vqrjpcqn.js → nmnsgj7x.js} +1 -1
- package/dist/shared/{b5pftnn2.js → p3xbdcvt.js} +14 -18
- package/dist/shared/{te5as7z7.js → p5nh3r8q.js} +3 -3
- package/dist/shared/{p6qc5gcp.js → pan0370z.js} +6 -6
- package/dist/shared/{79dt02vc.js → q0cqt2sp.js} +1 -1
- package/dist/shared/{5v3xf80k.js → qd9hhd8f.js} +1 -1
- package/dist/shared/{bm22fvzr.js → qfw14tna.js} +2 -2
- package/dist/shared/{9s0ypp87.js → sjk86yrx.js} +1 -1
- package/dist/shared/{3v7t1yrv.js → th3be82n.js} +2 -2
- package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
- package/dist/shared/{vczs8gd4.js → v1wad97q.js} +2 -2
- package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
- package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
- package/dist/shared/{bz84tkzm.js → wcrheftc.js} +2 -2
- package/dist/shared/{ab9gmbwy.js → wvdjznah.js} +5 -5
- package/dist/shared/{7mnme5tn.js → wz2a78mp.js} +1 -1
- package/dist/shared/{9y3mmmh1.js → xfhe73sb.js} +1 -1
- package/dist/shared/{je4axnm8.js → z581d7ny.js} +2 -2
- package/dist/shared/{x933k9a3.js → zbqbmmrp.js} +10 -10
- package/dist/shared/{rs73fca9.js → zgex00fd.js} +6 -6
- package/dist/shared/{jznfax0y.js → zq1he88x.js} +4 -4
- package/dist/tooling/cli.js +26 -13
- package/dist/tooling/driver-run.js +4971 -0
- package/dist/tooling/driver-test.d.ts +36 -0
- package/dist/tooling/migrate/commands.d.ts +2 -2
- package/dist/tooling/migrate/index.js +9 -9
- package/dist/tooling/migrate/project.d.ts +3 -0
- package/dist/tooling/shared/03k6res6.js +210 -0
- package/dist/tooling/shared/08kemxjd.js +10 -0
- package/dist/tooling/shared/2revefqt.js +209 -0
- package/dist/tooling/shared/2wtvc7rw.js +1425 -0
- package/dist/tooling/shared/345tbc2k.js +16 -0
- package/dist/tooling/shared/3m1hkg7z.js +344 -0
- package/dist/tooling/shared/3rrw5w8f.js +81 -0
- package/dist/tooling/shared/3tq8pnb8.js +131 -0
- package/dist/tooling/shared/417zdsk7.js +194 -0
- package/dist/tooling/shared/4d2w25vw.js +40 -0
- package/dist/tooling/shared/54tqkxja.js +51 -0
- package/dist/tooling/shared/5bvw2nev.js +12 -0
- package/dist/tooling/shared/6nyfyw70.js +231 -0
- package/dist/tooling/shared/72fyg4zv.js +160 -0
- package/dist/tooling/shared/733a1tq3.js +38 -0
- package/dist/tooling/shared/7ae7rjmn.js +20 -0
- package/dist/tooling/shared/7kms6fvj.js +20 -0
- package/dist/tooling/shared/8sqrsw3s.js +49 -0
- package/dist/tooling/shared/96ps4g1z.js +32 -0
- package/dist/tooling/shared/9kazs5p6.js +195 -0
- package/dist/tooling/shared/9xzm7hjg.js +38 -0
- package/dist/tooling/shared/a6pp9d12.js +49 -0
- package/dist/tooling/shared/a7q7t4n3.js +22 -0
- package/dist/tooling/shared/aftb2mwr.js +18 -0
- package/dist/tooling/shared/bz2dqhab.js +311 -0
- package/dist/tooling/shared/cmptmb4f.js +12 -0
- package/dist/tooling/shared/ddjtfgnx.js +177 -0
- package/dist/tooling/shared/djydjpqt.js +261 -0
- package/dist/tooling/shared/dw08f3m8.js +9 -0
- package/dist/tooling/shared/dy672fz6.js +16 -0
- package/dist/tooling/shared/dzx85q70.js +66 -0
- package/dist/tooling/shared/ec71zqgt.js +270 -0
- package/dist/tooling/shared/ep8zh3bk.js +6 -0
- package/dist/tooling/shared/f9mphxej.js +3789 -0
- package/dist/tooling/shared/fb9k2qwd.js +89 -0
- package/dist/tooling/shared/g9ad4n80.js +211 -0
- package/dist/tooling/shared/gfvtj6d0.js +94 -0
- package/dist/tooling/shared/gmcf9cxf.js +294 -0
- package/dist/tooling/shared/htnaj77v.js +17 -0
- package/dist/tooling/shared/j9t5s12a.js +7 -0
- package/dist/tooling/shared/jne7b93p.js +42 -0
- package/dist/tooling/shared/ma2340rx.js +118 -0
- package/dist/tooling/shared/mtrqn2hn.js +505 -0
- package/dist/tooling/shared/n4jqhpqz.js +27 -0
- package/dist/tooling/shared/nf7jmhfa.js +20 -0
- package/dist/tooling/shared/p7f08ktn.js +332 -0
- package/dist/tooling/shared/ppnnnvj8.js +13 -0
- package/dist/tooling/shared/pqy21k24.js +312 -0
- package/dist/tooling/shared/pw8fgahx.js +69 -0
- package/dist/tooling/shared/pwsytxm5.js +17 -0
- package/dist/tooling/shared/rf83gr2d.js +94 -0
- package/dist/tooling/shared/rq5kk8j6.js +401 -0
- package/dist/tooling/shared/rs1jb051.js +12 -0
- package/dist/tooling/shared/smn6kz1p.js +157 -0
- package/dist/tooling/shared/spk1jg3r.js +1696 -0
- package/dist/tooling/shared/tn8gay14.js +143 -0
- package/dist/tooling/shared/vraj6d74.js +42 -0
- package/dist/tooling/shared/vs0t6qt8.js +64 -0
- package/dist/tooling/shared/vx86qjv8.js +150 -0
- package/dist/tooling/shared/w7qe8sj1.js +140 -0
- package/dist/tooling/shared/wt7j7nf6.js +15 -0
- package/dist/tooling/shared/wwnekq5n.js +6 -0
- package/dist/tooling/shared/xhrnjch9.js +185 -0
- package/dist/tooling/shared/xjs6zqtc.js +190 -0
- package/dist/tooling/shared/y031jct9.js +16 -0
- package/dist/tooling/shared/y5656f0e.js +233 -0
- package/dist/tooling/shared/yfr8hzhm.js +604 -0
- package/dist/tooling/shared/yk9mp7vb.js +250 -0
- package/dist/tooling/shared/yw30vnq2.js +139 -0
- package/dist/tooling/shared/z8d7ptht.js +618 -0
- package/dist/tooling/shared/zhwnfyb2.js +9 -0
- package/dist/tooling/shared/zvnhh1n0.js +198 -0
- package/dist/tooling/testing/index.js +3 -3
- package/package.json +14 -2
- package/dist/shared/y34a8714.js +0 -150
- package/dist/shared/zy8r7qvz.js +0 -116
- package/dist/shared/{ywr8hmey.js → 606g0nbf.js} +3 -3
- package/dist/shared/{rpycarcr.js → gcefca6p.js} +4 -4
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
noticeBuffer,
|
|
3
|
+
WireSession
|
|
4
|
+
} from "./yw30vnq2.js";
|
|
5
|
+
import {
|
|
6
|
+
NODE_POSTGRES_CAPABILITIES,
|
|
7
|
+
driverErrors,
|
|
8
|
+
rejectClosed,
|
|
9
|
+
mapFailure,
|
|
10
|
+
runCall
|
|
11
|
+
} from "./xhrnjch9.js";
|
|
12
|
+
|
|
13
|
+
// src/adapters/pg/nodepostgres.ts
|
|
14
|
+
import net from "node:net";
|
|
15
|
+
import pg from "pg";
|
|
16
|
+
var CANCEL_CODE = 80877102;
|
|
17
|
+
var identity = (value) => value;
|
|
18
|
+
function armDriverError2(source, handle = () => {}) {
|
|
19
|
+
source.on("error", handle);
|
|
20
|
+
}
|
|
21
|
+
var WIRE = {
|
|
22
|
+
getTypeParser() {
|
|
23
|
+
return identity;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function open4(config) {
|
|
27
|
+
const max = config.max ?? 10;
|
|
28
|
+
const acquireMs = config.timeouts?.acquire;
|
|
29
|
+
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
30
|
+
const inflight = new Set;
|
|
31
|
+
const notices = noticeBuffer();
|
|
32
|
+
let closed = false;
|
|
33
|
+
const isClosed = () => closed;
|
|
34
|
+
const named = config.prepared === "named";
|
|
35
|
+
const pool = new pg.Pool({
|
|
36
|
+
connectionString: config.url,
|
|
37
|
+
max,
|
|
38
|
+
idleTimeoutMillis: 0,
|
|
39
|
+
allowExitOnIdle: true,
|
|
40
|
+
connectionTimeoutMillis: 5000,
|
|
41
|
+
application_name: "okmodel",
|
|
42
|
+
types: WIRE,
|
|
43
|
+
...config.ssl !== undefined ? { ssl: config.ssl } : {},
|
|
44
|
+
...config.searchPath !== undefined ? { options: `-c search_path=${config.searchPath}` } : {}
|
|
45
|
+
});
|
|
46
|
+
armDriverError2(pool);
|
|
47
|
+
pool.on("connect", (client) => {
|
|
48
|
+
client.on("notice", (notice) => {
|
|
49
|
+
notices.push(notice);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
const root = new WireSession((text, params) => send3(pool, text, params, named, undefined), notices, isClosed, true, () => {
|
|
53
|
+
counters.busy += 1;
|
|
54
|
+
}, () => {
|
|
55
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
56
|
+
}, inflight);
|
|
57
|
+
const held = { pool, acquireMs, counters, notices, named, isClosed };
|
|
58
|
+
const checkout = () => closed ? rejectClosed() : import("./tn8gay14.js").then((mod) => mod.checkout(held));
|
|
59
|
+
return {
|
|
60
|
+
capabilities: NODE_POSTGRES_CAPABILITIES,
|
|
61
|
+
execute(text, params, options) {
|
|
62
|
+
return runCall(closed, options, async (watch) => {
|
|
63
|
+
if (watch === undefined)
|
|
64
|
+
return root.query(text, params, undefined);
|
|
65
|
+
const client = await connectClient2(pool, acquireMs, counters);
|
|
66
|
+
counters.busy += 1;
|
|
67
|
+
const session = new WireSession((statement, values) => send3(client, statement, values, named, client), notices, isClosed, true, () => {
|
|
68
|
+
return;
|
|
69
|
+
}, () => {
|
|
70
|
+
return;
|
|
71
|
+
}, inflight);
|
|
72
|
+
try {
|
|
73
|
+
return await session.query(text, params, watch);
|
|
74
|
+
} finally {
|
|
75
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
76
|
+
client.release();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
async batch(statements, options) {
|
|
81
|
+
const connection = await checkout();
|
|
82
|
+
try {
|
|
83
|
+
return await connection.batch(statements, options);
|
|
84
|
+
} finally {
|
|
85
|
+
await connection.release();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
reserve: () => checkout(),
|
|
89
|
+
stream(text, params) {
|
|
90
|
+
return async function* () {
|
|
91
|
+
const { streamRows } = await import("./tn8gay14.js");
|
|
92
|
+
yield* streamRows(checkout, text, params);
|
|
93
|
+
}();
|
|
94
|
+
},
|
|
95
|
+
listen(channel, onNotify) {
|
|
96
|
+
if (closed)
|
|
97
|
+
return rejectClosed();
|
|
98
|
+
return import("./tn8gay14.js").then((mod) => mod.listen(held, channel, onNotify));
|
|
99
|
+
},
|
|
100
|
+
cancel() {
|
|
101
|
+
for (const pending of inflight)
|
|
102
|
+
pending.cancel?.();
|
|
103
|
+
},
|
|
104
|
+
stats: () => statsOf(counters, max),
|
|
105
|
+
async close() {
|
|
106
|
+
closed = true;
|
|
107
|
+
await pool.end();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function send3(runner, text, params, named, client) {
|
|
112
|
+
const query = {
|
|
113
|
+
text,
|
|
114
|
+
rowMode: "array",
|
|
115
|
+
types: WIRE,
|
|
116
|
+
...params !== undefined && params.length > 0 ? { values: params } : {},
|
|
117
|
+
...named ? { name: statementName(text) } : {}
|
|
118
|
+
};
|
|
119
|
+
const pending = runner.query(query);
|
|
120
|
+
if (client !== undefined)
|
|
121
|
+
pending.cancel = () => cancelBackend(client);
|
|
122
|
+
return pending;
|
|
123
|
+
}
|
|
124
|
+
var names = new Map;
|
|
125
|
+
function statementName(text) {
|
|
126
|
+
const existing = names.get(text);
|
|
127
|
+
if (existing !== undefined)
|
|
128
|
+
return existing;
|
|
129
|
+
const name = `okm_${String(names.size)}`;
|
|
130
|
+
names.set(text, name);
|
|
131
|
+
return name;
|
|
132
|
+
}
|
|
133
|
+
function cancelBackend(client) {
|
|
134
|
+
const pid = client.processID;
|
|
135
|
+
const secret = client.secretKey;
|
|
136
|
+
if (typeof pid !== "number" || typeof secret !== "number")
|
|
137
|
+
return;
|
|
138
|
+
const socket = client.host.startsWith("/") === true ? net.connect(client.host) : net.connect(client.port, client.host);
|
|
139
|
+
socket.unref();
|
|
140
|
+
socket.once("error", () => {
|
|
141
|
+
socket.destroy();
|
|
142
|
+
});
|
|
143
|
+
socket.once("connect", () => {
|
|
144
|
+
const bytes = Buffer.alloc(16);
|
|
145
|
+
bytes.writeInt32BE(16, 0);
|
|
146
|
+
bytes.writeInt32BE(CANCEL_CODE, 4);
|
|
147
|
+
bytes.writeInt32BE(pid, 8);
|
|
148
|
+
bytes.writeInt32BE(secret, 12);
|
|
149
|
+
socket.end(bytes);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function connectClient2(pool, acquireMs, counters) {
|
|
153
|
+
counters.waiting += 1;
|
|
154
|
+
let settled = false;
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
let timer;
|
|
157
|
+
if (acquireMs !== undefined) {
|
|
158
|
+
timer = setTimeout(() => {
|
|
159
|
+
settled = true;
|
|
160
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
161
|
+
driverErrors().then((errors) => {
|
|
162
|
+
reject(errors.acquireTimeout());
|
|
163
|
+
});
|
|
164
|
+
}, acquireMs);
|
|
165
|
+
}
|
|
166
|
+
pool.connect().then((client) => {
|
|
167
|
+
if (settled) {
|
|
168
|
+
client.release();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (timer !== undefined)
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
174
|
+
resolve(client);
|
|
175
|
+
}, (error) => {
|
|
176
|
+
if (settled)
|
|
177
|
+
return;
|
|
178
|
+
if (timer !== undefined)
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
181
|
+
mapFailure(error).then(reject);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function statsOf(counters, size) {
|
|
186
|
+
return {
|
|
187
|
+
size,
|
|
188
|
+
idle: Math.max(0, size - counters.reserved - counters.busy),
|
|
189
|
+
inflight: counters.busy + counters.reservedBusy,
|
|
190
|
+
waiting: counters.waiting
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { armDriverError2, open4, send3, connectClient2 };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rejectClosed
|
|
3
|
+
} from "./xhrnjch9.js";
|
|
4
|
+
import {
|
|
5
|
+
isConnectionLost
|
|
6
|
+
} from "./f9mphxej.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/pg/reserved.ts
|
|
9
|
+
var RESET_ALL = "RESET ALL";
|
|
10
|
+
var UNLOCK = "SELECT pg_advisory_unlock_all()";
|
|
11
|
+
async function resetSession2(depth, run) {
|
|
12
|
+
if (depth > 0)
|
|
13
|
+
await run("ROLLBACK").catch(() => {
|
|
14
|
+
return;
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
await run(RESET_ALL);
|
|
18
|
+
await run(UNLOCK);
|
|
19
|
+
} catch {
|
|
20
|
+
await run("ROLLBACK").catch(() => {
|
|
21
|
+
return;
|
|
22
|
+
});
|
|
23
|
+
await run(RESET_ALL);
|
|
24
|
+
await run(UNLOCK);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function resetQueried2(session) {
|
|
28
|
+
await resetSession2(session.inTransaction() ? 1 : 0, (text) => text === "ROLLBACK" ? session.rollback() : session.query(text, undefined, undefined));
|
|
29
|
+
}
|
|
30
|
+
function refuseWhenLost2(lost, run) {
|
|
31
|
+
if (lost.on)
|
|
32
|
+
return rejectClosed();
|
|
33
|
+
return run().catch((error) => {
|
|
34
|
+
if (isConnectionLost(error))
|
|
35
|
+
lost.on = true;
|
|
36
|
+
throw error;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { resetSession2, resetQueried2, refuseWhenLost2 };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/adapters/pg/watch.ts
|
|
2
|
+
var callers = new WeakMap;
|
|
3
|
+
function listenOn(signal, onAbort) {
|
|
4
|
+
let set = callers.get(signal);
|
|
5
|
+
if (set === undefined) {
|
|
6
|
+
const created = new Set;
|
|
7
|
+
callers.set(signal, created);
|
|
8
|
+
signal.addEventListener("abort", () => {
|
|
9
|
+
for (const each of created)
|
|
10
|
+
each();
|
|
11
|
+
}, { once: true });
|
|
12
|
+
set = created;
|
|
13
|
+
}
|
|
14
|
+
const registered = set;
|
|
15
|
+
registered.add(onAbort);
|
|
16
|
+
return () => {
|
|
17
|
+
registered.delete(onAbort);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function openWatch(options) {
|
|
21
|
+
let kind;
|
|
22
|
+
const controller = new AbortController;
|
|
23
|
+
const onAbort = () => {
|
|
24
|
+
if (kind === undefined)
|
|
25
|
+
kind = "cancelled";
|
|
26
|
+
controller.abort();
|
|
27
|
+
};
|
|
28
|
+
const release = options.signal === undefined ? undefined : listenOn(options.signal, onAbort);
|
|
29
|
+
let timer;
|
|
30
|
+
if (options.timeout !== undefined) {
|
|
31
|
+
timer = setTimeout(() => {
|
|
32
|
+
if (kind === undefined)
|
|
33
|
+
kind = "timeout";
|
|
34
|
+
controller.abort();
|
|
35
|
+
}, options.timeout);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
signal: controller.signal,
|
|
39
|
+
finish() {
|
|
40
|
+
if (timer !== undefined)
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
release?.();
|
|
43
|
+
},
|
|
44
|
+
reason() {
|
|
45
|
+
return kind;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
openWatch
|
|
51
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
creationOrder2,
|
|
3
|
+
catalogHash2,
|
|
4
|
+
loadTrustedCatalog2,
|
|
5
|
+
catalogFileText2
|
|
6
|
+
} from "./f9mphxej.js";
|
|
7
|
+
export {
|
|
8
|
+
catalogFileText2 as catalogFileText,
|
|
9
|
+
catalogHash2 as catalogHash,
|
|
10
|
+
creationOrder2 as creationOrder,
|
|
11
|
+
loadTrustedCatalog2 as loadTrustedCatalog
|
|
12
|
+
};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
touchFields,
|
|
3
|
+
fieldSealed
|
|
4
|
+
} from "./spk1jg3r.js";
|
|
5
|
+
import {
|
|
6
|
+
throwNamed,
|
|
7
|
+
projectExpr,
|
|
8
|
+
quote,
|
|
9
|
+
list,
|
|
10
|
+
isRecord,
|
|
11
|
+
registerFailFix,
|
|
12
|
+
fail2
|
|
13
|
+
} from "./f9mphxej.js";
|
|
14
|
+
|
|
15
|
+
// src/runtime/conflict.ts
|
|
16
|
+
registerFailFix("OKM1104", "Set on to the columns of a unique constraint or the primary key.");
|
|
17
|
+
registerFailFix("OKM1190", "Remove the guarded field. Input cannot set it.");
|
|
18
|
+
var NO_ALLOW = new Set;
|
|
19
|
+
function readConflict(table, value, allow = NO_ALLOW, tenantKey) {
|
|
20
|
+
if (value === undefined || value === "error")
|
|
21
|
+
return;
|
|
22
|
+
if (value === "ignore")
|
|
23
|
+
return { kind: "ignore", columns: [], update: [] };
|
|
24
|
+
if (!isRecord(value)) {
|
|
25
|
+
fail2("OKM1120", 'onConflict must be "error", "ignore", { on, update }, or { on, return: true }.');
|
|
26
|
+
}
|
|
27
|
+
const keys = Object.keys(value);
|
|
28
|
+
const update = value.update;
|
|
29
|
+
const ret = value.return;
|
|
30
|
+
if (update !== undefined && ret !== undefined) {
|
|
31
|
+
fail2("OKM1120", "onConflict takes update or return, not both.");
|
|
32
|
+
}
|
|
33
|
+
if (ret === true) {
|
|
34
|
+
rejectConflictKeys(keys, ["on", "return"]);
|
|
35
|
+
return { kind: "return", columns: uniqueColumns(table, value.on, tenantKey), update: [] };
|
|
36
|
+
}
|
|
37
|
+
if (update !== undefined) {
|
|
38
|
+
rejectConflictKeys(keys, ["on", "update"]);
|
|
39
|
+
return {
|
|
40
|
+
kind: "update",
|
|
41
|
+
columns: uniqueColumns(table, value.on, tenantKey),
|
|
42
|
+
update: updateColumns(table, update, allow)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
fail2("OKM1120", 'onConflict must be "error", "ignore", { on, update }, or { on, return: true }.');
|
|
46
|
+
}
|
|
47
|
+
function finishInsert(head, returning, params, plan, table) {
|
|
48
|
+
if (plan.kind === "ignore") {
|
|
49
|
+
return { text: `${head} on conflict do nothing${returning}`, params: [...params] };
|
|
50
|
+
}
|
|
51
|
+
const target = plan.columns.map((column) => quote(column.sql)).join(", ");
|
|
52
|
+
if (plan.kind === "update") {
|
|
53
|
+
const assignments = plan.update.map((column) => `${quote(column.sql)} = excluded.${quote(column.sql)}`);
|
|
54
|
+
const touch = touchFields(table.model);
|
|
55
|
+
if (touch !== undefined) {
|
|
56
|
+
for (const field of touch) {
|
|
57
|
+
const column = table.columns.get(field);
|
|
58
|
+
if (column !== undefined)
|
|
59
|
+
assignments.push(`${quote(column.sql)} = now()`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
text: `${head} on conflict (${target})${conflictWhere(table, plan.columns)} do update set ${assignments.join(", ")}${returning}`,
|
|
64
|
+
params: [...params]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
text: `${head} on conflict (${target})${conflictWhere(table, plan.columns)} do nothing${returning}`,
|
|
69
|
+
params: [...params]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function lookupExisting(table, keys, returningColumns, keyRows) {
|
|
73
|
+
const params = [];
|
|
74
|
+
const tuples = [];
|
|
75
|
+
for (const row of keyRows) {
|
|
76
|
+
const slots = [];
|
|
77
|
+
for (let index = 0;index < keys.length; index += 1) {
|
|
78
|
+
const column = keys[index];
|
|
79
|
+
if (column === undefined)
|
|
80
|
+
continue;
|
|
81
|
+
params.push(row[index] ?? null);
|
|
82
|
+
slots.push(`$${String(params.length)}::${column.dataType}`);
|
|
83
|
+
}
|
|
84
|
+
tuples.push(keys.length === 1 ? slots[0] ?? "null" : `(${slots.join(", ")})`);
|
|
85
|
+
}
|
|
86
|
+
const left = keys.length === 1 ? `t.${quote(keys[0]?.sql ?? "")}` : `(${keys.map((column) => `t.${quote(column.sql)}`).join(", ")})`;
|
|
87
|
+
const projected = returningColumns.map((column) => projectExpr(`t.${quote(column.sql)}`, column.dataType)).join(", ");
|
|
88
|
+
const text = `select ${projected} from ${quote(table.model.sql)} t where ${left} in (${tuples.join(", ")})${activeAnd(table, keys)}`;
|
|
89
|
+
return { text, params };
|
|
90
|
+
}
|
|
91
|
+
function activeAnd(table, columns) {
|
|
92
|
+
const clause = conflictWhere(table, columns);
|
|
93
|
+
if (clause === "")
|
|
94
|
+
return "";
|
|
95
|
+
return ` and t.${clause.replace(/^ where /, "")}`;
|
|
96
|
+
}
|
|
97
|
+
function conflictWhere(table, columns) {
|
|
98
|
+
const archive = table.model.archive;
|
|
99
|
+
if (archive === undefined || samePrimary(table, columns))
|
|
100
|
+
return "";
|
|
101
|
+
return ` where ${quote(archive.at)} is null`;
|
|
102
|
+
}
|
|
103
|
+
function samePrimary(table, columns) {
|
|
104
|
+
const primary = table.model.primary;
|
|
105
|
+
if (columns.length !== primary.length)
|
|
106
|
+
return false;
|
|
107
|
+
for (const field of primary) {
|
|
108
|
+
let found = false;
|
|
109
|
+
for (const column of columns)
|
|
110
|
+
if (column.field === field)
|
|
111
|
+
found = true;
|
|
112
|
+
if (!found)
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
function uniqueColumns(table, on, tenantKey) {
|
|
118
|
+
const names = conflictNames(on);
|
|
119
|
+
const keys = keyList(tenantKey);
|
|
120
|
+
for (const unique of table.model.uniques) {
|
|
121
|
+
const fields = fieldsOf(unique, names, keys);
|
|
122
|
+
if (fields === undefined)
|
|
123
|
+
continue;
|
|
124
|
+
const columns = [];
|
|
125
|
+
for (const name of fields) {
|
|
126
|
+
const column = table.columns.get(name);
|
|
127
|
+
if (column === undefined) {
|
|
128
|
+
fail2("OKM1104", `onConflict column ${name} is not on ${table.model.name}.`);
|
|
129
|
+
}
|
|
130
|
+
columns.push(column);
|
|
131
|
+
}
|
|
132
|
+
return columns;
|
|
133
|
+
}
|
|
134
|
+
const accepted = acceptedConstraints(table.model, keys);
|
|
135
|
+
const implicit = keys.length === 0 ? "" : ` The tenant key ${keys.join(", ")} is part of each one and is not named here.`;
|
|
136
|
+
throwNamed("OKM1104", names.join(", "), accepted, `onConflict on ${table.model.name} names ${names.join(", ")}, which is not a unique constraint. Accepted: ${list(accepted)}.${implicit}`);
|
|
137
|
+
}
|
|
138
|
+
function acceptedConstraints(model, keys) {
|
|
139
|
+
const shown = new Set;
|
|
140
|
+
for (const fields of model.uniques) {
|
|
141
|
+
const named = keys.length === 0 ? fields : fields.filter((field) => !keys.includes(field));
|
|
142
|
+
if (named.length === 0)
|
|
143
|
+
continue;
|
|
144
|
+
shown.add(named.length > 1 ? `(${named.join(", ")})` : named.join(""));
|
|
145
|
+
}
|
|
146
|
+
return [...shown];
|
|
147
|
+
}
|
|
148
|
+
function updateColumns(table, value, allow) {
|
|
149
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
150
|
+
fail2("OKM1120", "onConflict update must name at least one column.");
|
|
151
|
+
}
|
|
152
|
+
const columns = [];
|
|
153
|
+
for (const name of value) {
|
|
154
|
+
if (typeof name !== "string")
|
|
155
|
+
fail2("OKM1120", "onConflict update must name columns.");
|
|
156
|
+
const column = table.columns.get(name);
|
|
157
|
+
if (column === undefined) {
|
|
158
|
+
throwNamed("OKM1120", name, table.names, `Field ${name} is not on ${table.model.name}. Accepted names: ${list(table.names)}.`);
|
|
159
|
+
}
|
|
160
|
+
if (fieldSealed(table.model, name) || column.guardUpdate || !column.writable && !(column.guarded && allow.has(name))) {
|
|
161
|
+
refuseWrite(table, column);
|
|
162
|
+
}
|
|
163
|
+
columns.push(column);
|
|
164
|
+
}
|
|
165
|
+
return columns;
|
|
166
|
+
}
|
|
167
|
+
function conflictNames(on) {
|
|
168
|
+
if (typeof on === "string")
|
|
169
|
+
return [on];
|
|
170
|
+
if (Array.isArray(on) && on.length > 0 && on.every((name) => typeof name === "string")) {
|
|
171
|
+
return on;
|
|
172
|
+
}
|
|
173
|
+
fail2("OKM1104", "onConflict on must name a unique constraint's columns.");
|
|
174
|
+
}
|
|
175
|
+
function fieldsOf(unique, names, tenantKeys) {
|
|
176
|
+
if (tenantKeys.some((key) => unique.includes(key))) {
|
|
177
|
+
const rest = [];
|
|
178
|
+
for (const field of unique) {
|
|
179
|
+
if (!tenantKeys.includes(field))
|
|
180
|
+
rest.push(field);
|
|
181
|
+
}
|
|
182
|
+
if (!same(rest, names))
|
|
183
|
+
return;
|
|
184
|
+
return unique;
|
|
185
|
+
}
|
|
186
|
+
if (!same(unique, names))
|
|
187
|
+
return;
|
|
188
|
+
return names;
|
|
189
|
+
}
|
|
190
|
+
function keyList(tenantKey) {
|
|
191
|
+
if (tenantKey === undefined)
|
|
192
|
+
return [];
|
|
193
|
+
if (typeof tenantKey === "string")
|
|
194
|
+
return [tenantKey];
|
|
195
|
+
return tenantKey;
|
|
196
|
+
}
|
|
197
|
+
function same(unique, names) {
|
|
198
|
+
if (unique.length !== names.length)
|
|
199
|
+
return false;
|
|
200
|
+
const left = [...unique].sort();
|
|
201
|
+
const right = [...names].sort();
|
|
202
|
+
for (let index = 0;index < left.length; index += 1) {
|
|
203
|
+
if (left[index] !== right[index])
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
function rejectConflictKeys(keys, accepted) {
|
|
209
|
+
for (const key of keys) {
|
|
210
|
+
if (!accepted.includes(key)) {
|
|
211
|
+
throwNamed("OKM1120", key, accepted, `Option ${key} is not accepted by onConflict. Accepted options: ${list(accepted)}.`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function refuseWrite(table, column) {
|
|
216
|
+
if (fieldSealed(table.model, column.field)) {
|
|
217
|
+
fail2("OKM1190", `Field ${table.model.name}.${column.field} is set by a trait. Input cannot set it.`);
|
|
218
|
+
}
|
|
219
|
+
if (column.guardUpdate) {
|
|
220
|
+
fail2("OKM1190", `Field ${table.model.name}.${column.field} is a primary key. Input cannot change it.`);
|
|
221
|
+
}
|
|
222
|
+
if (column.guarded) {
|
|
223
|
+
fail2("OKM1190", `Field ${table.model.name}.${column.field} is guarded. Input cannot set it.`);
|
|
224
|
+
}
|
|
225
|
+
fail2("OKM1120", `Field ${table.model.name}.${column.field} cannot be written.`);
|
|
226
|
+
}
|
|
227
|
+
export {
|
|
228
|
+
finishInsert,
|
|
229
|
+
lookupExisting,
|
|
230
|
+
readConflict
|
|
231
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OkmError,
|
|
3
|
+
isOperator,
|
|
4
|
+
operatorValue,
|
|
5
|
+
safetyInstalled,
|
|
6
|
+
runSafety
|
|
7
|
+
} from "./f9mphxej.js";
|
|
8
|
+
|
|
9
|
+
// src/runtime/exposure.ts
|
|
10
|
+
var REDACTED = "[redacted]";
|
|
11
|
+
var namesOf = new WeakMap;
|
|
12
|
+
function redactView(schema, view, call) {
|
|
13
|
+
const names = concealedNames(schema);
|
|
14
|
+
const secrets = new Set;
|
|
15
|
+
harvest(schema, call.where, names, undefined, secrets);
|
|
16
|
+
harvest(schema, call.include, names, undefined, secrets);
|
|
17
|
+
const model = schema.model[call.table];
|
|
18
|
+
const rules = model === undefined ? view.rules : [...view.rules, ...exposureRules(model, call)];
|
|
19
|
+
if (safetyInstalled())
|
|
20
|
+
runSafety(rules, undefined);
|
|
21
|
+
return {
|
|
22
|
+
...view,
|
|
23
|
+
intent: {
|
|
24
|
+
...view.intent,
|
|
25
|
+
where: walk(view.intent.where, names),
|
|
26
|
+
include: walk(view.intent.include, names)
|
|
27
|
+
},
|
|
28
|
+
rules,
|
|
29
|
+
sql: {
|
|
30
|
+
...view.sql,
|
|
31
|
+
params: view.sql.params.map((value) => value !== null && secrets.has(value) ? REDACTED : value)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function scrubCall(error, schema, call) {
|
|
36
|
+
const names = concealedNames(schema);
|
|
37
|
+
const secrets = new Set;
|
|
38
|
+
harvest(schema, call.where, names, undefined, secrets);
|
|
39
|
+
harvest(schema, call.include, names, undefined, secrets);
|
|
40
|
+
let message = error.message;
|
|
41
|
+
for (const secret of secrets) {
|
|
42
|
+
if (secret.length < 4 || !message.includes(secret))
|
|
43
|
+
continue;
|
|
44
|
+
message = message.replaceAll(secret, REDACTED);
|
|
45
|
+
}
|
|
46
|
+
if (message === error.message)
|
|
47
|
+
return error;
|
|
48
|
+
return new OkmError(error.code, message, {
|
|
49
|
+
kind: error.kind,
|
|
50
|
+
...error.table !== undefined ? { table: error.table } : {},
|
|
51
|
+
...error.columns.length > 0 ? { columns: error.columns } : {},
|
|
52
|
+
fix: error.fix
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function concealedNames(schema) {
|
|
56
|
+
const cached = namesOf.get(schema);
|
|
57
|
+
if (cached !== undefined)
|
|
58
|
+
return cached;
|
|
59
|
+
const names = new Set;
|
|
60
|
+
for (const model of Object.values(schema.model)) {
|
|
61
|
+
if (model.conceal !== true)
|
|
62
|
+
continue;
|
|
63
|
+
for (const column of model.columns) {
|
|
64
|
+
if (column.hidden || column.sensitive)
|
|
65
|
+
names.add(column.field);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
namesOf.set(schema, names);
|
|
69
|
+
return names;
|
|
70
|
+
}
|
|
71
|
+
function exposureRules(model, call) {
|
|
72
|
+
const named = namedSelect(call.select);
|
|
73
|
+
const source = model.source;
|
|
74
|
+
const rules = [];
|
|
75
|
+
for (const column of model.columns) {
|
|
76
|
+
if (column.hidden && (named === undefined || !named.has(column.field))) {
|
|
77
|
+
rules.push({
|
|
78
|
+
rule: "hidden",
|
|
79
|
+
contribution: `hidden ${model.name}.${column.field} excluded`,
|
|
80
|
+
provenance: "catalog",
|
|
81
|
+
...source !== undefined ? { source } : {}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (column.sensitive) {
|
|
85
|
+
rules.push({
|
|
86
|
+
rule: "sensitive",
|
|
87
|
+
contribution: `sensitive ${model.name}.${column.field} redacted`,
|
|
88
|
+
provenance: "catalog",
|
|
89
|
+
...source !== undefined ? { source } : {}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return rules;
|
|
94
|
+
}
|
|
95
|
+
function namedSelect(select) {
|
|
96
|
+
if (!Array.isArray(select))
|
|
97
|
+
return;
|
|
98
|
+
const names = new Set;
|
|
99
|
+
for (const name of select) {
|
|
100
|
+
if (typeof name === "string")
|
|
101
|
+
names.add(name);
|
|
102
|
+
}
|
|
103
|
+
return names;
|
|
104
|
+
}
|
|
105
|
+
function harvest(schema, value, names, key, into) {
|
|
106
|
+
if (Array.isArray(value)) {
|
|
107
|
+
for (const item of value)
|
|
108
|
+
harvest(schema, item, names, key, into);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (isOperator(value)) {
|
|
112
|
+
harvest(schema, operatorValue(value), names, key, into);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === "object" && value !== null) {
|
|
116
|
+
const record = value;
|
|
117
|
+
for (const child of Object.keys(record))
|
|
118
|
+
harvest(schema, record[child], names, child, into);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (key === undefined || !names.has(key))
|
|
122
|
+
return;
|
|
123
|
+
const encode = encodeOf(schema, key);
|
|
124
|
+
if (encode === undefined)
|
|
125
|
+
return;
|
|
126
|
+
try {
|
|
127
|
+
into.add(encode(value));
|
|
128
|
+
} catch {}
|
|
129
|
+
}
|
|
130
|
+
function encodeOf(schema, field) {
|
|
131
|
+
for (const model of Object.values(schema.model)) {
|
|
132
|
+
for (const column of model.columns) {
|
|
133
|
+
if (column.field === field && (column.hidden || column.sensitive)) {
|
|
134
|
+
return column.encode;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
function walk(value, names, key) {
|
|
141
|
+
if (Array.isArray(value))
|
|
142
|
+
return value.map((item) => walk(item, names, key));
|
|
143
|
+
if (typeof value === "object" && value !== null) {
|
|
144
|
+
const record = value;
|
|
145
|
+
if (typeof record.op === "string" && "value" in record) {
|
|
146
|
+
return { op: record.op, value: walk(record.value, names, key) };
|
|
147
|
+
}
|
|
148
|
+
const out = {};
|
|
149
|
+
for (const child of Object.keys(record))
|
|
150
|
+
out[child] = walk(record[child], names, child);
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
if (key !== undefined && names.has(key))
|
|
154
|
+
return REDACTED;
|
|
155
|
+
return value;
|
|
156
|
+
}
|
|
157
|
+
export {
|
|
158
|
+
redactView,
|
|
159
|
+
scrubCall
|
|
160
|
+
};
|