@socotra/ec-react-utils 2.5.1-next.9 → 2.6.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.ts +181 -17
- package/dist/index.es.js +1514 -1419
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { ParamsChangeInstructionCreateRequest } from '@socotra/ec-react-schemas'
|
|
|
12
12
|
import { ProductConfig } from '@socotra/ec-react-schemas';
|
|
13
13
|
import { QuoteRequest } from '@socotra/ec-react-schemas';
|
|
14
14
|
import { QuoteResponse } from '@socotra/ec-react-schemas';
|
|
15
|
+
import { SegmentResponse } from '@socotra/ec-react-schemas';
|
|
15
16
|
import { TransactionSnapshotResponse } from '@socotra/ec-react-schemas';
|
|
16
17
|
|
|
17
18
|
declare type AnyObject = {
|
|
@@ -40,20 +41,35 @@ declare interface DataModelToJsonSchemaProps {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
|
-
* The function `
|
|
44
|
+
* The function `extractElementDataModelFromQuote` extracts element data model based on a given quote, data
|
|
44
45
|
* model, and element locator.
|
|
45
46
|
* @param - - `quote`: A QuoteResponse object containing information about a quote.
|
|
46
47
|
* @param - - `dataModel`: A DataModel object containing information about a data model.
|
|
47
48
|
* @param - - `elementLocator`: A string containing the element locator.
|
|
48
|
-
* @returns The function `
|
|
49
|
+
* @returns The function `extractElementDataModelFromQuote` returns either an `ElementConfig` object or `false`
|
|
49
50
|
* based on the provided parameters and data model.
|
|
50
51
|
*/
|
|
51
|
-
export declare const
|
|
52
|
+
export declare const extractElementDataModelFromQuote: ({ dataModel, quote, elementLocator, }: {
|
|
52
53
|
quote: QuoteResponse;
|
|
53
54
|
dataModel: DataModel;
|
|
54
55
|
elementLocator: string;
|
|
55
56
|
}) => ElementConfig | false;
|
|
56
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;
|
|
69
|
+
dataModel: DataModel;
|
|
70
|
+
elementLocator: string;
|
|
71
|
+
}) => ElementConfig | false;
|
|
72
|
+
|
|
57
73
|
/**
|
|
58
74
|
* The function `extractElementDataModelFromType` extracts element data model given a data model and
|
|
59
75
|
* element type.
|
|
@@ -101,6 +117,74 @@ export declare const extractElementFromQuote: (quote: QuoteResponse, elementLoca
|
|
|
101
117
|
} & any)[];
|
|
102
118
|
});
|
|
103
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 | ({
|
|
131
|
+
locator: string;
|
|
132
|
+
type: string;
|
|
133
|
+
staticLocator: string;
|
|
134
|
+
data?: Record<string, any> | undefined;
|
|
135
|
+
coverageTerms?: Record<string, string> | undefined;
|
|
136
|
+
parentLocator?: string | undefined;
|
|
137
|
+
rootLocator?: string | undefined;
|
|
138
|
+
tenantLocator?: string | undefined;
|
|
139
|
+
originalEffectiveTime?: string | undefined;
|
|
140
|
+
} & {
|
|
141
|
+
elements?: ({
|
|
142
|
+
locator: string;
|
|
143
|
+
type: string;
|
|
144
|
+
staticLocator: string;
|
|
145
|
+
data?: Record<string, any> | undefined;
|
|
146
|
+
coverageTerms?: Record<string, string> | undefined;
|
|
147
|
+
parentLocator?: string | undefined;
|
|
148
|
+
rootLocator?: string | undefined;
|
|
149
|
+
tenantLocator?: string | undefined;
|
|
150
|
+
originalEffectiveTime?: string | undefined;
|
|
151
|
+
} & any)[];
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The function `extractElementFromTransactionSegment` takes a `SegmentResponse` object and an element locator string,
|
|
156
|
+
* and returns the element with the matching locator from the segment or its nested elements.
|
|
157
|
+
* @param {SegmentResponse} transactionSegment - The `transactionSegment` parameter is of type `SegmentResponse`, which is an object
|
|
158
|
+
* containing information about a transaction.
|
|
159
|
+
* @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
|
|
160
|
+
* locator of the element you want to extract from the `transactionSegment` object.
|
|
161
|
+
* @returns The function `extractElementFromTransactionSegment` returns the element from the `SegmentResponse` object
|
|
162
|
+
* that matches the provided `elementLocator`.
|
|
163
|
+
*/
|
|
164
|
+
export declare const extractElementFromTransactionSegment: (transactionSegment: SegmentResponse, elementLocator: string) => false | ({
|
|
165
|
+
locator: string;
|
|
166
|
+
type: string;
|
|
167
|
+
staticLocator: string;
|
|
168
|
+
data?: Record<string, any> | undefined;
|
|
169
|
+
coverageTerms?: Record<string, string> | undefined;
|
|
170
|
+
parentLocator?: string | undefined;
|
|
171
|
+
rootLocator?: string | undefined;
|
|
172
|
+
tenantLocator?: string | undefined;
|
|
173
|
+
originalEffectiveTime?: string | undefined;
|
|
174
|
+
} & {
|
|
175
|
+
elements?: ({
|
|
176
|
+
locator: string;
|
|
177
|
+
type: string;
|
|
178
|
+
staticLocator: string;
|
|
179
|
+
data?: Record<string, any> | undefined;
|
|
180
|
+
coverageTerms?: Record<string, string> | undefined;
|
|
181
|
+
parentLocator?: string | undefined;
|
|
182
|
+
rootLocator?: string | undefined;
|
|
183
|
+
tenantLocator?: string | undefined;
|
|
184
|
+
originalEffectiveTime?: string | undefined;
|
|
185
|
+
} & any)[];
|
|
186
|
+
});
|
|
187
|
+
|
|
104
188
|
export declare const extractElementsFromQuote: (elements: Array<ElementResponse>, elementType: string) => ({
|
|
105
189
|
locator: string;
|
|
106
190
|
type: string;
|
|
@@ -125,6 +209,30 @@ export declare const extractElementsFromQuote: (elements: Array<ElementResponse>
|
|
|
125
209
|
} & any)[];
|
|
126
210
|
})[];
|
|
127
211
|
|
|
212
|
+
export declare const extractElementsFromTransactionSegment: (elements: Array<ElementResponse>, elementType: string) => ({
|
|
213
|
+
locator: string;
|
|
214
|
+
type: string;
|
|
215
|
+
staticLocator: string;
|
|
216
|
+
data?: Record<string, any> | undefined;
|
|
217
|
+
coverageTerms?: Record<string, string> | undefined;
|
|
218
|
+
parentLocator?: string | undefined;
|
|
219
|
+
rootLocator?: string | undefined;
|
|
220
|
+
tenantLocator?: string | undefined;
|
|
221
|
+
originalEffectiveTime?: string | undefined;
|
|
222
|
+
} & {
|
|
223
|
+
elements?: ({
|
|
224
|
+
locator: string;
|
|
225
|
+
type: string;
|
|
226
|
+
staticLocator: string;
|
|
227
|
+
data?: Record<string, any> | undefined;
|
|
228
|
+
coverageTerms?: Record<string, string> | undefined;
|
|
229
|
+
parentLocator?: string | undefined;
|
|
230
|
+
rootLocator?: string | undefined;
|
|
231
|
+
tenantLocator?: string | undefined;
|
|
232
|
+
originalEffectiveTime?: string | undefined;
|
|
233
|
+
} & any)[];
|
|
234
|
+
})[];
|
|
235
|
+
|
|
128
236
|
/**
|
|
129
237
|
* The function `extractProductDataModel` extracts product data model based on the product name from a
|
|
130
238
|
* given data model.
|
|
@@ -152,6 +260,14 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
|
|
|
152
260
|
contents: string[];
|
|
153
261
|
}) => ProductElementMap;
|
|
154
262
|
|
|
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;
|
|
270
|
+
|
|
155
271
|
/**
|
|
156
272
|
* The `getCoverageTermsDefaultValues` function extracts default coverage terms values from a
|
|
157
273
|
* `CoverageTermsConfigRecord` object and sets them based on certain conditions.
|
|
@@ -167,6 +283,19 @@ export declare const getCoverageTermsDefaultValues: ({ coverageTermOptions, cove
|
|
|
167
283
|
coverageTermDataModel: CoverageTermsConfigRecord;
|
|
168
284
|
}) => Record<string, string>;
|
|
169
285
|
|
|
286
|
+
export declare const getDefaultDraftTransactionValues: ({ transactionSnapshot, paramsChangeInstruction, modifyChangeInstruction, coverageTerms, }: {
|
|
287
|
+
transactionSnapshot: TransactionSnapshotResponse;
|
|
288
|
+
paramsChangeInstruction: ParamsChangeInstructionCreateRequest;
|
|
289
|
+
modifyChangeInstruction?: ModifyChangeInstructionCreateRequest;
|
|
290
|
+
coverageTerms: CoverageTermsConfigRecord;
|
|
291
|
+
}) => {
|
|
292
|
+
default: {
|
|
293
|
+
newPolicyEndDate?: string | undefined;
|
|
294
|
+
effectiveTime: string;
|
|
295
|
+
};
|
|
296
|
+
coverageTerms: Record<string, string>;
|
|
297
|
+
};
|
|
298
|
+
|
|
170
299
|
/**
|
|
171
300
|
* The function `getDefaultElementValues` returns a partial copy of an ElementResponse object with
|
|
172
301
|
* default values for coverageTerms if not provided.
|
|
@@ -178,6 +307,22 @@ export declare const getCoverageTermsDefaultValues: ({ coverageTermOptions, cove
|
|
|
178
307
|
*/
|
|
179
308
|
export declare const getDefaultElementValues: (element: ElementResponse, coverageTermDataModel: CoverageTermsConfigRecord) => Partial<ElementResponse>;
|
|
180
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
|
+
|
|
181
326
|
/**
|
|
182
327
|
* The `getDefaultQuoteValues` function extracts default values from a `QuoteResponse`
|
|
183
328
|
* object and sets them based on certain conditions.
|
|
@@ -211,20 +356,15 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
|
|
|
211
356
|
coverageTerms: Record<string, string>;
|
|
212
357
|
};
|
|
213
358
|
|
|
214
|
-
export declare const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
default: {
|
|
221
|
-
newPolicyEndDate?: string | undefined;
|
|
222
|
-
effectiveTime: string;
|
|
223
|
-
};
|
|
224
|
-
coverageTerms: Record<string, string>;
|
|
359
|
+
export declare const getElementTransactionUpdateRequestFromFormData: ({ data, elementResponse, locator, }: TransactionFormData) => {
|
|
360
|
+
locator: string;
|
|
361
|
+
removeCoverageTerms?: Record<string, unknown> | undefined;
|
|
362
|
+
removeData?: Record<string, unknown> | undefined;
|
|
363
|
+
setCoverageTerms?: Record<string, unknown> | undefined;
|
|
364
|
+
setData?: Record<string, unknown> | undefined;
|
|
225
365
|
};
|
|
226
366
|
|
|
227
|
-
export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ data, transactionSnapshot, staticLocator, }:
|
|
367
|
+
export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ data, transactionSnapshot, staticLocator, }: TransactionFormData_2) => {
|
|
228
368
|
staticLocator: string;
|
|
229
369
|
action: "modify";
|
|
230
370
|
removeCoverageTerms?: Record<string, any> | undefined;
|
|
@@ -238,7 +378,7 @@ export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ dat
|
|
|
238
378
|
* @param data - form data
|
|
239
379
|
* @returns ParamsChangeInstructionCreateRequest
|
|
240
380
|
*/
|
|
241
|
-
export declare const getParamsChangeInstructionCreateRequestFromFormData: ({ data, }:
|
|
381
|
+
export declare const getParamsChangeInstructionCreateRequestFromFormData: ({ data, }: TransactionFormData_3) => ParamsChangeInstructionCreateRequest;
|
|
242
382
|
|
|
243
383
|
/**
|
|
244
384
|
* The function `getQuoteRequest` processes form data to create a `QuoteRequest` object.
|
|
@@ -306,6 +446,30 @@ export declare const splitInputAndQuantifier: (input: string | undefined) => {
|
|
|
306
446
|
};
|
|
307
447
|
|
|
308
448
|
declare interface TransactionFormData {
|
|
449
|
+
data: {
|
|
450
|
+
default?: {
|
|
451
|
+
effectiveTime: string;
|
|
452
|
+
newPolicyEndDate?: string;
|
|
453
|
+
};
|
|
454
|
+
advanced?: {
|
|
455
|
+
currency?: string;
|
|
456
|
+
timezone?: string;
|
|
457
|
+
billingPlan?: string;
|
|
458
|
+
defaultTermDuration?: string;
|
|
459
|
+
installmentPlan?: string;
|
|
460
|
+
durationBasis?: string;
|
|
461
|
+
delinquencyPlanName?: string;
|
|
462
|
+
};
|
|
463
|
+
coverageTerms?: {
|
|
464
|
+
[key: string]: string;
|
|
465
|
+
};
|
|
466
|
+
[key: string]: any;
|
|
467
|
+
};
|
|
468
|
+
locator: string;
|
|
469
|
+
elementResponse: ElementResponse;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
declare interface TransactionFormData_2 {
|
|
309
473
|
data: {
|
|
310
474
|
default?: {
|
|
311
475
|
effectiveTime: string;
|
|
@@ -329,7 +493,7 @@ declare interface TransactionFormData {
|
|
|
329
493
|
transactionSnapshot: TransactionSnapshotResponse;
|
|
330
494
|
}
|
|
331
495
|
|
|
332
|
-
declare interface
|
|
496
|
+
declare interface TransactionFormData_3 {
|
|
333
497
|
data: {
|
|
334
498
|
default: {
|
|
335
499
|
effectiveTime: string;
|