@glion/config 0.14.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 +21 -0
- package/README.md +390 -0
- package/dist/define.d.ts +20 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +18 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +3 -0
- package/dist/json-schema2.js +1085 -0
- package/dist/json-schema2.js.map +1 -0
- package/dist/loader.d.ts +68 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +119 -0
- package/dist/loader.js.map +1 -0
- package/dist/schema.d.ts +292 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +51 -0
- package/dist/schema.js.map +1 -0
- package/package.json +59 -0
- package/schema.json +99 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for hl7v2-specific settings (NOT for plugins/linting).
|
|
4
|
+
*
|
|
5
|
+
* This schema defines the `settings` field that can be added to
|
|
6
|
+
* unified-args configuration files. The `plugins` field is handled
|
|
7
|
+
* by unified-args and should not be validated here.
|
|
8
|
+
*/
|
|
9
|
+
declare const HL7v2SettingsSchema: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
10
|
+
/**
|
|
11
|
+
* Custom delimiters to use as defaults.
|
|
12
|
+
*
|
|
13
|
+
* These delimiters serve as fallbacks when:
|
|
14
|
+
* - Processing non-MSH message fragments
|
|
15
|
+
* - Working with systems that use non-standard delimiters
|
|
16
|
+
* - CLI/batch processing where all messages use the same delimiters
|
|
17
|
+
*
|
|
18
|
+
* Note: MSH auto-detection will override these if the message starts with
|
|
19
|
+
* MSH.
|
|
20
|
+
*/
|
|
21
|
+
delimiters: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
22
|
+
/**
|
|
23
|
+
* Component separator character.
|
|
24
|
+
*
|
|
25
|
+
* @default "^"
|
|
26
|
+
*/
|
|
27
|
+
component: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
28
|
+
/**
|
|
29
|
+
* Escape character.
|
|
30
|
+
*
|
|
31
|
+
* @default "\\"
|
|
32
|
+
*/
|
|
33
|
+
escape: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
34
|
+
/**
|
|
35
|
+
* Field separator character.
|
|
36
|
+
*
|
|
37
|
+
* @default "|"
|
|
38
|
+
*/
|
|
39
|
+
field: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
40
|
+
/**
|
|
41
|
+
* Repetition separator character.
|
|
42
|
+
*
|
|
43
|
+
* @default "~"
|
|
44
|
+
*/
|
|
45
|
+
repetition: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
46
|
+
/**
|
|
47
|
+
* Segment terminator character.
|
|
48
|
+
*
|
|
49
|
+
* @default "\\r"
|
|
50
|
+
*/
|
|
51
|
+
segment: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
52
|
+
/**
|
|
53
|
+
* Subcomponent separator character.
|
|
54
|
+
*
|
|
55
|
+
* @default "&"
|
|
56
|
+
*/
|
|
57
|
+
subcomponent: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
58
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
|
+
component: string;
|
|
60
|
+
escape: string;
|
|
61
|
+
field: string;
|
|
62
|
+
repetition: string;
|
|
63
|
+
segment: string;
|
|
64
|
+
subcomponent: string;
|
|
65
|
+
}, {
|
|
66
|
+
component?: string | undefined;
|
|
67
|
+
escape?: string | undefined;
|
|
68
|
+
field?: string | undefined;
|
|
69
|
+
repetition?: string | undefined;
|
|
70
|
+
segment?: string | undefined;
|
|
71
|
+
subcomponent?: string | undefined;
|
|
72
|
+
}>>>;
|
|
73
|
+
/**
|
|
74
|
+
* Experimental features for the parser. These features are subject to
|
|
75
|
+
* change and may become defaults in future versions.
|
|
76
|
+
*/
|
|
77
|
+
experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
78
|
+
/**
|
|
79
|
+
* Controls how empty fields/components are represented in the AST.
|
|
80
|
+
*
|
|
81
|
+
* - 'legacy': Empty fields create full structure (Field → Rep → Comp → Sub
|
|
82
|
+
* with value: "")
|
|
83
|
+
* - 'empty': Empty fields have no children (Field with children: [])
|
|
84
|
+
*
|
|
85
|
+
* @default "legacy"
|
|
86
|
+
*/
|
|
87
|
+
emptyMode: z.ZodDefault<z.ZodEnum<["legacy", "empty"]>>;
|
|
88
|
+
}, "strict", z.ZodTypeAny, {
|
|
89
|
+
emptyMode: "legacy" | "empty";
|
|
90
|
+
}, {
|
|
91
|
+
emptyMode?: "legacy" | "empty" | undefined;
|
|
92
|
+
}>>>;
|
|
93
|
+
}, "strict", z.ZodTypeAny, {
|
|
94
|
+
delimiters: {
|
|
95
|
+
component: string;
|
|
96
|
+
escape: string;
|
|
97
|
+
field: string;
|
|
98
|
+
repetition: string;
|
|
99
|
+
segment: string;
|
|
100
|
+
subcomponent: string;
|
|
101
|
+
};
|
|
102
|
+
experimental: {
|
|
103
|
+
emptyMode: "legacy" | "empty";
|
|
104
|
+
};
|
|
105
|
+
}, {
|
|
106
|
+
delimiters?: {
|
|
107
|
+
component?: string | undefined;
|
|
108
|
+
escape?: string | undefined;
|
|
109
|
+
field?: string | undefined;
|
|
110
|
+
repetition?: string | undefined;
|
|
111
|
+
segment?: string | undefined;
|
|
112
|
+
subcomponent?: string | undefined;
|
|
113
|
+
} | undefined;
|
|
114
|
+
experimental?: {
|
|
115
|
+
emptyMode?: "legacy" | "empty" | undefined;
|
|
116
|
+
} | undefined;
|
|
117
|
+
}>>>;
|
|
118
|
+
export type HL7v2Settings = z.infer<typeof HL7v2SettingsSchema>;
|
|
119
|
+
/**
|
|
120
|
+
* Full config schema (for documentation/validation).
|
|
121
|
+
*
|
|
122
|
+
* Note: The `plugins` field is handled by unified-args.
|
|
123
|
+
* We document it here but don't deeply validate its structure.
|
|
124
|
+
*/
|
|
125
|
+
export declare const HL7v2ConfigSchema: z.ZodObject<{
|
|
126
|
+
/**
|
|
127
|
+
* JSON Schema reference for IDE support. Use:
|
|
128
|
+
* https://raw.githubusercontent.com/rethinkhealth/hl7v2/main/packages/hl7v2-config/schema.json
|
|
129
|
+
*/
|
|
130
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
131
|
+
/**
|
|
132
|
+
* Plugins configuration - handled by unified-args.
|
|
133
|
+
*
|
|
134
|
+
* Format examples:
|
|
135
|
+
*
|
|
136
|
+
* - ["preset-lint-recommended"]
|
|
137
|
+
* - ["lint-max-message-size", { "maxBytes": 5000000 }]
|
|
138
|
+
* - ["lint-message-version", ["error", { "expression": ">=2.3 <3.0.0" }]]
|
|
139
|
+
*
|
|
140
|
+
* Severity levels: "off" (0), "on"/"warn" (1), "error" (2)
|
|
141
|
+
*/
|
|
142
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
143
|
+
/**
|
|
144
|
+
* Hl7v2-specific settings (validated by this package).
|
|
145
|
+
*/
|
|
146
|
+
settings: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
147
|
+
/**
|
|
148
|
+
* Custom delimiters to use as defaults.
|
|
149
|
+
*
|
|
150
|
+
* These delimiters serve as fallbacks when:
|
|
151
|
+
* - Processing non-MSH message fragments
|
|
152
|
+
* - Working with systems that use non-standard delimiters
|
|
153
|
+
* - CLI/batch processing where all messages use the same delimiters
|
|
154
|
+
*
|
|
155
|
+
* Note: MSH auto-detection will override these if the message starts with
|
|
156
|
+
* MSH.
|
|
157
|
+
*/
|
|
158
|
+
delimiters: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
159
|
+
/**
|
|
160
|
+
* Component separator character.
|
|
161
|
+
*
|
|
162
|
+
* @default "^"
|
|
163
|
+
*/
|
|
164
|
+
component: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
165
|
+
/**
|
|
166
|
+
* Escape character.
|
|
167
|
+
*
|
|
168
|
+
* @default "\\"
|
|
169
|
+
*/
|
|
170
|
+
escape: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
171
|
+
/**
|
|
172
|
+
* Field separator character.
|
|
173
|
+
*
|
|
174
|
+
* @default "|"
|
|
175
|
+
*/
|
|
176
|
+
field: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
177
|
+
/**
|
|
178
|
+
* Repetition separator character.
|
|
179
|
+
*
|
|
180
|
+
* @default "~"
|
|
181
|
+
*/
|
|
182
|
+
repetition: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
183
|
+
/**
|
|
184
|
+
* Segment terminator character.
|
|
185
|
+
*
|
|
186
|
+
* @default "\\r"
|
|
187
|
+
*/
|
|
188
|
+
segment: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
189
|
+
/**
|
|
190
|
+
* Subcomponent separator character.
|
|
191
|
+
*
|
|
192
|
+
* @default "&"
|
|
193
|
+
*/
|
|
194
|
+
subcomponent: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
195
|
+
}, "strict", z.ZodTypeAny, {
|
|
196
|
+
component: string;
|
|
197
|
+
escape: string;
|
|
198
|
+
field: string;
|
|
199
|
+
repetition: string;
|
|
200
|
+
segment: string;
|
|
201
|
+
subcomponent: string;
|
|
202
|
+
}, {
|
|
203
|
+
component?: string | undefined;
|
|
204
|
+
escape?: string | undefined;
|
|
205
|
+
field?: string | undefined;
|
|
206
|
+
repetition?: string | undefined;
|
|
207
|
+
segment?: string | undefined;
|
|
208
|
+
subcomponent?: string | undefined;
|
|
209
|
+
}>>>;
|
|
210
|
+
/**
|
|
211
|
+
* Experimental features for the parser. These features are subject to
|
|
212
|
+
* change and may become defaults in future versions.
|
|
213
|
+
*/
|
|
214
|
+
experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
215
|
+
/**
|
|
216
|
+
* Controls how empty fields/components are represented in the AST.
|
|
217
|
+
*
|
|
218
|
+
* - 'legacy': Empty fields create full structure (Field → Rep → Comp → Sub
|
|
219
|
+
* with value: "")
|
|
220
|
+
* - 'empty': Empty fields have no children (Field with children: [])
|
|
221
|
+
*
|
|
222
|
+
* @default "legacy"
|
|
223
|
+
*/
|
|
224
|
+
emptyMode: z.ZodDefault<z.ZodEnum<["legacy", "empty"]>>;
|
|
225
|
+
}, "strict", z.ZodTypeAny, {
|
|
226
|
+
emptyMode: "legacy" | "empty";
|
|
227
|
+
}, {
|
|
228
|
+
emptyMode?: "legacy" | "empty" | undefined;
|
|
229
|
+
}>>>;
|
|
230
|
+
}, "strict", z.ZodTypeAny, {
|
|
231
|
+
delimiters: {
|
|
232
|
+
component: string;
|
|
233
|
+
escape: string;
|
|
234
|
+
field: string;
|
|
235
|
+
repetition: string;
|
|
236
|
+
segment: string;
|
|
237
|
+
subcomponent: string;
|
|
238
|
+
};
|
|
239
|
+
experimental: {
|
|
240
|
+
emptyMode: "legacy" | "empty";
|
|
241
|
+
};
|
|
242
|
+
}, {
|
|
243
|
+
delimiters?: {
|
|
244
|
+
component?: string | undefined;
|
|
245
|
+
escape?: string | undefined;
|
|
246
|
+
field?: string | undefined;
|
|
247
|
+
repetition?: string | undefined;
|
|
248
|
+
segment?: string | undefined;
|
|
249
|
+
subcomponent?: string | undefined;
|
|
250
|
+
} | undefined;
|
|
251
|
+
experimental?: {
|
|
252
|
+
emptyMode?: "legacy" | "empty" | undefined;
|
|
253
|
+
} | undefined;
|
|
254
|
+
}>>>;
|
|
255
|
+
}, "strip", z.ZodTypeAny, {
|
|
256
|
+
settings: {
|
|
257
|
+
delimiters: {
|
|
258
|
+
component: string;
|
|
259
|
+
escape: string;
|
|
260
|
+
field: string;
|
|
261
|
+
repetition: string;
|
|
262
|
+
segment: string;
|
|
263
|
+
subcomponent: string;
|
|
264
|
+
};
|
|
265
|
+
experimental: {
|
|
266
|
+
emptyMode: "legacy" | "empty";
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
$schema?: string | undefined;
|
|
270
|
+
plugins?: any[] | undefined;
|
|
271
|
+
}, {
|
|
272
|
+
$schema?: string | undefined;
|
|
273
|
+
plugins?: any[] | undefined;
|
|
274
|
+
settings?: {
|
|
275
|
+
delimiters?: {
|
|
276
|
+
component?: string | undefined;
|
|
277
|
+
escape?: string | undefined;
|
|
278
|
+
field?: string | undefined;
|
|
279
|
+
repetition?: string | undefined;
|
|
280
|
+
segment?: string | undefined;
|
|
281
|
+
subcomponent?: string | undefined;
|
|
282
|
+
} | undefined;
|
|
283
|
+
experimental?: {
|
|
284
|
+
emptyMode?: "legacy" | "empty" | undefined;
|
|
285
|
+
} | undefined;
|
|
286
|
+
} | undefined;
|
|
287
|
+
}>;
|
|
288
|
+
export type HL7v2Config = z.infer<typeof HL7v2ConfigSchema>;
|
|
289
|
+
/** Input type for config (before defaults are applied) */
|
|
290
|
+
export type HL7v2ConfigInput = z.input<typeof HL7v2ConfigSchema>;
|
|
291
|
+
export {};
|
|
292
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkHxB;;;;;;GAMG;AACH,QAAA,MAAM,mBAAmB;IAErB;;;;;;;;;;OAUG;;QApHH;;;;WAIG;;QAOH;;;;WAIG;;QAQH;;;;WAIG;;QAOH;;;;WAIG;;QAQH;;;;WAIG;;QAOH;;;;WAIG;;;;;;;;;;;;;;;;;IA0DH;;;OAGG;;QA/CH;;;;;;;;WAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4CO,CAAC;AAEf,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;;OAGG;;IAOH;;;;;;;;;;OAUG;;IASH;;OAEG;;QA/DD;;;;;;;;;;WAUG;;YApHH;;;;eAIG;;YAOH;;;;eAIG;;YAQH;;;;eAIG;;YAOH;;;;eAIG;;YAQH;;;;eAIG;;YAOH;;;;eAIG;;;;;;;;;;;;;;;;;QA0DH;;;WAGG;;YA/CH;;;;;;;;eAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwFL,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DEFAULT_DELIMITERS } from "@glion/utils";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/schema.ts
|
|
4
|
+
/**
|
|
5
|
+
* Schema for delimiter configuration.
|
|
6
|
+
*
|
|
7
|
+
* Each delimiter must be exactly one character. All fields are optional,
|
|
8
|
+
* allowing partial overrides (e.g., only override the field separator).
|
|
9
|
+
*
|
|
10
|
+
* Priority order (lowest to highest):
|
|
11
|
+
*
|
|
12
|
+
* 1. DEFAULT_DELIMITERS (hardcoded in hl7v2-utils)
|
|
13
|
+
* 2. Settings.delimiters (from config file)
|
|
14
|
+
* 3. Opts.delimiters (direct API parameter)
|
|
15
|
+
* 4. MSH auto-detection (if message starts with MSH)
|
|
16
|
+
*/
|
|
17
|
+
const DelimitersSchema = z.object({
|
|
18
|
+
component: z.string().length(1).optional().default(DEFAULT_DELIMITERS.component).describe("Component separator character"),
|
|
19
|
+
escape: z.string().length(1).optional().default(DEFAULT_DELIMITERS.escape).describe("Escape character"),
|
|
20
|
+
field: z.string().length(1).optional().default(DEFAULT_DELIMITERS.field).describe("Field separator character"),
|
|
21
|
+
repetition: z.string().length(1).optional().default(DEFAULT_DELIMITERS.repetition).describe("Repetition separator character"),
|
|
22
|
+
segment: z.string().length(1).optional().default(DEFAULT_DELIMITERS.segment).describe("Segment terminator character"),
|
|
23
|
+
subcomponent: z.string().length(1).optional().default(DEFAULT_DELIMITERS.subcomponent).describe("Subcomponent separator character")
|
|
24
|
+
}).strict().optional().default(DEFAULT_DELIMITERS);
|
|
25
|
+
const ExperimentalSchema = z.object({ emptyMode: z.enum(["legacy", "empty"]).default("legacy").describe("Control how empty values are represented in the parser. 'legacy' creates full structure with empty strings, 'empty' creates empty children arrays.") }).strict().optional().default({ emptyMode: "legacy" });
|
|
26
|
+
/**
|
|
27
|
+
* Schema for hl7v2-specific settings (NOT for plugins/linting).
|
|
28
|
+
*
|
|
29
|
+
* This schema defines the `settings` field that can be added to
|
|
30
|
+
* unified-args configuration files. The `plugins` field is handled
|
|
31
|
+
* by unified-args and should not be validated here.
|
|
32
|
+
*/
|
|
33
|
+
const HL7v2SettingsSchema = z.object({
|
|
34
|
+
delimiters: DelimitersSchema,
|
|
35
|
+
experimental: ExperimentalSchema
|
|
36
|
+
}).strict().optional().default({});
|
|
37
|
+
/**
|
|
38
|
+
* Full config schema (for documentation/validation).
|
|
39
|
+
*
|
|
40
|
+
* Note: The `plugins` field is handled by unified-args.
|
|
41
|
+
* We document it here but don't deeply validate its structure.
|
|
42
|
+
*/
|
|
43
|
+
const HL7v2ConfigSchema = z.object({
|
|
44
|
+
$schema: z.string().url().optional().describe("JSON Schema URL for IDE autocomplete support"),
|
|
45
|
+
plugins: z.array(z.any()).optional().describe("Plugins configuration - handled by unified-args. Format: [pluginName] or [pluginName, options] or [pluginName, [severity, options]]"),
|
|
46
|
+
settings: HL7v2SettingsSchema
|
|
47
|
+
});
|
|
48
|
+
//#endregion
|
|
49
|
+
export { HL7v2ConfigSchema };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import { DEFAULT_DELIMITERS } from \"@glion/utils\";\nimport { z } from \"zod\";\n\n/**\n * Schema for delimiter configuration.\n *\n * Each delimiter must be exactly one character. All fields are optional,\n * allowing partial overrides (e.g., only override the field separator).\n *\n * Priority order (lowest to highest):\n *\n * 1. DEFAULT_DELIMITERS (hardcoded in hl7v2-utils)\n * 2. Settings.delimiters (from config file)\n * 3. Opts.delimiters (direct API parameter)\n * 4. MSH auto-detection (if message starts with MSH)\n */\nconst DelimitersSchema = z\n .object({\n /**\n * Component separator character.\n *\n * @default \"^\"\n */\n component: z\n .string()\n .length(1)\n .optional()\n .default(DEFAULT_DELIMITERS.component)\n .describe(\"Component separator character\"),\n /**\n * Escape character.\n *\n * @default \"\\\\\"\n */\n escape: z\n .string()\n .length(1)\n .optional()\n .default(DEFAULT_DELIMITERS.escape)\n .describe(\"Escape character\"),\n\n /**\n * Field separator character.\n *\n * @default \"|\"\n */\n field: z\n .string()\n .length(1)\n .optional()\n .default(DEFAULT_DELIMITERS.field)\n .describe(\"Field separator character\"),\n /**\n * Repetition separator character.\n *\n * @default \"~\"\n */\n repetition: z\n .string()\n .length(1)\n .optional()\n .default(DEFAULT_DELIMITERS.repetition)\n .describe(\"Repetition separator character\"),\n\n /**\n * Segment terminator character.\n *\n * @default \"\\\\r\"\n */\n segment: z\n .string()\n .length(1)\n .optional()\n .default(DEFAULT_DELIMITERS.segment)\n .describe(\"Segment terminator character\"),\n /**\n * Subcomponent separator character.\n *\n * @default \"&\"\n */\n subcomponent: z\n .string()\n .length(1)\n .optional()\n .default(DEFAULT_DELIMITERS.subcomponent)\n .describe(\"Subcomponent separator character\"),\n })\n .strict()\n .optional()\n .default(DEFAULT_DELIMITERS);\n\nconst ExperimentalSchema = z\n .object({\n /**\n * Controls how empty fields/components are represented in the AST.\n *\n * - 'legacy': Empty fields create full structure (Field → Rep → Comp → Sub\n * with value: \"\")\n * - 'empty': Empty fields have no children (Field with children: [])\n *\n * @default \"legacy\"\n */\n emptyMode: z\n .enum([\"legacy\", \"empty\"])\n .default(\"legacy\")\n .describe(\n \"Control how empty values are represented in the parser. \" +\n \"'legacy' creates full structure with empty strings, \" +\n \"'empty' creates empty children arrays.\"\n ),\n })\n .strict()\n .optional()\n .default({ emptyMode: \"legacy\" });\n\n/**\n * Schema for hl7v2-specific settings (NOT for plugins/linting).\n *\n * This schema defines the `settings` field that can be added to\n * unified-args configuration files. The `plugins` field is handled\n * by unified-args and should not be validated here.\n */\nconst HL7v2SettingsSchema = z\n .object({\n /**\n * Custom delimiters to use as defaults.\n *\n * These delimiters serve as fallbacks when:\n * - Processing non-MSH message fragments\n * - Working with systems that use non-standard delimiters\n * - CLI/batch processing where all messages use the same delimiters\n *\n * Note: MSH auto-detection will override these if the message starts with\n * MSH.\n */\n delimiters: DelimitersSchema,\n\n /**\n * Experimental features for the parser. These features are subject to\n * change and may become defaults in future versions.\n */\n experimental: ExperimentalSchema,\n })\n .strict()\n .optional()\n .default({});\n\nexport type HL7v2Settings = z.infer<typeof HL7v2SettingsSchema>;\n\n/**\n * Full config schema (for documentation/validation).\n *\n * Note: The `plugins` field is handled by unified-args.\n * We document it here but don't deeply validate its structure.\n */\nexport const HL7v2ConfigSchema = z.object({\n /**\n * JSON Schema reference for IDE support. Use:\n * https://raw.githubusercontent.com/rethinkhealth/hl7v2/main/packages/hl7v2-config/schema.json\n */\n $schema: z\n .string()\n .url()\n .optional()\n .describe(\"JSON Schema URL for IDE autocomplete support\"),\n\n /**\n * Plugins configuration - handled by unified-args.\n *\n * Format examples:\n *\n * - [\"preset-lint-recommended\"]\n * - [\"lint-max-message-size\", { \"maxBytes\": 5000000 }]\n * - [\"lint-message-version\", [\"error\", { \"expression\": \">=2.3 <3.0.0\" }]]\n *\n * Severity levels: \"off\" (0), \"on\"/\"warn\" (1), \"error\" (2)\n */\n plugins: z\n .array(z.any())\n .optional()\n .describe(\n \"Plugins configuration - handled by unified-args. \" +\n \"Format: [pluginName] or [pluginName, options] or [pluginName, [severity, options]]\"\n ),\n\n /**\n * Hl7v2-specific settings (validated by this package).\n */\n settings: HL7v2SettingsSchema,\n});\n\nexport type HL7v2Config = z.infer<typeof HL7v2ConfigSchema>;\n\n/** Input type for config (before defaults are applied) */\nexport type HL7v2ConfigInput = z.input<typeof HL7v2ConfigSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,mBAAmB,EACtB,OAAO;CAMN,WAAW,EACR,QAAQ,CACR,OAAO,EAAE,CACT,UAAU,CACV,QAAQ,mBAAmB,UAAU,CACrC,SAAS,gCAAgC;CAM5C,QAAQ,EACL,QAAQ,CACR,OAAO,EAAE,CACT,UAAU,CACV,QAAQ,mBAAmB,OAAO,CAClC,SAAS,mBAAmB;CAO/B,OAAO,EACJ,QAAQ,CACR,OAAO,EAAE,CACT,UAAU,CACV,QAAQ,mBAAmB,MAAM,CACjC,SAAS,4BAA4B;CAMxC,YAAY,EACT,QAAQ,CACR,OAAO,EAAE,CACT,UAAU,CACV,QAAQ,mBAAmB,WAAW,CACtC,SAAS,iCAAiC;CAO7C,SAAS,EACN,QAAQ,CACR,OAAO,EAAE,CACT,UAAU,CACV,QAAQ,mBAAmB,QAAQ,CACnC,SAAS,+BAA+B;CAM3C,cAAc,EACX,QAAQ,CACR,OAAO,EAAE,CACT,UAAU,CACV,QAAQ,mBAAmB,aAAa,CACxC,SAAS,mCAAmC;CAChD,CAAC,CACD,QAAQ,CACR,UAAU,CACV,QAAQ,mBAAmB;AAE9B,MAAM,qBAAqB,EACxB,OAAO,EAUN,WAAW,EACR,KAAK,CAAC,UAAU,QAAQ,CAAC,CACzB,QAAQ,SAAS,CACjB,SACC,qJAGD,EACJ,CAAC,CACD,QAAQ,CACR,UAAU,CACV,QAAQ,EAAE,WAAW,UAAU,CAAC;;;;;;;;AASnC,MAAM,sBAAsB,EACzB,OAAO;CAYN,YAAY;CAMZ,cAAc;CACf,CAAC,CACD,QAAQ,CACR,UAAU,CACV,QAAQ,EAAE,CAAC;;;;;;;AAUd,MAAa,oBAAoB,EAAE,OAAO;CAKxC,SAAS,EACN,QAAQ,CACR,KAAK,CACL,UAAU,CACV,SAAS,+CAA+C;CAa3D,SAAS,EACN,MAAM,EAAE,KAAK,CAAC,CACd,UAAU,CACV,SACC,sIAED;CAKH,UAAU;CACX,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glion/config",
|
|
3
|
+
"version": "0.14.1",
|
|
4
|
+
"description": "Configuration schema and loader for hl7v2",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"config",
|
|
7
|
+
"configuration",
|
|
8
|
+
"hl7v2",
|
|
9
|
+
"schema",
|
|
10
|
+
"settings"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://glion.dev",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Melek Somai",
|
|
16
|
+
"email": "melek@rethinkhealth.io"
|
|
17
|
+
},
|
|
18
|
+
"repository": "rethinkhealth/glion.git",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"schema.json"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./dist/index.js",
|
|
27
|
+
"./schema.json": "./schema.json"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"cosmiconfig": "9.0.1",
|
|
34
|
+
"unified": "11.0.5",
|
|
35
|
+
"zod": "3.25.76",
|
|
36
|
+
"@glion/utils": "0.14.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^25.5.0",
|
|
40
|
+
"@vitest/coverage-v8": "4.1.2",
|
|
41
|
+
"tsdown": "0.21.7",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"vitest": "4.1.2",
|
|
44
|
+
"zod-to-json-schema": "3.25.0",
|
|
45
|
+
"@glion/tsconfig": "0.0.1",
|
|
46
|
+
"@glion/testing": "0.0.2"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsdown && tsc --emitDeclarationOnly && pnpm build:schema",
|
|
53
|
+
"build:schema": "node --input-type=module -e \"import{writeFileSync}from'fs';import{jsonSchema}from'./dist/json-schema.js';writeFileSync('schema.json',JSON.stringify(jsonSchema,null,2));\"",
|
|
54
|
+
"check-types": "tsc --noEmit",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:coverage": "vitest run --coverage",
|
|
57
|
+
"test:watch": "vitest"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/schema.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/HL7v2Config",
|
|
3
|
+
"definitions": {
|
|
4
|
+
"HL7v2Config": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"$schema": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"format": "uri",
|
|
10
|
+
"description": "JSON Schema URL for IDE autocomplete support"
|
|
11
|
+
},
|
|
12
|
+
"plugins": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"description": "Plugins configuration - handled by unified-args. Format: [pluginName] or [pluginName, options] or [pluginName, [severity, options]]"
|
|
15
|
+
},
|
|
16
|
+
"settings": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"delimiters": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"component": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"minLength": 1,
|
|
25
|
+
"maxLength": 1,
|
|
26
|
+
"default": "^",
|
|
27
|
+
"description": "Component separator character"
|
|
28
|
+
},
|
|
29
|
+
"escape": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"minLength": 1,
|
|
32
|
+
"maxLength": 1,
|
|
33
|
+
"default": "\\",
|
|
34
|
+
"description": "Escape character"
|
|
35
|
+
},
|
|
36
|
+
"field": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 1,
|
|
39
|
+
"maxLength": 1,
|
|
40
|
+
"default": "|",
|
|
41
|
+
"description": "Field separator character"
|
|
42
|
+
},
|
|
43
|
+
"repetition": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"minLength": 1,
|
|
46
|
+
"maxLength": 1,
|
|
47
|
+
"default": "~",
|
|
48
|
+
"description": "Repetition separator character"
|
|
49
|
+
},
|
|
50
|
+
"segment": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"minLength": 1,
|
|
53
|
+
"maxLength": 1,
|
|
54
|
+
"default": "\r",
|
|
55
|
+
"description": "Segment terminator character"
|
|
56
|
+
},
|
|
57
|
+
"subcomponent": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"minLength": 1,
|
|
60
|
+
"maxLength": 1,
|
|
61
|
+
"default": "&",
|
|
62
|
+
"description": "Subcomponent separator character"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"additionalProperties": false,
|
|
66
|
+
"default": {
|
|
67
|
+
"component": "^",
|
|
68
|
+
"escape": "\\",
|
|
69
|
+
"field": "|",
|
|
70
|
+
"repetition": "~",
|
|
71
|
+
"segment": "\r",
|
|
72
|
+
"subcomponent": "&"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"experimental": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"properties": {
|
|
78
|
+
"emptyMode": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"enum": ["legacy", "empty"],
|
|
81
|
+
"default": "legacy",
|
|
82
|
+
"description": "Control how empty values are represented in the parser. 'legacy' creates full structure with empty strings, 'empty' creates empty children arrays."
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"additionalProperties": false,
|
|
86
|
+
"default": {
|
|
87
|
+
"emptyMode": "legacy"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"additionalProperties": false,
|
|
92
|
+
"default": {}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"additionalProperties": false
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
99
|
+
}
|