@socotra/ec-react-utils 2.3.0-next.0 → 2.3.0-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
@@ -10,24 +10,65 @@ import { ProductConfig } from '@socotra/ec-react-schemas';
10
10
  import { QuoteRequest } from '@socotra/ec-react-schemas';
11
11
  import { QuoteResponse } from '@socotra/ec-react-schemas';
12
12
 
13
+ /**
14
+ * The function `dataModelToJSONSchema` converts a data model to a JSON schema based on specified
15
+ * criteria and data types.
16
+ * @param {DataModelToJsonSchemaProps} args - The `dataModelToJSONSchema` function takes in an object
17
+ * `args` with the following properties:
18
+ * @returns The function `dataModelToJSONSchema` returns a JSON schema object based on the provided
19
+ * arguments `args`. The JSON schema object includes properties, definitions, required fields, and
20
+ * other schema details based on the input data model and configuration.
21
+ */
13
22
  export declare const dataModelToJSONSchema: (args: DataModelToJsonSchemaProps) => JsonSchema7;
14
23
 
15
24
  declare interface DataModelToJsonSchemaProps {
16
25
  data: FieldConfigRecord;
17
26
  dataTypes?: DataTypeConfigRecord;
18
- scope: 'P' | 'Q';
19
- rootDisplayName: string;
27
+ scope: Array<'P' | 'Q' | 'QQ'>;
28
+ rootDisplayName?: string;
20
29
  account?: AccountResponse;
21
30
  quote?: QuoteResponse;
22
31
  element?: ElementResponse;
23
32
  }
24
33
 
34
+ /**
35
+ * The function `extractElementDataModel` extracts element data model based on a given quote, data
36
+ * model, and element locator.
37
+ * @param - - `quote`: A QuoteResponse object containing information about a quote.
38
+ * @param - - `dataModel`: A DataModel object containing information about a data model.
39
+ * @param - - `elementLocator`: A string containing the element locator.
40
+ * @returns The function `extractElementDataModel` returns either an `ElementConfig` object or `false`
41
+ * based on the provided parameters and data model.
42
+ */
25
43
  export declare const extractElementDataModel: ({ dataModel, quote, elementLocator, }: {
26
44
  quote: QuoteResponse;
27
45
  dataModel: DataModel;
28
46
  elementLocator: string;
29
47
  }) => ElementConfig | false;
30
48
 
