@malloydata/malloy 0.0.412 → 0.0.414

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 (45) hide show
  1. package/dist/api/foundation/core.d.ts +21 -0
  2. package/dist/api/foundation/core.js +30 -0
  3. package/dist/dialect/databricks/databricks.d.ts +2 -1
  4. package/dist/dialect/databricks/databricks.js +12 -6
  5. package/dist/dialect/dialect.d.ts +12 -1
  6. package/dist/dialect/dialect.js +25 -0
  7. package/dist/dialect/duckdb/duckdb.d.ts +2 -1
  8. package/dist/dialect/duckdb/duckdb.js +9 -2
  9. package/dist/dialect/mysql/mysql.d.ts +2 -1
  10. package/dist/dialect/mysql/mysql.js +14 -5
  11. package/dist/dialect/postgres/postgres.d.ts +2 -1
  12. package/dist/dialect/postgres/postgres.js +9 -2
  13. package/dist/dialect/snowflake/snowflake.d.ts +2 -1
  14. package/dist/dialect/snowflake/snowflake.js +11 -3
  15. package/dist/dialect/standardsql/standardsql.d.ts +2 -1
  16. package/dist/dialect/standardsql/standardsql.js +8 -2
  17. package/dist/dialect/trino/trino.d.ts +2 -1
  18. package/dist/dialect/trino/trino.js +8 -2
  19. package/dist/lang/ast/field-space/dynamic-space.js +14 -1
  20. package/dist/lang/ast/field-space/query-spaces.d.ts +1 -0
  21. package/dist/lang/ast/field-space/query-spaces.js +5 -0
  22. package/dist/lang/ast/query-items/field-references.d.ts +10 -1
  23. package/dist/lang/ast/query-items/field-references.js +67 -4
  24. package/dist/lang/ast/query-properties/nest.js +15 -0
  25. package/dist/lang/ast/source-elements/named-source.js +4 -1
  26. package/dist/lang/ast/statements/define-source.js +9 -2
  27. package/dist/lang/ast/types/malloy-element.js +3 -4
  28. package/dist/lang/parse-log.d.ts +10 -0
  29. package/dist/lang/parse-log.js +3 -0
  30. package/dist/model/expression_compiler.js +2 -2
  31. package/dist/model/field_instance.d.ts +1 -0
  32. package/dist/model/field_instance.js +14 -0
  33. package/dist/model/index.d.ts +2 -1
  34. package/dist/model/index.js +3 -1
  35. package/dist/model/malloy_types.d.ts +25 -6
  36. package/dist/model/nest-capability.d.ts +37 -0
  37. package/dist/model/nest-capability.js +31 -0
  38. package/dist/model/persist_utils.js +1 -1
  39. package/dist/model/query_query.d.ts +26 -5
  40. package/dist/model/query_query.js +256 -88
  41. package/dist/model/source_def_utils.d.ts +31 -7
  42. package/dist/model/source_def_utils.js +39 -9
  43. package/dist/version.d.ts +1 -1
  44. package/dist/version.js +1 -1
  45. package/package.json +4 -4
@@ -10,7 +10,9 @@ exports.mkBuildID = mkBuildID;
10
10
  exports.mkQuerySourceDef = mkQuerySourceDef;
11
11
  exports.mkSQLSourceDef = mkSQLSourceDef;
12
12
  exports.mkTableSourceDef = mkTableSourceDef;
13
+ exports.resolveSourceRef = resolveSourceRef;
13
14
  exports.resolveSourceID = resolveSourceID;
15
+ exports.sourceNamespaceReference = sourceNamespaceReference;
14
16
  exports.registerSource = registerSource;
15
17
  exports.hasSourceRegistryEntry = hasSourceRegistryEntry;
16
18
  const utils_1 = require("./utils");
@@ -59,8 +61,9 @@ function mkQuerySourceDef(base, query, name) {
59
61
  dialect: base.dialect,
60
62
  partitionComposite: base.partitionComposite,
61
63
  errorFactory: base.errorFactory,
62
- // PersistableSourceProperties - explicitly NOT copied
64
+ // Identity fields - explicitly NOT copied
63
65
  // sourceID: undefined,
66
+ // referenceID: undefined,
64
67
  // extends: undefined,
65
68
  // persistent: undefined,
66
69
  };
