@socotra/ec-react-utils 2.12.0-next.2 → 2.12.0-next.4

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,11 +1,14 @@
1
1
  import { AccountConfigRecord } from '@socotra/ec-react-schemas';
2
+ import { AccountCreateRequest } from '@socotra/ec-react-schemas';
2
3
  import { AccountResponse } from '@socotra/ec-react-schemas';
4
+ import { AccountUpdateRequest } from '@socotra/ec-react-schemas';
3
5
  import { ConstraintEvaluationResponse } from '@socotra/ec-react-schemas';
4
6
  import { CoverageTermsConfigRecord } from '@socotra/ec-react-schemas';
5
7
  import { DataFieldValue } from '@socotra/ec-react-schemas';
6
8
  import { DataModel } from '@socotra/ec-react-schemas';
7
9
  import { DataTypeConfigRecord } from '@socotra/ec-react-schemas';
8
10
  import { ElementConfig } from '@socotra/ec-react-schemas';
11
+ import { ElementRequest } from '@socotra/ec-react-schemas';
9
12
  import { ElementResponse } from '@socotra/ec-react-schemas';
10
13
  import { ErrorObject } from 'ajv';
11
14
  import { FieldConfigRecord } from '@socotra/ec-react-schemas';
@@ -20,6 +23,38 @@ import { QuoteRequest } from '@socotra/ec-react-schemas';
20
23
  import { QuoteResponse } from '@socotra/ec-react-schemas';
21
24
  import { SegmentResponse } from '@socotra/ec-react-schemas';
22
25
  import { TransactionSnapshotResponse } from '@socotra/ec-react-schemas';
26
+ import { z } from 'zod';
27
+
28
+ /**
29
+ * The type `QuoteRequestAdvancedFields` is a zod infererred type that represents the advanced fields of a quote request.
30
+ * It follows the fields that are found on the QuoteForm in @socotra/ec-react-components
31
+ */
32
+ declare type AccountRequestAdvancedFields = z.infer<typeof advancedFieldSchema_2>;
33
+
34
+ declare const advancedFieldSchema: z.ZodRecord<z.ZodEnum<["currency", "timezone", "billingLevel", "billingTrigger", "durationBasis", "delinquencyPlanName", "autoRenewalPlanName"]>, z.ZodOptional<z.ZodString>>;
35
+
36
+ declare const advancedFieldSchema_2: z.ZodObject<{
37
+ autoRenewalPlanName: z.ZodOptional<z.ZodString>;
38
+ delinquencyPlanName: z.ZodOptional<z.ZodString>;
39
+ excessCreditPlanName: z.ZodOptional<z.ZodString>;
40
+ shortfallTolerancePlanName: z.ZodOptional<z.ZodString>;
41
+ billingLevel: z.ZodOptional<z.ZodEnum<["account", "policy"]>>;
42
+ invoiceDocument: z.ZodOptional<z.ZodString>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ billingLevel?: "account" | "policy" | undefined;
45
+ delinquencyPlanName?: string | undefined;
46
+ autoRenewalPlanName?: string | undefined;
47
+ excessCreditPlanName?: string | undefined;
48
+ shortfallTolerancePlanName?: string | undefined;
49
+ invoiceDocument?: string | undefined;
50
+ }, {
51
+ billingLevel?: "account" | "policy" | undefined;
52
+ delinquencyPlanName?: string | undefined;
53
+ autoRenewalPlanName?: string | undefined;
54
+ excessCreditPlanName?: string | undefined;
55
+ shortfallTolerancePlanName?: string | undefined;
56
+ invoiceDocument?: string | undefined;
57
+ }>;
23
58
 
