@socotra/ec-react-utils 2.3.0-next.3 → 2.3.0-next.5
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 +53 -76
- package/dist/index.es.js +408 -368
- 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
|
@@ -10,15 +10,6 @@ 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
|
-
*/
|
|
22
13
|
export declare const dataModelToJSONSchema: (args: DataModelToJsonSchemaProps) => JsonSchema7;
|
|
23
14
|
|
|
24
15
|
declare interface DataModelToJsonSchemaProps {
|
|
@@ -31,29 +22,12 @@ declare interface DataModelToJsonSchemaProps {
|
|
|
31
22
|
element?: ElementResponse;
|
|
32
23
|
}
|
|
33
24
|
|
|
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
|
-
* @returns The function `extractElementDataModel` returns either an `ElementConfig` object or `false`
|
|
39
|
-
* based on the provided parameters and data model.
|
|
40
|
-
*/
|
|
41
25
|
export declare const extractElementDataModel: ({ dataModel, quote, elementLocator, }: {
|
|
42
26
|
quote: QuoteResponse;
|
|
43
27
|
dataModel: DataModel;
|
|
44
28
|
elementLocator: string;
|
|
45
29
|
}) => ElementConfig | false;
|
|
46
30
|
|
|
47
|
-
/**
|
|
48
|
-
* The function `extractElementFromQuote` takes a `QuoteResponse` object and an element locator string,
|
|
49
|
-
* and returns the element with the matching locator from the quote or its nested elements.
|
|
50
|
-
* @param {QuoteResponse} quote - The `quote` parameter is of type `QuoteResponse`, which is an object
|
|
51
|
-
* containing information about a quote.
|
|
52
|
-
* @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
|
|
53
|
-
* locator of the element you want to extract from the `quote` object.
|
|
54
|
-
* @returns The function `extractElementFromQuote` returns the element from the `QuoteResponse` object
|
|
55
|
-
* that matches the provided `elementLocator`.
|
|
56
|
-
*/
|
|
57
31
|
export declare const extractElementFromQuote: (quote: QuoteResponse, elementLocator: string) => false | ({
|
|
58
32
|
locator: string;
|
|
59
33
|
type: string;
|
|
@@ -76,13 +50,6 @@ export declare const extractElementFromQuote: (quote: QuoteResponse, elementLoca
|
|
|
76
50
|
} & any)[];
|
|
77
51
|
});
|
|
78
52
|
|
|
79
|
-
/**
|
|
80
|
-
* The function `extractProductDataModel` extracts product data model based on the product name from a
|
|
81
|
-
* given data model.
|
|
82
|
-
* @param - The `extractProductDataModel` function takes in two parameters:
|
|
83
|
-
* @returns The function `extractProductDataModel` returns the product configuration data for the
|
|
84
|
-
* specified product name from the provided data model.
|
|
85
|
-
*/
|
|
86
53
|
export declare const extractProductDataModel: ({ dataModel, element: { productName }, }: {
|
|
87
54
|
element: {
|
|
88
55
|
productName: string;
|
|
@@ -90,41 +57,13 @@ export declare const extractProductDataModel: ({ dataModel, element: { productNa
|
|
|
90
57
|
dataModel: DataModel;
|
|
91
58
|
}) => ProductConfig;
|
|
92
59
|
|
|
93
|
-
/**
|
|
94
|
-
* The function `extractProductElements` extracts specific elements from a data model based on a
|
|
95
|
-
* product data model configuration.
|
|
96
|
-
* @param - The `extractProductElements` function takes in two parameters:
|
|
97
|
-
* @returns The function `extractProductElements` returns a `ProductElementMap` object containing
|
|
98
|
-
* elements related to coverages, exposures, policy lines, and exposure groups that are available based
|
|
99
|
-
* on the provided `dataModel` and `productDataModel`.
|
|
100
|
-
*/
|
|
101
60
|
export declare const extractProductElements: ({ dataModel, productDataModel, }: {
|
|
102
61
|
dataModel: DataModel;
|
|
103
62
|
productDataModel: ProductConfig;
|
|
104
63
|
}) => ProductElementMap;
|
|
105
64
|
|
|
106
|
-
/**
|
|
107
|
-
* The function `getDefaultElementValues` returns a partial copy of an ElementResponse object with
|
|
108
|
-
* default values for coverageTerms if not provided.
|
|
109
|
-
* @param {ElementResponse} element - The `element` parameter in the `getDefaultElementValues` function
|
|
110
|
-
* is of type `ElementResponse`, which contains data related to an element in a system or
|
|
111
|
-
* application.
|
|
112
|
-
* @returns A partial ElementResponse object is being returned, with the data from the input element
|
|
113
|
-
* and the coverageTerms property set to element.coverageTerms if it exists, otherwise an empty object.
|
|
114
|
-
*/
|
|
115
65
|
export declare const getDefaultElementValues: (element: ElementResponse) => Partial<ElementResponse>;
|
|
116
66
|
|
|
117
|
-
/**
|
|
118
|
-
* The `getDefaultQuoteValues` function extracts default values from a `QuoteResponse`
|
|
119
|
-
* object and sets them based on certain conditions.
|
|
120
|
-
* @param {QuoteResponse} quote - The `getDefaultQuoteValues` function takes in three parameters:
|
|
121
|
-
* @param {ProductConfig} productModel - The `productModel` parameter in the `getDefaultQuoteValues`
|
|
122
|
-
* function represents the configuration settings for a specific product.
|
|
123
|
-
* @param {DataModel} dataModel - The `dataModel` parameter in the `getDefaultQuoteValues` function
|
|
124
|
-
* represents the data model used in the context of generating default values for a quote.
|
|
125
|
-
* @returns The `getDefaultQuoteValues` function returns an object with properties `default` and
|
|
126
|
-
* `advanced`.
|
|
127
|
-
*/
|
|
128
67
|
export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel: ProductConfig, dataModel: DataModel) => {
|
|
129
68
|
default: {
|
|
130
69
|
expirationTime?: string | undefined;
|
|
@@ -142,14 +81,23 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
|
|
|
142
81
|
};
|
|
143
82
|
};
|
|
144
83
|
|
|
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
|
+
|
|
145
95
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param
|
|
148
|
-
*
|
|
149
|
-
* @returns The function `getQuoteRequest` returns a `QuoteRequest` object based on the provided
|
|
150
|
-
* `QuoteFormData` data.
|
|
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]
|
|
151
99
|
*/
|
|
152
|
-
export declare const
|
|
100
|
+
export declare const parseElementTypeAndScopeByElementType: (elementType: string) => [elementName: string, scope: "Quote" | "QuickQuote" | "Policy" | null];
|
|
153
101
|
|
|
154
102
|
declare type ProductElement = Record<string, ElementConfig>;
|
|
155
103
|
|
|
@@ -181,16 +129,45 @@ declare interface QuoteFormData {
|
|
|
181
129
|
}
|
|
182
130
|
|
|
183
131
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @param
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
|
193
168
|
*/
|
|
169
|
+
export declare function retrieveElementFromQuoteByLocator(quoteElement: ElementResponse, locator: string): ElementResponse | undefined;
|
|
170
|
+
|
|
194
171
|
export declare const splitInputAndQuantifier: (input: string | undefined) => {
|
|
195
172
|
name: string;
|
|
196
173
|
quantifier: "" | "*" | "?" | "+" | "!";
|