@openmrs/esm-form-engine-lib 4.2.2-pre.2497 → 4.2.2-pre.2505

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.
@@ -0,0 +1,22 @@
1
+ // Module-level cache of resolved registry items. Lives in its own module (rather
2
+ // than registry.ts) so that test utilities can clear it without importing the full
3
+ // registry module graph, and without expanding the public API surface (src/index.ts
4
+ // re-exports everything from registry.ts).
5
+ export const registryCache = {
6
+ validators: {},
7
+ controls: {},
8
+ fieldValueAdapters: {},
9
+ postSubmissionActions: {},
10
+ dataSources: {},
11
+ formSchemaTransformers: {}
12
+ };
13
+ /**
14
+ * Empties every section of the registry cache in place. Intended for test isolation;
15
+ * production code never invalidates the cache.
16
+ */ export function clearRegistryCache() {
17
+ Object.values(registryCache).forEach((section)=>{
18
+ Object.keys(section).forEach((key)=>{
19
+ delete section[key];
20
+ });
21
+ });
22
+ }
@@ -8,14 +8,7 @@ import { inbuiltPostSubmissionActions } from "./inbuilt-components/InbuiltPostSu
8
8
  import { inbuiltFormTransformers } from "./inbuilt-components/inbuiltTransformers.js";
9
9
  import { inbuiltFieldValueAdapters } from "./inbuilt-components/inbuiltFieldValueAdapters.js";
10
10
  import { hasRendering } from "../utils/common-utils.js";
11
- const registryCache = {
12
- validators: {},
13
- controls: {},
14
- fieldValueAdapters: {},
15
- postSubmissionActions: {},
16
- dataSources: {},
17
- formSchemaTransformers: {}
18
- };
11
+ import { registryCache } from "./registry-cache.js";
19
12
  // Registers
