@socotra/ec-react-utils 2.5.1-next.13 → 2.5.1-next.14

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
@@ -41,16 +41,31 @@ declare interface DataModelToJsonSchemaProps {
41
41
  }
42
42
 
43
43
  /**
44
- * The function `extractElementDataModel` extracts element data model based on a given quote, data
44
+ * The function `extractElementDataModelFromQuote` extracts element data model based on a given quote, data
45
45
  * model, and element locator.
46
46
  * @param - - `quote`: A QuoteResponse object containing information about a quote.
47
47
  * @param - - `dataModel`: A DataModel object containing information about a data model.
48
48
  * @param - - `elementLocator`: A string containing the element locator.
49
- * @returns The function `extractElementDataModel` returns either an `ElementConfig` object or `false`
49
+ * @returns The function `extractElementDataModelFromQuote` returns either an `ElementConfig` object or `false`
50
50
  * based on the provided parameters and data model.
51
51
  */
52
- export declare const extractElementDataModel: ({ dataModel, quote, elementLocator, }: {
53
- quote: QuoteResponse | SegmentResponse;
52
+ export declare const extractElementDataModelFromQuote: ({ dataModel, quote, elementLocator, }: {
53
+ quote: QuoteResponse;
54
+ dataModel: DataModel;
55
+ elementLocator: string;
56
+ }) => ElementConfig | false;
57
+
58
+ /**
59
+ * The function `extractElementDataModelFromSegment` extracts element data model based on a given segment, data
60
+ * model, and element locator.
61
+ * @param - - `segment`: A SegmentResponse object containing information about a transaction or policy.
62
+ * @param - - `dataModel`: A DataModel object containing information about a data model.
63
+ * @param - - `elementLocator`: A string containing the element locator.
64
+ * @returns The function `extractElementDataModelFromSegment` returns either an `ElementConfig` object or `false`
65
+ * based on the provided parameters and data model.
66
+ */
67
+ export declare const extractElementDataModelFromSegment: ({ dataModel, segment, elementLocator, }: {
68
+ segment: SegmentResponse;
54
69
  dataModel: DataModel;
55
70
  elementLocator: string;
56
71
  }) => ElementConfig | false;
@@ -78,7 +93,41 @@ export declare const extractElementDataModelFromType: ({ dataModel, elementType,
78
93
  * @returns The function `extractElementFromQuote` returns the element from the `QuoteResponse` object
79
94
  * that matches the provided `elementLocator`.
80
95
  */
81
- export declare const extractElementFromQuote: (quote: QuoteResponse | SegmentResponse, elementLocator: string) => false | ({
96
+ export declare const extractElementFromQuote: (quote: QuoteResponse, elementLocator: string) => false | ({
97
+ locator: string;
98
+ type: string;
99
+ staticLocator: string;
100
+ data?: Record<string, any> | undefined;
101
+ coverageTerms?: Record<string, string> | undefined;
102
+ parentLocator?: string | undefined;
103
+ rootLocator?: string | undefined;
104
+ tenantLocator?: string | undefined;
105
+ originalEffectiveTime?: string | undefined;
106
+ } & {
107
+ elements?: ({
108
+ locator: string;
109
+ type: string;
110
+ staticLocator: string;
111
+ data?: Record<string, any> | undefined;
112
+ coverageTerms?: Record<string, string> | undefined;
113
+ parentLocator?: string | undefined;
114
+ rootLocator?: string | undefined;
115
+ tenantLocator?: string | undefined;
116
+ originalEffectiveTime?: string | undefined;
117
+ } & any)[];
118
+ });
119
+
120
+ /**
121
+ * The function `extractElementFromSegment` takes a `SegmentResponse` object and an element locator string,
122
+ * and returns the element with the matching locator from the segment or its nested elements.
123
+ * @param {SegmentResponse} segment - The `segment` parameter is of type `SegmentResponse`, which is an object
124
+ * containing information about a segment.
125
+ * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
126
+ * locator of the element you want to extract from the `segment` object.
127
+ * @returns The function `extractElementFromSegment` returns the element from the `SegmentResponse` object
128
+ * that matches the provided `elementLocator`.
129
+ */
130
+ export declare const extractElementFromSegment: (segment: SegmentResponse, elementLocator: string) => false | ({
82
131
  locator: string;
83
132
  type: string;
84
133
  staticLocator: string;
@@ -211,12 +260,13 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
211
260
  contents: string[];
212
261
  }) => ProductElementMap;
213
262
 
214
- export declare const geDefaultInitializedTransactionValues: ({ segmentResponse, coverageTerms, }: {
215
- segmentResponse: SegmentResponse;
216
- coverageTerms: CoverageTermsConfigRecord;
217
- }) => {
218
- coverageTerms: Record<string, string>;
219
- };
263
+ /**
264
+ * `findElementInElementArray` is a utility function that takes an array of `ElementResponse` objects and an element locator string,
265
+ * @param elements - The `elements` parameter is an array of `ElementResponse` objects.
266
+ * @param elementLocator - The `elementLocator` parameter is a string that represents the locator of the element you want to extract from the `elements` array.
267
+ * @returns
268
+ */
269
+ export declare const findElementInElementsArray: (elements: ElementResponse[], elementLocator: string) => ElementResponse | false;
220
270
 
221
271
  /**
222
272
  * The `getCoverageTermsDefaultValues` function extracts default coverage terms values from a
@@ -257,6 +307,22 @@ export declare const getDefaultDraftTransactionValues: ({ transactionSnapshot, p
257
307
  */
258
308
  export declare const getDefaultElementValues: (element: ElementResponse, coverageTermDataModel: CoverageTermsConfigRecord) => Partial<ElementResponse>;
259
309
 
310
+ /**
311
+ * The function `getDefaultInitializedTransactionValues` takes an `ElementResponse` object and a `CoverageTermsConfigRecord` object,
312
+ * and returns the default initialized transaction values for the element.
313
+ * @param {ElementResponse} elementResponse - The `elementResponse` parameter is of type `ElementResponse`, which is an object
314
+ * containing information about an element.
315
+ * @param {CoverageTermsConfigRecord} coverageTerms - The `coverageTerms` parameter is of type `CoverageTermsConfigRecord`, which is an object
316
+ * containing information about coverage terms.
317
+ * @returns The function `getDefaultInitializedTransactionValues` returns the default initialized transaction values for the element.
318
+ */
319
+ export declare const getDefaultInitializedTransactionValues: ({ elementResponse, coverageTerms, }: {
320
+ elementResponse: ElementResponse;
321
+ coverageTerms: CoverageTermsConfigRecord;
322
+ }) => {
323
+ coverageTerms?: Record<string, string> | undefined;
324
+ };
325
+
260
326
  /**
261
327
  * The `getDefaultQuoteValues` function extracts default values from a `QuoteResponse`
262
328
  * object and sets them based on certain conditions.
@@ -290,7 +356,7 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
290
356
  coverageTerms: Record<string, string>;
291
357
  };
292
358
 
293
- export declare const getElementTransactionUpdateRequestFromFormData: ({ data, segmentResponse, locator, }: TransactionFormData) => {
359
+ export declare const getElementTransactionUpdateRequestFromFormData: ({ data, elementResponse, locator, }: TransactionFormData) => {
294
360
  locator: string;
295
361
  removeCoverageTerms?: Record<string, unknown> | undefined;
296
362
  removeData?: Record<string, unknown> | undefined;
@@ -298,7 +364,7 @@ export declare const getElementTransactionUpdateRequestFromFormData: ({ data, se
298
364
  setData?: Record<string, unknown> | undefined;
299
365
  };
300
366
 
301
- export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ data, transactionSnapshot, staticLocator, }: TransactionFormData_3) => {
367
+ export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ data, transactionSnapshot, staticLocator, }: TransactionFormData_2) => {
302
368
  staticLocator: string;
303
369
  action: "modify";
304
370
  removeCoverageTerms?: Record<string, any> | undefined;
@@ -312,7 +378,7 @@ export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ dat
312
378
  * @param data - form data
313
379
  * @returns ParamsChangeInstructionCreateRequest
314
380
  */
315
- export declare const getParamsChangeInstructionCreateRequestFromFormData: ({ data, }: TransactionFormData_2) => ParamsChangeInstructionCreateRequest;
381
+ export declare const getParamsChangeInstructionCreateRequestFromFormData: ({ data, }: TransactionFormData_3) => ParamsChangeInstructionCreateRequest;
316
382
 
317
383
  /**
318
384
  * The function `getQuoteRequest` processes form data to create a `QuoteRequest` object.
@@ -400,19 +466,10 @@ declare interface TransactionFormData {
400
466
  [key: string]: any;
401
467
  };
402
468
  locator: string;
403
- segmentResponse: SegmentResponse;
469
+ elementResponse: ElementResponse;
404
470
  }
405
471
 
406
472
  declare interface TransactionFormData_2 {
407
- data: {
408
- default: {
409
- effectiveTime: string;
410
- newPolicyEndDate?: string;
411
- };
412
- };
413
- }
414
-
415
- declare interface TransactionFormData_3 {
416
473
  data: {
417
474
  default?: {
418
475
  effectiveTime: string;
@@ -436,6 +493,15 @@ declare interface TransactionFormData_3 {
436
493
  transactionSnapshot: TransactionSnapshotResponse;
437
494
  }
438
495
 
496
+ declare interface TransactionFormData_3 {
497
+ data: {
498
+ default: {
499
+ effectiveTime: string;
500
+ newPolicyEndDate?: string;
501
+ };
502
+ };
503
+ }
504
+
439
505
  export declare function translateError(error: ErrorObject): string;
440
506
 
441
507
  export { }