@socotra/ec-react-utils 2.21.0-next.0 → 2.21.0-next.2

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 CHANGED
@@ -62,6 +62,7 @@ Follow instructions in the `ec-react/packages/docs/README.md` file to build the
62
62
 
63
63
  | Function | Description | Returns |
64
64
  |----------|-------------|---------|
65
+ | `getAccountEvaluatedConstraintsRequest` | Creates a request payload to evaluate constraints for an account. | `AccountEvaluateConstraintsRequest` |
65
66
  | `extractElementByLocator` | Extracts the first element from a policy, quote, or transaction segment that matches the specified locator. | `Element` or `undefined` |
66
67
  | `extractElementByType` | Extracts the first element from a policy, quote, or transaction segment that matches the specified type. | `Element` or `undefined` |
67
68
  | `extractElementsByType` | Extracts all elements from a policy, quote, or transaction segment that match the specified type. | `Element[]` |
@@ -72,6 +73,7 @@ Follow instructions in the `ec-react/packages/docs/README.md` file to build the
72
73
  | `extractElementsFromTransactionSegment` | Extracts all elements from a transaction segment's exposures. | `Element[]` |
73
74
  | `extractProductDataModel` | Extracts the data model for a specific product from a policy or quote. | `object` or `undefined` |
74
75
  | `extractProductElements` | Extracts all elements associated with a product from a policy or quote. | `Element[]` |
76
+ | `shouldEvaluateConstraints` | Checks if the constraints should be evaluated based on the original and new data. | `boolean` |
75
77
 
76
78
  ### Default Value Getters
77
79
 
package/dist/index.d.ts CHANGED
@@ -1,16 +1,19 @@
1
1
  import { AccountConfigRecord } from '@socotra/ec-react-schemas';
2
2
  import { AccountCreateRequest } from '@socotra/ec-react-schemas';
3
+ import { AccountEvaluateConstraintsRequest } from '@socotra/ec-react-schemas';
3
4
  import { AccountResponse } from '@socotra/ec-react-schemas';
4
5
  import { AccountUpdateRequest } from '@socotra/ec-react-schemas';
5
- import { ConstraintEvaluationResponse } from '@socotra/ec-react-schemas';
6
6
  import { CoverageTermsConfigRecord } from '@socotra/ec-react-schemas';
7
7
  import { DataFieldValue } from '@socotra/ec-react-schemas';
8
8
  import { DataModel } from '@socotra/ec-react-schemas';
9
9
  import { DataTypeConfigRecord } from '@socotra/ec-react-schemas';
10
+ import { DependencyMapResponse } from '@socotra/ec-react-schemas';
10
11
  import { ElementConfig } from '@socotra/ec-react-schemas';
11
12
  import { ElementRequest } from '@socotra/ec-react-schemas';
12
13
  import { ElementResponse } from '@socotra/ec-react-schemas';
13
14
  import { ErrorObject } from 'ajv';
15
+ import { EvaluateConstraintsRequest } from '@socotra/ec-react-schemas';
16
+ import { EvaluateConstraintsResponse } from '@socotra/ec-react-schemas';
14
17
  import { FieldConfigRecord } from '@socotra/ec-react-schemas';
15
18
  import { JsonSchema7 } from '@jsonforms/core';
16
19
  import { ModifyChangeInstructionCreateRequest } from '@socotra/ec-react-schemas';
@@ -19,7 +22,6 @@ import { PolicyResponse } from '@socotra/ec-react-schemas';
19
22
  import { PrimitiveValue } from '@socotra/ec-react-schemas';
20
23
  import { ProductConfig } from '@socotra/ec-react-schemas';
21
24
  import { Quantifiers } from '@socotra/ec-react-schemas';
22
- import { QuoteDependencyMapResponse } from '@socotra/ec-react-schemas';
23
25
  import { QuoteRequest } from '@socotra/ec-react-schemas';
24
26
  import { QuoteResponse } from '@socotra/ec-react-schemas';
25
27
  import { SegmentResponse } from '@socotra/ec-react-schemas';
@@ -93,8 +95,8 @@ declare interface DataModelToJsonSchemaProps {
93
95
  data: FieldConfigRecord;
94
96
  timezone?: string;
95
97
  dataTypes?: DataTypeConfigRecord;
96
- evaluatedConstraints?: ConstraintEvaluationResponse;
97
- constraintDependencyMap?: QuoteDependencyMapResponse;
98
+ evaluatedConstraints?: EvaluateConstraintsResponse;
99
+ constraintDependencyMap?: DependencyMapResponse;
98
100
  ignoreConstraints?: boolean;
99
101
  scope: Array<'P' | 'Q' | 'QQ'>;
100
102
  rootDisplayName?: string;
@@ -304,6 +306,12 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
304
306
  contents: string[];
305
307
  }) => ProductElementMap;
306
308
 
309
+ export declare const getAccountEvaluatedConstraintsRequest: ({ dependencyMap, locator, data, }: {
310
+ dependencyMap: DependencyMapResponse;
311
+ data: any;
312
+ locator: string;
313
+ }) => AccountEvaluateConstraintsRequest;
314
+
307
315
  export declare function getAccountRequest(params: {
308
316
  data: {
309
317
  [key: string]: any;
@@ -498,10 +506,10 @@ export declare const getElementTransactionUpdateRequestFromFormData: (params: Tr
498
506
  };
499
507
 
500
508
  export declare const getEvaluatedConstraintsRequest: ({ dependencyMap, locator, data, }: {
501
- dependencyMap: QuoteDependencyMapResponse;
509
+ dependencyMap: DependencyMapResponse;
502
510
  data: any;
503
511
  locator: string;
504
- }) => Record<string, Record<string, Record<string, string | Record<string, string>>>>;
512
+ }) => EvaluateConstraintsRequest;
505
513
 
506
514
  export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ data, transactionSnapshot, staticLocator, }: TransactionFormData_2) => {
507
515
  action: "modify";
@@ -536,7 +544,7 @@ export declare const getQuoteRequest: (params: QuoteFormData) => QuoteRequest;
536
544
  */
537
545
  export declare function getRemoveDataFieldValues(originalObj: AnyObject, modifiedObj: AnyObject): AnyObject;
538
546
 
539
- export declare const getUpdatedDataFromConstraints: (newData: Record<string, PrimitiveValue>, evaluatedConstraintMap: ConstraintEvaluationResponse | undefined, elementLocator: string) => Record<string, PrimitiveValue>;
547
+ export declare const getUpdatedDataFromConstraints: (newData: Record<string, PrimitiveValue>, evaluatedConstraintMap: EvaluateConstraintsResponse | undefined, elementLocator: string) => Record<string, PrimitiveValue>;
540
548
 
541
549
  export declare const parseToPrimitive: (str: string) => any;
542
550
 
@@ -587,6 +595,8 @@ export declare type QuoteRequestAdvancedFields = z.infer<typeof advancedFieldSch
587
595
  */
588
596
  export declare type QuoteRequestDefaultFields = z.infer<typeof defaultFieldSchema>;
589
597
 
598
+ export declare const shouldEvaluateConstraints: (data: Record<string, unknown>, localData: Record<string, unknown>, constraintFieldNames: string[]) => boolean;
599
+
590
600
  /**
591
601
  * The function `splitInputAndQuantifier` takes a string input, removes certain characters from it, and
592
602
  * extracts a quantifier if present.