@malloydata/malloy 0.0.24-dev230224214106 → 0.0.24-dev230228224434

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 (310) hide show
  1. package/dist/connection_utils.js +10 -10
  2. package/dist/dialect/dialect.d.ts +2 -2
  3. package/dist/dialect/dialect.js +13 -13
  4. package/dist/dialect/dialect_map.d.ts +1 -1
  5. package/dist/dialect/duckdb.d.ts +3 -3
  6. package/dist/dialect/duckdb.js +44 -44
  7. package/dist/dialect/index.d.ts +6 -6
  8. package/dist/dialect/postgres.d.ts +3 -3
  9. package/dist/dialect/postgres.js +46 -46
  10. package/dist/dialect/standardsql.d.ts +4 -4
  11. package/dist/dialect/standardsql.js +51 -51
  12. package/dist/index.d.ts +10 -10
  13. package/dist/lang/ast/ast-utils.d.ts +1 -1
  14. package/dist/lang/ast/ast-utils.js +3 -3
  15. package/dist/lang/ast/elements/define-query.d.ts +3 -3
  16. package/dist/lang/ast/elements/define-query.js +6 -6
  17. package/dist/lang/ast/elements/define-source.d.ts +4 -4
  18. package/dist/lang/ast/elements/define-source.js +8 -8
  19. package/dist/lang/ast/elements/import-statement.d.ts +2 -2
  20. package/dist/lang/ast/elements/import-statement.js +7 -7
  21. package/dist/lang/ast/elements/pipeline-desc.d.ts +5 -5
  22. package/dist/lang/ast/elements/pipeline-desc.js +11 -11
  23. package/dist/lang/ast/elements/refined-source.d.ts +4 -4
  24. package/dist/lang/ast/elements/refined-source.js +6 -6
  25. package/dist/lang/ast/elements/source.d.ts +3 -3
  26. package/dist/lang/ast/elements/source.js +1 -1
  27. package/dist/lang/ast/error-factory.d.ts +1 -1
  28. package/dist/lang/ast/error-factory.js +15 -15
  29. package/dist/lang/ast/executors/index-executor.d.ts +7 -7
  30. package/dist/lang/ast/executors/index-executor.js +4 -4
  31. package/dist/lang/ast/executors/project-executor.d.ts +5 -5
  32. package/dist/lang/ast/executors/project-executor.js +2 -2
  33. package/dist/lang/ast/executors/reduce-executor.d.ts +8 -8
  34. package/dist/lang/ast/executors/reduce-executor.js +5 -5
  35. package/dist/lang/ast/expressions/apply.d.ts +2 -2
  36. package/dist/lang/ast/expressions/apply.js +1 -1
  37. package/dist/lang/ast/expressions/binary-boolean.d.ts +3 -3
  38. package/dist/lang/ast/expressions/binary-boolean.js +6 -6
  39. package/dist/lang/ast/expressions/binary-numeric.d.ts +3 -3
  40. package/dist/lang/ast/expressions/binary-numeric.js +2 -2
  41. package/dist/lang/ast/expressions/boolean.d.ts +4 -4
  42. package/dist/lang/ast/expressions/boolean.js +2 -2
  43. package/dist/lang/ast/expressions/constant-sub-expression.d.ts +4 -4
  44. package/dist/lang/ast/expressions/constant-sub-expression.js +12 -12
  45. package/dist/lang/ast/expressions/expr-add-sub.d.ts +2 -2
  46. package/dist/lang/ast/expressions/expr-add-sub.js +1 -1
  47. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +5 -5
  48. package/dist/lang/ast/expressions/expr-aggregate-function.js +15 -15
  49. package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +6 -6
  50. package/dist/lang/ast/expressions/expr-alternation-tree.js +6 -6
  51. package/dist/lang/ast/expressions/expr-asymmetric.d.ts +5 -5
  52. package/dist/lang/ast/expressions/expr-asymmetric.js +3 -3
  53. package/dist/lang/ast/expressions/expr-avg.d.ts +3 -3
  54. package/dist/lang/ast/expressions/expr-avg.js +2 -2
  55. package/dist/lang/ast/expressions/expr-cast.d.ts +4 -4
  56. package/dist/lang/ast/expressions/expr-cast.js +6 -6
  57. package/dist/lang/ast/expressions/expr-compare.d.ts +5 -5
  58. package/dist/lang/ast/expressions/expr-compare.js +9 -9
  59. package/dist/lang/ast/expressions/expr-count-distinct.d.ts +2 -2
  60. package/dist/lang/ast/expressions/expr-count-distinct.js +1 -1
  61. package/dist/lang/ast/expressions/expr-count.d.ts +4 -4
  62. package/dist/lang/ast/expressions/expr-count.js +10 -10
  63. package/dist/lang/ast/expressions/expr-filter.d.ts +4 -4
  64. package/dist/lang/ast/expressions/expr-filter.js +13 -13
  65. package/dist/lang/ast/expressions/expr-func.d.ts +3 -3
  66. package/dist/lang/ast/expressions/expr-func.js +8 -8
  67. package/dist/lang/ast/expressions/expr-granular-time.d.ts +4 -4
  68. package/dist/lang/ast/expressions/expr-granular-time.js +17 -17
  69. package/dist/lang/ast/expressions/expr-id-reference.d.ts +4 -4
  70. package/dist/lang/ast/expressions/expr-id-reference.js +11 -11
  71. package/dist/lang/ast/expressions/expr-logical-op.d.ts +2 -2
  72. package/dist/lang/ast/expressions/expr-logical-op.js +1 -1
  73. package/dist/lang/ast/expressions/expr-max.d.ts +4 -4
  74. package/dist/lang/ast/expressions/expr-max.js +1 -1
  75. package/dist/lang/ast/expressions/expr-min.d.ts +4 -4
  76. package/dist/lang/ast/expressions/expr-min.js +1 -1
  77. package/dist/lang/ast/expressions/expr-minus.d.ts +3 -3
  78. package/dist/lang/ast/expressions/expr-minus.js +5 -5
  79. package/dist/lang/ast/expressions/expr-mul-div.d.ts +2 -2
  80. package/dist/lang/ast/expressions/expr-mul-div.js +1 -1
  81. package/dist/lang/ast/expressions/expr-not.d.ts +4 -4
  82. package/dist/lang/ast/expressions/expr-not.js +3 -3
  83. package/dist/lang/ast/expressions/expr-now.d.ts +3 -3
  84. package/dist/lang/ast/expressions/expr-now.js +8 -8
  85. package/dist/lang/ast/expressions/expr-null.d.ts +2 -2
  86. package/dist/lang/ast/expressions/expr-null.js +4 -4
  87. package/dist/lang/ast/expressions/expr-number.d.ts +3 -3
  88. package/dist/lang/ast/expressions/expr-number.js +2 -2
  89. package/dist/lang/ast/expressions/expr-parens.d.ts +3 -3
  90. package/dist/lang/ast/expressions/expr-parens.js +3 -3
  91. package/dist/lang/ast/expressions/expr-regex.d.ts +2 -2
  92. package/dist/lang/ast/expressions/expr-regex.js +4 -4
  93. package/dist/lang/ast/expressions/expr-string.d.ts +3 -3
  94. package/dist/lang/ast/expressions/expr-string.js +8 -8
  95. package/dist/lang/ast/expressions/expr-sum.d.ts +3 -3
  96. package/dist/lang/ast/expressions/expr-sum.js +2 -2
  97. package/dist/lang/ast/expressions/expr-time-extract.d.ts +4 -4
  98. package/dist/lang/ast/expressions/expr-time-extract.js +30 -30
  99. package/dist/lang/ast/expressions/expr-time.d.ts +4 -4
  100. package/dist/lang/ast/expressions/expr-time.js +10 -10
  101. package/dist/lang/ast/expressions/expr-ungroup.d.ts +6 -6
  102. package/dist/lang/ast/expressions/expr-ungroup.js +13 -13
  103. package/dist/lang/ast/expressions/for-range.d.ts +4 -4
  104. package/dist/lang/ast/expressions/for-range.js +17 -17
  105. package/dist/lang/ast/expressions/granular-literal.d.ts +4 -4
  106. package/dist/lang/ast/expressions/granular-literal.js +34 -34
  107. package/dist/lang/ast/expressions/partial-compare.d.ts +4 -4
  108. package/dist/lang/ast/expressions/partial-compare.js +4 -4
  109. package/dist/lang/ast/expressions/pick-when.d.ts +4 -4
  110. package/dist/lang/ast/expressions/pick-when.js +32 -32
  111. package/dist/lang/ast/expressions/range.d.ts +3 -3
  112. package/dist/lang/ast/expressions/range.js +20 -20
  113. package/dist/lang/ast/expressions/time-frame.d.ts +2 -2
  114. package/dist/lang/ast/expressions/time-frame.js +3 -3
  115. package/dist/lang/ast/expressions/top-by.d.ts +4 -4
  116. package/dist/lang/ast/expressions/top-by.js +5 -5
  117. package/dist/lang/ast/expressions/unary.d.ts +1 -1
  118. package/dist/lang/ast/expressions/unary.js +1 -1
  119. package/dist/lang/ast/expressions/utils.d.ts +2 -2
  120. package/dist/lang/ast/expressions/utils.js +6 -6
  121. package/dist/lang/ast/field-space/column-space-field.d.ts +3 -3
  122. package/dist/lang/ast/field-space/dynamic-space.d.ts +7 -7
  123. package/dist/lang/ast/field-space/dynamic-space.js +2 -2
  124. package/dist/lang/ast/field-space/field-definition-value.d.ts +5 -5
  125. package/dist/lang/ast/field-space/index-field-space.d.ts +3 -3
  126. package/dist/lang/ast/field-space/index-field-space.js +4 -4
  127. package/dist/lang/ast/field-space/join-space-field.d.ts +3 -3
  128. package/dist/lang/ast/field-space/project-field-space.d.ts +2 -2
  129. package/dist/lang/ast/field-space/project-field-space.js +5 -5
  130. package/dist/lang/ast/field-space/query-field-struct.d.ts +3 -3
  131. package/dist/lang/ast/field-space/query-field-struct.js +1 -1
  132. package/dist/lang/ast/field-space/query-space-field.d.ts +4 -4
  133. package/dist/lang/ast/field-space/query-space-field.js +1 -1
  134. package/dist/lang/ast/field-space/query-spaces.d.ts +11 -11
  135. package/dist/lang/ast/field-space/query-spaces.js +8 -8
  136. package/dist/lang/ast/field-space/reference-field.d.ts +5 -5
  137. package/dist/lang/ast/field-space/reference-field.js +1 -1
  138. package/dist/lang/ast/field-space/refined-space.d.ts +4 -4
  139. package/dist/lang/ast/field-space/refined-space.js +2 -2
  140. package/dist/lang/ast/field-space/rename-space-field.d.ts +3 -3
  141. package/dist/lang/ast/field-space/rename-space-field.js +2 -2
  142. package/dist/lang/ast/field-space/static-space.d.ts +7 -7
  143. package/dist/lang/ast/field-space/static-space.js +12 -12
  144. package/dist/lang/ast/field-space/struct-space-field-base.d.ts +4 -4
  145. package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
  146. package/dist/lang/ast/field-space/wild-space-field.d.ts +4 -4
  147. package/dist/lang/ast/field-space/wild-space-field.js +1 -1
  148. package/dist/lang/ast/fragtype-utils.d.ts +1 -1
  149. package/dist/lang/ast/fragtype-utils.js +15 -15
  150. package/dist/lang/ast/index.d.ts +90 -90
  151. package/dist/lang/ast/parameters/constant-parameter.d.ts +3 -3
  152. package/dist/lang/ast/parameters/constant-parameter.js +10 -10
  153. package/dist/lang/ast/parameters/has-parameter.d.ts +3 -3
  154. package/dist/lang/ast/parameters/has-parameter.js +7 -7
  155. package/dist/lang/ast/query-elements/anonymous-query.d.ts +3 -3
  156. package/dist/lang/ast/query-elements/anonymous-query.js +2 -2
  157. package/dist/lang/ast/query-elements/existing-query.d.ts +4 -4
  158. package/dist/lang/ast/query-elements/existing-query.js +10 -10
  159. package/dist/lang/ast/query-elements/full-query.d.ts +4 -4
  160. package/dist/lang/ast/query-elements/full-query.js +10 -10
  161. package/dist/lang/ast/query-elements/query-head-struct.d.ts +2 -2
  162. package/dist/lang/ast/query-elements/query-head-struct.js +2 -2
  163. package/dist/lang/ast/query-items/field-declaration.d.ts +6 -6
  164. package/dist/lang/ast/query-items/field-declaration.js +14 -14
  165. package/dist/lang/ast/query-items/field-references.d.ts +6 -6
  166. package/dist/lang/ast/query-items/field-references.js +9 -9
  167. package/dist/lang/ast/query-properties/aggregate.d.ts +2 -2
  168. package/dist/lang/ast/query-properties/aggregate.js +1 -1
  169. package/dist/lang/ast/query-properties/declare-fields.d.ts +2 -2
  170. package/dist/lang/ast/query-properties/declare-fields.js +1 -1
  171. package/dist/lang/ast/query-properties/dimmensions.d.ts +2 -2
  172. package/dist/lang/ast/query-properties/dimmensions.js +1 -1
  173. package/dist/lang/ast/query-properties/filters.d.ts +4 -4
  174. package/dist/lang/ast/query-properties/filters.js +16 -16
  175. package/dist/lang/ast/query-properties/group-by.d.ts +2 -2
  176. package/dist/lang/ast/query-properties/group-by.js +1 -1
  177. package/dist/lang/ast/query-properties/indexing.d.ts +3 -3
  178. package/dist/lang/ast/query-properties/indexing.js +3 -3
  179. package/dist/lang/ast/query-properties/joins.d.ts +6 -6
  180. package/dist/lang/ast/query-properties/joins.js +27 -27
  181. package/dist/lang/ast/query-properties/limit.d.ts +1 -1
  182. package/dist/lang/ast/query-properties/limit.js +1 -1
  183. package/dist/lang/ast/query-properties/measures.d.ts +2 -2
  184. package/dist/lang/ast/query-properties/measures.js +1 -1
  185. package/dist/lang/ast/query-properties/nest-reference.d.ts +2 -2
  186. package/dist/lang/ast/query-properties/nest-reference.js +1 -1
  187. package/dist/lang/ast/query-properties/nest.d.ts +7 -7
  188. package/dist/lang/ast/query-properties/nest.js +7 -7
  189. package/dist/lang/ast/query-properties/nests.d.ts +2 -2
  190. package/dist/lang/ast/query-properties/nests.js +1 -1
  191. package/dist/lang/ast/query-properties/ordering.d.ts +3 -3
  192. package/dist/lang/ast/query-properties/ordering.js +6 -6
  193. package/dist/lang/ast/query-properties/project-statement.d.ts +2 -2
  194. package/dist/lang/ast/query-properties/project-statement.js +1 -1
  195. package/dist/lang/ast/query-properties/qop-desc.d.ts +7 -7
  196. package/dist/lang/ast/query-properties/qop-desc.js +20 -20
  197. package/dist/lang/ast/query-properties/sampling.d.ts +2 -2
  198. package/dist/lang/ast/query-properties/sampling.js +1 -1
  199. package/dist/lang/ast/query-properties/top.d.ts +4 -4
  200. package/dist/lang/ast/query-properties/top.js +5 -5
  201. package/dist/lang/ast/source-properties/field-list-edit.d.ts +4 -4
  202. package/dist/lang/ast/source-properties/field-list-edit.js +2 -2
  203. package/dist/lang/ast/source-properties/primary-key.d.ts +2 -2
  204. package/dist/lang/ast/source-properties/primary-key.js +2 -2
  205. package/dist/lang/ast/source-properties/renames.d.ts +2 -2
  206. package/dist/lang/ast/source-properties/renames.js +3 -3
  207. package/dist/lang/ast/source-properties/turtles.d.ts +2 -2
  208. package/dist/lang/ast/source-properties/turtles.js +1 -1
  209. package/dist/lang/ast/sources/named-source.d.ts +4 -4
  210. package/dist/lang/ast/sources/named-source.js +5 -5
  211. package/dist/lang/ast/sources/query-source.d.ts +3 -3
  212. package/dist/lang/ast/sources/query-source.js +3 -3
  213. package/dist/lang/ast/sources/sql-source.d.ts +2 -2
  214. package/dist/lang/ast/sources/sql-source.js +2 -2
  215. package/dist/lang/ast/sources/table-source.d.ts +2 -2
  216. package/dist/lang/ast/sources/table-source.js +7 -7
  217. package/dist/lang/ast/space-seed.d.ts +2 -2
  218. package/dist/lang/ast/space-seed.js +1 -1
  219. package/dist/lang/ast/sql-elements/sql-statement.d.ts +4 -4
  220. package/dist/lang/ast/sql-elements/sql-statement.js +9 -9
  221. package/dist/lang/ast/sql-elements/sql-string.d.ts +3 -3
  222. package/dist/lang/ast/sql-elements/sql-string.js +6 -6
  223. package/dist/lang/ast/struct-utils.d.ts +2 -2
  224. package/dist/lang/ast/struct-utils.js +3 -3
  225. package/dist/lang/ast/time-utils.d.ts +6 -6
  226. package/dist/lang/ast/time-utils.js +46 -46
  227. package/dist/lang/ast/types/document-compile-result.d.ts +2 -2
  228. package/dist/lang/ast/types/executor.d.ts +3 -3
  229. package/dist/lang/ast/types/explore-desc.d.ts +2 -2
  230. package/dist/lang/ast/types/explore-desc.js +1 -1
  231. package/dist/lang/ast/types/explore-field.d.ts +3 -3
  232. package/dist/lang/ast/types/expr-result.d.ts +2 -2
  233. package/dist/lang/ast/types/expr-value.d.ts +2 -2
  234. package/dist/lang/ast/types/expression-def.d.ts +4 -4
  235. package/dist/lang/ast/types/expression-def.js +86 -86
  236. package/dist/lang/ast/types/field-collection-member.d.ts +3 -3
  237. package/dist/lang/ast/types/field-decl.d.ts +5 -5
  238. package/dist/lang/ast/types/field-space.d.ts +5 -5
  239. package/dist/lang/ast/types/field-space.js +1 -1
  240. package/dist/lang/ast/types/granular-result.d.ts +3 -3
  241. package/dist/lang/ast/types/granular-result.js +1 -1
  242. package/dist/lang/ast/types/lookup-result.d.ts +1 -1
  243. package/dist/lang/ast/types/malloy-element.d.ts +6 -6
  244. package/dist/lang/ast/types/malloy-element.js +49 -49
  245. package/dist/lang/ast/types/model-entry.d.ts +1 -1
  246. package/dist/lang/ast/types/name-space.d.ts +1 -1
  247. package/dist/lang/ast/types/nested-query.d.ts +2 -2
  248. package/dist/lang/ast/types/op-desc.d.ts +2 -2
  249. package/dist/lang/ast/types/query-comp.d.ts +1 -1
  250. package/dist/lang/ast/types/query-element.d.ts +3 -3
  251. package/dist/lang/ast/types/query-item.d.ts +4 -4
  252. package/dist/lang/ast/types/query-property.d.ts +15 -15
  253. package/dist/lang/ast/types/source-property.d.ts +8 -8
  254. package/dist/lang/ast/types/space-entry.d.ts +2 -2
  255. package/dist/lang/ast/types/space-field.d.ts +4 -4
  256. package/dist/lang/ast/types/space-field.js +4 -4
  257. package/dist/lang/ast/types/space-param.d.ts +4 -4
  258. package/dist/lang/ast/types/space-param.js +4 -4
  259. package/dist/lang/ast/types/time-result.d.ts +2 -2
  260. package/dist/lang/ast/types/turtle-headed-pipe.d.ts +2 -2
  261. package/dist/lang/ast/types/turtle-headed-pipe.js +1 -1
  262. package/dist/lang/ast/types/type-desc.d.ts +3 -3
  263. package/dist/lang/field-utils.d.ts +1 -1
  264. package/dist/lang/field-utils.js +4 -4
  265. package/dist/lang/index.d.ts +10 -10
  266. package/dist/lang/malloy-to-ast.d.ts +8 -8
  267. package/dist/lang/malloy-to-ast.js +68 -68
  268. package/dist/lang/parse-error-handler.d.ts +3 -3
  269. package/dist/lang/parse-error-handler.js +4 -4
  270. package/dist/lang/parse-log.d.ts +2 -2
  271. package/dist/lang/parse-log.js +1 -1
  272. package/dist/lang/parse-malloy.d.ts +7 -7
  273. package/dist/lang/parse-malloy.js +81 -81
  274. package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +2 -2
  275. package/dist/lang/parse-tree-walkers/document-completion-walker.js +38 -38
  276. package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +1 -1
  277. package/dist/lang/parse-tree-walkers/document-help-context-walker.js +14 -14
  278. package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +3 -3
  279. package/dist/lang/parse-tree-walkers/document-highlight-walker.js +85 -85
  280. package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +4 -4
  281. package/dist/lang/parse-tree-walkers/document-symbol-walker.js +40 -40
  282. package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +3 -3
  283. package/dist/lang/parse-tree-walkers/explore-query-walker.js +3 -3
  284. package/dist/lang/parse-tree-walkers/find-external-references.d.ts +4 -4
  285. package/dist/lang/parse-tree-walkers/find-external-references.js +2 -2
  286. package/dist/lang/reference-list.d.ts +1 -1
  287. package/dist/lang/test/document-help-context-walker.spec.js +9 -9
  288. package/dist/lang/test/document-symbol-walker.spec.js +32 -32
  289. package/dist/lang/test/field-symbols.spec.js +87 -87
  290. package/dist/lang/test/parse.spec.d.ts +1 -1
  291. package/dist/lang/test/parse.spec.js +768 -768
  292. package/dist/lang/test/test-translator.d.ts +6 -6
  293. package/dist/lang/test/test-translator.js +159 -159
  294. package/dist/lang/translate-response.d.ts +7 -7
  295. package/dist/lang/translate-response.js +1 -1
  296. package/dist/lang/zone.d.ts +5 -5
  297. package/dist/lang/zone.js +8 -8
  298. package/dist/malloy.d.ts +7 -7
  299. package/dist/malloy.js +192 -192
  300. package/dist/model/index.d.ts +2 -2
  301. package/dist/model/malloy_query.d.ts +12 -12
  302. package/dist/model/malloy_query.js +497 -502
  303. package/dist/model/malloy_types.d.ts +68 -68
  304. package/dist/model/malloy_types.js +102 -102
  305. package/dist/model/sql_block.d.ts +1 -1
  306. package/dist/model/sql_block.js +4 -4
  307. package/dist/model/utils.d.ts +1 -1
  308. package/dist/model/utils.js +10 -10
  309. package/dist/runtime_types.d.ts +2 -2
  310. package/package.json +4 -1
