@glion/lint-profile-field-max-length 0.26.0 → 0.27.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Rethink Health
3
+ Copyright (c) 2023 Rethink Health, SUARL
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -77,7 +77,7 @@ PID|1||PATID1234^^^HOSP^MR||DOE^JANE||19800101|F
77
77
  Reported message:
78
78
 
79
79
  ```
80
- Field `MSH-10` (Message Control ID) is 28 characters long; it allows at most 20 characters.
80
+ The value is 28 characters long; the field allows at most 20 characters.
81
81
  ```
82
82
 
83
83
  A composite value such as `DOE^JANE` counts as 7 characters, not 8.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWvC;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,uBAAuB,mDA8B5B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWvC;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,uBAAuB,mDAwB5B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { getLength } from "@glion/utils";
3
3
  import pluralize from "pluralize";
4
4
  import { lintRule } from "unified-lint-rule";
5
5
  //#region src/index.ts
6
- const messages = { tooLong: (field, name, length, max) => `Field \`${field}\` (${name}) is ${pluralize("character", length, true)} long; it allows at most ${pluralize("character", max, true)}.` };
6
+ const messages = { tooLong: (length, max) => `The value is ${pluralize("character", length, true)} long; the field allows at most ${pluralize("character", max, true)}.` };
7
7
  /**
8
8
  * Lint rule that reports a field repetition longer than the field's LEN.
9
9
  *
@@ -24,13 +24,11 @@ const hl7v2LintFieldMaxLength = lintRule({
24
24
  url: "https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-field-max-length#readme"
25
25
  }, (tree, file) => {
26
26
  visit(tree, "field", (field, ancestors) => {
27
- const id = field.data?.id;
28
- const maxLength = field.data?.maxLength;
29
- if (id === void 0 || maxLength === void 0) return SKIP;
27
+ const maxLength = field.data?.maxLength ?? Number.POSITIVE_INFINITY;
30
28
  for (const repetition of field.children) {
31
29
  const length = getLength(repetition);
32
30
  if (length > maxLength) {
33
- const message = file.message(messages.tooLong(id, field.data?.name ?? "", length, maxLength), {
31
+ const message = file.message(messages.tooLong(length, maxLength), {
34
32
  ancestors: [
35
33
  ...ancestors,
36
34
  field,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\nimport type { Root } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport { getLength } from \"@glion/utils\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\n\nconst messages = {\n tooLong: (field: string, name: string, length: number, max: number) =>\n `Field \\`${field}\\` (${name}) is ${pluralize(\"character\", length, true)} long; it allows at most ${pluralize(\"character\", max, true)}.`,\n} as const;\n\n/**\n * Lint rule that reports a field repetition longer than the field's LEN.\n *\n * Reads `maxLength` from `field.data`, so `@glion/annotate-profile-fields`\n * MUST run before it. The length of a repetition is the sum of its values,\n * delimiters excluded.\n *\n * @example\n * ```typescript\n * unified()\n * .use(hl7v2AnnotateProfileContext)\n * .use(hl7v2AnnotateProfileFields)\n * .use(hl7v2LintFieldMaxLength);\n * ```;\n */\nconst hl7v2LintFieldMaxLength = lintRule<Root>(\n {\n origin: \"hl7v2-lint:field-max-length\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-field-max-length#readme\",\n },\n (tree, file) => {\n visit(tree, \"field\", (field, ancestors) => {\n const id = field.data?.id;\n const maxLength = field.data?.maxLength;\n if (id === undefined || maxLength === undefined) {\n return SKIP;\n }\n\n // HL7v2 applies LEN to each repetition, not to the whole field.\n for (const repetition of field.children) {\n const length = getLength(repetition);\n if (length > maxLength) {\n const message = file.message(\n messages.tooLong(id, field.data?.name ?? \"\", length, maxLength),\n {\n ancestors: [...ancestors, field, repetition],\n place: repetition.position ?? field.position,\n }\n );\n message.actual = String(length);\n }\n }\n return SKIP;\n });\n }\n);\n\nexport default hl7v2LintFieldMaxLength;\n"],"mappings":";;;;;AAQA,MAAM,WAAW,EACf,UAAU,OAAe,MAAc,QAAgB,QACrD,WAAW,MAAM,MAAM,KAAK,OAAO,UAAU,aAAa,QAAQ,KAAK,CAAC,2BAA2B,UAAU,aAAa,KAAK,KAAK,CAAC,IACxI;;;;;;;;;;;;;;;;AAiBD,MAAM,0BAA0B,SAC9B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;AACd,OAAM,MAAM,UAAU,OAAO,cAAc;EACzC,MAAM,KAAK,MAAM,MAAM;EACvB,MAAM,YAAY,MAAM,MAAM;AAC9B,MAAI,OAAO,KAAA,KAAa,cAAc,KAAA,EACpC,QAAO;AAIT,OAAK,MAAM,cAAc,MAAM,UAAU;GACvC,MAAM,SAAS,UAAU,WAAW;AACpC,OAAI,SAAS,WAAW;IACtB,MAAM,UAAU,KAAK,QACnB,SAAS,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,QAAQ,UAAU,EAC/D;KACE,WAAW;MAAC,GAAG;MAAW;MAAO;MAAW;KAC5C,OAAO,WAAW,YAAY,MAAM;KACrC,CACF;AACD,YAAQ,SAAS,OAAO,OAAO;;;AAGnC,SAAO;GACP;EAEL"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\nimport type { Root } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport { getLength } from \"@glion/utils\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\n\nconst messages = {\n tooLong: (length: number, max: number) =>\n `The value is ${pluralize(\"character\", length, true)} long; the field allows at most ${pluralize(\"character\", max, true)}.`,\n} as const;\n\n/**\n * Lint rule that reports a field repetition longer than the field's LEN.\n *\n * Reads `maxLength` from `field.data`, so `@glion/annotate-profile-fields`\n * MUST run before it. The length of a repetition is the sum of its values,\n * delimiters excluded.\n *\n * @example\n * ```typescript\n * unified()\n * .use(hl7v2AnnotateProfileContext)\n * .use(hl7v2AnnotateProfileFields)\n * .use(hl7v2LintFieldMaxLength);\n * ```;\n */\nconst hl7v2LintFieldMaxLength = lintRule<Root>(\n {\n origin: \"hl7v2-lint:field-max-length\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-profile-field-max-length#readme\",\n },\n (tree, file) => {\n visit(tree, \"field\", (field, ancestors) => {\n // A field without a LEN has no maximum length.\n const maxLength = field.data?.maxLength ?? Number.POSITIVE_INFINITY;\n\n // HL7v2 applies LEN to each repetition, not to the whole field.\n for (const repetition of field.children) {\n const length = getLength(repetition);\n if (length > maxLength) {\n const message = file.message(messages.tooLong(length, maxLength), {\n ancestors: [...ancestors, field, repetition],\n place: repetition.position ?? field.position,\n });\n message.actual = String(length);\n }\n }\n return SKIP;\n });\n }\n);\n\nexport default hl7v2LintFieldMaxLength;\n"],"mappings":";;;;;AAQA,MAAM,WAAW,EACf,UAAU,QAAgB,QACxB,gBAAgB,UAAU,aAAa,QAAQ,KAAK,CAAC,kCAAkC,UAAU,aAAa,KAAK,KAAK,CAAC,IAC5H;;;;;;;;;;;;;;;;AAiBD,MAAM,0BAA0B,SAC9B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,SAAS;AACd,OAAM,MAAM,UAAU,OAAO,cAAc;EAEzC,MAAM,YAAY,MAAM,MAAM,aAAa,OAAO;AAGlD,OAAK,MAAM,cAAc,MAAM,UAAU;GACvC,MAAM,SAAS,UAAU,WAAW;AACpC,OAAI,SAAS,WAAW;IACtB,MAAM,UAAU,KAAK,QAAQ,SAAS,QAAQ,QAAQ,UAAU,EAAE;KAChE,WAAW;MAAC,GAAG;MAAW;MAAO;MAAW;KAC5C,OAAO,WAAW,YAAY,MAAM;KACrC,CAAC;AACF,YAAQ,SAAS,OAAO,OAAO;;;AAGnC,SAAO;GACP;EAEL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/lint-profile-field-max-length",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Lint rule to validate field value lengths against HL7v2 profile maxLength",
