@voltro/database 0.62.3 → 0.64.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.
@@ -0,0 +1,32 @@
1
+ import { Schema as e } from "effect";
2
+ //#region src/optimisticVersion.ts
3
+ var t = class extends e.TaggedError()("VersionConflict", {
4
+ table: e.String,
5
+ id: e.String,
6
+ expected: e.Number,
7
+ actual: e.NullOr(e.Number)
8
+ }) {}, n = (e) => {
9
+ for (let [t, n] of Object.entries(e)) if (n?.definition?.versionColumn === !0) return t;
10
+ }, r = (e) => {
11
+ let { versionColumn: t, patch: n } = e;
12
+ if (t === void 0) return {
13
+ nextVersion: void 0,
14
+ expected: void 0,
15
+ patch: { ...n }
16
+ };
17
+ let r = n[t], i = typeof r == "number" && Number.isFinite(r) ? r : void 0, a = { ...n };
18
+ return delete a[t], {
19
+ nextVersion: i === void 0 ? void 0 : i + 1,
20
+ expected: i,
21
+ patch: a
22
+ };
23
+ }, i = (e) => {
24
+ if (e.expected !== void 0 && (e.current === null || e.current !== e.expected)) return new t({
25
+ table: e.table,
26
+ id: e.id,
27
+ expected: e.expected,
28
+ actual: e.current
29
+ });
30
+ }, a = 1, o = e.DateFromNumber, s = e.NullOr(o);
31
+ //#endregion
32
+ export { r as a, t as i, s as n, i as o, a as r, n as s, o as t };
package/dist/wire.d.ts CHANGED
@@ -41,4 +41,25 @@ export declare const timestampMs: Schema.Schema<Date, number>;
41
41
  */
42
42
  export declare const timestampMsOrNull: Schema.Schema<Date | null, number | null>;
43
43
 
44
+ /**
45
+ * A write lost the race.
46
+ *
47
+ * Carries both numbers because "someone else changed it" is not actionable and
48
+ * "you had 3, it is now 7" is: four intervening writes is a different situation
49
+ * from one, and a UI can say so.
50
+ */
51
+ export declare class VersionConflict extends VersionConflict_base {
52
+ }
53
+
54
+ declare const VersionConflict_base: Schema.TaggedErrorClass<VersionConflict, "VersionConflict", {
55
+ readonly _tag: Schema.tag<"VersionConflict">;
56
+ } & {
57
+ table: typeof Schema.String;
58
+ id: typeof Schema.String;
59
+ /** What the caller believed the row was at. */
60
+ expected: typeof Schema.Number;
61
+ /** What it is actually at. `null` when the row is gone entirely. */
62
+ actual: Schema.NullOr<typeof Schema.Number>;
63
+ }>;
64
+
44
65
  export { }
package/dist/wire.js CHANGED
@@ -1,5 +1,2 @@
1
- import { Schema as e } from "effect";
2
- //#region src/wire.ts
3
- var t = e.DateFromNumber, n = e.NullOr(t);
4
- //#endregion
5
- export { t as timestampMs, n as timestampMsOrNull };
1
+ import { i as e, n as t, t as n } from "./wire-B28cPjEp.js";
2
+ export { e as VersionConflict, n as timestampMs, t as timestampMsOrNull };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/database",
3
- "version": "0.62.3",
3
+ "version": "0.64.0",
4
4
  "description": "Browser-safe schema DSL, query builder, and cross-dialect migration planner for Voltro — one schema, every SQL backend.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@effect/sql": "^0.52.0",
47
- "@voltro/logger": "0.62.3",
47
+ "@voltro/logger": "0.64.0",
48
48
  "typeid-js": "^1.2.0",
49
49
  "ulidx": "^2.4.1"
50
50
  },