@atscript/db 0.1.163 → 0.1.165
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-DupYzFD7.cjs → aggregate-fns-CNtrSxGH.cjs} +1 -1
- package/dist/{aggregate-fns-DsS9UQVB.mjs → aggregate-fns-CmtSNIHm.mjs} +1 -1
- package/dist/{buckets-B8UOod-v.d.cts → buckets-BDxKfCNo.d.cts} +143 -13
- package/dist/{buckets-CHyspjYP.d.mts → buckets-CHUgky8T.d.mts} +143 -13
- package/dist/{column-diff-BfNIlMwX.mjs → column-diff-9pF0d8JP.mjs} +354 -31
- package/dist/{column-diff-BIGX3sRH.cjs → column-diff-DjeUj9kb.cjs} +371 -30
- package/dist/control-B5BJypqL.cjs +16 -0
- package/dist/control-CevYIJC4.mjs +16 -0
- package/dist/{db-error-hraC12B9.mjs → db-error-BMy4-OWq.mjs} +23 -1
- package/dist/{db-error-B_DRL1E9.d.cts → db-error-DQUw2cED.d.cts} +65 -9
- package/dist/{db-error-B_DRL1E9.d.mts → db-error-DQUw2cED.d.mts} +65 -9
- package/dist/{db-error-DmF1_xrz.cjs → db-error-G3sgvL87.cjs} +28 -0
- package/dist/{fk-diff-BNGawZi9.d.cts → fk-diff-DSM7O7hs.d.cts} +1 -1
- package/dist/{fk-diff-rj9N2QLw.d.mts → fk-diff-Dapr5Dk-.d.mts} +1 -1
- package/dist/index.cjs +17 -11
- package/dist/index.d.cts +38 -12
- package/dist/index.d.mts +38 -12
- package/dist/index.mjs +14 -12
- package/dist/{nested-writer-ClUX0DB0.mjs → nested-writer-BraWjS8a.mjs} +177 -26
- package/dist/{nested-writer-yCy6wGuN.cjs → nested-writer-DOvdbYG-.cjs} +194 -31
- package/dist/ops.cjs +1 -1
- package/dist/ops.mjs +1 -1
- package/dist/plugin.cjs +15 -12
- package/dist/plugin.mjs +15 -12
- package/dist/rel.cjs +2 -2
- package/dist/rel.d.cts +2 -2
- package/dist/rel.d.mts +2 -2
- package/dist/rel.mjs +2 -2
- package/dist/{relation-helpers-DloMywNs.d.cts → relation-helpers-C4UNWYQu.d.cts} +1 -1
- package/dist/{relation-helpers-zwt19E7r.d.mts → relation-helpers-hdbuqwjV.d.mts} +1 -1
- package/dist/{relation-loader-Qv3LrQ42.mjs → relation-loader-BOEVhcBe.mjs} +1 -1
- package/dist/{relation-loader-DujL_Mh9.cjs → relation-loader-BrkakVF_.cjs} +1 -1
- package/dist/shared.cjs +3 -1
- package/dist/shared.d.cts +13 -2
- package/dist/shared.d.mts +13 -2
- package/dist/shared.mjs +2 -2
- package/dist/sync.cjs +107 -25
- package/dist/sync.d.cts +53 -6
- package/dist/sync.d.mts +53 -6
- package/dist/sync.mjs +107 -25
- package/dist/{validator-DK9Ijpo7.cjs → validator-D7E7T0Oy.cjs} +1 -1
- package/dist/{validator-DuDWsIdQ.mjs → validator-UpgPhwvH.mjs} +1 -1
- package/dist/validator.cjs +2 -2
- package/dist/validator.d.cts +1 -1
- package/dist/validator.d.mts +1 -1
- package/dist/validator.mjs +2 -2
- package/dist/{view-validation-BiDLCYMw.cjs → view-validation-C0UVLx_H.cjs} +38 -10
- package/dist/{view-validation-BcgDq7M9.mjs → view-validation-KW77xIKn.mjs} +28 -12
- package/package.json +6 -6
- package/dist/control-D5cQmzFj.mjs +0 -14
- package/dist/control-jIVU2hkf.cjs +0 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as NULL_WHEN_EMPTY_AGGREGATE_FNS, o as SUPPORTED_AGGREGATE_FNS, t as AGG_ANNOTATIONS } from "./aggregate-fns-
|
|
1
|
+
import { i as NULL_WHEN_EMPTY_AGGREGATE_FNS, o as SUPPORTED_AGGREGATE_FNS, t as AGG_ANNOTATIONS } from "./aggregate-fns-CmtSNIHm.mjs";
|
|
2
2
|
import { i as searchKindOf, l as JSON_LEAF_TYPES, n as ENCRYPTED_SEARCH_FEATURES, r as SEARCH_PROBLEM, s as DB_ENTITY_ANNOTATIONS } from "./search-fields-BPNsxrCk.mjs";
|
|
3
|
-
import { AnnotationSpec, annotationExample, isArray, isInterface, isPrimitive, isProp, isQueryComparison, isQueryLogical, isRef, isStructure } from "@atscript/core";
|
|
3
|
+
import { AnnotationSpec, annotationExample, isArray, isGroup, isInterface, isPrimitive, isProp, isQueryComparison, isQueryLogical, isRef, isStructure } from "@atscript/core";
|
|
4
4
|
//#region src/shared/annotation-utils.ts
|
|
5
5
|
/**
|
|
6
6
|
* Names of a field's effective annotations: its own plus the ones it inherits
|
|
@@ -62,17 +62,21 @@ function primitiveBaseType(def) {
|
|
|
62
62
|
return typeof ct === "object" ? ct.kind === "final" ? ct.value : ct.kind : ct;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
+
* `null` in a type expression: the `null` reference or the `null` primitive
|
|
66
|
+
* (whose `config.type` is `"null"`).
|
|
67
|
+
*/
|
|
68
|
+
function isNullMember(node) {
|
|
69
|
+
return isRef(node) && !node.hasChain && node.id === "null" || primitiveBaseType(node) === "null";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
65
72
|
* Whether a definition is a union with a `null` member — `T | null`, or a
|
|
66
73
|
* ref to an alias of one (compile-time mirror of the runtime nullable union,
|
|
67
74
|
* since 0.1.155).
|
|
68
75
|
*/
|
|
69
76
|
function isNullableUnion(def, doc, depth = 0) {
|
|
70
77
|
if (!def || depth > 8) return false;
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
return isNullableUnion(doc.unwindType(def.id, def.chain)?.def, doc, depth + 1);
|
|
74
|
-
}
|
|
75
|
-
if (primitiveBaseType(def) === "null") return true;
|
|
78
|
+
if (isNullMember(def)) return true;
|
|
79
|
+
if (isRef(def)) return isNullableUnion(doc.unwindType(def.id, def.chain)?.def, doc, depth + 1);
|
|
76
80
|
const group = def;
|
|
77
81
|
if (!group.isGroup || group.op !== "|" || isStructure(def)) return false;
|
|
78
82
|
return group.unwrap().some((member) => isNullableUnion(member, doc, depth + 1));
|
|
@@ -369,6 +373,20 @@ function findViewCycle(owner, doc) {
|
|
|
369
373
|
return walk(owner, doc, [start]);
|
|
370
374
|
}
|
|
371
375
|
/**
|
|
376
|
+
* The chain reference (`User.id`) an `@db.rel.FK` field's type names, else
|
|
377
|
+
* `undefined`. `User.id | null` names it too (since 0.1.165) — the same
|
|
378
|
+
* optional foreign key as `field?: User.id`; any other union does not.
|
|
379
|
+
*/
|
|
380
|
+
function fkChainRef(def) {
|
|
381
|
+
if (def && isRef(def)) return def.hasChain ? def : void 0;
|
|
382
|
+
if (!def || !isGroup(def) || def.op !== "|") return void 0;
|
|
383
|
+
const members = def.unwrap();
|
|
384
|
+
const values = members.filter((m) => !isNullMember(m));
|
|
385
|
+
if (values.length !== 1 || values.length === members.length) return void 0;
|
|
386
|
+
const [only] = values;
|
|
387
|
+
return only && isRef(only) && only.hasChain ? only : void 0;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
372
390
|
* Find all `@db.rel.FK` fields on a type that reference `targetTypeName`.
|
|
373
391
|
* Resolves `extends` to include inherited fields.
|
|
374
392
|
*/
|
|
@@ -383,10 +401,8 @@ function findFKFieldsPointingTo(doc, iface, targetTypeName, alias) {
|
|
|
383
401
|
if (!struct) return results;
|
|
384
402
|
for (const [name, prop] of struct.props) {
|
|
385
403
|
if (prop.countAnnotations("db.rel.FK") === 0) continue;
|
|
386
|
-
const
|
|
387
|
-
if (!
|
|
388
|
-
const ref = def;
|
|
389
|
-
if (!ref.hasChain) continue;
|
|
404
|
+
const ref = fkChainRef(prop.getDefinition());
|
|
405
|
+
if (!ref) continue;
|
|
390
406
|
const refTypeName = ref.id;
|
|
391
407
|
const refField = ref.chain.map((c) => c.text).join(".");
|
|
392
408
|
if (refTypeName !== targetTypeName) continue;
|
|
@@ -812,4 +828,4 @@ function validateViewInterface(owner, doc) {
|
|
|
812
828
|
return errors;
|
|
813
829
|
}
|
|
814
830
|
//#endregion
|
|
815
|
-
export {
|
|
831
|
+
export { getParentStruct as A, validateFieldBaseType as B, validateRefArgument as C, getAnnotationAlias as D, effectiveAnnotationNames as E, isViewField as F, validateSiblingStringField as H, primitiveBaseType as I, refActionAnnotation as L, integerMemberIndexProblem as M, isNullMember as N, getDbTableOwner as O, isNullableUnion as P, searchFieldVerdict as R, validateQueryScope as S, viewScopeTypes as T, validateIncompatible as V, forEachFieldRef as _, findStoredField as a, isDbSourceDecl as b, refuseCiphertext as c, viewFieldSeals as d, viewProps as f, fkChainRef as g, findViewCycle as h, encryptedTypeSearchProblem as i, getParentTypeName as j, getNavTargetTypeName as k, sealedSearchProblem as l, findFKFieldsPointingTo as m, encryptedAncestorName as n, isNavProp as o, earlierJoinTargets as p, encryptedSearchProblem as r, jsonChainInfo as s, NAV_ANNOTATIONS as t, validateViewInterface as u, hasAnyViewAnnotation as v, viewJoins as w, joinTargets as x, isAliasDecl as y, validateExclusiveWith as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.165",
|
|
4
4
|
"description": "Database adapter utilities for atscript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@atscript/core": "^0.1
|
|
75
|
-
"@atscript/typescript": "^0.1
|
|
74
|
+
"@atscript/core": "^0.2.1",
|
|
75
|
+
"@atscript/typescript": "^0.2.1",
|
|
76
76
|
"@uniqu/core": "^0.1.15",
|
|
77
|
-
"unplugin-atscript": "^0.1
|
|
77
|
+
"unplugin-atscript": "^0.2.1"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@atscript/core": "^0.1
|
|
81
|
-
"@atscript/typescript": "^0.1
|
|
80
|
+
"@atscript/core": "^0.2.1",
|
|
81
|
+
"@atscript/typescript": "^0.2.1",
|
|
82
82
|
"@uniqu/core": "^0.1.15"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineAnnotatedType, throwFeatureDisabled } from "@atscript/typescript/utils";
|
|
2
|
-
//#region src/schema/control.as
|
|
3
|
-
var AtscriptControl = class {
|
|
4
|
-
static __is_atscript_annotated_type = true;
|
|
5
|
-
static type = {};
|
|
6
|
-
static metadata = /* @__PURE__ */ new Map();
|
|
7
|
-
static id = "AtscriptControl";
|
|
8
|
-
static toJsonSchema() {
|
|
9
|
-
throwFeatureDisabled("JSON Schema", "jsonSchema", "emit.jsonSchema");
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
defineAnnotatedType("object", AtscriptControl).prop("_id", defineAnnotatedType().designType("string").tags("string").annotate("meta.id", true).$type).prop("value", defineAnnotatedType().designType("string").tags("string").optional().$type).prop("lockedBy", defineAnnotatedType().designType("string").tags("string").optional().$type).prop("lockedAt", defineAnnotatedType().designType("number").tags("number").optional().$type).prop("expiresAt", defineAnnotatedType().designType("number").tags("number").optional().$type).annotate("db.table", "__atscript_control");
|
|
13
|
-
//#endregion
|
|
14
|
-
export { AtscriptControl };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
let _atscript_typescript_utils = require("@atscript/typescript/utils");
|
|
2
|
-
//#region src/schema/control.as
|
|
3
|
-
var AtscriptControl = class {
|
|
4
|
-
static __is_atscript_annotated_type = true;
|
|
5
|
-
static type = {};
|
|
6
|
-
static metadata = /* @__PURE__ */ new Map();
|
|
7
|
-
static id = "AtscriptControl";
|
|
8
|
-
static toJsonSchema() {
|
|
9
|
-
(0, _atscript_typescript_utils.throwFeatureDisabled)("JSON Schema", "jsonSchema", "emit.jsonSchema");
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
(0, _atscript_typescript_utils.defineAnnotatedType)("object", AtscriptControl).prop("_id", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("string").tags("string").annotate("meta.id", true).$type).prop("value", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("string").tags("string").optional().$type).prop("lockedBy", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("string").tags("string").optional().$type).prop("lockedAt", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("number").tags("number").optional().$type).prop("expiresAt", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("number").tags("number").optional().$type).annotate("db.table", "__atscript_control");
|
|
13
|
-
//#endregion
|
|
14
|
-
exports.AtscriptControl = AtscriptControl;
|