@atscript/db 0.1.43 → 0.1.45
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-readable-Cc868K54.d.mts → db-readable-D9odJuSf.d.mts} +1 -1
- package/dist/{db-space-crCFv3DF.d.mts → db-space-7bf9_IWC.d.mts} +1 -1
- package/dist/{db-view-DSK76uc9.mjs → db-view-7Y5N4muD.mjs} +19 -266
- package/dist/{db-view-CcUjETIF.cjs → db-view-BMPRfGjB.cjs} +20 -279
- package/dist/index.cjs +16 -3
- package/dist/index.d.cts +3 -28
- package/dist/index.d.mts +6 -31
- package/dist/index.mjs +4 -3
- package/dist/ops.d.mts +1 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.mjs +1 -1
- package/dist/rel.d.mts +2 -2
- package/dist/shared.cjs +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/sync.cjs +4 -3
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +5 -3
- package/dist/validator-0iGuvGOD.cjs +337 -0
- package/dist/validator-BeXlQISk.d.mts +69 -0
- package/dist/validator-D_7Fqzs4.mjs +296 -0
- package/dist/validator-_z_A3cKa.d.cts +69 -0
- package/dist/validator.cjs +19 -0
- package/dist/validator.d.cts +4 -0
- package/dist/validator.d.mts +4 -0
- package/dist/validator.mjs +3 -0
- package/package.json +11 -6
- /package/dist/{control-DRgryKeg.cjs → control-D1QdBO21.cjs} +0 -0
- /package/dist/{control-IANbnfjG.mjs → control-DBd_ff5-.mjs} +0 -0
- /package/dist/{db-validator-plugin-BLMVdi9z.d.mts → db-validator-plugin-KC4aNIQq.d.mts} +0 -0
- /package/dist/{ops-BdRAFLKY.d.mts → ops-DcHDxrjX.d.mts} +0 -0
- /package/dist/{validation-utils-DVJDijnB.cjs → validation-utils-BiG3pLP0.cjs} +0 -0
- /package/dist/{validation-utils-DhjIjP1-.mjs → validation-utils-aNrgK-cj.mjs} +0 -0
|
@@ -2,6 +2,7 @@ const require_nested_writer = require("./nested-writer-BIQ6EfaR.cjs");
|
|
|
2
2
|
const require_agg = require("./agg.cjs");
|
|
3
3
|
const require_relation_helpers = require("./relation-helpers-BYvsE1tR.cjs");
|
|
4
4
|
const require_ops = require("./ops.cjs");
|
|
5
|
+
const require_validator = require("./validator-0iGuvGOD.cjs");
|
|
5
6
|
let _atscript_typescript_utils = require("@atscript/typescript/utils");
|
|
6
7
|
let node_async_hooks = require("node:async_hooks");
|
|
7
8
|
//#region src/logger.ts
|
|
@@ -2106,224 +2107,6 @@ var ApplicationIntegrity = class extends IntegrityStrategy {
|
|
|
2106
2107
|
}
|
|
2107
2108
|
};
|
|
2108
2109
|
//#endregion
|
|
2109
|
-
//#region src/patch/patch-types.ts
|
|
2110
|
-
/**
|
|
2111
|
-
* Extracts `@expect.array.key` properties from an array-of-objects type.
|
|
2112
|
-
* These keys uniquely identify an element inside the array and are used
|
|
2113
|
-
* for `$update`, `$remove`, and `$upsert` operations.
|
|
2114
|
-
*
|
|
2115
|
-
* @param def - Atscript array type definition.
|
|
2116
|
-
* @returns Set of property names marked as keys; empty set if none.
|
|
2117
|
-
*/
|
|
2118
|
-
function getKeyProps(def) {
|
|
2119
|
-
if (def.type.of.type.kind === "object") {
|
|
2120
|
-
const objType = def.type.of.type;
|
|
2121
|
-
const keyProps = /* @__PURE__ */ new Set();
|
|
2122
|
-
for (const [key, val] of objType.props.entries()) if (val.metadata.get("expect.array.key")) keyProps.add(key);
|
|
2123
|
-
return keyProps;
|
|
2124
|
-
}
|
|
2125
|
-
return /* @__PURE__ */ new Set();
|
|
2126
|
-
}
|
|
2127
|
-
//#endregion
|
|
2128
|
-
//#region src/db-validator-plugin.ts
|
|
2129
|
-
/** Set of recognised array‑patch operator keys. */
|
|
2130
|
-
const PATCH_OPS = new Set([
|
|
2131
|
-
"$replace",
|
|
2132
|
-
"$insert",
|
|
2133
|
-
"$upsert",
|
|
2134
|
-
"$update",
|
|
2135
|
-
"$remove"
|
|
2136
|
-
]);
|
|
2137
|
-
/**
|
|
2138
|
-
* Returns `true` when `value` looks like a patch‑operator object
|
|
2139
|
-
* (at least one key is a recognised operator and no unknown keys).
|
|
2140
|
-
*/
|
|
2141
|
-
function isPatchOperatorObject(value) {
|
|
2142
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
2143
|
-
const keys = Object.keys(value);
|
|
2144
|
-
if (keys.length === 0) return false;
|
|
2145
|
-
return keys.every((k) => PATCH_OPS.has(k));
|
|
2146
|
-
}
|
|
2147
|
-
/**
|
|
2148
|
-
* Validator plugin for database operations.
|
|
2149
|
-
*
|
|
2150
|
-
* Handles navigation field constraints and delegates to the standard validator
|
|
2151
|
-
* for type checking. The annotated type tree already includes nav fields with
|
|
2152
|
-
* their full target types — this plugin controls WHEN recursion is allowed
|
|
2153
|
-
* based on the operation mode (insert/replace/patch).
|
|
2154
|
-
*
|
|
2155
|
-
* Replaces the old `navFieldsValidatorPlugin` (which blindly skipped all nav
|
|
2156
|
-
* fields) and `_checkNavProps()` (which validated constraints separately).
|
|
2157
|
-
*/
|
|
2158
|
-
function createDbValidatorPlugin() {
|
|
2159
|
-
return (ctx, def, value) => {
|
|
2160
|
-
const dbCtx = ctx.context;
|
|
2161
|
-
if (!dbCtx) return;
|
|
2162
|
-
const isTo = def.metadata.has("db.rel.to");
|
|
2163
|
-
const isFrom = def.metadata.has("db.rel.from");
|
|
2164
|
-
const isVia = def.metadata.has("db.rel.via");
|
|
2165
|
-
if (isTo || isFrom || isVia) return handleNavField(ctx, def, value, dbCtx, isTo, isFrom, isVia);
|
|
2166
|
-
if (dbCtx.mode === "patch") {
|
|
2167
|
-
if (require_ops.isDbFieldOp(value)) {
|
|
2168
|
-
if (dbCtx.flatMap && !isFieldOpAllowed(ctx.path, dbCtx.flatMap, dbCtx.navFields)) {
|
|
2169
|
-
ctx.error("Field operations ($inc/$dec/$mul) are not supported inside @db.json fields or nested objects without @db.patch.strategy \"merge\"");
|
|
2170
|
-
return false;
|
|
2171
|
-
}
|
|
2172
|
-
if (!(def.type.kind === "" && def.type.designType === "number")) {
|
|
2173
|
-
ctx.error("Field operations ($inc/$dec/$mul) can only be applied to numeric fields");
|
|
2174
|
-
return false;
|
|
2175
|
-
}
|
|
2176
|
-
return true;
|
|
2177
|
-
}
|
|
2178
|
-
if (def.type.kind === "array" && dbCtx.flatMap) {
|
|
2179
|
-
const flatEntry = dbCtx.flatMap.get(ctx.path);
|
|
2180
|
-
if (flatEntry?.metadata?.has("db.__topLevelArray") && !flatEntry.metadata.has("db.json")) return handleArrayPatch(ctx, def, value);
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
};
|
|
2184
|
-
}
|
|
2185
|
-
/**
|
|
2186
|
-
* Checks whether a field op is valid at `path`.
|
|
2187
|
-
*
|
|
2188
|
-
* Rejects when:
|
|
2189
|
-
* - The field itself is `@db.json` (ops on opaque blobs are meaningless).
|
|
2190
|
-
* - Any ancestor is `@db.json`.
|
|
2191
|
-
* - Any ancestor is a nested object without `@db.patch.strategy "merge"`.
|
|
2192
|
-
*
|
|
2193
|
-
* Accepts immediately when an ancestor is a navigation field (TO/FROM/VIA) —
|
|
2194
|
-
* the nested data is extracted and validated against its own table separately.
|
|
2195
|
-
*/
|
|
2196
|
-
function isFieldOpAllowed(path, flatMap, navFields) {
|
|
2197
|
-
if (flatMap.get(path)?.metadata.has("db.json")) return false;
|
|
2198
|
-
let pos = path.length;
|
|
2199
|
-
while ((pos = path.lastIndexOf(".", pos - 1)) !== -1) {
|
|
2200
|
-
const ancestor = path.slice(0, pos);
|
|
2201
|
-
if (navFields?.has(ancestor)) return true;
|
|
2202
|
-
const entry = flatMap.get(ancestor);
|
|
2203
|
-
if (!entry) continue;
|
|
2204
|
-
if (entry.metadata.has("db.json")) return false;
|
|
2205
|
-
if (entry.type.kind === "object" && entry.metadata.get("db.patch.strategy") !== "merge") return false;
|
|
2206
|
-
}
|
|
2207
|
-
return true;
|
|
2208
|
-
}
|
|
2209
|
-
function handleNavField(ctx, def, value, dbCtx, isTo, isFrom, isVia) {
|
|
2210
|
-
const dotIdx = ctx.path.lastIndexOf(".");
|
|
2211
|
-
const fieldName = dotIdx === -1 ? ctx.path : ctx.path.slice(dotIdx + 1);
|
|
2212
|
-
if (value === null) {
|
|
2213
|
-
ctx.error(`Cannot process null navigation property '${fieldName}'`);
|
|
2214
|
-
return false;
|
|
2215
|
-
}
|
|
2216
|
-
if (value === void 0) return true;
|
|
2217
|
-
if (dbCtx.mode === "patch") {
|
|
2218
|
-
if (isFrom || isVia) {
|
|
2219
|
-
if (isPatchOperatorObject(value)) return validateNavPatchOps(ctx, def, value, fieldName);
|
|
2220
|
-
const relType = isFrom ? "1:N" : "M:N";
|
|
2221
|
-
ctx.error(`Cannot patch ${relType} relation '${fieldName}' with a plain value — use patch operators ({ $insert, $remove, $replace, $update, $upsert })`);
|
|
2222
|
-
return false;
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
if (isVia) return true;
|
|
2226
|
-
}
|
|
2227
|
-
/**
|
|
2228
|
-
* Validates patch operator values against the nav field's target array type.
|
|
2229
|
-
* Each operator's items are validated against the element type.
|
|
2230
|
-
*/
|
|
2231
|
-
function validateNavPatchOps(ctx, def, ops, fieldName) {
|
|
2232
|
-
if (def.type.kind !== "array") {
|
|
2233
|
-
ctx.error(`Cannot use patch operators on non-array relation '${fieldName}'`);
|
|
2234
|
-
return false;
|
|
2235
|
-
}
|
|
2236
|
-
const arrayDef = def;
|
|
2237
|
-
for (const op of [
|
|
2238
|
-
"$replace",
|
|
2239
|
-
"$insert",
|
|
2240
|
-
"$upsert"
|
|
2241
|
-
]) if (ops[op] !== void 0) {
|
|
2242
|
-
if (!ctx.validateAnnotatedType(arrayDef, ops[op])) return false;
|
|
2243
|
-
}
|
|
2244
|
-
for (const op of ["$update", "$remove"]) if (ops[op] !== void 0) {
|
|
2245
|
-
if (!validatePartialItems(ctx, arrayDef, ops[op], op, true)) return false;
|
|
2246
|
-
}
|
|
2247
|
-
return true;
|
|
2248
|
-
}
|
|
2249
|
-
/**
|
|
2250
|
-
* Handles patch‑mode validation for top‑level embedded arrays.
|
|
2251
|
-
*
|
|
2252
|
-
* When the incoming value is:
|
|
2253
|
-
* - A plain array → falls through to default array validation ($replace semantics)
|
|
2254
|
-
* - A patch operator object → validates each operator's payload individually
|
|
2255
|
-
*/
|
|
2256
|
-
function handleArrayPatch(ctx, def, value) {
|
|
2257
|
-
if (Array.isArray(value)) return;
|
|
2258
|
-
if (typeof value !== "object" || value === null) return;
|
|
2259
|
-
const ops = value;
|
|
2260
|
-
const keys = Object.keys(ops);
|
|
2261
|
-
if (keys.length === 0 || !keys.every((k) => PATCH_OPS.has(k))) {
|
|
2262
|
-
if (keys.some((k) => PATCH_OPS.has(k))) {
|
|
2263
|
-
const unknown = keys.filter((k) => !PATCH_OPS.has(k));
|
|
2264
|
-
ctx.error(`Unknown patch operator(s): ${unknown.join(", ")}. Allowed: $replace, $insert, $upsert, $update, $remove`);
|
|
2265
|
-
return false;
|
|
2266
|
-
}
|
|
2267
|
-
return;
|
|
2268
|
-
}
|
|
2269
|
-
for (const op of [
|
|
2270
|
-
"$replace",
|
|
2271
|
-
"$insert",
|
|
2272
|
-
"$upsert"
|
|
2273
|
-
]) if (ops[op] !== void 0) {
|
|
2274
|
-
if (!ctx.validateAnnotatedType(def, ops[op])) return false;
|
|
2275
|
-
}
|
|
2276
|
-
const isMerge = def.metadata.get("db.patch.strategy") === "merge";
|
|
2277
|
-
for (const op of ["$update", "$remove"]) if (ops[op] !== void 0) {
|
|
2278
|
-
if (!validatePartialItems(ctx, def, ops[op], op, isMerge)) return false;
|
|
2279
|
-
}
|
|
2280
|
-
return true;
|
|
2281
|
-
}
|
|
2282
|
-
/**
|
|
2283
|
-
* Validates `$update` / `$remove` items.
|
|
2284
|
-
*
|
|
2285
|
-
* Each item must be an object. For object arrays with `@expect.array.key` fields,
|
|
2286
|
-
* key properties are required and non‑key properties are validated but optional.
|
|
2287
|
-
* For primitive arrays, items are validated directly against the element type.
|
|
2288
|
-
*/
|
|
2289
|
-
function validatePartialItems(ctx, arrayDef, items, op, isMerge) {
|
|
2290
|
-
if (!Array.isArray(items)) {
|
|
2291
|
-
ctx.error(`${op} must be an array`);
|
|
2292
|
-
return false;
|
|
2293
|
-
}
|
|
2294
|
-
const elementDef = arrayDef.type.of;
|
|
2295
|
-
if (elementDef.type.kind !== "object") return ctx.validateAnnotatedType(arrayDef, items);
|
|
2296
|
-
const keyProps = getKeyProps(arrayDef);
|
|
2297
|
-
for (let i = 0; i < items.length; i++) {
|
|
2298
|
-
const item = items[i];
|
|
2299
|
-
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
2300
|
-
ctx.error(`${op}[${i}]: expected object`);
|
|
2301
|
-
return false;
|
|
2302
|
-
}
|
|
2303
|
-
const rec = item;
|
|
2304
|
-
if (keyProps.size > 0) {
|
|
2305
|
-
for (const kp of keyProps) if (rec[kp] === void 0 || rec[kp] === null) {
|
|
2306
|
-
ctx.error(`${op}[${i}]: key field '${kp}' is required`);
|
|
2307
|
-
return false;
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
const objType = elementDef.type;
|
|
2311
|
-
for (const [key, val] of Object.entries(rec)) {
|
|
2312
|
-
const propDef = objType.props.get(key);
|
|
2313
|
-
if (propDef) {
|
|
2314
|
-
if (!ctx.validateAnnotatedType(propDef, val)) return false;
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
if (op === "$update" && isMerge !== true) {
|
|
2318
|
-
for (const [propName, propDef] of objType.props) if (!propDef.optional && !keyProps.has(propName) && rec[propName] === void 0) {
|
|
2319
|
-
ctx.error(`${op}[${i}]: field '${propName}' is required (replace strategy)`);
|
|
2320
|
-
return false;
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
return true;
|
|
2325
|
-
}
|
|
2326
|
-
//#endregion
|
|
2327
2110
|
//#region src/patch/array-ops-resolver.ts
|
|
2328
2111
|
/**
|
|
2329
2112
|
* Resolves array patch operator keys (`__$insert`, `__$remove`, `__$upsert`,
|
|
@@ -2384,7 +2167,7 @@ function resolveArrayOps(update, currentRecord, table) {
|
|
|
2384
2167
|
const raw = currentRecord?.[field] ?? [];
|
|
2385
2168
|
const current = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
2386
2169
|
const arrayType = table.flatMap.get(field);
|
|
2387
|
-
const keyProps = arrayType ? getKeyProps(arrayType) : /* @__PURE__ */ new Set();
|
|
2170
|
+
const keyProps = arrayType ? require_validator.getKeyProps(arrayType) : /* @__PURE__ */ new Set();
|
|
2388
2171
|
const uniqueItems = arrayType?.metadata?.get("expect.array.uniqueItems");
|
|
2389
2172
|
const mergeStrategy = arrayType?.metadata?.get("db.patch.strategy") === "merge";
|
|
2390
2173
|
resolved[field] = applyOps(current, ops, ops.keys && ops.keys.length > 0 ? new Set(ops.keys) : keyProps, !!uniqueItems, mergeStrategy);
|
|
@@ -2515,7 +2298,7 @@ function flattenPatchPayload(payload, prefix, update, table, topLevelArrayTag) {
|
|
|
2515
2298
|
* format the adapter can interpret.
|
|
2516
2299
|
*/
|
|
2517
2300
|
function decomposeArrayPatch(key, value, fieldType, update, _table) {
|
|
2518
|
-
const keyProps = fieldType.type.kind === "array" ? getKeyProps(fieldType) : /* @__PURE__ */ new Set();
|
|
2301
|
+
const keyProps = fieldType.type.kind === "array" ? require_validator.getKeyProps(fieldType) : /* @__PURE__ */ new Set();
|
|
2519
2302
|
if (value.$replace !== void 0) {
|
|
2520
2303
|
update[key] = value.$replace;
|
|
2521
2304
|
return;
|
|
@@ -2562,25 +2345,6 @@ function _translateOpsKeys(ops, meta) {
|
|
|
2562
2345
|
mul: ops.mul ? _translateOpsRecord(ops.mul, meta) : void 0
|
|
2563
2346
|
};
|
|
2564
2347
|
}
|
|
2565
|
-
/**
|
|
2566
|
-
* Forces nav fields non-optional so the plugin handles null/undefined
|
|
2567
|
-
* checks (validator skips optional+null before plugins run).
|
|
2568
|
-
*/
|
|
2569
|
-
function forceNavNonOptional(type) {
|
|
2570
|
-
if (type.metadata?.has("db.rel.to") || type.metadata?.has("db.rel.from") || type.metadata?.has("db.rel.via")) return type.optional ? {
|
|
2571
|
-
...type,
|
|
2572
|
-
optional: false
|
|
2573
|
-
} : type;
|
|
2574
|
-
return type;
|
|
2575
|
-
}
|
|
2576
|
-
/** Makes PK, defaulted, and FK fields optional; forces nav fields non-optional. */
|
|
2577
|
-
function insertReplace(type) {
|
|
2578
|
-
if (type.metadata?.has("meta.id") || type.metadata?.has("db.default") || type.metadata?.has("db.default.increment") || type.metadata?.has("db.default.uuid") || type.metadata?.has("db.default.now") || type.metadata?.has("db.rel.FK")) return {
|
|
2579
|
-
...type,
|
|
2580
|
-
optional: true
|
|
2581
|
-
};
|
|
2582
|
-
return forceNavNonOptional(type);
|
|
2583
|
-
}
|
|
2584
2348
|
var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
2585
2349
|
_cascadeResolver;
|
|
2586
2350
|
_fkLookupResolver;
|
|
@@ -2939,37 +2703,26 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2939
2703
|
* (including inside nav field target types).
|
|
2940
2704
|
*/
|
|
2941
2705
|
_buildValidator(purpose) {
|
|
2942
|
-
const
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
partial: true,
|
|
2952
|
-
replace: forceNavNonOptional
|
|
2953
|
-
});
|
|
2954
|
-
case "bulkReplace": return this.createValidator({
|
|
2706
|
+
const adapterPlugins = this.adapter.getValidatorPlugins();
|
|
2707
|
+
if (purpose === "insert" || purpose === "patch" || purpose === "bulkReplace") {
|
|
2708
|
+
const mode = purpose === "bulkReplace" ? "replace" : purpose;
|
|
2709
|
+
return require_validator.buildDbValidator(this.type, mode, adapterPlugins);
|
|
2710
|
+
}
|
|
2711
|
+
if (purpose === "bulkUpdate") {
|
|
2712
|
+
const plugins = adapterPlugins.length ? [...adapterPlugins, require_validator.dbPlugin] : [require_validator.dbPlugin];
|
|
2713
|
+
const navFields = this._meta.navFields;
|
|
2714
|
+
return this.createValidator({
|
|
2955
2715
|
plugins,
|
|
2956
|
-
|
|
2716
|
+
partial: (_def, path) => {
|
|
2717
|
+
if (path === "") return true;
|
|
2718
|
+
const root = path.split(".")[0];
|
|
2719
|
+
if (navFields.has(root)) return true;
|
|
2720
|
+
return _def.metadata.get("db.patch.strategy") === "merge";
|
|
2721
|
+
},
|
|
2722
|
+
replace: require_validator.forceNavNonOptional
|
|
2957
2723
|
});
|
|
2958
|
-
case "bulkUpdate": {
|
|
2959
|
-
const navFields = this._meta.navFields;
|
|
2960
|
-
return this.createValidator({
|
|
2961
|
-
plugins,
|
|
2962
|
-
partial: (_def, path) => {
|
|
2963
|
-
if (path === "") return true;
|
|
2964
|
-
const root = path.split(".")[0];
|
|
2965
|
-
if (navFields.has(root)) return true;
|
|
2966
|
-
return _def.metadata.get("db.patch.strategy") === "merge";
|
|
2967
|
-
},
|
|
2968
|
-
replace: forceNavNonOptional
|
|
2969
|
-
});
|
|
2970
|
-
}
|
|
2971
|
-
default: return this.createValidator({ plugins });
|
|
2972
2724
|
}
|
|
2725
|
+
return this.createValidator({ plugins: adapterPlugins });
|
|
2973
2726
|
}
|
|
2974
2727
|
};
|
|
2975
2728
|
//#endregion
|
|
@@ -3184,24 +2937,12 @@ Object.defineProperty(exports, "UniquSelect", {
|
|
|
3184
2937
|
return UniquSelect;
|
|
3185
2938
|
}
|
|
3186
2939
|
});
|
|
3187
|
-
Object.defineProperty(exports, "createDbValidatorPlugin", {
|
|
3188
|
-
enumerable: true,
|
|
3189
|
-
get: function() {
|
|
3190
|
-
return createDbValidatorPlugin;
|
|
3191
|
-
}
|
|
3192
|
-
});
|
|
3193
2940
|
Object.defineProperty(exports, "decomposePatch", {
|
|
3194
2941
|
enumerable: true,
|
|
3195
2942
|
get: function() {
|
|
3196
2943
|
return decomposePatch;
|
|
3197
2944
|
}
|
|
3198
2945
|
});
|
|
3199
|
-
Object.defineProperty(exports, "getKeyProps", {
|
|
3200
|
-
enumerable: true,
|
|
3201
|
-
get: function() {
|
|
3202
|
-
return getKeyProps;
|
|
3203
|
-
}
|
|
3204
|
-
});
|
|
3205
2946
|
Object.defineProperty(exports, "resolveDesignType", {
|
|
3206
2947
|
enumerable: true,
|
|
3207
2948
|
get: function() {
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_nested_writer = require("./nested-writer-BIQ6EfaR.cjs");
|
|
3
|
-
const require_db_view = require("./db-view-
|
|
3
|
+
const require_db_view = require("./db-view-BMPRfGjB.cjs");
|
|
4
4
|
const require_ops = require("./ops.cjs");
|
|
5
|
+
const require_validator = require("./validator-0iGuvGOD.cjs");
|
|
5
6
|
let _uniqu_core = require("@uniqu/core");
|
|
6
7
|
//#region src/table/db-space.ts
|
|
7
8
|
/**
|
|
@@ -138,6 +139,14 @@ function translateQueryTree(node, resolveField) {
|
|
|
138
139
|
return { [leftField]: { [comp.op]: comp.right } };
|
|
139
140
|
}
|
|
140
141
|
//#endregion
|
|
142
|
+
exports.$dec = require_ops.$dec;
|
|
143
|
+
exports.$inc = require_ops.$inc;
|
|
144
|
+
exports.$insert = require_ops.$insert;
|
|
145
|
+
exports.$mul = require_ops.$mul;
|
|
146
|
+
exports.$remove = require_ops.$remove;
|
|
147
|
+
exports.$replace = require_ops.$replace;
|
|
148
|
+
exports.$update = require_ops.$update;
|
|
149
|
+
exports.$upsert = require_ops.$upsert;
|
|
141
150
|
exports.ApplicationIntegrity = require_db_view.ApplicationIntegrity;
|
|
142
151
|
exports.AtscriptDbReadable = require_db_view.AtscriptDbReadable;
|
|
143
152
|
exports.AtscriptDbTable = require_db_view.AtscriptDbTable;
|
|
@@ -153,17 +162,21 @@ exports.NoopLogger = require_db_view.NoopLogger;
|
|
|
153
162
|
exports.RelationalFieldMapper = require_db_view.RelationalFieldMapper;
|
|
154
163
|
exports.TableMetadata = require_db_view.TableMetadata;
|
|
155
164
|
exports.UniquSelect = require_db_view.UniquSelect;
|
|
165
|
+
exports.buildDbValidator = require_validator.buildDbValidator;
|
|
166
|
+
exports.buildValidationContext = require_validator.buildValidationContext;
|
|
156
167
|
Object.defineProperty(exports, "computeInsights", {
|
|
157
168
|
enumerable: true,
|
|
158
169
|
get: function() {
|
|
159
170
|
return _uniqu_core.computeInsights;
|
|
160
171
|
}
|
|
161
172
|
});
|
|
162
|
-
exports.createDbValidatorPlugin =
|
|
173
|
+
exports.createDbValidatorPlugin = require_validator.createDbValidatorPlugin;
|
|
163
174
|
exports.decomposePatch = require_db_view.decomposePatch;
|
|
175
|
+
exports.forceNavNonOptional = require_validator.forceNavNonOptional;
|
|
164
176
|
exports.getDbFieldOp = require_ops.getDbFieldOp;
|
|
165
|
-
exports.getKeyProps =
|
|
177
|
+
exports.getKeyProps = require_validator.getKeyProps;
|
|
166
178
|
exports.isDbFieldOp = require_ops.isDbFieldOp;
|
|
179
|
+
exports.isNavRelation = require_validator.isNavRelation;
|
|
167
180
|
Object.defineProperty(exports, "isPrimitive", {
|
|
168
181
|
enumerable: true,
|
|
169
182
|
get: function() {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { $ as Uniquery, A as TDbForeignKey, B as TExistingColumn, C as TCascadeTarget, D as TDbDefaultValue, E as TDbDefaultFn, F as TDbInsertResult, G as TMetadataOverrides, H as TFkLookupResolver, I as TDbReferentialAction, J as TTableOptionDiff, K as TSearchIndexInfo, L as TDbRelation, M as TDbIndexField, N as TDbIndexType, O as TDbDeleteResult, P as TDbInsertManyResult, Q as TypedWithRelation, R as TDbStorageType, S as TCascadeResolver, T as TDbCollation, U as TFkLookupTarget, V as TExistingTableOption, W as TIdDescriptor, X as TValueFormatterPair, Y as TTableResolver, Z as TWriteTableResolver, _ as DbQuery, a as FieldMappingStrategy, b as NavPropsOf, c as NoopLogger, d as AggregateExpr, et as UniqueryControls, f as AggregateFn, g as DbControls, h as AtscriptDbWritable, i as DocumentFieldMapper, j as TDbIndex, k as TDbFieldMeta, l as TGenericLogger, m as AggregateResult, n as DbResponse, nt as UniquSelect, o as BaseDbAdapter, p as AggregateQuery, q as TSyncColumnResult, r as resolveDesignType, s as TableMetadata, t as AtscriptDbReadable, tt as WithRelation, u as AggregateControls, v as FieldOpsFor, w as TColumnDiff, x as OwnPropsOf, y as FilterExpr, z as TDbUpdateResult } from "./db-readable-C3C-qPcP.cjs";
|
|
2
|
-
import { d as getDbFieldOp, f as isDbFieldOp, l as TDbFieldOp, p as separateFieldOps, u as TFieldOps } from "./ops-DXJ4Zw0P.cjs";
|
|
2
|
+
import { a as $remove, c as $upsert, d as getDbFieldOp, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, p as separateFieldOps, r as $insert, s as $update, t as $dec, u as TFieldOps } from "./ops-DXJ4Zw0P.cjs";
|
|
3
3
|
import { a as AtscriptQueryComparison, c as AtscriptRef, d as translateQueryTree, f as AtscriptDbTable, i as TViewColumnMapping, l as TViewJoin, m as NativeIntegrity, n as TAdapterFactory, o as AtscriptQueryFieldRef, p as IntegrityStrategy, r as AtscriptDbView, s as AtscriptQueryNode, t as DbSpace, u as TViewPlan } from "./db-space-Dgf-CphX.cjs";
|
|
4
4
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-Cz4QoDWg.cjs";
|
|
5
|
+
import { 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";
|
|
5
6
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
6
|
-
import { TAtscriptAnnotatedType, TAtscriptTypeArray } from "@atscript/typescript/utils";
|
|
7
7
|
|
|
8
8
|
//#region src/strategies/relational-field-mapper.d.ts
|
|
9
9
|
/**
|
|
@@ -114,29 +114,4 @@ declare class DbError extends Error {
|
|
|
114
114
|
*/
|
|
115
115
|
declare function decomposePatch(payload: Record<string, unknown>, table: AtscriptDbTable): Record<string, unknown>;
|
|
116
116
|
//#endregion
|
|
117
|
-
|
|
118
|
-
interface TArrayPatch<A extends readonly unknown[]> {
|
|
119
|
-
$replace?: A;
|
|
120
|
-
$insert?: A;
|
|
121
|
-
$upsert?: A;
|
|
122
|
-
$update?: Array<Partial<TArrayElement<A>>>;
|
|
123
|
-
$remove?: Array<Partial<TArrayElement<A>>>;
|
|
124
|
-
}
|
|
125
|
-
type TArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
126
|
-
/**
|
|
127
|
-
* Maps each property of T into a patch payload:
|
|
128
|
-
* - Array properties become `TArrayPatch<T[K]>`
|
|
129
|
-
* - Non-array properties become `Partial<T[K]>`
|
|
130
|
-
*/
|
|
131
|
-
type TDbPatch<T> = { [K in keyof T]?: T[K] extends Array<infer _> ? TArrayPatch<T[K]> : Partial<T[K]> };
|
|
132
|
-
/**
|
|
133
|
-
* Extracts `@expect.array.key` properties from an array-of-objects type.
|
|
134
|
-
* These keys uniquely identify an element inside the array and are used
|
|
135
|
-
* for `$update`, `$remove`, and `$upsert` operations.
|
|
136
|
-
*
|
|
137
|
-
* @param def - Atscript array type definition.
|
|
138
|
-
* @returns Set of property names marked as keys; empty set if none.
|
|
139
|
-
*/
|
|
140
|
-
declare function getKeyProps(def: TAtscriptAnnotatedType<TAtscriptTypeArray>): Set<string>;
|
|
141
|
-
//#endregion
|
|
142
|
-
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type DbControls, DbError, type DbErrorCode, type DbQuery, type DbResponse, DbSpace, type DbValidationContext, DocumentFieldMapper, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type OwnPropsOf, RelationalFieldMapper, type TAdapterFactory, type TArrayPatch, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbStorageType, type TDbUpdateResult, type TExistingColumn, type TExistingTableOption, type TFieldOps, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TIdDescriptor, type TMetadataOverrides, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewPlan, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type WithRelation, computeInsights, createDbValidatorPlugin, decomposePatch, getDbFieldOp, getKeyProps, isDbFieldOp, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|
|
117
|
+
export { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type DbControls, DbError, type DbErrorCode, type DbQuery, type DbResponse, DbSpace, type DbValidationContext, DocumentFieldMapper, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type OwnPropsOf, RelationalFieldMapper, type TAdapterFactory, type TArrayPatch, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbStorageType, type TDbUpdateResult, type TExistingColumn, type TExistingTableOption, type TFieldOps, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TIdDescriptor, type TMetadataOverrides, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewPlan, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WithRelation, buildDbValidator, buildValidationContext, computeInsights, createDbValidatorPlugin, decomposePatch, forceNavNonOptional, getDbFieldOp, getKeyProps, isDbFieldOp, isNavRelation, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as Uniquery, A as TDbForeignKey, B as TExistingColumn, C as TCascadeTarget, D as TDbDefaultValue, E as TDbDefaultFn, F as TDbInsertResult, G as TMetadataOverrides, H as TFkLookupResolver, I as TDbReferentialAction, J as TTableOptionDiff, K as TSearchIndexInfo, L as TDbRelation, M as TDbIndexField, N as TDbIndexType, O as TDbDeleteResult, P as TDbInsertManyResult, Q as TypedWithRelation, R as TDbStorageType, S as TCascadeResolver, T as TDbCollation, U as TFkLookupTarget, V as TExistingTableOption, W as TIdDescriptor, X as TValueFormatterPair, Y as TTableResolver, Z as TWriteTableResolver, _ as DbQuery, a as FieldMappingStrategy, b as NavPropsOf, c as NoopLogger, d as AggregateExpr, et as UniqueryControls, f as AggregateFn, g as DbControls, h as AtscriptDbWritable, i as DocumentFieldMapper, j as TDbIndex, k as TDbFieldMeta, l as TGenericLogger, m as AggregateResult, n as DbResponse, nt as UniquSelect, o as BaseDbAdapter, p as AggregateQuery, q as TSyncColumnResult, r as resolveDesignType, s as TableMetadata, t as AtscriptDbReadable, tt as WithRelation, u as AggregateControls, v as FieldOpsFor, w as TColumnDiff, x as OwnPropsOf, y as FilterExpr, z as TDbUpdateResult } from "./db-readable-
|
|
2
|
-
import { d as getDbFieldOp, f as isDbFieldOp, l as TDbFieldOp, p as separateFieldOps, u as TFieldOps } from "./ops-
|
|
3
|
-
import { a as AtscriptQueryComparison, c as AtscriptRef, d as translateQueryTree, f as AtscriptDbTable, i as TViewColumnMapping, l as TViewJoin, m as NativeIntegrity, n as TAdapterFactory, o as AtscriptQueryFieldRef, p as IntegrityStrategy, r as AtscriptDbView, s as AtscriptQueryNode, t as DbSpace, u as TViewPlan } from "./db-space-
|
|
4
|
-
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-
|
|
5
|
-
import {
|
|
1
|
+
import { $ as Uniquery, A as TDbForeignKey, B as TExistingColumn, C as TCascadeTarget, D as TDbDefaultValue, E as TDbDefaultFn, F as TDbInsertResult, G as TMetadataOverrides, H as TFkLookupResolver, I as TDbReferentialAction, J as TTableOptionDiff, K as TSearchIndexInfo, L as TDbRelation, M as TDbIndexField, N as TDbIndexType, O as TDbDeleteResult, P as TDbInsertManyResult, Q as TypedWithRelation, R as TDbStorageType, S as TCascadeResolver, T as TDbCollation, U as TFkLookupTarget, V as TExistingTableOption, W as TIdDescriptor, X as TValueFormatterPair, Y as TTableResolver, Z as TWriteTableResolver, _ as DbQuery, a as FieldMappingStrategy, b as NavPropsOf, c as NoopLogger, d as AggregateExpr, et as UniqueryControls, f as AggregateFn, g as DbControls, h as AtscriptDbWritable, i as DocumentFieldMapper, j as TDbIndex, k as TDbFieldMeta, l as TGenericLogger, m as AggregateResult, n as DbResponse, nt as UniquSelect, o as BaseDbAdapter, p as AggregateQuery, q as TSyncColumnResult, r as resolveDesignType, s as TableMetadata, t as AtscriptDbReadable, tt as WithRelation, u as AggregateControls, v as FieldOpsFor, w as TColumnDiff, x as OwnPropsOf, y as FilterExpr, z as TDbUpdateResult } from "./db-readable-D9odJuSf.mjs";
|
|
2
|
+
import { a as $remove, c as $upsert, d as getDbFieldOp, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, p as separateFieldOps, r as $insert, s as $update, t as $dec, u as TFieldOps } from "./ops-DcHDxrjX.mjs";
|
|
3
|
+
import { a as AtscriptQueryComparison, c as AtscriptRef, d as translateQueryTree, f as AtscriptDbTable, i as TViewColumnMapping, l as TViewJoin, m as NativeIntegrity, n as TAdapterFactory, o as AtscriptQueryFieldRef, p as IntegrityStrategy, r as AtscriptDbView, s as AtscriptQueryNode, t as DbSpace, u as TViewPlan } from "./db-space-7bf9_IWC.mjs";
|
|
4
|
+
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-KC4aNIQq.mjs";
|
|
5
|
+
import { 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-BeXlQISk.mjs";
|
|
6
6
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
7
7
|
|
|
8
8
|
//#region src/strategies/relational-field-mapper.d.ts
|
|
@@ -114,29 +114,4 @@ declare class DbError extends Error {
|
|
|
114
114
|
*/
|
|
115
115
|
declare function decomposePatch(payload: Record<string, unknown>, table: AtscriptDbTable): Record<string, unknown>;
|
|
116
116
|
//#endregion
|
|
117
|
-
|
|
118
|
-
interface TArrayPatch<A extends readonly unknown[]> {
|
|
119
|
-
$replace?: A;
|
|
120
|
-
$insert?: A;
|
|
121
|
-
$upsert?: A;
|
|
122
|
-
$update?: Array<Partial<TArrayElement<A>>>;
|
|
123
|
-
$remove?: Array<Partial<TArrayElement<A>>>;
|
|
124
|
-
}
|
|
125
|
-
type TArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
126
|
-
/**
|
|
127
|
-
* Maps each property of T into a patch payload:
|
|
128
|
-
* - Array properties become `TArrayPatch<T[K]>`
|
|
129
|
-
* - Non-array properties become `Partial<T[K]>`
|
|
130
|
-
*/
|
|
131
|
-
type TDbPatch<T> = { [K in keyof T]?: T[K] extends Array<infer _> ? TArrayPatch<T[K]> : Partial<T[K]> };
|
|
132
|
-
/**
|
|
133
|
-
* Extracts `@expect.array.key` properties from an array-of-objects type.
|
|
134
|
-
* These keys uniquely identify an element inside the array and are used
|
|
135
|
-
* for `$update`, `$remove`, and `$upsert` operations.
|
|
136
|
-
*
|
|
137
|
-
* @param def - Atscript array type definition.
|
|
138
|
-
* @returns Set of property names marked as keys; empty set if none.
|
|
139
|
-
*/
|
|
140
|
-
declare function getKeyProps(def: TAtscriptAnnotatedType<TAtscriptTypeArray>): Set<string>;
|
|
141
|
-
//#endregion
|
|
142
|
-
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type DbControls, DbError, type DbErrorCode, type DbQuery, type DbResponse, DbSpace, type DbValidationContext, DocumentFieldMapper, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type OwnPropsOf, RelationalFieldMapper, type TAdapterFactory, type TArrayPatch, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbStorageType, type TDbUpdateResult, type TExistingColumn, type TExistingTableOption, type TFieldOps, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TIdDescriptor, type TMetadataOverrides, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewPlan, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type WithRelation, computeInsights, createDbValidatorPlugin, decomposePatch, getDbFieldOp, getKeyProps, isDbFieldOp, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|
|
117
|
+
export { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type DbControls, DbError, type DbErrorCode, type DbQuery, type DbResponse, DbSpace, type DbValidationContext, DocumentFieldMapper, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type OwnPropsOf, RelationalFieldMapper, type TAdapterFactory, type TArrayPatch, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbStorageType, type TDbUpdateResult, type TExistingColumn, type TExistingTableOption, type TFieldOps, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TIdDescriptor, type TMetadataOverrides, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewPlan, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WithRelation, buildDbValidator, buildValidationContext, computeInsights, createDbValidatorPlugin, decomposePatch, forceNavNonOptional, getDbFieldOp, getKeyProps, isDbFieldOp, isNavRelation, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { h as DbError } from "./nested-writer-CNDyhg2L.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { getDbFieldOp, isDbFieldOp, separateFieldOps } from "./ops.mjs";
|
|
2
|
+
import { a as BaseDbAdapter, c as AtscriptDbReadable, d as DocumentFieldMapper, f as FieldMappingStrategy, h as NoopLogger, i as ApplicationIntegrity, l as resolveDesignType, m as TableMetadata, n as AtscriptDbTable, o as IntegrityStrategy, p as UniquSelect, r as decomposePatch, s as NativeIntegrity, t as AtscriptDbView, u as RelationalFieldMapper } from "./db-view-7Y5N4muD.mjs";
|
|
3
|
+
import { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, separateFieldOps } from "./ops.mjs";
|
|
4
|
+
import { a as isNavRelation, i as forceNavNonOptional, n as buildValidationContext, o as createDbValidatorPlugin, s as getKeyProps, t as buildDbValidator } from "./validator-D_7Fqzs4.mjs";
|
|
4
5
|
import { computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
5
6
|
//#region src/table/db-space.ts
|
|
6
7
|
/**
|
|
@@ -137,4 +138,4 @@ function translateQueryTree(node, resolveField) {
|
|
|
137
138
|
return { [leftField]: { [comp.op]: comp.right } };
|
|
138
139
|
}
|
|
139
140
|
//#endregion
|
|
140
|
-
export { ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, BaseDbAdapter, DbError, DbSpace, DocumentFieldMapper, FieldMappingStrategy, IntegrityStrategy, NativeIntegrity, NoopLogger, RelationalFieldMapper, TableMetadata, UniquSelect, computeInsights, createDbValidatorPlugin, decomposePatch, getDbFieldOp, getKeyProps, isDbFieldOp, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|
|
141
|
+
export { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, BaseDbAdapter, DbError, DbSpace, DocumentFieldMapper, FieldMappingStrategy, IntegrityStrategy, NativeIntegrity, NoopLogger, RelationalFieldMapper, TableMetadata, UniquSelect, buildDbValidator, buildValidationContext, computeInsights, createDbValidatorPlugin, decomposePatch, forceNavNonOptional, getDbFieldOp, getKeyProps, isDbFieldOp, isNavRelation, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|
package/dist/ops.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as $remove, c as $upsert, d as getDbFieldOp, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, p as separateFieldOps, r as $insert, s as $update, t as $dec, u as TFieldOps } from "./ops-
|
|
1
|
+
import { a as $remove, c as $upsert, d as getDbFieldOp, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, p as separateFieldOps, r as $insert, s as $update, t as $dec, u as TFieldOps } from "./ops-DcHDxrjX.mjs";
|
|
2
2
|
export { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, TDbFieldOp, TFieldOps, getDbFieldOp, isDbFieldOp, separateFieldOps };
|
package/dist/plugin.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_validation_utils = require("./validation-utils-
|
|
5
|
+
const require_validation_utils = require("./validation-utils-BiG3pLP0.cjs");
|
|
6
6
|
let _atscript_core = require("@atscript/core");
|
|
7
7
|
//#region src/plugin/annotations/agg.ts
|
|
8
8
|
const dbAggAnnotations = { agg: {
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getAnnotationAlias, c as getParentStruct, d as validateFieldBaseType, i as validateRefArgument, l as getParentTypeName, n as hasAnyViewAnnotation, o as getDbTableOwner, r as validateQueryScope, s as getNavTargetTypeName, t as findFKFieldsPointingTo, u as refActionAnnotation } from "./validation-utils-
|
|
1
|
+
import { a as getAnnotationAlias, c as getParentStruct, d as validateFieldBaseType, i as validateRefArgument, l as getParentTypeName, n as hasAnyViewAnnotation, o as getDbTableOwner, r as validateQueryScope, s as getNavTargetTypeName, t as findFKFieldsPointingTo, u as refActionAnnotation } from "./validation-utils-aNrgK-cj.mjs";
|
|
2
2
|
import { AnnotationSpec, isArray, isInterface, isPrimitive, isRef, isStructure } from "@atscript/core";
|
|
3
3
|
//#region src/plugin/annotations/agg.ts
|
|
4
4
|
const dbAggAnnotations = { agg: {
|
package/dist/rel.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as TDbForeignKey, L as TDbRelation, Y as TTableResolver, Z as TWriteTableResolver, l as TGenericLogger, o as BaseDbAdapter, s as TableMetadata } from "./db-readable-
|
|
2
|
-
import { t as DbValidationContext } from "./db-validator-plugin-
|
|
1
|
+
import { A as TDbForeignKey, L as TDbRelation, Y as TTableResolver, Z as TWriteTableResolver, l as TGenericLogger, o as BaseDbAdapter, s as TableMetadata } from "./db-readable-D9odJuSf.mjs";
|
|
2
|
+
import { t as DbValidationContext } from "./db-validator-plugin-KC4aNIQq.mjs";
|
|
3
3
|
import { Validator } from "@atscript/typescript/utils";
|
|
4
4
|
import { FilterExpr, WithRelation } from "@uniqu/core";
|
|
5
5
|
|
package/dist/shared.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_validation_utils = require("./validation-utils-
|
|
2
|
+
const require_validation_utils = require("./validation-utils-BiG3pLP0.cjs");
|
|
3
3
|
exports.findFKFieldsPointingTo = require_validation_utils.findFKFieldsPointingTo;
|
|
4
4
|
exports.getAnnotationAlias = require_validation_utils.getAnnotationAlias;
|
|
5
5
|
exports.getDbTableOwner = require_validation_utils.getDbTableOwner;
|
package/dist/shared.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getAnnotationAlias, c as getParentStruct, d as validateFieldBaseType, i as validateRefArgument, l as getParentTypeName, n as hasAnyViewAnnotation, o as getDbTableOwner, r as validateQueryScope, s as getNavTargetTypeName, t as findFKFieldsPointingTo, u as refActionAnnotation } from "./validation-utils-
|
|
1
|
+
import { a as getAnnotationAlias, c as getParentStruct, d as validateFieldBaseType, i as validateRefArgument, l as getParentTypeName, n as hasAnyViewAnnotation, o as getDbTableOwner, r as validateQueryScope, s as getNavTargetTypeName, t as findFKFieldsPointingTo, u as refActionAnnotation } from "./validation-utils-aNrgK-cj.mjs";
|
|
2
2
|
export { findFKFieldsPointingTo, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, refActionAnnotation, validateFieldBaseType, validateQueryScope, validateRefArgument };
|
package/dist/sync.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./nested-writer-BIQ6EfaR.cjs");
|
|
3
|
-
const require_db_view = require("./db-view-
|
|
3
|
+
const require_db_view = require("./db-view-BMPRfGjB.cjs");
|
|
4
|
+
require("./validator-0iGuvGOD.cjs");
|
|
4
5
|
//#region src/schema/schema-hash.ts
|
|
5
6
|
/** Extracts sorted field snapshots from a readable's field descriptors. */
|
|
6
7
|
function extractFieldSnapshots(fields, typeMapper) {
|
|
@@ -284,7 +285,7 @@ var SyncStore = class {
|
|
|
284
285
|
}
|
|
285
286
|
async ensureControlTable() {
|
|
286
287
|
if (!this.controlTable) {
|
|
287
|
-
const { AtscriptControl } = await Promise.resolve().then(() => require("./control-
|
|
288
|
+
const { AtscriptControl } = await Promise.resolve().then(() => require("./control-D1QdBO21.cjs"));
|
|
288
289
|
this.controlTable = this.space.getTable(AtscriptControl);
|
|
289
290
|
}
|
|
290
291
|
await this.controlTable.ensureTable();
|
|
@@ -420,7 +421,7 @@ var SyncStore = class {
|
|
|
420
421
|
}
|
|
421
422
|
};
|
|
422
423
|
async function readStoredSnapshot(space, tableName, _asView) {
|
|
423
|
-
const { AtscriptControl } = await Promise.resolve().then(() => require("./control-
|
|
424
|
+
const { AtscriptControl } = await Promise.resolve().then(() => require("./control-D1QdBO21.cjs"));
|
|
424
425
|
const table = space.getTable(AtscriptControl);
|
|
425
426
|
await table.ensureTable();
|
|
426
427
|
const value = (await table.findOne({
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as TDbForeignKey, B as TExistingColumn, D as TDbDefaultValue, J as TTableOptionDiff, R as TDbStorageType, V as TExistingTableOption, k as TDbFieldMeta, l as TGenericLogger, t as AtscriptDbReadable, w as TColumnDiff } from "./db-readable-
|
|
2
|
-
import { r as AtscriptDbView, t as DbSpace } from "./db-space-
|
|
1
|
+
import { A as TDbForeignKey, B as TExistingColumn, D as TDbDefaultValue, J as TTableOptionDiff, R as TDbStorageType, V as TExistingTableOption, k as TDbFieldMeta, l as TGenericLogger, t as AtscriptDbReadable, w as TColumnDiff } from "./db-readable-D9odJuSf.mjs";
|
|
2
|
+
import { r as AtscriptDbView, t as DbSpace } from "./db-space-7bf9_IWC.mjs";
|
|
3
3
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/schema/sync-entry.d.ts
|
package/dist/sync.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./nested-writer-CNDyhg2L.mjs";
|
|
2
|
+
import { h as NoopLogger } from "./db-view-7Y5N4muD.mjs";
|
|
3
|
+
import "./validator-D_7Fqzs4.mjs";
|
|
2
4
|
//#region src/schema/schema-hash.ts
|
|
3
5
|
/** Extracts sorted field snapshots from a readable's field descriptors. */
|
|
4
6
|
function extractFieldSnapshots(fields, typeMapper) {
|
|
@@ -282,7 +284,7 @@ var SyncStore = class {
|
|
|
282
284
|
}
|
|
283
285
|
async ensureControlTable() {
|
|
284
286
|
if (!this.controlTable) {
|
|
285
|
-
const { AtscriptControl } = await import("./control-
|
|
287
|
+
const { AtscriptControl } = await import("./control-DBd_ff5-.mjs");
|
|
286
288
|
this.controlTable = this.space.getTable(AtscriptControl);
|
|
287
289
|
}
|
|
288
290
|
await this.controlTable.ensureTable();
|
|
@@ -418,7 +420,7 @@ var SyncStore = class {
|
|
|
418
420
|
}
|
|
419
421
|
};
|
|
420
422
|
async function readStoredSnapshot(space, tableName, _asView) {
|
|
421
|
-
const { AtscriptControl } = await import("./control-
|
|
423
|
+
const { AtscriptControl } = await import("./control-DBd_ff5-.mjs");
|
|
422
424
|
const table = space.getTable(AtscriptControl);
|
|
423
425
|
await table.ensureTable();
|
|
424
426
|
const value = (await table.findOne({
|