@memberjunction/core-entities-server 6.2.0-edge.5 → 6.2.0-edge.7
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 +155 -100
- package/dist/custom/MJAIAgentExampleEntityServer.server.d.ts +2 -0
- package/dist/custom/MJAIAgentExampleEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIAgentExampleEntityServer.server.js +8 -5
- package/dist/custom/MJAIAgentExampleEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIAgentNoteEntityServer.server.d.ts +2 -0
- package/dist/custom/MJAIAgentNoteEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIAgentNoteEntityServer.server.js +8 -5
- package/dist/custom/MJAIAgentNoteEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.d.ts +17 -0
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.js +71 -0
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.js.map +1 -0
- package/dist/custom/MJAIAgentSessionEntityServer.server.d.ts +8 -39
- package/dist/custom/MJAIAgentSessionEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIAgentSessionEntityServer.server.js +44 -44
- package/dist/custom/MJAIAgentSessionEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts +23 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js +53 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js.map +1 -0
- package/dist/custom/MJAIPromptEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIPromptEntityServer.server.js +2 -1
- package/dist/custom/MJAIPromptEntityServer.server.js.map +1 -1
- package/dist/custom/MJBrandKitEntityServer.server.d.ts +14 -0
- package/dist/custom/MJBrandKitEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJBrandKitEntityServer.server.js +75 -0
- package/dist/custom/MJBrandKitEntityServer.server.js.map +1 -0
- package/dist/custom/MJCompanyIntegrationEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJCompanyIntegrationEntityServer.server.js +1 -0
- package/dist/custom/MJCompanyIntegrationEntityServer.server.js.map +1 -1
- package/dist/custom/MJComponentEntityServer.server.d.ts +11 -0
- package/dist/custom/MJComponentEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJComponentEntityServer.server.js +30 -2
- package/dist/custom/MJComponentEntityServer.server.js.map +1 -1
- package/dist/custom/MJConversationEntityServer.server.d.ts +13 -0
- package/dist/custom/MJConversationEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJConversationEntityServer.server.js +33 -0
- package/dist/custom/MJConversationEntityServer.server.js.map +1 -0
- package/dist/custom/MJDashboardEntityServer.server.d.ts +14 -0
- package/dist/custom/MJDashboardEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJDashboardEntityServer.server.js +38 -0
- package/dist/custom/MJDashboardEntityServer.server.js.map +1 -0
- package/dist/custom/MJDuplicateRunEntityServer.server.d.ts +34 -2
- package/dist/custom/MJDuplicateRunEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJDuplicateRunEntityServer.server.js +103 -23
- package/dist/custom/MJDuplicateRunEntityServer.server.js.map +1 -1
- package/dist/custom/MJEntityAlternateBaseViewEntityServer.server.d.ts +73 -0
- package/dist/custom/MJEntityAlternateBaseViewEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJEntityAlternateBaseViewEntityServer.server.js +391 -0
- package/dist/custom/MJEntityAlternateBaseViewEntityServer.server.js.map +1 -0
- package/dist/custom/MJEntityDocumentEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJEntityDocumentEntityServer.server.js +1 -0
- package/dist/custom/MJEntityDocumentEntityServer.server.js.map +1 -1
- package/dist/custom/MJEntityFieldPermissionEntityServer.server.d.ts +96 -22
- package/dist/custom/MJEntityFieldPermissionEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJEntityFieldPermissionEntityServer.server.js +239 -55
- package/dist/custom/MJEntityFieldPermissionEntityServer.server.js.map +1 -1
- package/dist/custom/MJListDetailEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJListDetailEntityServer.server.js +1 -0
- package/dist/custom/MJListDetailEntityServer.server.js.map +1 -1
- package/dist/custom/MJQueryEntityServer.server.d.ts +184 -46
- package/dist/custom/MJQueryEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJQueryEntityServer.server.js +505 -159
- package/dist/custom/MJQueryEntityServer.server.js.map +1 -1
- package/dist/custom/MJQuerySQLEntityServer.server.d.ts +15 -18
- package/dist/custom/MJQuerySQLEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJQuerySQLEntityServer.server.js +34 -42
- package/dist/custom/MJQuerySQLEntityServer.server.js.map +1 -1
- package/dist/custom/MJTagEntityServer.server.d.ts +2 -0
- package/dist/custom/MJTagEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJTagEntityServer.server.js +13 -7
- package/dist/custom/MJTagEntityServer.server.js.map +1 -1
- package/dist/custom/MJUserRoleEntityServer.server.d.ts +74 -7
- package/dist/custom/MJUserRoleEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJUserRoleEntityServer.server.js +206 -20
- package/dist/custom/MJUserRoleEntityServer.server.js.map +1 -1
- package/dist/custom/MJUserRoutineEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJUserRoutineEntityServer.server.js +8 -1
- package/dist/custom/MJUserRoutineEntityServer.server.js.map +1 -1
- package/dist/custom/MJUserViewEntityServer.server.d.ts +17 -1
- package/dist/custom/MJUserViewEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJUserViewEntityServer.server.js +95 -7
- package/dist/custom/MJUserViewEntityServer.server.js.map +1 -1
- package/dist/custom/MJVectorIndexEntityServer.server.d.ts +2 -0
- package/dist/custom/MJVectorIndexEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJVectorIndexEntityServer.server.js +33 -0
- package/dist/custom/MJVectorIndexEntityServer.server.js.map +1 -1
- package/dist/custom/anonymousOwnershipKeyGuard.d.ts +42 -0
- package/dist/custom/anonymousOwnershipKeyGuard.d.ts.map +1 -0
- package/dist/custom/anonymousOwnershipKeyGuard.js +36 -0
- package/dist/custom/anonymousOwnershipKeyGuard.js.map +1 -0
- package/dist/custom/approvalStamp.d.ts +37 -0
- package/dist/custom/approvalStamp.d.ts.map +1 -0
- package/dist/custom/approvalStamp.js +67 -0
- package/dist/custom/approvalStamp.js.map +1 -0
- package/dist/custom/fieldPermissionAccess.d.ts +31 -0
- package/dist/custom/fieldPermissionAccess.d.ts.map +1 -0
- package/dist/custom/fieldPermissionAccess.js +38 -0
- package/dist/custom/fieldPermissionAccess.js.map +1 -0
- package/dist/custom/fieldPermissionReconciler.d.ts.map +1 -1
- package/dist/custom/fieldPermissionReconciler.js +12 -2
- package/dist/custom/fieldPermissionReconciler.js.map +1 -1
- package/dist/custom/query-extraction/childRowWriter.d.ts +77 -0
- package/dist/custom/query-extraction/childRowWriter.d.ts.map +1 -0
- package/dist/custom/query-extraction/childRowWriter.js +277 -0
- package/dist/custom/query-extraction/childRowWriter.js.map +1 -0
- package/dist/custom/query-extraction/compositionTargets.d.ts +40 -0
- package/dist/custom/query-extraction/compositionTargets.d.ts.map +1 -0
- package/dist/custom/query-extraction/compositionTargets.js +99 -0
- package/dist/custom/query-extraction/compositionTargets.js.map +1 -0
- package/dist/custom/query-extraction/declared.d.ts +79 -0
- package/dist/custom/query-extraction/declared.d.ts.map +1 -0
- package/dist/custom/query-extraction/declared.js +91 -0
- package/dist/custom/query-extraction/declared.js.map +1 -0
- package/dist/custom/query-extraction/describeFacts.d.ts +40 -0
- package/dist/custom/query-extraction/describeFacts.d.ts.map +1 -0
- package/dist/custom/query-extraction/describeFacts.js +225 -0
- package/dist/custom/query-extraction/describeFacts.js.map +1 -0
- package/dist/custom/query-extraction/descriptionPass.d.ts +23 -0
- package/dist/custom/query-extraction/descriptionPass.d.ts.map +1 -0
- package/dist/custom/query-extraction/descriptionPass.js +95 -0
- package/dist/custom/query-extraction/descriptionPass.js.map +1 -0
- package/dist/custom/query-extraction/extractQuery.d.ts +25 -0
- package/dist/custom/query-extraction/extractQuery.d.ts.map +1 -0
- package/dist/custom/query-extraction/extractQuery.js +146 -0
- package/dist/custom/query-extraction/extractQuery.js.map +1 -0
- package/dist/custom/query-extraction/extractionTypes.d.ts +133 -0
- package/dist/custom/query-extraction/extractionTypes.d.ts.map +1 -0
- package/dist/custom/query-extraction/extractionTypes.js +2 -0
- package/dist/custom/query-extraction/extractionTypes.js.map +1 -0
- package/dist/custom/query-extraction/index.d.ts +16 -0
- package/dist/custom/query-extraction/index.d.ts.map +1 -1
- package/dist/custom/query-extraction/index.js +11 -1
- package/dist/custom/query-extraction/index.js.map +1 -1
- package/dist/custom/query-extraction/pipeline.d.ts +6 -2
- package/dist/custom/query-extraction/pipeline.d.ts.map +1 -1
- package/dist/custom/query-extraction/pipeline.js +21 -14
- package/dist/custom/query-extraction/pipeline.js.map +1 -1
- package/dist/custom/query-extraction/resolve.d.ts +7 -2
- package/dist/custom/query-extraction/resolve.d.ts.map +1 -1
- package/dist/custom/query-extraction/resolve.js +41 -20
- package/dist/custom/query-extraction/resolve.js.map +1 -1
- package/dist/custom/query-extraction/sourceBinding.d.ts +57 -0
- package/dist/custom/query-extraction/sourceBinding.d.ts.map +1 -0
- package/dist/custom/query-extraction/sourceBinding.js +104 -0
- package/dist/custom/query-extraction/sourceBinding.js.map +1 -0
- package/dist/custom/query-extraction/sync.d.ts +28 -4
- package/dist/custom/query-extraction/sync.d.ts.map +1 -1
- package/dist/custom/query-extraction/sync.js +147 -59
- package/dist/custom/query-extraction/sync.js.map +1 -1
- package/dist/custom/query-extraction/templateFacts.d.ts +62 -0
- package/dist/custom/query-extraction/templateFacts.d.ts.map +1 -0
- package/dist/custom/query-extraction/templateFacts.js +229 -0
- package/dist/custom/query-extraction/templateFacts.js.map +1 -0
- package/dist/custom/query-extraction/types.d.ts +8 -0
- package/dist/custom/query-extraction/types.d.ts.map +1 -1
- package/dist/custom/query-refresh/QueryExtractionService.d.ts +54 -0
- package/dist/custom/query-refresh/QueryExtractionService.d.ts.map +1 -0
- package/dist/custom/query-refresh/QueryExtractionService.js +207 -0
- package/dist/custom/query-refresh/QueryExtractionService.js.map +1 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.d.ts +28 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.d.ts.map +1 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.js +106 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.js.map +1 -0
- package/dist/custom/query-refresh/index.d.ts +14 -0
- package/dist/custom/query-refresh/index.d.ts.map +1 -0
- package/dist/custom/query-refresh/index.js +10 -0
- package/dist/custom/query-refresh/index.js.map +1 -0
- package/dist/custom/query-refresh/queryRebind.d.ts +33 -0
- package/dist/custom/query-refresh/queryRebind.d.ts.map +1 -0
- package/dist/custom/query-refresh/queryRebind.js +85 -0
- package/dist/custom/query-refresh/queryRebind.js.map +1 -0
- package/dist/custom/query-refresh/refreshAuthorization.d.ts +29 -0
- package/dist/custom/query-refresh/refreshAuthorization.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshAuthorization.js +66 -0
- package/dist/custom/query-refresh/refreshAuthorization.js.map +1 -0
- package/dist/custom/query-refresh/refreshFormat.d.ts +16 -0
- package/dist/custom/query-refresh/refreshFormat.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshFormat.js +67 -0
- package/dist/custom/query-refresh/refreshFormat.js.map +1 -0
- package/dist/custom/query-refresh/refreshOrder.d.ts +25 -0
- package/dist/custom/query-refresh/refreshOrder.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshOrder.js +95 -0
- package/dist/custom/query-refresh/refreshOrder.js.map +1 -0
- package/dist/custom/query-refresh/refreshSelection.d.ts +15 -0
- package/dist/custom/query-refresh/refreshSelection.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshSelection.js +99 -0
- package/dist/custom/query-refresh/refreshSelection.js.map +1 -0
- package/dist/custom/query-refresh/refreshTypes.d.ts +81 -0
- package/dist/custom/query-refresh/refreshTypes.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshTypes.js +5 -0
- package/dist/custom/query-refresh/refreshTypes.js.map +1 -0
- package/dist/custom/systemUserGuardState.d.ts +73 -0
- package/dist/custom/systemUserGuardState.d.ts.map +1 -0
- package/dist/custom/systemUserGuardState.js +161 -0
- package/dist/custom/systemUserGuardState.js.map +1 -0
- package/dist/custom/template-extraction/parser.js +5 -2
- package/dist/custom/template-extraction/parser.js.map +1 -1
- package/dist/custom/template-extraction/types.d.ts +1 -1
- package/dist/custom/template-extraction/types.d.ts.map +1 -1
- package/dist/custom/util.d.ts +8 -0
- package/dist/custom/util.d.ts.map +1 -1
- package/dist/custom/util.js +18 -1
- package/dist/custom/util.js.map +1 -1
- package/dist/engines/QueryEngineServer.d.ts +4 -1
- package/dist/engines/QueryEngineServer.d.ts.map +1 -1
- package/dist/engines/QueryEngineServer.js +10 -7
- package/dist/engines/QueryEngineServer.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +30 -30
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { DatabasePlatform, EntityInfo, QueryDependencySpec, UserInfo } from "@memberjunction/core";
|
|
2
|
+
import type { CompositionCandidate } from "./compositionTargets.js";
|
|
3
|
+
import type { DescribeStatementResult } from "@memberjunction/generic-database-provider";
|
|
4
|
+
/**
|
|
5
|
+
* What a query save does about extraction, set per save on the query entity
|
|
6
|
+
* (`MJQueryEntityServer.ExtractionOverride`).
|
|
7
|
+
*
|
|
8
|
+
* - `Auto`: extract when the query is new or its SQL changed.
|
|
9
|
+
* - `Skip`: do not extract on this save, even when the SQL changed. The save-time rules are not
|
|
10
|
+
* applied; the stored child rows, the Extraction columns and `UsesTemplate` stay as they are.
|
|
11
|
+
* - `Force`: extract on this save even when the SQL did not change (a refresh).
|
|
12
|
+
*/
|
|
13
|
+
export type QueryExtractionOverride = 'Auto' | 'Skip' | 'Force';
|
|
14
|
+
/** The outcome of an extraction run, as stored in `MJ: Queries.ExtractionStatus`. */
|
|
15
|
+
export type QueryExtractionStatus = 'OK' | 'Warning' | 'Error' | 'Skipped';
|
|
16
|
+
/**
|
|
17
|
+
* Which save-time rules apply: `Save` for a new or edited query (errors refuse the save),
|
|
18
|
+
* `Refresh` for re-extracting a query whose SQL did not change (errors are recorded, never refused).
|
|
19
|
+
*/
|
|
20
|
+
export type QueryExtractionMode = 'Save' | 'Refresh';
|
|
21
|
+
/** A parameter type the `MJ: Query Parameters` table stores. */
|
|
22
|
+
export type QueryParameterType = 'string' | 'number' | 'date' | 'boolean' | 'array';
|
|
23
|
+
/**
|
|
24
|
+
* A parameter row extraction knows about before it runs: a row the save declares, or a row
|
|
25
|
+
* already stored. Its type, sample and server-set flag drive the renders that are described.
|
|
26
|
+
*/
|
|
27
|
+
export interface KnownQueryParameter {
|
|
28
|
+
readonly Name: string;
|
|
29
|
+
readonly Type: QueryParameterType;
|
|
30
|
+
readonly IsRequired: boolean;
|
|
31
|
+
readonly IsServerSet: boolean;
|
|
32
|
+
readonly SampleValue: string | null;
|
|
33
|
+
readonly DefaultValue: string | null;
|
|
34
|
+
readonly ValidationFilters: string | null;
|
|
35
|
+
/** Whether a person wrote the row (`DetectionMethod` `Manual`). */
|
|
36
|
+
readonly IsAuthored: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Everything one extraction run reads. Independent of the entity object, so it can be tested alone. */
|
|
39
|
+
export interface QueryExtractionInput {
|
|
40
|
+
/** The query's ID; `null` for a query not saved yet. */
|
|
41
|
+
readonly QueryID: string | null;
|
|
42
|
+
readonly QueryName: string;
|
|
43
|
+
/** The query's full path (category path and name), for composition cycle detection. */
|
|
44
|
+
readonly QueryPath: string;
|
|
45
|
+
/** The SQL to extract from: the query's SQL for the platform described on. */
|
|
46
|
+
readonly SQL: string;
|
|
47
|
+
/** The platform the SQL is rendered for and described on. */
|
|
48
|
+
readonly Platform: DatabasePlatform;
|
|
49
|
+
readonly Mode: QueryExtractionMode;
|
|
50
|
+
/** Whether the query reads an external data source, which the database server cannot describe. */
|
|
51
|
+
readonly IsExternal: boolean;
|
|
52
|
+
readonly KnownParameters: readonly KnownQueryParameter[];
|
|
53
|
+
/** Tested sample values a caller supplied (`ParameterHints`), by parameter name. */
|
|
54
|
+
readonly ParameterHints?: ReadonlyMap<string, string>;
|
|
55
|
+
/** The user the renders are made for (composed queries must be runnable by them). */
|
|
56
|
+
readonly ContextUser: UserInfo;
|
|
57
|
+
/** The entity catalog sources and table references are mapped through. */
|
|
58
|
+
readonly Entities: readonly EntityInfo[];
|
|
59
|
+
/** The saved queries compositions resolve against. */
|
|
60
|
+
readonly Queries: readonly CompositionCandidate[];
|
|
61
|
+
/**
|
|
62
|
+
* Render specs for composed queries the shared query cache does not hold yet (saved earlier in
|
|
63
|
+
* the same transaction), searched before the cache when the describe renders compose them.
|
|
64
|
+
*/
|
|
65
|
+
readonly CompositionDependencies?: readonly QueryDependencySpec[];
|
|
66
|
+
/** Describes a rendered statement on the database server; `null` when the provider cannot. */
|
|
67
|
+
readonly Describe: ((sql: string) => Promise<DescribeStatementResult>) | null;
|
|
68
|
+
}
|
|
69
|
+
/** The facts of one output column: what the server reports, mapped through MJ metadata. */
|
|
70
|
+
export interface QueryFieldFact {
|
|
71
|
+
readonly Name: string;
|
|
72
|
+
readonly Sequence: number;
|
|
73
|
+
readonly SQLBaseType: string;
|
|
74
|
+
readonly SQLFullType: string;
|
|
75
|
+
readonly IsNullable: boolean | null;
|
|
76
|
+
readonly IsComputed: boolean;
|
|
77
|
+
readonly SourceEntityID: string | null;
|
|
78
|
+
readonly SourceEntityFieldID: string | null;
|
|
79
|
+
readonly SourceFieldName: string | null;
|
|
80
|
+
readonly SourceObjectName: string | null;
|
|
81
|
+
/** A doc-comment description: an authored annotation. */
|
|
82
|
+
readonly DocDescription: string | null;
|
|
83
|
+
/** The source entity field's description, used for a new row with no other description. */
|
|
84
|
+
readonly SourceDescription: string | null;
|
|
85
|
+
}
|
|
86
|
+
/** The facts of one parameter the template reads. */
|
|
87
|
+
export interface QueryParameterFact {
|
|
88
|
+
readonly Name: string;
|
|
89
|
+
/** The type the template's filters imply; `null` when they imply none. */
|
|
90
|
+
readonly Type: QueryParameterType | null;
|
|
91
|
+
readonly IsRequired: boolean;
|
|
92
|
+
readonly DefaultValue: string | null;
|
|
93
|
+
/** A sample for a new row: the caller's hint, or the value a composed query's parameter has. */
|
|
94
|
+
readonly SampleValue: string | null;
|
|
95
|
+
/** A doc-comment description: an authored annotation. */
|
|
96
|
+
readonly DocDescription: string | null;
|
|
97
|
+
/** A description inherited from the composed query's parameter this one is passed to. */
|
|
98
|
+
readonly InheritedDescription: string | null;
|
|
99
|
+
}
|
|
100
|
+
/** An entity the query reads, through its base view, base table or an alternate base view. */
|
|
101
|
+
export interface QueryEntityFact {
|
|
102
|
+
readonly EntityID: string;
|
|
103
|
+
readonly AlternateBaseViewID: string | null;
|
|
104
|
+
}
|
|
105
|
+
/** A query this query composes. */
|
|
106
|
+
export interface QueryDependencyFact {
|
|
107
|
+
readonly DependsOnQueryID: string;
|
|
108
|
+
/** The full path as the composition writes it. */
|
|
109
|
+
readonly ReferencePath: string;
|
|
110
|
+
readonly Alias: string | null;
|
|
111
|
+
/** The arguments, as JSON (`{"Region":"@Region","Year":"2024"}`), or `null` when there are none. */
|
|
112
|
+
readonly ParameterMapping: string | null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The result of one extraction run. A `null` collection means its facts could not be established
|
|
116
|
+
* (a describe failure, an external source, SQL that could not be read): its stored rows are kept.
|
|
117
|
+
*/
|
|
118
|
+
export interface QueryExtractionResult {
|
|
119
|
+
/** Whether the SQL holds any template tag outside SQL comments: a lexer fact. */
|
|
120
|
+
readonly UsesTemplate: boolean;
|
|
121
|
+
/** Set when the save must be refused (save-time rule errors, duplicate output names); the reason. */
|
|
122
|
+
readonly Refusal: string | null;
|
|
123
|
+
readonly Status: QueryExtractionStatus;
|
|
124
|
+
/** Diagnostics for `ExtractionMessage`, one per line. */
|
|
125
|
+
readonly Messages: readonly string[];
|
|
126
|
+
/** SHA-256 of the platform SQL and the dialect key. */
|
|
127
|
+
readonly Hash: string;
|
|
128
|
+
readonly Fields: readonly QueryFieldFact[] | null;
|
|
129
|
+
readonly Parameters: readonly QueryParameterFact[];
|
|
130
|
+
readonly Entities: readonly QueryEntityFact[] | null;
|
|
131
|
+
readonly Dependencies: readonly QueryDependencyFact[] | null;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=extractionTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractionTypes.d.ts","sourceRoot":"","sources":["../../../src/custom/query-extraction/extractionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAEzF;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,qFAAqF;AACrF,MAAM,MAAM,qBAAqB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3E;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD,gEAAgE;AAChE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAA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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractionTypes.js","sourceRoot":"","sources":["../../../src/custom/query-extraction/extractionTypes.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export { ComputeQueryExtraction, ExtractionSQLHash } from "./extractQuery.js";
|
|
2
|
+
export { WriteExtractedChildRows, ApplyFieldFacts } from "./childRowWriter.js";
|
|
3
|
+
export type { ChildRowWriteContext, ChildRowWriteSummary, ChildRowChange, QueryChildCollection } from "./childRowWriter.js";
|
|
4
|
+
export { RunDescriptionPass } from "./descriptionPass.js";
|
|
5
|
+
export type { DescriptionPassRequest } from "./descriptionPass.js";
|
|
6
|
+
export { AnalyzeQueryTemplate, SQLUsesTemplate, DescribeDiagnostic } from "./templateFacts.js";
|
|
7
|
+
export { ReadCompositionTargetsAsync, MergeCompositionCandidates } from "./compositionTargets.js";
|
|
8
|
+
export type { CompositionCandidate, CompositionCandidateParameter, CompositionTargetRead } from "./compositionTargets.js";
|
|
9
|
+
export type { TemplateAnalysis } from "./templateFacts.js";
|
|
10
|
+
export { DescribeQueryOutput, SampleValueFor } from "./describeFacts.js";
|
|
11
|
+
export type { DescribedOutput } from "./describeFacts.js";
|
|
12
|
+
export { EntityObjectIndex, BindColumnSource, BindTableReferences } from "./sourceBinding.js";
|
|
13
|
+
export type { BoundColumnSource } from "./sourceBinding.js";
|
|
14
|
+
export type { QueryExtractionOverride, QueryExtractionStatus, QueryExtractionMode, QueryParameterType, KnownQueryParameter, QueryExtractionInput, QueryFieldFact, QueryParameterFact, QueryEntityFact, QueryDependencyFact, QueryExtractionResult, } from "./extractionTypes.js";
|
|
1
15
|
export { RunExtractionPipeline, CleanupQueryData } from "./pipeline.js";
|
|
2
16
|
export type { PipelineResult } from "./pipeline.js";
|
|
3
17
|
export type { ExtractedParameter, ExtractedField, ParameterExtractionResult, PassthroughParamContext, ResolvedCompositionReference, EntityMetadataEntry, ParseResult, ResolveResult, QuerySyncContext, } from "./types.js";
|
|
@@ -5,5 +19,7 @@ export { ParseQuerySQL, parseQuerySQL } from "./parse.js";
|
|
|
5
19
|
export { ResolveCompositionReferences, ResolveQueryByNameAndCategory, BuildParameterMappings, ExtractAliasFromSQL, BuildPassthroughParams, MergePassthroughParams, MapQueryParamTypeToParserType, BuildFieldsForSelectStar, EnrichFieldTypesFromCompositions, EnrichFieldTypesFromEntityMetadata, ExpandWildcardFields, ExtractEntityMetadataFromSQL, DetectDependencyCycles, FindEntityByName, } from "./resolve.js";
|
|
6
20
|
export { RunLLMEnrichment, MergeParametersWithLLM, GenerateParameterDescription, BuildPassthroughDescription, GenerateSampleValue, } from "./enrich.js";
|
|
7
21
|
export { SyncParameters, SyncFields, SyncEntities, SyncDependencies, RemoveAllRecords } from "./sync.js";
|
|
22
|
+
export { CollectDeclaredQueryChildren, HasDeclaredQueryChildren, FindReplacedRows, QueueReplacedRowDeletion, QueryChildNameKey, QueryEntityKey, NO_DECLARED_QUERY_CHILDREN, } from "./declared.js";
|
|
23
|
+
export type { DeclaredQueryChildren, DeclaredQueryCollections } from "./declared.js";
|
|
8
24
|
export { ConvertTSQLToPostgreSQL } from "./dialect.js";
|
|
9
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom/query-extraction/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACrE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,YAAY,EACR,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,4BAA4B,EAC5B,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,gBAAgB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGvD,OAAO,EACH,4BAA4B,E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,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,GAC7B,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAGlF,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
// Query Extraction Pipeline — barrel exports
|
|
2
2
|
// Re-exports the public API for the query extraction subsystem.
|
|
3
|
-
//
|
|
3
|
+
// Extraction (describe-based): facts, child-row writes, the post-commit description pass
|
|
4
|
+
export { ComputeQueryExtraction, ExtractionSQLHash } from "./extractQuery.js";
|
|
5
|
+
export { WriteExtractedChildRows, ApplyFieldFacts } from "./childRowWriter.js";
|
|
6
|
+
export { RunDescriptionPass } from "./descriptionPass.js";
|
|
7
|
+
export { AnalyzeQueryTemplate, SQLUsesTemplate, DescribeDiagnostic } from "./templateFacts.js";
|
|
8
|
+
export { ReadCompositionTargetsAsync, MergeCompositionCandidates } from "./compositionTargets.js";
|
|
9
|
+
export { DescribeQueryOutput, SampleValueFor } from "./describeFacts.js";
|
|
10
|
+
export { EntityObjectIndex, BindColumnSource, BindTableReferences } from "./sourceBinding.js";
|
|
11
|
+
// Legacy pipeline orchestrator (kept as a façade; saves use ComputeQueryExtraction)
|
|
4
12
|
export { RunExtractionPipeline, CleanupQueryData } from "./pipeline.js";
|
|
5
13
|
// Parse stage
|
|
6
14
|
export { ParseQuerySQL, parseQuerySQL } from "./parse.js";
|
|
@@ -10,6 +18,8 @@ export { ResolveCompositionReferences, ResolveQueryByNameAndCategory, BuildParam
|
|
|
10
18
|
export { RunLLMEnrichment, MergeParametersWithLLM, GenerateParameterDescription, BuildPassthroughDescription, GenerateSampleValue, } from "./enrich.js";
|
|
11
19
|
// Sync engine
|
|
12
20
|
export { SyncParameters, SyncFields, SyncEntities, SyncDependencies, RemoveAllRecords } from "./sync.js";
|
|
21
|
+
// Declared child rows (graph saves)
|
|
22
|
+
export { CollectDeclaredQueryChildren, HasDeclaredQueryChildren, FindReplacedRows, QueueReplacedRowDeletion, QueryChildNameKey, QueryEntityKey, NO_DECLARED_QUERY_CHILDREN, } from "./declared.js";
|
|
13
23
|
// Dialect conversion
|
|
14
24
|
export { ConvertTSQLToPostgreSQL } from "./dialect.js";
|
|
15
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/query-extraction/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,gEAAgE;AAEhE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/query-extraction/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,gEAAgE;AAEhE,yFAAyF;AACzF,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAG/F,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAgB3F,oFAAoF;AACpF,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgBrE,cAAc;AACd,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvD,sDAAsD;AACtD,OAAO,EACH,4BAA4B,EAC5B,6BAA6B,EAC7B,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,EACxB,gCAAgC,EAChC,kCAAkC,EAClC,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,WAAW,CAAC;AAEnB,sCAAsC;AACtC,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC5B,2BAA2B,EAC3B,mBAAmB,GACtB,MAAM,UAAU,CAAC;AAElB,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEtG,oCAAoC;AACpC,OAAO,EACH,4BAA4B,EAC5B,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,GAC7B,MAAM,YAAY,CAAC;AAGpB,qBAAqB;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { QuerySyncContext } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Result of running the full extraction pipeline.
|
|
4
|
-
*
|
|
3
|
+
* Result of running the full extraction pipeline. `UsesTemplate` is a lexical fact: whether the
|
|
4
|
+
* SQL holds any template tag outside SQL comments.
|
|
5
5
|
*/
|
|
6
6
|
export interface PipelineResult {
|
|
7
7
|
UsesTemplate: boolean;
|
|
@@ -15,6 +15,10 @@ export interface PipelineResult {
|
|
|
15
15
|
* 5. SYNC — parallel database writes
|
|
16
16
|
*
|
|
17
17
|
* Throws on invalid composition references (non-existent, non-Reusable, circular).
|
|
18
|
+
*
|
|
19
|
+
* @deprecated Saves extract with `ComputeQueryExtraction` (the database server describes the
|
|
20
|
+
* output) and `WriteExtractedChildRows` (facts corrected, authored annotations kept). This
|
|
21
|
+
* LLM-assisted pipeline is kept for callers of the package API.
|
|
18
22
|
*/
|
|
19
23
|
export declare function RunExtractionPipeline(ctx: QuerySyncContext): Promise<PipelineResult>;
|
|
20
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/custom/query-extraction/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAiC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/custom/query-extraction/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAiC,MAAM,SAAS,CAAC;AAoB/E;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,YAAY,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAqB1F;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ3E"}
|
|
@@ -2,6 +2,8 @@ import { ParseQuerySQL } from "./parse.js";
|
|
|
2
2
|
import { ResolveCompositionReferences, BuildPassthroughParams, MergePassthroughParams, ExtractEntityMetadataFromSQL, BuildFieldsForSelectStar, BuildFieldsFromSelectColumns, EnrichFieldTypesFromCompositions, EnrichFieldTypesFromEntityMetadata, } from "./resolve.js";
|
|
3
3
|
import { RunLLMEnrichment, MergeParametersWithLLM } from "./enrich.js";
|
|
4
4
|
import { SyncParameters, SyncFields, SyncEntities, SyncDependencies, RemoveAllRecords } from "./sync.js";
|
|
5
|
+
import { NO_DECLARED_QUERY_CHILDREN } from "./declared.js";
|
|
6
|
+
import { SQLUsesTemplate } from "./templateFacts.js";
|
|
5
7
|
import { QueryEngine } from "@memberjunction/core-entities";
|
|
6
8
|
import { LocalCacheManager } from "@memberjunction/core";
|
|
7
9
|
import { UUIDsEqual } from "@memberjunction/global";
|
|
@@ -14,6 +16,10 @@ import { UUIDsEqual } from "@memberjunction/global";
|
|
|
14
16
|
* 5. SYNC — parallel database writes
|
|
15
17
|
*
|
|
16
18
|
* Throws on invalid composition references (non-existent, non-Reusable, circular).
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Saves extract with `ComputeQueryExtraction` (the database server describes the
|
|
21
|
+
* output) and `WriteExtractedChildRows` (facts corrected, authored annotations kept). This
|
|
22
|
+
* LLM-assisted pipeline is kept for callers of the package API.
|
|
17
23
|
*/
|
|
18
24
|
export async function RunExtractionPipeline(ctx) {
|
|
19
25
|
// ── STAGE 1: PARSE ──
|
|
@@ -29,7 +35,7 @@ export async function RunExtractionPipeline(ctx) {
|
|
|
29
35
|
// ── STAGE 5: SYNC (parallel DB writes, cache slots rewritten once at the end) ──
|
|
30
36
|
await runInEntityEventBatches(syncBatchOwners(ctx), () => sync(ctx, finalParams, finalFields, resolveResult));
|
|
31
37
|
return {
|
|
32
|
-
UsesTemplate:
|
|
38
|
+
UsesTemplate: SQLUsesTemplate(ctx.sql, ctx.platform ?? 'sqlserver'),
|
|
33
39
|
};
|
|
34
40
|
}
|
|
35
41
|
/**
|
|
@@ -77,10 +83,11 @@ function merge(resolveResult, llmResult, parseResult, ctx) {
|
|
|
77
83
|
const llmFields = llmResult?.selectClause && Array.isArray(llmResult.selectClause) && llmResult.selectClause.length > 0
|
|
78
84
|
? llmResult.selectClause
|
|
79
85
|
: null;
|
|
80
|
-
// When we have deterministic fields, supplement them with LLM descriptions
|
|
86
|
+
// When we have deterministic fields, supplement them with LLM descriptions. The LLM never
|
|
87
|
+
// supplies a source: LLM-only fields carry none.
|
|
81
88
|
const rawFields = resolvedFields
|
|
82
89
|
? supplementDeterministicWithLLM(resolvedFields, llmFields)
|
|
83
|
-
: llmFields;
|
|
90
|
+
: llmFields?.map(f => ({ ...f, sourceEntity: null, sourceFieldName: null })) ?? null;
|
|
84
91
|
const finalFields = rawFields
|
|
85
92
|
? EnrichFieldTypesFromEntityMetadata(EnrichFieldTypesFromCompositions(rawFields, resolveResult.ResolvedCompositionRefs, parseResult.SelectColumns, md), parseResult.SelectColumns, parseResult.TableRefs, md)
|
|
86
93
|
: null;
|
|
@@ -129,22 +136,22 @@ async function runInEntityEventBatches(owners, work) {
|
|
|
129
136
|
}
|
|
130
137
|
async function sync(ctx, finalParams, finalFields, resolveResult) {
|
|
131
138
|
const syncPromises = [];
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
else {
|
|
137
|
-
syncPromises.push(RemoveAllRecords(ctx.queryID, 'MJ: Query Parameters', ctx.contextUser, ctx.runViewProvider, ctx.isSaved));
|
|
138
|
-
}
|
|
139
|
+
const declared = ctx.DeclaredChildren ?? NO_DECLARED_QUERY_CHILDREN;
|
|
140
|
+
// Parameters. With no parameter in the SQL this syncs an empty list: the rows the save declared
|
|
141
|
+
// and the rows a person authored stay, and only the extracted ones go.
|
|
142
|
+
syncPromises.push(SyncParameters(ctx.queryID, finalParams ?? [], ctx.contextUser, ctx.metadataProvider, ctx.runViewProvider, ctx.isSaved, declared.ParameterNames));
|
|
139
143
|
// Fields: when finalFields is null, preserve existing fields instead of deleting them.
|
|
140
144
|
// Deletion only happens when we have a positive new field list (handled inside SyncFields via diff).
|
|
141
145
|
if (finalFields) {
|
|
142
|
-
syncPromises.push(SyncFields(ctx.queryID, finalFields, ctx.contextUser, ctx.metadataProvider, ctx.runViewProvider, ctx.isSaved, ctx.platform));
|
|
146
|
+
syncPromises.push(SyncFields(ctx.queryID, finalFields, ctx.contextUser, ctx.metadataProvider, ctx.runViewProvider, ctx.isSaved, ctx.platform, declared.FieldNames));
|
|
143
147
|
}
|
|
144
148
|
// When finalFields is null, we intentionally do NOT call RemoveAllRecords — existing fields are preserved.
|
|
145
149
|
// Entities
|
|
146
150
|
if (resolveResult.EntityMetadata.length > 0) {
|
|
147
|
-
syncPromises.push(SyncEntities(ctx.queryID, resolveResult.EntityMetadata, ctx.contextUser, ctx.metadataProvider, ctx.runViewProvider, ctx.isSaved));
|
|
151
|
+
syncPromises.push(SyncEntities(ctx.queryID, resolveResult.EntityMetadata, ctx.contextUser, ctx.metadataProvider, ctx.runViewProvider, ctx.isSaved, declared.EntityKeys));
|
|
152
|
+
}
|
|
153
|
+
else if (declared.EntityKeys.size > 0) {
|
|
154
|
+
syncPromises.push(SyncEntities(ctx.queryID, [], ctx.contextUser, ctx.metadataProvider, ctx.runViewProvider, ctx.isSaved, declared.EntityKeys));
|
|
148
155
|
}
|
|
149
156
|
else {
|
|
150
157
|
syncPromises.push(RemoveAllRecords(ctx.queryID, 'MJ: Query Entities', ctx.contextUser, ctx.runViewProvider, ctx.isSaved));
|
|
@@ -184,8 +191,8 @@ function supplementDeterministicWithLLM(resolvedFields, llmFields) {
|
|
|
184
191
|
// LLM may identify summary/computed nature better
|
|
185
192
|
isSummary: llmMatch.isSummary ?? df.isSummary,
|
|
186
193
|
computationDescription: llmMatch.computationDescription ?? df.computationDescription,
|
|
187
|
-
//
|
|
188
|
-
sourceEntity: df.sourceEntity
|
|
194
|
+
// The source is a fact: it never comes from the LLM.
|
|
195
|
+
sourceEntity: df.sourceEntity,
|
|
189
196
|
};
|
|
190
197
|
});
|
|
191
198
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/custom/query-extraction/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EACH,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,gCAAgC,EAChC,kCAAkC,GACrC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB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C,IAAI,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAC3B,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,CAAC;QAEzB,OAAO;YACH,GAAG,EAAE;YACL,mEAAmE;YACnE,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC,WAAW;YACnD,6DAA6D;YAC7D,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI;YAC1D,kDAAkD;YAClD,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS;YAC7C,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB,IAAI,EAAE,CAAC,sBAAsB;YACpF,qDAAqD;YACrD,YAAY,EAAE,EAAE,CAAC,YAAY;SAChC,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -19,8 +19,13 @@ import type { EntityMetadataEntry, ExtractedField, PassthroughParamContext, Reso
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function ResolveCompositionReferences(sql: string, queryName: string, allQueries: MJQueryEntityExtended[]): ResolvedCompositionReference[];
|
|
21
21
|
/**
|
|
22
|
-
* Resolves a query
|
|
23
|
-
*
|
|
22
|
+
* Resolves a query the way a composition reference names it: by its full category path and name,
|
|
23
|
+
* or by a path that is a whole-segment suffix of exactly one same-named query's category path
|
|
24
|
+
* (`Demos/Active Users` finds `MJ/Demos/Active Users`; a warning is logged, and saving such a
|
|
25
|
+
* reference is refused by the template validation). Names and path segments compare ignoring case
|
|
26
|
+
* and surrounding spaces. There is no name-only fallback: a reference with a wrong path, or with no
|
|
27
|
+
* path for a query that has a category, resolves to nothing, and so does a partial path that is a
|
|
28
|
+
* suffix of more than one query's path.
|
|
24
29
|
*/
|
|
25
30
|
export declare function ResolveQueryByNameAndCategory(queryName: string, categorySegments: string[], allQueries: MJQueryEntityExtended[]): MJQueryEntityExtended | undefined;
|
|
26
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/custom/query-extraction/resolve.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/custom/query-extraction/resolve.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,gBAAgB,EAEhB,UAAU,EAEV,iBAAiB,EAGpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAsB,uBAAuB,EAAe,MAAM,+BAA+B,CAAC;AAKhI,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEtG,OAAO,KAAK,EACR,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,4BAA4B,EAC/B,MAAM,SAAS,CAAC;AAOjB;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CACxC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,qBAAqB,EAAE,GACpC,4BAA4B,EAAE,CAyChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CACzC,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,UAAU,EAAE,qBAAqB,EAAE,GACpC,qBAAqB,GAAG,SAAS,CASnC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GA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YAAY,EAAE,4BAA4B,EAAE,EAC5C,aAAa,EAAE,eAAe,EAAE,EAChC,EAAE,EAAE,iBAAiB,GACtB,cAAc,EAAE,CAmBlB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CAC9C,MAAM,EAAE,cAAc,EAAE,EACxB,aAAa,EAAE,eAAe,EAAE,EAChC,SAAS,EAAE,iBAAiB,EAAE,EAC9B,EAAE,EAAE,iBAAiB,GACtB,cAAc,EAAE,CAyBlB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,cAAc,EAAE,EACxB,EAAE,EAAE,iBAAiB,GACtB,cAAc,EAAE,CAsBlB;AAOD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CACxC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,iBAAiB,EAAE,EAC9B,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,EACvC,QAAQ,GAAE,gBAA8B,GACzC,mBAAmB,EAAE,CA+BvB;AAOD;;;GAGG;AACH,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,CAAC;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAAC,EACjD,eAAe,EAAE,uBAAuB,EAAE,EAC1C,UAAU,EAAE,qBAAqB,EAAE,GACpC,MAAM,GAAG,IAAI,CAef;AA8VD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAK5F"}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Contains all deterministic resolution logic — no LLM calls, no database writes.
|
|
5
5
|
* Every function is stateless: context is passed in as parameters rather than via `this`.
|
|
6
6
|
*/
|
|
7
|
-
import { TypeScriptTypeFromSQLType } from "@memberjunction/core";
|
|
7
|
+
import { FindAlternateBaseViewByPhysicalName, LogStatus, TypeScriptTypeFromSQLType, } from "@memberjunction/core";
|
|
8
8
|
import { QueryEngine } from "@memberjunction/core-entities";
|
|
9
9
|
import { QueryCompositionEngine } from "@memberjunction/generic-database-provider";
|
|
10
10
|
import { UUIDsEqual } from "@memberjunction/global";
|
|
11
|
-
import { SQLParser } from "@memberjunction/sql-parser";
|
|
11
|
+
import { MatchCompositionPath, SQLParser } from "@memberjunction/sql-parser";
|
|
12
12
|
import { GetDialect } from "@memberjunction/sql-dialect";
|
|
13
13
|
// ═══════════════════════════════════════════════════
|
|
14
14
|
// Composition Reference Resolution
|
|
@@ -55,20 +55,23 @@ export function ResolveCompositionReferences(sql, queryName, allQueries) {
|
|
|
55
55
|
return resolved;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* Resolves a query
|
|
59
|
-
*
|
|
58
|
+
* Resolves a query the way a composition reference names it: by its full category path and name,
|
|
59
|
+
* or by a path that is a whole-segment suffix of exactly one same-named query's category path
|
|
60
|
+
* (`Demos/Active Users` finds `MJ/Demos/Active Users`; a warning is logged, and saving such a
|
|
61
|
+
* reference is refused by the template validation). Names and path segments compare ignoring case
|
|
62
|
+
* and surrounding spaces. There is no name-only fallback: a reference with a wrong path, or with no
|
|
63
|
+
* path for a query that has a category, resolves to nothing, and so does a partial path that is a
|
|
64
|
+
* suffix of more than one query's path.
|
|
60
65
|
*/
|
|
61
66
|
export function ResolveQueryByNameAndCategory(queryName, categorySegments, allQueries) {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const nameMatches = allQueries.filter(q => q.Name.toLowerCase() === queryNameLower);
|
|
71
|
-
return nameMatches.length === 1 ? nameMatches[0] : undefined;
|
|
67
|
+
const match = MatchCompositionPath(categorySegments, queryName, allQueries);
|
|
68
|
+
if (match.Kind === 'Exact')
|
|
69
|
+
return match.Target;
|
|
70
|
+
if (match.Kind !== 'PartialPath')
|
|
71
|
+
return undefined;
|
|
72
|
+
LogStatus(`Warning (MJQ_COMPOSITION_PARTIAL_PATH): the composition reference "${[...categorySegments, queryName].join('/')}" ` +
|
|
73
|
+
`names the query at "${match.FullPath}" by part of its category path; write the full path {{query:"${match.FullPath}"}}.`);
|
|
74
|
+
return match.Target;
|
|
72
75
|
}
|
|
73
76
|
/**
|
|
74
77
|
* Builds the parameter mapping and extracts passthrough mappings from parsed composition parameters.
|
|
@@ -403,15 +406,18 @@ export function ExtractEntityMetadataFromSQL(sql, tableRefs, md, platform = 'sql
|
|
|
403
406
|
try {
|
|
404
407
|
const columnRefs = SQLParser.ExtractColumnRefs(sql, GetDialect(platform));
|
|
405
408
|
for (const tableRef of tableRefs) {
|
|
406
|
-
const
|
|
407
|
-
if (
|
|
409
|
+
const match = findEntityAndAbvByTableRef(md, tableRef);
|
|
410
|
+
if (match) {
|
|
411
|
+
const { entity: matchingEntity, alternateBaseView } = match;
|
|
408
412
|
const relevantFields = extractRelevantFields(matchingEntity, tableRef, columnRefs);
|
|
409
413
|
if (relevantFields.length > 0) {
|
|
410
414
|
results.push({
|
|
411
415
|
name: matchingEntity.Name,
|
|
412
416
|
SchemaName: matchingEntity.SchemaName,
|
|
413
|
-
BaseView: matchingEntity.BaseView,
|
|
417
|
+
BaseView: alternateBaseView ? alternateBaseView.ViewName : matchingEntity.BaseView,
|
|
414
418
|
Fields: relevantFields,
|
|
419
|
+
AlternateBaseViewID: alternateBaseView ? alternateBaseView.ID : null,
|
|
420
|
+
AlternateBaseViewName: alternateBaseView ? alternateBaseView.Name : null,
|
|
415
421
|
});
|
|
416
422
|
}
|
|
417
423
|
}
|
|
@@ -691,12 +697,27 @@ function findEntityNameByID(md, entityID) {
|
|
|
691
697
|
return entity?.Name ?? null;
|
|
692
698
|
}
|
|
693
699
|
/**
|
|
694
|
-
* Finds an entity by matching a SQL table reference
|
|
700
|
+
* Finds an entity (and optional registered alternate base view) by matching a SQL table reference
|
|
701
|
+
* against canonical BaseView/BaseTable + SchemaName first, then against registered EntityAlternateBaseViews.
|
|
695
702
|
*/
|
|
696
|
-
function
|
|
697
|
-
|
|
703
|
+
function findEntityAndAbvByTableRef(md, tableRef) {
|
|
704
|
+
const canonicalEntity = md.Entities.find(e => (e.BaseView.toLowerCase() === tableRef.TableName.toLowerCase() ||
|
|
698
705
|
e.BaseTable.toLowerCase() === tableRef.TableName.toLowerCase()) &&
|
|
699
706
|
e.SchemaName.toLowerCase() === tableRef.SchemaName.toLowerCase());
|
|
707
|
+
if (canonicalEntity) {
|
|
708
|
+
return { entity: canonicalEntity };
|
|
709
|
+
}
|
|
710
|
+
const abvMatch = FindAlternateBaseViewByPhysicalName(md.Entities, tableRef.TableName, tableRef.SchemaName || undefined);
|
|
711
|
+
if (abvMatch) {
|
|
712
|
+
return { entity: abvMatch.entity, alternateBaseView: abvMatch.alternateView };
|
|
713
|
+
}
|
|
714
|
+
return undefined;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Finds an entity by matching a SQL table reference against BaseView/BaseTable/AlternateBaseView + SchemaName.
|
|
718
|
+
*/
|
|
719
|
+
function findEntityByTableRef(md, tableRef) {
|
|
720
|
+
return findEntityAndAbvByTableRef(md, tableRef)?.entity;
|
|
700
721
|
}
|
|
701
722
|
/**
|
|
702
723
|
* Builds an output name -> SQLSelectColumn map for quick lookup.
|