@socotra/ec-react-utils 2.6.3-next.2 → 2.6.3-next.3

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
@@ -45,6 +45,18 @@ declare interface DataModelToJsonSchemaProps {
45
45
  element?: ElementResponse;
46
46
  }
47
47
 
48
+ /**
49
+ * The function `extractElementFromElement takes a `QuoteResponse`, `SegmentResponse` or `ElementResponse` object and an element locator string,
50
+ * and returns the element with the matching locator from the quote or its nested elements.
51
+ * @param {QuoteResponse} quote - The `quote` parameter is of type `QuoteResponse`, which is an object
52
+ * containing information about a quote.
53
+ * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
54
+ * locator of the element you want to extract from the `quote` object.
55
+ * @returns The function `extractElementByLocator` returns the element from the response object
56
+ * that matches the provided `elementLocator`.
57
+ */
58
+ export declare const extractElementByLocator: <T extends ElementResponse>(response: QuoteResponse | SegmentResponse | ElementResponse, elementLocator: string) => T | null;
59
+
48
60
  /**
49
61
  * The function `extractElementDataModelFromQuote` extracts element data model based on a given quote, data
50
62
  * model, and element locator.
@@ -58,7 +70,7 @@ export declare const extractElementDataModelFromQuote: ({ dataModel, quote, elem
58
70
  quote: QuoteResponse;
59
71
  dataModel: DataModel;
60
72
  elementLocator: string;
61
- }) => ElementConfig | false;
73
+ }) => ElementConfig | null;
62
74
 
63
75
  /**
64
76
  * The function `extractElementDataModelFromSegment` extracts element data model based on a given segment, data
@@ -73,7 +85,7 @@ export declare const extractElementDataModelFromSegment: ({ dataModel, segment,
73
85
  segment: SegmentResponse;
74
86
  dataModel: DataModel;
75
87
  elementLocator: string;
76
- }) => ElementConfig | false;
88
+ }) => ElementConfig | null;
77
89
 
78
90
  /**
79
91
  * The function `extractElementDataModelFromType` extracts element data model given a data model and
@@ -83,112 +95,28 @@ export declare const extractElementDataModelFromSegment: ({ dataModel, segment,
83
95
  * @returns The function `extractElementDataModelFromType` returns either an `ElementConfig` object or `false`
84
96
  * based on the provided parameters and data model.
85
97
  */
