@outburn/format-converter 1.0.0 → 1.0.3
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/dist/index.d.cts +90 -1
- package/dist/index.d.ts +90 -1
- package/package.json +66 -49
package/dist/index.d.cts
CHANGED
|
@@ -4,46 +4,135 @@ interface ILogger {
|
|
|
4
4
|
error: (msg: any) => void;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Enumeration of supported content formats for detection and conversion.
|
|
9
|
+
* Used by format detection algorithms to categorize input data and determine
|
|
10
|
+
* appropriate conversion strategies.
|
|
11
|
+
*/
|
|
7
12
|
declare const enum ContentFormat {
|
|
13
|
+
/** JavaScript Object Notation format */
|
|
8
14
|
JSON = "json",
|
|
15
|
+
/** Comma-Separated Values format */
|
|
9
16
|
CSV = "csv",
|
|
17
|
+
/** eXtensible Markup Language format */
|
|
10
18
|
XML = "xml",
|
|
19
|
+
/** Health Level 7 Version 2.x message format */
|
|
11
20
|
HL7 = "hl7",
|
|
21
|
+
/** Unknown or unsupported format */
|
|
12
22
|
UNKNOWN = "unknown"
|
|
13
23
|
}
|
|
14
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Enumeration of supported MIME types/content types for data format identification.
|
|
27
|
+
* These values correspond to standard HTTP Content-Type header values and are used
|
|
28
|
+
* for format detection and conversion operations.
|
|
29
|
+
*/
|
|
15
30
|
declare const enum ContentType {
|
|
31
|
+
/** Standard MIME type for JSON data */
|
|
16
32
|
JSON = "application/json",
|
|
33
|
+
/** Standard MIME type for CSV data */
|
|
17
34
|
CSV = "text/csv",
|
|
35
|
+
/** Standard MIME type for XML data */
|
|
18
36
|
XML = "application/xml",
|
|
37
|
+
/** Custom MIME type for HL7 Version 2.x messages in ER7 encoding */
|
|
19
38
|
HL7V2 = "x-application/hl7-v2+er7"
|
|
20
39
|
}
|
|
21
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Enumeration of supported editor language identifiers for syntax highlighting and editor configuration.
|
|
43
|
+
* These values are used to determine the appropriate language mode for displaying content
|
|
44
|
+
* in code editors or other text editing interfaces.
|
|
45
|
+
*/
|
|
22
46
|
declare const enum EditorLanguage {
|
|
47
|
+
/** JSON language mode for syntax highlighting */
|
|
23
48
|
JSON = "json",
|
|
49
|
+
/** XML language mode for syntax highlighting */
|
|
24
50
|
XML = "xml",
|
|
51
|
+
/** Plain text mode with no syntax highlighting */
|
|
25
52
|
PLAINTEXT = "plaintext"
|
|
26
53
|
}
|
|
27
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Interface for format conversion operations, providing methods to convert various data formats to JSON.
|
|
57
|
+
* Supports conversion from CSV, XML, and HL7 V2.x message formats.
|
|
58
|
+
*/
|
|
28
59
|
interface IFormatConverter {
|
|
60
|
+
/**
|
|
61
|
+
* Converts input data to JSON format based on the specified content type.
|
|
62
|
+
* If content type is not provided, defaults to `application/json`.
|
|
63
|
+
* @param input Data to be converted
|
|
64
|
+
* @param contentType Optional content type indicating the format of the input data
|
|
65
|
+
* @returns Promise resolving to JSON object
|
|
66
|
+
* @throws Error if the content type is unsupported or conversion fails
|
|
67
|
+
*/
|
|
29
68
|
toJson: (input: any, contentType?: ContentType | string) => Promise<any>;
|
|
30
69
|
/**
|
|
31
|
-
* Converts CSV string to JSON object. If conversion fails, returns empty array.
|
|
70
|
+
* Converts CSV string to JSON object. If conversion fails, returns an empty array.
|
|
32
71
|
* @param input CSV string to be converted
|
|
33
72
|
* @returns Promise resolving to JSON object
|
|
34
73
|
*/
|
|
35
74
|
csvToJson: (input: string) => Promise<any>;
|
|
75
|
+
/**
|
|
76
|
+
* Converts XML string to JSON object. If the input is empty, returns an empty object.
|
|
77
|
+
* @param input XML string to be converted
|
|
78
|
+
* @returns Promise resolving to JSON object
|
|
79
|
+
* @throws Error if XML parsing fails
|
|
80
|
+
*/
|
|
36
81
|
xmlToJson: (input: string) => Promise<any>;
|
|
82
|
+
/**
|
|
83
|
+
* Converts HL7 V2.x message string to JSON object.
|
|
84
|
+
* @param message HL7 V2.x message string to be converted
|
|
85
|
+
* @returns Promise resolving to JSON object
|
|
86
|
+
*/
|
|
37
87
|
hl7v2ToJson: (message: string) => Promise<any>;
|
|
38
88
|
}
|
|
39
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Interface for type conversion operations, providing methods to convert between
|
|
92
|
+
* different content type representations (ContentType, ContentFormat, EditorLanguage, and string).
|
|
93
|
+
*/
|
|
40
94
|
interface ITypeConverter {
|
|
95
|
+
/**
|
|
96
|
+
* Converts a ContentType to its corresponding ContentFormat.
|
|
97
|
+
* @param contentType The ContentType to convert
|
|
98
|
+
* @returns The corresponding ContentFormat
|
|
99
|
+
*/
|
|
41
100
|
contentTypeToContentFormat: (contentType: ContentType) => ContentFormat;
|
|
101
|
+
/**
|
|
102
|
+
* Converts a ContentType to its corresponding EditorLanguage.
|
|
103
|
+
* @param contentType The ContentType to convert
|
|
104
|
+
* @returns The corresponding EditorLanguage
|
|
105
|
+
*/
|
|
42
106
|
contentTypeToEditorLanguage: (contentType: ContentType) => EditorLanguage;
|
|
107
|
+
/**
|
|
108
|
+
* Converts a ContentFormat to its corresponding ContentType.
|
|
109
|
+
* @param format The ContentFormat to convert
|
|
110
|
+
* @returns The corresponding ContentType, or null if conversion is not possible
|
|
111
|
+
*/
|
|
43
112
|
contentFormatToContentType: (format: ContentFormat) => ContentType | null;
|
|
113
|
+
/**
|
|
114
|
+
* Converts a ContentFormat to its corresponding EditorLanguage.
|
|
115
|
+
* @param format The ContentFormat to convert
|
|
116
|
+
* @returns The corresponding EditorLanguage
|
|
117
|
+
*/
|
|
44
118
|
contentFormatToEditorLanguage: (format: ContentFormat) => EditorLanguage;
|
|
119
|
+
/**
|
|
120
|
+
* Converts a string representation to its corresponding ContentFormat.
|
|
121
|
+
* @param format The string representation of a format
|
|
122
|
+
* @returns The corresponding ContentFormat, or null if conversion is not possible
|
|
123
|
+
*/
|
|
45
124
|
stringToContentFormat: (format: string) => ContentFormat | null;
|
|
125
|
+
/**
|
|
126
|
+
* Converts a string representation to its corresponding ContentType.
|
|
127
|
+
* @param contentType The string representation of a content type
|
|
128
|
+
* @returns The corresponding ContentType, or null if conversion is not possible
|
|
129
|
+
*/
|
|
46
130
|
stringToContentType: (contentType: string) => ContentType | null;
|
|
131
|
+
/**
|
|
132
|
+
* Converts a string representation to its corresponding EditorLanguage.
|
|
133
|
+
* @param editorLanguage The string representation of an editor language
|
|
134
|
+
* @returns The corresponding EditorLanguage, or null if conversion is not possible
|
|
135
|
+
*/
|
|
47
136
|
stringToEditorLanguage: (editorLanguage: string) => EditorLanguage | null;
|
|
48
137
|
}
|
|
49
138
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,46 +4,135 @@ interface ILogger {
|
|
|
4
4
|
error: (msg: any) => void;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Enumeration of supported content formats for detection and conversion.
|
|
9
|
+
* Used by format detection algorithms to categorize input data and determine
|
|
10
|
+
* appropriate conversion strategies.
|
|
11
|
+
*/
|
|
7
12
|
declare const enum ContentFormat {
|
|
13
|
+
/** JavaScript Object Notation format */
|
|
8
14
|
JSON = "json",
|
|
15
|
+
/** Comma-Separated Values format */
|
|
9
16
|
CSV = "csv",
|
|
17
|
+
/** eXtensible Markup Language format */
|
|
10
18
|
XML = "xml",
|
|
19
|
+
/** Health Level 7 Version 2.x message format */
|
|
11
20
|
HL7 = "hl7",
|
|
21
|
+
/** Unknown or unsupported format */
|
|
12
22
|
UNKNOWN = "unknown"
|
|
13
23
|
}
|
|
14
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Enumeration of supported MIME types/content types for data format identification.
|
|
27
|
+
* These values correspond to standard HTTP Content-Type header values and are used
|
|
28
|
+
* for format detection and conversion operations.
|
|
29
|
+
*/
|
|
15
30
|
declare const enum ContentType {
|
|
31
|
+
/** Standard MIME type for JSON data */
|
|
16
32
|
JSON = "application/json",
|
|
33
|
+
/** Standard MIME type for CSV data */
|
|
17
34
|
CSV = "text/csv",
|
|
35
|
+
/** Standard MIME type for XML data */
|
|
18
36
|
XML = "application/xml",
|
|
37
|
+
/** Custom MIME type for HL7 Version 2.x messages in ER7 encoding */
|
|
19
38
|
HL7V2 = "x-application/hl7-v2+er7"
|
|
20
39
|
}
|
|
21
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Enumeration of supported editor language identifiers for syntax highlighting and editor configuration.
|
|
43
|
+
* These values are used to determine the appropriate language mode for displaying content
|
|
44
|
+
* in code editors or other text editing interfaces.
|
|
45
|
+
*/
|
|
22
46
|
declare const enum EditorLanguage {
|
|
47
|
+
/** JSON language mode for syntax highlighting */
|
|
23
48
|
JSON = "json",
|
|
49
|
+
/** XML language mode for syntax highlighting */
|
|
24
50
|
XML = "xml",
|
|
51
|
+
/** Plain text mode with no syntax highlighting */
|
|
25
52
|
PLAINTEXT = "plaintext"
|
|
26
53
|
}
|
|
27
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Interface for format conversion operations, providing methods to convert various data formats to JSON.
|
|
57
|
+
* Supports conversion from CSV, XML, and HL7 V2.x message formats.
|
|
58
|
+
*/
|
|
28
59
|
interface IFormatConverter {
|
|
60
|
+
/**
|
|
61
|
+
* Converts input data to JSON format based on the specified content type.
|
|
62
|
+
* If content type is not provided, defaults to `application/json`.
|
|
63
|
+
* @param input Data to be converted
|
|
64
|
+
* @param contentType Optional content type indicating the format of the input data
|
|
65
|
+
* @returns Promise resolving to JSON object
|
|
66
|
+
* @throws Error if the content type is unsupported or conversion fails
|
|
67
|
+
*/
|
|
29
68
|
toJson: (input: any, contentType?: ContentType | string) => Promise<any>;
|
|
30
69
|
/**
|
|
31
|
-
* Converts CSV string to JSON object. If conversion fails, returns empty array.
|
|
70
|
+
* Converts CSV string to JSON object. If conversion fails, returns an empty array.
|
|
32
71
|
* @param input CSV string to be converted
|
|
33
72
|
* @returns Promise resolving to JSON object
|
|
34
73
|
*/
|
|
35
74
|
csvToJson: (input: string) => Promise<any>;
|
|
75
|
+
/**
|
|
76
|
+
* Converts XML string to JSON object. If the input is empty, returns an empty object.
|
|
77
|
+
* @param input XML string to be converted
|
|
78
|
+
* @returns Promise resolving to JSON object
|
|
79
|
+
* @throws Error if XML parsing fails
|
|
80
|
+
*/
|
|
36
81
|
xmlToJson: (input: string) => Promise<any>;
|
|
82
|
+
/**
|
|
83
|
+
* Converts HL7 V2.x message string to JSON object.
|
|
84
|
+
* @param message HL7 V2.x message string to be converted
|
|
85
|
+
* @returns Promise resolving to JSON object
|
|
86
|
+
*/
|
|
37
87
|
hl7v2ToJson: (message: string) => Promise<any>;
|
|
38
88
|
}
|
|
39
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Interface for type conversion operations, providing methods to convert between
|
|
92
|
+
* different content type representations (ContentType, ContentFormat, EditorLanguage, and string).
|
|
93
|
+
*/
|
|
40
94
|
interface ITypeConverter {
|
|
95
|
+
/**
|
|
96
|
+
* Converts a ContentType to its corresponding ContentFormat.
|
|
97
|
+
* @param contentType The ContentType to convert
|
|
98
|
+
* @returns The corresponding ContentFormat
|
|
99
|
+
*/
|
|
41
100
|
contentTypeToContentFormat: (contentType: ContentType) => ContentFormat;
|
|
101
|
+
/**
|
|
102
|
+
* Converts a ContentType to its corresponding EditorLanguage.
|
|
103
|
+
* @param contentType The ContentType to convert
|
|
104
|
+
* @returns The corresponding EditorLanguage
|
|
105
|
+
*/
|
|
42
106
|
contentTypeToEditorLanguage: (contentType: ContentType) => EditorLanguage;
|
|
107
|
+
/**
|
|
108
|
+
* Converts a ContentFormat to its corresponding ContentType.
|
|
109
|
+
* @param format The ContentFormat to convert
|
|
110
|
+
* @returns The corresponding ContentType, or null if conversion is not possible
|
|
111
|
+
*/
|
|
43
112
|
contentFormatToContentType: (format: ContentFormat) => ContentType | null;
|
|
113
|
+
/**
|
|
114
|
+
* Converts a ContentFormat to its corresponding EditorLanguage.
|
|
115
|
+
* @param format The ContentFormat to convert
|
|
116
|
+
* @returns The corresponding EditorLanguage
|
|
117
|
+
*/
|
|
44
118
|
contentFormatToEditorLanguage: (format: ContentFormat) => EditorLanguage;
|
|
119
|
+
/**
|
|
120
|
+
* Converts a string representation to its corresponding ContentFormat.
|
|
121
|
+
* @param format The string representation of a format
|
|
122
|
+
* @returns The corresponding ContentFormat, or null if conversion is not possible
|
|
123
|
+
*/
|
|
45
124
|
stringToContentFormat: (format: string) => ContentFormat | null;
|
|
125
|
+
/**
|
|
126
|
+
* Converts a string representation to its corresponding ContentType.
|
|
127
|
+
* @param contentType The string representation of a content type
|
|
128
|
+
* @returns The corresponding ContentType, or null if conversion is not possible
|
|
129
|
+
*/
|
|
46
130
|
stringToContentType: (contentType: string) => ContentType | null;
|
|
131
|
+
/**
|
|
132
|
+
* Converts a string representation to its corresponding EditorLanguage.
|
|
133
|
+
* @param editorLanguage The string representation of an editor language
|
|
134
|
+
* @returns The corresponding EditorLanguage, or null if conversion is not possible
|
|
135
|
+
*/
|
|
47
136
|
stringToEditorLanguage: (editorLanguage: string) => EditorLanguage | null;
|
|
48
137
|
}
|
|
49
138
|
|
package/package.json
CHANGED
|
@@ -1,49 +1,66 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@outburn/format-converter",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A TypeScript library for converting between various data formats including CSV, XML, HL7 v2, and JSON with specialized healthcare message parsing",
|
|
5
|
-
"main": "./dist/index.cjs",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.mjs",
|
|
13
|
-
"require": "./dist/index.cjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist",
|
|
18
|
-
"lint": "eslint src",
|
|
19
|
-
"build": "npm run clean && tsup",
|
|
20
|
-
"prepublishOnly": "npm run build",
|
|
21
|
-
"test": "vitest run"
|
|
22
|
-
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@outburn/format-converter",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "A TypeScript library for converting between various data formats including CSV, XML, HL7 v2, and JSON with specialized healthcare message parsing",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"clean": "rimraf dist",
|
|
18
|
+
"lint": "eslint src",
|
|
19
|
+
"build": "npm run clean && tsup",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"test": "vitest run"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"format-converter",
|
|
25
|
+
"data-conversion",
|
|
26
|
+
"csv",
|
|
27
|
+
"xml",
|
|
28
|
+
"json",
|
|
29
|
+
"hl7",
|
|
30
|
+
"hl7v2",
|
|
31
|
+
"healthcare",
|
|
32
|
+
"parser",
|
|
33
|
+
"typescript",
|
|
34
|
+
"converter",
|
|
35
|
+
"data-transformation",
|
|
36
|
+
"message-parsing",
|
|
37
|
+
"healthcare-integration",
|
|
38
|
+
"interoperability"
|
|
39
|
+
],
|
|
40
|
+
"author": "Outburn Ltd.",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"csvtojson": "^2.0.14",
|
|
44
|
+
"fast-xml-parser": "^4.5.3",
|
|
45
|
+
"hl7-dictionary": "^1.0.1",
|
|
46
|
+
"hl7js": "^0.0.6",
|
|
47
|
+
"jsonata": "^2.1.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^24.10.1",
|
|
51
|
+
"eslint": "^9.39.1",
|
|
52
|
+
"prettier": "^3.7.3",
|
|
53
|
+
"rimraf": "^6.1.2",
|
|
54
|
+
"tsup": "^8.5.1",
|
|
55
|
+
"tsx": "^4.21.0",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
|
+
"typescript-eslint": "^8.48.1",
|
|
58
|
+
"vitest": "^4.0.14"
|
|
59
|
+
},
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+https://github.com/Outburn-IL/format-converter.git"
|
|
63
|
+
},
|
|
64
|
+
"bugs": "https://github.com/Outburn-IL/format-converter/issues",
|
|
65
|
+
"homepage": "https://github.com/Outburn-IL/format-converter#readme"
|
|
66
|
+
}
|