@metabase/cli 0.1.0-alpha.workspaces-commands.818a8f1 → 0.1.0-alpha.workspaces-commands.9af92d7

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.
Files changed (125) hide show
  1. package/README.md +129 -0
  2. package/dist/{api-key-D9XxErQn.mjs → api-key-U35bYysN.mjs} +1 -1
  3. package/dist/{archive-BPG5c88Y.mjs → archive-t98qQCTg.mjs} +6 -5
  4. package/dist/{auth--Hpjwlaf.mjs → auth-Pmzzbl9X.mjs} +3 -3
  5. package/dist/{body-DwU2s6Pg.mjs → body-qjVMvNjF.mjs} +3 -2
  6. package/dist/{branches-BbcoJXfp.mjs → branches-GR_uFakd.mjs} +6 -5
  7. package/dist/{cancel-task-BDas45YO.mjs → cancel-task-Bx4unmzB.mjs} +6 -5
  8. package/dist/card-CY60jlXc.mjs +19 -0
  9. package/dist/cards-CvXNClLR.mjs +37 -0
  10. package/dist/cli.mjs +19 -17
  11. package/dist/create-78zUdOrE.mjs +48 -0
  12. package/dist/{create-DpnjQvPw.mjs → create-A8ixnCEp.mjs} +8 -7
  13. package/dist/create-CT8GaHhd.mjs +44 -0
  14. package/dist/create-DOsPeHvv.mjs +47 -0
  15. package/dist/{create-CCzsCZMm.mjs → create-DRSgnSTg.mjs} +8 -7
  16. package/dist/{create-branch-sDttBORB.mjs → create-branch-95PKGg4J.mjs} +6 -5
  17. package/dist/{create-Bd_U1zWU.mjs → create-klUmZ4qb.mjs} +9 -8
  18. package/dist/{credentials-C0xKke5D.mjs → credentials-h6gwy6KC.mjs} +8 -7
  19. package/dist/{current-task-BGt1mqaX.mjs → current-task-CKTHTDJ-.mjs} +6 -5
  20. package/dist/dashboard-BVEiysxL.mjs +20 -0
  21. package/dist/dashboard-DVCLGg3X.mjs +152 -0
  22. package/dist/{database-4V1iiPEx.mjs → database-VBWFKoFw.mjs} +3 -3
  23. package/dist/{db-Dm2u2ISJ.mjs → db-BNIiulL8.mjs} +2 -2
  24. package/dist/{delete-DRBTgyus.mjs → delete-Dgw7tuwF.mjs} +7 -6
  25. package/dist/{delete-DUC_stoL.mjs → delete-SpvnjwpH.mjs} +7 -6
  26. package/dist/{delete-runtime-inOVw3IX.mjs → delete-runtime-ZDxlvZa6.mjs} +3 -3
  27. package/dist/{delete-table-9Is631O_.mjs → delete-table-BXmFReAx.mjs} +7 -6
  28. package/dist/{deprovision-BAMzZc6f.mjs → deprovision-Cay-ixJs.mjs} +11 -10
  29. package/dist/{dirty-CLjHbz6J.mjs → dirty-CNjg0YSW.mjs} +6 -5
  30. package/dist/{docker-QWVMG2gl.mjs → docker-D2GAMpHR.mjs} +3 -2
  31. package/dist/{eid-BNhutC1U.mjs → eid-CLOyMi0C.mjs} +1 -1
  32. package/dist/errors-C6w1eZ1F.mjs +101 -0
  33. package/dist/{export-D2Anfu3p.mjs → export-D2PP3RlE.mjs} +7 -6
  34. package/dist/{field-Dhs2AND3.mjs → field-D9nztsQP.mjs} +1 -1
  35. package/dist/{flag-pair-CWvvzDJ_.mjs → flag-pair-Dz-mbq0z.mjs} +1 -1
  36. package/dist/{get-CAPLfawI.mjs → get-B32KbqqV.mjs} +6 -5
  37. package/dist/{get-2po1uv9i.mjs → get-B6PHgITW.mjs} +6 -5
  38. package/dist/{get-BHJA78zg.mjs → get-Bc0yqaS1.mjs} +6 -5
  39. package/dist/{get-CAVVmdMX.mjs → get-BzfjbJ1f.mjs} +6 -5
  40. package/dist/{get-DhIoNeOp.mjs → get-CW0uHmFb.mjs} +6 -5
  41. package/dist/{get-qPOsuTPw.mjs → get-DtsLPlhf.mjs} +6 -5
  42. package/dist/{get-DDWpubE8.mjs → get-gZ5sQoS9.mjs} +7 -6
  43. package/dist/get-qXYTmiCW.mjs +40 -0
  44. package/dist/{has-remote-changes-DAL5jetW.mjs → has-remote-changes-BjdywTVP.mjs} +6 -5
  45. package/dist/{import-CUMxUfSF.mjs → import-CVOFq6HN.mjs} +7 -6
  46. package/dist/{input-BNqSFl38.mjs → input-DkgCMNA9.mjs} +1 -1
  47. package/dist/is-dirty-79hBpoVR.mjs +10 -0
  48. package/dist/{is-dirty-B10S6MG0.mjs → is-dirty-DgxNJz79.mjs} +3 -3
  49. package/dist/{key-CyhOpgWt.mjs → key-CpWh7W8M.mjs} +1 -1
  50. package/dist/{license-DtsGJi3l.mjs → license-B2eNHmdg.mjs} +3 -3
  51. package/dist/list-AcUuhDxS.mjs +47 -0
  52. package/dist/{list-DeFGwhhJ.mjs → list-B0durHcU.mjs} +5 -4
  53. package/dist/{list-qetY9OIN.mjs → list-B6LmdzL6.mjs} +5 -4
  54. package/dist/{list-Y7iGsOfE.mjs → list-B9ppD-U5.mjs} +5 -4
  55. package/dist/{list-evtQS7jl.mjs → list-CW20Zfq-.mjs} +5 -4
  56. package/dist/{list-C5MGydGU.mjs → list-Cw0Geehz.mjs} +5 -4
  57. package/dist/{list-B8s7Qnzk.mjs → list-DEW7ZHzy.mjs} +5 -4
  58. package/dist/{list-OBx5B3gd.mjs → list-bSb_Y5k9.mjs} +7 -6
  59. package/dist/{login-Dqw9ZtCx.mjs → login-ChQ9J6Ne.mjs} +6 -5
  60. package/dist/{logout-DwYJ5OUi.mjs → logout-Cit2O74l.mjs} +5 -4
  61. package/dist/{logs-B_lrY7Js.mjs → logs-Ca_YA7A6.mjs} +6 -5
  62. package/dist/{manifest-wzEFG0JB.mjs → manifest-IMg51yb7.mjs} +3 -7
  63. package/dist/{package-t8dKf4m_.mjs → package-CVNZnqz9.mjs} +6 -1
  64. package/dist/{parse-id-C1prc9US.mjs → parse-id-YyyUbzvS.mjs} +1 -1
  65. package/dist/{poll-D2sXM5rc.mjs → poll-CxWRi3iY.mjs} +2 -1
  66. package/dist/{poll-task-Byiunmaj.mjs → poll-task-DdXgrDJf.mjs} +2 -2
  67. package/dist/{prompt-fXeNtj0M.mjs → prompt-D8p00XDp.mjs} +1 -1
  68. package/dist/{provision-DC4_HWZD.mjs → provision-CV30W4mk.mjs} +12 -11
  69. package/dist/ps-B9-TFn7r.mjs +10 -0
  70. package/dist/{ps-BiOrecEe.mjs → ps-BR36xoRT.mjs} +3 -3
  71. package/dist/query-DmeLeLlh.mjs +93 -0
  72. package/dist/{query-BnGVGeM3.mjs → query-Dnlo_5UK.mjs} +6 -5
  73. package/dist/{remove-Bx48o-0S.mjs → remove-ChoQTtcC.mjs} +5 -4
  74. package/dist/{remove-DecoZzNd.mjs → remove-DfVVf1N9.mjs} +8 -7
  75. package/dist/{render-DlBijc5i.mjs → render-CZNR2MNK.mjs} +5 -2
  76. package/dist/{run-D4NgvaRh.mjs → run-BiXybcsl.mjs} +8 -7
  77. package/dist/{runtime-DUgFfYkN.mjs → runtime-DR8NwmQU.mjs} +7 -104
  78. package/dist/{search-4wKx5ug2.mjs → search-0cjOmsQu.mjs} +5 -4
  79. package/dist/{set-DCjrmTFm.mjs → set-BeVw7OX5.mjs} +8 -7
  80. package/dist/{set-BZnCRL4c.mjs → set-CLsmPD8_.mjs} +6 -5
  81. package/dist/{setting-C4vQSqer.mjs → setting-DEhllKkK.mjs} +3 -3
  82. package/dist/{setup-Dqh9hN6l.mjs → setup-BYL5Yagu.mjs} +7 -6
  83. package/dist/{start-xXQypG5L.mjs → start-BdAhhZYt.mjs} +9 -8
  84. package/dist/{stash-ZZkmW_V7.mjs → stash-Ca63-mCs.mjs} +7 -6
  85. package/dist/{status-9KAPIpX8.mjs → status-Bt6rZDLa.mjs} +4 -3
  86. package/dist/{status-JH6BZppo.mjs → status-D7Ihw-lN.mjs} +4 -3
  87. package/dist/{status-DezF-PIM.mjs → status-cZiC8-t_.mjs} +7 -6
  88. package/dist/{stop-br-ZOnve.mjs → stop-BDeCLqh0.mjs} +8 -7
  89. package/dist/sync-BZPts11d.mjs +26 -0
  90. package/dist/{table-BvAr2ixC.mjs → table-BbNgtqbd.mjs} +1 -1
  91. package/dist/{table-D-Mb5Nvw.mjs → table-CjnruP5H.mjs} +2 -2
  92. package/dist/transform-BXF9B-hF.mjs +21 -0
  93. package/dist/transform-job-DDsjt-4N.mjs +19 -0
  94. package/dist/{translate-DJxDVAE4.mjs → translate-oHz4-5o0.mjs} +8 -7
  95. package/dist/{update-DYVeVjk2.mjs → update-BqI8hYNO.mjs} +12 -11
  96. package/dist/update-CLXVmkyr.mjs +52 -0
  97. package/dist/{update-DxKlQ0hP.mjs → update-Dtu0CHTJ.mjs} +9 -8
  98. package/dist/update-WFBs9Nfq.mjs +55 -0
  99. package/dist/update-dashcard-BSf1-SfK.mjs +67 -0
  100. package/dist/{url-DP88YHNo.mjs → url-B0Bc70KV.mjs} +7 -6
  101. package/dist/validate-query-DE4UouY3.mjs +1521 -0
  102. package/dist/{wait-DwZN3ZwR.mjs → wait-DFI3pf6P.mjs} +2 -2
  103. package/dist/{wait-Cj_8wu4y.mjs → wait-Dkbfo1eS.mjs} +7 -6
  104. package/dist/{wait-flags-CjW4ogUJ.mjs → wait-flags-BIVgwvUI.mjs} +2 -2
  105. package/dist/workspace-Bv7qoaJi.mjs +24 -0
  106. package/dist/{workspace-credentials-q5RRFMT8.mjs → workspace-credentials-BxrU2xZb.mjs} +1 -1
  107. package/package.json +6 -1
  108. package/dist/card-D4zZSPUb.mjs +0 -19
  109. package/dist/create-CwVcoq0O.mjs +0 -43
  110. package/dist/create-_UOeEXAj.mjs +0 -39
  111. package/dist/is-dirty-CUuq-aB6.mjs +0 -9
  112. package/dist/ps-1bZKIwWh.mjs +0 -9
  113. package/dist/sync-C7VOWD00.mjs +0 -26
  114. package/dist/transform-CqxZwhGs.mjs +0 -21
  115. package/dist/transform-job-HjbqjEoP.mjs +0 -19
  116. package/dist/update-CDtm71m2.mjs +0 -50
  117. package/dist/workspace-CbwR0vX_.mjs +0 -24
  118. /package/dist/{body-flags-7oqLhu5j.mjs → body-flags-BK7J6Daz.mjs} +0 -0
  119. /package/dist/{card-C31pGtBZ.mjs → card-2XdaHHSS.mjs} +0 -0
  120. /package/dist/{database-BTX5qbSv.mjs → database-B9-7QAXE.mjs} +0 -0
  121. /package/dist/{field-QwBMAWsq.mjs → field-D_g4xvH9.mjs} +0 -0
  122. /package/dist/{setting-DM7pm7yh.mjs → setting-Bm84ixxW.mjs} +0 -0
  123. /package/dist/{transform-DfVkUttP.mjs → transform-CRRW0mFp.mjs} +0 -0
  124. /package/dist/{transform-job-DuB_OjhO.mjs → transform-job-BtCoVYsb.mjs} +0 -0
  125. /package/dist/{workspace-Dr9lWU3D.mjs → workspace-C3tGVQ6_.mjs} +0 -0