86
- export declare const extractElementDataModelFromType: ({ dataModel, elementType, }: {
87
- dataModel: DataModel;
88
- elementType: string;
89
- }) => ElementConfig | false;
90
-
91
- /**
92
- * The function `extractElementFromQuote` takes a `QuoteResponse` object and an element locator string,
93
- * and returns the element with the matching locator from the quote or its nested elements.
94
- * @param {QuoteResponse} quote - The `quote` parameter is of type `QuoteResponse`, which is an object
95
- * containing information about a quote.
96
- * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
97
- * locator of the element you want to extract from the `quote` object.
98
- * @returns The function `extractElementFromQuote` returns the element from the `QuoteResponse` object
99
- * that matches the provided `elementLocator`.
100
- */
101
- export declare const extractElementFromQuote: (quote: QuoteResponse, elementLocator: string) => false | ({
102
- locator: string;
103
- type: string;
104
- staticLocator: string;
105
- data?: Record<string, any> | undefined;
106
- coverageTerms?: Record<string, string> | undefined;
107
- parentLocator?: string | undefined;
108
- rootLocator?: string | undefined;
109
- tenantLocator?: string | undefined;
110
- originalEffectiveTime?: string | undefined;
111
- } & {
112
- elements?: ({
113
- locator: string;
114
- type: string;
115
- staticLocator: string;
116
- data?: Record<string, any> | undefined;
117
- coverageTerms?: Record<string, string> | undefined;
118
- parentLocator?: string | undefined;
119
- rootLocator?: string | undefined;
120
- tenantLocator?: string | undefined;
121
- originalEffectiveTime?: string | undefined;
122
- } & any)[];
123
- });
124
-
125
- /**
126
- * The function `extractElementFromSegment` takes a `SegmentResponse` object and an element locator string,
127
- * and returns the element with the matching locator from the segment or its nested elements.
128
- * @param {SegmentResponse} segment - The `segment` parameter is of type `SegmentResponse`, which is an object
129
- * containing information about a segment.
130
- * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
131
- * locator of the element you want to extract from the `segment` object.
132
- * @returns The function `extractElementFromSegment` returns the element from the `SegmentResponse` object
133
- * that matches the provided `elementLocator`.
134
- */
135
- export declare const extractElementFromSegment: (segment: SegmentResponse, elementLocator: string) => false | ({
136
- locator: string;
137
- type: string;
138
- staticLocator: string;
139
- data?: Record<string, any> | undefined;
140
- coverageTerms?: Record<string, string> | undefined;
141
- parentLocator?: string | undefined;
142
- rootLocator?: string | undefined;
143
- tenantLocator?: string | undefined;
144
- originalEffectiveTime?: string | undefined;
145
- } & {
146
- elements?: ({
147
- locator: string;
148
- type: string;
149
- staticLocator: string;
150
- data?: Record<string, any> | undefined;
151
- coverageTerms?: Record<string, string> | undefined;
152
- parentLocator?: string | undefined;
153
- rootLocator?: string | undefined;
154
- tenantLocator?: string | undefined;
155
- originalEffectiveTime?: string | undefined;
156
- } & any)[];
157
- });
158
-
159
- /**
160
- * The function `extractElementFromTransactionSegment` takes a `SegmentResponse` object and an element locator string,
161
- * and returns the element with the matching locator from the segment or its nested elements.
162
- * @param {SegmentResponse} transactionSegment - The `transactionSegment` parameter is of type `SegmentResponse`, which is an object
163
- * containing information about a transaction.
164
- * @param {string} elementLocator - The `elementLocator` parameter is a string that represents the
165
- * locator of the element you want to extract from the `transactionSegment` object.
166
- * @returns The function `extractElementFromTransactionSegment` returns the element from the `SegmentResponse` object
167
- * that matches the provided `elementLocator`.
168
- */
169
- export declare const extractElementFromTransactionSegment: (transactionSegment: SegmentResponse, elementLocator: string) => false | ({
170
- locator: string;
171
- type: string;
172
- staticLocator: string;
173
- data?: Record<string, any> | undefined;
174
- coverageTerms?: Record<string, string> | undefined;
175
- parentLocator?: string | undefined;
176
- rootLocator?: string | undefined;
177
- tenantLocator?: string | undefined;
178
- originalEffectiveTime?: string | undefined;
179
- } & {
180
- elements?: ({
181
- locator: string;
182
- type: string;
183
- staticLocator: string;
184
- data?: Record<string, any> | undefined;
185
- coverageTerms?: Record<string, string> | undefined;
186
- parentLocator?: string | undefined;
187
- rootLocator?: string | undefined;
188
- tenantLocator?: string | undefined;
189
- originalEffectiveTime?: string | undefined;
190
- } & any)[];
191
- });
98
+ export declare const extractElementDataModelFromType: ExtractElementDataModelFromTypeInterface;
99
+
100
+ declare interface ExtractElementDataModelFromTypeInterface {
101
+ (props: {
102
+ dataModel: DataModel;
103
+ elementType: string;
104
+ resultType?: 'value';
105
+ }): ElementConfig | null;
106
+ (props: {
107
+ dataModel: DataModel;
108
+ elementType: string;
109
+ resultType?: 'all';
110
+ }): {
111
+ value: ElementConfig;
112
+ path: string;
113
+ } | null;
114
+ (props: {
115
+ dataModel: DataModel;
116
+ elementType: string;
117
+ resultType?: 'path';
118
+ }): string | null;
119
+ }
192
120
 
193
121
  export declare const extractElementsFromQuote: (elements: Array<ElementResponse>, elementType: string) => ({
194
122
  locator: string;
@@ -270,14 +198,6 @@ export declare const extractProductElements: ({ dataModel, contents, }: {
270
198
  contents: string[];
271
199
  }) => ProductElementMap;
272
200
 
273
- /**
274
- * `findElementInElementArray` is a utility function that takes an array of `ElementResponse` objects and an element locator string,
275
- * @param elements - The `elements` parameter is an array of `ElementResponse` objects.
276
- * @param elementLocator - The `elementLocator` parameter is a string that represents the locator of the element you want to extract from the `elements` array.
277
- * @returns
278
- */
279
- export declare const findElementInElementsArray: (elements: ElementResponse[], elementLocator: string) => ElementResponse | false;
280
-
281
201
  /**
282
202
  * The `getCoverageTermsDefaultValues` function extracts default coverage terms values from a
283
203
  * `CoverageTermsConfigRecord` object and sets them based on certain conditions.
@@ -366,6 +286,14 @@ export declare const getDefaultQuoteValues: (quote: QuoteResponse, productModel:
366
286
  coverageTerms: Record<string, string>;
367
287
  };
368
288
 
289
+ /**
290
+ * The function `getElementNameByType` returns the element name based on the element type and suffix.
291
+ * @param - - `elementType`: A string containing the element type.
292
+ * @param - - `suffix`: A string containing the suffix.
293
+ * @returns The function `getElementNameByType` returns the element name.
294
+ */
295
+ export declare const getElementNameByType: (elementType: string) => string;
296
+
369
297
  export declare const getElementTransactionUpdateRequestFromFormData: ({ data, elementResponse, locator, }: TransactionFormData) => {
370
298
  locator: string;
371
299
  removeCoverageTerms?: Record<string, unknown> | undefined;