@atscript/db 0.1.54 → 0.1.55
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/db-error-Cepx-RsQ.mjs +29 -0
- package/dist/db-error-D8tQhNgM.cjs +40 -0
- package/dist/{db-readable-ktHqF277.d.cts → db-readable-DtrC0BGF.d.cts} +122 -115
- package/dist/{db-readable-GBjlsJXR.d.mts → db-readable-RTtqL7H4.d.mts} +123 -116
- package/dist/{db-space-DB0MT6B3.d.cts → db-space-BqVLHVq7.d.cts} +14 -1
- package/dist/{db-space-DpaXOdRp.d.mts → db-space-D3QSKx2B.d.mts} +14 -1
- package/dist/{db-validator-plugin-Cz4QoDWg.d.cts → db-validator-plugin-DDvYyv5t.d.mts} +10 -0
- package/dist/{db-validator-plugin-KC4aNIQq.d.mts → db-validator-plugin-DRGMCEn3.d.cts} +10 -0
- package/dist/{db-view-DjDKgytJ.cjs → db-view-DIGN4079.cjs} +81 -19
- package/dist/{db-view-B1j_IKSf.mjs → db-view-DNwX6_4x.mjs} +72 -10
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -3
- package/dist/{nested-writer-CNDyhg2L.mjs → nested-writer-CT2rLURx.mjs} +9 -16
- package/dist/{nested-writer-BIQ6EfaR.cjs → nested-writer-v_LPR1yJ.cjs} +14 -27
- package/dist/ops.d.mts +1 -1
- package/dist/plugin.cjs +99 -9
- package/dist/plugin.mjs +99 -9
- package/dist/rel.cjs +1 -1
- package/dist/rel.d.cts +2 -2
- package/dist/rel.d.mts +2 -2
- package/dist/rel.mjs +1 -1
- package/dist/shared.cjs +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/sync.cjs +5 -5
- package/dist/sync.d.cts +2 -2
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +5 -5
- package/dist/{validator-D_7Fqzs4.mjs → validator-BB5h1Le3.mjs} +42 -0
- package/dist/{validator-0iGuvGOD.cjs → validator-BIuw_T0k.cjs} +42 -0
- package/dist/validator.cjs +1 -1
- package/dist/validator.d.cts +1 -1
- package/dist/validator.d.mts +3 -3
- package/dist/validator.mjs +1 -1
- package/package.json +6 -6
- /package/dist/{control-D1QdBO21.cjs → control-CDnwVj4q.cjs} +0 -0
- /package/dist/{control-DBd_ff5-.mjs → control-ExEKWYBE.mjs} +0 -0
- /package/dist/{ops-DcHDxrjX.d.mts → ops-C61kelof.d.mts} +0 -0
- /package/dist/{validation-utils-BiG3pLP0.cjs → validation-utils-B9WJv9aH.cjs} +0 -0
- /package/dist/{validation-utils-aNrgK-cj.mjs → validation-utils-Bh7RVrVl.mjs} +0 -0
- /package/dist/{validator-BeXlQISk.d.mts → validator-DttN2e5_.d.mts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_db_error = require("./db-error-D8tQhNgM.cjs");
|
|
1
2
|
const require_ops = require("./ops.cjs");
|
|
2
3
|
let _atscript_typescript_utils = require("@atscript/typescript/utils");
|
|
3
4
|
//#region src/patch/patch-types.ts
|
|
@@ -124,6 +125,11 @@ function handleNavField(ctx, def, value, dbCtx, isTo, isFrom, isVia) {
|
|
|
124
125
|
return false;
|
|
125
126
|
}
|
|
126
127
|
if (value === void 0) return true;
|
|
128
|
+
if (isFrom && dbCtx.depthCheck) {
|
|
129
|
+
const { limit, fromDepthMap } = dbCtx.depthCheck;
|
|
130
|
+
const depth = fromDepthMap.get(stripNumericSegments(ctx.path));
|
|
131
|
+
if (depth !== void 0 && depth > limit) throw new require_db_error.DepthLimitExceededError(dotPathToBracket(ctx.path), limit, depth);
|
|
132
|
+
}
|
|
127
133
|
if (dbCtx.mode === "patch") {
|
|
128
134
|
if (isFrom || isVia) {
|
|
129
135
|
if (isPatchOperatorObject(value)) return validateNavPatchOps(ctx, def, value, fieldName);
|
|
@@ -233,6 +239,42 @@ function validatePartialItems(ctx, arrayDef, items, op, isMerge) {
|
|
|
233
239
|
}
|
|
234
240
|
return true;
|
|
235
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Returns `true` when every char in `[start, end)` is an ASCII digit.
|
|
244
|
+
* Matches segments that represent array indices in dot-notation paths.
|
|
245
|
+
*/
|
|
246
|
+
function isNumericSegment(path, start, end) {
|
|
247
|
+
if (start >= end) return false;
|
|
248
|
+
for (let i = start; i < end; i++) {
|
|
249
|
+
const c = path.charCodeAt(i);
|
|
250
|
+
if (c < 48 || c > 57) return false;
|
|
251
|
+
}
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Strips numeric (array-index) segments from a dot-notation path.
|
|
256
|
+
* `"children.0.grandchildren.10.foo"` → `"children.grandchildren.foo"`.
|
|
257
|
+
*/
|
|
258
|
+
function stripNumericSegments(path) {
|
|
259
|
+
if (!path) return path;
|
|
260
|
+
let out = "";
|
|
261
|
+
let segStart = 0;
|
|
262
|
+
for (let i = 0; i <= path.length; i++) if (i === path.length || path.charCodeAt(i) === 46) {
|
|
263
|
+
if (!isNumericSegment(path, segStart, i)) {
|
|
264
|
+
if (out) out += ".";
|
|
265
|
+
out += path.slice(segStart, i);
|
|
266
|
+
}
|
|
267
|
+
segStart = i + 1;
|
|
268
|
+
}
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Converts dot-notation array-index paths to bracket notation:
|
|
273
|
+
* `"children.0.grandchildren.1.foo"` → `"children[0].grandchildren[1].foo"`.
|
|
274
|
+
*/
|
|
275
|
+
function dotPathToBracket(path) {
|
|
276
|
+
return path.replace(/\.(\d+)/g, "[$1]");
|
|
277
|
+
}
|
|
236
278
|
//#endregion
|
|
237
279
|
//#region src/validator.ts
|
|
238
280
|
/** Singleton db validator plugin — stateless, safe to share across all validators. */
|
package/dist/validator.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_ops = require("./ops.cjs");
|
|
3
|
-
const require_validator = require("./validator-
|
|
3
|
+
const require_validator = require("./validator-BIuw_T0k.cjs");
|
|
4
4
|
exports.$dec = require_ops.$dec;
|
|
5
5
|
exports.$inc = require_ops.$inc;
|
|
6
6
|
exports.$insert = require_ops.$insert;
|
package/dist/validator.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as $remove, c as $upsert, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, r as $insert, s as $update, t as $dec } from "./ops-DXJ4Zw0P.cjs";
|
|
2
|
-
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-
|
|
2
|
+
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-DRGMCEn3.cjs";
|
|
3
3
|
import { a as dbPlugin, c as TArrayPatch, i as buildValidationContext, l as TDbPatch, n as ValidatorMode, o as forceNavNonOptional, r as buildDbValidator, s as isNavRelation, t as ValidationContext, u as getKeyProps } from "./validator-_z_A3cKa.cjs";
|
|
4
4
|
export { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, DbValidationContext, TArrayPatch, TDbFieldOp, TDbPatch, ValidationContext, ValidatorMode, buildDbValidator, buildValidationContext, createDbValidatorPlugin, dbPlugin, forceNavNonOptional, getKeyProps, isDbFieldOp, isNavRelation };
|
package/dist/validator.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as $remove, c as $upsert, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, r as $insert, s as $update, t as $dec } from "./ops-
|
|
2
|
-
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-
|
|
3
|
-
import { a as dbPlugin, c as TArrayPatch, i as buildValidationContext, l as TDbPatch, n as ValidatorMode, o as forceNavNonOptional, r as buildDbValidator, s as isNavRelation, t as ValidationContext, u as getKeyProps } from "./validator-
|
|
1
|
+
import { a as $remove, c as $upsert, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, r as $insert, s as $update, t as $dec } from "./ops-C61kelof.mjs";
|
|
2
|
+
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-DDvYyv5t.mjs";
|
|
3
|
+
import { a as dbPlugin, c as TArrayPatch, i as buildValidationContext, l as TDbPatch, n as ValidatorMode, o as forceNavNonOptional, r as buildDbValidator, s as isNavRelation, t as ValidationContext, u as getKeyProps } from "./validator-DttN2e5_.mjs";
|
|
4
4
|
export { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, DbValidationContext, TArrayPatch, TDbFieldOp, TDbPatch, ValidationContext, ValidatorMode, buildDbValidator, buildValidationContext, createDbValidatorPlugin, dbPlugin, forceNavNonOptional, getKeyProps, isDbFieldOp, isNavRelation };
|
package/dist/validator.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, isDbFieldOp } from "./ops.mjs";
|
|
2
|
-
import { a as isNavRelation, i as forceNavNonOptional, n as buildValidationContext, o as createDbValidatorPlugin, r as dbPlugin, s as getKeyProps, t as buildDbValidator } from "./validator-
|
|
2
|
+
import { a as isNavRelation, i as forceNavNonOptional, n as buildValidationContext, o as createDbValidatorPlugin, r as dbPlugin, s as getKeyProps, t as buildDbValidator } from "./validator-BB5h1Le3.mjs";
|
|
3
3
|
export { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, buildDbValidator, buildValidationContext, createDbValidatorPlugin, dbPlugin, forceNavNonOptional, getKeyProps, isDbFieldOp, isNavRelation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.55",
|
|
4
4
|
"description": "Database adapter utilities for atscript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"access": "public"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@atscript/core": "^0.1.
|
|
71
|
-
"@atscript/typescript": "^0.1.
|
|
70
|
+
"@atscript/core": "^0.1.50",
|
|
71
|
+
"@atscript/typescript": "^0.1.50",
|
|
72
72
|
"@uniqu/core": "^0.1.5",
|
|
73
|
-
"unplugin-atscript": "^0.1.
|
|
73
|
+
"unplugin-atscript": "^0.1.50"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@atscript/core": "^0.1.
|
|
77
|
-
"@atscript/typescript": "^0.1.
|
|
76
|
+
"@atscript/core": "^0.1.50",
|
|
77
|
+
"@atscript/typescript": "^0.1.50",
|
|
78
78
|
"@uniqu/core": "^0.1.5"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|