5
5
  "keywords": [
6
6
  "health",
@@ -35,12 +35,14 @@
35
35
  "dependencies": {
36
36
  "pluralize": "8.0.0",
37
37
  "unified-lint-rule": "3.0.1",
38
- "@glion/annotate-profile-fields": "0.26.0",
39
- "@glion/ast": "0.26.0",
40
- "@glion/util-visit": "0.26.0",
41
- "@glion/utils": "0.26.0"
38
+ "@glion/annotate-profile-fields": "0.27.0",
39
+ "@glion/ast": "0.27.0",
40
+ "@glion/util-visit": "0.27.0",
41
+ "@glion/utils": "0.27.0"
42
42
  },
43
43
  "devDependencies": {
44
+ "@stryker-mutator/core": "10.0.0",
45
+ "@stryker-mutator/vitest-runner": "10.0.0",
44
46
  "@types/node": "25.6.0",
45
47
  "@types/pluralize": "^0.0.33",
46
48
  "@vitest/coverage-v8": "4.1.11",
@@ -50,10 +52,10 @@
50
52
  "unified": "^11.0.5",
51
53
  "vfile": "^6.0.3",
52
54
  "vitest": "4.1.11",
53
- "@glion/annotate-profile-context": "0.26.0",
54
- "@glion/builder": "0.26.0",
55
+ "@glion/annotate-profile-context": "0.27.0",
56
+ "@glion/builder": "0.27.0",
55
57
  "@glion/check-readme": "0.18.0",
56
- "@glion/parser": "0.26.0",
58
+ "@glion/parser": "0.27.0",
57
59
  "@glion/testing": "0.18.0",
58
60
  "@glion/tsconfig": "0.18.0"
59
61
  },
@@ -64,9 +66,10 @@
64
66
  "build": "tsdown && tsc --emitDeclarationOnly",
65
67
  "check-types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
66
68
  "check:readme": "glion-check-readme",
69
+ "mutate": "stryker run",
70
+ "publint": "publint --strict",
67
71
  "test": "vitest run",
68
72
  "test:coverage": "vitest run --coverage",
69
- "test:watch": "vitest",
70
- "publint": "publint --strict"
73
+ "test:watch": "vitest"
71
74
  }
72
75
  }