@malloydata/malloy 0.0.337 → 0.0.339

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 (37) hide show
  1. package/dist/api/foundation/result.d.ts +4 -4
  2. package/dist/api/foundation/result.js +9 -9
  3. package/dist/api/foundation/writers.d.ts +1 -1
  4. package/dist/api/foundation/writers.js +9 -8
  5. package/dist/connection/registry.d.ts +1 -1
  6. package/dist/connection/types.d.ts +2 -2
  7. package/dist/dialect/dialect.d.ts +2 -1
  8. package/dist/dialect/dialect.js +3 -0
  9. package/dist/dialect/duckdb/duckdb.js +22 -1
  10. package/dist/dialect/mysql/mysql.d.ts +1 -0
  11. package/dist/dialect/mysql/mysql.js +1 -0
  12. package/dist/dialect/postgres/postgres.d.ts +1 -0
  13. package/dist/dialect/postgres/postgres.js +10 -0
  14. package/dist/dialect/standardsql/standardsql.js +21 -0
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +4 -2
  17. package/dist/lang/ast/expressions/expr-cast.d.ts +3 -3
  18. package/dist/lang/ast/expressions/expr-cast.js +4 -2
  19. package/dist/lang/ast/expressions/expr-func.d.ts +3 -3
  20. package/dist/lang/ast/expressions/expr-func.js +7 -9
  21. package/dist/lang/ast/expressions/for-range.js +1 -1
  22. package/dist/lang/ast/source-elements/named-source.js +4 -2
  23. package/dist/lang/ast/time-utils.d.ts +2 -2
  24. package/dist/lang/ast/time-utils.js +4 -5
  25. package/dist/lang/lib/Malloy/MalloyParser.d.ts +88 -45
  26. package/dist/lang/lib/Malloy/MalloyParser.js +2193 -1862
  27. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +33 -0
  28. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +21 -0
  29. package/dist/lang/malloy-to-ast.d.ts +4 -4
  30. package/dist/lang/malloy-to-ast.js +38 -22
  31. package/dist/model/malloy_types.d.ts +11 -8
  32. package/dist/model/malloy_types.js +23 -15
  33. package/dist/model/utils.d.ts +4 -6
  34. package/dist/model/utils.js +10 -11
  35. package/dist/version.d.ts +1 -1
  36. package/dist/version.js +1 -1
  37. package/package.json +5 -6
@@ -198,6 +198,9 @@ import { QueryAnnotationContext } from "./MalloyParser";
198
198
  import { SampleSpecContext } from "./MalloyParser";
199
199
  import { AggregateContext } from "./MalloyParser";
200
200
  import { MalloyTypeContext } from "./MalloyParser";
201
+ import { MalloyBasicTypeContext } from "./MalloyParser";
202
+ import { MalloyRecordTypeContext } from "./MalloyParser";
203
+ import { MalloyRecordFieldContext } from "./MalloyParser";
201
204
  import { CompareOpContext } from "./MalloyParser";
202
205
  import { StringContext } from "./MalloyParser";
203
206
  import { ShortStringContext } from "./MalloyParser";