20
13
  export function registerControl(registration) {
21
14
  getFormsStore().controls.push(registration);
@@ -4,7 +4,7 @@ declare class PageObserver {
4
4
  private pagesWithErrorsSubject;
5
5
  private activePagesSubject;
6
6
  private evaluatedPagesVisibilitySubject;
7
- setEvaluatedPagesVisibility(evaluatedPagesVisibility: boolean): void;
7
+ setEvaluatedPagesVisibility(evaluatedPagesVisibility: boolean | null): void;
8
8
  updateScrollablePages(newPages: Array<FormPage>): void;
9
9
  updatePagesWithErrors(newErrors: string[]): void;
10
10
  addActivePage(pageId: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"page-observer.d.ts","sourceRoot":"","sources":["../../../../src/components/sidebar/page-observer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,cAAM,YAAY;IAChB,OAAO,CAAC,sBAAsB,CAA4C;IAC1E,OAAO,CAAC,sBAAsB,CAA+C;IAC7E,OAAO,CAAC,kBAAkB,CAA+C;IACzE,OAAO,CAAC,+BAA+B,CAAsC;IAE7E,2BAA2B,CAAC,wBAAwB,EAAE,OAAO;IAI7D,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;IAI/C,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE;IAIzC,aAAa,CAAC,MAAM,EAAE,MAAM;IAM5B,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAMjC,wBAAwB;IAIxB,4BAA4B;IAI5B,4BAA4B;IAI5B,qCAAqC;IAIrC,KAAK;CAMN;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
1
+ {"version":3,"file":"page-observer.d.ts","sourceRoot":"","sources":["../../../../src/components/sidebar/page-observer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,cAAM,YAAY;IAChB,OAAO,CAAC,sBAAsB,CAA4C;IAC1E,OAAO,CAAC,sBAAsB,CAA+C;IAC7E,OAAO,CAAC,kBAAkB,CAA+C;IACzE,OAAO,CAAC,+BAA+B,CAA6C;IAEpF,2BAA2B,CAAC,wBAAwB,EAAE,OAAO,GAAG,IAAI;IAIpE,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;IAI/C,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE;IAIzC,aAAa,CAAC,MAAM,EAAE,MAAM;IAM5B,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAMjC,wBAAwB;IAIxB,4BAA4B;IAI5B,4BAA4B;IAI5B,qCAAqC;IAIrC,KAAK;CAMN;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
@@ -6,6 +6,7 @@ export interface FormContextProps extends FormProcessorContextProps {
6
6
  methods: UseFormReturn<any>;
7
7
  workspaceLayout: 'minimized' | 'maximized';
8
8
  isSubmitting?: boolean;
9
+ invalidFields?: FormField[];
9
10
  deletedFields: FormField[];
10
11
  getFormField?: (field: string) => FormField;
11
12
  addFormField?: (field: FormField) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"form-provider.d.ts","sourceRoot":"","sources":["../../../src/provider/form-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,WAAW,gBAAiB,SAAQ,yBAAyB;IACjE,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5B,eAAe,EAAE,WAAW,GAAG,WAAW,CAAC;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,SAAS,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC7C,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;I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IAC1C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC7C,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,iCAA+D,CAAC;AAExF,eAAO,MAAM,YAAY,GAAI,wCAAwC,iBAAiB,sBAErF,CAAC;AAEF,eAAO,MAAM,sBAAsB,wBAOlC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type ComponentType } from 'react';
2
+ import { type DataSource, type FormFieldInputProps, type FormFieldValidator, type FormFieldValueAdapter, type FormSchemaTransformer, type PostSubmissionAction } from '../types';
3
+ interface FormRegistryCache {
4
+ validators: Record<string, FormFieldValidator>;
5
+ controls: Record<string, ComponentType<FormFieldInputProps>>;
6
+ fieldValueAdapters: Record<string, FormFieldValueAdapter>;
7
+ postSubmissionActions: Record<string, PostSubmissionAction>;
8
+ dataSources: Record<string, DataSource<any>>;
9
+ formSchemaTransformers: Record<string, FormSchemaTransformer>;
10
+ }
11
+ export declare const registryCache: FormRegistryCache;
12
+ /**
13
+ * Empties every section of the registry cache in place. Intended for test isolation;
14
+ * production code never invalidates the cache.
15
+ */
16
+ export declare function clearRegistryCache(): void;
17
+ export {};
18
+ //# sourceMappingURL=registry-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-cache.d.ts","sourceRoot":"","sources":["../../../src/registry/registry-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAElB,UAAU,iBAAiB;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC7D,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC1D,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC5D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAC/D;AAMD,eAAO,MAAM,aAAa,EAAE,iBAO3B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,SAMjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAYlB;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAE7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE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CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,QAElE;AAED,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,qBAAqB,CAAC,qBAAqB,CAAC,QAUxG;AAID;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,oEAgB5D;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,SAAS,oEAW9D;AAED,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAcjG;AAED,wBAAsB,mCAAmC,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAyB5F;AAED,wBAAsB,iCAAiC,CAAC,QAAQ,EAAE,MAAM,iCA6BvE;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAatF;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAqBpF;AAED,wBAAgB,8BAA8B,6BAE7C"}
@@ -0,0 +1,2 @@
1
+ export declare const astCache: Map<number, import("jsep").Expression>;
2
+ //# sourceMappingURL=ast-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-cache.d.ts","sourceRoot":"","sources":["../../../src/utils/ast-cache.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,wCAAgD,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type OpenmrsEncounter, type FormField, type FormPage, type FormSection } from '../types';
2
+ import { astCache } from './ast-cache';
2
3
  import { compile, type DefaultEvaluateReturnType, type Visit } from '@openmrs/esm-framework';
3
4
  export interface FormNode {
4
5
  value: FormPage | FormSection | FormField;
@@ -12,7 +13,7 @@ export interface ExpressionContext {
12
13
  visit?: Visit;
13
14
  }
14
15
  export type EvaluateReturnType = DefaultEvaluateReturnType | Record<string, any>;
15
- export declare const astCache: Map<any, any>;
16
+ export { astCache };
16
17
  export declare function evaluateExpression(expression: string, node: FormNode, fields: Array<FormField>, fieldValues: Record<string, any>, context: ExpressionContext): any;
17
18
  export declare function evaluateAsyncExpression(expression: string, node: FormNode, fields: Array<FormField>, fieldValues: Record<string, any>, context: ExpressionContext): Promise<any>;
18
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"expression-runner.d.ts","sourceRoot":"","sources":["../../../src/utils/expression-runner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAGlG,OAAO,EACL,OAAO,EACP,KAAK,yBAAyB,EAK9B,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;IAC1C,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC;IAClD,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;IACb,iBAAiB,CAAC,EAAE,gBAAgB,CAAC;IACrC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,kBAAkB,GAAG,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEjF,eAAO,MAAM,QAAQ,eAAY,CAAC;AAclC,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,EACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,OAAO,EAAE,iBAAiB,GACzB,GAAG,CAaL;AAED,wBA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kB,CAChC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,EACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,OAAO,EAAE,iBAAiB,GACzB,GAAG,CAaL;AAED,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,EACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,GAAG,CAAC,CAkBd;AA+DD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,EACtC,SAAS,EAAE,QAAQ,EACnB,SAAS,EAAE,SAAS,EAAE,QAUvB"}
@@ -0,0 +1,5 @@
1
+ // Cache of compiled expression ASTs keyed by a hash of the expression source.
2
+ // Lives in its own module (rather than expression-runner.ts) so that test utilities
3
+ // can clear it without importing the expression runner's full module graph
4
+ // (which reaches the registry and, through it, every inbuilt control).
5
+ export const astCache = new Map();
@@ -2,8 +2,9 @@ import { getRegisteredExpressionHelpers } from "../registry/registry.js";
2
2
  import { isEmpty } from "lodash-es";
3
3
  import { CommonExpressionHelpers, registerDependency, simpleHash } from "./common-expression-helpers.js";
4
4
  import { HistoricalDataSourceService } from "../datasources/historical-data-source.js";
5
+ import { astCache } from "./ast-cache.js";
5
6
  import { compile, evaluateAsType, evaluateAsTypeAsync, extractVariableNames } from "@openmrs/esm-framework";
6
- export const astCache = new Map();
7
+ export { astCache };
7
8
  function typePredicate(result) {
8
9
  return typeof result === 'string' || typeof result === 'number' || typeof result === 'boolean' || typeof result === 'undefined' || typeof result === 'object' || // Support for arbitrary objects
9
10
  result === null || result === undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-form-engine-lib",
3
- "version": "4.2.2-pre.2497",
3
+ "version": "4.2.2-pre.2505",
4
4
  "description": "React Form Engine for O3",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -10,6 +10,7 @@
10
10
  "src",
11
11
  "!src/**/*.test.*",
12
12
  "!src/utils/test-utils.ts",
13
+ "!src/test-support",
13
14
  "!src/zscore-tests"
14
15
  ],
15
16
  "license": "MIT",
@@ -20,7 +21,7 @@
20
21
  "test": "cross-env TZ=UTC vitest run --passWithNoTests",
21
22
  "test:watch": "cross-env TZ=UTC vitest watch",
22
23
  "typescript": "tsc",
23
- "build": "rimraf dist && concurrently \"swc --copy-files --ignore '**/*.test.*' --ignore '**/setup-tests.*' --ignore '**/test-utils.*' src -d dist\" \"tsc --project tsconfig.build.json\"",
24
+ "build": "rimraf dist && concurrently \"swc --copy-files --ignore '**/*.test.*' --ignore '**/setup-tests.*' --ignore '**/test-utils.*' --ignore '**/test-support/**' src -d dist\" \"tsc --project tsconfig.build.json\"",
24
25
  "coverage": "yarn test --coverage",
25
26
  "prepare": "husky install",
26
27
  "extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.ts' --config './tools/i18next-parser.config.js'"
@@ -5,9 +5,9 @@ class PageObserver {
5
5
  private scrollablePagesSubject = new BehaviorSubject<Array<FormPage>>([]);
6
6
  private pagesWithErrorsSubject = new BehaviorSubject<Set<string>>(new Set());
7
7
  private activePagesSubject = new BehaviorSubject<Set<string>>(new Set());
8
- private evaluatedPagesVisibilitySubject = new BehaviorSubject<boolean>(null);
8
+ private evaluatedPagesVisibilitySubject = new BehaviorSubject<boolean | null>(null);
9
9
 
10
- setEvaluatedPagesVisibility(evaluatedPagesVisibility: boolean) {
10
+ setEvaluatedPagesVisibility(evaluatedPagesVisibility: boolean | null) {
11
11
  this.evaluatedPagesVisibilitySubject.next(evaluatedPagesVisibility);
12
12
  }
13
13
 
@@ -7,6 +7,7 @@ export interface FormContextProps extends FormProcessorContextProps {
7
7
  methods: UseFormReturn<any>;
8
8
  workspaceLayout: 'minimized' | 'maximized';
9
9
  isSubmitting?: boolean;
10
+ invalidFields?: FormField[];
10
11
  deletedFields: FormField[];
11
12
  getFormField?: (field: string) => FormField;
12
13
  addFormField?: (field: FormField) => void;
@@ -0,0 +1,43 @@
1
+ import { type ComponentType } from 'react';
2
+ import {
3
+ type DataSource,
4
+ type FormFieldInputProps,
5
+ type FormFieldValidator,
6
+ type FormFieldValueAdapter,
7
+ type FormSchemaTransformer,
8
+ type PostSubmissionAction,
9
+ } from '../types';
10
+
11
+ interface FormRegistryCache {
12
+ validators: Record<string, FormFieldValidator>;
13
+ controls: Record<string, ComponentType<FormFieldInputProps>>;
14
+ fieldValueAdapters: Record<string, FormFieldValueAdapter>;
15
+ postSubmissionActions: Record<string, PostSubmissionAction>;
16
+ dataSources: Record<string, DataSource<any>>;
17
+ formSchemaTransformers: Record<string, FormSchemaTransformer>;
18
+ }
19
+
20
+ // Module-level cache of resolved registry items. Lives in its own module (rather
21
+ // than registry.ts) so that test utilities can clear it without importing the full
22
+ // registry module graph, and without expanding the public API surface (src/index.ts
23
+ // re-exports everything from registry.ts).
24
+ export const registryCache: FormRegistryCache = {
25
+ validators: {},
26
+ controls: {},
27
+ fieldValueAdapters: {},
28
+ postSubmissionActions: {},
29
+ dataSources: {},
30
+ formSchemaTransformers: {},
31
+ };
32
+
33
+ /**
34
+ * Empties every section of the registry cache in place. Intended for test isolation;
35
+ * production code never invalidates the cache.
36
+ */
37
+ export function clearRegistryCache() {
38
+ Object.values(registryCache).forEach((section: Record<string, unknown>) => {
39
+ Object.keys(section).forEach((key) => {
40
+ delete section[key];
41
+ });
42
+ });
43
+ }
@@ -17,6 +17,7 @@ import { inbuiltPostSubmissionActions } from './inbuilt-components/InbuiltPostSu
17
17
  import { inbuiltFormTransformers } from './inbuilt-components/inbuiltTransformers';
18
18
  import { inbuiltFieldValueAdapters } from './inbuilt-components/inbuiltFieldValueAdapters';
19
19
  import { hasRendering } from '../utils/common-utils';
20
+ import { registryCache } from './registry-cache';
20
21
 
21
22
  /**
22
23
  * @internal
@@ -56,24 +57,6 @@ export interface FormsRegistryStoreState {
56
57
  formSchemaTransformers: ComponentRegistration<FormSchemaTransformer>[];
57
58
  }
58
59
 
59
- interface FormRegistryCache {
60
- validators: Record<string, FormFieldValidator>;
61
- controls: Record<string, React.ComponentType<FormFieldInputProps>>;
62
- fieldValueAdapters: Record<string, FormFieldValueAdapter>;
63
- postSubmissionActions: Record<string, PostSubmissionAction>;
64
- dataSources: Record<string, DataSource<any>>;
65
- formSchemaTransformers: Record<string, FormSchemaTransformer>;
66
- }
67
-
68
- const registryCache: FormRegistryCache = {
69
- validators: {},
70
- controls: {},
71
- fieldValueAdapters: {},
72
- postSubmissionActions: {},
73
- dataSources: {},
74
- formSchemaTransformers: {},
75
- };
76
-
77
60
  // Registers
78
61
 
79
62
  export function registerControl(registration: CustomControlRegistration) {
@@ -0,0 +1,7 @@
1
+ import { type compile } from '@openmrs/esm-framework';
2
+
3
+ // Cache of compiled expression ASTs keyed by a hash of the expression source.
4
+ // Lives in its own module (rather than expression-runner.ts) so that test utilities
5
+ // can clear it without importing the expression runner's full module graph
6
+ // (which reaches the registry and, through it, every inbuilt control).
7
+ export const astCache = new Map<number, ReturnType<typeof compile>>();
@@ -3,6 +3,7 @@ import { isEmpty } from 'lodash-es';
3
3
  import { type OpenmrsEncounter, type FormField, type FormPage, type FormSection } from '../types';
4
4
  import { CommonExpressionHelpers, registerDependency, simpleHash } from './common-expression-helpers';
5
5
  import { HistoricalDataSourceService } from '../datasources/historical-data-source';
6
+ import { astCache } from './ast-cache';
6
7
  import {
7
8
  compile,
8
9
  type DefaultEvaluateReturnType,
@@ -28,7 +29,7 @@ export interface ExpressionContext {
28
29
 
29
30
  export type EvaluateReturnType = DefaultEvaluateReturnType | Record<string, any>;
30
31
 
31
- export const astCache = new Map();
32
+ export { astCache };
32
33
 
33
34
  function typePredicate(result: unknown): result is EvaluateReturnType {
34
35
  return (