@true-sight/model-schema 1.0.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/constants.d.ts +1 -0
- package/dist/constants.js +4 -0
- package/dist/dsl/compile/compile-explore.d.ts +4 -0
- package/dist/dsl/compile/compile-explore.js +60 -0
- package/dist/dsl/compile/compile-model.d.ts +4 -0
- package/dist/dsl/compile/compile-model.js +39 -0
- package/dist/dsl/compile/compile-view.d.ts +2 -0
- package/dist/dsl/compile/compile-view.js +56 -0
- package/dist/dsl/compile/index.d.ts +3 -0
- package/dist/dsl/compile/index.js +10 -0
- package/dist/dsl/compile/join-helpers.d.ts +5 -0
- package/dist/dsl/compile/join-helpers.js +88 -0
- package/dist/dsl/decorators/dimension.decorator.d.ts +2 -0
- package/dist/dsl/decorators/dimension.decorator.js +12 -0
- package/dist/dsl/decorators/explore.decorator.d.ts +2 -0
- package/dist/dsl/decorators/explore.decorator.js +9 -0
- package/dist/dsl/decorators/index.d.ts +7 -0
- package/dist/dsl/decorators/index.js +18 -0
- package/dist/dsl/decorators/join.decorator.d.ts +2 -0
- package/dist/dsl/decorators/join.decorator.js +12 -0
- package/dist/dsl/decorators/measure.decorator.d.ts +2 -0
- package/dist/dsl/decorators/measure.decorator.js +12 -0
- package/dist/dsl/decorators/model.decorator.d.ts +2 -0
- package/dist/dsl/decorators/model.decorator.js +9 -0
- package/dist/dsl/decorators/view.decorator.d.ts +4 -0
- package/dist/dsl/decorators/view.decorator.js +20 -0
- package/dist/dsl/errors/compile-errors.d.ts +12 -0
- package/dist/dsl/errors/compile-errors.js +33 -0
- package/dist/dsl/expr/aggregates.d.ts +6 -0
- package/dist/dsl/expr/aggregates.js +21 -0
- package/dist/dsl/expr/field.d.ts +15 -0
- package/dist/dsl/expr/field.js +44 -0
- package/dist/dsl/expr/index.d.ts +4 -0
- package/dist/dsl/expr/index.js +16 -0
- package/dist/dsl/expr/join-scope.d.ts +5 -0
- package/dist/dsl/expr/join-scope.js +23 -0
- package/dist/dsl/expr/raw.d.ts +2 -0
- package/dist/dsl/expr/raw.js +6 -0
- package/dist/dsl/registry/explore-registry.d.ts +22 -0
- package/dist/dsl/registry/explore-registry.js +22 -0
- package/dist/dsl/registry/model-registry.d.ts +9 -0
- package/dist/dsl/registry/model-registry.js +11 -0
- package/dist/dsl/registry/view-registry.d.ts +32 -0
- package/dist/dsl/registry/view-registry.js +42 -0
- package/dist/dsl/types/join-scope.types.d.ts +9 -0
- package/dist/dsl/types/join-scope.types.js +8 -0
- package/dist/dsl/types/view-name-map.types.d.ts +13 -0
- package/dist/dsl/types/view-name-map.types.js +2 -0
- package/dist/dsl/types/view-proxy.types.d.ts +13 -0
- package/dist/dsl/types/view-proxy.types.js +2 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +39 -0
- package/dist/types/manifest-expr.types.d.ts +37 -0
- package/dist/types/manifest-expr.types.js +26 -0
- package/dist/types/manifest.types.d.ts +54 -0
- package/dist/types/manifest.types.js +2 -0
- package/dist/validate/expr-semantic.d.ts +6 -0
- package/dist/validate/expr-semantic.js +117 -0
- package/dist/validate/semantic-rules.d.ts +3 -0
- package/dist/validate/semantic-rules.js +68 -0
- package/dist/validate/structural.d.ts +2 -0
- package/dist/validate/structural.js +27 -0
- package/dist/validate/validate-manifest.d.ts +2 -0
- package/dist/validate/validate-manifest.js +16 -0
- package/dist/validate/validation-result.d.ts +10 -0
- package/dist/validate/validation-result.js +2 -0
- package/manifest.schema.json +207 -0
- package/package.json +47 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://truesight.dev/schemas/model-manifest/1.1",
|
|
4
|
+
"title": "ModelManifest",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schemaVersion", "generatedAt", "models"],
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"schemaVersion": { "type": "string", "const": "1.1" },
|
|
10
|
+
"generatedAt": { "type": "string", "minLength": 1 },
|
|
11
|
+
"sourceCommit": { "type": "string" },
|
|
12
|
+
"models": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"items": { "$ref": "#/definitions/Model" }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"definitions": {
|
|
18
|
+
"RefString": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*\\.[a-zA-Z_][a-zA-Z0-9_]*$"
|
|
21
|
+
},
|
|
22
|
+
"DimensionType": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": ["integer", "string", "date", "datetime", "boolean"]
|
|
25
|
+
},
|
|
26
|
+
"AggregateType": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["sum", "count", "min", "max"]
|
|
29
|
+
},
|
|
30
|
+
"JoinType": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"enum": ["inner", "left", "right", "full"]
|
|
33
|
+
},
|
|
34
|
+
"JoinRelationship": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"enum": ["one_to_one", "one_to_many", "many_to_one", "many_to_many"]
|
|
37
|
+
},
|
|
38
|
+
"ManifestExpr": {
|
|
39
|
+
"oneOf": [
|
|
40
|
+
{ "$ref": "#/definitions/RefString" },
|
|
41
|
+
{ "$ref": "#/definitions/ManifestExprObject" }
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"ManifestExprObject": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"required": ["kind"],
|
|
47
|
+
"additionalProperties": false,
|
|
48
|
+
"properties": {
|
|
49
|
+
"kind": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"enum": [
|
|
52
|
+
"raw",
|
|
53
|
+
"eq",
|
|
54
|
+
"neq",
|
|
55
|
+
"gt",
|
|
56
|
+
"gte",
|
|
57
|
+
"lt",
|
|
58
|
+
"lte",
|
|
59
|
+
"and",
|
|
60
|
+
"or",
|
|
61
|
+
"not",
|
|
62
|
+
"aggregate"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"sql": { "type": "string" },
|
|
66
|
+
"left": { "$ref": "#/definitions/ManifestExpr" },
|
|
67
|
+
"right": { "$ref": "#/definitions/ManifestExpr" },
|
|
68
|
+
"operand": { "$ref": "#/definitions/ManifestExpr" },
|
|
69
|
+
"fn": { "$ref": "#/definitions/AggregateType" }
|
|
70
|
+
},
|
|
71
|
+
"allOf": [
|
|
72
|
+
{
|
|
73
|
+
"if": { "properties": { "kind": { "const": "raw" } }, "required": ["kind"] },
|
|
74
|
+
"then": { "required": ["sql"] }
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"if": {
|
|
78
|
+
"properties": {
|
|
79
|
+
"kind": { "enum": ["eq", "neq", "gt", "gte", "lt", "lte", "and", "or"] }
|
|
80
|
+
},
|
|
81
|
+
"required": ["kind"]
|
|
82
|
+
},
|
|
83
|
+
"then": { "required": ["left", "right"] }
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"if": { "properties": { "kind": { "const": "not" } }, "required": ["kind"] },
|
|
87
|
+
"then": { "required": ["operand"] }
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"if": { "properties": { "kind": { "const": "aggregate" } }, "required": ["kind"] },
|
|
91
|
+
"then": { "required": ["fn", "operand"] }
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"JoinOn": {
|
|
96
|
+
"oneOf": [
|
|
97
|
+
{
|
|
98
|
+
"type": "object",
|
|
99
|
+
"required": ["pair"],
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"properties": {
|
|
102
|
+
"pair": {
|
|
103
|
+
"type": "array",
|
|
104
|
+
"minItems": 2,
|
|
105
|
+
"maxItems": 2,
|
|
106
|
+
"items": { "type": "string", "minLength": 1 }
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{ "$ref": "#/definitions/ManifestExpr" }
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"DimensionDefinition": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"required": ["groupLabel", "name", "label", "type", "expression"],
|
|
116
|
+
"additionalProperties": false,
|
|
117
|
+
"properties": {
|
|
118
|
+
"groupLabel": { "type": "string" },
|
|
119
|
+
"name": { "type": "string", "minLength": 1 },
|
|
120
|
+
"label": { "type": "string" },
|
|
121
|
+
"type": { "$ref": "#/definitions/DimensionType" },
|
|
122
|
+
"expression": { "$ref": "#/definitions/ManifestExpr" }
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"MeasurementDefinition": {
|
|
126
|
+
"type": "object",
|
|
127
|
+
"required": ["groupLabel", "name", "label", "type", "expression"],
|
|
128
|
+
"additionalProperties": false,
|
|
129
|
+
"properties": {
|
|
130
|
+
"groupLabel": { "type": "string" },
|
|
131
|
+
"name": { "type": "string", "minLength": 1 },
|
|
132
|
+
"label": { "type": "string" },
|
|
133
|
+
"type": { "$ref": "#/definitions/AggregateType" },
|
|
134
|
+
"expression": { "$ref": "#/definitions/ManifestExpr" }
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"ViewDefinition": {
|
|
138
|
+
"type": "object",
|
|
139
|
+
"required": ["name", "label", "sql", "dimensions", "measurements"],
|
|
140
|
+
"additionalProperties": false,
|
|
141
|
+
"properties": {
|
|
142
|
+
"name": { "type": "string", "minLength": 1 },
|
|
143
|
+
"label": { "type": "string" },
|
|
144
|
+
"sql": {
|
|
145
|
+
"type": "object",
|
|
146
|
+
"required": ["tableName"],
|
|
147
|
+
"additionalProperties": false,
|
|
148
|
+
"properties": {
|
|
149
|
+
"tableName": { "type": "string", "minLength": 1 }
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"dimensions": {
|
|
153
|
+
"type": "array",
|
|
154
|
+
"items": { "$ref": "#/definitions/DimensionDefinition" }
|
|
155
|
+
},
|
|
156
|
+
"measurements": {
|
|
157
|
+
"type": "array",
|
|
158
|
+
"items": { "$ref": "#/definitions/MeasurementDefinition" }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"ExploreJoin": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"required": ["name", "fromView", "on", "type", "relationship"],
|
|
165
|
+
"additionalProperties": false,
|
|
166
|
+
"properties": {
|
|
167
|
+
"name": { "type": "string", "minLength": 1 },
|
|
168
|
+
"fromView": { "type": "string", "minLength": 1 },
|
|
169
|
+
"on": { "$ref": "#/definitions/JoinOn" },
|
|
170
|
+
"type": { "$ref": "#/definitions/JoinType" },
|
|
171
|
+
"relationship": { "$ref": "#/definitions/JoinRelationship" }
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"Explore": {
|
|
175
|
+
"type": "object",
|
|
176
|
+
"required": ["name", "label", "from", "joins", "views"],
|
|
177
|
+
"additionalProperties": false,
|
|
178
|
+
"properties": {
|
|
179
|
+
"name": { "type": "string", "minLength": 1 },
|
|
180
|
+
"label": { "type": "string" },
|
|
181
|
+
"from": { "type": "string", "minLength": 1 },
|
|
182
|
+
"joins": {
|
|
183
|
+
"type": "array",
|
|
184
|
+
"items": { "$ref": "#/definitions/ExploreJoin" }
|
|
185
|
+
},
|
|
186
|
+
"views": {
|
|
187
|
+
"type": "array",
|
|
188
|
+
"items": { "$ref": "#/definitions/ViewDefinition" }
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"Model": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"required": ["name", "label", "connectionName", "explores"],
|
|
195
|
+
"additionalProperties": false,
|
|
196
|
+
"properties": {
|
|
197
|
+
"name": { "type": "string", "minLength": 1 },
|
|
198
|
+
"label": { "type": "string" },
|
|
199
|
+
"connectionName": { "type": "string" },
|
|
200
|
+
"explores": {
|
|
201
|
+
"type": "array",
|
|
202
|
+
"items": { "$ref": "#/definitions/Explore" }
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@true-sight/model-schema",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"manifest.schema.json"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./manifest.schema.json": "./manifest.schema.json"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"typecheck": "tsc -p test/dsl/typecheck/tsconfig.json --noEmit"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"ajv": "^8.17.1",
|
|
27
|
+
"reflect-metadata": "^0.2.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/jest": "^30.0.0",
|
|
31
|
+
"jest": "^30.0.0",
|
|
32
|
+
"ts-jest": "^29.2.5",
|
|
33
|
+
"typescript": "^5.7.3"
|
|
34
|
+
},
|
|
35
|
+
"jest": {
|
|
36
|
+
"moduleFileExtensions": ["js", "json", "ts"],
|
|
37
|
+
"rootDir": ".",
|
|
38
|
+
"testMatch": ["**/test/**/*.spec.ts"],
|
|
39
|
+
"transform": {
|
|
40
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
41
|
+
},
|
|
42
|
+
"moduleNameMapper": {
|
|
43
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
44
|
+
},
|
|
45
|
+
"testEnvironment": "node"
|
|
46
|
+
}
|
|
47
|
+
}
|