@d4l/collect-lib 1.51.1 → 1.53.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 +12 -2
- package/dist/chunk-DDAAVRWG.js +25 -0
- package/dist/chunk-DDAAVRWG.js.map +1 -0
- package/dist/chunk-FJBZBVPE.mjs +25 -0
- package/dist/chunk-FJBZBVPE.mjs.map +1 -0
- package/dist/enable-when-expression-L1gQM0rv.d.mts +76 -0
- package/dist/enable-when-expression-L1gQM0rv.d.ts +76 -0
- package/dist/fhirpath.d.mts +24 -0
- package/dist/fhirpath.d.ts +24 -0
- package/dist/fhirpath.js +16 -0
- package/dist/fhirpath.js.map +1 -0
- package/dist/fhirpath.mjs +16 -0
- package/dist/fhirpath.mjs.map +1 -0
- package/dist/index.d.mts +348 -158
- package/dist/index.d.ts +348 -158
- package/dist/index.js +3541 -2524
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3476 -2459
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -1
package/README.md
CHANGED
|
@@ -45,6 +45,16 @@ Update the types by running `yarn run readme:update`.
|
|
|
45
45
|
| featured | true | [ProgramFeatured](#ProgramFeatured) | Describes the featured state of the program. |
|
|
46
46
|
| theme | false | 'D4L', 'GREEN', 'PURPLE', 'OLIVE' or 'BLUE' | The theme to be used for the program in the app |
|
|
47
47
|
| appVersion | false | object | Minimum smartphone app version required to run this program. When the installed app is below `version`, the program update is withheld and the user is asked to update. `version` and `androidVersionCode` must describe the same app release. |
|
|
48
|
+
| tracking | false | [ProgramTracking](#ProgramTracking) | BI event tracking configuration. When absent, tracking is off. |
|
|
49
|
+
|
|
50
|
+
#### ProgramTracking
|
|
51
|
+
|
|
52
|
+
BI event tracking is opt-in per program: no configuration means no tracking.
|
|
53
|
+
|
|
54
|
+
| Properties | Required | Type | Description |
|
|
55
|
+
| ---------- | -------- | ------------------ | ------------------------------------------------------------------------- |
|
|
56
|
+
| enabled | true | boolean | Master switch for BI event tracking in this program |
|
|
57
|
+
| categories | true | TrackingCategory[] | Event categories ('technical', 'task', 'engagement') that may be recorded |
|
|
48
58
|
|
|
49
59
|
#### ProgramAppVersion
|
|
50
60
|
|
|
@@ -156,7 +166,7 @@ Minimum app version a program requires. `version` (semver / versionName) drives
|
|
|
156
166
|
| type | true | `date` | Condition that requires a date to have passed |
|
|
157
167
|
| date | true | string (YYYY-MM-DD) | Timestamp that needs to be passed for the condition to be true. |
|
|
158
168
|
|
|
159
|
-
####
|
|
169
|
+
#### CodeQuestionCondition
|
|
160
170
|
|
|
161
171
|
| Properties | Required | Type | Description |
|
|
162
172
|
| ------------ | -------- | ----------------------------------- | ------------------------------------------------------------------------------- |
|
|
@@ -167,7 +177,7 @@ Minimum app version a program requires. `version` (semver / versionName) drives
|
|
|
167
177
|
| operand | false | string | (unless operator is `exists`). Used as `<answer>` `<operator>` `<operand>`. |
|
|
168
178
|
| operator | true | `exists`,`=`,`!=`,`>`,`<`,`>=`,`<=` | Used as `<answer>` `<operator>` `<operand>`. |
|
|
169
179
|
|
|
170
|
-
####
|
|
180
|
+
#### DateQuestionCondition
|
|
171
181
|
|
|
172
182
|
| Properties | Required | Type | Description |
|
|
173
183
|
| ------------ | -------- | ---------- | --------------------------------------------------------------------- |
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps;
|
|
25
|
+
//# sourceMappingURL=chunk-DDAAVRWG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/collect-lib/collect-lib/dist/chunk-DDAAVRWG.js"],"names":[],"mappings":"AAAA,6EAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,WAAW,EAAE,MAAM,CAAC,gBAAgB;AACxC,IAAI,kBAAkB,EAAE,MAAM,CAAC,yBAAyB;AACxD,IAAI,oBAAoB,EAAE,MAAM,CAAC,qBAAqB;AACtD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,oBAAoB;AACxD,IAAI,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK;AAC/J,IAAI,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG;AAC/B,EAAE,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAChC,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACvC,EAAE,GAAG,CAAC,mBAAmB;AACzB,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACzC,IAAI;AACJ,EAAE,OAAO,CAAC;AACV,CAAC;AACD,IAAI,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;AACjE;AACA;AACE;AACA;AACF,+EAAC","file":"/home/runner/work/collect-lib/collect-lib/dist/chunk-DDAAVRWG.js"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
__spreadValues,
|
|
23
|
+
__spreadProps
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-FJBZBVPE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-questionnaire `enableWhen`: the supported FHIRPath subset, an engine-free subset validator,
|
|
3
|
+
* and a shared conformance fixture.
|
|
4
|
+
*
|
|
5
|
+
* A cross-questionnaire or derived condition is expressed as an SDC `enableWhenExpression`
|
|
6
|
+
* (text/fhirpath) over named variables (see `questionnaire-item-variable` in constants.ts).
|
|
7
|
+
* To keep the feature testable and the authoring UI able to compile to it, phoenix only
|
|
8
|
+
* evaluates and next-research-studio only emits the closed subset declared here. Studio never
|
|
9
|
+
* writes FHIRPath by hand: it compiles structured conditions via `enable-when-conditions.ts`, whose
|
|
10
|
+
* templates are the only producer of expressions.
|
|
11
|
+
*
|
|
12
|
+
* This module is intentionally engine-free: it defines the subset and the fixture as data.
|
|
13
|
+
* The evaluator lives in `enable-when-eval.ts` (exposed via the `./fhirpath`
|
|
14
|
+
* subpath) and must satisfy `ENABLE_WHEN_CONFORMANCE_CASES`; `findSubsetViolations` must accept
|
|
15
|
+
* every in-subset expression and reject every `OUT_OF_SUBSET_EXPRESSIONS` entry. Keeping both
|
|
16
|
+
* repos pinned to this one fixture is the guard against subset drift.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Boolean, comparison and membership operators, plus collection union, allowed in an enableWhen
|
|
20
|
+
* expression. `contains` is the infix membership operator (`%coll contains 'x'`), not the string
|
|
21
|
+
* function.
|
|
22
|
+
*/
|
|
23
|
+
declare const SUPPORTED_FHIRPATH_OPERATORS: readonly ["and", "or", "contains", "=", "!=", ">", "<", ">=", "<=", "|"];
|
|
24
|
+
/**
|
|
25
|
+
* Functions allowed in an enableWhen expression. `today`/`now` read the ambient clock (device time in
|
|
26
|
+
* production, pinned via fake timers in tests). Variable values always arrive as strings, so a
|
|
27
|
+
* value must be converted before it can be compared to a number (`toInteger`/`toDecimal`) or used
|
|
28
|
+
* in date arithmetic (`toDate`); comparing a raw string variable to a number is an evaluation
|
|
29
|
+
* error, not a false.
|
|
30
|
+
*/
|
|
31
|
+
declare const SUPPORTED_FHIRPATH_FUNCTIONS: readonly ["exists", "empty", "not", "first", "today", "now", "toDate", "toInteger", "toDecimal"];
|
|
32
|
+
/** Calendar units allowed in date arithmetic (`%d.first().toDate() + 18 years`). */
|
|
33
|
+
declare const SUPPORTED_FHIRPATH_DATE_UNITS: readonly ["years", "months", "weeks", "days"];
|
|
34
|
+
/**
|
|
35
|
+
* The variable environment an enableWhen expression is evaluated against. Each variable resolves to a
|
|
36
|
+
* collection of scalar strings: codes, free text, numbers as decimal strings, or dates as
|
|
37
|
+
* `YYYY-MM-DD` / `YYYY` (a dateTime string does not convert with `toDate()` and yields an empty
|
|
38
|
+
* collection). An empty array means the variable is unbound/absent (an empty FHIRPath
|
|
39
|
+
* collection). Every variable an expression references must be present as a key: fhirpath.js
|
|
40
|
+
* throws on an undefined environment variable.
|
|
41
|
+
*/
|
|
42
|
+
type FhirPathVariables = Record<string, string[]>;
|
|
43
|
+
/**
|
|
44
|
+
* A single conformance case: an expression, the environment and (fixed) clock it is evaluated
|
|
45
|
+
* against, and the expected result (shown or hidden). Shared verbatim between studio and phoenix so both sides
|
|
46
|
+
* agree on the supported subset and its semantics. The clock is pinned for determinism.
|
|
47
|
+
*/
|
|
48
|
+
type EnableWhenConformanceCase = {
|
|
49
|
+
description: string;
|
|
50
|
+
expression: string;
|
|
51
|
+
variables: FhirPathVariables;
|
|
52
|
+
/** Fixed value for `today()`/`now()`, ISO date (YYYY-MM-DD). */
|
|
53
|
+
now: string;
|
|
54
|
+
expected: boolean;
|
|
55
|
+
};
|
|
56
|
+
/** Extract the `%name` variables referenced by an expression (used by the fixture self-check). */
|
|
57
|
+
declare const referencedVariables: (expression: string) => string[];
|
|
58
|
+
/**
|
|
59
|
+
* Engine-free check that an expression stays inside the supported subset. Returns one human-readable
|
|
60
|
+
* violation per offending token (empty array = in subset). It is a lexical check, not a parser: it
|
|
61
|
+
* rejects unknown functions, unknown words (member access like `.code`, `$this`, `in`, `iif`),
|
|
62
|
+
* and characters the subset never uses. Well-formedness is left to the evaluator.
|
|
63
|
+
*/
|
|
64
|
+
declare const findSubsetViolations: (expression: string) => string[];
|
|
65
|
+
/**
|
|
66
|
+
* Canonical cases covering the supported subset. Every expression here is in-subset, and every
|
|
67
|
+
* template in `enable-when-conditions.ts` has at least one case here in its compiled form.
|
|
68
|
+
*/
|
|
69
|
+
declare const ENABLE_WHEN_CONFORMANCE_CASES: EnableWhenConformanceCase[];
|
|
70
|
+
/**
|
|
71
|
+
* Expressions outside the supported subset. Studio's validator must reject these; they are here so
|
|
72
|
+
* that rejection is tested against the same list phoenix refuses to evaluate. Not exhaustive.
|
|
73
|
+
*/
|
|
74
|
+
declare const OUT_OF_SUBSET_EXPRESSIONS: string[];
|
|
75
|
+
|
|
76
|
+
export { ENABLE_WHEN_CONFORMANCE_CASES as E, type FhirPathVariables as F, OUT_OF_SUBSET_EXPRESSIONS as O, SUPPORTED_FHIRPATH_DATE_UNITS as S, type EnableWhenConformanceCase as a, SUPPORTED_FHIRPATH_FUNCTIONS as b, SUPPORTED_FHIRPATH_OPERATORS as c, findSubsetViolations as f, referencedVariables as r };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-questionnaire `enableWhen`: the supported FHIRPath subset, an engine-free subset validator,
|
|
3
|
+
* and a shared conformance fixture.
|
|
4
|
+
*
|
|
5
|
+
* A cross-questionnaire or derived condition is expressed as an SDC `enableWhenExpression`
|
|
6
|
+
* (text/fhirpath) over named variables (see `questionnaire-item-variable` in constants.ts).
|
|
7
|
+
* To keep the feature testable and the authoring UI able to compile to it, phoenix only
|
|
8
|
+
* evaluates and next-research-studio only emits the closed subset declared here. Studio never
|
|
9
|
+
* writes FHIRPath by hand: it compiles structured conditions via `enable-when-conditions.ts`, whose
|
|
10
|
+
* templates are the only producer of expressions.
|
|
11
|
+
*
|
|
12
|
+
* This module is intentionally engine-free: it defines the subset and the fixture as data.
|
|
13
|
+
* The evaluator lives in `enable-when-eval.ts` (exposed via the `./fhirpath`
|
|
14
|
+
* subpath) and must satisfy `ENABLE_WHEN_CONFORMANCE_CASES`; `findSubsetViolations` must accept
|
|
15
|
+
* every in-subset expression and reject every `OUT_OF_SUBSET_EXPRESSIONS` entry. Keeping both
|
|
16
|
+
* repos pinned to this one fixture is the guard against subset drift.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Boolean, comparison and membership operators, plus collection union, allowed in an enableWhen
|
|
20
|
+
* expression. `contains` is the infix membership operator (`%coll contains 'x'`), not the string
|
|
21
|
+
* function.
|
|
22
|
+
*/
|
|
23
|
+
declare const SUPPORTED_FHIRPATH_OPERATORS: readonly ["and", "or", "contains", "=", "!=", ">", "<", ">=", "<=", "|"];
|
|
24
|
+
/**
|
|
25
|
+
* Functions allowed in an enableWhen expression. `today`/`now` read the ambient clock (device time in
|
|
26
|
+
* production, pinned via fake timers in tests). Variable values always arrive as strings, so a
|
|
27
|
+
* value must be converted before it can be compared to a number (`toInteger`/`toDecimal`) or used
|
|
28
|
+
* in date arithmetic (`toDate`); comparing a raw string variable to a number is an evaluation
|
|
29
|
+
* error, not a false.
|
|
30
|
+
*/
|
|
31
|
+
declare const SUPPORTED_FHIRPATH_FUNCTIONS: readonly ["exists", "empty", "not", "first", "today", "now", "toDate", "toInteger", "toDecimal"];
|
|
32
|
+
/** Calendar units allowed in date arithmetic (`%d.first().toDate() + 18 years`). */
|
|
33
|
+
declare const SUPPORTED_FHIRPATH_DATE_UNITS: readonly ["years", "months", "weeks", "days"];
|
|
34
|
+
/**
|
|
35
|
+
* The variable environment an enableWhen expression is evaluated against. Each variable resolves to a
|
|
36
|
+
* collection of scalar strings: codes, free text, numbers as decimal strings, or dates as
|
|
37
|
+
* `YYYY-MM-DD` / `YYYY` (a dateTime string does not convert with `toDate()` and yields an empty
|
|
38
|
+
* collection). An empty array means the variable is unbound/absent (an empty FHIRPath
|
|
39
|
+
* collection). Every variable an expression references must be present as a key: fhirpath.js
|
|
40
|
+
* throws on an undefined environment variable.
|
|
41
|
+
*/
|
|
42
|
+
type FhirPathVariables = Record<string, string[]>;
|
|
43
|
+
/**
|
|
44
|
+
* A single conformance case: an expression, the environment and (fixed) clock it is evaluated
|
|
45
|
+
* against, and the expected result (shown or hidden). Shared verbatim between studio and phoenix so both sides
|
|
46
|
+
* agree on the supported subset and its semantics. The clock is pinned for determinism.
|
|
47
|
+
*/
|
|
48
|
+
type EnableWhenConformanceCase = {
|
|
49
|
+
description: string;
|
|
50
|
+
expression: string;
|
|
51
|
+
variables: FhirPathVariables;
|
|
52
|
+
/** Fixed value for `today()`/`now()`, ISO date (YYYY-MM-DD). */
|
|
53
|
+
now: string;
|
|
54
|
+
expected: boolean;
|
|
55
|
+
};
|
|
56
|
+
/** Extract the `%name` variables referenced by an expression (used by the fixture self-check). */
|
|
57
|
+
declare const referencedVariables: (expression: string) => string[];
|
|
58
|
+
/**
|
|
59
|
+
* Engine-free check that an expression stays inside the supported subset. Returns one human-readable
|
|
60
|
+
* violation per offending token (empty array = in subset). It is a lexical check, not a parser: it
|
|
61
|
+
* rejects unknown functions, unknown words (member access like `.code`, `$this`, `in`, `iif`),
|
|
62
|
+
* and characters the subset never uses. Well-formedness is left to the evaluator.
|
|
63
|
+
*/
|
|
64
|
+
declare const findSubsetViolations: (expression: string) => string[];
|
|
65
|
+
/**
|
|
66
|
+
* Canonical cases covering the supported subset. Every expression here is in-subset, and every
|
|
67
|
+
* template in `enable-when-conditions.ts` has at least one case here in its compiled form.
|
|
68
|
+
*/
|
|
69
|
+
declare const ENABLE_WHEN_CONFORMANCE_CASES: EnableWhenConformanceCase[];
|
|
70
|
+
/**
|
|
71
|
+
* Expressions outside the supported subset. Studio's validator must reject these; they are here so
|
|
72
|
+
* that rejection is tested against the same list phoenix refuses to evaluate. Not exhaustive.
|
|
73
|
+
*/
|
|
74
|
+
declare const OUT_OF_SUBSET_EXPRESSIONS: string[];
|
|
75
|
+
|
|
76
|
+
export { ENABLE_WHEN_CONFORMANCE_CASES as E, type FhirPathVariables as F, OUT_OF_SUBSET_EXPRESSIONS as O, SUPPORTED_FHIRPATH_DATE_UNITS as S, type EnableWhenConformanceCase as a, SUPPORTED_FHIRPATH_FUNCTIONS as b, SUPPORTED_FHIRPATH_OPERATORS as c, findSubsetViolations as f, referencedVariables as r };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { F as FhirPathVariables } from './enable-when-expression-L1gQM0rv.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Evaluate an `enableWhenExpression` against a variable environment, returning whether the
|
|
5
|
+
* item should be shown. An empty or non-true result is treated as `false` (hidden until known),
|
|
6
|
+
* matching native `enableWhen` semantics. An evaluation error (malformed expression, type
|
|
7
|
+
* mismatch such as a raw string compared to a number, unbound variable) is also `false`: the
|
|
8
|
+
* fail-hidden contract must not depend on every caller validating the expression first.
|
|
9
|
+
*
|
|
10
|
+
* Variables are passed as the fhirpath.js environment and referenced in the expression as `%name`.
|
|
11
|
+
*
|
|
12
|
+
* Time: `today()`/`now()` read the ambient clock (fhirpath.js caches it for the duration of one
|
|
13
|
+
* evaluation). Tests pin it with fake timers; production uses device time.
|
|
14
|
+
*
|
|
15
|
+
* Packaging: this module imports the fhirpath.js engine (~157 KB gzipped) and is deliberately
|
|
16
|
+
* published on its own subpath (`@d4l/collect-lib/fhirpath`, see tsup.config.ts) instead of the
|
|
17
|
+
* barrel. The barrel is imported on nearly every Research Studio page, while evaluation is only
|
|
18
|
+
* needed where an expression is actually run (phoenix, and Studio's synthetic-data generator); the
|
|
19
|
+
* package declares no `sideEffects: false` (it imports polyfills), so bundlers could not drop the
|
|
20
|
+
* engine from the barrel on their own. Do not re-export it from `fhir/index.ts`.
|
|
21
|
+
*/
|
|
22
|
+
declare const evaluateEnableWhen: (expression: string, variables: FhirPathVariables) => boolean;
|
|
23
|
+
|
|
24
|
+
export { evaluateEnableWhen };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { F as FhirPathVariables } from './enable-when-expression-L1gQM0rv.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Evaluate an `enableWhenExpression` against a variable environment, returning whether the
|
|
5
|
+
* item should be shown. An empty or non-true result is treated as `false` (hidden until known),
|
|
6
|
+
* matching native `enableWhen` semantics. An evaluation error (malformed expression, type
|
|
7
|
+
* mismatch such as a raw string compared to a number, unbound variable) is also `false`: the
|
|
8
|
+
* fail-hidden contract must not depend on every caller validating the expression first.
|
|
9
|
+
*
|
|
10
|
+
* Variables are passed as the fhirpath.js environment and referenced in the expression as `%name`.
|
|
11
|
+
*
|
|
12
|
+
* Time: `today()`/`now()` read the ambient clock (fhirpath.js caches it for the duration of one
|
|
13
|
+
* evaluation). Tests pin it with fake timers; production uses device time.
|
|
14
|
+
*
|
|
15
|
+
* Packaging: this module imports the fhirpath.js engine (~157 KB gzipped) and is deliberately
|
|
16
|
+
* published on its own subpath (`@d4l/collect-lib/fhirpath`, see tsup.config.ts) instead of the
|
|
17
|
+
* barrel. The barrel is imported on nearly every Research Studio page, while evaluation is only
|
|
18
|
+
* needed where an expression is actually run (phoenix, and Studio's synthetic-data generator); the
|
|
19
|
+
* package declares no `sideEffects: false` (it imports polyfills), so bundlers could not drop the
|
|
20
|
+
* engine from the barrel on their own. Do not re-export it from `fhir/index.ts`.
|
|
21
|
+
*/
|
|
22
|
+
declare const evaluateEnableWhen: (expression: string, variables: FhirPathVariables) => boolean;
|
|
23
|
+
|
|
24
|
+
export { evaluateEnableWhen };
|
package/dist/fhirpath.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('./chunk-DDAAVRWG.js');
|
|
2
|
+
|
|
3
|
+
// src/fhir/enable-when-eval.ts
|
|
4
|
+
var _fhirpath = require('fhirpath'); var _fhirpath2 = _interopRequireDefault(_fhirpath);
|
|
5
|
+
var evaluateEnableWhen = (expression, variables) => {
|
|
6
|
+
try {
|
|
7
|
+
const result = _fhirpath2.default.evaluate({}, expression, variables);
|
|
8
|
+
return Array.isArray(result) && result[0] === true;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.evaluateEnableWhen = evaluateEnableWhen;
|
|
16
|
+
//# sourceMappingURL=fhirpath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/collect-lib/collect-lib/dist/fhirpath.js","../src/fhir/enable-when-eval.ts"],"names":[],"mappings":"AAAA,wMAA4B;AAC5B;AACA;ACFA,wFAAqB;AAsBd,IAAM,mBAAA,EAAqB,CAAC,UAAA,EAAoB,SAAA,EAAA,GAA0C;AAC/F,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,EAAS,kBAAA,CAAS,QAAA,CAAS,CAAC,CAAA,EAAG,UAAA,EAAY,SAAS,CAAA;AAC1D,IAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,MAAM,EAAA,GAAK,MAAA,CAAO,CAAC,EAAA,IAAM,IAAA;AAAA,EAChD,EAAA,MAAA,CAAQ,CAAA,EAAA;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF,CAAA;ADjBA;AACE;AACF,gDAAC","file":"/home/runner/work/collect-lib/collect-lib/dist/fhirpath.js","sourcesContent":[null,"import fhirpath from 'fhirpath';\nimport { FhirPathVariables } from './enable-when-expression';\n\n/**\n * Evaluate an `enableWhenExpression` against a variable environment, returning whether the\n * item should be shown. An empty or non-true result is treated as `false` (hidden until known),\n * matching native `enableWhen` semantics. An evaluation error (malformed expression, type\n * mismatch such as a raw string compared to a number, unbound variable) is also `false`: the\n * fail-hidden contract must not depend on every caller validating the expression first.\n *\n * Variables are passed as the fhirpath.js environment and referenced in the expression as `%name`.\n *\n * Time: `today()`/`now()` read the ambient clock (fhirpath.js caches it for the duration of one\n * evaluation). Tests pin it with fake timers; production uses device time.\n *\n * Packaging: this module imports the fhirpath.js engine (~157 KB gzipped) and is deliberately\n * published on its own subpath (`@d4l/collect-lib/fhirpath`, see tsup.config.ts) instead of the\n * barrel. The barrel is imported on nearly every Research Studio page, while evaluation is only\n * needed where an expression is actually run (phoenix, and Studio's synthetic-data generator); the\n * package declares no `sideEffects: false` (it imports polyfills), so bundlers could not drop the\n * engine from the barrel on their own. Do not re-export it from `fhir/index.ts`.\n */\nexport const evaluateEnableWhen = (expression: string, variables: FhirPathVariables): boolean => {\n try {\n const result = fhirpath.evaluate({}, expression, variables);\n return Array.isArray(result) && result[0] === true;\n } catch {\n return false;\n }\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./chunk-FJBZBVPE.mjs";
|
|
2
|
+
|
|
3
|
+
// src/fhir/enable-when-eval.ts
|
|
4
|
+
import fhirpath from "fhirpath";
|
|
5
|
+
var evaluateEnableWhen = (expression, variables) => {
|
|
6
|
+
try {
|
|
7
|
+
const result = fhirpath.evaluate({}, expression, variables);
|
|
8
|
+
return Array.isArray(result) && result[0] === true;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
evaluateEnableWhen
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=fhirpath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fhir/enable-when-eval.ts"],"sourcesContent":["import fhirpath from 'fhirpath';\nimport { FhirPathVariables } from './enable-when-expression';\n\n/**\n * Evaluate an `enableWhenExpression` against a variable environment, returning whether the\n * item should be shown. An empty or non-true result is treated as `false` (hidden until known),\n * matching native `enableWhen` semantics. An evaluation error (malformed expression, type\n * mismatch such as a raw string compared to a number, unbound variable) is also `false`: the\n * fail-hidden contract must not depend on every caller validating the expression first.\n *\n * Variables are passed as the fhirpath.js environment and referenced in the expression as `%name`.\n *\n * Time: `today()`/`now()` read the ambient clock (fhirpath.js caches it for the duration of one\n * evaluation). Tests pin it with fake timers; production uses device time.\n *\n * Packaging: this module imports the fhirpath.js engine (~157 KB gzipped) and is deliberately\n * published on its own subpath (`@d4l/collect-lib/fhirpath`, see tsup.config.ts) instead of the\n * barrel. The barrel is imported on nearly every Research Studio page, while evaluation is only\n * needed where an expression is actually run (phoenix, and Studio's synthetic-data generator); the\n * package declares no `sideEffects: false` (it imports polyfills), so bundlers could not drop the\n * engine from the barrel on their own. Do not re-export it from `fhir/index.ts`.\n */\nexport const evaluateEnableWhen = (expression: string, variables: FhirPathVariables): boolean => {\n try {\n const result = fhirpath.evaluate({}, expression, variables);\n return Array.isArray(result) && result[0] === true;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;AAAA,OAAO,cAAc;AAsBd,IAAM,qBAAqB,CAAC,YAAoB,cAA0C;AAC/F,MAAI;AACF,UAAM,SAAS,SAAS,SAAS,CAAC,GAAG,YAAY,SAAS;AAC1D,WAAO,MAAM,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM;AAAA,EAChD,SAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|