@memberjunction/generic-database-provider 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 +165 -1
- package/dist/GenericDatabaseProvider.d.ts +599 -69
- package/dist/GenericDatabaseProvider.d.ts.map +1 -1
- package/dist/GenericDatabaseProvider.js +2055 -403
- package/dist/GenericDatabaseProvider.js.map +1 -1
- package/dist/SqlLogger.d.ts +26 -0
- package/dist/SqlLogger.d.ts.map +1 -1
- package/dist/SqlLogger.js +77 -20
- package/dist/SqlLogger.js.map +1 -1
- package/dist/clientClauseScreen.d.ts +44 -75
- package/dist/clientClauseScreen.d.ts.map +1 -1
- package/dist/clientClauseScreen.js +129 -267
- package/dist/clientClauseScreen.js.map +1 -1
- package/dist/composition/compositionAssembler.d.ts +33 -0
- package/dist/composition/compositionAssembler.d.ts.map +1 -0
- package/dist/composition/compositionAssembler.js +270 -0
- package/dist/composition/compositionAssembler.js.map +1 -0
- package/dist/composition/compositionInfo.d.ts +7 -0
- package/dist/composition/compositionInfo.d.ts.map +1 -0
- package/dist/composition/compositionInfo.js +31 -0
- package/dist/composition/compositionInfo.js.map +1 -0
- package/dist/composition/compositionLookup.d.ts +44 -0
- package/dist/composition/compositionLookup.d.ts.map +1 -0
- package/dist/composition/compositionLookup.js +122 -0
- package/dist/composition/compositionLookup.js.map +1 -0
- package/dist/composition/compositionRender.d.ts +136 -0
- package/dist/composition/compositionRender.d.ts.map +1 -0
- package/dist/composition/compositionRender.js +264 -0
- package/dist/composition/compositionRender.js.map +1 -0
- package/dist/composition/compositionTypes.d.ts +40 -0
- package/dist/composition/compositionTypes.d.ts.map +1 -0
- package/dist/composition/compositionTypes.js +2 -0
- package/dist/composition/compositionTypes.js.map +1 -0
- package/dist/composition/quotedTagRefusal.d.ts +44 -0
- package/dist/composition/quotedTagRefusal.d.ts.map +1 -0
- package/dist/composition/quotedTagRefusal.js +132 -0
- package/dist/composition/quotedTagRefusal.js.map +1 -0
- package/dist/composition/renderSteps.d.ts +16 -0
- package/dist/composition/renderSteps.d.ts.map +1 -0
- package/dist/composition/renderSteps.js +42 -0
- package/dist/composition/renderSteps.js.map +1 -0
- package/dist/composition/safetyGate.d.ts +46 -0
- package/dist/composition/safetyGate.d.ts.map +1 -0
- package/dist/composition/safetyGate.js +61 -0
- package/dist/composition/safetyGate.js.map +1 -0
- package/dist/composition/templateUnit.d.ts +95 -0
- package/dist/composition/templateUnit.d.ts.map +1 -0
- package/dist/composition/templateUnit.js +189 -0
- package/dist/composition/templateUnit.js.map +1 -0
- package/dist/describeStatement.d.ts +51 -0
- package/dist/describeStatement.d.ts.map +1 -0
- package/dist/describeStatement.js +19 -0
- package/dist/describeStatement.js.map +1 -0
- package/dist/fieldSecurity/projectionStars.d.ts +15 -0
- package/dist/fieldSecurity/projectionStars.d.ts.map +1 -0
- package/dist/fieldSecurity/projectionStars.js +116 -0
- package/dist/fieldSecurity/projectionStars.js.map +1 -0
- package/dist/fieldSecurity/queryColumnSecurity.d.ts +35 -0
- package/dist/fieldSecurity/queryColumnSecurity.d.ts.map +1 -0
- package/dist/fieldSecurity/queryColumnSecurity.js +84 -0
- package/dist/fieldSecurity/queryColumnSecurity.js.map +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/pagingLayout.d.ts +68 -0
- package/dist/pagingLayout.d.ts.map +1 -0
- package/dist/pagingLayout.js +190 -0
- package/dist/pagingLayout.js.map +1 -0
- package/dist/queryCompositionEngine.d.ts +22 -222
- package/dist/queryCompositionEngine.d.ts.map +1 -1
- package/dist/queryCompositionEngine.js +35 -729
- package/dist/queryCompositionEngine.js.map +1 -1
- package/dist/queryPagingEngine.d.ts +26 -5
- package/dist/queryPagingEngine.d.ts.map +1 -1
- package/dist/queryPagingEngine.js +51 -15
- package/dist/queryPagingEngine.js.map +1 -1
- package/dist/recordChangeSnapshot.d.ts +43 -0
- package/dist/recordChangeSnapshot.d.ts.map +1 -0
- package/dist/recordChangeSnapshot.js +85 -0
- package/dist/recordChangeSnapshot.js.map +1 -0
- package/dist/renderPipeline.d.ts +91 -72
- package/dist/renderPipeline.d.ts.map +1 -1
- package/dist/renderPipeline.js +71 -179
- package/dist/renderPipeline.js.map +1 -1
- package/dist/statementMemo.d.ts +29 -0
- package/dist/statementMemo.d.ts.map +1 -0
- package/dist/statementMemo.js +61 -0
- package/dist/statementMemo.js.map +1 -0
- package/dist/systemUserFieldAccess.d.ts +16 -1
- package/dist/systemUserFieldAccess.d.ts.map +1 -1
- package/dist/systemUserFieldAccess.js +39 -8
- package/dist/systemUserFieldAccess.js.map +1 -1
- package/dist/typedQueryParameter.d.ts +55 -0
- package/dist/typedQueryParameter.d.ts.map +1 -0
- package/dist/typedQueryParameter.js +122 -0
- package/dist/typedQueryParameter.js.map +1 -0
- package/dist/types.d.ts +47 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { DatabasePlatform, QueryDependencySpec, QueryTemplateContext, UserInfo } from '@memberjunction/core';
|
|
2
|
+
import type { QueryParameterDefinition } from '@memberjunction/query-processor';
|
|
3
|
+
import type { SQLDialect } from '@memberjunction/sql-dialect';
|
|
4
|
+
import type { CompositionReference } from '@memberjunction/sql-parser';
|
|
5
|
+
import type { CompositionPath, ResolvedComposition } from './compositionTypes.js';
|
|
6
|
+
import { TemplateUnit } from './templateUnit.js';
|
|
7
|
+
/** Maximum nesting of compositions: a query composing a query composing … ten levels deep. */
|
|
8
|
+
export declare const MAX_COMPOSITION_DEPTH = 10;
|
|
9
|
+
/** What one render of a composed query needs beside the outer query itself. */
|
|
10
|
+
export interface CompositionRenderOptions {
|
|
11
|
+
readonly Platform: DatabasePlatform;
|
|
12
|
+
/** The dialect the SQL is read in. */
|
|
13
|
+
readonly Dialect: SQLDialect;
|
|
14
|
+
/** The dialect key the SQL filters render for. */
|
|
15
|
+
readonly DialectKey: string;
|
|
16
|
+
readonly ContextUser?: UserInfo;
|
|
17
|
+
/** The run's server-set values; an unpassed server-set parameter of a composed query reads its own name here. */
|
|
18
|
+
readonly ServerParameters?: Record<string, unknown>;
|
|
19
|
+
/** The `Context` object every template of this render reads (one clock for the whole render). */
|
|
20
|
+
readonly Context: QueryTemplateContext;
|
|
21
|
+
/** The ID of the query being rendered, when it is a saved query, so a composition leading back to it is a cycle. */
|
|
22
|
+
readonly RootQueryID?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve compositions without rendering the outer query: every argument of its compositions
|
|
25
|
+
* must be static, and the outer text keeps its own template tags.
|
|
26
|
+
*/
|
|
27
|
+
readonly StaticArgumentsOnly?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** One query's SQL and values, to be rendered. */
|
|
30
|
+
export interface UnitRenderRequest {
|
|
31
|
+
readonly SQL: string;
|
|
32
|
+
/** Whether the query is flagged a template (`UsesTemplate`). SQL with template syntax renders either way. */
|
|
33
|
+
readonly RendersTemplate: boolean;
|
|
34
|
+
/** Names the query in errors. */
|
|
35
|
+
readonly Label: string;
|
|
36
|
+
/** The saved query's name (a composed query's full path), for refusals written for its owners; absent for SQL that is not a saved query. */
|
|
37
|
+
readonly Name?: string;
|
|
38
|
+
readonly Definitions: ReadonlyArray<QueryParameterDefinition>;
|
|
39
|
+
/** Values a caller supplied (or, for a composed query, arguments that came from caller values). */
|
|
40
|
+
readonly Parameters?: Record<string, unknown>;
|
|
41
|
+
/** Values only the server sets (or arguments that came only from server values and constants). */
|
|
42
|
+
readonly ServerParameters?: Record<string, unknown>;
|
|
43
|
+
/** Whether a value for an undeclared name is accepted; decided once the compositions are known. */
|
|
44
|
+
readonly SkipUnknownParameterCheck: (unit: TemplateUnit) => boolean;
|
|
45
|
+
readonly InlineDependencies: QueryDependencySpec[] | undefined;
|
|
46
|
+
readonly Depth: number;
|
|
47
|
+
/** IDs of the queries being rendered around this one, outermost first, this one included. */
|
|
48
|
+
readonly Stack: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
/** A rendered unit. */
|
|
51
|
+
export interface UnitRenderResult {
|
|
52
|
+
/** Its SQL with each composition replaced by the instance's CTE name. */
|
|
53
|
+
readonly SQL: string;
|
|
54
|
+
readonly AppliedParameters: Record<string, string>;
|
|
55
|
+
/** Whether it holds compositions that are SQL (rendered or in a branch not taken). */
|
|
56
|
+
readonly HasCompositions: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** One composed query with one set of evaluated arguments: rendered once, emitted as one CTE. */
|
|
59
|
+
export interface CompositionInstance {
|
|
60
|
+
readonly Key: string;
|
|
61
|
+
readonly CTEName: string;
|
|
62
|
+
readonly Path: CompositionPath;
|
|
63
|
+
readonly Resolved: ResolvedComposition;
|
|
64
|
+
/** The evaluated arguments, keyed by the composed query's parameter names. */
|
|
65
|
+
readonly Arguments: Record<string, unknown>;
|
|
66
|
+
/** The argument names whose values came only from constants and server-set values. */
|
|
67
|
+
readonly TrustedArguments: ReadonlySet<string>;
|
|
68
|
+
readonly Depth: number;
|
|
69
|
+
readonly ParentStack: readonly string[];
|
|
70
|
+
State: 'Pending' | 'Rendering' | 'Done';
|
|
71
|
+
/** The rendered SQL, once {@link State} is `Done`. */
|
|
72
|
+
RenderedSQL: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Render-then-compose for one render: the outer template renders once, each composition it
|
|
76
|
+
* reaches records an instance (query + arguments evaluated in the caller's scope) and writes the
|
|
77
|
+
* instance's CTE name; each instance then renders on its own, with only its arguments, its own
|
|
78
|
+
* parameter definitions and the interpreter gate, recursively. All state lives on this object, so
|
|
79
|
+
* renders are re-entrant and safe under concurrency.
|
|
80
|
+
*
|
|
81
|
+
* Instances are deduplicated by query ID and evaluated arguments, cycles and depth are checked,
|
|
82
|
+
* and each saved composed query must be Reusable, Approved and runnable by the context user.
|
|
83
|
+
* {@link Instances} lists them dependencies first (post-order).
|
|
84
|
+
*/
|
|
85
|
+
export declare class CompositionRender {
|
|
86
|
+
private readonly options;
|
|
87
|
+
/** Every rendered instance, each after the instances it composes. */
|
|
88
|
+
readonly Instances: CompositionInstance[];
|
|
89
|
+
private readonly byKey;
|
|
90
|
+
constructor(options: CompositionRenderOptions);
|
|
91
|
+
/** Renders the outer query and, through it, every composed instance. */
|
|
92
|
+
RenderOuter(request: UnitRenderRequest): UnitRenderResult;
|
|
93
|
+
private renderUnit;
|
|
94
|
+
/**
|
|
95
|
+
* Whether a unit renders as a template: when it is flagged one, or when its SQL holds template
|
|
96
|
+
* syntax outside SQL comments. Whether SQL is a template is a lexical fact (COMPAT-MAP B12): the
|
|
97
|
+
* stored `UsesTemplate` flag can be stale or unset (a query whose only tokens read `Context` has
|
|
98
|
+
* no parameters to flag it by), and unrendered `{{ }}` text is never valid SQL.
|
|
99
|
+
*/
|
|
100
|
+
private rendersAsTemplate;
|
|
101
|
+
/**
|
|
102
|
+
* Evaluates the composition arguments of a query that is not rendered as a template. Static
|
|
103
|
+
* arguments need no values; arguments that read the query's parameters are evaluated with its
|
|
104
|
+
* validated values.
|
|
105
|
+
*/
|
|
106
|
+
private evaluateCalls;
|
|
107
|
+
private process;
|
|
108
|
+
/**
|
|
109
|
+
* The names a caller value may not use because they reach a server-set parameter of a query
|
|
110
|
+
* this unit composes: the outer names an argument for it reads, or the parameter's own name
|
|
111
|
+
* when no argument is passed for it. A composition that does not resolve protects nothing (it
|
|
112
|
+
* fails when reached).
|
|
113
|
+
*/
|
|
114
|
+
private protectedNames;
|
|
115
|
+
/** The names in a unit's scope whose values only the server sets. Template-assigned names never count. */
|
|
116
|
+
private trustedNames;
|
|
117
|
+
/**
|
|
118
|
+
* Records the instance a composition reaches with evaluated arguments and returns its CTE
|
|
119
|
+
* name. A repeat (same query, same arguments) returns the existing instance.
|
|
120
|
+
* @throws Error when the query is not found, may not be composed, or leads back to a query being rendered.
|
|
121
|
+
*/
|
|
122
|
+
RecordInstance(reference: CompositionReference, args: Record<string, unknown>, trusted: ReadonlySet<string>, request: UnitRenderRequest): CompositionInstance;
|
|
123
|
+
private renderInstance;
|
|
124
|
+
/**
|
|
125
|
+
* An instance's values: arguments from caller values as caller values, the rest as server
|
|
126
|
+
* values, and, for a server-set parameter no argument is passed for, the run's server value of
|
|
127
|
+
* that name.
|
|
128
|
+
*/
|
|
129
|
+
private instanceValues;
|
|
130
|
+
private cteName;
|
|
131
|
+
}
|
|
132
|
+
/** The arguments as a stable string: sorted by name, dates as ISO text. */
|
|
133
|
+
export declare function StableArguments(args: Record<string, unknown>): string;
|
|
134
|
+
/** A short deterministic hash of `input`, base 36. */
|
|
135
|
+
export declare function ShortHash(input: string): string;
|
|
136
|
+
//# sourceMappingURL=compositionRender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositionRender.d.ts","sourceRoot":"","sources":["../../src/composition/compositionRender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAClH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIvE,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAA6B,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE5E,8FAA8F;AAC9F,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,+EAA+E;AAC/E,MAAM,WAAW,wBAAwB;IACrC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B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C,YAAY;IAYpB;;;;OAIG;IACH,cAAc,CAAC,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,mBAAmB;IAmB7J,OAAO,CAAC,cAAc;IAyBtB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,OAAO;CAIlB;AA2DD,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAKrE;AAED,sDAAsD;AACtD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { NormalizeUUID, UUIDsEqual } from '@memberjunction/global';
|
|
2
|
+
import { QueryParameterProcessor } from '@memberjunction/query-processor';
|
|
3
|
+
import { CompositionLookup } from './compositionLookup.js';
|
|
4
|
+
import { COMPOSITION_RECORDER_NAME, TemplateUnit } from './templateUnit.js';
|
|
5
|
+
/** Maximum nesting of compositions: a query composing a query composing … ten levels deep. */
|
|
6
|
+
export const MAX_COMPOSITION_DEPTH = 10;
|
|
7
|
+
/**
|
|
8
|
+
* Render-then-compose for one render: the outer template renders once, each composition it
|
|
9
|
+
* reaches records an instance (query + arguments evaluated in the caller's scope) and writes the
|
|
10
|
+
* instance's CTE name; each instance then renders on its own, with only its arguments, its own
|
|
11
|
+
* parameter definitions and the interpreter gate, recursively. All state lives on this object, so
|
|
12
|
+
* renders are re-entrant and safe under concurrency.
|
|
13
|
+
*
|
|
14
|
+
* Instances are deduplicated by query ID and evaluated arguments, cycles and depth are checked,
|
|
15
|
+
* and each saved composed query must be Reusable, Approved and runnable by the context user.
|
|
16
|
+
* {@link Instances} lists them dependencies first (post-order).
|
|
17
|
+
*/
|
|
18
|
+
export class CompositionRender {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
/** Every rendered instance, each after the instances it composes. */
|
|
22
|
+
this.Instances = [];
|
|
23
|
+
this.byKey = new Map();
|
|
24
|
+
}
|
|
25
|
+
/** Renders the outer query and, through it, every composed instance. */
|
|
26
|
+
RenderOuter(request) {
|
|
27
|
+
return this.renderUnit(request, true);
|
|
28
|
+
}
|
|
29
|
+
renderUnit(request, outer) {
|
|
30
|
+
const staticOnly = outer && this.options.StaticArgumentsOnly === true;
|
|
31
|
+
const unit = TemplateUnit.Read(request.SQL, this.options.Dialect, staticOnly);
|
|
32
|
+
const recorder = new UnitRecorder(this, unit, request, this.trustedNames(unit, request));
|
|
33
|
+
let sql;
|
|
34
|
+
let applied = {};
|
|
35
|
+
if (this.rendersAsTemplate(request, unit) && !staticOnly) {
|
|
36
|
+
unit.AssertRenderable(request.Label, request.Definitions, request.Name ?? null);
|
|
37
|
+
const result = this.process(request, unit, unit.TemplateText(), recorder, request.Definitions);
|
|
38
|
+
sql = result.SQL;
|
|
39
|
+
applied = result.Applied;
|
|
40
|
+
}
|
|
41
|
+
else if (unit.References.length > 0) {
|
|
42
|
+
this.evaluateCalls(request, unit, recorder, staticOnly);
|
|
43
|
+
sql = unit.WithNames(recorder.NamesByIndex);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
sql = unit.SQL;
|
|
47
|
+
}
|
|
48
|
+
for (const instance of recorder.Used) {
|
|
49
|
+
if (instance.State === 'Pending')
|
|
50
|
+
this.renderInstance(instance);
|
|
51
|
+
}
|
|
52
|
+
return { SQL: sql, AppliedParameters: applied, HasCompositions: unit.References.length > 0 };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether a unit renders as a template: when it is flagged one, or when its SQL holds template
|
|
56
|
+
* syntax outside SQL comments. Whether SQL is a template is a lexical fact (COMPAT-MAP B12): the
|
|
57
|
+
* stored `UsesTemplate` flag can be stale or unset (a query whose only tokens read `Context` has
|
|
58
|
+
* no parameters to flag it by), and unrendered `{{ }}` text is never valid SQL.
|
|
59
|
+
*/
|
|
60
|
+
rendersAsTemplate(request, unit) {
|
|
61
|
+
return request.RendersTemplate || unit.HasTemplateSyntax();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Evaluates the composition arguments of a query that is not rendered as a template. Static
|
|
65
|
+
* arguments need no values; arguments that read the query's parameters are evaluated with its
|
|
66
|
+
* validated values.
|
|
67
|
+
*/
|
|
68
|
+
evaluateCalls(request, unit, recorder, staticOnly) {
|
|
69
|
+
const allStatic = unit.References.every(r => r.Arguments.every(a => a.IsStatic));
|
|
70
|
+
if (staticOnly && !allStatic) {
|
|
71
|
+
const passed = unit.References.flatMap(r => r.Arguments.filter(a => !a.IsStatic).map(a => `"${a.Name}" of "${r.FullPath}"`));
|
|
72
|
+
throw new Error(`Compositions resolved without rendering take static arguments only, but ${passed.join(', ')} reads a value of the outer query. ` +
|
|
73
|
+
'Run the query through the render pipeline (RenderPipeline.Run) to pass values through.');
|
|
74
|
+
}
|
|
75
|
+
// Static arguments need no validated values: the query's own definitions are left out, but a
|
|
76
|
+
// caller value for a name a composed query protects is still refused.
|
|
77
|
+
const values = allStatic ? { ...request, Definitions: [], SkipUnknownParameterCheck: () => true } : request;
|
|
78
|
+
this.process(values, unit, unit.CallsText(), recorder, values.Definitions);
|
|
79
|
+
}
|
|
80
|
+
process(request, unit, text, recorder, definitions) {
|
|
81
|
+
const result = QueryParameterProcessor.ProcessQueryTemplate({ SQL: text, UsesTemplate: true, Parameters: definitions }, request.Parameters, text, request.SkipUnknownParameterCheck(unit), { ServerParameters: request.ServerParameters, ProtectedNames: this.protectedNames(unit, request.InlineDependencies), Context: this.options.Context }, { DialectKey: this.options.DialectKey, Scope: { [COMPOSITION_RECORDER_NAME]: recorder.Call } });
|
|
82
|
+
if (recorder.Failure)
|
|
83
|
+
throw recorder.Failure;
|
|
84
|
+
if (!result.success)
|
|
85
|
+
throw new Error(result.error);
|
|
86
|
+
return { SQL: result.processedSQL, Applied: (result.appliedParameters ?? {}) };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The names a caller value may not use because they reach a server-set parameter of a query
|
|
90
|
+
* this unit composes: the outer names an argument for it reads, or the parameter's own name
|
|
91
|
+
* when no argument is passed for it. A composition that does not resolve protects nothing (it
|
|
92
|
+
* fails when reached).
|
|
93
|
+
*/
|
|
94
|
+
protectedNames(unit, inline) {
|
|
95
|
+
const names = new Set();
|
|
96
|
+
for (const reference of unit.References) {
|
|
97
|
+
const resolved = CompositionLookup.TryResolve(reference, inline);
|
|
98
|
+
for (const parameter of resolved?.ParameterDefinitions.filter(p => p.IsServerSet) ?? []) {
|
|
99
|
+
const argument = reference.Arguments.find(a => a.Name.toLowerCase() === parameter.Name.toLowerCase());
|
|
100
|
+
if (!argument)
|
|
101
|
+
names.add(parameter.Name);
|
|
102
|
+
else if (!argument.IsStatic)
|
|
103
|
+
argument.ReferencedNames.forEach(n => names.add(n));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return [...names];
|
|
107
|
+
}
|
|
108
|
+
/** The names in a unit's scope whose values only the server sets. Template-assigned names never count. */
|
|
109
|
+
trustedNames(unit, request) {
|
|
110
|
+
const assigned = unit.AssignedNames();
|
|
111
|
+
const trusted = [
|
|
112
|
+
...request.Definitions.filter(d => d.IsServerSet).map(d => d.Name),
|
|
113
|
+
...this.protectedNames(unit, request.InlineDependencies),
|
|
114
|
+
...Object.keys(request.ServerParameters ?? {}),
|
|
115
|
+
];
|
|
116
|
+
return new Set(trusted.filter(n => !assigned.has(n)));
|
|
117
|
+
}
|
|
118
|
+
// ─── Instances ──────────────────────────────────────────
|
|
119
|
+
/**
|
|
120
|
+
* Records the instance a composition reaches with evaluated arguments and returns its CTE
|
|
121
|
+
* name. A repeat (same query, same arguments) returns the existing instance.
|
|
122
|
+
* @throws Error when the query is not found, may not be composed, or leads back to a query being rendered.
|
|
123
|
+
*/
|
|
124
|
+
RecordInstance(reference, args, trusted, request) {
|
|
125
|
+
const resolved = CompositionLookup.Resolve(reference, request.InlineDependencies);
|
|
126
|
+
const id = resolved.Query.ID;
|
|
127
|
+
const key = `${NormalizeUUID(id)}|${StableArguments(args)}|${[...trusted].sort().join(',')}`;
|
|
128
|
+
const existing = this.byKey.get(key);
|
|
129
|
+
if (existing) {
|
|
130
|
+
if (existing.State === 'Rendering')
|
|
131
|
+
throw cycleError([...request.Stack, id], resolved.Query.Name);
|
|
132
|
+
return existing;
|
|
133
|
+
}
|
|
134
|
+
if (request.Stack.some(s => UUIDsEqual(s, id)))
|
|
135
|
+
throw cycleError([...request.Stack, id], resolved.Query.Name);
|
|
136
|
+
CompositionLookup.AssertComposable(resolved, reference, this.options.ContextUser);
|
|
137
|
+
const instance = {
|
|
138
|
+
Key: key, CTEName: this.cteName(resolved.Query.Name, key), Path: reference, Resolved: resolved, Arguments: args,
|
|
139
|
+
TrustedArguments: trusted, Depth: request.Depth + 1, ParentStack: request.Stack, State: 'Pending', RenderedSQL: '',
|
|
140
|
+
};
|
|
141
|
+
this.byKey.set(key, instance);
|
|
142
|
+
return instance;
|
|
143
|
+
}
|
|
144
|
+
renderInstance(instance) {
|
|
145
|
+
if (instance.Depth > MAX_COMPOSITION_DEPTH) {
|
|
146
|
+
throw new Error(`Query composition depth exceeds maximum of ${MAX_COMPOSITION_DEPTH}. This likely indicates an overly deep nesting chain.`);
|
|
147
|
+
}
|
|
148
|
+
instance.State = 'Rendering';
|
|
149
|
+
const query = instance.Resolved.Query;
|
|
150
|
+
const values = this.instanceValues(instance);
|
|
151
|
+
const result = this.renderUnit({
|
|
152
|
+
SQL: query.GetPlatformSQL(this.options.Platform) ?? '',
|
|
153
|
+
RendersTemplate: query.UsesTemplate === true,
|
|
154
|
+
Label: `"${instance.Path.FullPath}"`,
|
|
155
|
+
Name: instance.Path.FullPath,
|
|
156
|
+
Definitions: instance.Resolved.ParameterDefinitions,
|
|
157
|
+
Parameters: values.Caller,
|
|
158
|
+
ServerParameters: values.Server,
|
|
159
|
+
SkipUnknownParameterCheck: () => true,
|
|
160
|
+
InlineDependencies: instance.Resolved.InlineDependencies,
|
|
161
|
+
Depth: instance.Depth,
|
|
162
|
+
Stack: [...instance.ParentStack, query.ID],
|
|
163
|
+
}, false);
|
|
164
|
+
instance.RenderedSQL = result.SQL;
|
|
165
|
+
instance.State = 'Done';
|
|
166
|
+
this.Instances.push(instance);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* An instance's values: arguments from caller values as caller values, the rest as server
|
|
170
|
+
* values, and, for a server-set parameter no argument is passed for, the run's server value of
|
|
171
|
+
* that name.
|
|
172
|
+
*/
|
|
173
|
+
instanceValues(instance) {
|
|
174
|
+
const caller = {};
|
|
175
|
+
const server = {};
|
|
176
|
+
for (const [name, value] of Object.entries(instance.Arguments)) {
|
|
177
|
+
(instance.TrustedArguments.has(name) ? server : caller)[name] = value;
|
|
178
|
+
}
|
|
179
|
+
for (const parameter of instance.Resolved.ParameterDefinitions.filter(p => p.IsServerSet)) {
|
|
180
|
+
const runValue = this.options.ServerParameters?.[parameter.Name];
|
|
181
|
+
if (!(parameter.Name in instance.Arguments) && runValue !== undefined)
|
|
182
|
+
server[parameter.Name] = runValue;
|
|
183
|
+
}
|
|
184
|
+
return { Caller: caller, Server: server };
|
|
185
|
+
}
|
|
186
|
+
cteName(queryName, key) {
|
|
187
|
+
const sanitized = queryName.replace(/[^a-zA-Z0-9_ ]/g, '').replace(/\s+/g, '_').substring(0, 50);
|
|
188
|
+
return this.options.Dialect.QuoteIdentifier(`__cte_${sanitized}_${ShortHash(key)}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The composition recorder of one unit's render: the function the template calls for each
|
|
193
|
+
* composition. It evaluates nothing itself (Nunjucks evaluated the arguments in the template's
|
|
194
|
+
* scope); it maps them to the composed query's parameters, records the instance and returns its
|
|
195
|
+
* CTE name. A failure is kept and rethrown after the render, unchanged.
|
|
196
|
+
*/
|
|
197
|
+
class UnitRecorder {
|
|
198
|
+
constructor(render, unit, request, trustedNames) {
|
|
199
|
+
this.render = render;
|
|
200
|
+
this.unit = unit;
|
|
201
|
+
this.request = request;
|
|
202
|
+
this.trustedNames = trustedNames;
|
|
203
|
+
this.NamesByIndex = [];
|
|
204
|
+
this.Used = new Set();
|
|
205
|
+
this.Failure = null;
|
|
206
|
+
/** Called by the template as `__mjComposition(index, [argument values])`. */
|
|
207
|
+
this.Call = (index, values) => {
|
|
208
|
+
try {
|
|
209
|
+
const reference = this.unit.References[index];
|
|
210
|
+
const resolvedParameters = CompositionLookup.TryResolve(reference, this.request.InlineDependencies)?.ParameterDefinitions ?? [];
|
|
211
|
+
const mapped = mapArguments(reference, values, resolvedParameters, this.trustedNames);
|
|
212
|
+
const instance = this.render.RecordInstance(reference, mapped.Arguments, mapped.Trusted, this.request);
|
|
213
|
+
this.Used.add(instance);
|
|
214
|
+
this.NamesByIndex[index] = instance.CTEName;
|
|
215
|
+
return instance.CTEName;
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
this.Failure ??= error instanceof Error ? error : new Error(String(error));
|
|
219
|
+
throw this.Failure;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Pairs a composition's evaluated argument values with the composed query's parameters (names
|
|
226
|
+
* matched ignoring case, written as the parameter declares them). An argument that evaluated to
|
|
227
|
+
* nothing is absent. A boolean parameter given the dialect's 1/0 gets the boolean back, so its own
|
|
228
|
+
* validation reads it right.
|
|
229
|
+
*/
|
|
230
|
+
function mapArguments(reference, values, parameters, trustedNames) {
|
|
231
|
+
const args = {};
|
|
232
|
+
const trusted = new Set();
|
|
233
|
+
reference.Arguments.forEach((argument, i) => {
|
|
234
|
+
const value = values[i];
|
|
235
|
+
if (value === undefined)
|
|
236
|
+
return;
|
|
237
|
+
const parameter = parameters.find(p => p.Name.toLowerCase() === argument.Name.toLowerCase());
|
|
238
|
+
const name = parameter?.Name ?? argument.Name;
|
|
239
|
+
args[name] = parameter?.Type === 'boolean' && (value === 1 || value === 0) ? value === 1 : value;
|
|
240
|
+
if (argument.IsStatic || argument.ReferencedNames.every(n => trustedNames.has(n)))
|
|
241
|
+
trusted.add(name);
|
|
242
|
+
});
|
|
243
|
+
return { Arguments: args, Trusted: trusted };
|
|
244
|
+
}
|
|
245
|
+
/** The arguments as a stable string: sorted by name, dates as ISO text. */
|
|
246
|
+
export function StableArguments(args) {
|
|
247
|
+
return JSON.stringify(Object.keys(args).sort().map(k => {
|
|
248
|
+
const value = args[k];
|
|
249
|
+
return [k, value instanceof Date ? value.toISOString() : value];
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
/** A short deterministic hash of `input`, base 36. */
|
|
253
|
+
export function ShortHash(input) {
|
|
254
|
+
let hash = 0;
|
|
255
|
+
for (let i = 0; i < input.length; i++) {
|
|
256
|
+
hash = ((hash << 5) - hash) + input.charCodeAt(i);
|
|
257
|
+
hash |= 0;
|
|
258
|
+
}
|
|
259
|
+
return Math.abs(hash).toString(36).substring(0, 6);
|
|
260
|
+
}
|
|
261
|
+
function cycleError(path, name) {
|
|
262
|
+
return new Error(`Circular query dependency detected: ${path.join(' → ')}. Query "${name}" is already being resolved.`);
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=compositionRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositionRender.js","sourceRoot":"","sources":["../../src/composition/compositionRender.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE5E,8FAA8F;AAC9F,MAAM,CA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C,CAAC,CAAC;AACR,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS,CAAC,KAAa;IACnC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,UAAU,CAAC,IAAuB,EAAE,IAAY;IACrD,OAAO,IAAI,KAAK,CAAC,uCAAuC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,8BAA8B,CAAC,CAAC;AAC5H,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DatabasePlatform, QueryDependencySpec, UserInfo } from '@memberjunction/core';
|
|
2
|
+
import type { QueryParameterDefinition } from '@memberjunction/query-processor';
|
|
3
|
+
/**
|
|
4
|
+
* Minimal contract for queries flowing through composition. `MJQueryEntityExtended` satisfies it
|
|
5
|
+
* structurally; an inline dependency of a transient query satisfies it through a plain object.
|
|
6
|
+
*/
|
|
7
|
+
export interface IComposableQuery {
|
|
8
|
+
ID: string;
|
|
9
|
+
Name: string;
|
|
10
|
+
SQL: string | null;
|
|
11
|
+
UsesTemplate: boolean | null;
|
|
12
|
+
Reusable: boolean | null;
|
|
13
|
+
Status: string | null;
|
|
14
|
+
IsApproved: boolean;
|
|
15
|
+
UserCanRun(user: UserInfo, _visited?: Set<string>): {
|
|
16
|
+
canRun: boolean;
|
|
17
|
+
deniedEntities: string[];
|
|
18
|
+
};
|
|
19
|
+
GetPlatformSQL(platform: DatabasePlatform): string;
|
|
20
|
+
}
|
|
21
|
+
/** A composition reference's target, as `{{query:"…"}}` names it. */
|
|
22
|
+
export interface CompositionPath {
|
|
23
|
+
/** The category path and query name joined by `/`, as written. */
|
|
24
|
+
readonly FullPath: string;
|
|
25
|
+
/** The category path as written, `''` when the reference names no category. */
|
|
26
|
+
readonly CategoryPath: string;
|
|
27
|
+
/** The query name. */
|
|
28
|
+
readonly Name: string;
|
|
29
|
+
}
|
|
30
|
+
/** A composition reference resolved to the query it names. */
|
|
31
|
+
export interface ResolvedComposition {
|
|
32
|
+
readonly Query: IComposableQuery;
|
|
33
|
+
/** Whether the query is an inline dependency of a transient query (no governance checks: the caller supplied it). */
|
|
34
|
+
readonly IsInline: boolean;
|
|
35
|
+
/** The query's own parameter definitions. */
|
|
36
|
+
readonly ParameterDefinitions: ReadonlyArray<QueryParameterDefinition>;
|
|
37
|
+
/** The inline dependencies visible inside the query. */
|
|
38
|
+
readonly InlineDependencies: QueryDependencySpec[] | undefined;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=compositionTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositionTypes.d.ts","sourceRoot":"","sources":["../../src/composition/compositionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,cAAc,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAClG,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAAC;CACtD;AAED,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,qHAAqH;IACrH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,oBAAoB,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;IACvE,wDAAwD;IACxD,QAAQ,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,GAAG,SAAS,CAAC;CAClE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositionTypes.js","sourceRoot":"","sources":["../../src/composition/compositionTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ParserDialect } from '@memberjunction/sql-dialect';
|
|
2
|
+
/** Where a quoted tag sits: inside a SQL string literal, or inside a quoted identifier. */
|
|
3
|
+
export type QuotedTagKind = 'StringLiteral' | 'QuotedIdentifier';
|
|
4
|
+
/** One template tag written inside a SQL string literal or a quoted identifier. */
|
|
5
|
+
export interface QuotedTag {
|
|
6
|
+
readonly Kind: QuotedTagKind;
|
|
7
|
+
/** The tag, e.g. `{{ Region }}`. */
|
|
8
|
+
readonly Tag: string;
|
|
9
|
+
/** The parameter the tag reads; `null` when it is not a plain `{{ name }}`. */
|
|
10
|
+
readonly Parameter: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* The whole quoted piece the tag sits in, quotes included: the string literal (`'{{ Region }}'`)
|
|
13
|
+
* or the quoted identifier (`[{{ Col }}]`, `"{{ Col }}"`, `` `{{ Col }}` ``).
|
|
14
|
+
*/
|
|
15
|
+
readonly Quoted: string;
|
|
16
|
+
readonly Line: number;
|
|
17
|
+
readonly Column: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether a diagnostic reports a template tag inside a SQL string literal
|
|
21
|
+
* (`MJQ_TAG_IN_STRING_LITERAL`) or a quoted identifier (`MJQ_TAG_IN_QUOTED_IDENTIFIER`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function IsQuotedTagCode(code: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a tag written inside a SQL string literal or a quoted identifier pastes a value there: a
|
|
26
|
+
* `{{ … }}` value tag. A composition tag there stays literal text, and a `{% %}` block or `{# #}`
|
|
27
|
+
* comment pastes no value, so a run does not stop for those (a save still refuses them).
|
|
28
|
+
*/
|
|
29
|
+
export declare function IsQuotedValueTag(tagText: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Why a query whose SQL writes a value tag inside a SQL string literal (`'{{ Region }}'`) or a
|
|
32
|
+
* quoted identifier (`[{{ Col }}]`) may not run, written for the people who own the query: which
|
|
33
|
+
* tags, where, why each kind is refused, the exact fix, and how to find every query with the same
|
|
34
|
+
* problem. One message covers both kinds when the query has both.
|
|
35
|
+
*
|
|
36
|
+
* The positions are read from `sql` as stored (comments included), so they match what an editor
|
|
37
|
+
* shows. Returns `null` when `sql` has no such tag.
|
|
38
|
+
*
|
|
39
|
+
* @param queryName - Names the query; a request that is not a saved query passes `null`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function QuotedTagRefusalMessage(queryName: string | null, sql: string, dialect: ParserDialect): string | null;
|
|
42
|
+
/** The value tags `sql` writes inside SQL string literals or quoted identifiers, in source order. */
|
|
43
|
+
export declare function FindQuotedTags(sql: string, dialect: ParserDialect): QuotedTag[];
|
|
44
|
+
//# sourceMappingURL=quotedTagRefusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotedTagRefusal.d.ts","sourceRoot":"","sources":["../../src/composition/quotedTagRefusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAKjE,2FAA2F;AAC3F,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,kBAAkB,CAAC;AAEjE,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,oCAAoC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B;AAiBD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAapH;AAmDD,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,SAAS,EAAE,CAK/E"}
|