@true-sight/model-schema 1.0.1 → 1.2.0
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/dsl/compile/compile-explore.js +48 -0
- package/dist/dsl/compile/compile-view.js +2 -0
- package/dist/dsl/decorators/always-include.decorator.d.ts +2 -0
- package/dist/dsl/decorators/always-include.decorator.js +9 -0
- package/dist/dsl/decorators/index.d.ts +1 -0
- package/dist/dsl/decorators/index.js +3 -1
- package/dist/dsl/errors/compile-errors.d.ts +3 -0
- package/dist/dsl/errors/compile-errors.js +8 -1
- package/dist/dsl/expr/define-always-include.d.ts +6 -0
- package/dist/dsl/expr/define-always-include.js +6 -0
- package/dist/dsl/expr/field.d.ts +11 -8
- package/dist/dsl/expr/index.d.ts +2 -0
- package/dist/dsl/expr/index.js +3 -1
- package/dist/dsl/registry/explore-registry.d.ts +3 -0
- package/dist/dsl/registry/explore-registry.js +9 -0
- package/dist/dsl/registry/view-registry.d.ts +2 -0
- package/dist/dsl/types/join-scope.types.d.ts +2 -0
- package/dist/dsl/types/view-proxy.types.d.ts +4 -3
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -1
- package/dist/types/manifest.types.d.ts +3 -0
- package/dist/validate/semantic-rules.js +33 -0
- package/manifest.schema.json +8 -2
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileExplore = compileExplore;
|
|
4
4
|
require("reflect-metadata");
|
|
5
|
+
const manifest_expr_types_js_1 = require("../../types/manifest-expr.types.js");
|
|
5
6
|
const compile_errors_js_1 = require("../errors/compile-errors.js");
|
|
7
|
+
const field_js_1 = require("../expr/field.js");
|
|
6
8
|
const explore_registry_js_1 = require("../registry/explore-registry.js");
|
|
7
9
|
const view_registry_js_1 = require("../registry/view-registry.js");
|
|
8
10
|
const compile_view_js_1 = require("./compile-view.js");
|
|
@@ -50,11 +52,57 @@ function compileExplore(ExploreClass) {
|
|
|
50
52
|
scopedViewNames.push(joinViewMeta.name);
|
|
51
53
|
}
|
|
52
54
|
const views = [...viewClasses.values()].map((ViewClass) => (0, compile_view_js_1.compileView)(ViewClass));
|
|
55
|
+
const alwaysInclude = resolveAlwaysInclude(ExploreClass, exploreMeta.name, views, scopedViewNames);
|
|
53
56
|
return {
|
|
54
57
|
name: exploreMeta.name,
|
|
55
58
|
label: exploreMeta.label,
|
|
56
59
|
from: fromViewMeta.name,
|
|
57
60
|
joins,
|
|
58
61
|
views,
|
|
62
|
+
...(alwaysInclude ? { alwaysInclude } : {}),
|
|
59
63
|
};
|
|
60
64
|
}
|
|
65
|
+
function resolveAlwaysInclude(ExploreClass, exploreName, views, scopedViewNames) {
|
|
66
|
+
const callback = (0, explore_registry_js_1.getAlwaysInclude)(ExploreClass);
|
|
67
|
+
if (!callback) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const scope = (0, join_helpers_js_1.createJoinScope)(scopedViewNames);
|
|
71
|
+
const proxies = scopedViewNames.map((name) => scope[name]);
|
|
72
|
+
const raw = callback(...proxies);
|
|
73
|
+
if (!Array.isArray(raw)) {
|
|
74
|
+
throw new compile_errors_js_1.AlwaysIncludeError(exploreName, 'callback must return Field[]');
|
|
75
|
+
}
|
|
76
|
+
const visibility = new Map();
|
|
77
|
+
for (const view of views) {
|
|
78
|
+
for (const dimension of view.dimensions) {
|
|
79
|
+
visibility.set(`${view.name}.${dimension.name}`, dimension.visible !== false);
|
|
80
|
+
}
|
|
81
|
+
for (const measurement of view.measurements) {
|
|
82
|
+
visibility.set(`${view.name}.${measurement.name}`, measurement.visible !== false);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const seen = new Set();
|
|
86
|
+
const names = [];
|
|
87
|
+
for (const item of raw) {
|
|
88
|
+
if (!(item instanceof field_js_1.Field)) {
|
|
89
|
+
throw new compile_errors_js_1.AlwaysIncludeError(exploreName, 'callback must return Field[]');
|
|
90
|
+
}
|
|
91
|
+
const ref = item.ref;
|
|
92
|
+
if (!(0, manifest_expr_types_js_1.isRefString)(ref)) {
|
|
93
|
+
throw new compile_errors_js_1.AlwaysIncludeError(exploreName, `invalid name "${String(ref)}"`);
|
|
94
|
+
}
|
|
95
|
+
if (seen.has(ref)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
seen.add(ref);
|
|
99
|
+
if (!visibility.has(ref)) {
|
|
100
|
+
throw new compile_errors_js_1.AlwaysIncludeError(exploreName, `unknown field '${ref}'`);
|
|
101
|
+
}
|
|
102
|
+
if (visibility.get(ref) === false) {
|
|
103
|
+
throw new compile_errors_js_1.AlwaysIncludeError(exploreName, `field '${ref}' is not visible and cannot be alwaysInclude`);
|
|
104
|
+
}
|
|
105
|
+
names.push(ref);
|
|
106
|
+
}
|
|
107
|
+
return names.length > 0 ? names : undefined;
|
|
108
|
+
}
|
|
@@ -18,6 +18,7 @@ function compileView(ViewClass) {
|
|
|
18
18
|
label: entry.options.label,
|
|
19
19
|
type: entry.options.type,
|
|
20
20
|
expression: `${viewMeta.name}.${entry.propertyKey}`,
|
|
21
|
+
...(entry.options.visible === false ? { visible: false } : {}),
|
|
21
22
|
}));
|
|
22
23
|
const measurements = measureEntries.map((entry) => {
|
|
23
24
|
const raw = instance[entry.propertyKey];
|
|
@@ -28,6 +29,7 @@ function compileView(ViewClass) {
|
|
|
28
29
|
label: entry.options.label,
|
|
29
30
|
type: entry.options.type,
|
|
30
31
|
expression,
|
|
32
|
+
...(entry.options.visible === false ? { visible: false } : {}),
|
|
31
33
|
};
|
|
32
34
|
});
|
|
33
35
|
return {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AlwaysInclude = AlwaysInclude;
|
|
4
|
+
const explore_registry_js_1 = require("../registry/explore-registry.js");
|
|
5
|
+
function AlwaysInclude(callback) {
|
|
6
|
+
return (target) => {
|
|
7
|
+
(0, explore_registry_js_1.registerAlwaysInclude)(target, callback);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -4,4 +4,5 @@ export { Measure } from './measure.decorator.js';
|
|
|
4
4
|
export { Explore } from './explore.decorator.js';
|
|
5
5
|
export { Join } from './join.decorator.js';
|
|
6
6
|
export { Model } from './model.decorator.js';
|
|
7
|
+
export { AlwaysInclude } from './always-include.decorator.js';
|
|
7
8
|
export { joinScope, isJoinScopeTagged } from '../expr/join-scope.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isJoinScopeTagged = exports.joinScope = exports.Model = exports.Join = exports.Explore = exports.Measure = exports.Dimension = exports.View = void 0;
|
|
3
|
+
exports.isJoinScopeTagged = exports.joinScope = exports.AlwaysInclude = exports.Model = exports.Join = exports.Explore = exports.Measure = exports.Dimension = exports.View = void 0;
|
|
4
4
|
var view_decorator_js_1 = require("./view.decorator.js");
|
|
5
5
|
Object.defineProperty(exports, "View", { enumerable: true, get: function () { return view_decorator_js_1.View; } });
|
|
6
6
|
var dimension_decorator_js_1 = require("./dimension.decorator.js");
|
|
@@ -13,6 +13,8 @@ var join_decorator_js_1 = require("./join.decorator.js");
|
|
|
13
13
|
Object.defineProperty(exports, "Join", { enumerable: true, get: function () { return join_decorator_js_1.Join; } });
|
|
14
14
|
var model_decorator_js_1 = require("./model.decorator.js");
|
|
15
15
|
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return model_decorator_js_1.Model; } });
|
|
16
|
+
var always_include_decorator_js_1 = require("./always-include.decorator.js");
|
|
17
|
+
Object.defineProperty(exports, "AlwaysInclude", { enumerable: true, get: function () { return always_include_decorator_js_1.AlwaysInclude; } });
|
|
16
18
|
var join_scope_js_1 = require("../expr/join-scope.js");
|
|
17
19
|
Object.defineProperty(exports, "joinScope", { enumerable: true, get: function () { return join_scope_js_1.joinScope; } });
|
|
18
20
|
Object.defineProperty(exports, "isJoinScopeTagged", { enumerable: true, get: function () { return join_scope_js_1.isJoinScopeTagged; } });
|
|
@@ -10,3 +10,6 @@ export declare class JoinScopeError extends Error {
|
|
|
10
10
|
export declare class DuplicateNameError extends Error {
|
|
11
11
|
constructor(kind: string, name: string, context?: string);
|
|
12
12
|
}
|
|
13
|
+
export declare class AlwaysIncludeError extends Error {
|
|
14
|
+
constructor(exploreName: string, reason: string);
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DuplicateNameError = exports.JoinScopeError = exports.InvalidMeasureError = exports.MissingMetadataError = void 0;
|
|
3
|
+
exports.AlwaysIncludeError = exports.DuplicateNameError = exports.JoinScopeError = exports.InvalidMeasureError = exports.MissingMetadataError = void 0;
|
|
4
4
|
class MissingMetadataError extends Error {
|
|
5
5
|
constructor(kind, className) {
|
|
6
6
|
super(`${kind} metadata missing on ${className}`);
|
|
@@ -31,3 +31,10 @@ class DuplicateNameError extends Error {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.DuplicateNameError = DuplicateNameError;
|
|
34
|
+
class AlwaysIncludeError extends Error {
|
|
35
|
+
constructor(exploreName, reason) {
|
|
36
|
+
super(`Always include on explore '${exploreName}': ${reason}`);
|
|
37
|
+
this.name = 'AlwaysIncludeError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.AlwaysIncludeError = AlwaysIncludeError;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AlwaysIncludeCallback } from '../types/join-scope.types.js';
|
|
2
|
+
import type { StrictViewProxy, ViewConstructor } from '../types/view-proxy.types.js';
|
|
3
|
+
import type { VisibleField } from './field.js';
|
|
4
|
+
export declare function defineAlwaysInclude<const Vs extends readonly ViewConstructor[]>(_views: Vs, fn: (...proxies: {
|
|
5
|
+
[I in keyof Vs]: Vs[I] extends ViewConstructor ? StrictViewProxy<Vs[I]> : never;
|
|
6
|
+
}) => VisibleField[]): AlwaysIncludeCallback;
|
package/dist/dsl/expr/field.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { ManifestExpr, RefString } from '../../types/manifest-expr.types.js';
|
|
2
|
-
export declare class Field<T> {
|
|
2
|
+
export declare class Field<T, Visible extends boolean = true> {
|
|
3
3
|
readonly ref: RefString;
|
|
4
|
+
readonly __visible?: Visible;
|
|
4
5
|
constructor(viewName: string, fieldName: string);
|
|
5
|
-
eq(other: Field<unknown> | ManifestExpr): ManifestExpr;
|
|
6
|
-
neq(other: Field<unknown> | ManifestExpr): ManifestExpr;
|
|
7
|
-
gt(other: Field<unknown> | ManifestExpr): ManifestExpr;
|
|
8
|
-
gte(other: Field<unknown> | ManifestExpr): ManifestExpr;
|
|
9
|
-
lt(other: Field<unknown> | ManifestExpr): ManifestExpr;
|
|
10
|
-
lte(other: Field<unknown> | ManifestExpr): ManifestExpr;
|
|
6
|
+
eq(other: Field<unknown, boolean> | ManifestExpr): ManifestExpr;
|
|
7
|
+
neq(other: Field<unknown, boolean> | ManifestExpr): ManifestExpr;
|
|
8
|
+
gt(other: Field<unknown, boolean> | ManifestExpr): ManifestExpr;
|
|
9
|
+
gte(other: Field<unknown, boolean> | ManifestExpr): ManifestExpr;
|
|
10
|
+
lt(other: Field<unknown, boolean> | ManifestExpr): ManifestExpr;
|
|
11
|
+
lte(other: Field<unknown, boolean> | ManifestExpr): ManifestExpr;
|
|
11
12
|
and(other: ManifestExpr): ManifestExpr;
|
|
12
13
|
or(other: ManifestExpr): ManifestExpr;
|
|
13
14
|
not(): ManifestExpr;
|
|
14
15
|
}
|
|
15
|
-
export
|
|
16
|
+
export type VisibleField<T = unknown> = Field<T, true>;
|
|
17
|
+
export type HiddenField<T = unknown> = Field<T, false>;
|
|
18
|
+
export declare function field<T, Visible extends boolean = true>(viewName: string, fieldName: string): Field<T, Visible>;
|
package/dist/dsl/expr/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Field, field } from './field.js';
|
|
2
|
+
export type { VisibleField, HiddenField } from './field.js';
|
|
3
|
+
export { defineAlwaysInclude } from './define-always-include.js';
|
|
2
4
|
export { count, max, min, sum } from './aggregates.js';
|
|
3
5
|
export { raw } from './raw.js';
|
|
4
6
|
export { joinScope, isJoinScopeTagged } from './join-scope.js';
|
package/dist/dsl/expr/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isJoinScopeTagged = exports.joinScope = exports.raw = exports.sum = exports.min = exports.max = exports.count = exports.field = exports.Field = void 0;
|
|
3
|
+
exports.isJoinScopeTagged = exports.joinScope = exports.raw = exports.sum = exports.min = exports.max = exports.count = exports.defineAlwaysInclude = exports.field = exports.Field = void 0;
|
|
4
4
|
var field_js_1 = require("./field.js");
|
|
5
5
|
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return field_js_1.Field; } });
|
|
6
6
|
Object.defineProperty(exports, "field", { enumerable: true, get: function () { return field_js_1.field; } });
|
|
7
|
+
var define_always_include_js_1 = require("./define-always-include.js");
|
|
8
|
+
Object.defineProperty(exports, "defineAlwaysInclude", { enumerable: true, get: function () { return define_always_include_js_1.defineAlwaysInclude; } });
|
|
7
9
|
var aggregates_js_1 = require("./aggregates.js");
|
|
8
10
|
Object.defineProperty(exports, "count", { enumerable: true, get: function () { return aggregates_js_1.count; } });
|
|
9
11
|
Object.defineProperty(exports, "max", { enumerable: true, get: function () { return aggregates_js_1.max; } });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ManifestExpr } from '../../types/manifest-expr.types.js';
|
|
2
2
|
import type { JoinRelationship, JoinType } from '../../types/manifest.types.js';
|
|
3
|
+
import type { AlwaysIncludeCallback } from '../types/join-scope.types.js';
|
|
3
4
|
export type ViewConstructor = new (...args: unknown[]) => object;
|
|
4
5
|
export type ExploreOptions = {
|
|
5
6
|
name: string;
|
|
@@ -20,3 +21,5 @@ export declare function registerExplore(ctor: object, options: ExploreOptions):
|
|
|
20
21
|
export declare function getExploreMeta(ctor: object): ExploreOptions | undefined;
|
|
21
22
|
export declare function addJoin(prototype: object, entry: JoinEntry): void;
|
|
22
23
|
export declare function getJoins(prototype: object): JoinEntry[];
|
|
24
|
+
export declare function registerAlwaysInclude(ctor: object, callback: AlwaysIncludeCallback): void;
|
|
25
|
+
export declare function getAlwaysInclude(ctor: object): AlwaysIncludeCallback | undefined;
|
|
@@ -4,8 +4,11 @@ exports.registerExplore = registerExplore;
|
|
|
4
4
|
exports.getExploreMeta = getExploreMeta;
|
|
5
5
|
exports.addJoin = addJoin;
|
|
6
6
|
exports.getJoins = getJoins;
|
|
7
|
+
exports.registerAlwaysInclude = registerAlwaysInclude;
|
|
8
|
+
exports.getAlwaysInclude = getAlwaysInclude;
|
|
7
9
|
const exploreMeta = new WeakMap();
|
|
8
10
|
const joinMeta = new WeakMap();
|
|
11
|
+
const alwaysIncludeMeta = new WeakMap();
|
|
9
12
|
function registerExplore(ctor, options) {
|
|
10
13
|
exploreMeta.set(ctor, options);
|
|
11
14
|
}
|
|
@@ -20,3 +23,9 @@ function addJoin(prototype, entry) {
|
|
|
20
23
|
function getJoins(prototype) {
|
|
21
24
|
return joinMeta.get(prototype) ?? [];
|
|
22
25
|
}
|
|
26
|
+
function registerAlwaysInclude(ctor, callback) {
|
|
27
|
+
alwaysIncludeMeta.set(ctor, callback);
|
|
28
|
+
}
|
|
29
|
+
function getAlwaysInclude(ctor) {
|
|
30
|
+
return alwaysIncludeMeta.get(ctor);
|
|
31
|
+
}
|
|
@@ -8,11 +8,13 @@ export type DimensionOptions = {
|
|
|
8
8
|
groupLabel: string;
|
|
9
9
|
label: string;
|
|
10
10
|
type: DimensionType;
|
|
11
|
+
visible?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export type MeasureOptions = {
|
|
13
14
|
groupLabel: string;
|
|
14
15
|
label: string;
|
|
15
16
|
type: AggregateType;
|
|
17
|
+
visible?: boolean;
|
|
16
18
|
};
|
|
17
19
|
export type DimensionEntry = {
|
|
18
20
|
propertyKey: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ManifestExpr } from '../../types/manifest-expr.types.js';
|
|
2
|
+
import type { Field } from '../expr/field.js';
|
|
2
3
|
import type { JoinScopeProxy } from './view-name-map.types.js';
|
|
3
4
|
export type JoinScopeCallback = (...proxies: JoinScopeProxy[]) => ManifestExpr;
|
|
5
|
+
export type AlwaysIncludeCallback = (...proxies: JoinScopeProxy[]) => Field<unknown>[];
|
|
4
6
|
export type JoinScopeSqlOn = (scope: Record<string, unknown>) => ManifestExpr;
|
|
5
7
|
export interface JoinScopeTagged {
|
|
6
8
|
readonly __joinScopeBrand: symbol;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Field } from '../expr/field.js';
|
|
2
2
|
export type ViewConstructor = new (...args: unknown[]) => object;
|
|
3
3
|
export type DimensionKeys<V extends ViewConstructor> = {
|
|
4
|
-
[K in keyof InstanceType<V>]: InstanceType<V>[K] extends Field<infer
|
|
4
|
+
[K in keyof InstanceType<V>]: InstanceType<V>[K] extends Field<infer _T, infer _V> ? K : never;
|
|
5
5
|
}[keyof InstanceType<V>];
|
|
6
|
-
export type
|
|
6
|
+
export type StrictViewProxy<V extends ViewConstructor> = {
|
|
7
7
|
[K in DimensionKeys<V>]: InstanceType<V>[K];
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export type ViewProxy<V extends ViewConstructor> = StrictViewProxy<V> & {
|
|
9
10
|
[key: string]: Field<unknown>;
|
|
10
11
|
};
|
|
11
12
|
export interface ViewBrand {
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ export { isJoinPair, isManifestExprObject, isRefString, REF_STRING_PATTERN, } fr
|
|
|
4
4
|
export type { AggregateType, DimensionDefinition, DimensionType, Explore as ManifestExplore, ExploreJoin, JoinRelationship, JoinType, MeasurementDefinition, Model as ManifestModel, ModelManifest, ViewDefinition, } from './types/manifest.types.js';
|
|
5
5
|
export type { ManifestValidationError, ValidationResult, } from './validate/validation-result.js';
|
|
6
6
|
export { validateManifest } from './validate/validate-manifest.js';
|
|
7
|
-
export { Field, field, count, sum, min, max, raw, joinScope, isJoinScopeTagged } from './dsl/expr/index.js';
|
|
8
|
-
export type {
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
7
|
+
export { Field, field, count, sum, min, max, raw, joinScope, isJoinScopeTagged, defineAlwaysInclude } from './dsl/expr/index.js';
|
|
8
|
+
export type { VisibleField, HiddenField } from './dsl/expr/index.js';
|
|
9
|
+
export type { JoinScopeCallback, JoinScopeSqlOn, JoinScopeTagged, AlwaysIncludeCallback } from './dsl/types/join-scope.types.js';
|
|
10
|
+
export { View, Dimension, Measure, Explore, Join, Model, AlwaysInclude } from './dsl/decorators/index.js';
|
|
11
|
+
export type { ViewProxy, ViewConstructor, StrictViewProxy } from './dsl/types/view-proxy.types.js';
|
|
11
12
|
export type { ViewNameMap, ViewProxyByName, } from './dsl/types/view-name-map.types.js';
|
|
12
13
|
export { compileView, compileExplore, compileModel, compileModels } from './dsl/compile/index.js';
|
|
13
|
-
export { MissingMetadataError, InvalidMeasureError, JoinScopeError, DuplicateNameError, } from './dsl/errors/compile-errors.js';
|
|
14
|
+
export { MissingMetadataError, InvalidMeasureError, JoinScopeError, DuplicateNameError, AlwaysIncludeError, } from './dsl/errors/compile-errors.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DuplicateNameError = exports.JoinScopeError = exports.InvalidMeasureError = exports.MissingMetadataError = exports.compileModels = exports.compileModel = exports.compileExplore = exports.compileView = exports.Model = exports.Join = exports.Explore = exports.Measure = exports.Dimension = exports.View = exports.isJoinScopeTagged = exports.joinScope = exports.raw = exports.max = exports.min = exports.sum = exports.count = exports.field = exports.Field = exports.validateManifest = exports.REF_STRING_PATTERN = exports.isRefString = exports.isManifestExprObject = exports.isJoinPair = exports.SCHEMA_VERSION = void 0;
|
|
3
|
+
exports.AlwaysIncludeError = exports.DuplicateNameError = exports.JoinScopeError = exports.InvalidMeasureError = exports.MissingMetadataError = exports.compileModels = exports.compileModel = exports.compileExplore = exports.compileView = exports.AlwaysInclude = exports.Model = exports.Join = exports.Explore = exports.Measure = exports.Dimension = exports.View = exports.defineAlwaysInclude = exports.isJoinScopeTagged = exports.joinScope = exports.raw = exports.max = exports.min = exports.sum = exports.count = exports.field = exports.Field = exports.validateManifest = exports.REF_STRING_PATTERN = exports.isRefString = exports.isManifestExprObject = exports.isJoinPair = exports.SCHEMA_VERSION = void 0;
|
|
4
4
|
var constants_js_1 = require("./constants.js");
|
|
5
5
|
Object.defineProperty(exports, "SCHEMA_VERSION", { enumerable: true, get: function () { return constants_js_1.SCHEMA_VERSION; } });
|
|
6
6
|
var manifest_expr_types_js_1 = require("./types/manifest-expr.types.js");
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "max", { enumerable: true, get: function () { ret
|
|
|
20
20
|
Object.defineProperty(exports, "raw", { enumerable: true, get: function () { return index_js_1.raw; } });
|
|
21
21
|
Object.defineProperty(exports, "joinScope", { enumerable: true, get: function () { return index_js_1.joinScope; } });
|
|
22
22
|
Object.defineProperty(exports, "isJoinScopeTagged", { enumerable: true, get: function () { return index_js_1.isJoinScopeTagged; } });
|
|
23
|
+
Object.defineProperty(exports, "defineAlwaysInclude", { enumerable: true, get: function () { return index_js_1.defineAlwaysInclude; } });
|
|
23
24
|
var index_js_2 = require("./dsl/decorators/index.js");
|
|
24
25
|
Object.defineProperty(exports, "View", { enumerable: true, get: function () { return index_js_2.View; } });
|
|
25
26
|
Object.defineProperty(exports, "Dimension", { enumerable: true, get: function () { return index_js_2.Dimension; } });
|
|
@@ -27,6 +28,7 @@ Object.defineProperty(exports, "Measure", { enumerable: true, get: function () {
|
|
|
27
28
|
Object.defineProperty(exports, "Explore", { enumerable: true, get: function () { return index_js_2.Explore; } });
|
|
28
29
|
Object.defineProperty(exports, "Join", { enumerable: true, get: function () { return index_js_2.Join; } });
|
|
29
30
|
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return index_js_2.Model; } });
|
|
31
|
+
Object.defineProperty(exports, "AlwaysInclude", { enumerable: true, get: function () { return index_js_2.AlwaysInclude; } });
|
|
30
32
|
var index_js_3 = require("./dsl/compile/index.js");
|
|
31
33
|
Object.defineProperty(exports, "compileView", { enumerable: true, get: function () { return index_js_3.compileView; } });
|
|
32
34
|
Object.defineProperty(exports, "compileExplore", { enumerable: true, get: function () { return index_js_3.compileExplore; } });
|
|
@@ -37,3 +39,4 @@ Object.defineProperty(exports, "MissingMetadataError", { enumerable: true, get:
|
|
|
37
39
|
Object.defineProperty(exports, "InvalidMeasureError", { enumerable: true, get: function () { return compile_errors_js_1.InvalidMeasureError; } });
|
|
38
40
|
Object.defineProperty(exports, "JoinScopeError", { enumerable: true, get: function () { return compile_errors_js_1.JoinScopeError; } });
|
|
39
41
|
Object.defineProperty(exports, "DuplicateNameError", { enumerable: true, get: function () { return compile_errors_js_1.DuplicateNameError; } });
|
|
42
|
+
Object.defineProperty(exports, "AlwaysIncludeError", { enumerable: true, get: function () { return compile_errors_js_1.AlwaysIncludeError; } });
|
|
@@ -16,6 +16,7 @@ export interface DimensionDefinition {
|
|
|
16
16
|
label: string;
|
|
17
17
|
type: DimensionType;
|
|
18
18
|
expression: ManifestExpr;
|
|
19
|
+
visible?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export interface MeasurementDefinition {
|
|
21
22
|
groupLabel: string;
|
|
@@ -23,6 +24,7 @@ export interface MeasurementDefinition {
|
|
|
23
24
|
label: string;
|
|
24
25
|
type: AggregateType;
|
|
25
26
|
expression: ManifestExpr;
|
|
27
|
+
visible?: boolean;
|
|
26
28
|
}
|
|
27
29
|
export interface ViewDefinition {
|
|
28
30
|
name: string;
|
|
@@ -39,6 +41,7 @@ export interface Explore {
|
|
|
39
41
|
from: string;
|
|
40
42
|
joins: ExploreJoin[];
|
|
41
43
|
views: ViewDefinition[];
|
|
44
|
+
alwaysInclude?: string[];
|
|
42
45
|
}
|
|
43
46
|
export interface Model {
|
|
44
47
|
name: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.collectSemanticErrors = collectSemanticErrors;
|
|
4
|
+
const manifest_expr_types_js_1 = require("../types/manifest-expr.types.js");
|
|
4
5
|
const expr_semantic_js_1 = require("./expr-semantic.js");
|
|
5
6
|
function duplicateNameErrors(names, pathPrefix, entityLabel) {
|
|
6
7
|
const seen = new Map();
|
|
@@ -43,6 +44,38 @@ function collectSemanticErrors(manifest) {
|
|
|
43
44
|
message: `from view "${explore.from}" is not in explore views`,
|
|
44
45
|
});
|
|
45
46
|
}
|
|
47
|
+
const qualifiedFields = new Map();
|
|
48
|
+
for (const view of explore.views) {
|
|
49
|
+
for (const dimension of view.dimensions) {
|
|
50
|
+
qualifiedFields.set(`${view.name}.${dimension.name}`, dimension.visible !== false);
|
|
51
|
+
}
|
|
52
|
+
for (const measurement of view.measurements) {
|
|
53
|
+
qualifiedFields.set(`${view.name}.${measurement.name}`, measurement.visible !== false);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
(explore.alwaysInclude ?? []).forEach((name, index) => {
|
|
57
|
+
const path = `${explorePath}.alwaysInclude[${index}]`;
|
|
58
|
+
if (!(0, manifest_expr_types_js_1.isRefString)(name)) {
|
|
59
|
+
errors.push({
|
|
60
|
+
path,
|
|
61
|
+
message: `alwaysInclude name "${String(name)}" is not a view.field ref`,
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!qualifiedFields.has(name)) {
|
|
66
|
+
errors.push({
|
|
67
|
+
path,
|
|
68
|
+
message: `alwaysInclude name "${name}" is not a dimension or measurement on this explore`,
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (qualifiedFields.get(name) === false) {
|
|
73
|
+
errors.push({
|
|
74
|
+
path,
|
|
75
|
+
message: `alwaysInclude name "${name}" is not visible`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
46
79
|
explore.joins.forEach((join, joinIndex) => {
|
|
47
80
|
if (!viewNames.has(join.fromView)) {
|
|
48
81
|
errors.push({
|
package/manifest.schema.json
CHANGED
|
@@ -119,7 +119,8 @@
|
|
|
119
119
|
"name": { "type": "string", "minLength": 1 },
|
|
120
120
|
"label": { "type": "string" },
|
|
121
121
|
"type": { "$ref": "#/definitions/DimensionType" },
|
|
122
|
-
"expression": { "$ref": "#/definitions/ManifestExpr" }
|
|
122
|
+
"expression": { "$ref": "#/definitions/ManifestExpr" },
|
|
123
|
+
"visible": { "type": "boolean" }
|
|
123
124
|
}
|
|
124
125
|
},
|
|
125
126
|
"MeasurementDefinition": {
|
|
@@ -131,7 +132,8 @@
|
|
|
131
132
|
"name": { "type": "string", "minLength": 1 },
|
|
132
133
|
"label": { "type": "string" },
|
|
133
134
|
"type": { "$ref": "#/definitions/AggregateType" },
|
|
134
|
-
"expression": { "$ref": "#/definitions/ManifestExpr" }
|
|
135
|
+
"expression": { "$ref": "#/definitions/ManifestExpr" },
|
|
136
|
+
"visible": { "type": "boolean" }
|
|
135
137
|
}
|
|
136
138
|
},
|
|
137
139
|
"ViewDefinition": {
|
|
@@ -186,6 +188,10 @@
|
|
|
186
188
|
"views": {
|
|
187
189
|
"type": "array",
|
|
188
190
|
"items": { "$ref": "#/definitions/ViewDefinition" }
|
|
191
|
+
},
|
|
192
|
+
"alwaysInclude": {
|
|
193
|
+
"type": "array",
|
|
194
|
+
"items": { "$ref": "#/definitions/RefString" }
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
197
|
},
|