@@ -2405,6 +2408,36 @@ export interface MalloyParserListener extends ParseTreeListener {
2405
2408
  * @param ctx the parse tree
2406
2409
  */
2407
2410
  exitMalloyType?: (ctx: MalloyTypeContext) => void;
2411
+ /**
2412
+ * Enter a parse tree produced by `MalloyParser.malloyBasicType`.
2413
+ * @param ctx the parse tree
2414
+ */
2415
+ enterMalloyBasicType?: (ctx: MalloyBasicTypeContext) => void;
2416
+ /**
2417
+ * Exit a parse tree produced by `MalloyParser.malloyBasicType`.
2418
+ * @param ctx the parse tree
2419
+ */
2420
+ exitMalloyBasicType?: (ctx: MalloyBasicTypeContext) => void;
2421
+ /**
2422
+ * Enter a parse tree produced by `MalloyParser.malloyRecordType`.
2423
+ * @param ctx the parse tree
2424
+ */
2425
+ enterMalloyRecordType?: (ctx: MalloyRecordTypeContext) => void;
2426
+ /**
2427
+ * Exit a parse tree produced by `MalloyParser.malloyRecordType`.
2428
+ * @param ctx the parse tree
2429
+ */
2430
+ exitMalloyRecordType?: (ctx: MalloyRecordTypeContext) => void;
2431
+ /**
2432
+ * Enter a parse tree produced by `MalloyParser.malloyRecordField`.
2433
+ * @param ctx the parse tree
2434
+ */
2435
+ enterMalloyRecordField?: (ctx: MalloyRecordFieldContext) => void;
2436
+ /**
2437
+ * Exit a parse tree produced by `MalloyParser.malloyRecordField`.
2438
+ * @param ctx the parse tree
2439
+ */
2440
+ exitMalloyRecordField?: (ctx: MalloyRecordFieldContext) => void;
2408
2441
  /**
2409
2442
  * Enter a parse tree produced by `MalloyParser.compareOp`.
2410
2443
  * @param ctx the parse tree
@@ -198,6 +198,9 @@ import { QueryAnnotationContext } from "./MalloyParser";
198
198
  import { SampleSpecContext } from "./MalloyParser";
199
199
  import { AggregateContext } from "./MalloyParser";
200
200
  import { MalloyTypeContext } from "./MalloyParser";
201
+ import { MalloyBasicTypeContext } from "./MalloyParser";
202
+ import { MalloyRecordTypeContext } from "./MalloyParser";
203
+ import { MalloyRecordFieldContext } from "./MalloyParser";
201
204
  import { CompareOpContext } from "./MalloyParser";
202
205
  import { StringContext } from "./MalloyParser";
203
206
  import { ShortStringContext } from "./MalloyParser";
@@ -1528,6 +1531,24 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
1528
1531
  * @return the visitor result
1529
1532
  */
1530
1533
  visitMalloyType?: (ctx: MalloyTypeContext) => Result;
1534
+ /**
1535
+ * Visit a parse tree produced by `MalloyParser.malloyBasicType`.
1536
+ * @param ctx the parse tree
1537
+ * @return the visitor result
1538
+ */
1539
+ visitMalloyBasicType?: (ctx: MalloyBasicTypeContext) => Result;
1540
+ /**
1541
+ * Visit a parse tree produced by `MalloyParser.malloyRecordType`.
1542
+ * @param ctx the parse tree
1543
+ * @return the visitor result
1544
+ */
1545
+ visitMalloyRecordType?: (ctx: MalloyRecordTypeContext) => Result;
1546
+ /**
1547
+ * Visit a parse tree produced by `MalloyParser.malloyRecordField`.
1548
+ * @param ctx the parse tree
1549
+ * @return the visitor result
1550
+ */
1551
+ visitMalloyRecordField?: (ctx: MalloyRecordFieldContext) => Result;
1531
1552
  /**
1532
1553
  * Visit a parse tree produced by `MalloyParser.compareOp`.
1533
1554
  * @param ctx the parse tree
@@ -8,8 +8,7 @@ import type { LogMessageOptions, MessageCode, MessageLogger, MessageParameterTyp
8
8
  import type { MalloyParseInfo } from './malloy-parse-info';
9
9
  import type { FieldDeclarationConstructor } from './ast';
10
10
  import type { HasString, HasID } from './parse-utils';
11
- import type { CastType } from '../model';
12
- import type { AccessModifierLabel, DocumentLocation, DocumentRange, Note } from '../model/malloy_types';
11
+ import type { AccessModifierLabel, AtomicTypeDef, BasicAtomicTypeDef, DocumentLocation, DocumentRange, Note } from '../model/malloy_types';
13
12
  import type { Tag } from '@malloydata/malloy-tag';
14
13
  import type * as Malloy from '@malloydata/malloy-interfaces';
15
14
  import { Timer } from '../timing';
@@ -187,8 +186,9 @@ export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElem
187
186
  visitExprApply(pcx: parse.ExprApplyContext): ast.Apply;
188
187
  visitExprRange(pcx: parse.ExprRangeContext): ast.Range;
189
188
  visitExprCast(pcx: parse.ExprCastContext): ast.ExpressionDef;
190
- getMalloyType(pcx: parse.MalloyTypeContext): CastType;
191
- getMalloyOrSQLType(pcx: parse.MalloyOrSQLTypeContext): CastType | {
189
+ getBasicMalloyType(pcx: parse.MalloyBasicTypeContext): BasicAtomicTypeDef;
190
+ getMalloyType(pcx: parse.MalloyTypeContext): AtomicTypeDef;
191
+ getMalloyOrSQLType(pcx: parse.MalloyOrSQLTypeContext): AtomicTypeDef | {
192
192
  raw: string;
193
193
  };
194
194
  visitExprSafeCast(pcx: parse.ExprSafeCastContext): ast.ExpressionDef;
@@ -289,7 +289,8 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
289
289
  let pType;
290
290
  const typeCx = pcx.legalParamType();
291
291
  if (typeCx) {
292
- const t = this.getMalloyType(typeCx.malloyType());
292
+ const typeDef = this.getBasicMalloyType(typeCx.malloyBasicType());
293
+ const t = typeDef.type;
293
294
  if (typeCx.FILTER()) {
294
295
  if ((0, malloy_filter_1.isFilterable)(t)) {
295
296
  pType = { type: 'filter expression', filterType: t };
@@ -298,11 +299,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
298
299
  this.contextError(typeCx, 'parameter-illegal-default-type', `Unknown filter type ${t}`);
299
300
  }
300
301
  }
301
- else if ((0, malloy_types_1.isParameterType)(t)) {
302
- pType = { type: t };
302
+ else if (!(0, malloy_types_1.isParameterType)(t)) {
303
+ this.contextError(typeCx, 'parameter-illegal-default-type', `Unknown parameter type ${t}`);
303
304
  }
304
305
  else {
305
- this.contextError(typeCx, 'parameter-illegal-default-type', `Unknown parameter type ${t}`);
306
+ pType = { type: t };
306
307
  }
307
308
  }
308
309
  const defaultCx = pcx.fieldExpr();
@@ -1092,12 +1093,34 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
1092
1093
  const type = this.getMalloyOrSQLType(pcx.malloyOrSQLType());
1093
1094
  return new ast.ExprCast(this.getFieldExpr(pcx.fieldExpr()), type);
1094
1095
  }
1095
- getMalloyType(pcx) {
1096
+ getBasicMalloyType(pcx) {
1096
1097
  const type = pcx.text;
1097
- if ((0, malloy_types_1.isCastType)(type)) {
1098
- return type;
1098
+ if ((0, malloy_types_1.isBasicAtomicType)(type)) {
1099
+ return { type };
1100
+ }
1101
+ this.contextError(pcx, 'unexpected-malloy-type', `Unknown type '${type}'`);
1102
+ return { type: 'error' };
1103
+ }
1104
+ getMalloyType(pcx) {
1105
+ const basicCx = pcx.malloyBasicType();
1106
+ if (basicCx) {
1107
+ return this.getBasicMalloyType(basicCx);
1108
+ }
1109
+ const recordCx = pcx.malloyRecordType();
1110
+ if (recordCx) {
1111
+ const fields = recordCx.malloyRecordField().map(fieldCx => {
1112
+ const name = (0, parse_utils_1.getId)(fieldCx);
1113
+ const fieldType = this.getMalloyType(fieldCx.malloyType());
1114
+ return (0, malloy_types_1.mkFieldDef)(fieldType, name);
1115
+ });
1116
+ return { type: 'record', fields };
1117
+ }
1118
+ const innerCx = pcx.malloyType();
1119
+ if (innerCx) {
1120
+ return (0, malloy_types_1.mkArrayTypeDef)(this.getMalloyType(innerCx));
1099
1121
  }
1100
- throw this.internalError(pcx, `unknown type '${type}'`);
1122
+ this.contextError(pcx, 'unexpected-malloy-type', 'Expected a type');
1123
+ return { type: 'error' };
1101
1124
  }
1102
1125
  getMalloyOrSQLType(pcx) {
1103
1126
  const mtcx = pcx.malloyType();
@@ -1141,22 +1164,15 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
1141
1164
  return this.astAt(new ast.ExprFunc(fn, args, false, undefined, source), pcx);
1142
1165
  }
1143
1166
  visitExprFunc(pcx) {
1144
- var _a, _b;
1167
+ var _a;
1145
1168
  const argsCx = pcx.argumentList();
1146
1169
  const args = argsCx ? this.allFieldExpressions(argsCx.fieldExpr()) : [];
1147
1170
  const isRaw = pcx.EXCLAM() !== undefined;
1148
- const rawRawType = (_a = pcx.malloyType()) === null || _a === void 0 ? void 0 : _a.text;
1149
- let rawType = undefined;
1150
- if (rawRawType) {
1151
- if ((0, malloy_types_1.isCastType)(rawRawType)) {
1152
- rawType = rawRawType;
1153
- }
1154
- else {
1155
- this.contextError(pcx, 'unexpected-malloy-type', `'#' assertion for unknown type '${rawRawType}'`);
1156
- rawType = undefined;
1157
- }
1158
- }
1159
- let fn = (0, parse_utils_1.getOptionalId)(pcx) || ((_b = pcx.timeframe()) === null || _b === void 0 ? void 0 : _b.text);
1171
+ const malloyTypeCx = pcx.malloyType();
1172
+ const explicitType = malloyTypeCx
1173
+ ? this.getMalloyType(malloyTypeCx)
1174
+ : undefined;
1175
+ let fn = (0, parse_utils_1.getOptionalId)(pcx) || ((_a = pcx.timeframe()) === null || _a === void 0 ? void 0 : _a.text);
1160
1176
  if (fn === undefined) {
1161
1177
  this.contextError(pcx, 'failed-to-parse-function-name', 'Function name error');
1162
1178
  fn = 'FUNCTION_NAME_ERROR';
@@ -1164,7 +1180,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
1164
1180
  if (ast.ExprTimeExtract.extractor(fn)) {
1165
1181
  return this.astAt(new ast.ExprTimeExtract(fn, args), pcx);
1166
1182
  }
1167
- return this.astAt(new ast.ExprFunc(fn, args, isRaw, rawType), pcx);
1183
+ return this.astAt(new ast.ExprFunc(fn, args, isRaw, explicitType), pcx);
1168
1184
  }
1169
1185
  visitExprDuration(pcx) {
1170
1186
  return new ast.ExprDuration(this.getFieldExpr(pcx.fieldExpr()), this.visitTimeframe(pcx.timeframe()).text);
@@ -159,7 +159,7 @@ export interface MalloyTypecastExpr extends ExprE {
159
159
  node: 'cast';
160
160
  safe: boolean;
161
161
  e: Expr;
162
- dstType: BasicAtomicTypeDef;
162
+ dstType: AtomicTypeDef;
163
163
  srcType?: BasicAtomicTypeDef;
164
164
  }
165
165
  interface RawTypeCastExpr extends ExprE {
@@ -402,11 +402,11 @@ export interface HasExpression {
402
402
  export declare function hasExpression<T extends FieldDef>(f: T): f is T & Expression & HasExpression;
403
403
  export type TemporalFieldType = 'date' | 'timestamp' | 'timestamptz';
404
404
  export declare function isTemporalType(s: string): s is TemporalFieldType;
405
- export type CastType = 'string' | 'number' | TemporalFieldType | 'boolean' | 'json';
406
- export type AtomicFieldType = CastType | 'sql native' | 'record' | 'array' | 'error';
405
+ export type BasicAtomicType = 'string' | 'number' | TemporalFieldType | 'boolean' | 'json' | 'sql native' | 'error';
406
+ export declare function isBasicAtomicType(s: string): s is BasicAtomicType;
407
+ export type AtomicFieldType = BasicAtomicType | 'record' | 'array';
407
408
  export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
408
409
  export declare function canOrderBy(s: string): boolean;
409
- export declare function isCastType(s: string): s is CastType;
410
410
  /**
411
411
  * Fields which contain scalar data all inherit from this. The field
412
412
  * value could be an expression, and this is one of the objects
@@ -460,6 +460,7 @@ export interface BasicArrayDef extends BasicArrayTypeDef, StructDefBase, JoinBas
460
460
  */
461
461
  export declare function mkFieldDef(atd: AtomicTypeDef, name: string): AtomicFieldDef;
462
462
  export declare function mkArrayDef(ofType: AtomicTypeDef, name: string): ArrayDef;
463
+ export declare function mkArrayTypeDef(ofType: AtomicTypeDef): BasicArrayTypeDef | RepeatedRecordTypeDef;
463
464
  export interface RecordTypeDef {
464
465
  type: 'record';
465
466
  fields: FieldDef[];
@@ -982,20 +983,22 @@ export interface ModelAnnotation extends Annotation {
982
983
  }
983
984
  export type QueryScalar = string | boolean | number | bigint | Date | Buffer | null;
984
985
  /** One value in one column of returned data. */
985
- export type QueryValue = QueryScalar | QueryData | QueryDataRow;
986
+ export type QueryValue = QueryScalar | QueryData | QueryRecord | QueryValue[];
986
987
  /** A row of returned data. */
987
- export type QueryDataRow = {
988
+ export type QueryRecord = {
988
989
  [columnName: string]: QueryValue;
989
990
  };
990
991
  /** Returned query data. */
991
- export type QueryData = QueryDataRow[];
992
+ export type QueryData = QueryRecord[];
993
+ /** Type guard: is this array value compound (array of records) vs basic (array of scalars)? */
994
+ export declare function isCompoundArrayData(v: QueryValue): v is QueryData;
992
995
  /** Query execution stats. */
993
996
  export type QueryRunStats = {
994
997
  queryCostBytes?: number;
995
998
  };
996
999
  /** Returned Malloy query data */
997
1000
  export type MalloyQueryData = {
998
- rows: QueryDataRow[];
1001
+ rows: QueryRecord[];
999
1002
  totalRows: number;
1000
1003
  runStats?: QueryRunStats;
1001
1004
  profilingUrl?: string;
@@ -45,12 +45,13 @@ exports.maxExpressionType = maxExpressionType;
45
45
  exports.maxOfExpressionTypes = maxOfExpressionTypes;
46
46
  exports.hasExpression = hasExpression;
47
47
  exports.isTemporalType = isTemporalType;
48
+ exports.isBasicAtomicType = isBasicAtomicType;
48
49
  exports.isAtomicFieldType = isAtomicFieldType;
49
50
  exports.canOrderBy = canOrderBy;
50
- exports.isCastType = isCastType;
51
51
  exports.fieldIsIntrinsic = fieldIsIntrinsic;
52
52
  exports.mkFieldDef = mkFieldDef;
53
53
  exports.mkArrayDef = mkArrayDef;
54
+ exports.mkArrayTypeDef = mkArrayTypeDef;
54
55
  exports.isRepeatedRecordFunctionParam = isRepeatedRecordFunctionParam;
55
56
  exports.isRepeatedRecord = isRepeatedRecord;
56
57
  exports.isRecordOrRepeatedRecord = isRecordOrRepeatedRecord;
@@ -86,6 +87,7 @@ exports.isLiteral = isLiteral;
86
87
  exports.mergeEvalSpaces = mergeEvalSpaces;
87
88
  exports.isBasicAtomic = isBasicAtomic;
88
89
  exports.getIdentifier = getIdentifier;
90
+ exports.isCompoundArrayData = isCompoundArrayData;
89
91
  exports.isTurtle = isTurtle;
90
92
  exports.isAtomic = isAtomic;
91
93
  exports.isValueString = isValueString;
@@ -232,7 +234,7 @@ function hasExpression(f) {
232
234
  function isTemporalType(s) {
233
235
  return s === 'date' || s === 'timestamp' || s === 'timestamptz';
234
236
  }
235
- function isAtomicFieldType(s) {
237
+ function isBasicAtomicType(s) {
236
238
  return [
237
239
  'string',
238
240
  'number',
@@ -242,11 +244,12 @@ function isAtomicFieldType(s) {
242
244
  'boolean',
243
245
  'json',
244
246
  'sql native',
245
- 'record',
246
- 'array',
247
247
  'error',
248
248
  ].includes(s);
249
249
  }
250
+ function isAtomicFieldType(s) {
251
+ return isBasicAtomicType(s) || s === 'record' || s === 'array';
252
+ }
250
253
  function canOrderBy(s) {
251
254
  return [
252
255
  'string',
@@ -258,17 +261,6 @@ function canOrderBy(s) {
258
261
  'timestamptz',
259
262
  ].includes(s);
260
263
  }
261
- function isCastType(s) {
262
- return [
263
- 'string',
264
- 'number',
265
- 'date',
266
- 'timestamp',
267
- 'timestamptz',
268
- 'boolean',
269
- 'json',
270
- ].includes(s);
271
- }
272
264
  // this field definition represents something in the database.
273
265
  function fieldIsIntrinsic(f) {
274
266
  return isAtomicFieldType(f.type) && !hasExpression(f);
@@ -340,6 +332,16 @@ function mkArrayDef(ofType, name) {
340
332
  ],
341
333
  };
342
334
  }
335
+ function mkArrayTypeDef(ofType) {
336
+ if (ofType.type === 'record') {
337
+ return {
338
+ type: 'array',
339
+ elementTypeDef: { type: 'record_element' },
340
+ fields: ofType.fields,
341
+ };
342
+ }
343
+ return { type: 'array', elementTypeDef: ofType };
344
+ }
343
345
  function isRepeatedRecordFunctionParam(paramT) {
344
346
  return (paramT.type === 'array' && paramT.elementTypeDef.type === 'record_element');
345
347
  }
@@ -511,6 +513,12 @@ function getIdentifier(n) {
511
513
  }
512
514
  return n.name;
513
515
  }
516
+ /** Type guard: is this array value compound (array of records) vs basic (array of scalars)? */
517
+ function isCompoundArrayData(v) {
518
+ return (Array.isArray(v) &&
519
+ (v.length === 0 ||
520
+ (typeof v[0] === 'object' && v[0] !== null && !Array.isArray(v[0]))));
521
+ }
514
522
  function isTurtle(def) {
515
523
  return def.type === 'turtle';
516
524
  }
@@ -23,19 +23,17 @@ export declare class AndChain {
23
23
  }
24
24
  export declare function generateHash(input: string): string;
25
25
  /**
26
- * Compute a digest for lookup/identity purposes (not cryptographic).
26
+ * Compute a digest for lookup/identity purposes.
27
27
  *
28
- * Uses blueimp-md5 for these reasons:
28
+ * Uses @noble/hashes sha256:
29
29
  * - Works in both Node.js and browsers (no native crypto dependency)
30
30
  * - Synchronous API (unlike Web Crypto which is async)
31
- * - Well-maintained by Sebastian Tschan (blueimp), a known maintainer
32
- * - High adoption (~1.7M weekly downloads)
33
- * - MD5 is fast and produces short hex strings - perfect for cache keys
31
+ * - SHA-256 is appropriate since inputs may contain connection credentials
34
32
  *
35
33
  * Takes variable string arguments and combines them in a collision-resistant
36
34
  * way by including the length of each string (similar to pathToKey pattern).
37
35
  */
38
- export declare function makeDigest(...parts: string[]): string;
36
+ export declare function makeDigest(...parts: (string | undefined)[]): string;
39
37
  export declare function joinWith<T>(els: T[][], sep: T): T[];
40
38
  export declare function range(start: number, end: number): number[];
41
39
  export declare function exprKids(eNode: Expr): IterableIterator<Expr>;
@@ -21,9 +21,6 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
24
  Object.defineProperty(exports, "__esModule", { value: true });
28
25
  exports.GenerateState = exports.AndChain = void 0;
29
26
  exports.indent = indent;
@@ -42,7 +39,8 @@ exports.groupingKey = groupingKey;
42
39
  exports.caseGroup = caseGroup;
43
40
  exports.mkModelDef = mkModelDef;
44
41
  const uuid_1 = require("uuid");
45
- const blueimp_md5_1 = __importDefault(require("blueimp-md5"));
42
+ const sha256_1 = require("@noble/hashes/sha256");
43
+ const utils_1 = require("@noble/hashes/utils");
46
44
  const malloy_types_1 = require("./malloy_types");
47
45
  /** simple indent function */
48
46
  function indent(s) {
@@ -115,14 +113,12 @@ function generateHash(input) {
115
113
  return (0, uuid_1.v5)(input, MALLOY_UUID);
116
114
  }
117
115
  /**
118
- * Compute a digest for lookup/identity purposes (not cryptographic).
116
+ * Compute a digest for lookup/identity purposes.
119
117
  *
120
- * Uses blueimp-md5 for these reasons:
118
+ * Uses @noble/hashes sha256:
121
119
  * - Works in both Node.js and browsers (no native crypto dependency)
122
120
  * - Synchronous API (unlike Web Crypto which is async)
123
- * - Well-maintained by Sebastian Tschan (blueimp), a known maintainer
124
- * - High adoption (~1.7M weekly downloads)
125
- * - MD5 is fast and produces short hex strings - perfect for cache keys
121
+ * - SHA-256 is appropriate since inputs may contain connection credentials
126
122
  *
127
123
  * Takes variable string arguments and combines them in a collision-resistant
128
124
  * way by including the length of each string (similar to pathToKey pattern).
@@ -131,8 +127,11 @@ function makeDigest(...parts) {
131
127
  // Combine parts with length prefix to avoid collisions
132
128
  // e.g., ("ab", "c") vs ("a", "bc") both concat to "abc"
133
129
  // but with lengths: "2:ab/1:c" vs "1:a/2:bc"
134
- const combined = parts.map(p => `${p.length}:${p}`).join('/');
135
- return (0, blueimp_md5_1.default)(combined);
130
+ // undefined is distinct from empty string in the hash
131
+ const combined = parts
132
+ .map(p => (p === undefined ? '{undefined}' : `${p.length}:${p}`))
133
+ .join('/');
134
+ return (0, utils_1.bytesToHex)((0, sha256_1.sha256)(combined));
136
135
  }
137
136
  function joinWith(els, sep) {
138
137
  const result = [];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.337";
1
+ export declare const MALLOY_VERSION = "0.0.339";
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.337';
5
+ exports.MALLOY_VERSION = '0.0.339';
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.337",
3
+ "version": "0.0.339",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -45,12 +45,12 @@
45
45
  "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"
46
46
  },
47
47
  "dependencies": {
48
- "@malloydata/malloy-filter": "0.0.337",
49
- "@malloydata/malloy-interfaces": "0.0.337",
50
- "@malloydata/malloy-tag": "0.0.337",
48
+ "@malloydata/malloy-filter": "0.0.339",
49
+ "@malloydata/malloy-interfaces": "0.0.339",
50
+ "@malloydata/malloy-tag": "0.0.339",
51
+ "@noble/hashes": "^1.8.0",
51
52
  "antlr4ts": "^0.5.0-alpha.4",
52
53
  "assert": "^2.0.0",
53
- "blueimp-md5": "^2.19.0",
54
54
  "jaro-winkler": "^0.2.8",
55
55
  "jest-diff": "^29.6.2",
56
56
  "lodash": "^4.17.20",
@@ -58,7 +58,6 @@
58
58
  "uuid": "^8.3.2"
59
59
  },
60
60
  "devDependencies": {
61
- "@types/blueimp-md5": "^2.18.2",
62
61
  "@types/jaro-winkler": "^0.2.3",
63
62
  "@types/lodash": "^4.14.165",
64
63
  "@types/luxon": "^3.5.0",