fhirpath-ts 0.0.0-bootstrap.0 → 0.2.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 +50 -18
- package/dist/analyzer/analyze-dto.d.ts +4 -0
- package/dist/analyzer/analyze-dto.d.ts.map +1 -1
- package/dist/analyzer/analyze-dto.js +12 -14
- package/dist/analyzer/analyze-dto.js.map +1 -1
- package/dist/analyzer/analyze.d.ts +22 -6
- package/dist/analyzer/analyze.d.ts.map +1 -1
- package/dist/analyzer/analyze.js +242 -98
- package/dist/analyzer/analyze.js.map +1 -1
- package/dist/analyzer/declarations.d.ts +26 -0
- package/dist/analyzer/declarations.d.ts.map +1 -0
- package/dist/analyzer/declarations.js +68 -0
- package/dist/analyzer/declarations.js.map +1 -0
- package/dist/analyzer/operator-rules.d.ts +127 -0
- package/dist/analyzer/operator-rules.d.ts.map +1 -0
- package/dist/analyzer/operator-rules.js +70 -0
- package/dist/analyzer/operator-rules.js.map +1 -0
- package/dist/analyzer/signatures.d.ts +1097 -10
- package/dist/analyzer/signatures.d.ts.map +1 -1
- package/dist/analyzer/signatures.js +70 -29
- package/dist/analyzer/signatures.js.map +1 -1
- package/dist/api/compile.d.ts +32 -8
- package/dist/api/compile.d.ts.map +1 -1
- package/dist/api/compile.js +2 -0
- package/dist/api/compile.js.map +1 -1
- package/dist/api/engine.d.ts +42 -16
- package/dist/api/engine.d.ts.map +1 -1
- package/dist/api/engine.js +2 -1
- package/dist/api/engine.js.map +1 -1
- package/dist/api/project.d.ts +8 -8
- package/dist/api/project.d.ts.map +1 -1
- package/dist/api/project.js +31 -19
- package/dist/api/project.js.map +1 -1
- package/dist/api/strict.d.ts +6 -0
- package/dist/api/strict.d.ts.map +1 -0
- package/dist/api/strict.js +71 -0
- package/dist/api/strict.js.map +1 -0
- package/dist/api/tagged.d.ts +4 -4
- package/dist/api/tagged.d.ts.map +1 -1
- package/dist/api/tagged.js.map +1 -1
- package/dist/cli/dto-check.js +7 -3
- package/dist/cli/dto-check.js.map +1 -1
- package/dist/engine/context.d.ts +3 -1
- package/dist/engine/context.d.ts.map +1 -1
- package/dist/engine/context.js +5 -1
- package/dist/engine/context.js.map +1 -1
- package/dist/engine/navigation.d.ts.map +1 -1
- package/dist/engine/navigation.js +7 -48
- package/dist/engine/navigation.js.map +1 -1
- package/dist/engine/type-matching.d.ts.map +1 -1
- package/dist/engine/type-matching.js +6 -16
- package/dist/engine/type-matching.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js +102 -73
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/precedence.d.ts +368 -4
- package/dist/parser/precedence.d.ts.map +1 -1
- package/dist/parser/precedence.js +146 -32
- package/dist/parser/precedence.js.map +1 -1
- package/dist/r4/generated/type-maps.d.ts +1367 -0
- package/dist/r4/generated/type-maps.d.ts.map +1 -1
- package/dist/r4/index.d.ts +3 -1
- package/dist/r4/index.d.ts.map +1 -1
- package/dist/typed/context-maps.d.ts +23 -0
- package/dist/typed/context-maps.d.ts.map +1 -0
- package/dist/typed/context-maps.js +2 -0
- package/dist/typed/context-maps.js.map +1 -0
- package/dist/typed/infer.d.ts +99 -229
- package/dist/typed/infer.d.ts.map +1 -1
- package/dist/typed/infer.js +1 -84
- package/dist/typed/infer.js.map +1 -1
- package/dist/typed/inference-limits.d.ts +7 -0
- package/dist/typed/inference-limits.d.ts.map +1 -0
- package/dist/typed/inference-limits.js +6 -0
- package/dist/typed/inference-limits.js.map +1 -0
- package/dist/typed/metadata-compact.d.ts +189 -0
- package/dist/typed/metadata-compact.d.ts.map +1 -0
- package/dist/typed/metadata-compact.js +3 -0
- package/dist/typed/metadata-compact.js.map +1 -0
- package/dist/typed/parser.d.ts +515 -0
- package/dist/typed/parser.d.ts.map +1 -0
- package/dist/typed/parser.js +2 -0
- package/dist/typed/parser.js.map +1 -0
- package/dist/values/type-compat.d.ts +8 -0
- package/dist/values/type-compat.d.ts.map +1 -1
- package/dist/values/type-compat.js +44 -1
- package/dist/values/type-compat.js.map +1 -1
- package/package.json +20 -1
- package/src/analyzer/analyze-dto.ts +21 -17
- package/src/analyzer/analyze.ts +335 -109
- package/src/analyzer/declarations.ts +120 -0
- package/src/analyzer/operator-rules.ts +88 -0
- package/src/analyzer/signatures.ts +99 -41
- package/src/api/compile.ts +66 -11
- package/src/api/engine.ts +97 -33
- package/src/api/project.ts +54 -30
- package/src/api/strict.ts +112 -0
- package/src/api/tagged.ts +5 -5
- package/src/cli/dto-check.ts +7 -3
- package/src/engine/context.ts +7 -2
- package/src/engine/navigation.ts +7 -52
- package/src/engine/type-matching.ts +11 -17
- package/src/index.ts +25 -2
- package/src/parser/parser.ts +106 -74
- package/src/parser/precedence.ts +250 -33
- package/src/r4/generated/type-maps.ts +1557 -0
- package/src/typed/context-maps.ts +41 -0
- package/src/typed/infer.ts +157 -425
- package/src/typed/inference-limits.ts +9 -0
- package/src/typed/metadata-compact.ts +307 -0
- package/src/typed/parser.ts +2277 -0
- package/src/values/type-compat.ts +48 -1
- package/dist/typed/perf-fixture.types.d.ts +0 -136
- package/dist/typed/perf-fixture.types.d.ts.map +0 -1
- package/dist/typed/perf-fixture.types.js +0 -2
- package/dist/typed/perf-fixture.types.js.map +0 -1
- package/src/typed/perf-fixture.types.ts +0 -143
package/dist/r4/index.d.ts
CHANGED
|
@@ -5,5 +5,7 @@ export type { GeneratedElement, GeneratedType } from './model-data.ts';
|
|
|
5
5
|
/** The generated R4 model: type resolution, element lookup, and the type hierarchy. */
|
|
6
6
|
export declare const r4Model: ModelProvider;
|
|
7
7
|
/** A ready-made engine with the R4 model bound: `r4.evaluate('Patient.name.given', patient)`. */
|
|
8
|
-
export declare const r4: FhirPathEngine
|
|
8
|
+
export declare const r4: FhirPathEngine<{
|
|
9
|
+
readonly model: ModelProvider;
|
|
10
|
+
}>;
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/r4/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/r4/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAOtE,OAAO,EAAE,wBAAwB,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAmCtE,uFAAuF;AACvF,eAAO,MAAM,OAAO,EAAE,aA0DrB,CAAA;AAED,iGAAiG;AACjG,eAAO,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/r4/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAOtE,OAAO,EAAE,wBAAwB,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAmCtE,uFAAuF;AACvF,eAAO,MAAM,OAAO,EAAE,aA0DrB,CAAA;AAED,iGAAiG;AACjG,eAAO,MAAM,EAAE;;EAAyC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** An empty host context that contributes no known keys. */
|
|
2
|
+
export type EmptyContextMap = Record<never, never>;
|
|
3
|
+
/** Preserve host values for best-effort type inference without exposing them as declarations. */
|
|
4
|
+
export type HostValueDeclarations<Values> = Values extends Readonly<Record<PropertyKey, unknown>> ? {
|
|
5
|
+
readonly [Name in keyof Values]: {
|
|
6
|
+
readonly __value: Values[Name];
|
|
7
|
+
};
|
|
8
|
+
} : EmptyContextMap;
|
|
9
|
+
/** Environment names are stored without the optional leading `%`. */
|
|
10
|
+
export type BareContextName<Name extends PropertyKey> = Name extends string ? Name extends `%${infer Bare}` ? Bare : Name : Name;
|
|
11
|
+
/** Normalize both accepted environment-key spellings into one type-level map. */
|
|
12
|
+
export type NormalizeContextMap<Map> = Map extends Readonly<Record<PropertyKey, unknown>> ? {
|
|
13
|
+
readonly [Name in keyof Map as BareContextName<Name>]: Map[Name];
|
|
14
|
+
} : EmptyContextMap;
|
|
15
|
+
/** Merge normalized maps by name, with the overlay taking precedence. */
|
|
16
|
+
export type MergeContextMaps<Base, Overlay> = Omit<NormalizeContextMap<Base>, keyof NormalizeContextMap<Overlay>> & NormalizeContextMap<Overlay>;
|
|
17
|
+
/** Infer undeclared host values while letting explicit declarations replace them. */
|
|
18
|
+
export type InferredHostValueDeclarations<Values, Declarations> = keyof NormalizeContextMap<Values> extends keyof NormalizeContextMap<Declarations> ? NormalizeContextMap<Declarations> : MergeContextMaps<HostValueDeclarations<Values>, Declarations>;
|
|
19
|
+
/** Read an optional context field without distributing undefined into its map. */
|
|
20
|
+
export type ContextProperty<Context, Name extends PropertyKey> = Name extends keyof Context ? Exclude<Context[Name], undefined> : EmptyContextMap;
|
|
21
|
+
/** Look up one normalized name, returning never when it is undeclared. */
|
|
22
|
+
export type LookupContextMap<Map, Name extends string> = Name extends keyof NormalizeContextMap<Map> ? NormalizeContextMap<Map>[Name] : never;
|
|
23
|
+
//# sourceMappingURL=context-maps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-maps.d.ts","sourceRoot":"","sources":["../../src/typed/context-maps.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAElD,iGAAiG;AACjG,MAAM,MAAM,qBAAqB,CAAC,MAAM,IACtC,MAAM,SAAS,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CA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C1E,MAAM,MAAM,gBAAgB,CAAC,GAAG,EAAE,IAAI,SAAS,MAAM,IAAI,IAAI,SAAS,MAAM,mBAAmB,CAAC,GAAG,CAAC,GAChG,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAC9B,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-maps.js","sourceRoot":"","sources":["../../src/typed/context-maps.ts"],"names":[],"mappings":""}
|
package/dist/typed/infer.d.ts
CHANGED
|
@@ -1,234 +1,104 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* functions, unions, groups, and variable roots. Other expressions return
|
|
6
|
-
* `unknown[]`. The runtime and analyzer support the full language.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* A type name the bound model knows — a resource or a datatype. What a DTO's
|
|
10
|
-
* `fhirType` must be, and what `fhirpath`/`compile` accept as the type an
|
|
11
|
-
* expression runs against. Lives here, with the rest of the inference vocabulary,
|
|
12
|
-
* so every layer above spells it one way.
|
|
13
|
-
*/
|
|
1
|
+
import type { R4Resources, R4TypeOf } from '../r4/generated/type-maps.ts';
|
|
2
|
+
import type { BareContextName, ContextProperty, EmptyContextMap, InferredHostValueDeclarations, MergeContextMaps, NormalizeContextMap } from './context-maps.ts';
|
|
3
|
+
import type { InferTypeExpression } from './parser.ts';
|
|
4
|
+
/** A type name known by the generated R4 model. */
|
|
14
5
|
export type FhirTypeName = keyof R4TypeOf & string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type StripQuoted<A extends string> = A extends `${infer L}'${string}'${infer R}` ? `${L}${StripQuoted<R>}` : A;
|
|
47
|
-
/** Every `(` opens before its `)` closes; one nesting level per pair. */
|
|
48
|
-
type Balanced<A extends string> = A extends `${infer L}(${infer M})${infer R}` ? L extends `${string})${string}` ? false : M extends `${string}(${string}` ? false : Balanced<R> : A extends `${string})${string}` ? false : true;
|
|
49
|
-
/** Push one stack entry per `(` of A (quoted spans already stripped). */
|
|
50
|
-
type PushOpens<A extends string, Acc extends unknown[]> = A extends `${string}(${infer R}` ? PushOpens<R, [...Acc, 0]> : Acc;
|
|
51
|
-
/** Checks full parenthesis balance after quoted spans have been removed. */
|
|
52
|
-
type BalancedDeep<A extends string, Open extends unknown[] = []> = A extends `${infer Head})${infer Rest}` ? PushOpens<Head, Open> extends [unknown, ...infer Remaining] ? BalancedDeep<Rest, Remaining> : false : PushOpens<A, Open> extends [] ? true : false;
|
|
53
|
-
/**
|
|
54
|
-
* Whether a fragment is a complete sub-expression, so a `|` (or a group's `)`)
|
|
55
|
-
* right after it is really at the top level: quotes pair up, and what remains
|
|
56
|
-
* after stripping them balances with nothing left open. Backslashes and
|
|
57
|
-
* backticks are declined outright, like CleanArg.
|
|
58
|
-
*/
|
|
59
|
-
type CompleteFragment<A extends string> = A extends `${string}\\${string}` | `${string}\`${string}` ? false : StripQuoted<A> extends infer Q extends string ? Q extends `${string}'${string}` ? false : BalancedDeep<Q> : false;
|
|
60
|
-
/** Strip the leading/trailing spaces a union split leaves around its terms. */
|
|
61
|
-
type Trim<S extends string> = S extends ` ${infer R}` ? Trim<R> : S extends `${infer L} ` ? Trim<L> : S;
|
|
62
|
-
/**
|
|
63
|
-
* Functions with input-independent result types. A test compares this table
|
|
64
|
-
* with analyzer signatures. Functions whose result depends on input stay out.
|
|
65
|
-
*/
|
|
66
|
-
export declare const FIXED_RETURNS: {
|
|
67
|
-
readonly exists: "boolean";
|
|
68
|
-
readonly empty: "boolean";
|
|
69
|
-
readonly not: "boolean";
|
|
70
|
-
readonly hasValue: "boolean";
|
|
71
|
-
readonly count: "integer";
|
|
72
|
-
readonly length: "integer";
|
|
73
|
-
readonly toBoolean: "boolean";
|
|
74
|
-
readonly convertsToBoolean: "boolean";
|
|
75
|
-
readonly convertsToInteger: "boolean";
|
|
76
|
-
readonly convertsToDecimal: "boolean";
|
|
77
|
-
readonly convertsToString: "boolean";
|
|
78
|
-
readonly convertsToDate: "boolean";
|
|
79
|
-
readonly convertsToDateTime: "boolean";
|
|
80
|
-
readonly convertsToTime: "boolean";
|
|
81
|
-
readonly convertsToQuantity: "boolean";
|
|
82
|
-
readonly toInteger: "integer";
|
|
83
|
-
readonly toDecimal: "decimal";
|
|
84
|
-
readonly toString: "string";
|
|
85
|
-
readonly toDate: "date";
|
|
86
|
-
readonly toDateTime: "dateTime";
|
|
87
|
-
readonly toTime: "time";
|
|
88
|
-
readonly toQuantity: "Quantity";
|
|
89
|
-
readonly toChars: "string";
|
|
90
|
-
readonly join: "string";
|
|
91
|
-
readonly trim: "string";
|
|
92
|
-
readonly upper: "string";
|
|
93
|
-
readonly lower: "string";
|
|
94
|
-
readonly replace: "string";
|
|
95
|
-
readonly replaceMatches: "string";
|
|
96
|
-
readonly substring: "string";
|
|
97
|
-
readonly encode: "string";
|
|
98
|
-
readonly decode: "string";
|
|
99
|
-
readonly escape: "string";
|
|
100
|
-
readonly unescape: "string";
|
|
101
|
-
readonly split: "string";
|
|
102
|
-
readonly matches: "boolean";
|
|
103
|
-
readonly matchesFull: "boolean";
|
|
104
|
-
readonly startsWith: "boolean";
|
|
105
|
-
readonly endsWith: "boolean";
|
|
106
|
-
readonly contains: "boolean";
|
|
107
|
-
readonly subsetOf: "boolean";
|
|
108
|
-
readonly supersetOf: "boolean";
|
|
109
|
-
readonly isDistinct: "boolean";
|
|
110
|
-
readonly allTrue: "boolean";
|
|
111
|
-
readonly anyTrue: "boolean";
|
|
112
|
-
readonly allFalse: "boolean";
|
|
113
|
-
readonly anyFalse: "boolean";
|
|
114
|
-
readonly all: "boolean";
|
|
115
|
-
readonly indexOf: "integer";
|
|
116
|
-
readonly lastIndexOf: "integer";
|
|
117
|
-
readonly ceiling: "integer";
|
|
118
|
-
readonly floor: "integer";
|
|
119
|
-
readonly truncate: "integer";
|
|
120
|
-
readonly round: "decimal";
|
|
121
|
-
readonly sqrt: "decimal";
|
|
122
|
-
readonly exp: "decimal";
|
|
123
|
-
readonly ln: "decimal";
|
|
124
|
-
readonly log: "decimal";
|
|
6
|
+
export type EmptyFhirpathTypeContext = EmptyContextMap;
|
|
7
|
+
/** A host declaration that the type-level evaluator can use without reading a runtime value. */
|
|
8
|
+
export interface FhirpathTypeDeclaration<Type extends FhirTypeName = FhirTypeName, Collection extends boolean = boolean> {
|
|
9
|
+
/** One candidate type, or every candidate a value may hold. */
|
|
10
|
+
type: Type | readonly Type[];
|
|
11
|
+
/** Omitted means at most one item; true means the value may contain many. */
|
|
12
|
+
collection?: Collection;
|
|
13
|
+
/** Resource targets when `type` includes Reference. */
|
|
14
|
+
targets?: FhirTypeName | readonly FhirTypeName[];
|
|
15
|
+
}
|
|
16
|
+
export type FhirpathTypeDeclarations = Readonly<Record<string, FhirpathTypeDeclaration>>;
|
|
17
|
+
/** The static fields of a native, expression-defined, or overloaded custom function. */
|
|
18
|
+
export type FhirpathFunctionDeclaration = {
|
|
19
|
+
readonly signature?: {
|
|
20
|
+
readonly input?: {
|
|
21
|
+
readonly types?: readonly string[];
|
|
22
|
+
};
|
|
23
|
+
readonly args?: readonly string[];
|
|
24
|
+
readonly result?: {
|
|
25
|
+
readonly types?: readonly string[];
|
|
26
|
+
readonly single?: boolean;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly expression?: string | {
|
|
30
|
+
readonly source: string;
|
|
31
|
+
};
|
|
32
|
+
readonly criteria?: boolean;
|
|
33
|
+
readonly env?: Readonly<Record<string, unknown>>;
|
|
34
|
+
readonly envTypes?: FhirpathTypeDeclarations;
|
|
35
|
+
} | {
|
|
36
|
+
readonly overloads: readonly FhirpathFunctionDeclaration[];
|
|
125
37
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*/
|
|
134
|
-
export
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
* final `)`.
|
|
149
|
-
*/
|
|
150
|
-
type StepAcrossParen<Expr extends string, S extends string> = ScanSegmentEnd<Expr, '', S>;
|
|
151
|
-
type ScanSegmentEnd<Expr extends string, Acc extends string, S extends string> = Expr extends `${infer Head}).${infer Rest}` ? SegmentComplete<`${Acc}${Head}`> extends true ? ParseSegments<Rest, Step<S, `${Acc}${Head})`>> : ScanSegmentEnd<Rest, `${Acc}${Head}).`, S> : WholeParenSegment<`${Acc}${Expr}`, S>;
|
|
152
|
-
/** Whether `Body)` is one complete call segment: its argument closes exactly there. */
|
|
153
|
-
type SegmentComplete<Body extends string> = `${Body})` extends `${infer _Fn}(${infer Arg})` ? CompleteFragment<Arg> : false;
|
|
154
|
-
/** The rest of the expression is a single paren segment ending at its final `)`. */
|
|
155
|
-
type WholeParenSegment<Expr extends string, S extends string> = Expr extends `${infer Head})${''}` ? Step<S, `${Head})`> : 'opaque';
|
|
156
|
-
/**
|
|
157
|
-
* One expression in a context state `S`: a `|`-union of terms, or a single
|
|
158
|
-
* term. Plain dotted paths take two cheap checks: one skips the union scanner,
|
|
159
|
-
* and the next skips trimming and group or `%var` handling.
|
|
160
|
-
*/
|
|
161
|
-
type ParseExpr<Expr extends string, S extends string> = Expr extends `${string}|${string}` | `(${string}` | `%${string}` ? ParseUnion<Expr, S> : Expr extends `${infer Root}.${infer Rest}` ? Root extends keyof R4Resources & string ? ParseSegments<Rest, Root> : ParseSegments<Expr, S> : Expr extends keyof R4Resources & string ? Expr : ParseSegments<Expr, S>;
|
|
162
|
-
/**
|
|
163
|
-
* Split off the leftmost top-level `|`. A candidate fragment whose quotes or
|
|
164
|
-
* parens are cut mid-way (the `|` sat inside a literal or a group) is not a
|
|
165
|
-
* split point: the fragment absorbs the `|` and the scan continues. With no
|
|
166
|
-
* top-level `|` at all, the whole expression is one term — its own parse is
|
|
167
|
-
* the validation, so this branch needs no separate completeness check.
|
|
168
|
-
*/
|
|
169
|
-
type SplitUnion<Expr extends string, Acc extends string = ''> = Expr extends `${infer L}|${infer R}` ? CompleteFragment<`${Acc}${L}`> extends true ? {
|
|
170
|
-
term: `${Acc}${L}`;
|
|
171
|
-
rest: R;
|
|
172
|
-
} : SplitUnion<R, `${Acc}${L}|`> : {
|
|
173
|
-
whole: `${Acc}${Expr}`;
|
|
38
|
+
/** Type information supplied by a host around a literal FHIRPath expression. */
|
|
39
|
+
export interface FhirpathTypeContext {
|
|
40
|
+
env?: FhirpathTypeDeclarations;
|
|
41
|
+
vars?: FhirpathTypeDeclarations;
|
|
42
|
+
/** The same declarations accepted by `EvaluateOptions.functions`. */
|
|
43
|
+
functions?: Readonly<Record<string, FhirpathFunctionDeclaration>>;
|
|
44
|
+
}
|
|
45
|
+
/** The inferred result of evaluating a literal FHIRPath expression. */
|
|
46
|
+
export type FhirpathResult<Expression extends string, Context extends FhirpathTypeContext = EmptyFhirpathTypeContext> = FhirpathResultIn<Expression, 'opaque', Context>;
|
|
47
|
+
/**
|
|
48
|
+
* The inferred result with an explicit FHIR input type. Non-literal,
|
|
49
|
+
* malformed, over-budget, or unsupported expressions safely become
|
|
50
|
+
* `unknown[]`.
|
|
51
|
+
*/
|
|
52
|
+
export type FhirpathResultIn<Expression extends string, Input extends string, Context extends FhirpathTypeContext = EmptyFhirpathTypeContext> = FhirpathResultForContext<Expression, Input, Context>;
|
|
53
|
+
/** Internal inference entry point for contexts assembled from generic API options. */
|
|
54
|
+
export type FhirpathResultForContext<Expression extends string, Input extends string, Context extends object = EmptyFhirpathTypeContext> = string extends Expression ? unknown[] : InferTypeExpression<Expression, Input, Context>;
|
|
55
|
+
/** Merge contexts by normalized name. The later context wins, matching per-call runtime options. */
|
|
56
|
+
export type MergeFhirpathTypeContexts<Base extends object, Overlay extends object> = {
|
|
57
|
+
env: MergeContextMaps<ContextProperty<Base, 'env'>, ContextProperty<Overlay, 'env'>>;
|
|
58
|
+
vars: MergeContextMaps<ContextProperty<Base, 'vars'>, ContextProperty<Overlay, 'vars'>>;
|
|
59
|
+
functions: MergeContextMaps<ContextProperty<Base, 'functions'>, ContextProperty<Overlay, 'functions'>>;
|
|
174
60
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} ?
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
type
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
type
|
|
204
|
-
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
type
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
* `string` (a non-literal expression) and anything outside the subset give
|
|
218
|
-
* `unknown[]`. The context is 'opaque': terms must be resource-rooted,
|
|
219
|
-
* `%var`-rooted, or parenthesized groups of those — a relative term
|
|
220
|
-
* (`id | …`) has no root to resolve against here and degrades.
|
|
221
|
-
*/
|
|
222
|
-
export type FhirpathResult<Expr extends string> = FhirpathResultIn<Expr, 'opaque'>;
|
|
223
|
-
/**
|
|
224
|
-
* The inferred result of evaluating `Expr` with `Input` as the context type —
|
|
225
|
-
* what a DTO's `fhirType` gives its columns, so their paths can stay relative
|
|
226
|
-
* (`clinicalStatus.coding.first().code`). A resource-rooted term still resolves
|
|
227
|
-
* against its own root, and a type name outside the model degrades like any
|
|
228
|
-
* other out-of-subset expression.
|
|
229
|
-
*/
|
|
230
|
-
export type FhirpathResultIn<Expr extends string, Input extends string> = string extends Expr ? unknown[] : ResultOf<ParseExpr<Expr, Input>>;
|
|
231
|
-
/** The expected input resource for `Expr` (`Patient.name` wants a Patient). */
|
|
232
|
-
export type FhirpathInput<Expr extends string> = string extends Expr ? unknown : Expr extends `${infer Root}.${string}` ? Root extends keyof R4Resources ? R4Resources[Root] : unknown : Expr extends keyof R4Resources ? R4Resources[Expr] : unknown;
|
|
61
|
+
type LiteralVarDeclaration<Value> = Value extends string ? string extends Value ? FhirpathTypeDeclaration : FhirpathTypeDeclaration & {
|
|
62
|
+
readonly __expression: Value;
|
|
63
|
+
} : Value extends {
|
|
64
|
+
readonly source: infer Source extends string;
|
|
65
|
+
} ? string extends Source ? FhirpathTypeDeclaration : FhirpathTypeDeclaration & {
|
|
66
|
+
readonly __expression: Source;
|
|
67
|
+
} : FhirpathTypeDeclaration;
|
|
68
|
+
type LiteralVarDeclarations<Values> = Values extends Readonly<Record<PropertyKey, unknown>> ? {
|
|
69
|
+
readonly [Name in keyof Values]: LiteralVarDeclaration<Values[Name]>;
|
|
70
|
+
} : EmptyFhirpathTypeContext;
|
|
71
|
+
type OptionEnvironmentContext<Options> = Options extends {
|
|
72
|
+
readonly env?: infer Env;
|
|
73
|
+
} ? InferredHostValueDeclarations<Exclude<Env, undefined>, ContextProperty<Options, 'envTypes'>> : NormalizeContextMap<ContextProperty<Options, 'envTypes'>>;
|
|
74
|
+
/** The inference context retained from one literal engine or per-call options object. */
|
|
75
|
+
export type FhirpathTypeContextOf<Options> = {
|
|
76
|
+
env: OptionEnvironmentContext<Options>;
|
|
77
|
+
vars: MergeContextMaps<LiteralVarDeclarations<ContextProperty<Options, 'vars'>>, ContextProperty<Options, 'varTypes'>>;
|
|
78
|
+
functions: NormalizeContextMap<ContextProperty<Options, 'functions'>>;
|
|
79
|
+
};
|
|
80
|
+
type DeclarationElement<Declaration> = Declaration extends {
|
|
81
|
+
readonly type: infer Type;
|
|
82
|
+
} ? Type extends readonly FhirTypeName[] ? R4TypeOf[Type[number]] : Type extends FhirTypeName ? R4TypeOf[Type] : unknown : unknown;
|
|
83
|
+
type DeclaredHostValue<Declaration> = Declaration extends {
|
|
84
|
+
readonly collection: true;
|
|
85
|
+
} ? DeclarationElement<Declaration> | readonly DeclarationElement<Declaration>[] | undefined : DeclarationElement<Declaration> | readonly [] | readonly [DeclarationElement<Declaration>] | undefined;
|
|
86
|
+
type ConstrainedDeclaredValues<Values, Declarations> = Values extends Readonly<Record<PropertyKey, unknown>> ? {
|
|
87
|
+
[Name in keyof Values]: LookupNormalizedDeclaration<Declarations, Name> extends infer Declaration ? [Declaration] extends [never] ? Values[Name] : Values[Name] extends DeclaredHostValue<Declaration> ? Values[Name] : never : Values[Name];
|
|
88
|
+
} : Values;
|
|
89
|
+
type LookupNormalizedDeclaration<Declarations, Name extends PropertyKey> = BareContextName<Name> extends keyof NormalizeContextMap<Declarations> ? NormalizeContextMap<Declarations>[BareContextName<Name>] : never;
|
|
90
|
+
/** Cross-check declarations and values when both remain visible in one literal options object. */
|
|
91
|
+
export type CheckedFhirpathOptionValues<Options> = Options extends {
|
|
92
|
+
readonly env: infer Env;
|
|
93
|
+
readonly envTypes: infer EnvTypes;
|
|
94
|
+
} ? {
|
|
95
|
+
readonly env: ConstrainedDeclaredValues<Env, EnvTypes>;
|
|
96
|
+
} : unknown;
|
|
97
|
+
/** A model root known from a resource-shaped input; ambiguous and structural inputs stay opaque. */
|
|
98
|
+
export type FhirpathRootOf<Input> = Input extends readonly (infer Item)[] ? FhirpathRootOf<Item> : Input extends {
|
|
99
|
+
readonly resourceType: infer Root extends FhirTypeName;
|
|
100
|
+
} ? Root : 'opaque';
|
|
101
|
+
/** The expected input resource for a resource-rooted literal expression. */
|
|
102
|
+
export type FhirpathInput<Expression extends string> = string extends Expression ? unknown : Expression extends `${infer Root}.${string}` ? Root extends keyof R4Resources ? R4Resources[Root] : unknown : Expression extends keyof R4Resources ? R4Resources[Expression] : unknown;
|
|
233
103
|
export {};
|
|
234
104
|
//# sourceMappingURL=infer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infer.d.ts","sourceRoot":"","sources":["../../src/typed/infer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"infer.d.ts","sourceRoot":"","sources":["../../src/typed/infer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG,MAAM,QAAQ,GAAG,MAAM,CAAA;AAClD,MAAM,MAAM,wBAAwB,GAAG,eAAe,CAAA;AAEtD,gGAAgG;AAChG,MAAM,WAAW,uBAAuB,CACtC,IAAI,SAAS,YAAY,GAAG,YAAY,EACxC,UAAU,SAAS,OAAO,GAAG,OAAO;IAEpC,+DAA+D;IAC/D,IAAI,EAAE,IAAI,GAAG,SAAS,IAAI,EAAE,CAAA;IAC5B,6EAA6E;IAC7E,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,uDAAuD;IACvD,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,YAAY,EAAE,CAAA;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AE,yBAAyB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;CAAE,GAC1D,OAAO,CAAA;AAEX,oGAAoG;AACpG,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI,KAAK,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GACrE,cAAc,CAAC,IAAI,CAAC,GACpB,KAAK,SAAS;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,SAAS,YAAY,CAAA;CAAE,GACtE,IAAI,GACJ,QAAQ,CAAA;AAEd,4EAA4E;AAC5E,MAAM,MAAM,aAAa,CAAC,UAAU,SAAS,MAAM,IAAI,MAAM,SAAS,UAAU,GAC5E,OAAO,GACP,UAAU,SAAS,GAAG,MAAM,IAAI,IAAI,MAAM,EAAE,GAC1C,IAAI,SAAS,MAAM,WAAW,GAC5B,WAAW,CAAC,IAAI,CAAC,GACjB,OAAO,GACT,UAAU,SAAS,MAAM,WAAW,GAClC,WAAW,CAAC,UAAU,CAAC,GACvB,OAAO,CAAA"}
|
package/dist/typed/infer.js
CHANGED
|
@@ -1,85 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Functions with input-independent result types. A test compares this table
|
|
3
|
-
* with analyzer signatures. Functions whose result depends on input stay out.
|
|
4
|
-
*/
|
|
5
|
-
export const FIXED_RETURNS = {
|
|
6
|
-
exists: 'boolean',
|
|
7
|
-
empty: 'boolean',
|
|
8
|
-
not: 'boolean',
|
|
9
|
-
hasValue: 'boolean',
|
|
10
|
-
count: 'integer',
|
|
11
|
-
length: 'integer',
|
|
12
|
-
toBoolean: 'boolean',
|
|
13
|
-
convertsToBoolean: 'boolean',
|
|
14
|
-
convertsToInteger: 'boolean',
|
|
15
|
-
convertsToDecimal: 'boolean',
|
|
16
|
-
convertsToString: 'boolean',
|
|
17
|
-
convertsToDate: 'boolean',
|
|
18
|
-
convertsToDateTime: 'boolean',
|
|
19
|
-
convertsToTime: 'boolean',
|
|
20
|
-
convertsToQuantity: 'boolean',
|
|
21
|
-
toInteger: 'integer',
|
|
22
|
-
toDecimal: 'decimal',
|
|
23
|
-
toString: 'string',
|
|
24
|
-
toDate: 'date',
|
|
25
|
-
toDateTime: 'dateTime',
|
|
26
|
-
toTime: 'time',
|
|
27
|
-
toQuantity: 'Quantity',
|
|
28
|
-
toChars: 'string',
|
|
29
|
-
join: 'string',
|
|
30
|
-
trim: 'string',
|
|
31
|
-
upper: 'string',
|
|
32
|
-
lower: 'string',
|
|
33
|
-
replace: 'string',
|
|
34
|
-
replaceMatches: 'string',
|
|
35
|
-
substring: 'string',
|
|
36
|
-
encode: 'string',
|
|
37
|
-
decode: 'string',
|
|
38
|
-
escape: 'string',
|
|
39
|
-
unescape: 'string',
|
|
40
|
-
split: 'string',
|
|
41
|
-
matches: 'boolean',
|
|
42
|
-
matchesFull: 'boolean',
|
|
43
|
-
startsWith: 'boolean',
|
|
44
|
-
endsWith: 'boolean',
|
|
45
|
-
contains: 'boolean',
|
|
46
|
-
subsetOf: 'boolean',
|
|
47
|
-
supersetOf: 'boolean',
|
|
48
|
-
isDistinct: 'boolean',
|
|
49
|
-
allTrue: 'boolean',
|
|
50
|
-
anyTrue: 'boolean',
|
|
51
|
-
allFalse: 'boolean',
|
|
52
|
-
anyFalse: 'boolean',
|
|
53
|
-
all: 'boolean',
|
|
54
|
-
indexOf: 'integer',
|
|
55
|
-
lastIndexOf: 'integer',
|
|
56
|
-
ceiling: 'integer',
|
|
57
|
-
floor: 'integer',
|
|
58
|
-
truncate: 'integer',
|
|
59
|
-
round: 'decimal',
|
|
60
|
-
sqrt: 'decimal',
|
|
61
|
-
exp: 'decimal',
|
|
62
|
-
ln: 'decimal',
|
|
63
|
-
log: 'decimal',
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Functions that yield a subset or reordering of their input, so the input's
|
|
67
|
-
* type carries through. Cross-checked against the analyzer the same way as
|
|
68
|
-
* FIXED_RETURNS (their signatures preserve the input's types). `abs` is
|
|
69
|
-
* excluded deliberately: it preserves the numeric kind at runtime, but the
|
|
70
|
-
* analyzer declares its result unknown, and the table must not outrun it.
|
|
71
|
-
*/
|
|
72
|
-
export const IDENTITY_RETURNS = [
|
|
73
|
-
'where',
|
|
74
|
-
'first',
|
|
75
|
-
'last',
|
|
76
|
-
'single',
|
|
77
|
-
'distinct',
|
|
78
|
-
'tail',
|
|
79
|
-
'skip',
|
|
80
|
-
'take',
|
|
81
|
-
'exclude',
|
|
82
|
-
'intersect',
|
|
83
|
-
'trace',
|
|
84
|
-
];
|
|
1
|
+
export {};
|
|
85
2
|
//# sourceMappingURL=infer.js.map
|
package/dist/typed/infer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infer.js","sourceRoot":"","sources":["../../src/typed/infer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"infer.js","sourceRoot":"","sources":["../../src/typed/infer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Maximum tokens the type-level scanner emits for one literal expression. */
|
|
2
|
+
export declare const INFERENCE_TOKEN_LIMIT = 64;
|
|
3
|
+
/** Maximum source characters the type-level scanner visits for one literal expression. */
|
|
4
|
+
export declare const INFERENCE_SOURCE_STEP_LIMIT = 256;
|
|
5
|
+
export type InferenceTokenLimit = typeof INFERENCE_TOKEN_LIMIT;
|
|
6
|
+
export type InferenceSourceStepLimit = typeof INFERENCE_SOURCE_STEP_LIMIT;
|
|
7
|
+
//# sourceMappingURL=inference-limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference-limits.d.ts","sourceRoot":"","sources":["../../src/typed/inference-limits.ts"],"names":[],"mappings":"AACA,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,KAAK,CAAA;AAEvC,0FAA0F;AAC1F,eAAO,MAAM,2BAA2B,MAAM,CAAA;AAE9C,MAAM,MAAM,mBAAmB,GAAG,OAAO,qBAAqB,CAAA;AAC9D,MAAM,MAAM,wBAAwB,GAAG,OAAO,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* v8 ignore file -- build-time constants consumed by the type parser and generation scripts */
|
|
2
|
+
/** Maximum tokens the type-level scanner emits for one literal expression. */
|
|
3
|
+
export const INFERENCE_TOKEN_LIMIT = 64;
|
|
4
|
+
/** Maximum source characters the type-level scanner visits for one literal expression. */
|
|
5
|
+
export const INFERENCE_SOURCE_STEP_LIMIT = 256;
|
|
6
|
+
//# sourceMappingURL=inference-limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference-limits.js","sourceRoot":"","sources":["../../src/typed/inference-limits.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,8EAA8E;AAC9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEvC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAA"}
|