@socotra/ec-react-utils 2.6.3-next.1 → 2.6.3-next.3

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.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AccountResponse } from '@socotra/ec-react-schemas';
2
+ import { ConstraintEvaluationResponse } from '@socotra/ec-react-schemas';
2
3
  import { CoverageTermsConfigRecord } from '@socotra/ec-react-schemas';
3
4
  import { DataModel } from '@socotra/ec-react-schemas';
4
5
  import { DataTypeConfigRecord } from '@socotra/ec-react-schemas';
@@ -11,6 +12,7 @@ import { ModifyChangeInstructionCreateRequest } from '@socotra/ec-react-schemas'
11
12
  import { ParamsChangeInstructionCreateRequest } from '@socotra/ec-react-schemas';
12
13
  import { ProductConfig } from '@socotra/ec-react-schemas';
13
14
  import { Quantifiers } from '@socotra/ec-react-schemas';
15
+ import { QuoteDependencyMapResponse } from '@socotra/ec-react-schemas';
14
16
  import { QuoteRequest } from '@socotra/ec-react-schemas';
15
17
  import { QuoteResponse } from '@socotra/ec-react-schemas';
16
18
  import { SegmentResponse } from '@socotra/ec-react-schemas';
@@ -34,6 +36,8 @@ export declare const dataModelToJSONSchema: (args: DataModelToJsonSchemaProps) =
34
36
  declare interface DataModelToJsonSchemaProps {
35
37
  data: FieldConfigRecord;
36
38
  dataTypes?: DataTypeConfigRecord;
39
+ evaluatedConstraints?: ConstraintEvaluationResponse;
40
+ constraintDependencyMap?: QuoteDependencyMapResponse;
37
41
  scope: Array<'P' | 'Q' | 'QQ'>;
38
42
  rootDisplayName?: string;
39
43
  account?: AccountResponse;
@@ -41,6 +45,18 @@ declare interface DataModelToJsonSchemaProps {
41
45
  element?: ElementResponse;
42
46
  }
43
47
 
48
+ /**
49
+ * The function `extractElementFromElement takes a `QuoteResponse`, `SegmentResponse` or `ElementResponse` object and an element locator string,
50
+ * and returns the element with the matching locator from the quote or its nested elements.
51
+ * @param {QuoteResponse} quote - The `quote` parameter is of type `QuoteResponse`, which is an object
52
+ * containing information about a quote.
53
+ * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
54
+ * locator of the element you want to extract from the `quote` object.
55
+ * @returns The function `extractElementByLocator` returns the element from the response object
56
+ * that matches the provided `elementLocator`.
57
+ */
58
+ export declare const extractElementByLocator: <T extends ElementResponse>(response: QuoteResponse | SegmentResponse | ElementResponse, elementLocator: string) => T | null;
59
+
44
60
  /**
45
61
  * The function `extractElementDataModelFromQuote` extracts element data model based on a given quote, data
46
62
  * model, and element locator.
@@ -54,7 +70,7 @@ export declare const extractElementDataModelFromQuote: ({ dataModel, quote, elem
54
70
  quote: QuoteResponse;
55
71
  dataModel: DataModel;
56
72
  elementLocator: string;
57
- }) => ElementConfig | false;
73
+ }) => ElementConfig | null;
58
74
 
59
75
  /**
60
76
  * The function `extractElementDataModelFromSegment` extracts element data model based on a given segment, data
@@ -69,7 +85,7 @@ export declare const extractElementDataModelFromSegment: ({ dataModel, segment,
69
85
  segment: SegmentResponse;
70
86
  dataModel: DataModel;
71
87
  elementLocator: string;
72
- }) => ElementConfig | false;
88
+ }) => ElementConfig | null;
73
89
 
74
90
  /**
75
91
  * The function `extractElementDataModelFromType` extracts element data model given a data model and
@@ -79,112 +95,28 @@ export declare const extractElementDataModelFromSegment: ({ dataModel, segment,
79
95
  * @returns The function `extractElementDataModelFromType` returns either an `ElementConfig` object or `false`
80
96
  * based on the provided parameters and data model.
81
97
  */
82
- export declare const extractElementDataModelFromType: ({ dataModel, elementType, }: {
83
- dataModel: DataModel;
84
- elementType: string;
85
- }) => ElementConfig | false;
86
-
87
- /**
88
- * The function `extractElementFromQuote` takes a `QuoteResponse` object and an element locator string,
89
- * and returns the element with the matching locator from the quote or its nested elements.
90
- * @param {QuoteResponse} quote - The `quote` parameter is of type `QuoteResponse`, which is an object
91
- * containing information about a quote.
92
- * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
93
- * locator of the element you want to extract from the `quote` object.
94
- * @returns The function `extractElementFromQuote` returns the element from the `QuoteResponse` object
95
- * that matches the provided `elementLocator`.
96
- */
97
- export declare const extractElementFromQuote: (quote: QuoteResponse, elementLocator: string) => false | ({
98
- locator: string;
99
- type: string;
100
- staticLocator: string;
101
- data?: Record<string, any> | undefined;
102
- coverageTerms?: Record<string, string> | undefined;
103
- parentLocator?: string | undefined;
104
- rootLocator?: string | undefined;
105
- tenantLocator?: string | undefined;
106
- originalEffectiveTime?: string | undefined;
107
- } & {
108
- elements?: ({
109
- locator: string;
110
- type: string;
111
- staticLocator: string;
112
- data?: Record<string, any> | undefined;
113
- coverageTerms?: Record<string, string> | undefined;
114
- parentLocator?: string | undefined;
115
- rootLocator?: string | undefined;
116
- tenantLocator?: string | undefined;
117
- originalEffectiveTime?: string | undefined;
118
- } & any)[];
119
- });
120
-
121
- /**
122
- * The function `extractElementFromSegment` takes a `SegmentResponse` object and an element locator string,
123
- * and returns the element with the matching locator from the segment or its nested elements.
124
- * @param {SegmentResponse} segment - The `segment` parameter is of type `SegmentResponse`, which is an object
125
- * containing information about a segment.
126
- * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
127
- * locator of the element you want to extract from the `segment` object.
128
- * @returns The function `extractElementFromSegment` returns the element from the `SegmentResponse` object
129
- * that matches the provided `elementLocator`.
130
- */
131
- export declare const extractElementFromSegment: (segment: SegmentResponse, elementLocator: string) => false | ({
132
- locator: string;
133
- type: string;
134
- staticLocator: string;
135
- data?: Record<string, any> | undefined;
136
- coverageTerms?: Record<string, string> | undefined;
137
- parentLocator?: string | undefined;
138
- rootLocator?: string | undefined;
139
- tenantLocator?: string | undefined;
140
- originalEffectiveTime?: string | undefined;
141
- } & {
142
- elements?: ({
143
- locator: string;
144
- type: string;
145
- staticLocator: string;
146
- data?: Record<string, any> | undefined;
147
- coverageTerms?: Record<string, string> | undefined;
148
- parentLocator?: string | undefined;
149
- rootLocator?: string | undefined;
150
- tenantLocator?: string | undefined;
151
- originalEffectiveTime?: string | undefined;
152
- } & any)[];
153
- });
154
-
155
- /**
156
- * The function `extractElementFromTransactionSegment` takes a `SegmentResponse` object and an element locator string,
157
- * and returns the element with the matching locator from the segment or its nested elements.
158
- * @param {SegmentResponse} transactionSegment - The `transactionSegment` parameter is of type `SegmentResponse`, which is an object
159
- * containing information about a transaction.
160
- * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
161
- * locator of the element you want to extract from the `transactionSegment` object.
162
- * @returns The function `extractElementFromTransactionSegment` returns the element from the `SegmentResponse` object
163
- * that matches the provided `elementLocator`.
164
- */
165
- export declare const extractElementFromTransactionSegment: (transactionSegment: SegmentResponse, elementLocator: string) => false | ({
166
- locator: string;
167
- type: string;
168
- staticLocator: string;
169
- data?: Record<string, any> | undefined;
170
- coverageTerms?: Record<string, string> | undefined;
171
- parentLocator?: string | undefined;
172
- rootLocator?: string | undefined;
173
- tenantLocator?: string | undefined;
174
- originalEffectiveTime?: string | undefined;
175
- } & {
176
- elements?: ({
177
- locator: string;
178
- type: string;
179
- staticLocator: string;
180
- data?: Record<string, any> | undefined;
181
- coverageTerms?: Record<string, string> | undefined;
182
- parentLocator?: string | undefined;
183
- rootLocator?: string | undefined;
184
- tenantLocator?: string | undefined;
185
- originalEffectiveTime?: string | undefined;
186
- } & any)[];
187
- });
98
+ export declare const extractElementDataModelFromType: ExtractElementDataModelFromTypeInterface;
99
+
100
+ declare interface ExtractElementDataModelFromTypeInterface {
101
+ (props: {
102
+ dataModel: DataModel;
103
+ elementType: string;
104
+ resultType?: 'value';
105
+ }): ElementConfig | null;
106
+ (props: {
107
+ dataModel: DataModel;
108
+ elementType: string;
109
+ resultType?: 'all';
110
+ }): {
111
+ value: ElementConfig;
112
+ path: string;
113
+ } | null;
114
+ (props: {
115
+ dataModel: DataModel;
116
+ elementType: string;
117
+ resultType?: 'path';
118
+ }): string | null;
119
+ }
188
120
 
189
121
  export declare const extractElementsFromQuote: (elements: Array<ElementResponse>, elementType: string) => ({
190
122
  locator: string;
@@ -266,14 +198,6 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
266
198
  contents: string[];
267
199
  }) => ProductElementMap;
268
200
 
269
- /**
270
- * `findElementInElementArray` is a utility function that takes an array of `ElementResponse` objects and an element locator string,
271
- * @param elements - The `elements` parameter is an array of `ElementResponse` objects.
272
- * @param elementLocator - The `elementLocator` parameter is a string that represents the locator of the element you want to extract from the `elements` array.
273
- * @returns
274
- */
275
- export declare const findElementInElementsArray: (elements: ElementResponse[], elementLocator: string) => ElementResponse | false;
276
-
277
201
  /**
278
202
  * The `getCoverageTermsDefaultValues` function extracts default coverage terms values from a
279
203
  * `CoverageTermsConfigRecord` object and sets them based on certain conditions.
@@ -362,6 +286,14 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
362
286
  coverageTerms: Record<string, string>;
363
287
  };
364
288
 
289
+ /**
290
+ * The function `getElementNameByType` returns the element name based on the element type and suffix.
291
+ * @param - - `elementType`: A string containing the element type.
292
+ * @param - - `suffix`: A string containing the suffix.
293
+ * @returns The function `getElementNameByType` returns the element name.
294
+ */
295
+ export declare const getElementNameByType: (elementType: string) => string;
296
+
365
297
  export declare const getElementTransactionUpdateRequestFromFormData: ({ data, elementResponse, locator, }: TransactionFormData) => {
366
298
  locator: string;
367
299
  removeCoverageTerms?: Record<string, unknown> | undefined;
@@ -370,6 +302,12 @@ export declare const getElementTransactionUpdateRequestFromFormData: ({ data, el
370
302
  setData?: Record<string, unknown> | undefined;
371
303
  };
372
304
 
305
+ export declare const getEvaluatedConstraintsRequest: ({ dependencyMap, locator, data, }: {
306
+ dependencyMap: QuoteDependencyMapResponse;
307
+ data: any;
308
+ locator: string;
309
+ }) => Record<string, Record<string, Record<string, string | Record<string, string>>>>;
310
+
373
311
  export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ data, transactionSnapshot, staticLocator, }: TransactionFormData_2) => {
374
312
  staticLocator: string;
375
313
  action: "modify";