@glion/lint-max-message-size 0.26.0 → 0.27.1
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 +1 -1
- package/README.md +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Lint rule that flags HL7v2 messages exceeding a maximum byte size or segment cou
|
|
|
4
4
|
|
|
5
5
|
## What it does
|
|
6
6
|
|
|
7
|
-
Measures the UTF-8 byte length of the source message and, optionally, the number of segment nodes in the tree. Reports a warning when the message is larger than `maxBytes` (default 10,000,000) or when `maxSegments` is set and the tree contains more segments than allowed. Intended to protect downstream systems from oversized payloads that would cause resource or protocol limits to be hit.
|
|
7
|
+
Measures the UTF-8 byte length of the source message (0 for a file with no value) and, optionally, the number of segment nodes in the tree. Reports a warning when the message is larger than `maxBytes` (default 10,000,000) or when `maxSegments` is set and the tree contains more segments than allowed. Intended to protect downstream systems from oversized payloads that would cause resource or protocol limits to be hit.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKvC,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD;;;;;GAKG;AACH,QAAA,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKvC,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD;;;;;GAKG;AACH,QAAA,MAAM,uBAAuB,iEAiC5B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ const hl7v2LintMaxMessageSize = lintRule({
|
|
|
24
24
|
...defaultOptions,
|
|
25
25
|
...opts
|
|
26
26
|
};
|
|
27
|
-
const byteLength = Buffer.byteLength(
|
|
27
|
+
const byteLength = Buffer.byteLength(file.value ?? "");
|
|
28
28
|
if (byteLength > options.maxBytes) {
|
|
29
29
|
const message = file.message(messages.tooManyBytes(byteLength, options.maxBytes));
|
|
30
30
|
message.actual = String(byteLength);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Node } from \"@glion/ast\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { SKIP, visit } from \"unist-util-visit\";\n\nexport interface MaxMessageSizeOptions {\n /**\n * Max allowed size of the HL7v2 message in bytes (UTF-8). Default: 1_000_000\n * (1MB).\n */\n maxBytes?: number;\n /**\n * Max allowed number of segments (counts nodes with `type: \"segment\"`).\n * Default: undefined (disabled). Set to a number to enable.\n */\n maxSegments?: number;\n}\n\nconst messages = {\n tooManyBytes: (byteLength: number, maxBytes: number) =>\n `The message is ${pluralize(\"byte\", byteLength, true)}; the configured limit is ${pluralize(\"byte\", maxBytes, true)}. Shorten the message or raise \\`maxBytes\\`.`,\n tooManySegments: (segmentCount: number, maxSegments: number) =>\n `The message has ${pluralize(\"segment\", segmentCount, true)}; the configured limit is ${pluralize(\"segment\", maxSegments, true)}. Remove segments or raise \\`maxSegments\\`.`,\n} as const;\n\nconst defaultOptions: Required<Omit<MaxMessageSizeOptions, \"maxSegments\">> & {\n maxSegments?: number;\n} = {\n maxBytes: 10_000_000, // 10MB\n maxSegments: undefined,\n};\n\n/**\n * Hl7v2-lint rule to warn when message size exceeds the maximum allowed size.\n *\n * This rule is useful for ensuring that HL7v2 messages do not exceed a safe\n * or expected size limit (default: 10MB).\n */\nconst hl7v2LintMaxMessageSize = lintRule<Node, MaxMessageSizeOptions>(\n {\n origin: \"hl7v2-lint:max-message-size\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-max-message-size#readme\",\n },\n (tree, file, opts) => {\n const options = { ...defaultOptions, ...opts };\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Node } from \"@glion/ast\";\nimport pluralize from \"pluralize\";\nimport { lintRule } from \"unified-lint-rule\";\nimport { SKIP, visit } from \"unist-util-visit\";\n\nexport interface MaxMessageSizeOptions {\n /**\n * Max allowed size of the HL7v2 message in bytes (UTF-8). Default: 1_000_000\n * (1MB).\n */\n maxBytes?: number;\n /**\n * Max allowed number of segments (counts nodes with `type: \"segment\"`).\n * Default: undefined (disabled). Set to a number to enable.\n */\n maxSegments?: number;\n}\n\nconst messages = {\n tooManyBytes: (byteLength: number, maxBytes: number) =>\n `The message is ${pluralize(\"byte\", byteLength, true)}; the configured limit is ${pluralize(\"byte\", maxBytes, true)}. Shorten the message or raise \\`maxBytes\\`.`,\n tooManySegments: (segmentCount: number, maxSegments: number) =>\n `The message has ${pluralize(\"segment\", segmentCount, true)}; the configured limit is ${pluralize(\"segment\", maxSegments, true)}. Remove segments or raise \\`maxSegments\\`.`,\n} as const;\n\nconst defaultOptions: Required<Omit<MaxMessageSizeOptions, \"maxSegments\">> & {\n maxSegments?: number;\n} = {\n maxBytes: 10_000_000, // 10MB\n maxSegments: undefined,\n};\n\n/**\n * Hl7v2-lint rule to warn when message size exceeds the maximum allowed size.\n *\n * This rule is useful for ensuring that HL7v2 messages do not exceed a safe\n * or expected size limit (default: 10MB).\n */\nconst hl7v2LintMaxMessageSize = lintRule<Node, MaxMessageSizeOptions>(\n {\n origin: \"hl7v2-lint:max-message-size\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-max-message-size#readme\",\n },\n (tree, file, opts) => {\n const options = { ...defaultOptions, ...opts };\n\n const byteLength = Buffer.byteLength(file.value ?? \"\");\n if (byteLength > options.maxBytes) {\n const message = file.message(\n messages.tooManyBytes(byteLength, options.maxBytes)\n );\n message.actual = String(byteLength);\n }\n\n let totalSegments = 0;\n\n visit(tree, (node) => {\n // Count all segments including those in nested groups\n if (node.type === \"segment\") {\n totalSegments += 1;\n return SKIP;\n }\n });\n\n if (options.maxSegments && totalSegments > options.maxSegments) {\n const message = file.message(\n messages.tooManySegments(totalSegments, options.maxSegments)\n );\n message.actual = String(totalSegments);\n }\n }\n);\n\nexport default hl7v2LintMaxMessageSize;\n"],"mappings":";;;;AAkBA,MAAM,WAAW;CACf,eAAe,YAAoB,aACjC,kBAAkB,UAAU,QAAQ,YAAY,KAAK,CAAC,4BAA4B,UAAU,QAAQ,UAAU,KAAK,CAAC;CACtH,kBAAkB,cAAsB,gBACtC,mBAAmB,UAAU,WAAW,cAAc,KAAK,CAAC,4BAA4B,UAAU,WAAW,aAAa,KAAK,CAAC;CACnI;AAED,MAAM,iBAEF;CACF,UAAU;CACV,aAAa,KAAA;CACd;;;;;;;AAQD,MAAM,0BAA0B,SAC9B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,MAAM,SAAS;CACpB,MAAM,UAAU;EAAE,GAAG;EAAgB,GAAG;EAAM;CAE9C,MAAM,aAAa,OAAO,WAAW,KAAK,SAAS,GAAG;AACtD,KAAI,aAAa,QAAQ,UAAU;EACjC,MAAM,UAAU,KAAK,QACnB,SAAS,aAAa,YAAY,QAAQ,SAAS,CACpD;AACD,UAAQ,SAAS,OAAO,WAAW;;CAGrC,IAAI,gBAAgB;AAEpB,OAAM,OAAO,SAAS;AAEpB,MAAI,KAAK,SAAS,WAAW;AAC3B,oBAAiB;AACjB,UAAO;;GAET;AAEF,KAAI,QAAQ,eAAe,gBAAgB,QAAQ,aAAa;EAC9D,MAAM,UAAU,KAAK,QACnB,SAAS,gBAAgB,eAAe,QAAQ,YAAY,CAC7D;AACD,UAAQ,SAAS,OAAO,cAAc;;EAG3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/lint-max-message-size",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "hl7v2-lint rule to warn when message size exceeds the maximum allowed size",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"definition",
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
"unist-util-visit-parents": "6.0.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
+
"@stryker-mutator/core": "10.0.0",
|
|
47
|
+
"@stryker-mutator/vitest-runner": "10.0.0",
|
|
46
48
|
"@types/node": "25.6.0",
|
|
47
49
|
"@types/pluralize": "^0.0.33",
|
|
48
50
|
"@types/unist": "^3.0.3",
|
|
@@ -52,11 +54,11 @@
|
|
|
52
54
|
"typescript": "6.0.3",
|
|
53
55
|
"vfile": "^6.0.3",
|
|
54
56
|
"vitest": "4.1.11",
|
|
55
|
-
"@glion/ast": "0.
|
|
56
|
-
"@glion/builder": "0.26.0",
|
|
57
|
+
"@glion/ast": "0.27.1",
|
|
57
58
|
"@glion/check-readme": "0.18.0",
|
|
58
59
|
"@glion/testing": "0.18.0",
|
|
59
|
-
"@glion/tsconfig": "0.18.0"
|
|
60
|
+
"@glion/tsconfig": "0.18.0",
|
|
61
|
+
"@glion/builder": "0.27.1"
|
|
60
62
|
},
|
|
61
63
|
"engines": {
|
|
62
64
|
"node": ">=22"
|
|
@@ -65,9 +67,10 @@
|
|
|
65
67
|
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
66
68
|
"check-types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
|
|
67
69
|
"check:readme": "glion-check-readme",
|
|
70
|
+
"mutate": "stryker run",
|
|
71
|
+
"publint": "publint --strict",
|
|
68
72
|
"test": "vitest run",
|
|
69
73
|
"test:coverage": "vitest run --coverage",
|
|
70
|
-
"test:watch": "vitest"
|
|
71
|
-
"publint": "publint --strict"
|
|
74
|
+
"test:watch": "vitest"
|
|
72
75
|
}
|
|
73
76
|
}
|