@fhiron/sdk 0.1.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 +128 -0
- package/package.json +57 -0
- package/src/_linter/catalog.js +638 -0
- package/src/_linter/examples.js +270 -0
- package/src/_linter/i18n.js +403 -0
- package/src/_linter/resources.js +173 -0
- package/src/_linter/rules.d.ts +105 -0
- package/src/_linter/rules.js +1196 -0
- package/src/_linter/terminology.js +265 -0
- package/src/errors.js +73 -0
- package/src/http.js +127 -0
- package/src/index.d.ts +125 -0
- package/src/index.js +194 -0
- package/src/index.mjs +16 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Type declarations for @fhiron/linter rules.
|
|
2
|
+
// The runtime is pure JS (CommonJS) so it works unchanged in Node, the
|
|
3
|
+
// dashboard's Web Worker, and the MCP connector.
|
|
4
|
+
|
|
5
|
+
export type Severity = "error" | "warning" | "info";
|
|
6
|
+
|
|
7
|
+
export interface QuickFix {
|
|
8
|
+
/** Human-readable title shown in the dashboard and returned to the IDE. */
|
|
9
|
+
title: string;
|
|
10
|
+
/** RFC 6901 pointer into the FHIR resource (e.g. /identifier/0/value). */
|
|
11
|
+
jsonPointer: string;
|
|
12
|
+
/** Replacement value for the target node. */
|
|
13
|
+
replacement: unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface LintIssue {
|
|
17
|
+
/** Stable identifier — e.g. cl-run-01. The IA reads this, not the prose. */
|
|
18
|
+
code: string;
|
|
19
|
+
severity: Severity;
|
|
20
|
+
/** Dotted FHIR path (Patient.identifier[0].value). Empty string for root. */
|
|
21
|
+
path: string;
|
|
22
|
+
/** Message in Spanish, Sentence case, with profile reference. */
|
|
23
|
+
message: string;
|
|
24
|
+
/** Optional pedagogical context — explains POR QUÉ the issue is wrong. */
|
|
25
|
+
why?: string;
|
|
26
|
+
/** Optional canonical URL of the StructureDefinition / CodeSystem that fails. */
|
|
27
|
+
profileUrl?: string;
|
|
28
|
+
/** Optional human docs URL (docs.fhiron.cl/errores/{code}). */
|
|
29
|
+
docsUrl?: string;
|
|
30
|
+
/** Optional textual suggestion when no automatic quickFix is possible. */
|
|
31
|
+
suggestion?: string;
|
|
32
|
+
/** Optional small example (5–10 lines) of a correct shape. */
|
|
33
|
+
example?: unknown;
|
|
34
|
+
/** Optional automated correction. */
|
|
35
|
+
quickFix?: QuickFix;
|
|
36
|
+
/** Bundle context: when the issue belongs to a Bundle entry, the entry index. */
|
|
37
|
+
entryIndex?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare const RUN_SYSTEMS: readonly string[];
|
|
41
|
+
|
|
42
|
+
export interface LintOptions {
|
|
43
|
+
/** Si false, no agrega los campos pedagógicos (why, profileUrl, etc.). Default: true. */
|
|
44
|
+
enrich?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare function lintResource(
|
|
48
|
+
input: object | string,
|
|
49
|
+
options?: LintOptions,
|
|
50
|
+
): LintIssue[];
|
|
51
|
+
|
|
52
|
+
export declare function applyQuickFix(
|
|
53
|
+
input: object | string,
|
|
54
|
+
fix: QuickFix,
|
|
55
|
+
): string;
|
|
56
|
+
|
|
57
|
+
export declare function stripRunDots(value: string): string;
|
|
58
|
+
|
|
59
|
+
export interface RunDvResult {
|
|
60
|
+
valid: boolean;
|
|
61
|
+
expected?: string;
|
|
62
|
+
given?: string;
|
|
63
|
+
/** Present when valid:true — cuerpo-DV sin puntos. */
|
|
64
|
+
normalized?: string;
|
|
65
|
+
/** Present when valid:false and format was parseable — cuerpo-DV sin puntos. */
|
|
66
|
+
cleaned?: string;
|
|
67
|
+
/** Human-readable error message when valid:false. */
|
|
68
|
+
message?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare function validateRunDv(raw: string): RunDvResult;
|
|
72
|
+
|
|
73
|
+
export interface RunFormatResult {
|
|
74
|
+
valid: boolean;
|
|
75
|
+
message: string | null;
|
|
76
|
+
cleaned: string | null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export declare function classifyRunFormat(raw: string): RunFormatResult;
|
|
80
|
+
|
|
81
|
+
export declare function translateJsonParseError(err: unknown): string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Devuelve la entrada del catálogo (catalog.js) para un código, o null.
|
|
85
|
+
* Útil para `fhiron_explain_code` y para enriquecer issues servidor.
|
|
86
|
+
*/
|
|
87
|
+
export declare function lookupCode(code: string): {
|
|
88
|
+
why?: string;
|
|
89
|
+
profileUrl?: string;
|
|
90
|
+
docsUrl?: string;
|
|
91
|
+
suggestion?: string;
|
|
92
|
+
example?: unknown;
|
|
93
|
+
} | null;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Lista todos los códigos del catálogo. Útil para tests y para ofrecer
|
|
97
|
+
* sugerencias a la IA cuando el usuario pregunta "¿qué errores conoces?".
|
|
98
|
+
*/
|
|
99
|
+
export declare function listCodes(): string[];
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Aplica la información del catálogo a un issue (mutativo + return).
|
|
103
|
+
* Si el código no está en el catálogo, devuelve el issue intacto.
|
|
104
|
+
*/
|
|
105
|
+
export declare function enrichIssue(issue: LintIssue): LintIssue;
|