@socotra/ec-react-utils 2.22.0 → 2.23.0-next.0

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/README.md CHANGED
@@ -72,6 +72,7 @@ Follow instructions in the `ec-react/packages/docs/README.md` file to build the
72
72
  | `extractElementsFromQuote` | Extracts all elements from a quote's exposures. | `Element[]` |
73
73
  | `extractElementsFromTransactionSegment` | Extracts all elements from a transaction segment's exposures. | `Element[]` |
74
74
  | `extractProductDataModel` | Extracts the data model for a specific product from a policy or quote. | `object` or `undefined` |
75
+ | `extractProductElementMap` | Extracts a flat map of element configurations for a given contents array from a product. | `Record<string, ElementConfig>` |
75
76
  | `extractProductElements` | Extracts all elements associated with a product from a policy or quote. | `Element[]` |
76
77
  | `shouldEvaluateConstraints` | Checks if the constraints should be evaluated based on the original and new data. | `boolean` |
77
78
 
@@ -132,4 +133,4 @@ Run `pnpm run sync` to update the documentation in the `README.md` files of this
132
133
 
133
134
  Run `pnpm run build` to build the documentation for the `Socotra Documentation` repo.
134
135
 
135
- Follow instructions in the `ec-react/packages/docs/README.md` file to build the documentation and update the `Socotra Documentation` repo.
136
+ Follow instructions in the `ec-react/packages/docs/README.md` file to build the documentation and update the `Socotra Documentation` repo.
package/dist/index.d.ts CHANGED
@@ -289,6 +289,21 @@ export declare const extractProductDataModel: ({ dataModel, element: { productNa
289
289
  dataModel: DataModel;
290
290
  }) => ProductConfig;
291
291
 
292
+ /**
293
+ * `extractProductElementMap` creates a map of product element keys to their corresponding ElementConfig objects.
294
+ * This function recursively extracts product elements (coverages, exposure groups, exposures, policy lines)
295
+ * from the provided data model and contents, and builds a flat map of all elements and their sub-elements.
296
+ *
297
+ * @param {Object} params - The parameters for creating the product element map.
298
+ * @param {DataModel} params.dataModel - The data model for the tenant
299
+ * @param {string[]} params.contents - The list of product element keys to extract elements from.
300
+ * @returns {ProductElementMap} A map where each key is an element identifier and the value is its ElementConfig.
301
+ */
302
+ export declare const extractProductElementMap: ({ dataModel, contents, }: {
303
+ dataModel: DataModel;
304
+ contents: string[];
305
+ }) => ProductElementMap_2;
306
+
292
307
  /**
293
308
  * The function `extractProductElements` extracts specific elements from a data model based on a
294
309
  * product data model configuration.
@@ -579,6 +594,8 @@ declare interface ProductElementMap {
579
594
  exposureGroups: ProductElement;
580
595
  }
581
596
 
597
+ declare type ProductElementMap_2 = Map<string, ElementConfig>;
598
+
582
599
  declare interface QuoteFormData {
583
600
  data: {
584
601
  [key: string]: any;