@finsys/core 1.2.0 → 1.3.1

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/dist/index.d.cts CHANGED
@@ -370,6 +370,11 @@ declare const FIELD_TYPE_DEFINITIONS: FormFieldTypeDefinitions;
370
370
  declare const DEFAULT_VALIDATOR_DEFINITIONS: FormValidatorDefinitions;
371
371
  declare function getBaseFieldSpecs(): FieldData[];
372
372
  declare function getBaseCategories(): Category[];
373
+ /**
374
+ * Returns a cached Map of base field name → FieldData.
375
+ * Keyed by each field's `name` property from the base specs.
376
+ */
377
+ declare function getBaseFieldSpecMap(): Map<string, FieldData>;
373
378
  declare function getBaseFieldNames(): string[];
374
379
 
375
- export { BASE_FIELD_SPECS, BasicFormField, type Category, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DropdownOption, type EditorValidator, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldReference, FieldType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, type PageConfig, type RHFSchemaOutput, type RHFStep, type ResolvedField, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type UnifiedFormConfig, type Validator, applyDynamicTitles, evaluateExpression, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecs, getCategoryName, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupFieldsByCategory, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
380
+ export { BASE_FIELD_SPECS, BasicFormField, type Category, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DropdownOption, type EditorValidator, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldReference, FieldType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, type PageConfig, type RHFSchemaOutput, type RHFStep, type ResolvedField, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type UnifiedFormConfig, type Validator, applyDynamicTitles, evaluateExpression, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupFieldsByCategory, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
package/dist/index.d.ts CHANGED
@@ -370,6 +370,11 @@ declare const FIELD_TYPE_DEFINITIONS: FormFieldTypeDefinitions;
370
370
  declare const DEFAULT_VALIDATOR_DEFINITIONS: FormValidatorDefinitions;
371
371
  declare function getBaseFieldSpecs(): FieldData[];
372
372
  declare function getBaseCategories(): Category[];
373
+ /**
374
+ * Returns a cached Map of base field name → FieldData.
375
+ * Keyed by each field's `name` property from the base specs.
376
+ */
377
+ declare function getBaseFieldSpecMap(): Map<string, FieldData>;
373
378
  declare function getBaseFieldNames(): string[];
374
379
 
375
- export { BASE_FIELD_SPECS, BasicFormField, type Category, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DropdownOption, type EditorValidator, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldReference, FieldType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, type PageConfig, type RHFSchemaOutput, type RHFStep, type ResolvedField, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type UnifiedFormConfig, type Validator, applyDynamicTitles, evaluateExpression, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecs, getCategoryName, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupFieldsByCategory, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
380
+ export { BASE_FIELD_SPECS, BasicFormField, type Category, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DropdownOption, type EditorValidator, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldReference, FieldType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, type PageConfig, type RHFSchemaOutput, type RHFStep, type ResolvedField, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type UnifiedFormConfig, type Validator, applyDynamicTitles, evaluateExpression, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupFieldsByCategory, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
package/dist/index.js CHANGED
@@ -15,6 +15,22 @@ function evaluateExpression(expression, data) {
15
15
  return `this['${key.trim()}']`;
16
16
  });
17
17
  jsExpression = jsExpression.replace(/(?<![<>!=])=(?![=])/g, "==");
18
+ jsExpression = jsExpression.replace(
19
+ /(this\['[^']+'\])\s+anyof\s+(\[[^\]]+\])/gi,
20
+ (_, ref, arr) => `(${arr}).includes(${ref})`
21
+ );
22
+ jsExpression = jsExpression.replace(
23
+ /(this\['[^']+'\])\s+allof\s+(\[[^\]]+\])/gi,
24
+ (_, ref, arr) => `${arr}.every(item => (${ref} || []).includes(item))`
25
+ );
26
+ jsExpression = jsExpression.replace(
27
+ /(this\['[^']+'\])\s+contains\s+'([^']+)'/gi,
28
+ (_, ref, val) => `(${ref} || []).includes('${val}')`
29
+ );
30
+ jsExpression = jsExpression.replace(
31
+ /(this\['[^']+'\])\s+notcontains\s+'([^']+)'/gi,
32
+ (_, ref, val) => `!(${ref} || []).includes('${val}')`
33
+ );
18
34
  const func = new Function(`return ${jsExpression};`);
19
35
  return !!func.call(data || {});
20
36
  } catch (e) {
@@ -8989,6 +9005,20 @@ function getBaseFieldSpecs() {
8989
9005
  function getBaseCategories() {
8990
9006
  return BASE_FIELD_SPECS.categories;
8991
9007
  }
9008
+ var cachedFieldSpecMap = null;
9009
+ function getBaseFieldSpecMap() {
9010
+ if (cachedFieldSpecMap) {
9011
+ return cachedFieldSpecMap;
9012
+ }
9013
+ const map = /* @__PURE__ */ new Map();
9014
+ for (const field of BASE_FIELD_SPECS.fields) {
9015
+ if (field.name) {
9016
+ map.set(field.name, field);
9017
+ }
9018
+ }
9019
+ cachedFieldSpecMap = map;
9020
+ return cachedFieldSpecMap;
9021
+ }
8992
9022
  var cachedFieldNames = null;
8993
9023
  function getBaseFieldNames() {
8994
9024
  if (cachedFieldNames) {
@@ -9023,6 +9053,7 @@ export {
9023
9053
  generateSurveyJson,
9024
9054
  getBaseCategories,
9025
9055
  getBaseFieldNames,
9056
+ getBaseFieldSpecMap,
9026
9057
  getBaseFieldSpecs,
9027
9058
  getCategoryName,
9028
9059
  getPastMonthLabel,