24
59
  declare type AnyObject = {
25
60
  [key: string]: any;
@@ -61,6 +96,16 @@ declare interface DataModelToJsonSchemaProps {
61
96
  falsyLabel?: string;
62
97
  }
63
98
 
99
+ declare interface ElementFormData {
100
+ data: {
101
+ [key: string]: any;
102
+ };
103
+ coverageTerms?: {
104
+ [key: string]: string;
105
+ };
106
+ element: ElementResponse;
107
+ }
108
+
64
109
  /**
65
110
  * The function `extractElementFromElement takes a `QuoteResponse`, `SegmentResponse` or `ElementResponse` object and an element locator string,
66
111
  * and returns the element with the matching locator from the quote or its nested elements.
@@ -214,6 +259,26 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
214
259
  contents: string[];
215
260
  }) => ProductElementMap;
216
261
 
262
+ export declare function getAccountRequest(params: {
263
+ data: {
264
+ [key: string]: any;
265
+ };
266
+ advanced: AccountRequestAdvancedFields;
267
+ type: string;
268
+ autoValidate: boolean;
269
+ account: AccountResponse;
270
+ }): AccountUpdateRequest;
271
+
272
+ export declare function getAccountRequest(params: {
273
+ data: {
274
+ [key: string]: any;
275
+ };
276
+ advanced: AccountRequestAdvancedFields;
277
+ type: string;
278
+ autoValidate: boolean;
279
+ account?: undefined;
280
+ }): AccountCreateRequest;
281
+
217
282
  /**
218
283
  * The `getCoverageTermsDefaultValues` function extracts default coverage terms values from a
219
284
  * `CoverageTermsConfigRecord` object and sets them based on certain conditions.
@@ -224,9 +289,10 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
224
289
  * @returns The `getCoverageTermsDefaultValues` function returns an object with default values for
225
290
  * coverage terms.
226
291
  */
227
- export declare const getCoverageTermsDefaultValues: ({ coverageTermOptions, coverageTermDataModel, }: {
292
+ export declare const getCoverageTermsDefaultValues: ({ coverageTermOptions, coverageTermDataModel, coverageTerms, }: {
228
293
  coverageTermOptions: Record<string, string>;
229
294
  coverageTermDataModel?: CoverageTermsConfigRecord;
295
+ coverageTerms: string[];
230
296
  }) => Record<string, string>;
231
297
 
232
298
  export declare const getDefaultAccountFormValues: ({ defaultValues, accountType, account, }: {
@@ -249,11 +315,12 @@ export declare const getDefaultAccountFormValues: ({ defaultValues, accountType,
249
315
  saveAsDraft: boolean;
250
316
  };
251
317
 
252
- export declare const getDefaultDraftTransactionValues: ({ transactionSnapshot, paramsChangeInstruction, modifyChangeInstruction, coverageTerms, }: {
318
+ export declare const getDefaultDraftTransactionValues: ({ transactionSnapshot, paramsChangeInstruction, modifyChangeInstruction, coverageTerms, coverageTermsDataModel, }: {
253
319
  transactionSnapshot: TransactionSnapshotResponse;
254
320
  paramsChangeInstruction: ParamsChangeInstructionCreateRequest;
321
+ coverageTerms: string[];
255
322
  modifyChangeInstruction?: ModifyChangeInstructionCreateRequest;
256
- coverageTerms?: CoverageTermsConfigRecord;
323
+ coverageTermsDataModel?: CoverageTermsConfigRecord;
257
324
  }) => {
258
325
  default: {
259
326
  newPolicyEndDate?: string | undefined;
@@ -271,7 +338,7 @@ export declare const getDefaultDraftTransactionValues: ({ transactionSnapshot, p
271
338
  * @returns A partial ElementResponse object is being returned, with the data from the input element
272
339
  * and the coverageTerms property set to element.coverageTerms if it exists, otherwise an empty object.
273
340
  */
274
- export declare const getDefaultElementValues: (element: ElementResponse, coverageTermDataModel?: CoverageTermsConfigRecord) => Partial<ElementResponse>;
341
+ export declare const getDefaultElementValues: (element: ElementResponse, coverageTerms: string[], coverageTermDataModel?: CoverageTermsConfigRecord) => Partial<ElementResponse>;
275
342
 
276
343
  /**
277
344
  * The function `getDefaultInitializedTransactionValues` takes an `ElementResponse` object and a `CoverageTermsConfigRecord` object,
@@ -282,9 +349,10 @@ export declare const getDefaultElementValues: (element: ElementResponse, coverag
282
349
  * containing information about coverage terms.
283
350
  * @returns The function `getDefaultInitializedTransactionValues` returns the default initialized transaction values for the element.
284
351
  */
285
- export declare const getDefaultInitializedTransactionValues: ({ elementResponse, coverageTerms, }: {
352
+ export declare const getDefaultInitializedTransactionValues: ({ elementResponse, coverageTerms, coverageTermsDataModel, }: {
286
353
  elementResponse: ElementResponse;
287
- coverageTerms?: CoverageTermsConfigRecord;
354
+ coverageTerms: string[];
355
+ coverageTermsDataModel?: CoverageTermsConfigRecord;
288
356
  }) => {
289
357
  coverageTerms?: Record<string, string> | undefined;
290
358
  };
@@ -330,7 +398,14 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
330
398
  */
331
399
  export declare const getElementNameByType: (elementType: string) => string;
332
400
 
333
- export declare const getElementTransactionUpdateRequestFromFormData: ({ data, elementResponse, locator, }: TransactionFormData) => {
401
+ /**
402
+ * Get the ElementRequest object from the ElementFormData object.
403
+ * @param formData The ElementFormData object
404
+ * @returns The ElementRequest object
405
+ */
406
+ export declare const getElementRequest: (formData: ElementFormData) => ElementRequest;
407
+
408
+ export declare const getElementTransactionUpdateRequestFromFormData: (params: TransactionFormData) => {
334
409
  locator: string;
335
410
  removeCoverageTerms?: Record<string, unknown> | undefined;
336
411
  removeData?: Record<string, unknown> | undefined;
@@ -367,7 +442,7 @@ export declare const getParamsChangeInstructionCreateRequestFromFormData: ({ dat
367
442
  * @returns The function `getQuoteRequest` returns a `QuoteRequest` object based on the provided
368
443
  * `QuoteFormData` data.
369
444
  */
370
- export declare const getQuoteRequest: ({ data }: QuoteFormData) => QuoteRequest;
445
+ export declare const getQuoteRequest: (params: QuoteFormData) => QuoteRequest;
371
446
 
372
447
  /**
373
448
  * Recursively compare two objects and return the values that should be removed.
@@ -392,27 +467,26 @@ declare interface ProductElementMap {
392
467
 
393
468
  declare interface QuoteFormData {
394
469
  data: {
395
- default?: {
396
- startTime?: string;
397
- endTime?: string;
398
- expirationTime?: string;
399
- };
400
- advanced?: {
401
- currency?: string;
402
- timezone?: string;
403
- billingPlan?: string;
404
- defaultTermDuration?: string;
405
- installmentPlan?: string;
406
- durationBasis?: string;
407
- delinquencyPlanName?: string;
408
- };
409
- coverageTerms?: {
410
- [key: string]: string;
411
- };
412
470
  [key: string]: any;
413
471
  };
472
+ default?: {
473
+ startTime?: string;
474
+ endTime?: string;
475
+ expirationTime?: string;
476
+ };
477
+ advanced?: QuoteRequestAdvancedFields;
478
+ coverageTerms?: {
479
+ [key: string]: string;
480
+ };
481
+ quote: QuoteResponse;
414
482
  }
415
483
 
484
+ /**
485
+ * The type `QuoteRequestAdvancedFields` is a zod infererred type that represents the advanced fields of a quote request.
486
+ * It follows the fields that are found on the QuoteForm in @socotra/ec-react-components
487
+ */
488
+ export declare type QuoteRequestAdvancedFields = z.infer<typeof advancedFieldSchema>;
489
+
416
490
  /**
417
491
  * The function `splitInputAndQuantifier` takes a string input, removes certain characters from it, and
418
492
  * extracts a quantifier if present.
@@ -431,26 +505,18 @@ export declare const splitInputAndQuantifier: (input: string | undefined) => {
431
505
 
432
506
  declare interface TransactionFormData {
433
507
  data: {
434
- default?: {
435
- effectiveTime: string;
436
- newPolicyEndDate?: string;
437
- };
438
- advanced?: {
439
- currency?: string;
440
- timezone?: string;
441
- billingPlan?: string;
442
- defaultTermDuration?: string;
443
- installmentPlan?: string;
444
- durationBasis?: string;
445
- delinquencyPlanName?: string;
446
- };
447
- coverageTerms?: {
448
- [key: string]: string;
449
- };
450
508
  [key: string]: any;
451
509
  };
452
- locator: string;
453
- elementResponse: ElementResponse;
510
+ default?: {
511
+ startTime?: string;
512
+ endTime?: string;
513
+ expirationTime?: string;
514
+ };
515
+ advanced?: QuoteRequestAdvancedFields;
516
+ coverageTerms?: {
517
+ [key: string]: string;
518
+ };
519
+ element: ElementResponse;
454
520
  }
455
521
 
456
522
  declare interface TransactionFormData_2 {