@aehrc/ecl-core 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,31 @@ const formatted = formatDocument('<<404684003:246075003=<<19829001', {
50
50
 
51
51
  Range formatting is also supported via `expandToExpressionBoundaries`, `getExpressionsInRange`, and `formatRangeExpressions`.
52
52
 
53
+ ### Minifying
54
+
55
+ ```typescript
56
+ import { minifyExpression } from '@aehrc/ecl-core';
57
+
58
+ minifyExpression(`/* Lung findings */
59
+ (<< 404684003 |Clinical finding| :
60
+ 363698007 |Finding site| = << 39057004 |Lung structure|)
61
+ OR << 71388002 |Procedure|`);
62
+ // → '/* Lung findings */(<<404684003:363698007=<<39057004)OR <<71388002'
63
+
64
+ minifyExpression('<< 404684003 /* any */ {{ D term = "heart attack" }}', { removeComments: true });
65
+ // → '<<404684003{{D term="heart attack"}}'
66
+ ```
67
+
68
+ Returns the shortest text that parses to the same expression, for storing ECL where size and RF2 safety matter, such as the query field of a query specification reference set:
69
+
70
+ - display terms are removed;
71
+ - whitespace is removed wherever the grammar makes it optional, and is one space where it is mandatory: after `AND`, `OR` and `MINUS`, and between the items of a set such as `(en-au (prefer) en-gb)`;
72
+ - a space is kept where removing it would join two words (`D term`, `R 363698007`) or two characters into a different operator;
73
+ - quoted strings are kept as written, except that a tab or line break in one becomes a space;
74
+ - block comments are kept, with their whitespace collapsed, unless `removeComments` is set.
75
+
76
+ The result has no tab, carriage return or line feed. Operand order, brackets and refinement groups are never changed. Before returning, the result is re-parsed and its structure compared with the input's. Throws `MinifyError` for unparseable input. Pure, synchronous, zero-network-dependency.
77
+
53
78
  ### Validation
54
79
 
55
80
  ```typescript
@@ -224,13 +249,14 @@ it is turned into ECL. They follow checks of the NHS ValueSet Management Tool
224
249
  (CHK numbers below), and all are advisory. `formatDeriveReport` prints them
225
250
  under "Review:". The checks:
226
251
 
227
- | Field | Check | Flags | Limit (default) |
228
- | ------------------ | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
229
- | `clauses` | CHK16 | The best exact candidate needs more clauses than the limit | `maxClauses` (35) |
230
- | `nearMisses` | CHK12 | Concepts X where the list holds most, but not all, of `<< X`, with the missing concepts counted on the server. Only the outermost of nested ones is listed | `nearMissShare` (0.9), `nearMissMinSize` (5), `maxNearMisses` (5) |
231
- | `spansHierarchies` | CHK15 | Members in more than one top-level hierarchy (`hierarchies` gives the counts) | |
232
- | `inactive` | CHK07 | Inactive ids in the input, or a reference set's inactive members | |
233
- | `impliedInactive` | CHK08 | Inactive concepts the members' history implies but the input leaves out. Off unless asked for; needs ECL history supplements on the server | `impliedInactive` (false; `true` is `'HISTORY-MOD'`) |
252
+ | Field | Check | Flags | Limit (default) |
253
+ | ------------------ | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
254
+ | `clauses` | CHK16 | The best exact candidate needs more clauses than the limit | `maxClauses` (35) |
255
+ | `nearMisses` | CHK12 | Concepts X where the list holds most, but not all, of `<< X`, with the missing concepts counted on the server. Only the outermost of nested ones is listed | `nearMissShare` (0.9), `nearMissMinSize` (5), `maxNearMisses` (5) |
256
+ | `spansHierarchies` | CHK15 | Members in more than one top-level hierarchy (`hierarchies` gives the counts) | |
257
+ | `inactive` | CHK07 | Inactive ids in the input, or a reference set's inactive members | |
258
+ | `impliedInactive` | CHK08 | Inactive concepts the members' history implies but the input leaves out. Off unless asked for; needs ECL history supplements on the server | `impliedInactive` (false; `true` is `'HISTORY-MOD'`) |
259
+ | `duplicateTerms` | CHK13 | Different members with the same preferred term (e.g. a procedure and an observable entity), with FSNs to tell them apart. Whitespace and the case of the first letter are ignored. Skipped for lists of more than `maxGraphConcepts` members | `maxDuplicateTerms` (20; 0 turns it off) |
234
260
 
235
261
  Near misses need the IS-A subgraph (see `useGraph`); without it they are
236
262
  skipped with a note. Only groupers whose subtree the subgraph loaded are judged:
@@ -22,4 +22,21 @@ export declare function outermost<T extends {
22
22
  }>(g: TaxonomyGraph, items: T[], max: number): T[];
23
23
  /** The near misses on the graph alone: {@link nearMissCandidates}, outermost first, at most `max`. */
24
24
  export declare function findNearMisses(g: TaxonomyGraph, share: number, minSize: number, max: number): LocalNearMiss[];
25
+ /** Different concepts of the list with the same preferred term (CHK13). */
26
+ export interface LocalDuplicateTerm {
27
+ /** The term as the lowest id has it. */
28
+ term: string;
29
+ /** Sorted. */
30
+ conceptIds: string[];
31
+ }
32
+ /**
33
+ * Groups of two or more concepts whose terms match, ordered by term. Runs of
34
+ * whitespace and the case of the first letter are ignored, as SNOMED CT
35
+ * terms are mostly case-insensitive only there. Concepts without a term are
36
+ * left out.
37
+ */
38
+ export declare function findDuplicateTerms(concepts: {
39
+ code: string;
40
+ display: string;
41
+ }[]): LocalDuplicateTerm[];
25
42
  //# sourceMappingURL=critique.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"critique.d.ts","sourceRoot":"","sources":["../../src/derive/critique.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAWpG;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,CAUzG;AAED,sGAAsG;AACtG,wBA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iqueOptions {
97
97
  * Needs a server that supports ECL history supplements. Default false.
98
98
  */
99
99
  impliedInactive?: boolean | 'HISTORY-MIN' | 'HISTORY-MOD' | 'HISTORY-MAX';
100
+ /**
101
+ * CHK13: the most shared terms reported (0 turns the check off). Default 20.
102
+ * Lists of more than `maxGraphConcepts` members are not checked.
103
+ */
104
+ maxDuplicateTerms?: number;
100
105
  }
101
106
  /** A concept the list holds most, but not all, of `<< conceptId` of (CHK12). */
102
107
  export interface NearMiss {
@@ -109,6 +114,15 @@ export interface NearMiss {
109
114
  /** `<< conceptId` concepts the list leaves out, counted on the server. */
110
115
  missing: SetDifference;
111
116
  }
117
+ /** Different members with the same preferred term (CHK13), e.g. a procedure and an observable entity. */
118
+ export interface DuplicateTerm {
119
+ term: string;
120
+ /** Sorted by id; `fsn` tells them apart, unless `omitTerms`. */
121
+ concepts: {
122
+ conceptId: string;
123
+ fsn?: string;
124
+ }[];
125
+ }
112
126
  /**
113
127
  * Structural checks on the list, after the NHS ValueSet Management Tool's
114
128
  * (CHK numbers are its checks). Advisory: each can be intended.
@@ -127,6 +141,8 @@ export interface CodelistCritique {
127
141
  spansHierarchies: boolean;
128
142
  /** CHK07: inactive ids in the input. */
129
143
  inactive: string[];
144
+ /** CHK13: members that share a preferred term. */
145
+ duplicateTerms: DuplicateTerm[];
130
146
  /** CHK08: inactive concepts the history implies but the input leaves out (when asked for). */
131
147
  impliedInactive?: SetDifference;
132
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"derive-ecl.d.ts","sourceRoot":"","sources":["../../src/derive/derive-ecl.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,EAAe,mBAAmB,EAAmB,MAAM,sBAAsB,CAAC;AAE9F,OAAO,EASL,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGhG,OAAO,EAA6D,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAIjH,kG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WAAW,CAW7D;AAuBD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAsC/D"}
@@ -43,6 +43,11 @@ export declare class SetQueries {
43
43
  codes: string[];
44
44
  total: number;
45
45
  }>;
46
+ /** Up to `max` concepts of the set with their terms, in the server's order, plus the set's exact total. */
47
+ concepts(compose: ValueSetCompose, max: number, activeOnly?: boolean): Promise<{
48
+ concepts: EvaluationConcept[];
49
+ total: number;
50
+ }>;
46
51
  /**
47
52
  * Every concept of the set with its direct parents, or why not: the set has
48
53
  * more than `max` concepts, or the server does not return parents.
@@ -1 +1 @@
1
- {"version":3,"file":"set-queries.d.ts","sourceRoot":"","sources":["../../src/derive/set-queries.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEpH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED,eAAO,MAAM,WAAW,cAAc,CAAC;AAGvC,sDAAsD;AACtD,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,oFAAoF;AACpF,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,mB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M,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAKlH,2GAA2G;IACrG,QAAQ,CACZ,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,MAAM,EACX,UAAU,UAAO,GAChB,OAAO,CAAC;QAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAc5D;;;OAGG;IACG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,WAAW,GAAG,YAAY,CAAC;IAc/G,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGvC"}
package/dist/index.cjs CHANGED
@@ -42416,8 +42416,9 @@ function runParseAttempt(input, predictionMode) {
42416
42416
  parser.removeErrorListeners();
42417
42417
  parser.addErrorListener(errorListener);
42418
42418
  let ast = null;
42419
+ let tree = null;
42419
42420
  try {
42420
- const tree = parser.expressionconstraint();
42421
+ tree = parser.expressionconstraint();
42421
42422
  ast = new ECLASTVisitor().visit(tree);
42422
42423
  const currentToken = parser.currentToken;
42423
42424
  if (currentToken.type !== import_antlr4ts.Token.EOF) {
@@ -42434,7 +42435,8 @@ function runParseAttempt(input, predictionMode) {
42434
42435
  } catch {}
42435
42436
  return {
42436
42437
  ast,
42437
- errors: errorListener.getErrors()
42438
+ errors: errorListener.getErrors(),
42439
+ tree
42438
42440
  };
42439
42441
  }
42440
42442
  /**
@@ -42458,6 +42460,22 @@ function parseWithFallback(input) {
42458
42460
  if (sll.ast !== null && sll.errors.length === 0) return sll;
42459
42461
  return runParseAttempt(input, import_PredictionMode.PredictionMode.LL);
42460
42462
  }
42463
+ /**
42464
+ * Parses `input` and returns the ANTLR parse tree, which keeps every character
42465
+ * of the source: whitespace, comments and display terms included. The AST from
42466
+ * `parseECL` drops these, so code that rewrites the source text exactly (such as
42467
+ * the minifier) walks this tree instead.
42468
+ *
42469
+ * Uses the same SLL-then-LL strategy as `parseECL`. `errors` are ANTLR's raw
42470
+ * messages; call `parseECL` for the clearer ones shown to users.
42471
+ */
42472
+ function parseConcreteTree(input) {
42473
+ const { tree, errors } = parseWithFallback(input);
42474
+ return {
42475
+ tree,
42476
+ errors
42477
+ };
42478
+ }
42461
42479
  function parseECL(input) {
42462
42480
  if (input === lastInput && lastResult !== null) return lastResult;
42463
42481
  const tokenLexer = new ECLLexer(new import_antlr4ts.ANTLRInputStream(input));
@@ -43235,6 +43253,8 @@ function toHttpError(options) {
43235
43253
  return new TerminologyHttpError(`Terminology server returned HTTP ${options.status} for ${options.operation}${suffix}`, options);
43236
43254
  }
43237
43255
  // src/terminology/fhir-service.ts
43256
+ /** SNOMED CT's description type for a fully specified name. */
43257
+ var FSN_TYPE = "900000000000003001";
43238
43258
  /** URL of the R5 `ValueSet.expansion.contains.property` element as an R4 extension. */
43239
43259
  var CONTAINS_PROPERTY_EXTENSION = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property";
43240
43260
  /**
@@ -43604,7 +43624,7 @@ var FhirTerminologyService = class FhirTerminologyService {
43604
43624
  }
43605
43625
  const conceptInfo = {
43606
43626
  id: conceptId,
43607
- fsn: display,
43627
+ fsn: params.filter((p) => p.name === "designation").find((p) => p.part?.some((q) => q.name === "use" && q.valueCoding?.code === FSN_TYPE))?.part?.find((q) => q.name === "value")?.valueString ?? display,
43608
43628
  pt: display,
43609
43629
  active
43610
43630
  };
@@ -43725,7 +43745,7 @@ var FhirTerminologyService = class FhirTerminologyService {
43725
43745
  }));
43726
43746
  }
43727
43747
  async bulkExpand(conceptIds) {
43728
- const url = `${this.baseUrl}/ValueSet/$expand?property=inactive&activeOnly=false`;
43748
+ const url = `${this.baseUrl}/ValueSet/$expand?property=inactive&activeOnly=false&includeDesignations=true`;
43729
43749
  const include = {
43730
43750
  system: "http://snomed.info/sct",
43731
43751
  concept: conceptIds.map((code) => ({ code }))
@@ -43764,7 +43784,7 @@ var FhirTerminologyService = class FhirTerminologyService {
43764
43784
  else if ((entry.property ?? []).find((p) => p.code === "inactive")?.valueBoolean === true) active = false;
43765
43785
  results.set(code, {
43766
43786
  id: code,
43767
- fsn: display,
43787
+ fsn: entry.designation?.find((d) => d.use?.code === FSN_TYPE)?.value ?? display,
43768
43788
  pt: display,
43769
43789
  active
43770
43790
  });
@@ -44083,7 +44103,7 @@ var FhirTerminologyService = class FhirTerminologyService {
44083
44103
  return {
44084
44104
  results: contains.slice(0, 20).map((item) => {
44085
44105
  const display = item.display ?? "";
44086
- const fsnDesignation = item.designation?.find((d) => d.use?.code === "900000000000003001");
44106
+ const fsnDesignation = item.designation?.find((d) => d.use?.code === FSN_TYPE);
44087
44107
  return {
44088
44108
  id: item.code ?? "",
44089
44109
  fsn: fsnDesignation?.value ?? display,
@@ -48492,23 +48512,30 @@ var SetQueries = class {
48492
48512
  }
48493
48513
  /** Up to `max` codes of the set, sorted, plus the set's exact total. */
48494
48514
  async codes(compose, max, activeOnly = true) {
48495
- const codes = [];
48515
+ const { concepts, total } = await this.concepts(compose, max, activeOnly);
48516
+ return {
48517
+ codes: concepts.map((c) => c.code).sort(byId),
48518
+ total
48519
+ };
48520
+ }
48521
+ /** Up to `max` concepts of the set with their terms, in the server's order, plus the set's exact total. */
48522
+ async concepts(compose, max, activeOnly = true) {
48523
+ const concepts = [];
48496
48524
  let total = 0;
48497
- for (let offset = 0; codes.length < max;) {
48525
+ for (let offset = 0; concepts.length < max;) {
48498
48526
  const r = await this.expand(compose, {
48499
- count: Math.min(PAGE_SIZE, max - codes.length),
48527
+ count: Math.min(PAGE_SIZE, max - concepts.length),
48500
48528
  offset,
48501
48529
  activeOnly
48502
48530
  });
48503
48531
  total = r.total;
48504
48532
  if (r.concepts.length === 0) break;
48505
- for (const c of r.concepts) codes.push(c.code);
48533
+ for (const c of r.concepts) concepts.push(c);
48506
48534
  offset += r.concepts.length;
48507
48535
  if (offset >= total) break;
48508
48536
  }
48509
- codes.sort(byId);
48510
48537
  return {
48511
- codes,
48538
+ concepts,
48512
48539
  total
48513
48540
  };
48514
48541
  }
@@ -48862,6 +48889,30 @@ function outermost(g, items, max) {
48862
48889
  }
48863
48890
  return kept;
48864
48891
  }
48892
+ /**
48893
+ * Groups of two or more concepts whose terms match, ordered by term. Runs of
48894
+ * whitespace and the case of the first letter are ignored, as SNOMED CT
48895
+ * terms are mostly case-insensitive only there. Concepts without a term are
48896
+ * left out.
48897
+ */
48898
+ function findDuplicateTerms(concepts) {
48899
+ const groups = /* @__PURE__ */ new Map();
48900
+ for (const { code, display } of concepts) {
48901
+ const term = display.trim().replaceAll(/\s+/g, " ");
48902
+ if (!term) continue;
48903
+ const key = term.charAt(0).toLowerCase() + term.slice(1);
48904
+ const group = groups.get(key) ?? /* @__PURE__ */ new Map();
48905
+ group.set(code, display.trim());
48906
+ groups.set(key, group);
48907
+ }
48908
+ return [...groups].filter(([, g]) => g.size > 1).sort(([a], [b]) => a.localeCompare(b)).map(([, g]) => {
48909
+ const conceptIds = [...g.keys()].sort(byId);
48910
+ return {
48911
+ term: g.get(conceptIds[0]) ?? "",
48912
+ conceptIds
48913
+ };
48914
+ });
48915
+ }
48865
48916
  // src/derive/greedy-grouping.ts
48866
48917
  var MINIMUM_CLUSTER_SIZE = 2;
48867
48918
  var FIT_THRESHOLD = .9;
@@ -49425,7 +49476,8 @@ var CRITIQUE_DEFAULTS = {
49425
49476
  nearMissShare: .9,
49426
49477
  nearMissMinSize: 5,
49427
49478
  maxNearMisses: 5,
49428
- impliedInactive: false
49479
+ impliedInactive: false,
49480
+ maxDuplicateTerms: 20
49429
49481
  };
49430
49482
  /** Above this many concept references, candidates are not formatted or given terms. */
49431
49483
  var MAX_DECORATED_CLAUSES = 200;
@@ -49579,7 +49631,11 @@ async function buildCritique(limits, found, q, terminology, opts) {
49579
49631
  const { input, result, members, graph, hierarchies, scored } = found;
49580
49632
  const induced = scored.filter((s) => s.exact && s.construction.kind !== "refset" && s.construction.kind !== "expression");
49581
49633
  const best = Math.min(members.size, ...induced.map((s) => s.clauses));
49582
- const [near, inactive] = await Promise.all([nearMisses(limits, members, graph, q, terminology, opts, result.notes), "refsetId" in input ? inactiveMembers(members, graph, q, result.notes) : [...result.input.inactive]]);
49634
+ const [near, inactive, duplicateTerms] = await Promise.all([
49635
+ nearMisses(limits, members, graph, q, terminology, opts, result.notes),
49636
+ "refsetId" in input ? inactiveMembers(members, graph, q, result.notes) : [...result.input.inactive],
49637
+ sharedTerms(limits.maxDuplicateTerms, members, q, terminology, opts, result.notes)
49638
+ ]);
49583
49639
  const critique = {
49584
49640
  clauses: {
49585
49641
  best,
@@ -49589,7 +49645,8 @@ async function buildCritique(limits, found, q, terminology, opts) {
49589
49645
  nearMisses: near,
49590
49646
  hierarchies,
49591
49647
  spansHierarchies: hierarchies.length > 1,
49592
- inactive
49648
+ inactive,
49649
+ duplicateTerms
49593
49650
  };
49594
49651
  if (limits.impliedInactive) {
49595
49652
  const profile = limits.impliedInactive === true ? "HISTORY-MOD" : limits.impliedInactive;
@@ -49640,6 +49697,43 @@ async function nearMisses(limits, members, graph, q, terminology, opts, notes) {
49640
49697
  return found;
49641
49698
  }
49642
49699
  /**
49700
+ * Members that share a preferred term (CHK13): one listing of the members with
49701
+ * their terms, plus a lookup of the FSNs that tell each group apart.
49702
+ */
49703
+ async function sharedTerms(max, members, q, terminology, opts, notes) {
49704
+ const limit = Math.max(0, Math.floor(max));
49705
+ if (limit === 0) return [];
49706
+ if (members.size > opts.maxGraphConcepts) {
49707
+ notes.push(`Shared terms were not checked: the list has ${members.size} members, more than ${opts.maxGraphConcepts} (maxGraphConcepts).`);
49708
+ return [];
49709
+ }
49710
+ let groups;
49711
+ try {
49712
+ groups = findDuplicateTerms((await q.concepts({ include: [members.clause] }, members.size)).concepts);
49713
+ } catch (error) {
49714
+ notes.push(`Shared terms were not checked: ${errorMessage(error)}.`);
49715
+ return [];
49716
+ }
49717
+ if (groups.length > limit) notes.push(`${plural(groups.length, "term")} ${groups.length === 1 ? "is" : "are"} shared by more than one member; the first ${limit} ${limit === 1 ? "is" : "are"} listed (maxDuplicateTerms).`);
49718
+ const found = groups.slice(0, limit).map((g) => ({
49719
+ term: g.term,
49720
+ concepts: g.conceptIds.map((conceptId) => ({ conceptId }))
49721
+ }));
49722
+ if (!opts.omitTerms && found.length > 0) await addFsns(found, terminology);
49723
+ return found;
49724
+ }
49725
+ /** Each concept's FSN, where it says more than the shared term. */
49726
+ async function addFsns(found, terminology) {
49727
+ const concepts = found.flatMap((d) => d.concepts);
49728
+ try {
49729
+ const info = await terminology.validateConcepts(concepts.map((c) => c.conceptId));
49730
+ for (const c of concepts) {
49731
+ const concept = info.get(c.conceptId);
49732
+ if (concept?.fsn && concept.fsn !== concept.pt) c.fsn = concept.fsn;
49733
+ }
49734
+ } catch {}
49735
+ }
49736
+ /**
49643
49737
  * A reference set's inactive members (CHK07). Its member set holds only the
49644
49738
  * active ones, so one count says whether there are any, and a listing which
49645
49739
  * (two off the graph, which already holds the active members).
@@ -50455,6 +50549,10 @@ function reviewLines(c, inactiveListedAbove) {
50455
50549
  lines.push(`Inactive members: ${c.inactive.length}: ${c.inactive.slice(0, 20).join(", ")}${more}.`);
50456
50550
  }
50457
50551
  if (c.impliedInactive?.count) lines.push(sampleLine("Implied inactive codes not listed", c.impliedInactive));
50552
+ for (const d of c.duplicateTerms) {
50553
+ const concepts = d.concepts.map((x) => x.fsn ? `${x.conceptId} |${x.fsn}|` : x.conceptId);
50554
+ lines.push(`Same term, different concepts: |${d.term}| is ${concepts.join(", ")}.`);
50555
+ }
50458
50556
  return lines.length > 0 ? lines : ["Nothing flagged."];
50459
50557
  }
50460
50558
  function errorMessage(error) {
@@ -50667,6 +50765,189 @@ function formatCompressReport(result) {
50667
50765
  });
50668
50766
  return lines.join("\n");
50669
50767
  }
50768
+ // src/minify/minify.ts
50769
+ var import_TerminalNode = require_TerminalNode();
50770
+ var MinifyError = class extends Error {
50771
+ parseErrors;
50772
+ constructor(message, parseErrors) {
50773
+ super(message);
50774
+ this.parseErrors = parseErrors;
50775
+ this.name = "MinifyError";
50776
+ }
50777
+ };
50778
+ /**
50779
+ * Returns the shortest form of an ECL expression that parses to the same
50780
+ * expression.
50781
+ *
50782
+ * - Display terms (`404684003 |Clinical finding|`) are removed.
50783
+ * - Whitespace is removed wherever the grammar makes it optional, and becomes a
50784
+ * single space where it is mandatory (after `AND`, `OR` and `MINUS`, and
50785
+ * between the items of a set such as `(en-au (prefer) en-gb)`).
50786
+ * - A space is also kept where removing it would join two words or numbers
50787
+ * (`D term`, `R 363698007`) or two characters into a different operator
50788
+ * (`< !!>`, `{ {`).
50789
+ * - Quoted strings (term filters, alternate identifiers, dates) are kept as
50790
+ * written, except that a tab or line break in one becomes a space.
50791
+ * - Block comments are kept unless `removeComments` is set.
50792
+ *
50793
+ * The result contains no tab, carriage return or line feed, so it is safe for
50794
+ * an RF2 file. Operand order, brackets and refinement groups are unchanged.
50795
+ *
50796
+ * Throws `MinifyError` if the expression cannot be parsed.
50797
+ */
50798
+ function minifyExpression(expression, options = {}) {
50799
+ const tree = parseOrThrow(expression);
50800
+ const minified = new Minifier(options.removeComments ?? false).print(tree);
50801
+ const check = parseConcreteTree(minified);
50802
+ if (!check.tree || check.errors.length > 0 || structureOf(check.tree) !== structureOf(tree)) throw new MinifyError(`Minifying changed the expression's structure; the result was: ${minified}`, check.errors);
50803
+ return minified;
50804
+ }
50805
+ function parseOrThrow(expression) {
50806
+ const { tree, errors } = parseConcreteTree(expression);
50807
+ if (tree && errors.length === 0) return tree;
50808
+ const friendly = parseECL(expression).errors;
50809
+ const reported = friendly.length > 0 ? friendly : errors;
50810
+ throw new MinifyError(`Cannot minify invalid ECL: ${reported[0]?.message ?? "unknown error"}`, reported);
50811
+ }
50812
+ var VERBATIM_RULES = /* @__PURE__ */ new Set([ECLParser.RULE_matchsearchtermset]);
50813
+ var TERM_BEARING_RULES = /* @__PURE__ */ new Set([ECLParser.RULE_eclconceptreference, ECLParser.RULE_altidentifier]);
50814
+ var LINE_BREAK_OR_TAB = /[\t\r\n]/g;
50815
+ var WHITESPACE_CHAR_RULES = /* @__PURE__ */ new Set([
50816
+ ECLParser.RULE_htab,
50817
+ ECLParser.RULE_cr,
50818
+ ECLParser.RULE_lf
50819
+ ]);
50820
+ var WORD_CHAR = /[\p{L}\p{N}_]/u;
50821
+ var JOINING_PAIRS = /* @__PURE__ */ new Set([
50822
+ "<<",
50823
+ "<!",
50824
+ "<=",
50825
+ ">>",
50826
+ ">!",
50827
+ ">=",
50828
+ "!!",
50829
+ "!=",
50830
+ "!<",
50831
+ "!>",
50832
+ "{{",
50833
+ "}}",
50834
+ "/*",
50835
+ "*/",
50836
+ "//",
50837
+ ".."
50838
+ ]);
50839
+ function needsSpace(before, after) {
50840
+ if (WORD_CHAR.test(before) && WORD_CHAR.test(after)) return true;
50841
+ return JOINING_PAIRS.has(before + after);
50842
+ }
50843
+ var Minifier = class {
50844
+ removeComments;
50845
+ out = "";
50846
+ brokenHere = false;
50847
+ afterUnquotedCode = false;
50848
+ constructor(removeComments) {
50849
+ this.removeComments = removeComments;
50850
+ }
50851
+ print(tree) {
50852
+ this.visit(tree);
50853
+ return this.out;
50854
+ }
50855
+ visit(node) {
50856
+ if (node instanceof import_TerminalNode.TerminalNode) {
50857
+ this.append(node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50858
+ return;
50859
+ }
50860
+ if (!(node instanceof import_antlr4ts.ParserRuleContext)) return;
50861
+ switch (node.ruleIndex) {
50862
+ case ECLParser.RULE_ws:
50863
+ this.separator(node, false);
50864
+ return;
50865
+ case ECLParser.RULE_mws:
50866
+ this.separator(node, true);
50867
+ return;
50868
+ }
50869
+ if (VERBATIM_RULES.has(node.ruleIndex)) {
50870
+ this.append(node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50871
+ return;
50872
+ }
50873
+ if (TERM_BEARING_RULES.has(node.ruleIndex)) {
50874
+ this.visitWithoutTerm(node);
50875
+ return;
50876
+ }
50877
+ for (const child of node.children ?? []) this.visit(child);
50878
+ }
50879
+ /** Prints a concept reference or alternate identifier without its `|term|`. */
50880
+ visitWithoutTerm(node) {
50881
+ const children = node.children ?? [];
50882
+ const firstPipe = children.findIndex((c) => c instanceof import_TerminalNode.TerminalNode && c.text === "|");
50883
+ if (firstPipe === -1) {
50884
+ for (const child of children) this.visit(child);
50885
+ this.noteUnquotedCode(node);
50886
+ return;
50887
+ }
50888
+ for (const child of children.slice(0, firstPipe - 1)) this.visit(child);
50889
+ this.noteUnquotedCode(node);
50890
+ for (const child of children.slice(firstPipe - 1)) if (child instanceof import_antlr4ts.ParserRuleContext && child.ruleIndex === ECLParser.RULE_ws) this.visit(child);
50891
+ this.brokenHere = true;
50892
+ }
50893
+ noteUnquotedCode(node) {
50894
+ const first = node.children?.[0];
50895
+ const quoted = first instanceof import_antlr4ts.ParserRuleContext && first.ruleIndex === ECLParser.RULE_qm;
50896
+ this.afterUnquotedCode = node.ruleIndex === ECLParser.RULE_altidentifier && !quoted;
50897
+ }
50898
+ /** Optional (`ws`) or mandatory (`mws`) whitespace, which may hold comments. */
50899
+ separator(node, mandatory) {
50900
+ if (node.text.length === 0) return;
50901
+ const comments = this.removeComments ? [] : (node.children ?? []).filter((c) => c instanceof import_antlr4ts.ParserRuleContext && c.ruleIndex === ECLParser.RULE_comment);
50902
+ this.brokenHere = true;
50903
+ for (const comment of comments) {
50904
+ this.append(comment.text.replaceAll(/\s+/g, " "));
50905
+ this.brokenHere = true;
50906
+ }
50907
+ if (mandatory && comments.length === 0) {
50908
+ this.out += " ";
50909
+ this.brokenHere = false;
50910
+ }
50911
+ }
50912
+ append(text) {
50913
+ if (text.length === 0) return;
50914
+ const last = this.out.at(-1);
50915
+ const keepApart = needsSpace(last ?? "", text[0]) || this.afterUnquotedCode && text.startsWith(".");
50916
+ if (this.brokenHere && last !== void 0 && keepApart) this.out += " ";
50917
+ this.out += text;
50918
+ this.brokenHere = false;
50919
+ this.afterUnquotedCode = false;
50920
+ }
50921
+ };
50922
+ /**
50923
+ * The parse tree reduced to what the expression means: rule names and
50924
+ * characters, without whitespace, comments, display terms, or the difference
50925
+ * between a tab and a space inside a string.
50926
+ */
50927
+ function structureOf(tree) {
50928
+ const parts = [];
50929
+ const walk = (node) => {
50930
+ if (node instanceof import_TerminalNode.TerminalNode) {
50931
+ parts.push(node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50932
+ return;
50933
+ }
50934
+ if (!(node instanceof import_antlr4ts.ParserRuleContext)) return;
50935
+ const rule = WHITESPACE_CHAR_RULES.has(node.ruleIndex) ? ECLParser.RULE_sp : node.ruleIndex;
50936
+ if (rule === ECLParser.RULE_ws || rule === ECLParser.RULE_mws) return;
50937
+ if (VERBATIM_RULES.has(rule)) {
50938
+ parts.push(`[${rule}]`, node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50939
+ return;
50940
+ }
50941
+ parts.push(`[${rule}]`);
50942
+ const children = node.children ?? [];
50943
+ const firstPipe = TERM_BEARING_RULES.has(rule) ? children.findIndex((c) => c instanceof import_TerminalNode.TerminalNode && c.text === "|") : -1;
50944
+ const kept = firstPipe === -1 ? children : children.slice(0, firstPipe - 1);
50945
+ for (const child of kept) walk(child);
50946
+ parts.push("]");
50947
+ };
50948
+ walk(tree);
50949
+ return parts.join("");
50950
+ }
50670
50951
  // src/knowledge/operators.ts
50671
50952
  /**
50672
50953
  * All 15+ ECL operators with meanings, syntax, and examples.
@@ -51731,6 +52012,7 @@ function getGuide(uri) {
51731
52012
  }
51732
52013
  exports.CanonicaliseError = CanonicaliseError;
51733
52014
  exports.FhirTerminologyService = FhirTerminologyService;
52015
+ exports.MinifyError = MinifyError;
51734
52016
  exports.REFACTORING_RESOLVE_KIND = REFACTORING_RESOLVE_KIND;
51735
52017
  exports.TerminologyError = TerminologyError;
51736
52018
  exports.TerminologyHttpError = TerminologyHttpError;
@@ -51786,6 +52068,7 @@ exports.isValidConceptId = isValidConceptId;
51786
52068
  exports.isValidDescriptionId = isValidDescriptionId;
51787
52069
  exports.isValidSnomedId = isValidSnomedId;
51788
52070
  exports.knowledgeGuides = knowledgeGuides;
52071
+ exports.minifyExpression = minifyExpression;
51789
52072
  exports.offsetAt = offsetAt;
51790
52073
  exports.operatorHoverDocs = operatorHoverDocs;
51791
52074
  exports.parseConceptIdList = parseConceptIdList;
package/dist/index.d.ts CHANGED
@@ -47,6 +47,8 @@ export type { RefinementClause } from './derive/refinements';
47
47
  export type { DeriveInput, DeriveOptions, DeriveResult, DeriveCandidate, DeriveInputReport, CandidateConstruction, SetDifference, CritiqueOptions, CodelistCritique, NearMiss, } from './derive/derive-ecl';
48
48
  export { canonicalise, compareExpressions, CanonicaliseError } from './canonical/comparator';
49
49
  export type { ComparisonResult } from './canonical/comparator';
50
+ export { minifyExpression, MinifyError } from './minify/minify';
51
+ export type { MinifyOptions } from './minify/minify';
50
52
  export { allArticles, getArticle, getArticlesByCategory, operatorHoverDocs, getOperatorHoverDoc, knowledgeGuides, getGuide, } from './knowledge';
51
53
  export type { KnowledgeArticle, KnowledgeGuide, KnowledgeCategory, OperatorHoverDoc } from './knowledge';
52
54
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA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,CAAC;AAGvF,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5F,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACxF,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtF,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC7F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EACL,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.mjs CHANGED
@@ -42419,8 +42419,9 @@ function runParseAttempt(input, predictionMode) {
42419
42419
  parser.removeErrorListeners();
42420
42420
  parser.addErrorListener(errorListener);
42421
42421
  let ast = null;
42422
+ let tree = null;
42422
42423
  try {
42423
- const tree = parser.expressionconstraint();
42424
+ tree = parser.expressionconstraint();
42424
42425
  ast = new ECLASTVisitor().visit(tree);
42425
42426
  const currentToken = parser.currentToken;
42426
42427
  if (currentToken.type !== import_antlr4ts.Token.EOF) {
@@ -42437,7 +42438,8 @@ function runParseAttempt(input, predictionMode) {
42437
42438
  } catch {}
42438
42439
  return {
42439
42440
  ast,
42440
- errors: errorListener.getErrors()
42441
+ errors: errorListener.getErrors(),
42442
+ tree
42441
42443
  };
42442
42444
  }
42443
42445
  /**
@@ -42461,6 +42463,22 @@ function parseWithFallback(input) {
42461
42463
  if (sll.ast !== null && sll.errors.length === 0) return sll;
42462
42464
  return runParseAttempt(input, import_PredictionMode.PredictionMode.LL);
42463
42465
  }
42466
+ /**
42467
+ * Parses `input` and returns the ANTLR parse tree, which keeps every character
42468
+ * of the source: whitespace, comments and display terms included. The AST from
42469
+ * `parseECL` drops these, so code that rewrites the source text exactly (such as
42470
+ * the minifier) walks this tree instead.
42471
+ *
42472
+ * Uses the same SLL-then-LL strategy as `parseECL`. `errors` are ANTLR's raw
42473
+ * messages; call `parseECL` for the clearer ones shown to users.
42474
+ */
42475
+ function parseConcreteTree(input) {
42476
+ const { tree, errors } = parseWithFallback(input);
42477
+ return {
42478
+ tree,
42479
+ errors
42480
+ };
42481
+ }
42464
42482
  function parseECL(input) {
42465
42483
  if (input === lastInput && lastResult !== null) return lastResult;
42466
42484
  const tokenLexer = new ECLLexer(new import_antlr4ts.ANTLRInputStream(input));
@@ -43238,6 +43256,8 @@ function toHttpError(options) {
43238
43256
  return new TerminologyHttpError(`Terminology server returned HTTP ${options.status} for ${options.operation}${suffix}`, options);
43239
43257
  }
43240
43258
  // src/terminology/fhir-service.ts
43259
+ /** SNOMED CT's description type for a fully specified name. */
43260
+ var FSN_TYPE = "900000000000003001";
43241
43261
  /** URL of the R5 `ValueSet.expansion.contains.property` element as an R4 extension. */
43242
43262
  var CONTAINS_PROPERTY_EXTENSION = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property";
43243
43263
  /**
@@ -43607,7 +43627,7 @@ var FhirTerminologyService = class FhirTerminologyService {
43607
43627
  }
43608
43628
  const conceptInfo = {
43609
43629
  id: conceptId,
43610
- fsn: display,
43630
+ fsn: params.filter((p) => p.name === "designation").find((p) => p.part?.some((q) => q.name === "use" && q.valueCoding?.code === FSN_TYPE))?.part?.find((q) => q.name === "value")?.valueString ?? display,
43611
43631
  pt: display,
43612
43632
  active
43613
43633
  };
@@ -43728,7 +43748,7 @@ var FhirTerminologyService = class FhirTerminologyService {
43728
43748
  }));
43729
43749
  }
43730
43750
  async bulkExpand(conceptIds) {
43731
- const url = `${this.baseUrl}/ValueSet/$expand?property=inactive&activeOnly=false`;
43751
+ const url = `${this.baseUrl}/ValueSet/$expand?property=inactive&activeOnly=false&includeDesignations=true`;
43732
43752
  const include = {
43733
43753
  system: "http://snomed.info/sct",
43734
43754
  concept: conceptIds.map((code) => ({ code }))
@@ -43767,7 +43787,7 @@ var FhirTerminologyService = class FhirTerminologyService {
43767
43787
  else if ((entry.property ?? []).find((p) => p.code === "inactive")?.valueBoolean === true) active = false;
43768
43788
  results.set(code, {
43769
43789
  id: code,
43770
- fsn: display,
43790
+ fsn: entry.designation?.find((d) => d.use?.code === FSN_TYPE)?.value ?? display,
43771
43791
  pt: display,
43772
43792
  active
43773
43793
  });
@@ -44086,7 +44106,7 @@ var FhirTerminologyService = class FhirTerminologyService {
44086
44106
  return {
44087
44107
  results: contains.slice(0, 20).map((item) => {
44088
44108
  const display = item.display ?? "";
44089
- const fsnDesignation = item.designation?.find((d) => d.use?.code === "900000000000003001");
44109
+ const fsnDesignation = item.designation?.find((d) => d.use?.code === FSN_TYPE);
44090
44110
  return {
44091
44111
  id: item.code ?? "",
44092
44112
  fsn: fsnDesignation?.value ?? display,
@@ -48495,23 +48515,30 @@ var SetQueries = class {
48495
48515
  }
48496
48516
  /** Up to `max` codes of the set, sorted, plus the set's exact total. */
48497
48517
  async codes(compose, max, activeOnly = true) {
48498
- const codes = [];
48518
+ const { concepts, total } = await this.concepts(compose, max, activeOnly);
48519
+ return {
48520
+ codes: concepts.map((c) => c.code).sort(byId),
48521
+ total
48522
+ };
48523
+ }
48524
+ /** Up to `max` concepts of the set with their terms, in the server's order, plus the set's exact total. */
48525
+ async concepts(compose, max, activeOnly = true) {
48526
+ const concepts = [];
48499
48527
  let total = 0;
48500
- for (let offset = 0; codes.length < max;) {
48528
+ for (let offset = 0; concepts.length < max;) {
48501
48529
  const r = await this.expand(compose, {
48502
- count: Math.min(PAGE_SIZE, max - codes.length),
48530
+ count: Math.min(PAGE_SIZE, max - concepts.length),
48503
48531
  offset,
48504
48532
  activeOnly
48505
48533
  });
48506
48534
  total = r.total;
48507
48535
  if (r.concepts.length === 0) break;
48508
- for (const c of r.concepts) codes.push(c.code);
48536
+ for (const c of r.concepts) concepts.push(c);
48509
48537
  offset += r.concepts.length;
48510
48538
  if (offset >= total) break;
48511
48539
  }
48512
- codes.sort(byId);
48513
48540
  return {
48514
- codes,
48541
+ concepts,
48515
48542
  total
48516
48543
  };
48517
48544
  }
@@ -48865,6 +48892,30 @@ function outermost(g, items, max) {
48865
48892
  }
48866
48893
  return kept;
48867
48894
  }
48895
+ /**
48896
+ * Groups of two or more concepts whose terms match, ordered by term. Runs of
48897
+ * whitespace and the case of the first letter are ignored, as SNOMED CT
48898
+ * terms are mostly case-insensitive only there. Concepts without a term are
48899
+ * left out.
48900
+ */
48901
+ function findDuplicateTerms(concepts) {
48902
+ const groups = /* @__PURE__ */ new Map();
48903
+ for (const { code, display } of concepts) {
48904
+ const term = display.trim().replaceAll(/\s+/g, " ");
48905
+ if (!term) continue;
48906
+ const key = term.charAt(0).toLowerCase() + term.slice(1);
48907
+ const group = groups.get(key) ?? /* @__PURE__ */ new Map();
48908
+ group.set(code, display.trim());
48909
+ groups.set(key, group);
48910
+ }
48911
+ return [...groups].filter(([, g]) => g.size > 1).sort(([a], [b]) => a.localeCompare(b)).map(([, g]) => {
48912
+ const conceptIds = [...g.keys()].sort(byId);
48913
+ return {
48914
+ term: g.get(conceptIds[0]) ?? "",
48915
+ conceptIds
48916
+ };
48917
+ });
48918
+ }
48868
48919
  // src/derive/greedy-grouping.ts
48869
48920
  var MINIMUM_CLUSTER_SIZE = 2;
48870
48921
  var FIT_THRESHOLD = .9;
@@ -49428,7 +49479,8 @@ var CRITIQUE_DEFAULTS = {
49428
49479
  nearMissShare: .9,
49429
49480
  nearMissMinSize: 5,
49430
49481
  maxNearMisses: 5,
49431
- impliedInactive: false
49482
+ impliedInactive: false,
49483
+ maxDuplicateTerms: 20
49432
49484
  };
49433
49485
  /** Above this many concept references, candidates are not formatted or given terms. */
49434
49486
  var MAX_DECORATED_CLAUSES = 200;
@@ -49582,7 +49634,11 @@ async function buildCritique(limits, found, q, terminology, opts) {
49582
49634
  const { input, result, members, graph, hierarchies, scored } = found;
49583
49635
  const induced = scored.filter((s) => s.exact && s.construction.kind !== "refset" && s.construction.kind !== "expression");
49584
49636
  const best = Math.min(members.size, ...induced.map((s) => s.clauses));
49585
- const [near, inactive] = await Promise.all([nearMisses(limits, members, graph, q, terminology, opts, result.notes), "refsetId" in input ? inactiveMembers(members, graph, q, result.notes) : [...result.input.inactive]]);
49637
+ const [near, inactive, duplicateTerms] = await Promise.all([
49638
+ nearMisses(limits, members, graph, q, terminology, opts, result.notes),
49639
+ "refsetId" in input ? inactiveMembers(members, graph, q, result.notes) : [...result.input.inactive],
49640
+ sharedTerms(limits.maxDuplicateTerms, members, q, terminology, opts, result.notes)
49641
+ ]);
49586
49642
  const critique = {
49587
49643
  clauses: {
49588
49644
  best,
@@ -49592,7 +49648,8 @@ async function buildCritique(limits, found, q, terminology, opts) {
49592
49648
  nearMisses: near,
49593
49649
  hierarchies,
49594
49650
  spansHierarchies: hierarchies.length > 1,
49595
- inactive
49651
+ inactive,
49652
+ duplicateTerms
49596
49653
  };
49597
49654
  if (limits.impliedInactive) {
49598
49655
  const profile = limits.impliedInactive === true ? "HISTORY-MOD" : limits.impliedInactive;
@@ -49643,6 +49700,43 @@ async function nearMisses(limits, members, graph, q, terminology, opts, notes) {
49643
49700
  return found;
49644
49701
  }
49645
49702
  /**
49703
+ * Members that share a preferred term (CHK13): one listing of the members with
49704
+ * their terms, plus a lookup of the FSNs that tell each group apart.
49705
+ */
49706
+ async function sharedTerms(max, members, q, terminology, opts, notes) {
49707
+ const limit = Math.max(0, Math.floor(max));
49708
+ if (limit === 0) return [];
49709
+ if (members.size > opts.maxGraphConcepts) {
49710
+ notes.push(`Shared terms were not checked: the list has ${members.size} members, more than ${opts.maxGraphConcepts} (maxGraphConcepts).`);
49711
+ return [];
49712
+ }
49713
+ let groups;
49714
+ try {
49715
+ groups = findDuplicateTerms((await q.concepts({ include: [members.clause] }, members.size)).concepts);
49716
+ } catch (error) {
49717
+ notes.push(`Shared terms were not checked: ${errorMessage(error)}.`);
49718
+ return [];
49719
+ }
49720
+ if (groups.length > limit) notes.push(`${plural(groups.length, "term")} ${groups.length === 1 ? "is" : "are"} shared by more than one member; the first ${limit} ${limit === 1 ? "is" : "are"} listed (maxDuplicateTerms).`);
49721
+ const found = groups.slice(0, limit).map((g) => ({
49722
+ term: g.term,
49723
+ concepts: g.conceptIds.map((conceptId) => ({ conceptId }))
49724
+ }));
49725
+ if (!opts.omitTerms && found.length > 0) await addFsns(found, terminology);
49726
+ return found;
49727
+ }
49728
+ /** Each concept's FSN, where it says more than the shared term. */
49729
+ async function addFsns(found, terminology) {
49730
+ const concepts = found.flatMap((d) => d.concepts);
49731
+ try {
49732
+ const info = await terminology.validateConcepts(concepts.map((c) => c.conceptId));
49733
+ for (const c of concepts) {
49734
+ const concept = info.get(c.conceptId);
49735
+ if (concept?.fsn && concept.fsn !== concept.pt) c.fsn = concept.fsn;
49736
+ }
49737
+ } catch {}
49738
+ }
49739
+ /**
49646
49740
  * A reference set's inactive members (CHK07). Its member set holds only the
49647
49741
  * active ones, so one count says whether there are any, and a listing which
49648
49742
  * (two off the graph, which already holds the active members).
@@ -50458,6 +50552,10 @@ function reviewLines(c, inactiveListedAbove) {
50458
50552
  lines.push(`Inactive members: ${c.inactive.length}: ${c.inactive.slice(0, 20).join(", ")}${more}.`);
50459
50553
  }
50460
50554
  if (c.impliedInactive?.count) lines.push(sampleLine("Implied inactive codes not listed", c.impliedInactive));
50555
+ for (const d of c.duplicateTerms) {
50556
+ const concepts = d.concepts.map((x) => x.fsn ? `${x.conceptId} |${x.fsn}|` : x.conceptId);
50557
+ lines.push(`Same term, different concepts: |${d.term}| is ${concepts.join(", ")}.`);
50558
+ }
50461
50559
  return lines.length > 0 ? lines : ["Nothing flagged."];
50462
50560
  }
50463
50561
  function errorMessage(error) {
@@ -50670,6 +50768,189 @@ function formatCompressReport(result) {
50670
50768
  });
50671
50769
  return lines.join("\n");
50672
50770
  }
50771
+ // src/minify/minify.ts
50772
+ var import_TerminalNode = require_TerminalNode();
50773
+ var MinifyError = class extends Error {
50774
+ parseErrors;
50775
+ constructor(message, parseErrors) {
50776
+ super(message);
50777
+ this.parseErrors = parseErrors;
50778
+ this.name = "MinifyError";
50779
+ }
50780
+ };
50781
+ /**
50782
+ * Returns the shortest form of an ECL expression that parses to the same
50783
+ * expression.
50784
+ *
50785
+ * - Display terms (`404684003 |Clinical finding|`) are removed.
50786
+ * - Whitespace is removed wherever the grammar makes it optional, and becomes a
50787
+ * single space where it is mandatory (after `AND`, `OR` and `MINUS`, and
50788
+ * between the items of a set such as `(en-au (prefer) en-gb)`).
50789
+ * - A space is also kept where removing it would join two words or numbers
50790
+ * (`D term`, `R 363698007`) or two characters into a different operator
50791
+ * (`< !!>`, `{ {`).
50792
+ * - Quoted strings (term filters, alternate identifiers, dates) are kept as
50793
+ * written, except that a tab or line break in one becomes a space.
50794
+ * - Block comments are kept unless `removeComments` is set.
50795
+ *
50796
+ * The result contains no tab, carriage return or line feed, so it is safe for
50797
+ * an RF2 file. Operand order, brackets and refinement groups are unchanged.
50798
+ *
50799
+ * Throws `MinifyError` if the expression cannot be parsed.
50800
+ */
50801
+ function minifyExpression(expression, options = {}) {
50802
+ const tree = parseOrThrow(expression);
50803
+ const minified = new Minifier(options.removeComments ?? false).print(tree);
50804
+ const check = parseConcreteTree(minified);
50805
+ if (!check.tree || check.errors.length > 0 || structureOf(check.tree) !== structureOf(tree)) throw new MinifyError(`Minifying changed the expression's structure; the result was: ${minified}`, check.errors);
50806
+ return minified;
50807
+ }
50808
+ function parseOrThrow(expression) {
50809
+ const { tree, errors } = parseConcreteTree(expression);
50810
+ if (tree && errors.length === 0) return tree;
50811
+ const friendly = parseECL(expression).errors;
50812
+ const reported = friendly.length > 0 ? friendly : errors;
50813
+ throw new MinifyError(`Cannot minify invalid ECL: ${reported[0]?.message ?? "unknown error"}`, reported);
50814
+ }
50815
+ var VERBATIM_RULES = /* @__PURE__ */ new Set([ECLParser.RULE_matchsearchtermset]);
50816
+ var TERM_BEARING_RULES = /* @__PURE__ */ new Set([ECLParser.RULE_eclconceptreference, ECLParser.RULE_altidentifier]);
50817
+ var LINE_BREAK_OR_TAB = /[\t\r\n]/g;
50818
+ var WHITESPACE_CHAR_RULES = /* @__PURE__ */ new Set([
50819
+ ECLParser.RULE_htab,
50820
+ ECLParser.RULE_cr,
50821
+ ECLParser.RULE_lf
50822
+ ]);
50823
+ var WORD_CHAR = /[\p{L}\p{N}_]/u;
50824
+ var JOINING_PAIRS = /* @__PURE__ */ new Set([
50825
+ "<<",
50826
+ "<!",
50827
+ "<=",
50828
+ ">>",
50829
+ ">!",
50830
+ ">=",
50831
+ "!!",
50832
+ "!=",
50833
+ "!<",
50834
+ "!>",
50835
+ "{{",
50836
+ "}}",
50837
+ "/*",
50838
+ "*/",
50839
+ "//",
50840
+ ".."
50841
+ ]);
50842
+ function needsSpace(before, after) {
50843
+ if (WORD_CHAR.test(before) && WORD_CHAR.test(after)) return true;
50844
+ return JOINING_PAIRS.has(before + after);
50845
+ }
50846
+ var Minifier = class {
50847
+ removeComments;
50848
+ out = "";
50849
+ brokenHere = false;
50850
+ afterUnquotedCode = false;
50851
+ constructor(removeComments) {
50852
+ this.removeComments = removeComments;
50853
+ }
50854
+ print(tree) {
50855
+ this.visit(tree);
50856
+ return this.out;
50857
+ }
50858
+ visit(node) {
50859
+ if (node instanceof import_TerminalNode.TerminalNode) {
50860
+ this.append(node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50861
+ return;
50862
+ }
50863
+ if (!(node instanceof import_antlr4ts.ParserRuleContext)) return;
50864
+ switch (node.ruleIndex) {
50865
+ case ECLParser.RULE_ws:
50866
+ this.separator(node, false);
50867
+ return;
50868
+ case ECLParser.RULE_mws:
50869
+ this.separator(node, true);
50870
+ return;
50871
+ }
50872
+ if (VERBATIM_RULES.has(node.ruleIndex)) {
50873
+ this.append(node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50874
+ return;
50875
+ }
50876
+ if (TERM_BEARING_RULES.has(node.ruleIndex)) {
50877
+ this.visitWithoutTerm(node);
50878
+ return;
50879
+ }
50880
+ for (const child of node.children ?? []) this.visit(child);
50881
+ }
50882
+ /** Prints a concept reference or alternate identifier without its `|term|`. */
50883
+ visitWithoutTerm(node) {
50884
+ const children = node.children ?? [];
50885
+ const firstPipe = children.findIndex((c) => c instanceof import_TerminalNode.TerminalNode && c.text === "|");
50886
+ if (firstPipe === -1) {
50887
+ for (const child of children) this.visit(child);
50888
+ this.noteUnquotedCode(node);
50889
+ return;
50890
+ }
50891
+ for (const child of children.slice(0, firstPipe - 1)) this.visit(child);
50892
+ this.noteUnquotedCode(node);
50893
+ for (const child of children.slice(firstPipe - 1)) if (child instanceof import_antlr4ts.ParserRuleContext && child.ruleIndex === ECLParser.RULE_ws) this.visit(child);
50894
+ this.brokenHere = true;
50895
+ }
50896
+ noteUnquotedCode(node) {
50897
+ const first = node.children?.[0];
50898
+ const quoted = first instanceof import_antlr4ts.ParserRuleContext && first.ruleIndex === ECLParser.RULE_qm;
50899
+ this.afterUnquotedCode = node.ruleIndex === ECLParser.RULE_altidentifier && !quoted;
50900
+ }
50901
+ /** Optional (`ws`) or mandatory (`mws`) whitespace, which may hold comments. */
50902
+ separator(node, mandatory) {
50903
+ if (node.text.length === 0) return;
50904
+ const comments = this.removeComments ? [] : (node.children ?? []).filter((c) => c instanceof import_antlr4ts.ParserRuleContext && c.ruleIndex === ECLParser.RULE_comment);
50905
+ this.brokenHere = true;
50906
+ for (const comment of comments) {
50907
+ this.append(comment.text.replaceAll(/\s+/g, " "));
50908
+ this.brokenHere = true;
50909
+ }
50910
+ if (mandatory && comments.length === 0) {
50911
+ this.out += " ";
50912
+ this.brokenHere = false;
50913
+ }
50914
+ }
50915
+ append(text) {
50916
+ if (text.length === 0) return;
50917
+ const last = this.out.at(-1);
50918
+ const keepApart = needsSpace(last ?? "", text[0]) || this.afterUnquotedCode && text.startsWith(".");
50919
+ if (this.brokenHere && last !== void 0 && keepApart) this.out += " ";
50920
+ this.out += text;
50921
+ this.brokenHere = false;
50922
+ this.afterUnquotedCode = false;
50923
+ }
50924
+ };
50925
+ /**
50926
+ * The parse tree reduced to what the expression means: rule names and
50927
+ * characters, without whitespace, comments, display terms, or the difference
50928
+ * between a tab and a space inside a string.
50929
+ */
50930
+ function structureOf(tree) {
50931
+ const parts = [];
50932
+ const walk = (node) => {
50933
+ if (node instanceof import_TerminalNode.TerminalNode) {
50934
+ parts.push(node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50935
+ return;
50936
+ }
50937
+ if (!(node instanceof import_antlr4ts.ParserRuleContext)) return;
50938
+ const rule = WHITESPACE_CHAR_RULES.has(node.ruleIndex) ? ECLParser.RULE_sp : node.ruleIndex;
50939
+ if (rule === ECLParser.RULE_ws || rule === ECLParser.RULE_mws) return;
50940
+ if (VERBATIM_RULES.has(rule)) {
50941
+ parts.push(`[${rule}]`, node.text.replaceAll(LINE_BREAK_OR_TAB, " "));
50942
+ return;
50943
+ }
50944
+ parts.push(`[${rule}]`);
50945
+ const children = node.children ?? [];
50946
+ const firstPipe = TERM_BEARING_RULES.has(rule) ? children.findIndex((c) => c instanceof import_TerminalNode.TerminalNode && c.text === "|") : -1;
50947
+ const kept = firstPipe === -1 ? children : children.slice(0, firstPipe - 1);
50948
+ for (const child of kept) walk(child);
50949
+ parts.push("]");
50950
+ };
50951
+ walk(tree);
50952
+ return parts.join("");
50953
+ }
50673
50954
  // src/knowledge/operators.ts
50674
50955
  /**
50675
50956
  * All 15+ ECL operators with meanings, syntax, and examples.
@@ -51732,4 +52013,4 @@ var knowledgeGuides = [
51732
52013
  function getGuide(uri) {
51733
52014
  return knowledgeGuides.find((g) => g.uri === uri);
51734
52015
  }
51735
- export { CanonicaliseError, FhirTerminologyService, REFACTORING_RESOLVE_KIND, TerminologyError, TerminologyHttpError, TerminologyTransportError, allArticles, analyzeExpression, buildReplacementText, canonicalise, checkMixedRefinementOperators, clearFilterCache, compareExpressions, compressExpression, computeSemanticTokens, coreInsert, coreReplace, defaultFormattingOptions, deriveEcl, deriveInputFromText, detectCursorContext, detectFilterContext, eclSnippetCompletions, eclTokenModifiers, eclTokenTypes, expandToExpressionBoundaries, extractCompoundOperands, extractConceptIds, extractConceptSearchQuery, extractRefinementInfo, extractText, formatCompressReport, formatDeriveReport, formatDocument, formatRangeExpressions, getArticle, getArticlesByCategory, getCompletionItems, getCompletionItemsWithSearch, getConceptSearchPriority, getExpressionsInRange, getFhirFilterCompletions, getGuide, getOperatorHoverDoc, getRefactoringActions, getText, getValidOperatorsAtPosition, groupIntoExpressions, isConceptPositionValid, isEclEvaluationStrategy, isTerminologyError, isTerminologyHttpError, isTerminologyTransportError, isValidConceptId, isValidDescriptionId, isValidSnomedId, knowledgeGuides, offsetAt, operatorHoverDocs, parseConceptIdList, parseECL, positionAt, refineParseError, resolveAddDisplayTerms, resolveUnifiedSimplify, simplifyExpression, toHttpError, toTransportError, validateBoolean, validateIndentSize, validateIndentStyle, validateMaxLineLength, validateSemantics };
52016
+ export { CanonicaliseError, FhirTerminologyService, MinifyError, REFACTORING_RESOLVE_KIND, TerminologyError, TerminologyHttpError, TerminologyTransportError, allArticles, analyzeExpression, buildReplacementText, canonicalise, checkMixedRefinementOperators, clearFilterCache, compareExpressions, compressExpression, computeSemanticTokens, coreInsert, coreReplace, defaultFormattingOptions, deriveEcl, deriveInputFromText, detectCursorContext, detectFilterContext, eclSnippetCompletions, eclTokenModifiers, eclTokenTypes, expandToExpressionBoundaries, extractCompoundOperands, extractConceptIds, extractConceptSearchQuery, extractRefinementInfo, extractText, formatCompressReport, formatDeriveReport, formatDocument, formatRangeExpressions, getArticle, getArticlesByCategory, getCompletionItems, getCompletionItemsWithSearch, getConceptSearchPriority, getExpressionsInRange, getFhirFilterCompletions, getGuide, getOperatorHoverDoc, getRefactoringActions, getText, getValidOperatorsAtPosition, groupIntoExpressions, isConceptPositionValid, isEclEvaluationStrategy, isTerminologyError, isTerminologyHttpError, isTerminologyTransportError, isValidConceptId, isValidDescriptionId, isValidSnomedId, knowledgeGuides, minifyExpression, offsetAt, operatorHoverDocs, parseConceptIdList, parseECL, positionAt, refineParseError, resolveAddDisplayTerms, resolveUnifiedSimplify, simplifyExpression, toHttpError, toTransportError, validateBoolean, validateIndentSize, validateIndentStyle, validateMaxLineLength, validateSemantics };
@@ -0,0 +1,34 @@
1
+ import { ParseError } from '../parser/error-listener';
2
+ export interface MinifyOptions {
3
+ /**
4
+ * Remove block comments. Default `false`: comments are kept, with the
5
+ * whitespace inside them collapsed, because they cannot be reconstructed.
6
+ */
7
+ removeComments?: boolean;
8
+ }
9
+ export declare class MinifyError extends Error {
10
+ readonly parseErrors: ParseError[];
11
+ constructor(message: string, parseErrors: ParseError[]);
12
+ }
13
+ /**
14
+ * Returns the shortest form of an ECL expression that parses to the same
15
+ * expression.
16
+ *
17
+ * - Display terms (`404684003 |Clinical finding|`) are removed.
18
+ * - Whitespace is removed wherever the grammar makes it optional, and becomes a
19
+ * single space where it is mandatory (after `AND`, `OR` and `MINUS`, and
20
+ * between the items of a set such as `(en-au (prefer) en-gb)`).
21
+ * - A space is also kept where removing it would join two words or numbers
22
+ * (`D term`, `R 363698007`) or two characters into a different operator
23
+ * (`< !!>`, `{ {`).
24
+ * - Quoted strings (term filters, alternate identifiers, dates) are kept as
25
+ * written, except that a tab or line break in one becomes a space.
26
+ * - Block comments are kept unless `removeComments` is set.
27
+ *
28
+ * The result contains no tab, carriage return or line feed, so it is safe for
29
+ * an RF2 file. Operand order, brackets and refinement groups are unchanged.
30
+ *
31
+ * Throws `MinifyError` if the expression cannot be parsed.
32
+ */
33
+ export declare function minifyExpression(expression: string, options?: MinifyOptions): string;
34
+ //# sourceMappingURL=minify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minify.d.ts","sourceRoot":"","sources":["../../src/minify/minify.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,qBAAa,WAAY,SAAQ,KAAK;aAGlB,WAAW,EAAE,UAAU,EAAE;gBADzC,OAAO,EAAE,MAAM,EACC,WAAW,EAAE,UAAU,EAAE;CAK5C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAWxF"}
@@ -1,3 +1,4 @@
1
+ import { ExpressionconstraintContext } from './generated/grammar/ECLParser';
1
2
  import { ParseError } from './error-listener';
2
3
  import { ExpressionNode, Range } from './ast';
3
4
  import { RefinementWarning } from './refinement-check';
@@ -19,6 +20,19 @@ export interface ParseResult {
19
20
  warnings: RefinementWarning[];
20
21
  tokens: TokenInfo[];
21
22
  }
23
+ /**
24
+ * Parses `input` and returns the ANTLR parse tree, which keeps every character
25
+ * of the source: whitespace, comments and display terms included. The AST from
26
+ * `parseECL` drops these, so code that rewrites the source text exactly (such as
27
+ * the minifier) walks this tree instead.
28
+ *
29
+ * Uses the same SLL-then-LL strategy as `parseECL`. `errors` are ANTLR's raw
30
+ * messages; call `parseECL` for the clearer ones shown to users.
31
+ */
32
+ export declare function parseConcreteTree(input: string): {
33
+ tree: ExpressionconstraintContext | null;
34
+ errors: ParseError[];
35
+ };
22
36
  export declare function parseECL(input: string): ParseResult;
23
37
  export * from './ast';
24
38
  export * from './visitor';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAoB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAiC,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,cAAc,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB;;;;;;OAMG;IACH,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AA0FD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CA8InD;AAED,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAa,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEvF,OAAO,EAAoB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAiC,iBAAiB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SAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoB/E;;;;;;;OAOG;YACW,qBAAqB;IAuCnC,2GAA2G;IAC3G,OAAO,CAAC,0BAA0B;IAKlC;;;;OAIG;YACW,qBAAqB;IA4BnC;;;;;;;OAOG;IACG,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC;IAczF,0GAA0G;IAC1G,OAAO,CAAC,MAAM,CAAC,eAAe;IAsB9B,gGAAgG;IAChG,OAAO,CAAC,MAAM,CAAC,QAAQ;IAUvB;;;;;;;OAOG;IACG,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwC9G;;;;;;;;OAQG;IACH,OAAO,CAAC,0BAA0B;IAUlC,uFAAuF;IACvF,OAAO,CAAC,gBAAgB;IAQxB,kFAAkF;YACpE,oBAAoB;IASlC,yFAAyF;IACzF,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,qBAAqB;YAkBf,cAAc;IAsC5B,4EAA4E;IACtE,iBAAiB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAgDpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aehrc/ecl-core",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -50,13 +50,13 @@
50
50
  "node-fetch": "^2.7.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/node": "^26.6.3",
53
+ "@types/node": "^26.6.6",
54
54
  "@types/node-fetch": "^2.6.9",
55
55
  "antlr4ts-cli": "^0.5.0-alpha.4",
56
56
  "rimraf": "^5.0.5",
57
57
  "typescript": "^6.0.2",
58
58
  "vite": "^8.2.2",
59
- "vite-plugin-dts": "^5.1.1",
59
+ "vite-plugin-dts": "^5.1.2",
60
60
  "vite-plugin-node-polyfills": "^0.28.0"
61
61
  }
62
62
  }