49
+ /**
50
+ * The function `extractElementDataModelFromType` extracts element data model given a data model and
51
+ * element type.
52
+ * @param - - `dataModel`: A DataModel object containing information about a data model.
53
+ * @param - - `elementType`: A string containing the element type.
54
+ * @returns The function `extractElementDataModelFromType` returns either an `ElementConfig` object or `false`
55
+ * based on the provided parameters and data model.
56
+ */
57
+ export declare const extractElementDataModelFromType: ({ dataModel, elementType, }: {
58
+ dataModel: DataModel;
59
+ elementType: string;
60
+ }) => ElementConfig | false;
61
+
62
+ /**
63
+ * The function `extractElementFromQuote` takes a `QuoteResponse` object and an element locator string,
64
+ * and returns the element with the matching locator from the quote or its nested elements.
65
+ * @param {QuoteResponse} quote - The `quote` parameter is of type `QuoteResponse`, which is an object
66
+ * containing information about a quote.
67
+ * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
68
+ * locator of the element you want to extract from the `quote` object.
69
+ * @returns The function `extractElementFromQuote` returns the element from the `QuoteResponse` object
70
+ * that matches the provided `elementLocator`.
71
+ */
31
72
  export declare const extractElementFromQuote: (quote: QuoteResponse, elementLocator: string) => false | ({
32
73
  locator: string;
33
74
  type: string;
@@ -37,6 +78,7 @@ export declare const extractElementFromQuote: (quote: QuoteResponse, elementLoca
37
78
  rootLocator?: string | undefined;
38
79
  tenantLocator?: string | undefined;
39
80
  parentLocator?: string | undefined;
81
+ originalEffectiveTime?: string | undefined;
40
82
  } & {
41
83
  elements?: ({
42
84
  locator: string;
@@ -47,9 +89,41 @@ export declare const extractElementFromQuote: (quote: QuoteResponse, elementLoca
47
89
  rootLocator?: string | undefined;
48
90
  tenantLocator?: string | undefined;
49
91
  parentLocator?: string | undefined;
92
+ originalEffectiveTime?: string | undefined;
50
93
  } & any)[];
51
94
  });
52
95
 
96
+ export declare const extractElementsFromQuote: (elements: Array<ElementResponse>, elementType: string) => ({
97
+ locator: string;
98
+ type: string;
99
+ staticLocator: string;
100
+ data?: Record<string, any> | undefined;
101
+ coverageTerms?: Record<string, string> | undefined;
102
+ rootLocator?: string | undefined;
103
+ tenantLocator?: string | undefined;
104
+ parentLocator?: 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
+ rootLocator?: string | undefined;
114
+ tenantLocator?: string | undefined;
115
+ parentLocator?: string | undefined;
116
+ originalEffectiveTime?: string | undefined;
117
+ } & any)[];
118
+ })[];
119
+
120
+ /**
121
+ * The function `extractProductDataModel` extracts product data model based on the product name from a
122
+ * given data model.
123
+ * @param - The `extractProductDataModel` function takes in two parameters:
124
+ * @returns The function `extractProductDataModel` returns the product configuration data for the
125
+ * specified product name from the provided data model.
126
+ */
53
127
  export declare const extractProductDataModel: ({ dataModel, element: { productName }, }: {
54
128
  element: {
55
129
  productName: string;
@@ -57,13 +131,41 @@ export declare const extractProductDataModel: ({ dataModel, element: { productNa
57
131
  dataModel: DataModel;
58
132
  }) => ProductConfig;
59
133
 
60
- export declare const extractProductElements: ({ dataModel, productDataModel, }: {
134
+ /**
135
+ * The function `extractProductElements` extracts specific elements from a data model based on a
136
+ * product data model configuration.
137
+ * @param - The `extractProductElements` function takes in two parameters:
138
+ * @returns The function `extractProductElements` returns a `ProductElementMap` object containing
139
+ * elements related to coverages, exposures, policy lines, and exposure groups that are available based
140
+ * on the provided `dataModel` and `productDataModel`.
141
+ */
142
+ export declare const extractProductElements: ({ dataModel, contents, }: {
61
143
  dataModel: DataModel;
62
- productDataModel: ProductConfig;
144
+ contents: string[];
63
145
  }) => ProductElementMap;
64
146
 
147
+ /**
148
+ * The function `getDefaultElementValues` returns a partial copy of an ElementResponse object with
149
+ * default values for coverageTerms if not provided.
150
+ * @param {ElementResponse} element - The `element` parameter in the `getDefaultElementValues` function
151
+ * is of type `ElementResponse`, which contains data related to an element in a system or
152
+ * application.
153
+ * @returns A partial ElementResponse object is being returned, with the data from the input element
154
+ * and the coverageTerms property set to element.coverageTerms if it exists, otherwise an empty object.
155
+ */
65
156
  export declare const getDefaultElementValues: (element: ElementResponse) => Partial<ElementResponse>;
66
157
 
158
+ /**
159
+ * The `getDefaultQuoteValues` function extracts default values from a `QuoteResponse`
160
+ * object and sets them based on certain conditions.
161
+ * @param {QuoteResponse} quote - The `getDefaultQuoteValues` function takes in three parameters:
162
+ * @param {ProductConfig} productModel - The `productModel` parameter in the `getDefaultQuoteValues`
163
+ * function represents the configuration settings for a specific product.
164
+ * @param {DataModel} dataModel - The `dataModel` parameter in the `getDefaultQuoteValues` function
165
+ * represents the data model used in the context of generating default values for a quote.
166
+ * @returns The `getDefaultQuoteValues` function returns an object with properties `default` and
167
+ * `advanced`.
168
+ */
67
169
  export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel: ProductConfig, dataModel: DataModel) => {
68
170
  default: {
69
171
  expirationTime?: string | undefined;
@@ -79,25 +181,17 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
79
181
  delinquencyPlanName: string | undefined;
80
182
  autoRenewalPlanName: string | undefined;
81
183
  };
184
+ coverageTerms: Record<string, string>;
82
185
  };
83
186
 
84
- export declare const getQuoteElementRequest: ({ formData, locator, }: GetQuoteElementRequestAttributes) => QuoteRequest;
85
-
86
- declare type GetQuoteElementRequestAttributes = {
87
- formData: {
88
- [key: string]: unknown;
89
- };
90
- locator: string;
91
- };
92
-
93
- export declare const getQuoteRequest: ({ data }: QuoteFormData) => QuoteRequest;
94
-
95
187
  /**
96
- * Takes an element type and splits the postfix scope from the base model name. E.g., 'PersonalAutoQuote' becomes ['PersonalAuto', 'Quote']
97
- * @param elementType The element type to parse, e.g. `element.type` from an `ElementResponse`
98
- * @returns [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null]
188
+ * The function `getQuoteRequest` processes form data to create a `QuoteRequest` object.
189
+ * @param {QuoteFormData} - The `getQuoteRequest` function takes in a parameter `data` of type
190
+ * `QuoteFormData` and returns a `QuoteRequest` object.
191
+ * @returns The function `getQuoteRequest` returns a `QuoteRequest` object based on the provided
192
+ * `QuoteFormData` data.
99
193
  */
100
- export declare const parseElementTypeAndScopeByElementType: (elementType: string) => [elementName: string, scope: "Quote" | "QuickQuote" | "Policy" | null];
194
+ export declare const getQuoteRequest: ({ data }: QuoteFormData) => QuoteRequest;
101
195
 
102
196
  declare type ProductElement = Record<string, ElementConfig>;
103
197
 
@@ -124,50 +218,24 @@ declare interface QuoteFormData {
124
218
  durationBasis?: string;
125
219
  delinquencyPlanName?: string;
126
220
  };
221
+ coverageTerms?: {
222
+ [key: string]: string;
223
+ };
127
224
  [key: string]: any;
128
225
  };
129
226
  }
130
227
 
131
228
  /**
132
- * Looks through a data model for a matching element type and returns the element model
133
- * @param element The element to retrieve the data model for
134
- * @param dataModel The full resolved data model to search
135
- * @returns ElementConfig
136
- */
137
- export declare function retrieveDataModelFromElement(element: ElementResponse, dataModel: DataModel): {
138
- displayName?: string | undefined;
139
- abstract?: boolean | undefined;
140
- extend?: string | undefined;
141
- data?: Record<string, {
142
- options?: string[] | undefined;
143
- type?: string | undefined;
144
- displayName?: string | undefined;
145
- defaultValue?: string | undefined;
146
- minLength?: number | undefined;
147
- maxLength?: number | undefined;
148
- regex?: string | undefined;
149
- min?: string | undefined;
150
- multiline?: boolean | undefined;
151
- max?: string | undefined;
152
- overrides?: string | undefined;
153
- scope?: string | undefined;
154
- inherited?: boolean | undefined;
155
- precision?: number | undefined;
156
- readOnly?: boolean | undefined;
157
- }> | undefined;
158
- contents?: string[] | undefined;
159
- coverageTerms?: string[] | undefined;
160
- charges?: string[] | undefined;
161
- };
162
-
163
- /**
164
- * Takes the root element of a quote and a locator and returns the element with the matching locator
165
- * @param quoteElement The root element from the QuoteResponse
166
- * @param locator The locator of the element to retrieve
167
- * @returns ElementResponse | undefined
229
+ * The function `splitInputAndQuantifier` takes a string input, removes certain characters from it, and
230
+ * extracts a quantifier if present.
231
+ * @param {string | undefined} input - The `splitInputAndQuantifier` function takes a string input and
232
+ * splits it into two parts: the name and the quantifier. The quantifier is extracted from the end of
233
+ * the input string, while the name is the input string with certain characters (? * ! +) removed.
234
+ * @returns The function `splitInputAndQuantifier` returns an object with two properties:
235
+ * - `name`: a string that is the input with any of the characters '?', '*', '!', or '+' removed
236
+ * - `quantifier`: a string that represents the quantifier found at the end of the input string, or an
237
+ * empty string if no quantifier is found
168
238
  */
169
- export declare function retrieveElementFromQuoteByLocator(quoteElement: ElementResponse, locator: string): ElementResponse | undefined;
170
-
171
239
  export declare const splitInputAndQuantifier: (input: string | undefined) => {
172
240
  name: string;
173
241
  quantifier: "" | "*" | "?" | "+" | "!";