@atscript/db 0.1.140 → 0.1.142
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.d.cts +1 -1
- package/dist/agg.d.mts +1 -1
- package/dist/{buckets-C-27xmtq.d.cts → buckets-Bv4pah66.d.cts} +225 -22
- package/dist/{buckets-BFG2RYRW.d.mts → buckets-CjL7F-hp.d.mts} +225 -22
- package/dist/{column-diff-CgxgFKzx.cjs → column-diff-CfPNcP6e.cjs} +663 -239
- package/dist/{column-diff-BwOA5101.mjs → column-diff-CmFNXV8C.mjs} +638 -220
- package/dist/column-diff-DiBbXyLA.d.cts +211 -0
- package/dist/column-diff-n-k5KY0u.d.mts +211 -0
- package/dist/derived-rules-0sKn4f5C.mjs +44 -0
- package/dist/derived-rules-YstgIxG-.cjs +67 -0
- package/dist/index.cjs +38 -4
- package/dist/index.d.cts +23 -6
- package/dist/index.d.mts +23 -6
- package/dist/index.mjs +34 -4
- package/dist/{nested-writer-FWD5oOYh.mjs → nested-writer-BO3vhbkP.mjs} +8 -4
- package/dist/{nested-writer-BZNCuqI6.cjs → nested-writer-DYsRxZ5f.cjs} +8 -4
- package/dist/object-DSN0h9lB.d.cts +30 -0
- package/dist/object-DSN0h9lB.d.mts +30 -0
- package/dist/plugin.cjs +392 -139
- package/dist/plugin.mjs +392 -139
- 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-D3Zu0Mta.d.mts → relation-helpers-B59to_dG.d.mts} +5 -4
- package/dist/{relation-helpers-DxrvS6ar.d.cts → relation-helpers-DQ_nRsV9.d.cts} +5 -4
- package/dist/{relation-loader-6ZB_5KFq.cjs → relation-loader-CgJ8bK6X.cjs} +1 -1
- package/dist/{relation-loader-CTFaZpVa.mjs → relation-loader-CuhEBzFU.mjs} +1 -1
- package/dist/shared.cjs +6 -1
- package/dist/shared.d.cts +48 -9
- package/dist/shared.d.mts +48 -9
- package/dist/shared.mjs +2 -2
- package/dist/sync.cjs +331 -105
- package/dist/sync.d.cts +62 -163
- package/dist/sync.d.mts +62 -163
- package/dist/sync.mjs +331 -105
- package/dist/{validation-utils-B4h-GW4d.mjs → validation-utils-CMR4fe2M.mjs} +99 -34
- package/dist/{validation-utils-Dg0hW6dn.cjs → validation-utils-DOsB4e6G.cjs} +128 -33
- package/dist/{validator-Drb2N-YL.d.cts → validator-Bw6ks9Hy.d.cts} +1 -11
- package/dist/{validator-Drb2N-YL.d.mts → validator-Bw6ks9Hy.d.mts} +1 -11
- package/dist/{validator-Ch7UIQl9.mjs → validator-D8bPsXPN.mjs} +54 -2
- package/dist/{validator-BtZbcLN2.cjs → validator-DASnXf1j.cjs} +77 -1
- package/dist/validator.cjs +1 -1
- package/dist/validator.d.cts +2 -1
- package/dist/validator.d.mts +2 -1
- package/dist/validator.mjs +1 -1
- package/package.json +6 -6
- package/dist/column-diff-BmqvgBWw.d.cts +0 -24
- package/dist/column-diff-DPkbZIVE.d.mts +0 -24
package/dist/rel.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_nested_writer = require("./nested-writer-
|
|
3
|
-
const require_relation_loader = require("./relation-loader-
|
|
2
|
+
const require_nested_writer = require("./nested-writer-DYsRxZ5f.cjs");
|
|
3
|
+
const require_relation_loader = require("./relation-loader-CgJ8bK6X.cjs");
|
|
4
4
|
exports.batchInsertNestedFrom = require_nested_writer.batchInsertNestedFrom;
|
|
5
5
|
exports.batchInsertNestedTo = require_nested_writer.batchInsertNestedTo;
|
|
6
6
|
exports.batchInsertNestedVia = require_nested_writer.batchInsertNestedVia;
|
package/dist/rel.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dt as TWriteTableResolver, It as BaseDbAdapter, Mt as TableMetadata, St as TTableResolver, q as TDbRelation, un as TGenericLogger, z as TDbForeignKey } from "./buckets-Bv4pah66.cjs";
|
|
2
2
|
import { t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
|
|
3
|
-
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-
|
|
3
|
+
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-DQ_nRsV9.cjs";
|
|
4
4
|
import { FilterExpr, WithRelation } from "@uniqu/core";
|
|
5
5
|
import { Validator } from "@atscript/typescript/utils";
|
|
6
6
|
|
package/dist/rel.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dt as TWriteTableResolver, It as BaseDbAdapter, Mt as TableMetadata, St as TTableResolver, q as TDbRelation, un as TGenericLogger, z as TDbForeignKey } from "./buckets-CjL7F-hp.mjs";
|
|
2
2
|
import { t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
|
|
3
|
-
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-
|
|
3
|
+
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-B59to_dG.mjs";
|
|
4
4
|
import { Validator } from "@atscript/typescript/utils";
|
|
5
5
|
import { FilterExpr, WithRelation } from "@uniqu/core";
|
|
6
6
|
|
package/dist/rel.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as loadRelationsImpl } from "./relation-loader-
|
|
2
|
-
import { _ as resolveRelationTargetTable, a as batchPatchNestedTo, c as batchReplaceNestedTo, d as preValidateNestedFrom, f as validateBatch, g as findRemoteFK, h as findFKForRelation, i as batchPatchNestedFrom, l as batchReplaceNestedVia, n as batchInsertNestedTo, o as batchPatchNestedVia, r as batchInsertNestedVia, s as batchReplaceNestedFrom, t as batchInsertNestedFrom, u as checkDepthOverflow } from "./nested-writer-
|
|
1
|
+
import { t as loadRelationsImpl } from "./relation-loader-CuhEBzFU.mjs";
|
|
2
|
+
import { _ as resolveRelationTargetTable, a as batchPatchNestedTo, c as batchReplaceNestedTo, d as preValidateNestedFrom, f as validateBatch, g as findRemoteFK, h as findFKForRelation, i as batchPatchNestedFrom, l as batchReplaceNestedVia, n as batchInsertNestedTo, o as batchPatchNestedVia, r as batchInsertNestedVia, s as batchReplaceNestedFrom, t as batchInsertNestedFrom, u as checkDepthOverflow } from "./nested-writer-BO3vhbkP.mjs";
|
|
3
3
|
export { batchInsertNestedFrom, batchInsertNestedTo, batchInsertNestedVia, batchPatchNestedFrom, batchPatchNestedTo, batchPatchNestedVia, batchReplaceNestedFrom, batchReplaceNestedTo, batchReplaceNestedVia, checkDepthOverflow, findFKForRelation, findRemoteFK, loadRelationsImpl, preValidateNestedFrom, resolveRelationTargetTable, validateBatch };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as TDbRelation, z as TDbForeignKey } from "./buckets-
|
|
1
|
+
import { q as TDbRelation, z as TDbForeignKey } from "./buckets-CjL7F-hp.mjs";
|
|
2
2
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
3
3
|
|
|
4
4
|
//#region src/rel/relation-helpers.d.ts
|
|
@@ -16,9 +16,10 @@ declare function findRemoteFK(targetTable: {
|
|
|
16
16
|
foreignKeys: ReadonlyMap<string, TDbForeignKey>;
|
|
17
17
|
}, thisTableName: string, alias?: string): TDbForeignKey | undefined;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Physical name of an annotated type — its `@db.table`, else its `@db.view`
|
|
20
|
+
* name (a view is a readable source too, since 0.1.141), else its type id
|
|
21
|
+
* (`""` when none is set). The rule relations, foreign keys and view plans
|
|
22
|
+
* use to name a referenced table or view.
|
|
22
23
|
* @since 0.1.136
|
|
23
24
|
*/
|
|
24
25
|
declare function tableNameOf(type: TAtscriptAnnotatedType | undefined): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as TDbRelation, z as TDbForeignKey } from "./buckets-
|
|
1
|
+
import { q as TDbRelation, z as TDbForeignKey } from "./buckets-Bv4pah66.cjs";
|
|
2
2
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
3
3
|
|
|
4
4
|
//#region src/rel/relation-helpers.d.ts
|
|
@@ -16,9 +16,10 @@ declare function findRemoteFK(targetTable: {
|
|
|
16
16
|
foreignKeys: ReadonlyMap<string, TDbForeignKey>;
|
|
17
17
|
}, thisTableName: string, alias?: string): TDbForeignKey | undefined;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Physical name of an annotated type — its `@db.table`, else its `@db.view`
|
|
20
|
+
* name (a view is a readable source too, since 0.1.141), else its type id
|
|
21
|
+
* (`""` when none is set). The rule relations, foreign keys and view plans
|
|
22
|
+
* use to name a referenced table or view.
|
|
22
23
|
* @since 0.1.136
|
|
23
24
|
*/
|
|
24
25
|
declare function tableNameOf(type: TAtscriptAnnotatedType | undefined): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_nested_writer = require("./nested-writer-
|
|
1
|
+
const require_nested_writer = require("./nested-writer-DYsRxZ5f.cjs");
|
|
2
2
|
//#region src/rel/relation-loader.ts
|
|
3
3
|
var relation_loader_exports = /* @__PURE__ */ require("./plugin.cjs").__exportAll({
|
|
4
4
|
ensureSelectIncludesFields: () => ensureSelectIncludesFields,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as resolveRelationTargetTable, g as findRemoteFK, h as findFKForRelation } from "./nested-writer-
|
|
1
|
+
import { _ as resolveRelationTargetTable, g as findRemoteFK, h as findFKForRelation } from "./nested-writer-BO3vhbkP.mjs";
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __exportAll = (all, no_symbols) => {
|
package/dist/shared.cjs
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
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-DOsB4e6G.cjs");
|
|
3
|
+
exports.earlierJoinTargets = require_validation_utils.earlierJoinTargets;
|
|
3
4
|
exports.findFKFieldsPointingTo = require_validation_utils.findFKFieldsPointingTo;
|
|
5
|
+
exports.findViewCycle = require_validation_utils.findViewCycle;
|
|
6
|
+
exports.forEachFieldRef = require_validation_utils.forEachFieldRef;
|
|
4
7
|
exports.getAnnotationAlias = require_validation_utils.getAnnotationAlias;
|
|
5
8
|
exports.getDbTableOwner = require_validation_utils.getDbTableOwner;
|
|
6
9
|
exports.getNavTargetTypeName = require_validation_utils.getNavTargetTypeName;
|
|
7
10
|
exports.getParentStruct = require_validation_utils.getParentStruct;
|
|
8
11
|
exports.getParentTypeName = require_validation_utils.getParentTypeName;
|
|
9
12
|
exports.hasAnyViewAnnotation = require_validation_utils.hasAnyViewAnnotation;
|
|
13
|
+
exports.isAliasDecl = require_validation_utils.isAliasDecl;
|
|
14
|
+
exports.isDbSourceDecl = require_validation_utils.isDbSourceDecl;
|
|
10
15
|
exports.joinTargets = require_validation_utils.joinTargets;
|
|
11
16
|
exports.primitiveBaseType = require_validation_utils.primitiveBaseType;
|
|
12
17
|
exports.refActionAnnotation = require_validation_utils.refActionAnnotation;
|
package/dist/shared.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnnotationSpec, AtscriptDoc, SemanticInterfaceNode, SemanticNode, SemanticPropNode, SemanticStructureNode, TAnnotationTokens, TMessages, Token } from "@atscript/core";
|
|
1
|
+
import { AnnotationSpec, AtscriptDoc, SemanticInterfaceNode, SemanticNode, SemanticPropNode, SemanticQueryExprNode, SemanticQueryFieldRefNode, SemanticStructureNode, TAnnotationTokens, TMessages, TQueryScope, Token } from "@atscript/core";
|
|
2
2
|
|
|
3
3
|
//#region src/shared/annotation-utils.d.ts
|
|
4
4
|
/** Asserts the field carrying this annotation does not also carry any of `others`. */
|
|
@@ -43,13 +43,36 @@ declare function getAnnotationAlias(prop: SemanticNode, annotationName: string):
|
|
|
43
43
|
declare function refActionAnnotation(name: "onDelete" | "onUpdate"): AnnotationSpec;
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/shared/validation-utils.d.ts
|
|
46
|
+
/** Options of {@link validateRefArgument}. */
|
|
47
|
+
interface TRefArgumentOptions {
|
|
48
|
+
/**
|
|
49
|
+
* The declarations the argument may name — the same predicate its editor
|
|
50
|
+
* `refFilter` completes with (`lsp-scopes`), so a diagnostic and the
|
|
51
|
+
* completion list never disagree. A `@db.alias` declaration it rejects
|
|
52
|
+
* gets the alias-specific message.
|
|
53
|
+
* @since 0.1.141
|
|
54
|
+
*/
|
|
55
|
+
accept?: (decl: SemanticNode) => boolean;
|
|
56
|
+
/** What {@link accept} demands, for the diagnostic: `Type 'X' <expected>`. */
|
|
57
|
+
expected?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Whether a declaration node is a `@db.table` or a `@db.view` (managed or external). */
|
|
60
|
+
declare function isDbSourceDecl(node: SemanticNode): boolean;
|
|
61
|
+
/** Whether a declaration node is a `@db.alias` type. @since 0.1.141 */
|
|
62
|
+
declare function isAliasDecl(node: SemanticNode): boolean;
|
|
46
63
|
/**
|
|
47
64
|
* Validate a ref annotation argument against the document's type registry.
|
|
48
65
|
* Returns diagnostic messages for unknown types or fields.
|
|
49
66
|
*/
|
|
50
|
-
declare function validateRefArgument(token: Token, doc: AtscriptDoc, options?:
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
declare function validateRefArgument(token: Token, doc: AtscriptDoc, options?: TRefArgumentOptions): TMessages;
|
|
68
|
+
/**
|
|
69
|
+
* VW9 — the dependency cycle a view closes, as the list of view names from
|
|
70
|
+
* the view back to itself (`["A", "B", "A"]`), or `undefined`. Walks
|
|
71
|
+
* `@db.view.for` / `@db.view.joins` of the referenced declarations across
|
|
72
|
+
* documents; `@db.alias` sources resolve to their target.
|
|
73
|
+
* @since 0.1.141
|
|
74
|
+
*/
|
|
75
|
+
declare function findViewCycle(owner: SemanticNode, doc: AtscriptDoc): string[] | undefined;
|
|
53
76
|
interface TFKFieldMatch {
|
|
54
77
|
name: string;
|
|
55
78
|
prop: SemanticPropNode;
|
|
@@ -67,6 +90,13 @@ declare function findFKFieldsPointingTo(doc: AtscriptDoc, iface: SemanticInterfa
|
|
|
67
90
|
declare function viewJoins(owner: SemanticNode): TAnnotationTokens[];
|
|
68
91
|
/** The target type names of `@db.view.joins` annotations. */
|
|
69
92
|
declare function joinTargets(joins: readonly TAnnotationTokens[]): string[];
|
|
93
|
+
/**
|
|
94
|
+
* The targets of the `@db.view.joins` declared before `join` among the
|
|
95
|
+
* view's `joins` ({@link viewJoins}) — what a chained join condition may
|
|
96
|
+
* reference besides its target and the entry.
|
|
97
|
+
* @since 0.1.141
|
|
98
|
+
*/
|
|
99
|
+
declare function earlierJoinTargets(joins: readonly TAnnotationTokens[], join: TAnnotationTokens): string[];
|
|
70
100
|
/**
|
|
71
101
|
* The type names a view predicate (`@db.view.filter`, a conditional
|
|
72
102
|
* `@db.agg.*`) may reference: the `@db.view.for` entry table, then every
|
|
@@ -78,14 +108,23 @@ declare function viewScopeTypes(owner: SemanticNode): string[];
|
|
|
78
108
|
*/
|
|
79
109
|
declare function hasAnyViewAnnotation(node: SemanticNode): boolean;
|
|
80
110
|
/**
|
|
81
|
-
* Validate that all
|
|
111
|
+
* Validate that all field refs in a query expression are within `scope` —
|
|
112
|
+
* the same {@link TQueryScope} the editor completes (`lsp-scopes`):
|
|
113
|
+
* qualified refs must name one of `scope.allowedTypes`; an unqualified ref
|
|
114
|
+
* (a dotted path included) must be a field of `scope.unqualifiedTarget`, or
|
|
115
|
+
* is rejected outright when that is `null`.
|
|
82
116
|
*
|
|
83
117
|
* @param queryToken - The query arg token (must have .queryNode)
|
|
84
|
-
* @param
|
|
85
|
-
* @param unqualifiedTarget - Type name for resolving unqualified refs, or null to disallow them
|
|
118
|
+
* @param scope - The scope of the argument
|
|
86
119
|
* @param doc - The document for type lookups
|
|
87
120
|
* @param scopeHint - Replaces the default "expected 'A' or 'B'" tail of the out-of-scope message
|
|
88
121
|
*/
|
|
89
|
-
declare function validateQueryScope(queryToken: Token,
|
|
122
|
+
declare function validateQueryScope(queryToken: Token, scope: TQueryScope, doc: AtscriptDoc, scopeHint?: string): TMessages;
|
|
123
|
+
/**
|
|
124
|
+
* Calls `fn` for every field reference of a query expression — both operands
|
|
125
|
+
* of a field-to-field comparison included.
|
|
126
|
+
* @since 0.1.141
|
|
127
|
+
*/
|
|
128
|
+
declare function forEachFieldRef(expr: SemanticQueryExprNode, fn: (ref: SemanticQueryFieldRefNode) => void): void;
|
|
90
129
|
//#endregion
|
|
91
|
-
export { TFKFieldMatch, findFKFieldsPointingTo, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, joinTargets, primitiveBaseType, refActionAnnotation, validateExclusiveWith, validateFieldBaseType, validateQueryScope, validateRefArgument, validateSiblingStringField, viewJoins, viewScopeTypes };
|
|
130
|
+
export { TFKFieldMatch, TRefArgumentOptions, earlierJoinTargets, findFKFieldsPointingTo, findViewCycle, forEachFieldRef, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, isAliasDecl, isDbSourceDecl, joinTargets, primitiveBaseType, refActionAnnotation, validateExclusiveWith, validateFieldBaseType, validateQueryScope, validateRefArgument, validateSiblingStringField, viewJoins, viewScopeTypes };
|
package/dist/shared.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnnotationSpec, AtscriptDoc, SemanticInterfaceNode, SemanticNode, SemanticPropNode, SemanticStructureNode, TAnnotationTokens, TMessages, Token } from "@atscript/core";
|
|
1
|
+
import { AnnotationSpec, AtscriptDoc, SemanticInterfaceNode, SemanticNode, SemanticPropNode, SemanticQueryExprNode, SemanticQueryFieldRefNode, SemanticStructureNode, TAnnotationTokens, TMessages, TQueryScope, Token } from "@atscript/core";
|
|
2
2
|
|
|
3
3
|
//#region src/shared/annotation-utils.d.ts
|
|
4
4
|
/** Asserts the field carrying this annotation does not also carry any of `others`. */
|
|
@@ -43,13 +43,36 @@ declare function getAnnotationAlias(prop: SemanticNode, annotationName: string):
|
|
|
43
43
|
declare function refActionAnnotation(name: "onDelete" | "onUpdate"): AnnotationSpec;
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/shared/validation-utils.d.ts
|
|
46
|
+
/** Options of {@link validateRefArgument}. */
|
|
47
|
+
interface TRefArgumentOptions {
|
|
48
|
+
/**
|
|
49
|
+
* The declarations the argument may name — the same predicate its editor
|
|
50
|
+
* `refFilter` completes with (`lsp-scopes`), so a diagnostic and the
|
|
51
|
+
* completion list never disagree. A `@db.alias` declaration it rejects
|
|
52
|
+
* gets the alias-specific message.
|
|
53
|
+
* @since 0.1.141
|
|
54
|
+
*/
|
|
55
|
+
accept?: (decl: SemanticNode) => boolean;
|
|
56
|
+
/** What {@link accept} demands, for the diagnostic: `Type 'X' <expected>`. */
|
|
57
|
+
expected?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Whether a declaration node is a `@db.table` or a `@db.view` (managed or external). */
|
|
60
|
+
declare function isDbSourceDecl(node: SemanticNode): boolean;
|
|
61
|
+
/** Whether a declaration node is a `@db.alias` type. @since 0.1.141 */
|
|
62
|
+
declare function isAliasDecl(node: SemanticNode): boolean;
|
|
46
63
|
/**
|
|
47
64
|
* Validate a ref annotation argument against the document's type registry.
|
|
48
65
|
* Returns diagnostic messages for unknown types or fields.
|
|
49
66
|
*/
|
|
50
|
-
declare function validateRefArgument(token: Token, doc: AtscriptDoc, options?:
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
declare function validateRefArgument(token: Token, doc: AtscriptDoc, options?: TRefArgumentOptions): TMessages;
|
|
68
|
+
/**
|
|
69
|
+
* VW9 — the dependency cycle a view closes, as the list of view names from
|
|
70
|
+
* the view back to itself (`["A", "B", "A"]`), or `undefined`. Walks
|
|
71
|
+
* `@db.view.for` / `@db.view.joins` of the referenced declarations across
|
|
72
|
+
* documents; `@db.alias` sources resolve to their target.
|
|
73
|
+
* @since 0.1.141
|
|
74
|
+
*/
|
|
75
|
+
declare function findViewCycle(owner: SemanticNode, doc: AtscriptDoc): string[] | undefined;
|
|
53
76
|
interface TFKFieldMatch {
|
|
54
77
|
name: string;
|
|
55
78
|
prop: SemanticPropNode;
|
|
@@ -67,6 +90,13 @@ declare function findFKFieldsPointingTo(doc: AtscriptDoc, iface: SemanticInterfa
|
|
|
67
90
|
declare function viewJoins(owner: SemanticNode): TAnnotationTokens[];
|
|
68
91
|
/** The target type names of `@db.view.joins` annotations. */
|
|
69
92
|
declare function joinTargets(joins: readonly TAnnotationTokens[]): string[];
|
|
93
|
+
/**
|
|
94
|
+
* The targets of the `@db.view.joins` declared before `join` among the
|
|
95
|
+
* view's `joins` ({@link viewJoins}) — what a chained join condition may
|
|
96
|
+
* reference besides its target and the entry.
|
|
97
|
+
* @since 0.1.141
|
|
98
|
+
*/
|
|
99
|
+
declare function earlierJoinTargets(joins: readonly TAnnotationTokens[], join: TAnnotationTokens): string[];
|
|
70
100
|
/**
|
|
71
101
|
* The type names a view predicate (`@db.view.filter`, a conditional
|
|
72
102
|
* `@db.agg.*`) may reference: the `@db.view.for` entry table, then every
|
|
@@ -78,14 +108,23 @@ declare function viewScopeTypes(owner: SemanticNode): string[];
|
|
|
78
108
|
*/
|
|
79
109
|
declare function hasAnyViewAnnotation(node: SemanticNode): boolean;
|
|
80
110
|
/**
|
|
81
|
-
* Validate that all
|
|
111
|
+
* Validate that all field refs in a query expression are within `scope` —
|
|
112
|
+
* the same {@link TQueryScope} the editor completes (`lsp-scopes`):
|
|
113
|
+
* qualified refs must name one of `scope.allowedTypes`; an unqualified ref
|
|
114
|
+
* (a dotted path included) must be a field of `scope.unqualifiedTarget`, or
|
|
115
|
+
* is rejected outright when that is `null`.
|
|
82
116
|
*
|
|
83
117
|
* @param queryToken - The query arg token (must have .queryNode)
|
|
84
|
-
* @param
|
|
85
|
-
* @param unqualifiedTarget - Type name for resolving unqualified refs, or null to disallow them
|
|
118
|
+
* @param scope - The scope of the argument
|
|
86
119
|
* @param doc - The document for type lookups
|
|
87
120
|
* @param scopeHint - Replaces the default "expected 'A' or 'B'" tail of the out-of-scope message
|
|
88
121
|
*/
|
|
89
|
-
declare function validateQueryScope(queryToken: Token,
|
|
122
|
+
declare function validateQueryScope(queryToken: Token, scope: TQueryScope, doc: AtscriptDoc, scopeHint?: string): TMessages;
|
|
123
|
+
/**
|
|
124
|
+
* Calls `fn` for every field reference of a query expression — both operands
|
|
125
|
+
* of a field-to-field comparison included.
|
|
126
|
+
* @since 0.1.141
|
|
127
|
+
*/
|
|
128
|
+
declare function forEachFieldRef(expr: SemanticQueryExprNode, fn: (ref: SemanticQueryFieldRefNode) => void): void;
|
|
90
129
|
//#endregion
|
|
91
|
-
export { TFKFieldMatch, findFKFieldsPointingTo, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, joinTargets, primitiveBaseType, refActionAnnotation, validateExclusiveWith, validateFieldBaseType, validateQueryScope, validateRefArgument, validateSiblingStringField, viewJoins, viewScopeTypes };
|
|
130
|
+
export { TFKFieldMatch, TRefArgumentOptions, earlierJoinTargets, findFKFieldsPointingTo, findViewCycle, forEachFieldRef, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, isAliasDecl, isDbSourceDecl, joinTargets, primitiveBaseType, refActionAnnotation, validateExclusiveWith, validateFieldBaseType, validateQueryScope, validateRefArgument, validateSiblingStringField, viewJoins, viewScopeTypes };
|
package/dist/shared.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { findFKFieldsPointingTo, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, joinTargets, primitiveBaseType, refActionAnnotation, validateExclusiveWith, validateFieldBaseType, validateQueryScope, validateRefArgument, validateSiblingStringField, viewJoins, viewScopeTypes };
|
|
1
|
+
import { S as validateSiblingStringField, _ as getParentTypeName, a as hasAnyViewAnnotation, b as validateExclusiveWith, c as joinTargets, d as viewJoins, f as viewScopeTypes, g as getParentStruct, h as getNavTargetTypeName, i as forEachFieldRef, l as validateQueryScope, m as getDbTableOwner, n as findFKFieldsPointingTo, o as isAliasDecl, p as getAnnotationAlias, r as findViewCycle, s as isDbSourceDecl, t as earlierJoinTargets, u as validateRefArgument, v as primitiveBaseType, x as validateFieldBaseType, y as refActionAnnotation } from "./validation-utils-CMR4fe2M.mjs";
|
|
2
|
+
export { earlierJoinTargets, findFKFieldsPointingTo, findViewCycle, forEachFieldRef, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, isAliasDecl, isDbSourceDecl, joinTargets, primitiveBaseType, refActionAnnotation, validateExclusiveWith, validateFieldBaseType, validateQueryScope, validateRefArgument, validateSiblingStringField, viewJoins, viewScopeTypes };
|