@socotra/ec-react-utils 2.5.1-next.0 → 2.5.1-next.10

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
@@ -7,9 +7,17 @@ import { ElementResponse } from '@socotra/ec-react-schemas';
7
7
  import { ErrorObject } from 'ajv';
8
8
  import { FieldConfigRecord } from '@socotra/ec-react-schemas';
9
9
  import { JsonSchema7 } from '@jsonforms/core';
10
+ import { ModifyChangeInstructionCreateRequest } from '@socotra/ec-react-schemas';
11
+ import { ParamsChangeInstructionCreateRequest } from '@socotra/ec-react-schemas';
10
12
  import { ProductConfig } from '@socotra/ec-react-schemas';
11
13
  import { QuoteRequest } from '@socotra/ec-react-schemas';
12
14
  import { QuoteResponse } from '@socotra/ec-react-schemas';
15
+ import { SegmentResponse } from '@socotra/ec-react-schemas';
16
+ import { TransactionSnapshotResponse } from '@socotra/ec-react-schemas';
17
+
18
+ declare type AnyObject = {
19
+ [key: string]: any;
20
+ };
13
21
 
14
22
  /**
15
23
  * The function `dataModelToJSONSchema` converts a data model to a JSON schema based on specified
@@ -145,6 +153,13 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
145
153
  contents: string[];
146
154
  }) => ProductElementMap;
147
155
 
156
+ export declare const geDefaultInitializedTransactionValues: ({ segmentResponse, coverageTerms, }: {
157
+ segmentResponse: SegmentResponse;
158
+ coverageTerms: CoverageTermsConfigRecord;
159
+ }) => {
160
+ coverageTerms: Record<string, string>;
161
+ };
162
+
148
163
  /**
149
164
  * The `getCoverageTermsDefaultValues` function extracts default coverage terms values from a
150
165
  * `CoverageTermsConfigRecord` object and sets them based on certain conditions.
@@ -160,6 +175,19 @@ export declare const getCoverageTermsDefaultValues: ({ coverageTermOptions, cove
160
175
  coverageTermDataModel: CoverageTermsConfigRecord;
161
176
  }) => Record<string, string>;
162
177
 
178
+ export declare const getDefaultDraftTransactionValues: ({ transactionSnapshot, paramsChangeInstruction, modifyChangeInstruction, coverageTerms, }: {
179
+ transactionSnapshot: TransactionSnapshotResponse;
180
+ paramsChangeInstruction: ParamsChangeInstructionCreateRequest;
181
+ modifyChangeInstruction?: ModifyChangeInstructionCreateRequest;
182
+ coverageTerms: CoverageTermsConfigRecord;
183
+ }) => {
184
+ default: {
185
+ newPolicyEndDate?: string | undefined;
186
+ effectiveTime: string;
187
+ };
188
+ coverageTerms: Record<string, string>;
189
+ };
190
+
163
191
  /**
164
192
  * The function `getDefaultElementValues` returns a partial copy of an ElementResponse object with
165
193
  * default values for coverageTerms if not provided.
@@ -184,9 +212,13 @@ export declare const getDefaultElementValues: (element: ElementResponse, coverag
184
212
  */