@@ -0,0 +1,1521 @@
1
+ import { writeJson } from "./render-CZNR2MNK.mjs";
2
+ import { ConfigError } from "./errors-C6w1eZ1F.mjs";
3
+ import { z } from "zod";
4
+ import Ajv2020 from "ajv/dist/2020.js";
5
+ import addFormats from "ajv-formats";
6
+
7
+ //#region src/core/schema/data/schemas/common/id.json
8
+ var title$4 = "ID";
9
+ var description$4 = "Shared type definitions for entity identifiers and foreign keys.";
10
+ var $defs$4 = {
11
+ "entity_id": {
12
+ "type": "string",
13
+ "description": "NanoID identifier (21 characters, alphabet A-Za-z0-9_-)",
14
+ "pattern": "^[A-Za-z0-9_-]{21}$"
15
+ },
16
+ "user_id": {
17
+ "type": "string",
18
+ "description": "User FK (email address)",
19
+ "format": "email"
20
+ },
21
+ "database_id": {
22
+ "type": "string",
23
+ "description": "Database FK (database name)"
24
+ },
25
+ "table_id": {
26
+ "type": "array",
27
+ "description": "Table FK [database, schema, table]",
28
+ "prefixItems": [
29
+ {
30
+ "type": "string",
31
+ "description": "Database name"
32
+ },
33
+ {
34
+ "type": ["string", "null"],
35
+ "description": "Schema name (null for schemaless databases)"
36
+ },
37
+ {
38
+ "type": "string",
39
+ "description": "Table name"
40
+ }
41
+ ],
42
+ "minItems": 3,
43
+ "maxItems": 3
44
+ },
45
+ "field_id": {
46
+ "type": "array",
47
+ "description": "Field FK [database, schema, table, field] for regular fields, or [database, schema, table, parent, child, ...] for JSON-unfolded fields.\n",
48
+ "prefixItems": [
49
+ {
50
+ "type": "string",
51
+ "description": "Database name"
52
+ },
53
+ {
54
+ "type": ["string", "null"],
55
+ "description": "Schema name (null for schemaless databases)"
56
+ },
57
+ {
58
+ "type": "string",
59
+ "description": "Table name"
60
+ },
61
+ {
62
+ "type": "string",
63
+ "description": "Field name (or first JSON path segment)"
64
+ }
65
+ ],
66
+ "items": {
67
+ "type": "string",
68
+ "description": "Additional JSON path segments"
69
+ },
70
+ "minItems": 4
71
+ }
72
+ };
73
+ var id_default = {
74
+ title: title$4,
75
+ description: description$4,
76
+ $defs: $defs$4
77
+ };
78
+
79
+ //#endregion
80
+ //#region src/core/schema/data/schemas/common/parameter.json
81
+ var title$3 = "Parameter";
82
+ var description$3 = "A filter control parameter for cards and dashboards. Parameters allow users to interactively filter data via UI controls.\n";
83
+ var type$1 = "object";
84
+ var required$1 = [
85
+ "id",
86
+ "name",
87
+ "slug",
88
+ "type"
89
+ ];
90
+ var properties$1 = {
91
+ "id": {
92
+ "type": "string",
93
+ "minLength": 1,
94
+ "description": "Unique identifier within the dashboard or card. UUIDs are recommended, but Metabase accepts any unique non-empty string.\n"
95
+ },
96
+ "name": {
97
+ "type": "string",
98
+ "description": "Display name"
99
+ },
100
+ "slug": {
101
+ "type": "string",
102
+ "description": "URL-friendly identifier"
103
+ },
104
+ "type": {
105
+ "type": "string",
106
+ "description": "Filter widget type: string/=, string/!=, string/contains, string/starts-with, string/ends-with, number/=, number/!=, number/>=, number/<=, number/between, date/single, date/range, date/month-year, date/quarter-year, date/relative, date/all-options, boolean/=, temporal-unit\n"
107
+ },
108
+ "default": { "description": "Default value (type depends on filter type)" },
109
+ "required": {
110
+ "type": "boolean",
111
+ "description": "Whether a value is required"
112
+ },
113
+ "sectionId": {
114
+ "type": "string",
115
+ "description": "UI section grouping. Restricts which columns are available for mapping. For id — only PK and FK columns. For location — only location columns (country, city, etc.). Normally matches the first part of the parameter type.\n",
116
+ "enum": [
117
+ "string",
118
+ "number",
119
+ "date",
120
+ "boolean",
121
+ "temporal-unit",
122
+ "id",
123
+ "location"
124
+ ]
125
+ },
126
+ "temporal_units": {
127
+ "type": "array",
128
+ "description": "Allowed temporal units (for temporal-unit type)",
129
+ "items": {
130
+ "type": "string",
131
+ "enum": [
132
+ "minute",
133
+ "hour",
134
+ "day",
135
+ "week",
136
+ "month",
137
+ "quarter",
138
+ "year"
139
+ ]
140
+ }
141
+ },
142
+ "values_query_type": {
143
+ "type": "string",
144
+ "enum": [
145
+ "list",
146
+ "search",
147
+ "none"
148
+ ]
149
+ },
150
+ "values_source_type": {
151
+ "type": ["string", "null"],
152
+ "enum": [
153
+ null,
154
+ "card",
155
+ "static-list"
156
+ ]
157
+ },
158
+ "values_source_config": {
159
+ "type": "object",
160
+ "description": "Source configuration. For static-list: {values: [[val, label], ...]}. For card: {card_id, value_field, label_field}.\n",
161
+ "properties": {
162
+ "values": {
163
+ "type": "array",
164
+ "description": "Static list of [value, label] pairs"
165
+ },
166
+ "card_id": {
167
+ "type": "string",
168
+ "description": "Card entity_id to source values from"
169
+ },
170
+ "value_field": { "description": "Field clause for extracting values from card results" },
171
+ "label_field": { "description": "Field clause for extracting labels from card results" }
172
+ },
173
+ "additionalProperties": true
174
+ }
175
+ };
176
+ var $defs$3 = { "parameter_target": {
177
+ "description": "Parameter target for dashboard parameter mappings. Uses legacy MBQL format: [field, Field-FK, null-or-options].\n",
178
+ "type": "array",
179
+ "minItems": 2,
180
+ "allOf": [
181
+ {
182
+ "if": { "prefixItems": [{ "const": "dimension" }] },
183
+ "then": {
184
+ "prefixItems": [{ "const": "dimension" }, {
185
+ "type": "array",
186
+ "minItems": 2,
187
+ "allOf": [
188
+ {
189
+ "if": { "prefixItems": [{ "const": "field" }] },
190
+ "then": { "$ref": "ref.yaml#/$defs/legacy_field_ref" }
191
+ },
192
+ {
193
+ "if": { "prefixItems": [{ "const": "expression" }] },
194
+ "then": { "$ref": "ref.yaml#/$defs/legacy_expression_ref" }
195
+ },
196
+ {
197
+ "if": { "prefixItems": [{ "const": "template-tag" }] },
198
+ "then": {
199
+ "prefixItems": [{ "const": "template-tag" }, { "type": "string" }],
200
+ "minItems": 2,
201
+ "maxItems": 2
202
+ }
203
+ }
204
+ ]
205
+ }],
206
+ "items": { "anyOf": [{
207
+ "type": "object",
208
+ "properties": { "stage-number": { "type": "integer" } }
209
+ }, { "type": "null" }] },
210
+ "maxItems": 3
211
+ }
212
+ },
213
+ {
214
+ "if": { "prefixItems": [{ "const": "variable" }] },
215
+ "then": {
216
+ "prefixItems": [{ "const": "variable" }, {
217
+ "type": "array",
218
+ "prefixItems": [{ "const": "template-tag" }, { "type": "string" }],
219
+ "minItems": 2,
220
+ "maxItems": 2
221
+ }],
222
+ "minItems": 2,
223
+ "maxItems": 2
224
+ }
225
+ },
226
+ {
227
+ "if": { "prefixItems": [{ "const": "text-tag" }] },
228
+ "then": {
229
+ "prefixItems": [{ "const": "text-tag" }, { "type": "string" }],
230
+ "minItems": 2,
231
+ "maxItems": 2
232
+ }
233
+ }
234
+ ]
235
+ } };
236
+ var parameter_default = {
237
+ title: title$3,
238
+ description: description$3,
239
+ type: type$1,
240
+ required: required$1,
241
+ properties: properties$1,
242
+ $defs: $defs$3
243
+ };
244
+
245
+ //#endregion
246
+ //#region src/core/schema/data/schemas/common/query.json
247
+ var title$2 = "Query";
248
+ var description$2 = "A query definition in serialized pMBQL format. Contains a flat list of stages (no recursive source-query nesting). Each stage is either an MBQL structured stage or a native SQL stage.\n";
249
+ var type = "object";
250
+ var required = [
251
+ "lib/type",
252
+ "database",
253
+ "stages"
254
+ ];
255
+ var properties = {
256
+ "lib/type": {
257
+ "type": "string",
258
+ "const": "mbql/query"
259
+ },
260
+ "database": { "$ref": "id.yaml#/$defs/database_id" },
261
+ "stages": {
262
+ "type": "array",
263
+ "minItems": 1,
264
+ "items": { "$ref": "#/$defs/stage" }
265
+ }
266
+ };
267
+ var $defs$2 = {
268
+ "options": {
269
+ "description": "Base options object for pMBQL clauses. Always present as the second element of every clause array. Empty {} when no options apply.\n",
270
+ "type": "object",
271
+ "properties": {
272
+ "base-type": { "type": "string" },
273
+ "effective-type": { "type": "string" },
274
+ "lib/uuid": {
275
+ "type": "string",
276
+ "format": "uuid"
277
+ },
278
+ "lib/expression-name": { "type": "string" }
279
+ }
280
+ },
281
+ "case_sensitive_options": {
282
+ "description": "Options for string filter operators.",
283
+ "allOf": [{ "$ref": "#/$defs/options" }, {
284
+ "type": "object",
285
+ "properties": { "case-sensitive": { "type": "boolean" } }
286
+ }]
287
+ },
288
+ "time_interval_options": {
289
+ "description": "Options for the time-interval operator.",
290
+ "allOf": [{ "$ref": "#/$defs/options" }, {
291
+ "type": "object",
292
+ "properties": { "include-current": { "type": "boolean" } }
293
+ }]
294
+ },
295
+ "datetime_parse_options": {
296
+ "description": "Options for the datetime parsing operator.",
297
+ "allOf": [{ "$ref": "#/$defs/options" }, {
298
+ "type": "object",
299
+ "properties": { "mode": {
300
+ "type": "string",
301
+ "enum": [
302
+ "iso",
303
+ "simple",
304
+ "unix-seconds",
305
+ "unix-milliseconds",
306
+ "unix-microseconds",
307
+ "unix-nanoseconds",
308
+ "iso-bytes",
309
+ "simple-bytes"
310
+ ]
311
+ } }
312
+ }]
313
+ },
314
+ "stage": {
315
+ "type": "object",
316
+ "required": ["lib/type"],
317
+ "allOf": [{
318
+ "if": { "properties": { "lib/type": { "const": "mbql.stage/mbql" } } },
319
+ "then": { "$ref": "#/$defs/mbql_stage" }
320
+ }, {
321
+ "if": { "properties": { "lib/type": { "const": "mbql.stage/native" } } },
322
+ "then": { "$ref": "#/$defs/native_stage" }
323
+ }]
324
+ },
325
+ "mbql_stage": {
326
+ "type": "object",
327
+ "properties": {
328
+ "lib/type": { "const": "mbql.stage/mbql" },
329
+ "source-table": { "$ref": "id.yaml#/$defs/table_id" },
330
+ "source-card": { "$ref": "id.yaml#/$defs/entity_id" },
331
+ "joins": {
332
+ "type": "array",
333
+ "items": { "$ref": "#/$defs/join" }
334
+ },
335
+ "expressions": {
336
+ "type": "array",
337
+ "items": { "$ref": "#/$defs/expression" }
338
+ },
339
+ "fields": {
340
+ "type": "array",
341
+ "items": {
342
+ "type": "array",
343
+ "allOf": [{
344
+ "if": { "prefixItems": [{ "const": "field" }] },
345
+ "then": { "$ref": "ref.yaml#/$defs/field_ref" }
346
+ }, {
347
+ "if": { "prefixItems": [{ "const": "expression" }] },
348
+ "then": { "$ref": "ref.yaml#/$defs/expression_ref" }
349
+ }]
350
+ }
351
+ },
352
+ "filters": {
353
+ "type": "array",
354
+ "items": { "$ref": "#/$defs/expression" }
355
+ },
356
+ "aggregation": {
357
+ "type": "array",
358
+ "items": { "$ref": "#/$defs/expression" }
359
+ },
360
+ "breakout": {
361
+ "type": "array",
362
+ "items": { "$ref": "#/$defs/expression" }
363
+ },
364
+ "order-by": {
365
+ "type": "array",
366
+ "items": { "$ref": "#/$defs/expression" }
367
+ },
368
+ "limit": { "type": ["integer", "null"] }
369
+ }
370
+ },
371
+ "expression": {
372
+ "description": "An MBQL expression clause. Either a literal value or an array [operator, options, ...args] where options is always an object.\n",
373
+ "type": [
374
+ "string",
375
+ "number",
376
+ "boolean",
377
+ "null",
378
+ "array"
379
+ ],
380
+ "if": { "type": "array" },
381
+ "then": {
382
+ "minItems": 1,
383
+ "allOf": [
384
+ {
385
+ "if": { "prefixItems": [{ "const": "field" }] },
386
+ "then": { "$ref": "ref.yaml#/$defs/field_ref" }
387
+ },
388
+ {
389
+ "if": { "prefixItems": [{ "const": "expression" }] },
390
+ "then": { "$ref": "ref.yaml#/$defs/expression_ref" }
391
+ },
392
+ {
393
+ "if": { "prefixItems": [{ "const": "aggregation" }] },
394
+ "then": { "$ref": "ref.yaml#/$defs/aggregation_ref" }
395
+ },
396
+ {
397
+ "if": { "prefixItems": [{ "const": "metric" }] },
398
+ "then": { "$ref": "ref.yaml#/$defs/metric_ref" }
399
+ },
400
+ {
401
+ "if": { "prefixItems": [{ "const": "measure" }] },
402
+ "then": { "$ref": "ref.yaml#/$defs/measure_ref" }
403
+ },
404
+ {
405
+ "if": { "prefixItems": [{ "const": "segment" }] },
406
+ "then": { "$ref": "ref.yaml#/$defs/segment_ref" }
407
+ },
408
+ {
409
+ "if": { "prefixItems": [{ "const": "value" }] },
410
+ "then": {
411
+ "prefixItems": [
412
+ { "const": "value" },
413
+ { "$ref": "#/$defs/options" },
414
+ { "type": [
415
+ "string",
416
+ "number",
417
+ "boolean"
418
+ ] }
419
+ ],
420
+ "minItems": 3,
421
+ "maxItems": 3
422
+ }
423
+ },
424
+ {
425
+ "if": { "prefixItems": [{ "enum": [
426
+ "+",
427
+ "-",
428
+ "*",
429
+ "/"
430
+ ] }] },
431
+ "then": {
432
+ "prefixItems": [
433
+ { "enum": [
434
+ "+",
435
+ "-",
436
+ "*",
437
+ "/"
438
+ ] },
439
+ { "$ref": "#/$defs/options" },
440
+ { "$ref": "#/$defs/expression" }
441
+ ],
442
+ "items": { "$ref": "#/$defs/expression" },
443
+ "minItems": 3
444
+ }
445
+ },
446
+ {
447
+ "if": { "prefixItems": [{ "enum": ["and", "or"] }] },
448
+ "then": {
449
+ "prefixItems": [
450
+ { "enum": ["and", "or"] },
451
+ { "$ref": "#/$defs/options" },
452
+ { "$ref": "#/$defs/expression" },
453
+ { "$ref": "#/$defs/expression" }
454
+ ],
455
+ "items": { "$ref": "#/$defs/expression" },
456
+ "minItems": 4
457
+ }
458
+ },
459
+ {
460
+ "if": { "prefixItems": [{ "const": "not" }] },
461
+ "then": {
462
+ "prefixItems": [
463
+ { "const": "not" },
464
+ { "$ref": "#/$defs/options" },
465
+ { "$ref": "#/$defs/expression" }
466
+ ],
467
+ "minItems": 3,
468
+ "maxItems": 3
469
+ }
470
+ },
471
+ {
472
+ "if": { "prefixItems": [{ "enum": [
473
+ "=",
474
+ "!=",
475
+ "<",
476
+ ">",
477
+ "<=",
478
+ ">="
479
+ ] }] },
480
+ "then": {
481
+ "prefixItems": [
482
+ { "enum": [
483
+ "=",
484
+ "!=",
485
+ "<",
486
+ ">",
487
+ "<=",
488
+ ">="
489
+ ] },
490
+ { "$ref": "#/$defs/options" },
491
+ { "$ref": "#/$defs/expression" },
492
+ { "$ref": "#/$defs/expression" }
493
+ ],
494
+ "items": { "$ref": "#/$defs/expression" },
495
+ "minItems": 4
496
+ }
497
+ },
498
+ {
499
+ "if": { "prefixItems": [{ "enum": ["in", "not-in"] }] },
500
+ "then": {
501
+ "prefixItems": [
502
+ { "enum": ["in", "not-in"] },
503
+ { "$ref": "#/$defs/options" },
504
+ { "$ref": "#/$defs/expression" },
505
+ { "$ref": "#/$defs/expression" }
506
+ ],
507
+ "items": { "$ref": "#/$defs/expression" },
508
+ "minItems": 4
509
+ }
510
+ },
511
+ {
512
+ "if": { "prefixItems": [{ "const": "between" }] },
513
+ "then": {
514
+ "prefixItems": [
515
+ { "const": "between" },
516
+ { "$ref": "#/$defs/options" },
517
+ { "$ref": "#/$defs/expression" },
518
+ { "$ref": "#/$defs/expression" },
519
+ { "$ref": "#/$defs/expression" }
520
+ ],
521
+ "minItems": 5,
522
+ "maxItems": 5
523
+ }
524
+ },
525
+ {
526
+ "if": { "prefixItems": [{ "const": "inside" }] },
527
+ "then": {
528
+ "prefixItems": [
529
+ { "const": "inside" },
530
+ { "$ref": "#/$defs/options" },
531
+ { "$ref": "#/$defs/expression" },
532
+ { "$ref": "#/$defs/expression" },
533
+ { "type": "number" },
534
+ { "type": "number" },
535
+ { "type": "number" },
536
+ { "type": "number" }
537
+ ],
538
+ "minItems": 8,
539
+ "maxItems": 8
540
+ }
541
+ },
542
+ {
543
+ "if": { "prefixItems": [{ "enum": [
544
+ "is-null",
545
+ "not-null",
546
+ "is-empty",
547
+ "not-empty"
548
+ ] }] },
549
+ "then": {
550
+ "prefixItems": [
551
+ { "enum": [
552
+ "is-null",
553
+ "not-null",
554
+ "is-empty",
555
+ "not-empty"
556
+ ] },
557
+ { "$ref": "#/$defs/options" },
558
+ { "$ref": "#/$defs/expression" }
559
+ ],
560
+ "minItems": 3,
561
+ "maxItems": 3
562
+ }
563
+ },
564
+ {
565
+ "if": { "prefixItems": [{ "enum": [
566
+ "contains",
567
+ "does-not-contain",
568
+ "starts-with",
569
+ "ends-with"
570
+ ] }] },
571
+ "then": {
572
+ "prefixItems": [
573
+ { "enum": [
574
+ "contains",
575
+ "does-not-contain",
576
+ "starts-with",
577
+ "ends-with"
578
+ ] },
579
+ { "$ref": "#/$defs/case_sensitive_options" },
580
+ { "$ref": "#/$defs/expression" },
581
+ { "$ref": "#/$defs/expression" }
582
+ ],
583
+ "items": { "$ref": "#/$defs/expression" },
584
+ "minItems": 4
585
+ }
586
+ },
587
+ {
588
+ "if": { "prefixItems": [{ "const": "time-interval" }] },
589
+ "then": {
590
+ "prefixItems": [
591
+ { "const": "time-interval" },
592
+ { "$ref": "#/$defs/time_interval_options" },
593
+ { "$ref": "#/$defs/expression" },
594
+ {
595
+ "if": { "type": "integer" },
596
+ "then": { "type": "integer" },
597
+ "else": { "enum": [
598
+ "current",
599
+ "last",
600
+ "next"
601
+ ] }
602
+ },
603
+ { "$ref": "temporal_bucketing.yaml#/$defs/datetime_truncation_unit" }
604
+ ],
605
+ "minItems": 5,
606
+ "maxItems": 5
607
+ }
608
+ },
609
+ {
610
+ "if": { "prefixItems": [{ "const": "relative-time-interval" }] },
611
+ "then": {
612
+ "prefixItems": [
613
+ { "const": "relative-time-interval" },
614
+ { "$ref": "#/$defs/options" },
615
+ { "$ref": "#/$defs/expression" },
616
+ { "type": "integer" },
617
+ { "$ref": "temporal_bucketing.yaml#/$defs/datetime_truncation_unit" },
618
+ { "type": "integer" },
619
+ { "$ref": "temporal_bucketing.yaml#/$defs/datetime_truncation_unit" }
620
+ ],
621
+ "minItems": 7,
622
+ "maxItems": 7
623
+ }
624
+ },
625
+ {
626
+ "if": { "prefixItems": [{ "enum": ["now", "today"] }] },
627
+ "then": {
628
+ "prefixItems": [{ "enum": ["now", "today"] }, { "$ref": "#/$defs/options" }],
629
+ "minItems": 2,
630
+ "maxItems": 2
631
+ }
632
+ },
633
+ {
634
+ "if": { "prefixItems": [{ "const": "interval" }] },
635
+ "then": {
636
+ "prefixItems": [
637
+ { "const": "interval" },
638
+ { "$ref": "#/$defs/options" },
639
+ { "type": "integer" },
640
+ { "$ref": "temporal_bucketing.yaml#/$defs/datetime_truncation_unit" }
641
+ ],
642
+ "minItems": 4,
643
+ "maxItems": 4
644
+ }
645
+ },
646
+ {
647
+ "if": { "prefixItems": [{ "enum": [
648
+ "abs",
649
+ "ceil",
650
+ "floor",
651
+ "round",
652
+ "sqrt",
653
+ "exp",
654
+ "log",
655
+ "length",
656
+ "trim",
657
+ "ltrim",
658
+ "rtrim",
659
+ "upper",
660
+ "lower",
661
+ "host",
662
+ "domain",
663
+ "subdomain",
664
+ "path",
665
+ "get-year",
666
+ "get-quarter",
667
+ "get-month",
668
+ "get-day",
669
+ "get-hour",
670
+ "get-minute",
671
+ "get-second",
672
+ "text",
673
+ "integer",
674
+ "float",
675
+ "day-name",
676
+ "month-name",
677
+ "quarter-name",
678
+ "date"
679
+ ] }] },
680
+ "then": {
681
+ "prefixItems": [
682
+ { "enum": [
683
+ "abs",
684
+ "ceil",
685
+ "floor",
686
+ "round",
687
+ "sqrt",
688
+ "exp",
689
+ "log",
690
+ "length",
691
+ "trim",
692
+ "ltrim",
693
+ "rtrim",
694
+ "upper",
695
+ "lower",
696
+ "host",
697
+ "domain",
698
+ "subdomain",
699
+ "path",
700
+ "get-year",
701
+ "get-quarter",
702
+ "get-month",
703
+ "get-day",
704
+ "get-hour",
705
+ "get-minute",
706
+ "get-second",
707
+ "text",
708
+ "integer",
709
+ "float",
710
+ "day-name",
711
+ "month-name",
712
+ "quarter-name",
713
+ "date"
714
+ ] },
715
+ { "$ref": "#/$defs/options" },
716
+ { "$ref": "#/$defs/expression" }
717
+ ],
718
+ "minItems": 3,
719
+ "maxItems": 3
720
+ }
721
+ },
722
+ {
723
+ "if": { "prefixItems": [{ "const": "datetime" }] },
724
+ "then": {
725
+ "prefixItems": [
726
+ { "const": "datetime" },
727
+ { "$ref": "#/$defs/datetime_parse_options" },
728
+ { "$ref": "#/$defs/expression" }
729
+ ],
730
+ "minItems": 3,
731
+ "maxItems": 3
732
+ }
733
+ },
734
+ {
735
+ "if": { "prefixItems": [{ "enum": ["get-day-of-week", "get-week"] }] },
736
+ "then": {
737
+ "prefixItems": [
738
+ { "enum": ["get-day-of-week", "get-week"] },
739
+ { "$ref": "#/$defs/options" },
740
+ { "$ref": "#/$defs/expression" },
741
+ {
742
+ "type": "string",
743
+ "enum": [
744
+ "iso",
745
+ "us",
746
+ "instance"
747
+ ]
748
+ }
749
+ ],
750
+ "minItems": 3,
751
+ "maxItems": 4
752
+ }
753
+ },
754
+ {
755
+ "if": { "prefixItems": [{ "const": "power" }] },
756
+ "then": {
757
+ "prefixItems": [
758
+ { "const": "power" },
759
+ { "$ref": "#/$defs/options" },
760
+ { "$ref": "#/$defs/expression" },
761
+ { "$ref": "#/$defs/expression" }
762
+ ],
763
+ "minItems": 4,
764
+ "maxItems": 4
765
+ }
766
+ },
767
+ {
768
+ "if": { "prefixItems": [{ "enum": ["replace", "split-part"] }] },
769
+ "then": {
770
+ "prefixItems": [
771
+ { "enum": ["replace", "split-part"] },
772
+ { "$ref": "#/$defs/options" },
773
+ { "$ref": "#/$defs/expression" },
774
+ { "$ref": "#/$defs/expression" },
775
+ { "$ref": "#/$defs/expression" }
776
+ ],
777
+ "minItems": 5,
778
+ "maxItems": 5
779
+ }
780
+ },
781
+ {
782
+ "if": { "prefixItems": [{ "const": "substring" }] },
783
+ "then": {
784
+ "prefixItems": [
785
+ { "const": "substring" },
786
+ { "$ref": "#/$defs/options" },
787
+ { "$ref": "#/$defs/expression" },
788
+ { "$ref": "#/$defs/expression" },
789
+ { "$ref": "#/$defs/expression" }
790
+ ],
791
+ "minItems": 4,
792
+ "maxItems": 5
793
+ }
794
+ },
795
+ {
796
+ "if": { "prefixItems": [{ "const": "collate" }] },
797
+ "then": {
798
+ "prefixItems": [
799
+ { "const": "collate" },
800
+ { "$ref": "#/$defs/options" },
801
+ { "$ref": "#/$defs/expression" },
802
+ { "type": "string" }
803
+ ],
804
+ "minItems": 4,
805
+ "maxItems": 4
806
+ }
807
+ },
808
+ {
809
+ "if": { "prefixItems": [{ "const": "regex-match-first" }] },
810
+ "then": {
811
+ "prefixItems": [
812
+ { "const": "regex-match-first" },
813
+ { "$ref": "#/$defs/options" },
814
+ { "$ref": "#/$defs/expression" },
815
+ { "type": "string" }
816
+ ],
817
+ "minItems": 4,
818
+ "maxItems": 4
819
+ }
820
+ },
821
+ {
822
+ "if": { "prefixItems": [{ "const": "concat" }] },
823
+ "then": {
824
+ "prefixItems": [
825
+ { "const": "concat" },
826
+ { "$ref": "#/$defs/options" },
827
+ { "$ref": "#/$defs/expression" },
828
+ { "$ref": "#/$defs/expression" }
829
+ ],
830
+ "items": { "$ref": "#/$defs/expression" },
831
+ "minItems": 4
832
+ }
833
+ },
834
+ {
835
+ "if": { "prefixItems": [{ "const": "coalesce" }] },
836
+ "then": {
837
+ "prefixItems": [
838
+ { "const": "coalesce" },
839
+ { "$ref": "#/$defs/options" },
840
+ { "$ref": "#/$defs/expression" },
841
+ { "$ref": "#/$defs/expression" }
842
+ ],
843
+ "items": { "$ref": "#/$defs/expression" },
844
+ "minItems": 4
845
+ }
846
+ },
847
+ {
848
+ "if": { "prefixItems": [{ "enum": ["datetime-add", "datetime-subtract"] }] },
849
+ "then": {
850
+ "prefixItems": [
851
+ { "enum": ["datetime-add", "datetime-subtract"] },
852
+ { "$ref": "#/$defs/options" },
853
+ { "$ref": "#/$defs/expression" },
854
+ { "type": "integer" },
855
+ { "$ref": "temporal_bucketing.yaml#/$defs/datetime_truncation_unit" }
856
+ ],
857
+ "minItems": 5,
858
+ "maxItems": 5
859
+ }
860
+ },
861
+ {
862
+ "if": { "prefixItems": [{ "const": "datetime-diff" }] },
863
+ "then": {
864
+ "prefixItems": [
865
+ { "const": "datetime-diff" },
866
+ { "$ref": "#/$defs/options" },
867
+ { "$ref": "#/$defs/expression" },
868
+ { "$ref": "#/$defs/expression" },
869
+ { "$ref": "#/$defs/datetime_diff_unit" }
870
+ ],
871
+ "minItems": 5,
872
+ "maxItems": 5
873
+ }
874
+ },
875
+ {
876
+ "if": { "prefixItems": [{ "const": "convert-timezone" }] },
877
+ "then": {
878
+ "prefixItems": [
879
+ { "const": "convert-timezone" },
880
+ { "$ref": "#/$defs/options" },
881
+ { "$ref": "#/$defs/expression" },
882
+ { "type": "string" },
883
+ { "type": "string" }
884
+ ],
885
+ "minItems": 4,
886
+ "maxItems": 5
887
+ }
888
+ },
889
+ {
890
+ "if": { "prefixItems": [{ "const": "temporal-extract" }] },
891
+ "then": {
892
+ "prefixItems": [
893
+ { "const": "temporal-extract" },
894
+ { "$ref": "#/$defs/options" },
895
+ { "$ref": "#/$defs/expression" },
896
+ { "$ref": "temporal_bucketing.yaml#/$defs/datetime_extraction_unit" },
897
+ {
898
+ "type": "string",
899
+ "enum": [
900
+ "iso",
901
+ "us",
902
+ "instance"
903
+ ]
904
+ }
905
+ ],
906
+ "minItems": 4,
907
+ "maxItems": 5
908
+ }
909
+ },
910
+ {
911
+ "if": { "prefixItems": [{ "enum": ["count", "cum-count"] }] },
912
+ "then": {
913
+ "prefixItems": [{ "enum": ["count", "cum-count"] }, { "$ref": "#/$defs/options" }],
914
+ "items": { "$ref": "#/$defs/expression" },
915
+ "minItems": 2,
916
+ "maxItems": 3
917
+ }
918
+ },
919
+ {
920
+ "if": { "prefixItems": [{ "enum": [
921
+ "sum",
922
+ "avg",
923
+ "min",
924
+ "max",
925
+ "distinct",
926
+ "stddev",
927
+ "var",
928
+ "median",
929
+ "cum-sum"
930
+ ] }] },
931
+ "then": {
932
+ "prefixItems": [
933
+ { "enum": [
934
+ "sum",
935
+ "avg",
936
+ "min",
937
+ "max",
938
+ "distinct",
939
+ "stddev",
940
+ "var",
941
+ "median",
942
+ "cum-sum"
943
+ ] },
944
+ { "$ref": "#/$defs/options" },
945
+ { "$ref": "#/$defs/expression" }
946
+ ],
947
+ "minItems": 3,
948
+ "maxItems": 3
949
+ }
950
+ },
951
+ {
952
+ "if": { "prefixItems": [{ "const": "percentile" }] },
953
+ "then": {
954
+ "prefixItems": [
955
+ { "const": "percentile" },
956
+ { "$ref": "#/$defs/options" },
957
+ { "$ref": "#/$defs/expression" },
958
+ { "type": "number" }
959
+ ],
960
+ "minItems": 4,
961
+ "maxItems": 4
962
+ }
963
+ },
964
+ {
965
+ "if": { "prefixItems": [{ "enum": ["count-where", "share"] }] },
966
+ "then": {
967
+ "prefixItems": [
968
+ { "enum": ["count-where", "share"] },
969
+ { "$ref": "#/$defs/options" },
970
+ { "$ref": "#/$defs/expression" }
971
+ ],
972
+ "minItems": 3,
973
+ "maxItems": 3
974
+ }
975
+ },
976
+ {
977
+ "if": { "prefixItems": [{ "enum": ["sum-where", "distinct-where"] }] },
978
+ "then": {
979
+ "prefixItems": [
980
+ { "enum": ["sum-where", "distinct-where"] },
981
+ { "$ref": "#/$defs/options" },
982
+ { "$ref": "#/$defs/expression" },
983
+ { "$ref": "#/$defs/expression" }
984
+ ],
985
+ "minItems": 4,
986
+ "maxItems": 4
987
+ }
988
+ },
989
+ {
990
+ "if": { "prefixItems": [{ "enum": ["case", "if"] }] },
991
+ "then": {
992
+ "prefixItems": [
993
+ { "enum": ["case", "if"] },
994
+ { "$ref": "#/$defs/options" },
995
+ {
996
+ "type": "array",
997
+ "items": {
998
+ "type": "array",
999
+ "prefixItems": [{ "$ref": "#/$defs/expression" }, { "$ref": "#/$defs/expression" }],
1000
+ "minItems": 2,
1001
+ "maxItems": 2
1002
+ }
1003
+ },
1004
+ { "$ref": "#/$defs/expression" }
1005
+ ],
1006
+ "minItems": 3,
1007
+ "maxItems": 4
1008
+ }
1009
+ },
1010
+ {
1011
+ "if": { "prefixItems": [{ "const": "offset" }] },
1012
+ "then": {
1013
+ "prefixItems": [
1014
+ { "const": "offset" },
1015
+ { "$ref": "#/$defs/options" },
1016
+ { "$ref": "#/$defs/expression" },
1017
+ { "type": "integer" }
1018
+ ],
1019
+ "minItems": 4,
1020
+ "maxItems": 4
1021
+ }
1022
+ },
1023
+ {
1024
+ "if": { "prefixItems": [{ "enum": ["asc", "desc"] }] },
1025
+ "then": {
1026
+ "prefixItems": [
1027
+ { "enum": ["asc", "desc"] },
1028
+ { "$ref": "#/$defs/options" },
1029
+ { "$ref": "#/$defs/expression" }
1030
+ ],
1031
+ "minItems": 3,
1032
+ "maxItems": 3
1033
+ }
1034
+ }
1035
+ ]
1036
+ }
1037
+ },
1038
+ "datetime_diff_unit": {
1039
+ "type": "string",
1040
+ "enum": [
1041
+ "second",
1042
+ "minute",
1043
+ "hour",
1044
+ "day",
1045
+ "week",
1046
+ "month",
1047
+ "quarter",
1048
+ "year"
1049
+ ]
1050
+ },
1051
+ "join": {
1052
+ "type": "object",
1053
+ "required": [
1054
+ "stages",
1055
+ "conditions",
1056
+ "alias"
1057
+ ],
1058
+ "properties": {
1059
+ "stages": {
1060
+ "type": "array",
1061
+ "minItems": 1,
1062
+ "items": { "$ref": "#/$defs/stage" }
1063
+ },
1064
+ "conditions": {
1065
+ "type": "array",
1066
+ "minItems": 1,
1067
+ "items": { "$ref": "#/$defs/expression" }
1068
+ },
1069
+ "alias": { "type": "string" },
1070
+ "strategy": {
1071
+ "type": "string",
1072
+ "enum": [
1073
+ "left-join",
1074
+ "right-join",
1075
+ "inner-join",
1076
+ "full-join"
1077
+ ]
1078
+ },
1079
+ "fields": {
1080
+ "if": { "type": "string" },
1081
+ "then": { "enum": ["all", "none"] },
1082
+ "else": {
1083
+ "type": "array",
1084
+ "items": { "$ref": "#/$defs/expression" }
1085
+ }
1086
+ }
1087
+ }
1088
+ },
1089
+ "native_stage": {
1090
+ "type": "object",
1091
+ "required": ["lib/type", "native"],
1092
+ "properties": {
1093
+ "lib/type": { "const": "mbql.stage/native" },
1094
+ "native": { "type": "string" },
1095
+ "template-tags": {
1096
+ "type": "object",
1097
+ "additionalProperties": { "$ref": "#/$defs/template_tag" }
1098
+ }
1099
+ }
1100
+ },
1101
+ "template_tag": {
1102
+ "type": "object",
1103
+ "required": [
1104
+ "type",
1105
+ "name",
1106
+ "id"
1107
+ ],
1108
+ "properties": {
1109
+ "type": {
1110
+ "type": "string",
1111
+ "enum": [
1112
+ "text",
1113
+ "number",
1114
+ "date",
1115
+ "boolean",
1116
+ "dimension",
1117
+ "temporal-unit",
1118
+ "card",
1119
+ "snippet",
1120
+ "table"
1121
+ ]
1122
+ },
1123
+ "name": { "type": "string" },
1124
+ "id": {
1125
+ "type": "string",
1126
+ "format": "uuid"
1127
+ },
1128
+ "display-name": { "type": "string" },
1129
+ "default": { "description": "Default value (type depends on tag type)" },
1130
+ "required": { "type": "boolean" }
1131
+ },
1132
+ "allOf": [
1133
+ {
1134
+ "if": { "properties": { "type": { "const": "dimension" } } },
1135
+ "then": {
1136
+ "required": ["dimension", "widget-type"],
1137
+ "properties": {
1138
+ "dimension": { "$ref": "#/$defs/expression" },
1139
+ "widget-type": { "type": "string" },
1140
+ "options": { "type": "object" },
1141
+ "alias": { "type": "string" }
1142
+ }
1143
+ }
1144
+ },
1145
+ {
1146
+ "if": { "properties": { "type": { "const": "temporal-unit" } } },
1147
+ "then": {
1148
+ "required": ["dimension"],
1149
+ "properties": {
1150
+ "dimension": { "$ref": "#/$defs/expression" },
1151
+ "alias": { "type": "string" }
1152
+ }
1153
+ }
1154
+ },
1155
+ {
1156
+ "if": { "properties": { "type": { "const": "card" } } },
1157
+ "then": {
1158
+ "required": ["card-id"],
1159
+ "properties": { "card-id": { "$ref": "id.yaml#/$defs/entity_id" } }
1160
+ }
1161
+ },
1162
+ {
1163
+ "if": { "properties": { "type": { "const": "snippet" } } },
1164
+ "then": {
1165
+ "required": ["snippet-name", "snippet-id"],
1166
+ "properties": {
1167
+ "snippet-name": { "type": "string" },
1168
+ "snippet-id": { "$ref": "id.yaml#/$defs/entity_id" }
1169
+ }
1170
+ }
1171
+ },
1172
+ {
1173
+ "if": { "properties": { "type": { "const": "table" } } },
1174
+ "then": {
1175
+ "required": ["table-id"],
1176
+ "properties": {
1177
+ "table-id": { "$ref": "id.yaml#/$defs/table_id" },
1178
+ "emit-alias": { "type": "boolean" }
1179
+ }
1180
+ }
1181
+ }
1182
+ ]
1183
+ }
1184
+ };
1185
+ var query_default = {
1186
+ title: title$2,
1187
+ description: description$2,
1188
+ type,
1189
+ required,
1190
+ properties,
1191
+ $defs: $defs$2
1192
+ };
1193
+
1194
+ //#endregion
1195
+ //#region src/core/schema/data/schemas/common/ref.json
1196
+ var title$1 = "Ref";
1197
+ var description$1 = "Column and entity reference types used in MBQL expressions, parameter mappings, and visualization settings. Options are always the second element (an object, never null).\n";
1198
+ var $defs$1 = {
1199
+ "field_options": {
1200
+ "description": "Options for field refs.",
1201
+ "allOf": [{ "$ref": "query.yaml#/$defs/options" }, {
1202
+ "type": "object",
1203
+ "properties": {
1204
+ "temporal-unit": { "$ref": "temporal_bucketing.yaml#/$defs/datetime_bucketing_unit" },
1205
+ "join-alias": { "type": "string" },
1206
+ "binning": {
1207
+ "type": "object",
1208
+ "required": ["strategy"],
1209
+ "properties": { "strategy": {
1210
+ "type": "string",
1211
+ "enum": [
1212
+ "default",
1213
+ "num-bins",
1214
+ "bin-width"
1215
+ ]
1216
+ } },
1217
+ "allOf": [{
1218
+ "if": { "properties": { "strategy": { "const": "bin-width" } } },
1219
+ "then": {
1220
+ "required": ["bin-width"],
1221
+ "properties": { "bin-width": {
1222
+ "type": "number",
1223
+ "exclusiveMinimum": 0
1224
+ } }
1225
+ }
1226
+ }, {
1227
+ "if": { "properties": { "strategy": { "const": "num-bins" } } },
1228
+ "then": {
1229
+ "required": ["num-bins"],
1230
+ "properties": { "num-bins": {
1231
+ "type": "integer",
1232
+ "minimum": 1
1233
+ } }
1234
+ }
1235
+ }]
1236
+ },
1237
+ "source-field": { "$ref": "id.yaml#/$defs/field_id" },
1238
+ "source-field-name": { "type": "string" },
1239
+ "source-field-join-alias": { "type": "string" }
1240
+ }
1241
+ }]
1242
+ },
1243
+ "field_ref": {
1244
+ "description": "[field, options, Field-FK-or-name]",
1245
+ "type": "array",
1246
+ "prefixItems": [
1247
+ { "const": "field" },
1248
+ { "$ref": "#/$defs/field_options" },
1249
+ {
1250
+ "if": { "type": "array" },
1251
+ "then": { "$ref": "id.yaml#/$defs/field_id" }
1252
+ }
1253
+ ],
1254
+ "minItems": 3,
1255
+ "maxItems": 3
1256
+ },
1257
+ "expression_ref": {
1258
+ "description": "[expression, options, name]",
1259
+ "type": "array",
1260
+ "prefixItems": [
1261
+ { "const": "expression" },
1262
+ { "$ref": "query.yaml#/$defs/options" },
1263
+ { "type": "string" }
1264
+ ],
1265
+ "minItems": 3,
1266
+ "maxItems": 3
1267
+ },
1268
+ "aggregation_ref": {
1269
+ "description": "[aggregation, options, uuid] — uuid matches the lib/uuid on the aggregation clause",
1270
+ "type": "array",
1271
+ "prefixItems": [
1272
+ { "const": "aggregation" },
1273
+ { "$ref": "query.yaml#/$defs/options" },
1274
+ {
1275
+ "type": "string",
1276
+ "format": "uuid"
1277
+ }
1278
+ ],
1279
+ "minItems": 3,
1280
+ "maxItems": 3
1281
+ },
1282
+ "metric_ref": {
1283
+ "description": "[metric, options, entity_id]",
1284
+ "type": "array",
1285
+ "prefixItems": [
1286
+ { "const": "metric" },
1287
+ { "$ref": "query.yaml#/$defs/options" },
1288
+ { "type": "string" }
1289
+ ],
1290
+ "minItems": 3,
1291
+ "maxItems": 3
1292
+ },
1293
+ "measure_ref": {
1294
+ "description": "[measure, options, entity_id]",
1295
+ "type": "array",
1296
+ "prefixItems": [
1297
+ { "const": "measure" },
1298
+ { "$ref": "query.yaml#/$defs/options" },
1299
+ { "type": "string" }
1300
+ ],
1301
+ "minItems": 3,
1302
+ "maxItems": 3
1303
+ },
1304
+ "segment_ref": {
1305
+ "description": "[segment, options, entity_id]",
1306
+ "type": "array",
1307
+ "prefixItems": [
1308
+ { "const": "segment" },
1309
+ { "$ref": "query.yaml#/$defs/options" },
1310
+ { "type": "string" }
1311
+ ],
1312
+ "minItems": 3,
1313
+ "maxItems": 3
1314
+ },
1315
+ "legacy_field_ref": {
1316
+ "description": "[field, Field-FK-or-name, null-or-options] — legacy format used in parameter targets",
1317
+ "type": "array",
1318
+ "prefixItems": [
1319
+ { "const": "field" },
1320
+ {
1321
+ "if": { "type": "array" },
1322
+ "then": { "$ref": "id.yaml#/$defs/field_id" }
1323
+ },
1324
+ { "type": ["object", "null"] }
1325
+ ],
1326
+ "minItems": 3,
1327
+ "maxItems": 3
1328
+ },
1329
+ "legacy_expression_ref": {
1330
+ "description": "[expression, name] or [expression, name, null-or-options] — legacy format used in parameter targets",
1331
+ "type": "array",
1332
+ "prefixItems": [
1333
+ { "const": "expression" },
1334
+ { "type": "string" },
1335
+ { "type": ["object", "null"] }
1336
+ ],
1337
+ "minItems": 2,
1338
+ "maxItems": 3
1339
+ }
1340
+ };
1341
+ var ref_default = {
1342
+ title: title$1,
1343
+ description: description$1,
1344
+ $defs: $defs$1
1345
+ };
1346
+
1347
+ //#endregion
1348
+ //#region src/core/schema/data/schemas/common/temporal_bucketing.json
1349
+ var title = "Temporal Bucketing";
1350
+ var description = "Datetime truncation, extraction, and bucketing unit definitions.";
1351
+ var $defs = {
1352
+ "datetime_truncation_unit": {
1353
+ "description": "Truncation units — truncate a datetime to a boundary. Also used for intervals and datetime arithmetic.\n",
1354
+ "type": "string",
1355
+ "enum": [
1356
+ "millisecond",
1357
+ "second",
1358
+ "minute",
1359
+ "hour",
1360
+ "day",
1361
+ "week",
1362
+ "month",
1363
+ "quarter",
1364
+ "year"
1365
+ ]
1366
+ },
1367
+ "datetime_extraction_unit": {
1368
+ "description": "Extraction units — extract a numeric component from a datetime.\n",
1369
+ "type": "string",
1370
+ "enum": [
1371
+ "second-of-minute",
1372
+ "minute-of-hour",
1373
+ "hour-of-day",
1374
+ "day-of-week",
1375
+ "day-of-week-iso",
1376
+ "day-of-month",
1377
+ "day-of-year",
1378
+ "week-of-year",
1379
+ "week-of-year-iso",
1380
+ "week-of-year-us",
1381
+ "week-of-year-instance",
1382
+ "month-of-year",
1383
+ "quarter-of-year",
1384
+ "year-of-era"
1385
+ ]
1386
+ },
1387
+ "datetime_bucketing_unit": {
1388
+ "description": "All datetime units — truncation + extraction + default. Used for field temporal-unit option.\n",
1389
+ "anyOf": [
1390
+ { "const": "default" },
1391
+ { "$ref": "#/$defs/datetime_truncation_unit" },
1392
+ { "$ref": "#/$defs/datetime_extraction_unit" }
1393
+ ]
1394
+ }
1395
+ };
1396
+ var temporal_bucketing_default = {
1397
+ title,
1398
+ description,
1399
+ $defs
1400
+ };
1401
+
1402
+ //#endregion
1403
+ //#region src/core/schema/validate.ts
1404
+ const ValidationIssue = z.object({
1405
+ path: z.string(),
1406
+ message: z.string()
1407
+ });
1408
+ const ValidationOutcome = z.object({
1409
+ ok: z.boolean(),
1410
+ errors: z.array(ValidationIssue)
1411
+ });
1412
+ const POSITIVE_INTEGER = {
1413
+ type: "integer",
1414
+ minimum: 1
1415
+ };
1416
+ const internalIdSchema = {
1417
+ title: "ID (internal)",
1418
+ description: "Internal-MBQL identifier overrides — every ID is a positive integer.",
1419
+ $defs: {
1420
+ entity_id: POSITIVE_INTEGER,
1421
+ user_id: POSITIVE_INTEGER,
1422
+ database_id: POSITIVE_INTEGER,
1423
+ table_id: POSITIVE_INTEGER,
1424
+ field_id: POSITIVE_INTEGER
1425
+ }
1426
+ };
1427
+ let externalValidator = null;
1428
+ let internalValidator = null;
1429
+ function buildAjv(idVariant) {
1430
+ const ajv = new Ajv2020({
1431
+ allErrors: true,
1432
+ strictTuples: false,
1433
+ allowUnionTypes: true
1434
+ });
1435
+ addFormats(ajv);
1436
+ ajv.addSchema(idVariant, "id.yaml");
1437
+ ajv.addSchema(parameter_default, "parameter.yaml");
1438
+ ajv.addSchema(ref_default, "ref.yaml");
1439
+ ajv.addSchema(temporal_bucketing_default, "temporal_bucketing.yaml");
1440
+ ajv.addSchema(query_default, "query.yaml");
1441
+ const compiled = ajv.getSchema("query.yaml");
1442
+ if (compiled === void 0) throw new Error("internal: query.yaml validator not registered");
1443
+ return compiled;
1444
+ }
1445
+ function getExternalValidator() {
1446
+ if (externalValidator === null) externalValidator = buildAjv(id_default);
1447
+ return externalValidator;
1448
+ }
1449
+ function getInternalValidator() {
1450
+ if (internalValidator === null) internalValidator = buildAjv(internalIdSchema);
1451
+ return internalValidator;
1452
+ }
1453
+ function runValidator(validator, value) {
1454
+ if (validator(value)) return {
1455
+ ok: true,
1456
+ errors: []
1457
+ };
1458
+ const issues = validator.errors ?? [];
1459
+ const errors = issues.map((issue) => {
1460
+ if (issue.message === void 0) throw new Error(`Ajv issue at ${issue.instancePath} has no message`);
1461
+ return {
1462
+ path: issue.instancePath === "" ? "/" : issue.instancePath,
1463
+ message: issue.message
1464
+ };
1465
+ });
1466
+ return {
1467
+ ok: false,
1468
+ errors
1469
+ };
1470
+ }
1471
+ function validateExternalQuery(value) {
1472
+ return runValidator(getExternalValidator(), value);
1473
+ }
1474
+ function validateInternalQuery(value) {
1475
+ return runValidator(getInternalValidator(), value);
1476
+ }
1477
+ function isMbql5Query(value) {
1478
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
1479
+ return "lib/type" in value && value["lib/type"] === "mbql/query";
1480
+ }
1481
+ const SchemaMode = z.enum(["external", "internal"]);
1482
+ const QuerySchemaBundle = z.object({
1483
+ mode: SchemaMode,
1484
+ schema: z.unknown(),
1485
+ defs: z.object({
1486
+ "id.yaml": z.unknown(),
1487
+ "parameter.yaml": z.unknown(),
1488
+ "ref.yaml": z.unknown(),
1489
+ "temporal_bucketing.yaml": z.unknown()
1490
+ })
1491
+ });
1492
+ function getQuerySchemaBundle(mode) {
1493
+ return {
1494
+ mode,
1495
+ schema: query_default,
1496
+ defs: {
1497
+ "id.yaml": mode === "internal" ? internalIdSchema : id_default,
1498
+ "parameter.yaml": parameter_default,
1499
+ "ref.yaml": ref_default,
1500
+ "temporal_bucketing.yaml": temporal_bucketing_default
1501
+ }
1502
+ };
1503
+ }
1504
+
1505
+ //#endregion
1506
+ //#region src/commands/validate-query.ts
1507
+ const skipValidateFlag = { "skip-validate": {
1508
+ type: "boolean",
1509
+ description: "Skip the local MBQL 5 pre-flight validation; let the server be the authority. Use only when the bundled schema disagrees with what the server accepts."
1510
+ } };
1511
+ function preflightInternalMbql5Query(query, contextLabel, options) {
1512
+ if (options.skip) return;
1513
+ if (!isMbql5Query(query)) return;
1514
+ const outcome = validateInternalQuery(query);
1515
+ if (outcome.ok) return;
1516
+ writeJson(outcome);
1517
+ throw new ConfigError(`${contextLabel}: ${outcome.errors.length} error(s) — pass valid MBQL 5 or use the legacy format`);
1518
+ }
1519
+
1520
+ //#endregion
1521
+ export { getQuerySchemaBundle, preflightInternalMbql5Query, skipValidateFlag, validateExternalQuery, validateInternalQuery };