@atscript/db 0.1.39 → 0.1.40
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/README.md +18 -18
- package/dist/agg.cjs +8 -3
- package/dist/agg.d.cts +7 -0
- package/dist/agg.d.mts +7 -0
- package/dist/agg.mjs +7 -3
- package/dist/control-DRgryKeg.cjs +14 -0
- package/dist/{control_as-bjmwe24C.mjs → control-IANbnfjG.mjs} +6 -18
- package/dist/db-readable-BQQzfguJ.d.cts +1249 -0
- package/dist/db-readable-Bbr4CjMb.d.mts +1249 -0
- package/dist/db-space-BUrQ5BFm.d.mts +309 -0
- package/dist/db-space-Vxpcnyt5.d.cts +309 -0
- package/dist/db-validator-plugin-07kDiis2.d.cts +22 -0
- package/dist/db-validator-plugin-CiqsHTI_.d.mts +22 -0
- package/dist/db-view-BntnAmXO.cjs +3071 -0
- package/dist/db-view-ZsoN91-q.mjs +2970 -0
- package/dist/index.cjs +95 -2801
- package/dist/index.d.cts +137 -0
- package/dist/index.d.mts +137 -0
- package/dist/index.mjs +55 -2761
- package/dist/{nested-writer-BkqL7cp3.cjs → nested-writer-BDXsDMPP.cjs} +196 -150
- package/dist/{nested-writer-NEN51mnR.mjs → nested-writer-Dmm1gbZV.mjs} +118 -70
- package/dist/ops-BdRAFLKY.d.mts +67 -0
- package/dist/ops-DXJ4Zw0P.d.cts +67 -0
- package/dist/ops.cjs +123 -0
- package/dist/ops.d.cts +2 -0
- package/dist/ops.d.mts +2 -0
- package/dist/ops.mjs +112 -0
- package/dist/plugin.cjs +90 -109
- package/dist/plugin.d.cts +6 -0
- package/dist/plugin.d.mts +6 -0
- package/dist/plugin.mjs +29 -49
- package/dist/rel.cjs +20 -20
- package/dist/rel.d.cts +119 -0
- package/dist/rel.d.mts +119 -0
- package/dist/rel.mjs +4 -5
- package/dist/{relation-helpers-guFL_oRf.cjs → relation-helpers-BYvsE1tR.cjs} +26 -22
- package/dist/{relation-helpers-DyBIlQnB.mjs → relation-helpers-CLasawQq.mjs} +11 -6
- package/dist/{relation-loader-Dv7qXYq7.mjs → relation-loader-BEOTXNcq.mjs} +63 -43
- package/dist/{relation-loader-CpnDRf9k.cjs → relation-loader-CRC5LcqM.cjs} +74 -49
- package/dist/shared.cjs +13 -13
- package/dist/{shared.d.ts → shared.d.cts} +14 -13
- package/dist/shared.d.mts +71 -0
- package/dist/shared.mjs +2 -3
- package/dist/sync.cjs +300 -252
- package/dist/sync.d.cts +369 -0
- package/dist/sync.d.mts +369 -0
- package/dist/sync.mjs +284 -233
- package/dist/{validation-utils-DEoCMmEb.cjs → validation-utils-DVJDijnB.cjs} +141 -109
- package/dist/{validation-utils-DhR_mtKa.mjs → validation-utils-DhjIjP1-.mjs} +71 -37
- package/package.json +30 -29
- package/LICENSE +0 -21
- package/dist/agg-BJFJ3dFQ.mjs +0 -8
- package/dist/agg-DnUWAOK8.cjs +0 -14
- package/dist/agg.d.ts +0 -13
- package/dist/chunk-CrpGerW8.cjs +0 -31
- package/dist/control_as-BFPERAF_.cjs +0 -28
- package/dist/index.d.ts +0 -1706
- package/dist/logger-B7oxCfLQ.mjs +0 -12
- package/dist/logger-Dt2v_-wb.cjs +0 -18
- package/dist/plugin.d.ts +0 -5
- package/dist/rel.d.ts +0 -1305
- package/dist/relation-loader-D4mTw6yH.cjs +0 -4
- package/dist/relation-loader-Ggy1ujwR.mjs +0 -4
- package/dist/sync.d.ts +0 -1878
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { AnnotationSpec, AtscriptDoc, SemanticInterfaceNode, SemanticNode, SemanticPropNode, SemanticStructureNode, TMessages, Token } from "@atscript/core";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/annotation-utils.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Traverse from annotation token → prop → structure → interface
|
|
6
|
+
* to check if the parent interface has @db.table.
|
|
7
|
+
*/
|
|
8
|
+
declare function getDbTableOwner(token: Token): SemanticNode | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Get the parent structure node from an annotation token.
|
|
11
|
+
*/
|
|
12
|
+
declare function getParentStruct(token: Token): SemanticStructureNode | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Get the parent interface name (for error messages and cross-type resolution).
|
|
15
|
+
*/
|
|
16
|
+
declare function getParentTypeName(token: Token): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Validate that an annotation is on a field with the expected base type.
|
|
19
|
+
*/
|
|
20
|
+
declare function validateFieldBaseType(token: Token, doc: AtscriptDoc, annotationName: string, expectedType: string | string[]): TMessages;
|
|
21
|
+
/**
|
|
22
|
+
* Extract target type name from a navigational field definition.
|
|
23
|
+
* Unwraps arrays (e.g., `Post[]` → `Post`).
|
|
24
|
+
*/
|
|
25
|
+
declare function getNavTargetTypeName(field: SemanticNode): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get the alias argument from an annotation on a field.
|
|
28
|
+
*/
|
|
29
|
+
declare function getAnnotationAlias(prop: SemanticNode, annotationName: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Factory for @db.rel.onDelete / @db.rel.onUpdate — identical validation logic,
|
|
32
|
+
* only the annotation name and description verb differ.
|
|
33
|
+
*/
|
|
34
|
+
declare function refActionAnnotation(name: "onDelete" | "onUpdate"): AnnotationSpec;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/shared/validation-utils.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* Validate a ref annotation argument against the document's type registry.
|
|
39
|
+
* Returns diagnostic messages for unknown types or fields.
|
|
40
|
+
*/
|
|
41
|
+
declare function validateRefArgument(token: Token, doc: AtscriptDoc, options?: {
|
|
42
|
+
requireDbTable?: boolean;
|
|
43
|
+
}): TMessages;
|
|
44
|
+
interface TFKFieldMatch {
|
|
45
|
+
name: string;
|
|
46
|
+
prop: SemanticPropNode;
|
|
47
|
+
chainRef: {
|
|
48
|
+
type: string;
|
|
49
|
+
field: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Find all `@db.rel.FK` fields on a type that reference `targetTypeName`.
|
|
54
|
+
* Resolves `extends` to include inherited fields.
|
|
55
|
+
*/
|
|
56
|
+
declare function findFKFieldsPointingTo(doc: AtscriptDoc, iface: SemanticInterfaceNode | SemanticStructureNode, targetTypeName: string, alias?: string): TFKFieldMatch[];
|
|
57
|
+
/**
|
|
58
|
+
* Check if a node has any @db.view.* annotation.
|
|
59
|
+
*/
|
|
60
|
+
declare function hasAnyViewAnnotation(node: SemanticNode): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Validate that all type refs in a query expression are within the allowed scope.
|
|
63
|
+
*
|
|
64
|
+
* @param queryToken - The query arg token (must have .queryNode)
|
|
65
|
+
* @param allowedTypes - Type names allowed as qualified refs
|
|
66
|
+
* @param unqualifiedTarget - Type name for resolving unqualified refs, or null to disallow them
|
|
67
|
+
* @param doc - The document for type lookups
|
|
68
|
+
*/
|
|
69
|
+
declare function validateQueryScope(queryToken: Token, allowedTypes: string[], unqualifiedTarget: string | null, doc: AtscriptDoc): TMessages;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { TFKFieldMatch, findFKFieldsPointingTo, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, refActionAnnotation, validateFieldBaseType, validateQueryScope, validateRefArgument };
|
package/dist/shared.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { findFKFieldsPointingTo, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, refActionAnnotation, validateFieldBaseType, validateQueryScope, validateRefArgument };
|
|
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-DhjIjP1-.mjs";
|
|
2
|
+
export { findFKFieldsPointingTo, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, refActionAnnotation, validateFieldBaseType, validateQueryScope, validateRefArgument };
|