@atscript/db 0.1.161 → 0.1.163
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/agg.cjs +1 -1
- package/dist/agg.d.cts +1 -1
- package/dist/agg.d.mts +1 -1
- package/dist/agg.mjs +1 -1
- package/dist/{aggregate-fns-B_sgl4mB.mjs → aggregate-fns-DsS9UQVB.mjs} +1 -1
- package/dist/{aggregate-fns-DFtKAv7Q.cjs → aggregate-fns-DupYzFD7.cjs} +1 -1
- package/dist/{buckets-B4T_alUe.d.cts → buckets-B8UOod-v.d.cts} +488 -57
- package/dist/{buckets-8mG67Mtw.d.mts → buckets-CHyspjYP.d.mts} +488 -57
- package/dist/{column-diff-DpeUbhEI.cjs → column-diff-BIGX3sRH.cjs} +853 -232
- package/dist/{column-diff-DR1glykD.mjs → column-diff-BfNIlMwX.mjs} +836 -233
- package/dist/{validator-B3xlbrWf.d.cts → db-error-B_DRL1E9.d.cts} +18 -89
- package/dist/{validator-B3xlbrWf.d.mts → db-error-B_DRL1E9.d.mts} +18 -89
- package/dist/{db-error-JcfJqqpk.cjs → db-error-DmF1_xrz.cjs} +13 -0
- package/dist/{db-error-eSsQX7rt.mjs → db-error-hraC12B9.mjs} +8 -1
- package/dist/{db-validator-plugin-BWy60OvG.d.cts → db-validator-plugin-wRqMYNBI.d.cts} +6 -0
- package/dist/{db-validator-plugin-BWy60OvG.d.mts → db-validator-plugin-wRqMYNBI.d.mts} +6 -0
- package/dist/{fk-diff-5gX42hBt.d.mts → fk-diff-BNGawZi9.d.cts} +34 -10
- package/dist/{fk-diff-BWdQ7kRZ.d.cts → fk-diff-rj9N2QLw.d.mts} +34 -10
- package/dist/index.cjs +15 -11
- package/dist/index.d.cts +24 -21
- package/dist/index.d.mts +24 -21
- package/dist/index.mjs +10 -12
- package/dist/{nested-writer-BOj_c_lI.mjs → nested-writer-ClUX0DB0.mjs} +16 -22
- package/dist/{nested-writer-Bl1SZS7x.cjs → nested-writer-yCy6wGuN.cjs} +16 -22
- package/dist/{object-CtPYTIvy.d.cts → object-Czia_qD4.d.cts} +7 -1
- package/dist/{object-CtPYTIvy.d.mts → object-Czia_qD4.d.mts} +7 -1
- package/dist/{object-Djg28csK.cjs → object-GjsuPNqo.cjs} +19 -0
- package/dist/{object-TkiJQ-Dp.mjs → object-PQ1J8jri.mjs} +14 -1
- package/dist/ops.cjs +6 -21
- package/dist/ops.mjs +6 -21
- package/dist/plugin.cjs +263 -323
- package/dist/plugin.mjs +163 -223
- package/dist/rel.cjs +2 -2
- package/dist/rel.d.cts +3 -3
- package/dist/rel.d.mts +3 -3
- package/dist/rel.mjs +2 -2
- package/dist/{relation-helpers-17_2f5hX.d.mts → relation-helpers-DloMywNs.d.cts} +1 -1
- package/dist/{relation-helpers-BLBrLQYi.d.cts → relation-helpers-zwt19E7r.d.mts} +1 -1
- package/dist/{relation-loader-DeulLrAw.cjs → relation-loader-DujL_Mh9.cjs} +1 -1
- package/dist/{relation-loader-CNBMPfRr.mjs → relation-loader-Qv3LrQ42.mjs} +1 -1
- package/dist/{search-fields-CT_UZ9fg.cjs → search-fields-B49-RCWd.cjs} +65 -1
- package/dist/{search-fields-CE8cmj9X.mjs → search-fields-BPNsxrCk.mjs} +48 -2
- package/dist/search-fields-CHqqcC3W.d.cts +30 -0
- package/dist/search-fields-CHqqcC3W.d.mts +30 -0
- package/dist/server-stamped-B6XbUQ4p.cjs +33 -0
- package/dist/server-stamped-BoP56K9M.mjs +22 -0
- package/dist/shared.cjs +42 -26
- package/dist/shared.d.cts +98 -4
- package/dist/shared.d.mts +98 -4
- package/dist/shared.mjs +4 -2
- package/dist/sync.cjs +228 -65
- package/dist/sync.d.cts +41 -5
- package/dist/sync.d.mts +41 -5
- package/dist/sync.mjs +228 -66
- package/dist/{validator-B4YDLUkj.cjs → validator-DK9Ijpo7.cjs} +3 -2
- package/dist/validator-DX97RzC2.d.cts +108 -0
- package/dist/validator-DX97RzC2.d.mts +108 -0
- package/dist/{validator-B3fPJjS1.mjs → validator-DuDWsIdQ.mjs} +3 -2
- package/dist/validator.cjs +6 -3
- package/dist/validator.d.cts +5 -4
- package/dist/validator.d.mts +5 -4
- package/dist/validator.mjs +5 -4
- package/dist/{validation-utils-BGjqc2jU.mjs → view-validation-BcgDq7M9.mjs} +364 -20
- package/dist/{validation-utils-CtLNlBtB.cjs → view-validation-BiDLCYMw.cjs} +452 -18
- package/package.json +6 -6
|
@@ -62,5 +62,18 @@ function deletePath(target, path) {
|
|
|
62
62
|
}
|
|
63
63
|
if (current !== null && typeof current === "object" && !Array.isArray(current)) delete current[segments[segments.length - 1]];
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* `JSON.stringify` with object keys sorted at every level — one string per
|
|
67
|
+
* JSON value, whatever its key order (`{"b":1,"a":2}` = `{"a":2,"b":1}`).
|
|
68
|
+
* @since 0.1.162
|
|
69
|
+
*/
|
|
70
|
+
function stableJson(value) {
|
|
71
|
+
return JSON.stringify(value, (_key, v) => {
|
|
72
|
+
if (v === null || typeof v !== "object" || Array.isArray(v)) return v;
|
|
73
|
+
const sorted = {};
|
|
74
|
+
for (const k of Object.keys(v).toSorted()) sorted[k] = v[k];
|
|
75
|
+
return sorted;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
65
78
|
//#endregion
|
|
66
|
-
export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, selfOrAncestor as o, getPath as r, deletePath as t };
|
|
79
|
+
export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, selfOrAncestor as o, getPath as r, stableJson as s, deletePath as t };
|
package/dist/ops.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_db_error = require("./db-error-
|
|
2
|
+
const require_db_error = require("./db-error-DmF1_xrz.cjs");
|
|
3
3
|
//#region src/ops.ts
|
|
4
4
|
/** Increment a numeric field by `value` (default 1). */
|
|
5
5
|
function $inc(value = 1) {
|
|
@@ -175,10 +175,7 @@ function reconcileCas(data, versionColumn, target) {
|
|
|
175
175
|
let expected;
|
|
176
176
|
if (hasCas) {
|
|
177
177
|
expected = separateCas(data, versionColumn);
|
|
178
|
-
if (hasVersion && versionValue !== expected) throw
|
|
179
|
-
path: "$cas",
|
|
180
|
-
message: `Ambiguous version: "${versionColumn}" and "$cas.${versionColumn}" differ`
|
|
181
|
-
}]);
|
|
178
|
+
if (hasVersion && versionValue !== expected) throw require_db_error.invalidQuery("$cas", `Ambiguous version: "${versionColumn}" and "$cas.${versionColumn}" differ`);
|
|
182
179
|
} else expected = versionValue;
|
|
183
180
|
if (target === "cas") {
|
|
184
181
|
delete data[versionColumn];
|
|
@@ -188,28 +185,16 @@ function reconcileCas(data, versionColumn, target) {
|
|
|
188
185
|
}
|
|
189
186
|
function separateCas(data, versionColumn) {
|
|
190
187
|
if (!("$cas" in data)) return void 0;
|
|
191
|
-
if (versionColumn === void 0) throw
|
|
192
|
-
path: "$cas",
|
|
193
|
-
message: "$cas operator: table has no @db.column.version; cannot use $cas"
|
|
194
|
-
}]);
|
|
188
|
+
if (versionColumn === void 0) throw require_db_error.invalidQuery("$cas", "$cas operator: table has no @db.column.version; cannot use $cas");
|
|
195
189
|
const raw = data.$cas;
|
|
196
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw
|
|
197
|
-
path: "$cas",
|
|
198
|
-
message: "$cas operator: must be a plain object"
|
|
199
|
-
}]);
|
|
190
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw require_db_error.invalidQuery("$cas", "$cas operator: must be a plain object");
|
|
200
191
|
const map = raw;
|
|
201
192
|
let foundKey;
|
|
202
193
|
for (const k in map) {
|
|
203
|
-
if (foundKey !== void 0) throw
|
|
204
|
-
path: "$cas",
|
|
205
|
-
message: "$cas operator: expected exactly one entry (v1 single-column CAS)"
|
|
206
|
-
}]);
|
|
194
|
+
if (foundKey !== void 0) throw require_db_error.invalidQuery("$cas", "$cas operator: expected exactly one entry (v1 single-column CAS)");
|
|
207
195
|
foundKey = k;
|
|
208
196
|
}
|
|
209
|
-
if (foundKey === void 0) throw
|
|
210
|
-
path: "$cas",
|
|
211
|
-
message: "$cas operator: must contain a single version entry"
|
|
212
|
-
}]);
|
|
197
|
+
if (foundKey === void 0) throw require_db_error.invalidQuery("$cas", "$cas operator: must contain a single version entry");
|
|
213
198
|
if (versionColumn !== void 0 && foundKey !== versionColumn) throw new require_db_error.DbError("INVALID_QUERY", [{
|
|
214
199
|
path: `$cas.${foundKey}`,
|
|
215
200
|
message: `$cas operator: key "${foundKey}" does not match version column "${versionColumn}"`
|
package/dist/ops.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as DbError } from "./db-error-
|
|
1
|
+
import { c as invalidQuery, r as DbError } from "./db-error-hraC12B9.mjs";
|
|
2
2
|
//#region src/ops.ts
|
|
3
3
|
/** Increment a numeric field by `value` (default 1). */
|
|
4
4
|
function $inc(value = 1) {
|
|
@@ -174,10 +174,7 @@ function reconcileCas(data, versionColumn, target) {
|
|
|
174
174
|
let expected;
|
|
175
175
|
if (hasCas) {
|
|
176
176
|
expected = separateCas(data, versionColumn);
|
|
177
|
-
if (hasVersion && versionValue !== expected) throw
|
|
178
|
-
path: "$cas",
|
|
179
|
-
message: `Ambiguous version: "${versionColumn}" and "$cas.${versionColumn}" differ`
|
|
180
|
-
}]);
|
|
177
|
+
if (hasVersion && versionValue !== expected) throw invalidQuery("$cas", `Ambiguous version: "${versionColumn}" and "$cas.${versionColumn}" differ`);
|
|
181
178
|
} else expected = versionValue;
|
|
182
179
|
if (target === "cas") {
|
|
183
180
|
delete data[versionColumn];
|
|
@@ -187,28 +184,16 @@ function reconcileCas(data, versionColumn, target) {
|
|
|
187
184
|
}
|
|
188
185
|
function separateCas(data, versionColumn) {
|
|
189
186
|
if (!("$cas" in data)) return void 0;
|
|
190
|
-
if (versionColumn === void 0) throw
|
|
191
|
-
path: "$cas",
|
|
192
|
-
message: "$cas operator: table has no @db.column.version; cannot use $cas"
|
|
193
|
-
}]);
|
|
187
|
+
if (versionColumn === void 0) throw invalidQuery("$cas", "$cas operator: table has no @db.column.version; cannot use $cas");
|
|
194
188
|
const raw = data.$cas;
|
|
195
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw
|
|
196
|
-
path: "$cas",
|
|
197
|
-
message: "$cas operator: must be a plain object"
|
|
198
|
-
}]);
|
|
189
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw invalidQuery("$cas", "$cas operator: must be a plain object");
|
|
199
190
|
const map = raw;
|
|
200
191
|
let foundKey;
|
|
201
192
|
for (const k in map) {
|
|
202
|
-
if (foundKey !== void 0) throw
|
|
203
|
-
path: "$cas",
|
|
204
|
-
message: "$cas operator: expected exactly one entry (v1 single-column CAS)"
|
|
205
|
-
}]);
|
|
193
|
+
if (foundKey !== void 0) throw invalidQuery("$cas", "$cas operator: expected exactly one entry (v1 single-column CAS)");
|
|
206
194
|
foundKey = k;
|
|
207
195
|
}
|
|
208
|
-
if (foundKey === void 0) throw
|
|
209
|
-
path: "$cas",
|
|
210
|
-
message: "$cas operator: must contain a single version entry"
|
|
211
|
-
}]);
|
|
196
|
+
if (foundKey === void 0) throw invalidQuery("$cas", "$cas operator: must contain a single version entry");
|
|
212
197
|
if (versionColumn !== void 0 && foundKey !== versionColumn) throw new DbError("INVALID_QUERY", [{
|
|
213
198
|
path: `$cas.${foundKey}`,
|
|
214
199
|
message: `$cas operator: key "${foundKey}" does not match version column "${versionColumn}"`
|