185
213
  export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel: ProductConfig, dataModel: DataModel) => {
186
214
  default: {
187
- expirationTime?: string | undefined;
188
- endTime?: string | undefined;
189
- startTime?: string | undefined;
215
+ startTime: string;
216
+ endTime: string;
217
+ expirationTime: string | undefined;
218
+ } | {
219
+ startTime: string;
220
+ expirationTime: string | undefined;
221
+ endTime?: undefined;
190
222
  };
191
223
  advanced: {
192
224
  currency: string | undefined;
@@ -200,6 +232,30 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
200
232
  coverageTerms: Record<string, string>;
201
233
  };
202
234
 
235
+ export declare const getElementTransactionUpdateRequestFromFormData: ({ data, segmentResponse, locator, }: TransactionFormData) => {
236
+ locator: string;
237
+ removeCoverageTerms?: Record<string, unknown> | undefined;
238
+ removeData?: Record<string, unknown> | undefined;
239
+ setCoverageTerms?: Record<string, unknown> | undefined;
240
+ setData?: Record<string, unknown> | undefined;
241
+ };
242
+
243
+ export declare const getModifyChangeInstructionCreateRequestFromFormData: ({ data, transactionSnapshot, staticLocator, }: TransactionFormData_3) => {
244
+ staticLocator: string;
245
+ action: "modify";
246
+ removeCoverageTerms?: Record<string, any> | undefined;
247
+ removeData?: Record<string, any> | undefined;
248
+ setCoverageTerms?: Record<string, string> | undefined;
249
+ setData?: Record<string, any> | undefined;
250
+ };
251
+
252
+ /**
253
+ * Get ParamsChangeInstructionCreateRequest from form data
254
+ * @param data - form data
255
+ * @returns ParamsChangeInstructionCreateRequest
256
+ */
257
+ export declare const getParamsChangeInstructionCreateRequestFromFormData: ({ data, }: TransactionFormData_2) => ParamsChangeInstructionCreateRequest;
258
+
203
259
  /**
204
260
  * The function `getQuoteRequest` processes form data to create a `QuoteRequest` object.
205
261
  * @param {QuoteFormData} - The `getQuoteRequest` function takes in a parameter `data` of type
@@ -209,6 +265,14 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
209
265
  */
210
266
  export declare const getQuoteRequest: ({ data }: QuoteFormData) => QuoteRequest;
211
267
 
268
+ /**
269
+ * Recursively compare two objects and return the values that should be removed.
270
+ * @param originalObj - The original object.
271
+ * @param modifiedObj - The modified object.
272
+ * @returns The values that should be removed.
273
+ */
274
+ export declare function getRemoveDataFieldValues(originalObj: AnyObject, modifiedObj: AnyObject): AnyObject;
275
+
212
276
  declare type ProductElement = Record<string, ElementConfig>;
213
277
 
214
278
  declare interface ProductElementMap {
@@ -257,6 +321,63 @@ export declare const splitInputAndQuantifier: (input: string | undefined) => {
257
321
  quantifier: "" | "*" | "?" | "+" | "!";
258
322
  };
259
323
 
260
- export declare function transformErrors(errors: ErrorObject<string, Record<string, any>, unknown>[] | null | undefined): ErrorObject<string, Record<string, any>, unknown>[] | undefined;
324
+ declare interface TransactionFormData {
325
+ data: {
326
+ default?: {
327
+ effectiveTime: string;
328
+ newPolicyEndDate?: string;
329
+ };
330
+ advanced?: {
331
+ currency?: string;
332
+ timezone?: string;
333
+ billingPlan?: string;
334
+ defaultTermDuration?: string;
335
+ installmentPlan?: string;
336
+ durationBasis?: string;
337
+ delinquencyPlanName?: string;
338
+ };
339
+ coverageTerms?: {
340
+ [key: string]: string;
341
+ };
342
+ [key: string]: any;
343
+ };
344
+ locator: string;
345
+ segmentResponse: SegmentResponse;
346
+ }
347
+
348
+ declare interface TransactionFormData_2 {
349
+ data: {
350
+ default: {
351
+ effectiveTime: string;
352
+ newPolicyEndDate?: string;
353
+ };
354
+ };
355
+ }
356
+
357
+ declare interface TransactionFormData_3 {
358
+ data: {
359
+ default?: {
360
+ effectiveTime: string;
361
+ newPolicyEndDate?: string;
362
+ };
363
+ advanced?: {
364
+ currency?: string;
365
+ timezone?: string;
366
+ billingPlan?: string;
367
+ defaultTermDuration?: string;
368
+ installmentPlan?: string;
369
+ durationBasis?: string;
370
+ delinquencyPlanName?: string;
371
+ };
372
+ coverageTerms?: {
373
+ [key: string]: string;
374
+ };
375
+ [key: string]: any;
376
+ };
377
+ staticLocator: string;
378
+ transactionSnapshot: TransactionSnapshotResponse;
379
+ }
380
+
381
+ export declare function translateError(error: ErrorObject): string;
261
382
 
262
383
  export { }