@@ -97,8 +100,9 @@ function mkSQLSourceDef(base, selectStr, selectSegments) {
97
100
  dialect: base.dialect,
98
101
  partitionComposite: base.partitionComposite,
99
102
  errorFactory: base.errorFactory,
100
- // PersistableSourceProperties - explicitly NOT copied
103
+ // Identity fields - explicitly NOT copied
101
104
  // sourceID: undefined,
105
+ // referenceID: undefined,
102
106
  // extends: undefined,
103
107
  // persistent: undefined,
104
108
  };
@@ -120,25 +124,51 @@ function mkTableSourceDef(name, connection, tablePath, dialect, fields) {
120
124
  // Source Registry Utilities
121
125
  // =============================================================================
122
126
  /**
123
- * Resolve a sourceID to a SourceDef using the sourceRegistry.
127
+ * Resolve a SourceID (a source's own `sourceID`, or a `referenceID` pointing at
128
+ * one) to its SourceDef using the sourceRegistry, returning any kind of source.
124
129
  *
125
130
  * @param modelDef The model definition containing the registry
126
- * @param sourceID The sourceID to resolve
131
+ * @param sourceID The SourceID to resolve
127
132
  * @returns The SourceDef if found, undefined otherwise
128
133
  */
129
- function resolveSourceID(modelDef, sourceID) {
134
+ function resolveSourceRef(modelDef, sourceID) {
130
135
  const value = modelDef.sourceRegistry[sourceID];
131
136
  if (!value)
132
137
  return undefined;
133
138
  if ((0, malloy_types_1.isSourceRegistryReference)(value.entry)) {
134
139
  const obj = (0, malloy_types_1.safeRecordGet)(modelDef.contents, value.entry.name);
135
- return obj && (0, malloy_types_1.isSourceDef)(obj) && (0, malloy_types_1.isPersistableSourceDef)(obj)
136
- ? obj
137
- : undefined;
140
+ return obj && (0, malloy_types_1.isSourceDef)(obj) ? obj : undefined;
138
141
  }
139
- // It's a PersistableSourceDef
140
142
  return value.entry;
141
143
  }
144
+ /**
145
+ * Resolve a sourceID to a persistable SourceDef using the sourceRegistry.
146
+ *
147
+ * @param modelDef The model definition containing the registry
148
+ * @param sourceID The sourceID to resolve
149
+ * @returns The PersistableSourceDef if found, undefined otherwise
150
+ */
151
+ function resolveSourceID(modelDef, sourceID) {
152
+ const sd = resolveSourceRef(modelDef, sourceID);
153
+ return sd && (0, malloy_types_1.isPersistableSourceDef)(sd) ? sd : undefined;
154
+ }
155
+ /**
156
+ * If `sd` was created as an unmodified reference to another source
157
+ * (`sd.referenceID` is set) and that source is present in this model's
158
+ * namespace, return it together with the name it goes by. Returns undefined
159
+ * when `sd` defines its own shape, or when the referenced source is not in this
160
+ * model's namespace (e.g. an imported source whose own target wasn't imported).
161
+ */
162
+ function sourceNamespaceReference(modelDef, sd) {
163
+ if (sd.referenceID === undefined)
164
+ return undefined;
165
+ const value = modelDef.sourceRegistry[sd.referenceID];
166
+ if (!value || !(0, malloy_types_1.isSourceRegistryReference)(value.entry))
167
+ return undefined;
168
+ const name = value.entry.name;
169
+ const source = (0, malloy_types_1.safeRecordGet)(modelDef.contents, name);
170
+ return source && (0, malloy_types_1.isSourceDef)(source) ? { name, source } : undefined;
171
+ }
142
172
  /**
143
173
  * Add an entry to the sourceRegistry.
144
174
  *
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.412";
1
+ export declare const MALLOY_VERSION = "0.0.414";
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MALLOY_VERSION = void 0;
4
4
  // generated with 'generate-version-file' script; do not edit manually
5
- exports.MALLOY_VERSION = '0.0.412';
5
+ exports.MALLOY_VERSION = '0.0.414';
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.412",
3
+ "version": "0.0.414",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  "generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
52
52
  },
53
53
  "dependencies": {
54
- "@malloydata/malloy-filter": "0.0.412",
55
- "@malloydata/malloy-interfaces": "0.0.412",
56
- "@malloydata/malloy-tag": "0.0.412",
54
+ "@malloydata/malloy-filter": "0.0.414",
55
+ "@malloydata/malloy-interfaces": "0.0.414",
56
+ "@malloydata/malloy-tag": "0.0.414",
57
57
  "@noble/hashes": "^1.8.0",
58
58
  "antlr4ts": "^0.5.0-alpha.4",
59
59
  "assert": "^2.0.0",