fhirpath-ts 0.0.0-bootstrap.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/LICENSE +201 -0
- package/README.md +391 -0
- package/THIRD-PARTY-NOTICES.md +296 -0
- package/dist/analyzer/analyze-dto.d.ts +45 -0
- package/dist/analyzer/analyze-dto.d.ts.map +1 -0
- package/dist/analyzer/analyze-dto.js +147 -0
- package/dist/analyzer/analyze-dto.js.map +1 -0
- package/dist/analyzer/analyze.d.ts +98 -0
- package/dist/analyzer/analyze.d.ts.map +1 -0
- package/dist/analyzer/analyze.js +925 -0
- package/dist/analyzer/analyze.js.map +1 -0
- package/dist/analyzer/expression-policy.d.ts +210 -0
- package/dist/analyzer/expression-policy.d.ts.map +1 -0
- package/dist/analyzer/expression-policy.js +254 -0
- package/dist/analyzer/expression-policy.js.map +1 -0
- package/dist/analyzer/index.d.ts +3 -0
- package/dist/analyzer/index.d.ts.map +1 -0
- package/dist/analyzer/index.js +6 -0
- package/dist/analyzer/index.js.map +1 -0
- package/dist/analyzer/regex-safety.d.ts +10 -0
- package/dist/analyzer/regex-safety.d.ts.map +1 -0
- package/dist/analyzer/regex-safety.js +84 -0
- package/dist/analyzer/regex-safety.js.map +1 -0
- package/dist/analyzer/signatures.d.ts +72 -0
- package/dist/analyzer/signatures.d.ts.map +1 -0
- package/dist/analyzer/signatures.js +195 -0
- package/dist/analyzer/signatures.js.map +1 -0
- package/dist/api/bundle.d.ts +29 -0
- package/dist/api/bundle.d.ts.map +1 -0
- package/dist/api/bundle.js +108 -0
- package/dist/api/bundle.js.map +1 -0
- package/dist/api/cache.d.ts +10 -0
- package/dist/api/cache.d.ts.map +1 -0
- package/dist/api/cache.js +38 -0
- package/dist/api/cache.js.map +1 -0
- package/dist/api/column-signature.d.ts +53 -0
- package/dist/api/column-signature.d.ts.map +1 -0
- package/dist/api/column-signature.js +43 -0
- package/dist/api/column-signature.js.map +1 -0
- package/dist/api/compile.d.ts +120 -0
- package/dist/api/compile.d.ts.map +1 -0
- package/dist/api/compile.js +167 -0
- package/dist/api/compile.js.map +1 -0
- package/dist/api/constraints.d.ts +48 -0
- package/dist/api/constraints.d.ts.map +1 -0
- package/dist/api/constraints.js +52 -0
- package/dist/api/constraints.js.map +1 -0
- package/dist/api/dto.d.ts +134 -0
- package/dist/api/dto.d.ts.map +1 -0
- package/dist/api/dto.js +295 -0
- package/dist/api/dto.js.map +1 -0
- package/dist/api/engine.d.ts +136 -0
- package/dist/api/engine.d.ts.map +1 -0
- package/dist/api/engine.js +183 -0
- package/dist/api/engine.js.map +1 -0
- package/dist/api/evaluate.d.ts +7 -0
- package/dist/api/evaluate.d.ts.map +1 -0
- package/dist/api/evaluate.js +10 -0
- package/dist/api/evaluate.js.map +1 -0
- package/dist/api/project.d.ts +89 -0
- package/dist/api/project.d.ts.map +1 -0
- package/dist/api/project.js +150 -0
- package/dist/api/project.js.map +1 -0
- package/dist/api/tagged.d.ts +14 -0
- package/dist/api/tagged.d.ts.map +1 -0
- package/dist/api/tagged.js +13 -0
- package/dist/api/tagged.js.map +1 -0
- package/dist/cli/dto-check.d.ts +25 -0
- package/dist/cli/dto-check.d.ts.map +1 -0
- package/dist/cli/dto-check.js +77 -0
- package/dist/cli/dto-check.js.map +1 -0
- package/dist/cli/fhirpath-check.d.ts +3 -0
- package/dist/cli/fhirpath-check.d.ts.map +1 -0
- package/dist/cli/fhirpath-check.js +149 -0
- package/dist/cli/fhirpath-check.js.map +1 -0
- package/dist/cli/ts-loader.d.mts +3 -0
- package/dist/cli/ts-loader.d.mts.map +1 -0
- package/dist/cli/ts-loader.mjs +48 -0
- package/dist/cli/ts-loader.mjs.map +1 -0
- package/dist/engine/context.d.ts +173 -0
- package/dist/engine/context.d.ts.map +1 -0
- package/dist/engine/context.js +118 -0
- package/dist/engine/context.js.map +1 -0
- package/dist/engine/evaluator.d.ts +7 -0
- package/dist/engine/evaluator.d.ts.map +1 -0
- package/dist/engine/evaluator.js +196 -0
- package/dist/engine/evaluator.js.map +1 -0
- package/dist/engine/navigation.d.ts +11 -0
- package/dist/engine/navigation.d.ts.map +1 -0
- package/dist/engine/navigation.js +102 -0
- package/dist/engine/navigation.js.map +1 -0
- package/dist/engine/operators/collections.d.ts +12 -0
- package/dist/engine/operators/collections.d.ts.map +1 -0
- package/dist/engine/operators/collections.js +31 -0
- package/dist/engine/operators/collections.js.map +1 -0
- package/dist/engine/operators/comparison.d.ts +13 -0
- package/dist/engine/operators/comparison.d.ts.map +1 -0
- package/dist/engine/operators/comparison.js +77 -0
- package/dist/engine/operators/comparison.js.map +1 -0
- package/dist/engine/operators/equality.d.ts +19 -0
- package/dist/engine/operators/equality.d.ts.map +1 -0
- package/dist/engine/operators/equality.js +203 -0
- package/dist/engine/operators/equality.js.map +1 -0
- package/dist/engine/operators/index.d.ts +18 -0
- package/dist/engine/operators/index.d.ts.map +1 -0
- package/dist/engine/operators/index.js +30 -0
- package/dist/engine/operators/index.js.map +1 -0
- package/dist/engine/operators/logic.d.ts +8 -0
- package/dist/engine/operators/logic.d.ts.map +1 -0
- package/dist/engine/operators/logic.js +38 -0
- package/dist/engine/operators/logic.js.map +1 -0
- package/dist/engine/operators/math.d.ts +13 -0
- package/dist/engine/operators/math.d.ts.map +1 -0
- package/dist/engine/operators/math.js +198 -0
- package/dist/engine/operators/math.js.map +1 -0
- package/dist/engine/operators/strings.d.ts +8 -0
- package/dist/engine/operators/strings.d.ts.map +1 -0
- package/dist/engine/operators/strings.js +22 -0
- package/dist/engine/operators/strings.js.map +1 -0
- package/dist/engine/operators/types.d.ts +3 -0
- package/dist/engine/operators/types.d.ts.map +1 -0
- package/dist/engine/operators/types.js +15 -0
- package/dist/engine/operators/types.js.map +1 -0
- package/dist/engine/type-matching.d.ts +20 -0
- package/dist/engine/type-matching.d.ts.map +1 -0
- package/dist/engine/type-matching.js +122 -0
- package/dist/engine/type-matching.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -0
- package/dist/eslint/index.d.ts +12 -0
- package/dist/eslint/index.d.ts.map +1 -0
- package/dist/eslint/index.js +316 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/fhir/html-checks.d.ts +7 -0
- package/dist/fhir/html-checks.d.ts.map +1 -0
- package/dist/fhir/html-checks.js +256 -0
- package/dist/fhir/html-checks.js.map +1 -0
- package/dist/fhir/model-navigation.d.ts +11 -0
- package/dist/fhir/model-navigation.d.ts.map +1 -0
- package/dist/fhir/model-navigation.js +142 -0
- package/dist/fhir/model-navigation.js.map +1 -0
- package/dist/functions/aggregate.d.ts +2 -0
- package/dist/functions/aggregate.d.ts.map +1 -0
- package/dist/functions/aggregate.js +127 -0
- package/dist/functions/aggregate.js.map +1 -0
- package/dist/functions/boundary.d.ts +2 -0
- package/dist/functions/boundary.d.ts.map +1 -0
- package/dist/functions/boundary.js +189 -0
- package/dist/functions/boundary.js.map +1 -0
- package/dist/functions/combining.d.ts +2 -0
- package/dist/functions/combining.d.ts.map +1 -0
- package/dist/functions/combining.js +13 -0
- package/dist/functions/combining.js.map +1 -0
- package/dist/functions/control.d.ts +2 -0
- package/dist/functions/control.d.ts.map +1 -0
- package/dist/functions/control.js +25 -0
- package/dist/functions/control.js.map +1 -0
- package/dist/functions/conversion.d.ts +3 -0
- package/dist/functions/conversion.d.ts.map +1 -0
- package/dist/functions/conversion.js +316 -0
- package/dist/functions/conversion.js.map +1 -0
- package/dist/functions/date-components.d.ts +2 -0
- package/dist/functions/date-components.d.ts.map +1 -0
- package/dist/functions/date-components.js +81 -0
- package/dist/functions/date-components.js.map +1 -0
- package/dist/functions/existence.d.ts +4 -0
- package/dist/functions/existence.d.ts.map +1 -0
- package/dist/functions/existence.js +97 -0
- package/dist/functions/existence.js.map +1 -0
- package/dist/functions/fhir.d.ts +2 -0
- package/dist/functions/fhir.d.ts.map +1 -0
- package/dist/functions/fhir.js +222 -0
- package/dist/functions/fhir.js.map +1 -0
- package/dist/functions/filtering.d.ts +2 -0
- package/dist/functions/filtering.d.ts.map +1 -0
- package/dist/functions/filtering.js +112 -0
- package/dist/functions/filtering.js.map +1 -0
- package/dist/functions/install.d.ts +18 -0
- package/dist/functions/install.d.ts.map +1 -0
- package/dist/functions/install.js +20 -0
- package/dist/functions/install.js.map +1 -0
- package/dist/functions/iteration.d.ts +7 -0
- package/dist/functions/iteration.d.ts.map +1 -0
- package/dist/functions/iteration.js +9 -0
- package/dist/functions/iteration.js.map +1 -0
- package/dist/functions/math.d.ts +2 -0
- package/dist/functions/math.d.ts.map +1 -0
- package/dist/functions/math.js +152 -0
- package/dist/functions/math.js.map +1 -0
- package/dist/functions/reflection.d.ts +2 -0
- package/dist/functions/reflection.d.ts.map +1 -0
- package/dist/functions/reflection.js +23 -0
- package/dist/functions/reflection.js.map +1 -0
- package/dist/functions/registry.d.ts +28 -0
- package/dist/functions/registry.d.ts.map +1 -0
- package/dist/functions/registry.js +46 -0
- package/dist/functions/registry.js.map +1 -0
- package/dist/functions/sort.d.ts +2 -0
- package/dist/functions/sort.d.ts.map +1 -0
- package/dist/functions/sort.js +48 -0
- package/dist/functions/sort.js.map +1 -0
- package/dist/functions/string.d.ts +2 -0
- package/dist/functions/string.d.ts.map +1 -0
- package/dist/functions/string.js +353 -0
- package/dist/functions/string.js.map +1 -0
- package/dist/functions/subsetting.d.ts +2 -0
- package/dist/functions/subsetting.d.ts.map +1 -0
- package/dist/functions/subsetting.js +72 -0
- package/dist/functions/subsetting.js.map +1 -0
- package/dist/functions/tree.d.ts +8 -0
- package/dist/functions/tree.d.ts.map +1 -0
- package/dist/functions/tree.js +109 -0
- package/dist/functions/tree.js.map +1 -0
- package/dist/functions/type-specifier.d.ts +8 -0
- package/dist/functions/type-specifier.d.ts.map +1 -0
- package/dist/functions/type-specifier.js +27 -0
- package/dist/functions/type-specifier.js.map +1 -0
- package/dist/functions/utility.d.ts +2 -0
- package/dist/functions/utility.d.ts.map +1 -0
- package/dist/functions/utility.js +76 -0
- package/dist/functions/utility.js.map +1 -0
- package/dist/functions/variables.d.ts +2 -0
- package/dist/functions/variables.d.ts.map +1 -0
- package/dist/functions/variables.js +35 -0
- package/dist/functions/variables.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer/lexer.d.ts +4 -0
- package/dist/lexer/lexer.d.ts.map +1 -0
- package/dist/lexer/lexer.js +318 -0
- package/dist/lexer/lexer.js.map +1 -0
- package/dist/lexer/tokens.d.ts +23 -0
- package/dist/lexer/tokens.d.ts.map +1 -0
- package/dist/lexer/tokens.js +40 -0
- package/dist/lexer/tokens.js.map +1 -0
- package/dist/model/provider.d.ts +36 -0
- package/dist/model/provider.d.ts.map +1 -0
- package/dist/model/provider.js +2 -0
- package/dist/model/provider.js.map +1 -0
- package/dist/parser/ast.d.ts +104 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +2 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/parser.d.ts +4 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +299 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/precedence.d.ts +24 -0
- package/dist/parser/precedence.d.ts.map +1 -0
- package/dist/parser/precedence.js +52 -0
- package/dist/parser/precedence.js.map +1 -0
- package/dist/parser/printer.d.ts +4 -0
- package/dist/parser/printer.d.ts.map +1 -0
- package/dist/parser/printer.js +112 -0
- package/dist/parser/printer.js.map +1 -0
- package/dist/r4/generated/resources-data.d.ts +3 -0
- package/dist/r4/generated/resources-data.d.ts.map +1 -0
- package/dist/r4/generated/resources-data.js +28628 -0
- package/dist/r4/generated/resources-data.js.map +1 -0
- package/dist/r4/generated/type-maps.d.ts +43153 -0
- package/dist/r4/generated/type-maps.d.ts.map +1 -0
- package/dist/r4/generated/type-maps.js +4 -0
- package/dist/r4/generated/type-maps.js.map +1 -0
- package/dist/r4/generated/types-data.d.ts +3 -0
- package/dist/r4/generated/types-data.d.ts.map +1 -0
- package/dist/r4/generated/types-data.js +2205 -0
- package/dist/r4/generated/types-data.js.map +1 -0
- package/dist/r4/index.d.ts +9 -0
- package/dist/r4/index.d.ts.map +1 -0
- package/dist/r4/index.js +94 -0
- package/dist/r4/index.js.map +1 -0
- package/dist/r4/model-data.d.ts +17 -0
- package/dist/r4/model-data.d.ts.map +1 -0
- package/dist/r4/model-data.js +2 -0
- package/dist/r4/model-data.js.map +1 -0
- package/dist/sites/index.d.ts +31 -0
- package/dist/sites/index.d.ts.map +1 -0
- package/dist/sites/index.js +205 -0
- package/dist/sites/index.js.map +1 -0
- package/dist/typed/infer.d.ts +234 -0
- package/dist/typed/infer.d.ts.map +1 -0
- package/dist/typed/infer.js +85 -0
- package/dist/typed/infer.js.map +1 -0
- package/dist/typed/perf-fixture.types.d.ts +136 -0
- package/dist/typed/perf-fixture.types.d.ts.map +1 -0
- package/dist/typed/perf-fixture.types.js +2 -0
- package/dist/typed/perf-fixture.types.js.map +1 -0
- package/dist/values/collection.d.ts +24 -0
- package/dist/values/collection.d.ts.map +1 -0
- package/dist/values/collection.js +51 -0
- package/dist/values/collection.js.map +1 -0
- package/dist/values/datetime.d.ts +54 -0
- package/dist/values/datetime.d.ts.map +1 -0
- package/dist/values/datetime.js +226 -0
- package/dist/values/datetime.js.map +1 -0
- package/dist/values/decimal.d.ts +48 -0
- package/dist/values/decimal.d.ts.map +1 -0
- package/dist/values/decimal.js +188 -0
- package/dist/values/decimal.js.map +1 -0
- package/dist/values/numeric.d.ts +24 -0
- package/dist/values/numeric.d.ts.map +1 -0
- package/dist/values/numeric.js +53 -0
- package/dist/values/numeric.js.map +1 -0
- package/dist/values/quantity.d.ts +49 -0
- package/dist/values/quantity.d.ts.map +1 -0
- package/dist/values/quantity.js +297 -0
- package/dist/values/quantity.js.map +1 -0
- package/dist/values/temporal-arithmetic.d.ts +17 -0
- package/dist/values/temporal-arithmetic.d.ts.map +1 -0
- package/dist/values/temporal-arithmetic.js +183 -0
- package/dist/values/temporal-arithmetic.js.map +1 -0
- package/dist/values/temporal-compare.d.ts +9 -0
- package/dist/values/temporal-compare.d.ts.map +1 -0
- package/dist/values/temporal-compare.js +59 -0
- package/dist/values/temporal-compare.js.map +1 -0
- package/dist/values/type-compat.d.ts +47 -0
- package/dist/values/type-compat.d.ts.map +1 -0
- package/dist/values/type-compat.js +100 -0
- package/dist/values/type-compat.js.map +1 -0
- package/dist/values/typed-value.d.ts +48 -0
- package/dist/values/typed-value.d.ts.map +1 -0
- package/dist/values/typed-value.js +117 -0
- package/dist/values/typed-value.js.map +1 -0
- package/dist/values/ucum.d.ts +14 -0
- package/dist/values/ucum.d.ts.map +1 -0
- package/dist/values/ucum.js +146 -0
- package/dist/values/ucum.js.map +1 -0
- package/package.json +137 -0
- package/src/analyzer/analyze-dto.ts +195 -0
- package/src/analyzer/analyze.ts +1181 -0
- package/src/analyzer/expression-policy.ts +434 -0
- package/src/analyzer/index.ts +23 -0
- package/src/analyzer/regex-safety.ts +85 -0
- package/src/analyzer/signatures.ts +260 -0
- package/src/api/bundle.ts +132 -0
- package/src/api/cache.ts +40 -0
- package/src/api/column-signature.ts +71 -0
- package/src/api/compile.ts +308 -0
- package/src/api/constraints.ts +104 -0
- package/src/api/dto.ts +445 -0
- package/src/api/engine.ts +328 -0
- package/src/api/evaluate.ts +11 -0
- package/src/api/project.ts +255 -0
- package/src/api/tagged.ts +35 -0
- package/src/cli/dto-check.ts +94 -0
- package/src/cli/fhirpath-check.ts +168 -0
- package/src/cli/ts-loader.mjs +49 -0
- package/src/engine/context.ts +282 -0
- package/src/engine/evaluator.ts +246 -0
- package/src/engine/navigation.ts +106 -0
- package/src/engine/operators/collections.ts +34 -0
- package/src/engine/operators/comparison.ts +82 -0
- package/src/engine/operators/equality.ts +232 -0
- package/src/engine/operators/index.ts +65 -0
- package/src/engine/operators/logic.ts +53 -0
- package/src/engine/operators/math.ts +225 -0
- package/src/engine/operators/strings.ts +25 -0
- package/src/engine/operators/types.ts +16 -0
- package/src/engine/type-matching.ts +148 -0
- package/src/errors.ts +33 -0
- package/src/eslint/index.ts +388 -0
- package/src/fhir/html-checks.ts +266 -0
- package/src/fhir/model-navigation.ts +148 -0
- package/src/functions/aggregate.ts +136 -0
- package/src/functions/boundary.ts +209 -0
- package/src/functions/combining.ts +15 -0
- package/src/functions/control.ts +25 -0
- package/src/functions/conversion.ts +349 -0
- package/src/functions/date-components.ts +88 -0
- package/src/functions/existence.ts +107 -0
- package/src/functions/fhir.ts +247 -0
- package/src/functions/filtering.ts +120 -0
- package/src/functions/install.ts +19 -0
- package/src/functions/iteration.ts +21 -0
- package/src/functions/math.ts +167 -0
- package/src/functions/reflection.ts +24 -0
- package/src/functions/registry.ts +72 -0
- package/src/functions/sort.ts +68 -0
- package/src/functions/string.ts +413 -0
- package/src/functions/subsetting.ts +89 -0
- package/src/functions/tree.ts +112 -0
- package/src/functions/type-specifier.ts +29 -0
- package/src/functions/utility.ts +82 -0
- package/src/functions/variables.ts +36 -0
- package/src/index.ts +30 -0
- package/src/lexer/lexer.ts +341 -0
- package/src/lexer/tokens.ts +69 -0
- package/src/model/provider.ts +36 -0
- package/src/parser/ast.ts +164 -0
- package/src/parser/parser.ts +321 -0
- package/src/parser/precedence.ts +52 -0
- package/src/parser/printer.ts +114 -0
- package/src/r4/generated/resources-data.ts +28631 -0
- package/src/r4/generated/type-maps.ts +22145 -0
- package/src/r4/generated/types-data.ts +2208 -0
- package/src/r4/index.ts +107 -0
- package/src/r4/model-data.ts +17 -0
- package/src/sites/index.ts +285 -0
- package/src/typed/infer.ts +433 -0
- package/src/typed/perf-fixture.types.ts +143 -0
- package/src/values/collection.ts +57 -0
- package/src/values/datetime.ts +285 -0
- package/src/values/decimal.ts +213 -0
- package/src/values/numeric.ts +63 -0
- package/src/values/quantity.ts +358 -0
- package/src/values/temporal-arithmetic.ts +231 -0
- package/src/values/temporal-compare.ts +65 -0
- package/src/values/type-compat.ts +133 -0
- package/src/values/typed-value.ts +151 -0
- package/src/values/ucum.ts +181 -0
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fhirpath-ts",
|
|
3
|
+
"version": "0.0.0-bootstrap.0",
|
|
4
|
+
"description": "TypeScript-native FHIRPath engine with compile-time type inference and a spec §11 static analyzer.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fhirpath",
|
|
7
|
+
"fhir",
|
|
8
|
+
"hl7",
|
|
9
|
+
"healthcare",
|
|
10
|
+
"interoperability",
|
|
11
|
+
"r4",
|
|
12
|
+
"static-analysis",
|
|
13
|
+
"type-inference",
|
|
14
|
+
"eslint-plugin",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"author": "Vinta Software (https://github.com/vintasoftware)",
|
|
19
|
+
"homepage": "https://github.com/vintasoftware/fhirpath-ts#readme",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/vintasoftware/fhirpath-ts.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/vintasoftware/fhirpath-ts/issues"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"./dist/functions/*.js",
|
|
33
|
+
"./src/functions/*.ts",
|
|
34
|
+
"./dist/cli/*.js",
|
|
35
|
+
"./src/cli/*.ts"
|
|
36
|
+
],
|
|
37
|
+
"main": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./r4": {
|
|
45
|
+
"types": "./dist/r4/index.d.ts",
|
|
46
|
+
"default": "./dist/r4/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./analyzer": {
|
|
49
|
+
"types": "./dist/analyzer/index.d.ts",
|
|
50
|
+
"default": "./dist/analyzer/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./eslint": {
|
|
53
|
+
"types": "./dist/eslint/index.d.ts",
|
|
54
|
+
"default": "./dist/eslint/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./sites": {
|
|
57
|
+
"types": "./dist/sites/index.d.ts",
|
|
58
|
+
"default": "./dist/sites/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
},
|
|
62
|
+
"bin": {
|
|
63
|
+
"fhirpath-check": "./dist/cli/fhirpath-check.js"
|
|
64
|
+
},
|
|
65
|
+
"files": [
|
|
66
|
+
"dist",
|
|
67
|
+
"src",
|
|
68
|
+
"!src/**/*.test.ts",
|
|
69
|
+
"!src/testing",
|
|
70
|
+
"THIRD-PARTY-NOTICES.md"
|
|
71
|
+
],
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"eslint": ">=9.0.0",
|
|
77
|
+
"typescript": ">=5.0.0 <7.0.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"eslint": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"typescript": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
89
|
+
"@eslint/js": "^9.39.2",
|
|
90
|
+
"@medplum/definitions": "5.1.24",
|
|
91
|
+
"@medplum/fhirtypes": "5.1.24",
|
|
92
|
+
"@types/estree": "^1.0.9",
|
|
93
|
+
"@types/node": "^24.12.0",
|
|
94
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
95
|
+
"eslint": "^9.39.2",
|
|
96
|
+
"eslint-config-prettier": "^10.1.8",
|
|
97
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
98
|
+
"fast-check": "^4.9.0",
|
|
99
|
+
"fast-xml-parser": "^5.3.2",
|
|
100
|
+
"fhirpath": "^4.11.0",
|
|
101
|
+
"globals": "^17.7.0",
|
|
102
|
+
"husky": "^9.1.7",
|
|
103
|
+
"jiti": "^2.6.1",
|
|
104
|
+
"lint-staged": "^16.2.4",
|
|
105
|
+
"npm": "11.11.0",
|
|
106
|
+
"prettier": "^3.6.2",
|
|
107
|
+
"publint": "^0.3.23",
|
|
108
|
+
"typescript": "^5.9.3",
|
|
109
|
+
"typescript-eslint": "^8.46.0",
|
|
110
|
+
"vite": "^8.0.3",
|
|
111
|
+
"vitest": "^4.1.2"
|
|
112
|
+
},
|
|
113
|
+
"lint-staged": {
|
|
114
|
+
"*.{ts,tsx,js,jsx,mjs,cjs}": [
|
|
115
|
+
"eslint --fix",
|
|
116
|
+
"prettier --write"
|
|
117
|
+
],
|
|
118
|
+
"*.{json,jsonc}": [
|
|
119
|
+
"prettier --write"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"scripts": {
|
|
123
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
124
|
+
"build": "pnpm run clean && tsc -p tsconfig.build.json",
|
|
125
|
+
"typecheck": "tsc --noEmit",
|
|
126
|
+
"check:type-perf": "node scripts/check-type-perf.ts",
|
|
127
|
+
"check:package": "node scripts/check-package.ts",
|
|
128
|
+
"test": "vitest run",
|
|
129
|
+
"test:watch": "vitest",
|
|
130
|
+
"coverage": "vitest run --coverage",
|
|
131
|
+
"lint": "eslint . && prettier --check .",
|
|
132
|
+
"lint:fix": "eslint --fix . && prettier --write .",
|
|
133
|
+
"format": "prettier --write .",
|
|
134
|
+
"generate:r4": "node scripts/generate-r4-model.ts",
|
|
135
|
+
"check:fhirpath": "node src/cli/fhirpath-check.ts"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { columnResultType } from '../api/column-signature.ts'
|
|
2
|
+
import { type ColumnSpec, type DtoClass, dtoDefinition } from '../api/dto.ts'
|
|
3
|
+
import type { ModelProvider } from '../model/provider.ts'
|
|
4
|
+
import { valueKindOfTypeName } from '../values/type-compat.ts'
|
|
5
|
+
import {
|
|
6
|
+
analyzeExpressionDetailed,
|
|
7
|
+
type AnalyzeOptions,
|
|
8
|
+
type AnalyzerDiagnostic,
|
|
9
|
+
type DeclaredFunction,
|
|
10
|
+
type DeclaredVariable,
|
|
11
|
+
} from './analyze.ts'
|
|
12
|
+
|
|
13
|
+
/** One `analyzeDto` finding: an analyzer diagnostic plus the class member it came from. */
|
|
14
|
+
export interface DtoDiagnostic extends AnalyzerDiagnostic {
|
|
15
|
+
/** The column field name, or `vars.<name>` for a DTO var. */
|
|
16
|
+
member: string
|
|
17
|
+
/** The expression that produced the finding, so a reporter can locate it in source. */
|
|
18
|
+
expression: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Engine context read by the analyzer without importing the engine implementation. */
|
|
22
|
+
export interface AnalyzedContext {
|
|
23
|
+
readonly defaults: { model?: ModelProvider; functions?: Record<string, DeclaredFunction>; env?: object }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A context that also knows which DTOs it registered, which is what a sweep needs. */
|
|
27
|
+
export interface AnalyzedEngine extends AnalyzedContext {
|
|
28
|
+
readonly dtos: readonly DtoClass[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `analyzeDto` options, with the engine the DTO belongs to as a shortcut for its context. */
|
|
32
|
+
export interface AnalyzeDtoOptions extends AnalyzeOptions {
|
|
33
|
+
/** Engine model, functions, and environment names used while checking the DTO. */
|
|
34
|
+
engine?: AnalyzedContext
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The analyzer context for a DTO: what its engine supplies, with the caller's
|
|
39
|
+
* own options layered on top *per name* — one function or variable a host
|
|
40
|
+
* declares must not displace the engine's whole table, or a valid column call
|
|
41
|
+
* would be reported as unresolved. `model` and `inputType` are single values, so
|
|
42
|
+
* there the caller simply wins.
|
|
43
|
+
*/
|
|
44
|
+
function contextOf(options: AnalyzeDtoOptions | undefined): AnalyzeOptions {
|
|
45
|
+
const { engine, ...caller } = options ?? {}
|
|
46
|
+
if (engine === undefined) {
|
|
47
|
+
return caller
|
|
48
|
+
}
|
|
49
|
+
const { model, functions, env } = engine.defaults
|
|
50
|
+
return {
|
|
51
|
+
...(model !== undefined && { model }),
|
|
52
|
+
...caller,
|
|
53
|
+
functions: { ...functions, ...caller.functions },
|
|
54
|
+
variables: { ...envVariables(env), ...caller.variables },
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** An engine's env names, declared as variables the expressions may read. */
|
|
59
|
+
function envVariables(env: object | undefined): Record<string, DeclaredVariable> {
|
|
60
|
+
const variables: Record<string, DeclaredVariable> = {}
|
|
61
|
+
for (const name of Object.keys(env ?? {})) {
|
|
62
|
+
variables[bare(name)] = {}
|
|
63
|
+
}
|
|
64
|
+
return variables
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Every DTO an engine registered, checked against that engine's own context —
|
|
69
|
+
* the sweep a project's checker runs, with no list to maintain: the engine
|
|
70
|
+
* already knows its `resourceDtos`. Each finding names the class it came from.
|
|
71
|
+
* DTOs the engine does not register (row shapes you only ever project) are not
|
|
72
|
+
* reachable from here; pass those to `analyzeDto` yourself, or list them.
|
|
73
|
+
*/
|
|
74
|
+
export function analyzeEngineDtos(
|
|
75
|
+
engine: AnalyzedEngine,
|
|
76
|
+
options?: AnalyzeOptions
|
|
77
|
+
): (DtoDiagnostic & { dto: string })[] {
|
|
78
|
+
return engine.dtos.flatMap(dto =>
|
|
79
|
+
analyzeDto(dto, { ...options, engine }).map(finding => ({ ...finding, dto: dto.name }))
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Checks a DTO's columns, criteria, and variables. The DTO type is the input
|
|
85
|
+
* context. DTO environment names, caller environment names, and row variables
|
|
86
|
+
* are declared automatically. Variables are checked in order. Declared column
|
|
87
|
+
* types and enums are compared with the analyzer result.
|
|
88
|
+
*/
|
|
89
|
+
export function analyzeDto(dto: DtoClass, options?: AnalyzeDtoOptions): DtoDiagnostic[] {
|
|
90
|
+
const definition = dtoDefinition(dto)
|
|
91
|
+
const context = contextOf(options)
|
|
92
|
+
const inputType = context.inputType ?? definition.fhirType
|
|
93
|
+
const declared: Record<string, DeclaredVariable> = {
|
|
94
|
+
rowIndex: { types: ['System.Integer'], single: true },
|
|
95
|
+
rowTotal: { types: ['System.Integer'], single: true },
|
|
96
|
+
}
|
|
97
|
+
for (const name of [...Object.keys(definition.env ?? {}), ...(definition.callerEnv ?? [])]) {
|
|
98
|
+
declared[bare(name)] = {}
|
|
99
|
+
}
|
|
100
|
+
const diagnostics: DtoDiagnostic[] = []
|
|
101
|
+
const analyze = (member: string, expression: string, column?: ColumnSpec): void => {
|
|
102
|
+
const perExpression: AnalyzeOptions = {
|
|
103
|
+
...context,
|
|
104
|
+
...(inputType !== undefined && { inputType }),
|
|
105
|
+
variables: { ...declared, ...context.variables },
|
|
106
|
+
}
|
|
107
|
+
const { diagnostics: found, result } = analyzeExpressionDetailed(expression, perExpression)
|
|
108
|
+
for (const diagnostic of found) {
|
|
109
|
+
diagnostics.push({ member, expression, ...diagnostic })
|
|
110
|
+
}
|
|
111
|
+
const mismatch = column === undefined ? undefined : declaredTypeMismatch(column, result.types, context)
|
|
112
|
+
if (mismatch !== undefined) {
|
|
113
|
+
// The conflicting field declaration is outside the expression, so mark the whole expression.
|
|
114
|
+
diagnostics.push({
|
|
115
|
+
member,
|
|
116
|
+
expression,
|
|
117
|
+
severity: 'error',
|
|
118
|
+
code: 'column-type',
|
|
119
|
+
message: mismatch,
|
|
120
|
+
span: { start: 0, end: expression.length, line: 1, column: 1 },
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const [name, value] of Object.entries(definition.vars ?? {})) {
|
|
125
|
+
const source = typeof value === 'string' ? value : sourceOf(value)
|
|
126
|
+
if (source !== undefined) {
|
|
127
|
+
// A var declares no type, so there is nothing to cross-check against.
|
|
128
|
+
analyze(`vars.${bare(name)}`, source)
|
|
129
|
+
}
|
|
130
|
+
declared[bare(name)] = {}
|
|
131
|
+
}
|
|
132
|
+
for (const [name, spec] of Object.entries(definition.columns)) {
|
|
133
|
+
analyze(name, expressionOf(spec), spec)
|
|
134
|
+
}
|
|
135
|
+
return diagnostics
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The expression a column reads: a criteria's `test`, else its path. */
|
|
139
|
+
function expressionOf(column: ColumnSpec): string {
|
|
140
|
+
return 'test' in column ? column.test : column.path
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The type a column claims its expression yields — `columnSignature`'s rule, the
|
|
145
|
+
* one the engine registers and the walkers declare, so a cross-check can never
|
|
146
|
+
* contradict a claim that was never made.
|
|
147
|
+
*
|
|
148
|
+
* A criteria claims nothing here, even though its function declares a Boolean
|
|
149
|
+
* result. The Boolean comes from the criteria rule applied to the result, not
|
|
150
|
+
* from the expression itself. `@criteria('name.given')` validly returns
|
|
151
|
+
* HumanName.given, which then reads as true.
|
|
152
|
+
*/
|
|
153
|
+
function claimedType(column: ColumnSpec): string | undefined {
|
|
154
|
+
return 'test' in column ? undefined : columnResultType(column)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Compares a declared column type with analyzer results. Primitive types compare
|
|
159
|
+
* by value kind; complex types use the model hierarchy. Unknown results pass.
|
|
160
|
+
*/
|
|
161
|
+
function declaredTypeMismatch(
|
|
162
|
+
column: ColumnSpec,
|
|
163
|
+
yielded: string[] | undefined,
|
|
164
|
+
options: AnalyzeOptions | undefined
|
|
165
|
+
): string | undefined {
|
|
166
|
+
const claimed = claimedType(column)
|
|
167
|
+
if (claimed === undefined || yielded === undefined || yielded.length === 0) {
|
|
168
|
+
return undefined
|
|
169
|
+
}
|
|
170
|
+
const canonical = options?.model?.resolveType(claimed) ?? claimed
|
|
171
|
+
const claimedKind = valueKindOfTypeName(canonical)
|
|
172
|
+
const fits = yielded.some(type => {
|
|
173
|
+
if (valueKindOfTypeName(type) !== claimedKind) {
|
|
174
|
+
return false
|
|
175
|
+
}
|
|
176
|
+
if (claimedKind !== 'Complex') {
|
|
177
|
+
return true
|
|
178
|
+
}
|
|
179
|
+
const model = options?.model
|
|
180
|
+
/* v8 ignore next -- without a model the analyzer never reaches a complex FHIR type, so the model-less half cannot be exercised */
|
|
181
|
+
return model === undefined || model.isSubtypeOf(type, canonical) || model.isSubtypeOf(canonical, type)
|
|
182
|
+
})
|
|
183
|
+
return fits ? undefined : `Column declares type '${claimed}', but the expression yields ${yielded.join(' | ')}`
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const bare = (name: string): string => (name.startsWith('%') ? name.slice(1) : name)
|
|
187
|
+
|
|
188
|
+
/** A pre-compiled var's source text; a pre-bound TypedValue[] has nothing to analyze. */
|
|
189
|
+
function sourceOf(value: object): string | undefined {
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
return undefined
|
|
192
|
+
}
|
|
193
|
+
const source = (value as { source?: unknown }).source
|
|
194
|
+
return typeof source === 'string' ? source : undefined
|
|
195
|
+
}
|