package/dist/malloy.js CHANGED
@@ -28,7 +28,7 @@ const model_1 = require("./model");
28
28
  class Malloy {
29
29
  // TODO load from file built during release
30
30
  static get version() {
31
- return "0.0.1";
31
+ return '0.0.1';
32
32
  }
33
33
  static get log() {
34
34
  return Malloy._log || console;
@@ -38,25 +38,25 @@ class Malloy {
38
38
  }
39
39
  static _parse(source, url) {
40
40
  if (url === undefined) {
41
- url = new URL("internal://internal.malloy");
41
+ url = new URL('internal://internal.malloy');
42
42
  }
43
43
  const translator = new lang_1.MalloyTranslator(url.toString(), {
44
- "urls": { [url.toString()]: source }
44
+ urls: { [url.toString()]: source },
45
45
  });
46
46
  return new Parse(translator);
47
47
  }
48
- static parse({ url, urlReader, source }) {
48
+ static parse({ url, urlReader, source, }) {
49
49
  if (source !== undefined) {
50
50
  return Malloy._parse(source, url);
51
51
  }
52
52
  else {
53
53
  if (urlReader === undefined) {
54
- throw new Error("Internal Error: urlReader is required.");
54
+ throw new Error('Internal Error: urlReader is required.');
55
55
  }
56
56
  if (url === undefined) {
57
- throw new Error("Internal Error: url is required if source not present.");
57
+ throw new Error('Internal Error: url is required if source not present.');
58
58
  }
59
- return urlReader.readURL(url).then((source) => {
59
+ return urlReader.readURL(url).then(source => {
60
60
  return Malloy._parse(source, url);
61
61
  });
62
62
  }
@@ -70,7 +70,7 @@ class Malloy {
70
70
  * @param model A compiled model to build upon (optional).
71
71
  * @return A (promise of a) compiled `Model`.
72
72
  */
73
- static async compile({ urlReader, connections, parse, model }) {
73
+ static async compile({ urlReader, connections, parse, model, }) {
74
74
  const translator = parse._translator;
75
75
  // eslint-disable-next-line no-constant-condition
76
76
  while (true) {
@@ -91,8 +91,8 @@ class Malloy {
91
91
  if (result.urls) {
92
92
  for (const neededUrl of result.urls) {
93
93
  try {
94
- if (neededUrl.startsWith("internal://")) {
95
- throw new Error("In order to use relative imports, you must compile a file via a URL.");
94
+ if (neededUrl.startsWith('internal://')) {
95
+ throw new Error('In order to use relative imports, you must compile a file via a URL.');
96
96
  }
97
97
  const neededText = await urlReader.readURL(new URL(neededUrl));
98
98
  const urls = { [neededUrl]: neededText };
@@ -100,7 +100,7 @@ class Malloy {
100
100
  }
101
101
  catch (error) {
102
102
  translator.update({
103
- "errors": { "urls": { [neededUrl]: error.message } }
103
+ errors: { urls: { [neededUrl]: error.message } },
104
104
  });
105
105
  }
106
106
  }
@@ -120,14 +120,14 @@ class Malloy {
120
120
  tablesByConnection.set(connectionName, connectionToTablesMap);
121
121
  }
122
122
  // iterate over connections, fetching schema for all missing tables
123
- for (const [connectionName, connectionTableString] of tablesByConnection) {
123
+ for (const [connectionName, connectionTableString,] of tablesByConnection) {
124
124
  try {
125
125
  const connection = await connections.lookupConnection(connectionName);
126
126
  // TODO detect if the union of `Object.keys(tables)` and `Object.keys(errors)` is not the same
127
127
  // as `Object.keys(connectionTableString)`, i.e. that all tables are accounted for. Otherwise
128
128
  // the translator runs into an infinite loop fetching tables.
129
- const { "schemas": tables, errors } = await connection.fetchSchemaForTables(connectionTableString);
130
- translator.update({ tables, "errors": { "tables": errors } });
129
+ const { schemas: tables, errors } = await connection.fetchSchemaForTables(connectionTableString);
130
+ translator.update({ tables, errors: { tables: errors } });
131
131
  }
132
132
  catch (error) {
133
133
  // There was an exception getting the connection, associate that error
@@ -137,7 +137,7 @@ class Malloy {
137
137
  for (const table of connectionTableString) {
138
138
  errors[table] = error.toString();
139
139
  }
140
- translator.update({ tables, "errors": { "tables": errors } });
140
+ translator.update({ tables, errors: { tables: errors } });
141
141
  }
142
142
  }
143
143
  }
@@ -151,13 +151,13 @@ class Malloy {
151
151
  const resolved = await conn.fetchSchemaForSQLBlock(expanded);
152
152
  if (resolved.error) {
153
153
  translator.update({
154
- "errors": { "compileSQL": { [expanded.name]: resolved.error } }
154
+ errors: { compileSQL: { [expanded.name]: resolved.error } },
155
155
  });
156
156
  }
157
157
  if (resolved.structDef) {
158
158
  if ((0, model_1.isSQLBlock)(resolved.structDef)) {
159
159
  translator.update({
160
- "compileSQL": { [expanded.name]: resolved.structDef }
160
+ compileSQL: { [expanded.name]: resolved.structDef },
161
161
  });
162
162
  }
163
163
  }
@@ -165,7 +165,7 @@ class Malloy {
165
165
  catch (error) {
166
166
  const errors = {};
167
167
  errors[toCompile.name] = error.toString();
168
- translator.update({ "errors": { "compileSQL": errors } });
168
+ translator.update({ errors: { compileSQL: errors } });
169
169
  }
170
170
  }
171
171
  }
@@ -173,7 +173,7 @@ class Malloy {
173
173
  }
174
174
  static compileSQLBlock(partialModel, toCompile) {
175
175
  let queryModel;
176
- const sqlStrings = toCompile.select.map((segment) => {
176
+ const sqlStrings = toCompile.select.map(segment => {
177
177
  if ((0, model_1.isSQLFragment)(segment)) {
178
178
  return segment.sql;
179
179
  }
@@ -181,7 +181,7 @@ class Malloy {
181
181
  // TODO catch exceptions and throw errors ...
182
182
  if (!queryModel) {
183
183
  if (!partialModel) {
184
- throw new Error("Internal error: Partial model missing when compiling SQL block");
184
+ throw new Error('Internal error: Partial model missing when compiling SQL block');
185
185
  }
186
186
  queryModel = new model_1.QueryModel(partialModel);
187
187
  }
@@ -190,65 +190,65 @@ class Malloy {
190
190
  });
191
191
  const { name, connection } = toCompile;
192
192
  return {
193
- "type": "sqlBlock",
193
+ type: 'sqlBlock',
194
194
  name,
195
195
  connection,
196
- "selectStr": sqlStrings.join("")
196
+ selectStr: sqlStrings.join(''),
197
197
  };
198
198
  }
199
- static async run({ connections, preparedResult, sqlStruct, connection, options }) {
199
+ static async run({ connections, preparedResult, sqlStruct, connection, options, }) {
200
200
  const sqlBlock = sqlStruct === null || sqlStruct === void 0 ? void 0 : sqlStruct.structSource.sqlBlock;
201
201
  if (!connection) {
202
202
  if (!connections) {
203
- throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");
203
+ throw new Error('Internal Error: Connection or LookupConnection<Connection> must be provided.');
204
204
  }
205
205
  const connectionName = (sqlBlock === null || sqlBlock === void 0 ? void 0 : sqlBlock.connection) || (preparedResult === null || preparedResult === void 0 ? void 0 : preparedResult.connectionName);
206
206
  connection = await connections.lookupConnection(connectionName);
207
207
  }
208
208
  if (sqlStruct && sqlBlock) {
209
- if (sqlStruct.structRelationship.type !== "basetable") {
209
+ if (sqlStruct.structRelationship.type !== 'basetable') {
210
210
  throw new Error("Expected schema's structRelationship type to be 'basetable'.");
211
211
  }
212
212
  const data = await connection.runSQL(sqlBlock.selectStr);
213
213
  return new Result({
214
- "structs": [sqlStruct],
215
- "sql": sqlBlock.selectStr,
216
- "result": data.rows,
217
- "totalRows": data.totalRows,
218
- "lastStageName": sqlBlock.name,
214
+ structs: [sqlStruct],
215
+ sql: sqlBlock.selectStr,
216
+ result: data.rows,
217
+ totalRows: data.totalRows,
218
+ lastStageName: sqlBlock.name,
219
219
  // TODO feature-sql-block There is no malloy code...
220
- "malloy": "",
221
- "connectionName": sqlStruct.structRelationship.connectionName,
220
+ malloy: '',
221
+ connectionName: sqlStruct.structRelationship.connectionName,
222
222
  // TODO feature-sql-block There is no source explore...
223
- "sourceExplore": "",
224
- "sourceFilters": []
223
+ sourceExplore: '',
224
+ sourceFilters: [],
225
225
  }, {
226
- "name": "empty_model",
227
- "exports": [],
228
- "contents": {}
226
+ name: 'empty_model',
227
+ exports: [],
228
+ contents: {},
229
229
  });
230
230
  }
231
231
  else if (preparedResult) {
232
232
  const result = await connection.runSQL(preparedResult.sql, options);
233
233
  return new Result({
234
234
  ...preparedResult._rawQuery,
235
- "result": result.rows,
236
- "totalRows": result.totalRows
235
+ result: result.rows,
236
+ totalRows: result.totalRows,
237
237
  }, preparedResult._modelDef);
238
238
  }
239
239
  else {
240
- throw new Error("Internal error: sqlStruct or preparedResult must be provided.");
240
+ throw new Error('Internal error: sqlStruct or preparedResult must be provided.');
241
241
  }
242
242
  }
243
- static async *runStream({ connections, preparedResult, sqlStruct, connection, options }) {
243
+ static async *runStream({ connections, preparedResult, sqlStruct, connection, options, }) {
244
244
  const sqlBlock = sqlStruct === null || sqlStruct === void 0 ? void 0 : sqlStruct.structSource.sqlBlock;
245
245
  if (sqlBlock === undefined && preparedResult === undefined) {
246
- throw new Error("Internal error: sqlBlock or preparedResult must be provided.");
246
+ throw new Error('Internal error: sqlBlock or preparedResult must be provided.');
247
247
  }
248
248
  const connectionName = (sqlBlock === null || sqlBlock === void 0 ? void 0 : sqlBlock.connection) || (preparedResult === null || preparedResult === void 0 ? void 0 : preparedResult.connectionName);
249
249
  if (connection === undefined) {
250
250
  if (connections === undefined) {
251
- throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");
251
+ throw new Error('Internal Error: Connection or LookupConnection<Connection> must be provided.');
252
252
  }
253
253
  connection = await connections.lookupConnection(connectionName);
254
254
  }
@@ -259,7 +259,7 @@ class Malloy {
259
259
  let sql;
260
260
  let resultExplore;
261
261
  if (sqlStruct) {
262
- if (sqlStruct.structRelationship.type !== "basetable") {
262
+ if (sqlStruct.structRelationship.type !== 'basetable') {
263
263
  throw new Error("Expected schema's structRelationship type to be 'basetable'.");
264
264
  }
265
265
  resultExplore = new Explore(sqlStruct);
@@ -270,7 +270,7 @@ class Malloy {
270
270
  sql = preparedResult.sql;
271
271
  }
272
272
  else {
273
- throw new Error("Internal error: sqlStruct or preparedResult must be provided.");
273
+ throw new Error('Internal error: sqlStruct or preparedResult must be provided.');
274
274
  }
275
275
  let index = 0;
276
276
  for await (const row of connection.runSQLStream(sql, options)) {
@@ -318,10 +318,10 @@ class Model {
318
318
  */
319
319
  getPreparedQueryByName(queryName) {
320
320
  const query = this.modelDef.contents[queryName];
321
- if (query.type === "query") {
321
+ if (query.type === 'query') {
322
322
  return new PreparedQuery(query, this.modelDef, queryName);
323
323
  }
324
- throw new Error("Given query name does not refer to a named query.");
324
+ throw new Error('Given query name does not refer to a named query.');
325
325
  }
326
326
  /**
327
327
  * Retrieve a prepared query by the index of an unnamed query at the top level of a model.
@@ -345,7 +345,7 @@ class Model {
345
345
  * @return A prepared query.
346
346
  */
347
347
  getSQLBlockByName(sqlBlockName) {
348
- const sqlBlock = this.sqlBlocks.find((sqlBlock) => sqlBlock.as === sqlBlockName);
348
+ const sqlBlock = this.sqlBlocks.find(sqlBlock => sqlBlock.as === sqlBlockName);
349
349
  if (sqlBlock === undefined) {
350
350
  throw new Error(`No SQL Block named '${sqlBlockName}'`);
351
351
  }
@@ -371,7 +371,7 @@ class Model {
371
371
  */
372
372
  get preparedQuery() {
373
373
  if (this.queryList.length === 0) {
374
- throw new Error("Model has no queries.");
374
+ throw new Error('Model has no queries.');
375
375
  }
376
376
  return new PreparedQuery(this.queryList[this.queryList.length - 1], this.modelDef);
377
377
  }
@@ -383,10 +383,10 @@ class Model {
383
383
  */
384
384
  getExploreByName(name) {
385
385
  const struct = this.modelDef.contents[name];
386
- if (struct.type === "struct") {
386
+ if (struct.type === 'struct') {
387
387
  return new Explore(struct);
388
388
  }
389
- throw new Error(`'name' is not an explore`);
389
+ throw new Error("'name' is not an explore");
390
390
  }
391
391
  /**
392
392
  * Get an array of `Explore`s contained in the model.
@@ -397,14 +397,14 @@ class Model {
397
397
  const explores = [];
398
398
  for (const me in this.modelDef.contents) {
399
399
  const ent = this.modelDef.contents[me];
400
- if (ent.type === "struct") {
400
+ if (ent.type === 'struct') {
401
401
  explores.push(new Explore(ent));
402
402
  }
403
403
  }
404
404
  return explores;
405
405
  }
406
406
  get exportedExplores() {
407
- return this.explores.filter((explore) => this.modelDef.exports.includes(explore.name));
407
+ return this.explores.filter(explore => this.modelDef.exports.includes(explore.name));
408
408
  }
409
409
  get _modelDef() {
410
410
  return this.modelDef;
@@ -430,16 +430,16 @@ class PreparedQuery {
430
430
  const translatedQuery = queryModel.compileQuery(this._query);
431
431
  return new PreparedResult({
432
432
  ...translatedQuery,
433
- "queryName": this.name || translatedQuery.queryName
433
+ queryName: this.name || translatedQuery.queryName,
434
434
  }, this._modelDef);
435
435
  }
436
436
  get dialect() {
437
437
  const sourceRef = this._query.structRef;
438
- const source = typeof sourceRef === "string"
438
+ const source = typeof sourceRef === 'string'
439
439
  ? this._modelDef.contents[sourceRef]
440
440
  : sourceRef;
441
- if (source.type !== "struct") {
442
- throw new Error("Invalid source for query");
441
+ if (source.type !== 'struct') {
442
+ throw new Error('Invalid source for query');
443
443
  }
444
444
  return source.dialect;
445
445
  }
@@ -448,15 +448,15 @@ class PreparedQuery {
448
448
  */
449
449
  getFlattenedQuery(defaultName) {
450
450
  let structRef = this._query.structRef;
451
- if (typeof structRef !== "string") {
451
+ if (typeof structRef !== 'string') {
452
452
  structRef = structRef.as || structRef.name;
453
453
  }
454
454
  const turtleDef = (0, model_1.flattenQuery)(this._modelDef, {
455
455
  ...this._query,
456
- "type": "query",
457
- "name": "as" in this._query ? this._query.as || this._query.name : defaultName
456
+ type: 'query',
457
+ name: 'as' in this._query ? this._query.as || this._query.name : defaultName,
458
458
  });
459
- return new PreparedQuery({ ...turtleDef, structRef, "type": "query" }, this._modelDef, this.name || turtleDef.as || turtleDef.name);
459
+ return new PreparedQuery({ ...turtleDef, structRef, type: 'query' }, this._modelDef, this.name || turtleDef.as || turtleDef.name);
460
460
  }
461
461
  }
462
462
  exports.PreparedQuery = PreparedQuery;
@@ -464,10 +464,10 @@ function parseTableURI(tableURI) {
464
464
  const parts = tableURI.match(/^([^:]*):(.*)$/);
465
465
  if (parts) {
466
466
  const [, firstPart, secondPart] = parts;
467
- return { "connectionName": firstPart, "tablePath": secondPart };
467
+ return { connectionName: firstPart, tablePath: secondPart };
468
468
  }
469
469
  else {
470
- return { "tablePath": tableURI };
470
+ return { tablePath: tableURI };
471
471
  }
472
472
  }
473
473
  exports.parseTableURI = parseTableURI;
@@ -487,7 +487,7 @@ class Parse {
487
487
  * @return An array of document highlights.
488
488
  */
489
489
  get highlights() {
490
- return (this.translator.metadata().highlights || []).map((highlight) => new DocumentHighlight(highlight));
490
+ return (this.translator.metadata().highlights || []).map(highlight => new DocumentHighlight(highlight));
491
491
  }
492
492
  /**
493
493
  * Retrieve the symbols defined in the parsed document.
@@ -498,13 +498,13 @@ class Parse {
498
498
  * @return An array of document symbols.
499
499
  */
500
500
  get symbols() {
501
- return (this.translator.metadata().symbols || []).map((symbol) => new DocumentSymbol(symbol));
501
+ return (this.translator.metadata().symbols || []).map(symbol => new DocumentSymbol(symbol));
502
502
  }
503
503
  get _translator() {
504
504
  return this.translator;
505
505
  }
506
506
  completions(position) {
507
- return (this.translator.completions(position).completions || []).map((completion) => new DocumentCompletion(completion));
507
+ return (this.translator.completions(position).completions || []).map(completion => new DocumentCompletion(completion));
508
508
  }
509
509
  helpContext(position) {
510
510
  return this.translator.helpContext(position).helpContext;
@@ -561,8 +561,8 @@ class DocumentRange {
561
561
  */
562
562
  toJSON() {
563
563
  return {
564
- "start": this.start.toJSON(),
565
- "end": this.end.toJSON()
564
+ start: this.start.toJSON(),
565
+ end: this.end.toJSON(),
566
566
  };
567
567
  }
568
568
  }
@@ -591,7 +591,7 @@ class DocumentPosition {
591
591
  * @return This position in JSON format.
592
592
  */
593
593
  toJSON() {
594
- return { "line": this.line, "character": this.character };
594
+ return { line: this.line, character: this.character };
595
595
  }
596
596
  }
597
597
  exports.DocumentPosition = DocumentPosition;
@@ -605,7 +605,7 @@ class DocumentSymbol {
605
605
  this._range = new DocumentRange(new DocumentPosition(documentSymbol.range.start.line, documentSymbol.range.start.character), new DocumentPosition(documentSymbol.range.end.line, documentSymbol.range.end.character));
606
606
  this._type = documentSymbol.type;
607
607
  this._name = documentSymbol.name;
608
- this._children = documentSymbol.children.map((child) => new DocumentSymbol(child));
608
+ this._children = documentSymbol.children.map(child => new DocumentSymbol(child));
609
609
  }
610
610
  /**
611
611
  * @return The range of characters in the source Malloy document that define this symbol.
@@ -677,12 +677,12 @@ class PreparedResult {
677
677
  */
678
678
  get resultExplore() {
679
679
  if (this.inner.structs.length === 0) {
680
- throw new Error("Malformed query result.");
680
+ throw new Error('Malformed query result.');
681
681
  }
682
682
  const explore = this.inner.structs[this.inner.structs.length - 1];
683
683
  const namedExplore = {
684
684
  ...explore,
685
- "name": this.inner.queryName || explore.name
685
+ name: this.inner.queryName || explore.name,
686
686
  };
687
687
  // TODO `sourceExplore` is not fully-implemented yet -- it cannot
688
688
  // handle cases where the source of the query is something other than
@@ -698,9 +698,9 @@ class PreparedResult {
698
698
  const name = this.inner.sourceExplore;
699
699
  const explore = this.modelDef.contents[name];
700
700
  if (explore === undefined) {
701
- throw new Error("Malformed query result.");
701
+ throw new Error('Malformed query result.');
702
702
  }
703
- if (explore.type === "struct") {
703
+ if (explore.type === 'struct') {
704
704
  return new Explore(explore);
705
705
  }
706
706
  throw new Error(`'${name} is not an explore`);
@@ -720,7 +720,7 @@ exports.PreparedResult = PreparedResult;
720
720
  */
721
721
  class EmptyURLReader {
722
722
  async readURL(_url) {
723
- throw new Error("No files.");
723
+ throw new Error('No files.');
724
724
  }
725
725
  }
726
726
  exports.EmptyURLReader = EmptyURLReader;
@@ -763,7 +763,7 @@ class FixedConnectionMap {
763
763
  connectionName = this.defaultConnectionName;
764
764
  }
765
765
  else {
766
- throw new Error("No default connection.");
766
+ throw new Error('No default connection.');
767
767
  }
768
768
  }
769
769
  const connection = this.connections.get(connectionName);
@@ -778,7 +778,7 @@ class FixedConnectionMap {
778
778
  return this.getConnection(connectionName);
779
779
  }
780
780
  static fromArray(connections) {
781
- return new FixedConnectionMap(new Map(connections.map((connection) => [connection.name, connection])));
781
+ return new FixedConnectionMap(new Map(connections.map(connection => [connection.name, connection])));
782
782
  }
783
783
  }
784
784
  exports.FixedConnectionMap = FixedConnectionMap;
@@ -855,22 +855,22 @@ class Explore extends Entity {
855
855
  }
856
856
  getQueryByName(name) {
857
857
  const internalQuery = {
858
- "type": "query",
859
- "structRef": this.structDef,
860
- "pipeline": [
858
+ type: 'query',
859
+ structRef: this.structDef,
860
+ pipeline: [
861
861
  {
862
- "type": "reduce",
863
- "fields": [name]
864
- }
865
- ]
862
+ type: 'reduce',
863
+ fields: [name],
864
+ },
865
+ ],
866
866
  };
867
867
  return new PreparedQuery(internalQuery, this.modelDef, name);
868
868
  }
869
869
  get modelDef() {
870
870
  return {
871
- "name": "generated_model",
872
- "exports": [],
873
- "contents": { [this.structDef.name]: this.structDef }
871
+ name: 'generated_model',
872
+ exports: [],
873
+ contents: { [this.structDef.name]: this.structDef },
874
874
  };
875
875
  }
876
876
  getSingleExploreModel() {
@@ -880,45 +880,45 @@ class Explore extends Entity {
880
880
  var _a;
881
881
  if (this._fieldMap === undefined) {
882
882
  const sourceFields = ((_a = this.source) === null || _a === void 0 ? void 0 : _a.fieldMap) || new Map();
883
- this._fieldMap = new Map(this.structDef.fields.map((fieldDef) => {
883
+ this._fieldMap = new Map(this.structDef.fields.map(fieldDef => {
884
884
  const name = fieldDef.as || fieldDef.name;
885
885
  const sourceField = sourceFields.get(fieldDef.name);
886
- if (fieldDef.type === "struct") {
886
+ if (fieldDef.type === 'struct') {
887
887
  return [name, new ExploreField(fieldDef, this, sourceField)];
888
888
  }
889
- else if (fieldDef.type === "turtle") {
889
+ else if (fieldDef.type === 'turtle') {
890
890
  return [name, new QueryField(fieldDef, this, sourceField)];
891
891
  }
892
892
  else {
893
- if (fieldDef.type === "string") {
893
+ if (fieldDef.type === 'string') {
894
894
  return [name, new StringField(fieldDef, this, sourceField)];
895
895
  }
896
- else if (fieldDef.type === "number") {
896
+ else if (fieldDef.type === 'number') {
897
897
  return [name, new NumberField(fieldDef, this, sourceField)];
898
898
  }
899
- else if (fieldDef.type === "date") {
899
+ else if (fieldDef.type === 'date') {
900
900
  // TODO this is a hack
901
901
  // Is this a bug? The extraction functions don't seem like they should return a
902
902
  // field of type "date". Rather, they should be of type "number".
903
903
  if (fieldDef.timeframe &&
904
- ["day_of_month", "day_of_week", "day_of_year"].includes(fieldDef.timeframe)) {
904
+ ['day_of_month', 'day_of_week', 'day_of_year'].includes(fieldDef.timeframe)) {
905
905
  return [
906
906
  name,
907
- new NumberField({ ...fieldDef, "type": "number" }, this, sourceField)
907
+ new NumberField({ ...fieldDef, type: 'number' }, this, sourceField),
908
908
  ];
909
909
  }
910
910
  return [name, new DateField(fieldDef, this, sourceField)];
911
911
  }
912
- else if (fieldDef.type === "timestamp") {
912
+ else if (fieldDef.type === 'timestamp') {
913
913
  return [name, new TimestampField(fieldDef, this, sourceField)];
914
914
  }
915
- else if (fieldDef.type === "boolean") {
915
+ else if (fieldDef.type === 'boolean') {
916
916
  return [name, new BooleanField(fieldDef, this, sourceField)];
917
917
  }
918
- else if (fieldDef.type === "json") {
918
+ else if (fieldDef.type === 'json') {
919
919
  return [name, new JSONField(fieldDef, this, sourceField)];
920
920
  }
921
- else if (fieldDef.type === "unsupported") {
921
+ else if (fieldDef.type === 'unsupported') {
922
922
  return [name, new UnsupportedField(fieldDef, this, sourceField)];
923
923
  }
924
924
  }
@@ -930,7 +930,7 @@ class Explore extends Entity {
930
930
  return [...this.fieldMap.values()];
931
931
  }
932
932
  get intrinsicFields() {
933
- return [...this.fieldMap.values()].filter((f) => f.isIntrinsic());
933
+ return [...this.fieldMap.values()].filter(f => f.isIntrinsic());
934
934
  }
935
935
  getFieldByName(fieldName) {
936
936
  const field = this.fieldMap.get(fieldName);
@@ -950,17 +950,17 @@ class Explore extends Entity {
950
950
  }
951
951
  get sourceRelationship() {
952
952
  switch (this.structDef.structRelationship.type) {
953
- case "many":
953
+ case 'many':
954
954
  return SourceRelationship.Many;
955
- case "one":
955
+ case 'one':
956
956
  return SourceRelationship.One;
957
- case "cross":
957
+ case 'cross':
958
958
  return SourceRelationship.Cross;
959
- case "inline":
959
+ case 'inline':
960
960
  return SourceRelationship.Inline;
961
- case "nested":
961
+ case 'nested':
962
962
  return SourceRelationship.Nested;
963
- case "basetable":
963
+ case 'basetable':
964
964
  return SourceRelationship.BaseTable;
965
965
  }
966
966
  }
@@ -999,19 +999,19 @@ class AtomicField extends Entity {
999
999
  }
1000
1000
  get type() {
1001
1001
  switch (this.fieldTypeDef.type) {
1002
- case "string":
1002
+ case 'string':
1003
1003
  return AtomicFieldType.String;
1004
- case "boolean":
1004
+ case 'boolean':
1005
1005
  return AtomicFieldType.Boolean;
1006
- case "date":
1006
+ case 'date':
1007
1007
  return AtomicFieldType.Date;
1008
- case "timestamp":
1008
+ case 'timestamp':
1009
1009
  return AtomicFieldType.Timestamp;
1010
- case "number":
1010
+ case 'number':
1011
1011
  return AtomicFieldType.Number;
1012
- case "json":
1012
+ case 'json':
1013
1013
  return AtomicFieldType.Json;
1014
- case "unsupported":
1014
+ case 'unsupported':
1015
1015
  return AtomicFieldType.Unsupported;
1016
1016
  }
1017
1017
  }
@@ -1042,16 +1042,16 @@ class AtomicField extends Entity {
1042
1042
  // was the field generated from a measure in the previous query
1043
1043
  sourceWasMeasure() {
1044
1044
  var _a;
1045
- return ((_a = this.fieldTypeDef.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === "measure";
1045
+ return ((_a = this.fieldTypeDef.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'measure';
1046
1046
  }
1047
1047
  sourceWasMeasureLike() {
1048
1048
  var _a, _b;
1049
- return (((_a = this.fieldTypeDef.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === "measure" ||
1050
- ((_b = this.fieldTypeDef.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) === "struct");
1049
+ return (((_a = this.fieldTypeDef.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'measure' ||
1050
+ ((_b = this.fieldTypeDef.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) === 'struct');
1051
1051
  }
1052
1052
  sourceWasDimension() {
1053
1053
  var _a;
1054
- return ((_a = this.fieldTypeDef.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === "dimension";
1054
+ return ((_a = this.fieldTypeDef.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'dimension';
1055
1055
  }
1056
1056
  hasParentExplore() {
1057
1057
  return true;
@@ -1117,15 +1117,15 @@ class DateField extends AtomicField {
1117
1117
  return undefined;
1118
1118
  }
1119
1119
  switch (this.fieldDateDef.timeframe) {
1120
- case "day":
1120
+ case 'day':
1121
1121
  return DateTimeframe.Day;
1122
- case "week":
1122
+ case 'week':
1123
1123
  return DateTimeframe.Week;
1124
- case "month":
1124
+ case 'month':
1125
1125
  return DateTimeframe.Month;
1126
- case "quarter":
1126
+ case 'quarter':
1127
1127
  return DateTimeframe.Quarter;
1128
- case "year":
1128
+ case 'year':
1129
1129
  return DateTimeframe.Year;
1130
1130
  }
1131
1131
  }
@@ -1141,21 +1141,21 @@ class TimestampField extends AtomicField {
1141
1141
  return undefined;
1142
1142
  }
1143
1143
  switch (this.fieldTimestampDef.timeframe) {
1144
- case "day":
1144
+ case 'day':
1145
1145
  return TimestampTimeframe.Day;
1146
- case "week":
1146
+ case 'week':
1147
1147
  return TimestampTimeframe.Week;
1148
- case "month":
1148
+ case 'month':
1149
1149
  return TimestampTimeframe.Month;
1150
- case "quarter":
1150
+ case 'quarter':
1151
1151
  return TimestampTimeframe.Quarter;
1152
- case "year":
1152
+ case 'year':
1153
1153
  return TimestampTimeframe.Year;
1154
- case "second":
1154
+ case 'second':
1155
1155
  return TimestampTimeframe.Second;
1156
- case "hour":
1156
+ case 'hour':
1157
1157
  return TimestampTimeframe.Hour;
1158
- case "minute":
1158
+ case 'minute':
1159
1159
  return TimestampTimeframe.Minute;
1160
1160
  }
1161
1161
  }
@@ -1251,17 +1251,17 @@ class ExploreField extends Explore {
1251
1251
  }
1252
1252
  get joinRelationship() {
1253
1253
  switch (this.structDef.structRelationship.type) {
1254
- case "one":
1254
+ case 'one':
1255
1255
  return JoinRelationship.OneToMany;
1256
- case "many":
1257
- case "cross":
1256
+ case 'many':
1257
+ case 'cross':
1258
1258
  return JoinRelationship.ManyToOne;
1259
- case "inline":
1259
+ case 'inline':
1260
1260
  return JoinRelationship.OneToOne;
1261
- case "nested":
1261
+ case 'nested':
1262
1262
  return JoinRelationship.ManyToOne;
1263
1263
  default:
1264
- throw new Error("An explore field must have a join relationship.");
1264
+ throw new Error('An explore field must have a join relationship.');
1265
1265
  }
1266
1266
  }
1267
1267
  isQueryField() {
@@ -1298,7 +1298,7 @@ class Runtime {
1298
1298
  }
1299
1299
  else {
1300
1300
  connections = {
1301
- "lookupConnection": () => Promise.resolve(arg)
1301
+ lookupConnection: () => Promise.resolve(arg),
1302
1302
  };
1303
1303
  }
1304
1304
  }
@@ -1306,7 +1306,7 @@ class Runtime {
1306
1306
  urlReader = new EmptyURLReader();
1307
1307
  }
1308
1308
  if (connections === undefined) {
1309
- throw new Error("A LookupConnection<Connection> or Connection is required.");
1309
+ throw new Error('A LookupConnection<Connection> or Connection is required.');
1310
1310
  }
1311
1311
  this._urlReader = urlReader;
1312
1312
  this._connections = connections;
@@ -1334,16 +1334,16 @@ class Runtime {
1334
1334
  return new ModelMaterializer(this, async () => {
1335
1335
  const parse = source instanceof URL
1336
1336
  ? await Malloy.parse({
1337
- "url": source,
1338
- "urlReader": this.urlReader
1337
+ url: source,
1338
+ urlReader: this.urlReader,
1339
1339
  })
1340
1340
  : Malloy.parse({
1341
- source
1341
+ source,
1342
1342
  });
1343
1343
  return Malloy.compile({
1344
- "urlReader": this.urlReader,
1345
- "connections": this.connections,
1346
- parse
1344
+ urlReader: this.urlReader,
1345
+ connections: this.connections,
1346
+ parse,
1347
1347
  });
1348
1348
  });
1349
1349
  }
@@ -1352,7 +1352,7 @@ class Runtime {
1352
1352
  // `ModelDef` to the world formally. For now, this should only
1353
1353
  // be used in tests.
1354
1354
  _loadModelFromModelDef(modelDef) {
1355
- return new ModelMaterializer(this, async function materialize() {
1355
+ return new ModelMaterializer(this, async () => {
1356
1356
  return new Model(modelDef, [], []);
1357
1357
  });
1358
1358
  }
@@ -1591,18 +1591,18 @@ class ModelMaterializer extends FluentState {
1591
1591
  const connections = this.runtime.connections;
1592
1592
  const parse = query instanceof URL
1593
1593
  ? await Malloy.parse({
1594
- "url": query,
1595
- urlReader
1594
+ url: query,
1595
+ urlReader,
1596
1596
  })
1597
1597
  : Malloy.parse({
1598
- "source": query
1598
+ source: query,
1599
1599
  });
1600
1600
  const model = await this.getModel();
1601
1601
  const queryModel = await Malloy.compile({
1602
1602
  urlReader,
1603
1603
  connections,
1604
1604
  parse,
1605
- model
1605
+ model,
1606
1606
  });
1607
1607
  return queryModel.preparedQuery;
1608
1608
  });
@@ -1611,7 +1611,7 @@ class ModelMaterializer extends FluentState {
1611
1611
  const model = await this.materialize();
1612
1612
  const queryModel = new model_1.QueryModel(model._modelDef);
1613
1613
  const schema = model.getExploreByName(sourceName).structDef;
1614
- if (schema.structRelationship.type !== "basetable") {
1614
+ if (schema.structRelationship.type !== 'basetable') {
1615
1615
  throw new Error("Expected schema's structRelationship type to be 'basetable'.");
1616
1616
  }
1617
1617
  const connectionName = schema.structRelationship.connectionName;
@@ -1621,12 +1621,12 @@ class ModelMaterializer extends FluentState {
1621
1621
  async searchValueMap(sourceName, limit = 10) {
1622
1622
  const model = await this.materialize();
1623
1623
  const schema = model.getExploreByName(sourceName);
1624
- if (schema.structDef.structRelationship.type !== "basetable") {
1624
+ if (schema.structDef.structRelationship.type !== 'basetable') {
1625
1625
  throw new Error("Expected schema's structRelationship type to be 'basetable'.");
1626
1626
  }
1627
- let indexQuery = "{index: *}";
1628
- if (schema.getFieldByNameIfExists("search_index")) {
1629
- indexQuery = "search_index";
1627
+ let indexQuery = '{index: *}';
1628
+ if (schema.getFieldByNameIfExists('search_index')) {
1629
+ indexQuery = 'search_index';
1630
1630
  }
1631
1631
  const searchMapMalloy = `
1632
1632
  query: ${sourceName}
@@ -1644,7 +1644,7 @@ class ModelMaterializer extends FluentState {
1644
1644
  }
1645
1645
  `;
1646
1646
  const result = await this.loadQuery(searchMapMalloy).run({
1647
- "rowLimit": 1000
1647
+ rowLimit: 1000,
1648
1648
  });
1649
1649
  return result._queryResult.result;
1650
1650
  }
@@ -1889,8 +1889,8 @@ class SQLBlockMaterializer extends FluentState {
1889
1889
  const connections = this.runtime.connections;
1890
1890
  return Malloy.run({
1891
1891
  connections,
1892
- "sqlStruct": sqlBlock,
1893
- options
1892
+ sqlStruct: sqlBlock,
1893
+ options,
1894
1894
  });
1895
1895
  }
1896
1896
  async *runStream(options) {
@@ -1980,7 +1980,7 @@ class Result extends PreparedResult {
1980
1980
  return this.inner.totalRows;
1981
1981
  }
1982
1982
  toJSON() {
1983
- return { "queryResult": this.inner, "modelDef": this._modelDef };
1983
+ return { queryResult: this.inner, modelDef: this._modelDef };
1984
1984
  }
1985
1985
  static fromJSON({ queryResult, modelDef }) {
1986
1986
  return new Result(queryResult, modelDef);
@@ -2001,7 +2001,7 @@ class Data {
2001
2001
  if (this.isString()) {
2002
2002
  return this;
2003
2003
  }
2004
- throw new Error("Not a string.");
2004
+ throw new Error('Not a string.');
2005
2005
  }
2006
2006
  isBoolean() {
2007
2007
  return this instanceof DataBoolean;
@@ -2010,7 +2010,7 @@ class Data {
2010
2010
  if (this.isBoolean()) {
2011
2011
  return this;
2012
2012
  }
2013
- throw new Error("Not a boolean.");
2013
+ throw new Error('Not a boolean.');
2014
2014
  }
2015
2015
  isNumber() {
2016
2016
  return this instanceof DataNumber;
@@ -2019,7 +2019,7 @@ class Data {
2019
2019
  if (this.isNumber()) {
2020
2020
  return this;
2021
2021
  }
2022
- throw new Error("Not a number.");
2022
+ throw new Error('Not a number.');
2023
2023
  }
2024
2024
  isTimestamp() {
2025
2025
  return this instanceof DataTimestamp;
@@ -2028,7 +2028,7 @@ class Data {
2028
2028
  if (this.isTimestamp()) {
2029
2029
  return this;
2030
2030
  }
2031
- throw new Error("Not a timestamp.");
2031
+ throw new Error('Not a timestamp.');
2032
2032
  }
2033
2033
  isDate() {
2034
2034
  return this instanceof DataDate;
@@ -2037,7 +2037,7 @@ class Data {
2037
2037
  if (this.isDate()) {
2038
2038
  return this;
2039
2039
  }
2040
- throw new Error("Not a date.");
2040
+ throw new Error('Not a date.');
2041
2041
  }
2042
2042
  isNull() {
2043
2043
  return this instanceof DataNull;
@@ -2049,7 +2049,7 @@ class Data {
2049
2049
  if (this.isBytes()) {
2050
2050
  return this;
2051
2051
  }
2052
- throw new Error("Not bytes.");
2052
+ throw new Error('Not bytes.');
2053
2053
  }
2054
2054
  isRecord() {
2055
2055
  return this instanceof DataRecord;
@@ -2058,7 +2058,7 @@ class Data {
2058
2058
  if (this.isRecord()) {
2059
2059
  return this;
2060
2060
  }
2061
- throw new Error("Not a record.");
2061
+ throw new Error('Not a record.');
2062
2062
  }
2063
2063
  isUnsupported() {
2064
2064
  return this instanceof DataUnsupported;
@@ -2067,7 +2067,7 @@ class Data {
2067
2067
  if (this.isUnsupported()) {
2068
2068
  return this;
2069
2069
  }
2070
- throw new Error("Not unsupported.");
2070
+ throw new Error('Not unsupported.');
2071
2071
  }
2072
2072
  isArray() {
2073
2073
  return this instanceof DataArray;
@@ -2076,13 +2076,13 @@ class Data {
2076
2076
  if (this.isArray()) {
2077
2077
  return this;
2078
2078
  }
2079
- throw new Error("Not an array.");
2079
+ throw new Error('Not an array.');
2080
2080
  }
2081
2081
  isArrayOrRecord() {
2082
2082
  if (this instanceof DataArray || this instanceof DataRecord) {
2083
2083
  return this;
2084
2084
  }
2085
- throw new Error("No Array or Record");
2085
+ throw new Error('No Array or Record');
2086
2086
  }
2087
2087
  }
2088
2088
  class ScalarData extends Data {
@@ -2153,10 +2153,10 @@ class DataTimestamp extends ScalarData {
2153
2153
  if (this._value instanceof Date) {
2154
2154
  return this._value;
2155
2155
  }
2156
- else if (typeof this._value === "number") {
2156
+ else if (typeof this._value === 'number') {
2157
2157
  return new Date(this._value);
2158
2158
  }
2159
- else if (typeof this._value !== "string") {
2159
+ else if (typeof this._value !== 'string') {
2160
2160
  return new Date(this._value.value);
2161
2161
  }
2162
2162
  else {
@@ -2177,7 +2177,7 @@ class DataDate extends ScalarData {
2177
2177
  if (this._value instanceof Date) {
2178
2178
  return this._value;
2179
2179
  }
2180
- else if (typeof this._value !== "string") {
2180
+ else if (typeof this._value !== 'string') {
2181
2181
  return new Date(this._value.value);
2182
2182
  }
2183
2183
  else {
@@ -2233,12 +2233,12 @@ class DataArray extends Data {
2233
2233
  return {
2234
2234
  next() {
2235
2235
  if (currentIndex < queryData.length) {
2236
- return { "value": getRow(currentIndex++), "done": false };
2236
+ return { value: getRow(currentIndex++), done: false };
2237
2237
  }
2238
2238
  else {
2239
- return { "value": undefined, "done": true };
2239
+ return { value: undefined, done: true };
2240
2240
  }
2241
- }
2241
+ },
2242
2242
  };
2243
2243
  }
2244
2244
  async *inMemoryStream() {
@@ -2250,7 +2250,7 @@ class DataArray extends Data {
2250
2250
  exports.DataArray = DataArray;
2251
2251
  function getPath(data, path) {
2252
2252
  for (const segment of path) {
2253
- if (typeof segment === "number") {
2253
+ if (typeof segment === 'number') {
2254
2254
  data = data.array.row(segment);
2255
2255
  }
2256
2256
  else {
@@ -2274,7 +2274,7 @@ class DataRecord extends Data {
2274
2274
  return getPath(this, path);
2275
2275
  }
2276
2276
  cell(fieldOrName) {
2277
- const fieldName = typeof fieldOrName === "string" ? fieldOrName : fieldOrName.name;
2277
+ const fieldName = typeof fieldOrName === 'string' ? fieldOrName : fieldOrName.name;
2278
2278
  const field = this._field.getFieldByName(fieldName);
2279
2279
  const value = this.queryDataRow[fieldName];
2280
2280
  if (value === null) {
@@ -2314,7 +2314,7 @@ class DataRecord extends Data {
2314
2314
  throw new Error(`Internal Error: could not construct data column for field '${fieldName}'.`);
2315
2315
  }
2316
2316
  get value() {
2317
- throw new Error("Not implemented;");
2317
+ throw new Error('Not implemented;');
2318
2318
  }
2319
2319
  // Non repeating values show up as DataRecords
2320
2320
  get field() {
@@ -2331,23 +2331,23 @@ class DataRecord extends Data {
2331
2331
  if (!returned) {
2332
2332
  returned = true;
2333
2333
  return {
2334
- "value": getSelf(),
2335
- "done": false
2334
+ value: getSelf(),
2335
+ done: false,
2336
2336
  };
2337
2337
  }
2338
2338
  else {
2339
- return { "value": undefined, "done": true };
2339
+ return { value: undefined, done: true };
2340
2340
  }
2341
- }
2341
+ },
2342
2342
  };
2343
2343
  }
2344
2344
  }
2345
2345
  exports.DataRecord = DataRecord;
2346
2346
  function isURLReader(thing) {
2347
- return "readURL" in thing;
2347
+ return 'readURL' in thing;
2348
2348
  }
2349
2349
  function isLookupConnection(thing) {
2350
- return "lookupConnection" in thing;
2350
+ return 'lookupConnection' in thing;
2351
2351
  }
2352
2352
  class DataWriter {
2353
2353
  constructor(stream) {
@@ -2357,22 +2357,22 @@ class DataWriter {
2357
2357
  exports.DataWriter = DataWriter;
2358
2358
  class JSONWriter extends DataWriter {
2359
2359
  async process(data) {
2360
- this.stream.write("[\n");
2360
+ this.stream.write('[\n');
2361
2361
  for await (const row of data) {
2362
2362
  if (row.index !== undefined && row.index > 0) {
2363
- this.stream.write(",\n");
2363
+ this.stream.write(',\n');
2364
2364
  }
2365
2365
  const json = JSON.stringify(row.toObject(), null, 2);
2366
- const jsonLines = json.split("\n");
2366
+ const jsonLines = json.split('\n');
2367
2367
  for (let i = 0; i < jsonLines.length; i++) {
2368
2368
  const line = jsonLines[i];
2369
2369
  this.stream.write(` ${line}`);
2370
2370
  if (i < jsonLines.length - 1) {
2371
- this.stream.write("\n");
2371
+ this.stream.write('\n');
2372
2372
  }
2373
2373
  }
2374
2374
  }
2375
- this.stream.write("\n]\n");
2375
+ this.stream.write('\n]\n');
2376
2376
  this.stream.close();
2377
2377
  }
2378
2378
  }
@@ -2380,8 +2380,8 @@ exports.JSONWriter = JSONWriter;
2380
2380
  class CSVWriter extends DataWriter {
2381
2381
  constructor() {
2382
2382
  super(...arguments);
2383
- this.columnSeparator = ",";
2384
- this.rowSeparator = "\n";
2383
+ this.columnSeparator = ',';
2384
+ this.rowSeparator = '\n';
2385
2385
  this.quoteCharacter = '"';
2386
2386
  this.includeHeader = true;
2387
2387
  }
@@ -2391,7 +2391,7 @@ class CSVWriter extends DataWriter {
2391
2391
  const hasNewline = value.includes(this.rowSeparator);
2392
2392
  const needsQuoting = hasInnerCommas || hasInnerQuote || hasNewline;
2393
2393
  if (hasInnerQuote) {
2394
- value = value.replace(new RegExp(this.quoteCharacter, "g"), this.quoteCharacter + this.quoteCharacter);
2394
+ value = value.replace(new RegExp(this.quoteCharacter, 'g'), this.quoteCharacter + this.quoteCharacter);
2395
2395
  }
2396
2396
  if (needsQuoting) {
2397
2397
  value = this.quoteCharacter + value + this.quoteCharacter;
@@ -2400,7 +2400,7 @@ class CSVWriter extends DataWriter {
2400
2400
  }
2401
2401
  stringify(cell) {
2402
2402
  if (cell.isNull()) {
2403
- return "";
2403
+ return '';
2404
2404
  }
2405
2405
  else if (cell.isArray() ||
2406
2406
  cell.isRecord() ||