@factiii/runner 0.24.0 → 0.43.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/DISCLOSURE +174 -0
- package/README.md +87 -12
- package/dist/cli.js +83814 -40252
- package/dist/vault-client.js +876 -0
- package/dist/vault-db.js +858 -0
- package/embedder/app.py +331 -0
- package/embedder/clip_tokenizer.py +137 -0
- package/embedder/convert_clip.py +119 -0
- package/embedder/convert_onnx.py +129 -0
- package/embedder/convert_text.py +148 -0
- package/embedder/onnx_backend.py +48 -0
- package/embedder/overrides-onnx.txt +3 -0
- package/embedder/requirements-onnx.txt +22 -0
- package/embedder/requirements.txt +20 -0
- package/embedder/serve.py +241 -0
- package/embedder/text_tokenizer.py +34 -0
- package/native/simhid.m +7 -0
- package/native/simstream.m +7 -0
- package/package.json +28 -14
- package/plugin/factiii/bin/factiii-board-mcp +206 -0
- package/plugin/factiii/bin/factiii-secrets +182 -18
- package/plugin/factiii/bin/report-state.sh +19 -1
- package/plugin/factiii/bin/session-context.sh +76 -0
- package/plugin/factiii/hooks/hooks.json +22 -0
- package/plugin/factiii/skills/board-sessions/SKILL.md +74 -0
- package/plugin/factiii/skills/factiii-secrets/SKILL.md +21 -3
- package/plugin/factiii/skills/runner-onboarding/SKILL.md +67 -0
- package/plugin/factiii/skills/scratchpad/SKILL.md +1 -0
- package/plugin/factiii/skills/share-a-port/SKILL.md +11 -6
- package/index/image-package.json +0 -8
- package/index/index.js +0 -105341
- package/native/screenhost.m +0 -500
- package/plugin/factiii/skills/factiii-workspace/SKILL.md +0 -69
- package/vendor/frpc-darwin-amd64 +0 -0
- package/vendor/frpc-darwin-arm64 +0 -0
- package/vendor/frpc-linux-amd64 +0 -0
- package/vendor/frpc-linux-arm64 +0 -0
package/dist/vault-db.js
ADDED
|
@@ -0,0 +1,858 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
// src/vault/dbChild.ts
|
|
26
|
+
var import_node_module = require("node:module");
|
|
27
|
+
var import_node_path = __toESM(require("node:path"));
|
|
28
|
+
|
|
29
|
+
// ../../node_modules/@prisma/debug/dist/index.mjs
|
|
30
|
+
var __defProp2 = Object.defineProperty;
|
|
31
|
+
var __export = (target, all) => {
|
|
32
|
+
for (var name in all)
|
|
33
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
34
|
+
};
|
|
35
|
+
var colors_exports = {};
|
|
36
|
+
__export(colors_exports, {
|
|
37
|
+
$: () => $,
|
|
38
|
+
bgBlack: () => bgBlack,
|
|
39
|
+
bgBlue: () => bgBlue,
|
|
40
|
+
bgCyan: () => bgCyan,
|
|
41
|
+
bgGreen: () => bgGreen,
|
|
42
|
+
bgMagenta: () => bgMagenta,
|
|
43
|
+
bgRed: () => bgRed,
|
|
44
|
+
bgWhite: () => bgWhite,
|
|
45
|
+
bgYellow: () => bgYellow,
|
|
46
|
+
black: () => black,
|
|
47
|
+
blue: () => blue,
|
|
48
|
+
bold: () => bold,
|
|
49
|
+
cyan: () => cyan,
|
|
50
|
+
dim: () => dim,
|
|
51
|
+
gray: () => gray,
|
|
52
|
+
green: () => green,
|
|
53
|
+
grey: () => grey,
|
|
54
|
+
hidden: () => hidden,
|
|
55
|
+
inverse: () => inverse,
|
|
56
|
+
italic: () => italic,
|
|
57
|
+
magenta: () => magenta,
|
|
58
|
+
red: () => red,
|
|
59
|
+
reset: () => reset,
|
|
60
|
+
strikethrough: () => strikethrough,
|
|
61
|
+
underline: () => underline,
|
|
62
|
+
white: () => white,
|
|
63
|
+
yellow: () => yellow
|
|
64
|
+
});
|
|
65
|
+
var FORCE_COLOR;
|
|
66
|
+
var NODE_DISABLE_COLORS;
|
|
67
|
+
var NO_COLOR;
|
|
68
|
+
var TERM;
|
|
69
|
+
var isTTY = true;
|
|
70
|
+
if (typeof process !== "undefined") {
|
|
71
|
+
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
72
|
+
isTTY = process.stdout && process.stdout.isTTY;
|
|
73
|
+
}
|
|
74
|
+
var $ = {
|
|
75
|
+
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY)
|
|
76
|
+
};
|
|
77
|
+
function init(x, y) {
|
|
78
|
+
let rgx = new RegExp(`\\x1b\\[${y}m`, "g");
|
|
79
|
+
let open = `\x1B[${x}m`, close = `\x1B[${y}m`;
|
|
80
|
+
return function(txt) {
|
|
81
|
+
if (!$.enabled || txt == null) return txt;
|
|
82
|
+
return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
var reset = init(0, 0);
|
|
86
|
+
var bold = init(1, 22);
|
|
87
|
+
var dim = init(2, 22);
|
|
88
|
+
var italic = init(3, 23);
|
|
89
|
+
var underline = init(4, 24);
|
|
90
|
+
var inverse = init(7, 27);
|
|
91
|
+
var hidden = init(8, 28);
|
|
92
|
+
var strikethrough = init(9, 29);
|
|
93
|
+
var black = init(30, 39);
|
|
94
|
+
var red = init(31, 39);
|
|
95
|
+
var green = init(32, 39);
|
|
96
|
+
var yellow = init(33, 39);
|
|
97
|
+
var blue = init(34, 39);
|
|
98
|
+
var magenta = init(35, 39);
|
|
99
|
+
var cyan = init(36, 39);
|
|
100
|
+
var white = init(37, 39);
|
|
101
|
+
var gray = init(90, 39);
|
|
102
|
+
var grey = init(90, 39);
|
|
103
|
+
var bgBlack = init(40, 49);
|
|
104
|
+
var bgRed = init(41, 49);
|
|
105
|
+
var bgGreen = init(42, 49);
|
|
106
|
+
var bgYellow = init(43, 49);
|
|
107
|
+
var bgBlue = init(44, 49);
|
|
108
|
+
var bgMagenta = init(45, 49);
|
|
109
|
+
var bgCyan = init(46, 49);
|
|
110
|
+
var bgWhite = init(47, 49);
|
|
111
|
+
var MAX_ARGS_HISTORY = 100;
|
|
112
|
+
var COLORS = ["green", "yellow", "blue", "magenta", "cyan", "red"];
|
|
113
|
+
var argsHistory = [];
|
|
114
|
+
var lastTimestamp = Date.now();
|
|
115
|
+
var lastColor = 0;
|
|
116
|
+
var processEnv = typeof process !== "undefined" ? process.env : {};
|
|
117
|
+
globalThis.DEBUG ??= processEnv.DEBUG ?? "";
|
|
118
|
+
globalThis.DEBUG_COLORS ??= processEnv.DEBUG_COLORS ? processEnv.DEBUG_COLORS === "true" : true;
|
|
119
|
+
var topProps = {
|
|
120
|
+
enable(namespace) {
|
|
121
|
+
if (typeof namespace === "string") {
|
|
122
|
+
globalThis.DEBUG = namespace;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
disable() {
|
|
126
|
+
const prev = globalThis.DEBUG;
|
|
127
|
+
globalThis.DEBUG = "";
|
|
128
|
+
return prev;
|
|
129
|
+
},
|
|
130
|
+
// this is the core logic to check if logging should happen or not
|
|
131
|
+
enabled(namespace) {
|
|
132
|
+
const listenedNamespaces = globalThis.DEBUG.split(",").map((s) => {
|
|
133
|
+
return s.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
134
|
+
});
|
|
135
|
+
const isListened = listenedNamespaces.some((listenedNamespace) => {
|
|
136
|
+
if (listenedNamespace === "" || listenedNamespace[0] === "-") return false;
|
|
137
|
+
return namespace.match(RegExp(listenedNamespace.split("*").join(".*") + "$"));
|
|
138
|
+
});
|
|
139
|
+
const isExcluded = listenedNamespaces.some((listenedNamespace) => {
|
|
140
|
+
if (listenedNamespace === "" || listenedNamespace[0] !== "-") return false;
|
|
141
|
+
return namespace.match(RegExp(listenedNamespace.slice(1).split("*").join(".*") + "$"));
|
|
142
|
+
});
|
|
143
|
+
return isListened && !isExcluded;
|
|
144
|
+
},
|
|
145
|
+
log: (...args) => {
|
|
146
|
+
const [namespace, format, ...rest] = args;
|
|
147
|
+
const logWithFormatting = console.warn ?? console.log;
|
|
148
|
+
logWithFormatting(`${namespace} ${format}`, ...rest);
|
|
149
|
+
},
|
|
150
|
+
formatters: {}
|
|
151
|
+
// not implemented
|
|
152
|
+
};
|
|
153
|
+
function debugCreate(namespace) {
|
|
154
|
+
const instanceProps = {
|
|
155
|
+
color: COLORS[lastColor++ % COLORS.length],
|
|
156
|
+
enabled: topProps.enabled(namespace),
|
|
157
|
+
namespace,
|
|
158
|
+
log: topProps.log,
|
|
159
|
+
extend: () => {
|
|
160
|
+
}
|
|
161
|
+
// not implemented
|
|
162
|
+
};
|
|
163
|
+
const debugCall = (...args) => {
|
|
164
|
+
const { enabled, namespace: namespace2, color, log } = instanceProps;
|
|
165
|
+
if (args.length !== 0) {
|
|
166
|
+
argsHistory.push([namespace2, ...args]);
|
|
167
|
+
}
|
|
168
|
+
if (argsHistory.length > MAX_ARGS_HISTORY) {
|
|
169
|
+
argsHistory.shift();
|
|
170
|
+
}
|
|
171
|
+
if (topProps.enabled(namespace2) || enabled) {
|
|
172
|
+
const stringArgs = args.map((arg) => {
|
|
173
|
+
if (typeof arg === "string") {
|
|
174
|
+
return arg;
|
|
175
|
+
}
|
|
176
|
+
return safeStringify(arg);
|
|
177
|
+
});
|
|
178
|
+
const ms = `+${Date.now() - lastTimestamp}ms`;
|
|
179
|
+
lastTimestamp = Date.now();
|
|
180
|
+
if (globalThis.DEBUG_COLORS) {
|
|
181
|
+
log(colors_exports[color](bold(namespace2)), ...stringArgs, colors_exports[color](ms));
|
|
182
|
+
} else {
|
|
183
|
+
log(namespace2, ...stringArgs, ms);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
return new Proxy(debugCall, {
|
|
188
|
+
get: (_, prop) => instanceProps[prop],
|
|
189
|
+
set: (_, prop, value) => instanceProps[prop] = value
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
var Debug = new Proxy(debugCreate, {
|
|
193
|
+
get: (_, prop) => topProps[prop],
|
|
194
|
+
set: (_, prop, value) => topProps[prop] = value
|
|
195
|
+
});
|
|
196
|
+
function safeStringify(value, indent = 2) {
|
|
197
|
+
const cache = /* @__PURE__ */ new Set();
|
|
198
|
+
return JSON.stringify(
|
|
199
|
+
value,
|
|
200
|
+
(key, value2) => {
|
|
201
|
+
if (typeof value2 === "object" && value2 !== null) {
|
|
202
|
+
if (cache.has(value2)) {
|
|
203
|
+
return `[Circular *]`;
|
|
204
|
+
}
|
|
205
|
+
cache.add(value2);
|
|
206
|
+
} else if (typeof value2 === "bigint") {
|
|
207
|
+
return value2.toString();
|
|
208
|
+
}
|
|
209
|
+
return value2;
|
|
210
|
+
},
|
|
211
|
+
indent
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ../../node_modules/@prisma/driver-adapter-utils/dist/index.mjs
|
|
216
|
+
var DriverAdapterError = class extends Error {
|
|
217
|
+
name = "DriverAdapterError";
|
|
218
|
+
cause;
|
|
219
|
+
constructor(payload) {
|
|
220
|
+
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
221
|
+
this.cause = payload;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var debug = Debug("driver-adapter-utils");
|
|
225
|
+
var ColumnTypeEnum = {
|
|
226
|
+
// Scalars
|
|
227
|
+
Int32: 0,
|
|
228
|
+
Int64: 1,
|
|
229
|
+
Float: 2,
|
|
230
|
+
Double: 3,
|
|
231
|
+
Numeric: 4,
|
|
232
|
+
Boolean: 5,
|
|
233
|
+
Character: 6,
|
|
234
|
+
Text: 7,
|
|
235
|
+
Date: 8,
|
|
236
|
+
Time: 9,
|
|
237
|
+
DateTime: 10,
|
|
238
|
+
Json: 11,
|
|
239
|
+
Enum: 12,
|
|
240
|
+
Bytes: 13,
|
|
241
|
+
Set: 14,
|
|
242
|
+
Uuid: 15,
|
|
243
|
+
// Arrays
|
|
244
|
+
Int32Array: 64,
|
|
245
|
+
Int64Array: 65,
|
|
246
|
+
FloatArray: 66,
|
|
247
|
+
DoubleArray: 67,
|
|
248
|
+
NumericArray: 68,
|
|
249
|
+
BooleanArray: 69,
|
|
250
|
+
CharacterArray: 70,
|
|
251
|
+
TextArray: 71,
|
|
252
|
+
DateArray: 72,
|
|
253
|
+
TimeArray: 73,
|
|
254
|
+
DateTimeArray: 74,
|
|
255
|
+
JsonArray: 75,
|
|
256
|
+
EnumArray: 76,
|
|
257
|
+
BytesArray: 77,
|
|
258
|
+
UuidArray: 78,
|
|
259
|
+
// Custom
|
|
260
|
+
UnknownNumber: 128
|
|
261
|
+
};
|
|
262
|
+
var mockAdapterErrors = {
|
|
263
|
+
queryRaw: new Error("Not implemented: queryRaw"),
|
|
264
|
+
executeRaw: new Error("Not implemented: executeRaw"),
|
|
265
|
+
startTransaction: new Error("Not implemented: startTransaction"),
|
|
266
|
+
executeScript: new Error("Not implemented: executeScript"),
|
|
267
|
+
dispose: new Error("Not implemented: dispose")
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// src/vault/pgliteAdapter.ts
|
|
271
|
+
var BACKSLASH = "\\";
|
|
272
|
+
var DQUOT = '"';
|
|
273
|
+
var LBRACE = "{";
|
|
274
|
+
var RBRACE = "}";
|
|
275
|
+
var LBRACKET = "[";
|
|
276
|
+
var EQUALS = "=";
|
|
277
|
+
var COMMA = ",";
|
|
278
|
+
var NULL_STRING = "NULL";
|
|
279
|
+
function parseArray(str, transform) {
|
|
280
|
+
const rbraceIndex = str.length - 1;
|
|
281
|
+
if (rbraceIndex === 1) {
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
284
|
+
if (str[rbraceIndex] !== RBRACE) {
|
|
285
|
+
throw new Error("Invalid array text - must end with }");
|
|
286
|
+
}
|
|
287
|
+
let position = 0;
|
|
288
|
+
if (str[position] === LBRACKET) {
|
|
289
|
+
position = str.indexOf(EQUALS) + 1;
|
|
290
|
+
}
|
|
291
|
+
if (str[position++] !== LBRACE) {
|
|
292
|
+
throw new Error("Invalid array text - must start with {");
|
|
293
|
+
}
|
|
294
|
+
const output = [];
|
|
295
|
+
let current = output;
|
|
296
|
+
const stack = [];
|
|
297
|
+
let currentStringStart = position;
|
|
298
|
+
let currentString = "";
|
|
299
|
+
let expectValue = true;
|
|
300
|
+
for (; position < rbraceIndex; ++position) {
|
|
301
|
+
let char = str[position];
|
|
302
|
+
if (char === DQUOT) {
|
|
303
|
+
currentStringStart = ++position;
|
|
304
|
+
let dquot = str.indexOf(DQUOT, currentStringStart);
|
|
305
|
+
let backSlash = str.indexOf(BACKSLASH, currentStringStart);
|
|
306
|
+
while (backSlash !== -1 && backSlash < dquot) {
|
|
307
|
+
position = backSlash;
|
|
308
|
+
const part2 = str.slice(currentStringStart, position);
|
|
309
|
+
currentString += part2;
|
|
310
|
+
currentStringStart = ++position;
|
|
311
|
+
if (dquot === position++) {
|
|
312
|
+
dquot = str.indexOf(DQUOT, position);
|
|
313
|
+
}
|
|
314
|
+
backSlash = str.indexOf(BACKSLASH, position);
|
|
315
|
+
}
|
|
316
|
+
position = dquot;
|
|
317
|
+
const part = str.slice(currentStringStart, position);
|
|
318
|
+
currentString += part;
|
|
319
|
+
current.push(transform ? transform(currentString) : currentString);
|
|
320
|
+
currentString = "";
|
|
321
|
+
expectValue = false;
|
|
322
|
+
} else if (char === LBRACE) {
|
|
323
|
+
const newArray = [];
|
|
324
|
+
current.push(newArray);
|
|
325
|
+
stack.push(current);
|
|
326
|
+
current = newArray;
|
|
327
|
+
currentStringStart = position + 1;
|
|
328
|
+
expectValue = true;
|
|
329
|
+
} else if (char === COMMA) {
|
|
330
|
+
expectValue = true;
|
|
331
|
+
} else if (char === RBRACE) {
|
|
332
|
+
expectValue = false;
|
|
333
|
+
const arr = stack.pop();
|
|
334
|
+
if (arr === void 0) {
|
|
335
|
+
throw new Error("Invalid array text - too many '}'");
|
|
336
|
+
}
|
|
337
|
+
current = arr;
|
|
338
|
+
} else if (expectValue) {
|
|
339
|
+
currentStringStart = position;
|
|
340
|
+
while ((char = str[position]) !== COMMA && char !== RBRACE && position < rbraceIndex) {
|
|
341
|
+
++position;
|
|
342
|
+
}
|
|
343
|
+
const part = str.slice(currentStringStart, position--);
|
|
344
|
+
current.push(part === NULL_STRING ? null : transform ? transform(part) : part);
|
|
345
|
+
expectValue = false;
|
|
346
|
+
} else {
|
|
347
|
+
throw new Error("Was expecting delimeter");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return output;
|
|
351
|
+
}
|
|
352
|
+
var AdditionalScalarColumnType = { NAME: 19 };
|
|
353
|
+
var ArrayColumnType = {
|
|
354
|
+
BIT: 1561,
|
|
355
|
+
BOOL: 1e3,
|
|
356
|
+
BYTEA: 1001,
|
|
357
|
+
BPCHAR: 1014,
|
|
358
|
+
CHAR: 1002,
|
|
359
|
+
CIDR: 651,
|
|
360
|
+
DATE: 1182,
|
|
361
|
+
FLOAT4: 1021,
|
|
362
|
+
FLOAT8: 1022,
|
|
363
|
+
INET: 1041,
|
|
364
|
+
INT2: 1005,
|
|
365
|
+
INT4: 1007,
|
|
366
|
+
INT8: 1016,
|
|
367
|
+
JSONB: 3807,
|
|
368
|
+
JSON: 199,
|
|
369
|
+
MONEY: 791,
|
|
370
|
+
NUMERIC: 1231,
|
|
371
|
+
OID: 1028,
|
|
372
|
+
TEXT: 1009,
|
|
373
|
+
TIMESTAMP: 1115,
|
|
374
|
+
TIMESTAMPTZ: 1185,
|
|
375
|
+
TIME: 1183,
|
|
376
|
+
UUID: 2951,
|
|
377
|
+
VARBIT: 1563,
|
|
378
|
+
VARCHAR: 1015,
|
|
379
|
+
XML: 143
|
|
380
|
+
};
|
|
381
|
+
var UnsupportedNativeDataType = class extends Error {
|
|
382
|
+
// The upstream table names every builtin; the message only needs a name.
|
|
383
|
+
type;
|
|
384
|
+
constructor(code) {
|
|
385
|
+
super();
|
|
386
|
+
this.type = `oid ${code}`;
|
|
387
|
+
this.message = `Unsupported column type ${this.type}`;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
function fieldToColumnType(t, fieldTypeId) {
|
|
391
|
+
switch (fieldTypeId) {
|
|
392
|
+
case t.INT2:
|
|
393
|
+
case t.INT4:
|
|
394
|
+
return ColumnTypeEnum.Int32;
|
|
395
|
+
case t.INT8:
|
|
396
|
+
return ColumnTypeEnum.Int64;
|
|
397
|
+
case t.FLOAT4:
|
|
398
|
+
return ColumnTypeEnum.Float;
|
|
399
|
+
case t.FLOAT8:
|
|
400
|
+
return ColumnTypeEnum.Double;
|
|
401
|
+
case t.BOOL:
|
|
402
|
+
return ColumnTypeEnum.Boolean;
|
|
403
|
+
case t.DATE:
|
|
404
|
+
return ColumnTypeEnum.Date;
|
|
405
|
+
case t.TIME:
|
|
406
|
+
case t.TIMETZ:
|
|
407
|
+
return ColumnTypeEnum.Time;
|
|
408
|
+
case t.TIMESTAMP:
|
|
409
|
+
case t.TIMESTAMPTZ:
|
|
410
|
+
return ColumnTypeEnum.DateTime;
|
|
411
|
+
case t.NUMERIC:
|
|
412
|
+
case t.MONEY:
|
|
413
|
+
return ColumnTypeEnum.Numeric;
|
|
414
|
+
case t.JSON:
|
|
415
|
+
case t.JSONB:
|
|
416
|
+
return ColumnTypeEnum.Json;
|
|
417
|
+
case t.UUID:
|
|
418
|
+
return ColumnTypeEnum.Uuid;
|
|
419
|
+
case t.OID:
|
|
420
|
+
return ColumnTypeEnum.Int64;
|
|
421
|
+
case t.BPCHAR:
|
|
422
|
+
case t.TEXT:
|
|
423
|
+
case t.VARCHAR:
|
|
424
|
+
case t.BIT:
|
|
425
|
+
case t.VARBIT:
|
|
426
|
+
case t.INET:
|
|
427
|
+
case t.CIDR:
|
|
428
|
+
case t.XML:
|
|
429
|
+
case AdditionalScalarColumnType.NAME:
|
|
430
|
+
return ColumnTypeEnum.Text;
|
|
431
|
+
case t.CHAR:
|
|
432
|
+
return ColumnTypeEnum.Character;
|
|
433
|
+
case t.BYTEA:
|
|
434
|
+
return ColumnTypeEnum.Bytes;
|
|
435
|
+
case ArrayColumnType.INT2:
|
|
436
|
+
case ArrayColumnType.INT4:
|
|
437
|
+
return ColumnTypeEnum.Int32Array;
|
|
438
|
+
case ArrayColumnType.FLOAT4:
|
|
439
|
+
return ColumnTypeEnum.FloatArray;
|
|
440
|
+
case ArrayColumnType.FLOAT8:
|
|
441
|
+
return ColumnTypeEnum.DoubleArray;
|
|
442
|
+
case ArrayColumnType.NUMERIC:
|
|
443
|
+
case ArrayColumnType.MONEY:
|
|
444
|
+
return ColumnTypeEnum.NumericArray;
|
|
445
|
+
case ArrayColumnType.BOOL:
|
|
446
|
+
return ColumnTypeEnum.BooleanArray;
|
|
447
|
+
case ArrayColumnType.CHAR:
|
|
448
|
+
return ColumnTypeEnum.CharacterArray;
|
|
449
|
+
case ArrayColumnType.BPCHAR:
|
|
450
|
+
case ArrayColumnType.TEXT:
|
|
451
|
+
case ArrayColumnType.VARCHAR:
|
|
452
|
+
case ArrayColumnType.VARBIT:
|
|
453
|
+
case ArrayColumnType.BIT:
|
|
454
|
+
case ArrayColumnType.INET:
|
|
455
|
+
case ArrayColumnType.CIDR:
|
|
456
|
+
case ArrayColumnType.XML:
|
|
457
|
+
return ColumnTypeEnum.TextArray;
|
|
458
|
+
case ArrayColumnType.DATE:
|
|
459
|
+
return ColumnTypeEnum.DateArray;
|
|
460
|
+
case ArrayColumnType.TIMESTAMP:
|
|
461
|
+
case ArrayColumnType.TIMESTAMPTZ:
|
|
462
|
+
return ColumnTypeEnum.DateTimeArray;
|
|
463
|
+
case ArrayColumnType.JSON:
|
|
464
|
+
case ArrayColumnType.JSONB:
|
|
465
|
+
return ColumnTypeEnum.JsonArray;
|
|
466
|
+
case ArrayColumnType.BYTEA:
|
|
467
|
+
return ColumnTypeEnum.BytesArray;
|
|
468
|
+
case ArrayColumnType.UUID:
|
|
469
|
+
return ColumnTypeEnum.UuidArray;
|
|
470
|
+
case ArrayColumnType.INT8:
|
|
471
|
+
case ArrayColumnType.OID:
|
|
472
|
+
return ColumnTypeEnum.Int64Array;
|
|
473
|
+
default:
|
|
474
|
+
if (fieldTypeId >= 1e4) return ColumnTypeEnum.Text;
|
|
475
|
+
throw new UnsupportedNativeDataType(fieldTypeId);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
var normalizeArray = (elementNormalizer) => (str) => parseArray(str, elementNormalizer);
|
|
479
|
+
var identity = (value) => value;
|
|
480
|
+
var normalizeTimestamp = (time) => `${time.replace(" ", "T")}+00:00`;
|
|
481
|
+
var normalizeTimestampz = (time) => time.replace(" ", "T").replace(/[+-]\d{2}(:\d{2})?$/, "+00:00");
|
|
482
|
+
var normalizeTimez = (time) => time.replace(/[+-]\d{2}(:\d{2})?$/, "");
|
|
483
|
+
var normalizeMoney = (money) => money.slice(1);
|
|
484
|
+
var parsePgBytes = (x) => {
|
|
485
|
+
const hexString = x.slice(2);
|
|
486
|
+
return Uint8Array.from(
|
|
487
|
+
{ length: hexString.length / 2 },
|
|
488
|
+
(_, idx) => Number.parseInt(hexString.substring(idx * 2, (idx + 1) * 2), 16)
|
|
489
|
+
);
|
|
490
|
+
};
|
|
491
|
+
var normalizeByteaArray = (x) => parseArray(x).map((item) => parsePgBytes(item));
|
|
492
|
+
function customParsers(t) {
|
|
493
|
+
return {
|
|
494
|
+
[t.NUMERIC]: identity,
|
|
495
|
+
[ArrayColumnType.NUMERIC]: normalizeArray(identity),
|
|
496
|
+
[t.TIME]: identity,
|
|
497
|
+
[ArrayColumnType.TIME]: normalizeArray(identity),
|
|
498
|
+
[t.TIMETZ]: normalizeTimez,
|
|
499
|
+
[t.DATE]: identity,
|
|
500
|
+
[ArrayColumnType.DATE]: normalizeArray(identity),
|
|
501
|
+
[t.TIMESTAMP]: normalizeTimestamp,
|
|
502
|
+
[ArrayColumnType.TIMESTAMP]: normalizeArray(normalizeTimestamp),
|
|
503
|
+
[t.TIMESTAMPTZ]: normalizeTimestampz,
|
|
504
|
+
[ArrayColumnType.TIMESTAMPTZ]: normalizeArray(normalizeTimestampz),
|
|
505
|
+
[t.MONEY]: normalizeMoney,
|
|
506
|
+
[ArrayColumnType.MONEY]: normalizeArray(normalizeMoney),
|
|
507
|
+
[t.JSON]: identity,
|
|
508
|
+
[ArrayColumnType.JSON]: normalizeArray(identity),
|
|
509
|
+
[t.JSONB]: identity,
|
|
510
|
+
[ArrayColumnType.JSONB]: normalizeArray(identity),
|
|
511
|
+
[t.BYTEA]: parsePgBytes,
|
|
512
|
+
[ArrayColumnType.BYTEA]: normalizeByteaArray,
|
|
513
|
+
[ArrayColumnType.BIT]: normalizeArray(identity),
|
|
514
|
+
[ArrayColumnType.VARBIT]: normalizeArray(identity),
|
|
515
|
+
[ArrayColumnType.XML]: normalizeArray(identity),
|
|
516
|
+
[t.INT8]: identity,
|
|
517
|
+
[ArrayColumnType.INT8]: normalizeArray(identity)
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
var pad = (n, z = 2) => String(n).padStart(z, "0");
|
|
521
|
+
function formatDateTime(date) {
|
|
522
|
+
const ms = date.getUTCMilliseconds();
|
|
523
|
+
return `${pad(date.getUTCFullYear(), 4)}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())} ${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}${ms ? `.${String(ms).padStart(3, "0")}` : ""}`;
|
|
524
|
+
}
|
|
525
|
+
function formatDate(date) {
|
|
526
|
+
return `${pad(date.getUTCFullYear(), 4)}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
|
|
527
|
+
}
|
|
528
|
+
function formatTime(date) {
|
|
529
|
+
const ms = date.getUTCMilliseconds();
|
|
530
|
+
return `${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}${ms ? `.${String(ms).padStart(3, "0")}` : ""}`;
|
|
531
|
+
}
|
|
532
|
+
function mapArg(arg, argType) {
|
|
533
|
+
if (arg === null) return null;
|
|
534
|
+
if (Array.isArray(arg) && argType.arity === "list") {
|
|
535
|
+
return arg.map((value2) => mapArg(value2, argType));
|
|
536
|
+
}
|
|
537
|
+
let value = arg;
|
|
538
|
+
if (typeof value === "string" && argType.scalarType === "datetime") value = new Date(value);
|
|
539
|
+
if (value instanceof Date) {
|
|
540
|
+
switch (argType.dbType) {
|
|
541
|
+
case "TIME":
|
|
542
|
+
case "TIMETZ":
|
|
543
|
+
return formatTime(value);
|
|
544
|
+
case "DATE":
|
|
545
|
+
return formatDate(value);
|
|
546
|
+
default:
|
|
547
|
+
return formatDateTime(value);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (typeof value === "string" && argType.scalarType === "bytes") {
|
|
551
|
+
return Buffer.from(value, "base64");
|
|
552
|
+
}
|
|
553
|
+
if (ArrayBuffer.isView(value)) {
|
|
554
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
555
|
+
}
|
|
556
|
+
return value;
|
|
557
|
+
}
|
|
558
|
+
function isDriverError(error) {
|
|
559
|
+
const e = error;
|
|
560
|
+
return typeof e.code === "string" && typeof e.message === "string" && typeof e.severity === "string" && (typeof e.detail === "string" || e.detail === void 0) && (typeof e.column === "string" || e.column === void 0) && (typeof e.hint === "string" || e.hint === void 0);
|
|
561
|
+
}
|
|
562
|
+
var keyFields = (error) => error.detail?.match(/Key \(([^)]+)\)/)?.at(1)?.split(", ");
|
|
563
|
+
var quoted = (text) => text?.split('"').at(1);
|
|
564
|
+
function mapDriverError(error) {
|
|
565
|
+
switch (error.code) {
|
|
566
|
+
case "22001":
|
|
567
|
+
return { kind: "LengthMismatch", column: error.column };
|
|
568
|
+
case "22003":
|
|
569
|
+
return { kind: "ValueOutOfRange", cause: error.message };
|
|
570
|
+
case "22P02":
|
|
571
|
+
return { kind: "InvalidInputValue", message: error.message };
|
|
572
|
+
case "23505": {
|
|
573
|
+
const fields = keyFields(error);
|
|
574
|
+
return {
|
|
575
|
+
kind: "UniqueConstraintViolation",
|
|
576
|
+
constraint: fields !== void 0 ? { fields } : void 0
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
case "23502": {
|
|
580
|
+
const fields = keyFields(error);
|
|
581
|
+
return {
|
|
582
|
+
kind: "NullConstraintViolation",
|
|
583
|
+
constraint: fields !== void 0 ? { fields } : void 0
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
case "23503": {
|
|
587
|
+
let constraint;
|
|
588
|
+
if (error.column) constraint = { fields: [error.column] };
|
|
589
|
+
else if (error.constraint) constraint = { index: error.constraint };
|
|
590
|
+
return { kind: "ForeignKeyConstraintViolation", constraint };
|
|
591
|
+
}
|
|
592
|
+
case "3D000":
|
|
593
|
+
return { kind: "DatabaseDoesNotExist", db: quoted(error.message.split(" ").at(1)) };
|
|
594
|
+
case "28000":
|
|
595
|
+
return {
|
|
596
|
+
kind: "DatabaseAccessDenied",
|
|
597
|
+
db: quoted(error.message.split(",").find((s) => s.startsWith(" database")))
|
|
598
|
+
};
|
|
599
|
+
case "28P01":
|
|
600
|
+
return { kind: "AuthenticationFailed", user: quoted(error.message.split(" ").pop()) };
|
|
601
|
+
case "40001":
|
|
602
|
+
return { kind: "TransactionWriteConflict" };
|
|
603
|
+
case "42P01":
|
|
604
|
+
return { kind: "TableDoesNotExist", table: quoted(error.message.split(" ").at(1)) };
|
|
605
|
+
case "42703":
|
|
606
|
+
return { kind: "ColumnNotFound", column: quoted(error.message.split(" ").at(1)) };
|
|
607
|
+
case "42P04":
|
|
608
|
+
return { kind: "DatabaseAlreadyExists", db: quoted(error.message.split(" ").at(1)) };
|
|
609
|
+
case "53300":
|
|
610
|
+
return { kind: "TooManyConnections", cause: error.message };
|
|
611
|
+
default:
|
|
612
|
+
return {
|
|
613
|
+
kind: "postgres",
|
|
614
|
+
code: error.code ?? "N/A",
|
|
615
|
+
severity: error.severity ?? "N/A",
|
|
616
|
+
message: error.message,
|
|
617
|
+
detail: error.detail,
|
|
618
|
+
column: error.column,
|
|
619
|
+
hint: error.hint
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function convertDriverError(error) {
|
|
624
|
+
if (isDriverError(error)) {
|
|
625
|
+
return {
|
|
626
|
+
originalCode: error.code,
|
|
627
|
+
originalMessage: error.message,
|
|
628
|
+
...mapDriverError(error)
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
throw error;
|
|
632
|
+
}
|
|
633
|
+
var ADAPTER_NAME = "pglite-prisma-adapter";
|
|
634
|
+
var PgliteQueryableAdapter = class {
|
|
635
|
+
constructor(pglite, client) {
|
|
636
|
+
this.pglite = pglite;
|
|
637
|
+
this.client = client;
|
|
638
|
+
}
|
|
639
|
+
provider = "postgres";
|
|
640
|
+
adapterName = ADAPTER_NAME;
|
|
641
|
+
async queryRaw(query) {
|
|
642
|
+
const { fields, rows } = await this.performIO(query);
|
|
643
|
+
const columnNames = fields.map((field) => field.name);
|
|
644
|
+
let columnTypes = [];
|
|
645
|
+
try {
|
|
646
|
+
columnTypes = fields.map((field) => fieldToColumnType(this.pglite.types, field.dataTypeID));
|
|
647
|
+
} catch (e) {
|
|
648
|
+
if (e instanceof UnsupportedNativeDataType) {
|
|
649
|
+
throw new DriverAdapterError({ kind: "UnsupportedNativeDataType", type: e.type });
|
|
650
|
+
}
|
|
651
|
+
throw e;
|
|
652
|
+
}
|
|
653
|
+
return { columnNames, columnTypes, rows };
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Execute a query given as SQL, interpolating the given parameters and
|
|
657
|
+
* returning the number of affected rows.
|
|
658
|
+
*/
|
|
659
|
+
async executeRaw(query) {
|
|
660
|
+
return (await this.performIO(query)).affectedRows ?? 0;
|
|
661
|
+
}
|
|
662
|
+
async performIO(query) {
|
|
663
|
+
const { sql, args } = query;
|
|
664
|
+
const values = args.map((arg, i) => mapArg(arg, query.argTypes[i]));
|
|
665
|
+
try {
|
|
666
|
+
return await this.client.query(sql, values, {
|
|
667
|
+
rowMode: "array",
|
|
668
|
+
parsers: customParsers(this.pglite.types)
|
|
669
|
+
});
|
|
670
|
+
} catch (e) {
|
|
671
|
+
return this.onError(e);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
onError(error) {
|
|
675
|
+
if (error instanceof this.pglite.messages.DatabaseError) {
|
|
676
|
+
throw new DriverAdapterError(convertDriverError(error));
|
|
677
|
+
}
|
|
678
|
+
throw error;
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
var PgliteTransaction = class extends PgliteQueryableAdapter {
|
|
682
|
+
constructor(pglite, client, options, done, result) {
|
|
683
|
+
super(pglite, client);
|
|
684
|
+
this.options = options;
|
|
685
|
+
this.done = done;
|
|
686
|
+
this.result = result;
|
|
687
|
+
}
|
|
688
|
+
async commit() {
|
|
689
|
+
this.done();
|
|
690
|
+
return this.result;
|
|
691
|
+
}
|
|
692
|
+
async rollback() {
|
|
693
|
+
await this.client.rollback();
|
|
694
|
+
this.done();
|
|
695
|
+
return this.result;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
var PgliteAdapter = class extends PgliteQueryableAdapter {
|
|
699
|
+
constructor(pglite, db) {
|
|
700
|
+
super(pglite, db);
|
|
701
|
+
this.db = db;
|
|
702
|
+
}
|
|
703
|
+
async executeScript(script) {
|
|
704
|
+
try {
|
|
705
|
+
await this.db.exec(script);
|
|
706
|
+
} catch (e) {
|
|
707
|
+
this.onError(e);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
getConnectionInfo() {
|
|
711
|
+
return { supportsRelationJoins: true };
|
|
712
|
+
}
|
|
713
|
+
async startTransaction(isolationLevel) {
|
|
714
|
+
const options = { usePhantomQuery: true };
|
|
715
|
+
if (isolationLevel) {
|
|
716
|
+
await this.db.exec(`SET TRANSACTION ISOLATION LEVEL ${isolationLevel}`).catch((error) => this.onError(error));
|
|
717
|
+
}
|
|
718
|
+
return new Promise((resolve, reject) => {
|
|
719
|
+
let done = () => {
|
|
720
|
+
};
|
|
721
|
+
const finished = new Promise((end) => {
|
|
722
|
+
done = end;
|
|
723
|
+
});
|
|
724
|
+
const result = this.db.transaction(async (tx) => {
|
|
725
|
+
resolve(new PgliteTransaction(this.pglite, tx, options, done, result));
|
|
726
|
+
return finished;
|
|
727
|
+
}).catch((error) => {
|
|
728
|
+
reject(error);
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
async dispose() {
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
function pgliteAdapter(pglite, db) {
|
|
736
|
+
return new PgliteAdapter(pglite, db);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// src/vault/dbChild.ts
|
|
740
|
+
var send = (reply) => process.send?.(reply);
|
|
741
|
+
async function main() {
|
|
742
|
+
const [dataDir, engineDir, mode] = process.argv.slice(2);
|
|
743
|
+
if (!dataDir || !engineDir || !process.send) {
|
|
744
|
+
throw new Error("Usage: vault-db <data dir> <engine dir> [--load], as a forked child.");
|
|
745
|
+
}
|
|
746
|
+
const loaded = mode === "--load" ? await firstLoad() : null;
|
|
747
|
+
const load = (0, import_node_module.createRequire)(import_node_path.default.join(engineDir, "package.json"));
|
|
748
|
+
const pglite = load("@electric-sql/pglite");
|
|
749
|
+
const { vector } = load("@electric-sql/pglite/vector");
|
|
750
|
+
const db = await pglite.PGlite.create(dataDir, {
|
|
751
|
+
extensions: { vector },
|
|
752
|
+
...loaded ? { loadDataDir: new Blob([loaded]) } : {}
|
|
753
|
+
});
|
|
754
|
+
const adapter = pgliteAdapter(pglite, db);
|
|
755
|
+
const driver = driverOf(adapter);
|
|
756
|
+
let queue = Promise.resolve();
|
|
757
|
+
process.on("message", (request) => {
|
|
758
|
+
if (request.op === "driver") {
|
|
759
|
+
void driver(request.driver).then(
|
|
760
|
+
(value) => send({ id: request.id, ok: true, value }),
|
|
761
|
+
(err) => send(failure(request.id, err))
|
|
762
|
+
);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
queue = queue.then(async () => {
|
|
766
|
+
try {
|
|
767
|
+
if (request.op === "close") {
|
|
768
|
+
await db.close();
|
|
769
|
+
send({ id: request.id, ok: true, results: [] });
|
|
770
|
+
process.exit(0);
|
|
771
|
+
}
|
|
772
|
+
if (request.op === "dump") {
|
|
773
|
+
const blob = await db.dumpDataDir("gzip");
|
|
774
|
+
send({ id: request.id, ok: true, value: new Uint8Array(await blob.arrayBuffer()) });
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const results = await db.transaction(async (tx) => {
|
|
778
|
+
const out = [];
|
|
779
|
+
for (const statement of request.statements) {
|
|
780
|
+
if (statement.exec) {
|
|
781
|
+
await tx.exec(statement.sql);
|
|
782
|
+
out.push([]);
|
|
783
|
+
} else {
|
|
784
|
+
out.push((await tx.query(statement.sql, statement.params)).rows);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return out;
|
|
788
|
+
});
|
|
789
|
+
send({ id: request.id, ok: true, results });
|
|
790
|
+
} catch (err) {
|
|
791
|
+
send({
|
|
792
|
+
id: request.id,
|
|
793
|
+
ok: false,
|
|
794
|
+
error: err instanceof Error ? err.message : String(err)
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
});
|
|
799
|
+
process.on("SIGINT", () => void 0);
|
|
800
|
+
process.on("disconnect", () => {
|
|
801
|
+
void db.close().finally(() => process.exit(0));
|
|
802
|
+
});
|
|
803
|
+
send({ id: 0, ok: true, results: [] });
|
|
804
|
+
}
|
|
805
|
+
function firstLoad() {
|
|
806
|
+
return new Promise((resolve) => {
|
|
807
|
+
const onMessage = (message) => {
|
|
808
|
+
if (message?.op !== "load") return;
|
|
809
|
+
process.off("message", onMessage);
|
|
810
|
+
resolve(message.data ? new Uint8Array(message.data) : null);
|
|
811
|
+
};
|
|
812
|
+
process.on("message", onMessage);
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
function failure(id, err) {
|
|
816
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
817
|
+
const cause = err?.cause;
|
|
818
|
+
return err?.name === "DriverAdapterError" && cause ? { id, ok: false, error: message, driverError: cause } : { id, ok: false, error: message };
|
|
819
|
+
}
|
|
820
|
+
function driverOf(adapter) {
|
|
821
|
+
const open = /* @__PURE__ */ new Map();
|
|
822
|
+
let nextTx = 1;
|
|
823
|
+
const on = (tx) => {
|
|
824
|
+
if (tx === void 0) return adapter;
|
|
825
|
+
const found = open.get(tx);
|
|
826
|
+
if (!found) throw new Error("That vault transaction has already ended.");
|
|
827
|
+
return found;
|
|
828
|
+
};
|
|
829
|
+
return async (op) => {
|
|
830
|
+
switch (op.op) {
|
|
831
|
+
case "queryRaw":
|
|
832
|
+
return on(op.tx).queryRaw(op.query);
|
|
833
|
+
case "executeRaw":
|
|
834
|
+
return on(op.tx).executeRaw(op.query);
|
|
835
|
+
case "executeScript":
|
|
836
|
+
return adapter.executeScript(op.script);
|
|
837
|
+
case "begin": {
|
|
838
|
+
const tx = await adapter.startTransaction(op.isolation);
|
|
839
|
+
const id = nextTx++;
|
|
840
|
+
open.set(id, tx);
|
|
841
|
+
return { tx: id, options: tx.options };
|
|
842
|
+
}
|
|
843
|
+
case "commit":
|
|
844
|
+
case "rollback": {
|
|
845
|
+
const tx = on(op.tx);
|
|
846
|
+
open.delete(op.tx);
|
|
847
|
+
return op.op === "commit" ? tx.commit() : tx.rollback();
|
|
848
|
+
}
|
|
849
|
+
case "rss":
|
|
850
|
+
return process.memoryUsage().rss;
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
main().catch((err) => {
|
|
855
|
+
send({ id: 0, ok: false, error: err instanceof Error ? err.message : String(err) });
|
|
856
|
+
process.exit(1);
|
|
857
|
+
});
|
|
858
|
+
//# sourceMappingURL=vault-db.js.map
|