@plyaz/core 1.9.1 → 1.9.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.
@@ -4864,20 +4864,37 @@ var init_BaseFrontendDomainService = __esm({
4864
4864
  return storeState;
4865
4865
  }
4866
4866
  /**
4867
- * Sync multiple entities to store using mapper.toStoreStateList.
4868
- * Converts entities to store format and syncs via setData (full replacement).
4867
+ * Sync multiple entities to store.
4868
+ * Uses storeDataKey config to wrap entities in the correct structure.
4869
4869
  *
4870
4870
  * @param entities - Entities to sync
4871
4871
  * @returns Array of converted store states
4872
4872
  */
4873
4873
  syncEntitiesToStore(entities) {
4874
4874
  const storeStates = entities.map((entity) => this.mapper.toStoreState(entity));
4875
- if (this._primaryStore && !this.storeHandlers?.disabled && this.mapper.toStoreStateList) {
4876
- const storeData = this.mapper.toStoreStateList(entities);
4875
+ if (this._primaryStore && !this.storeHandlers?.disabled) {
4876
+ const storeDataKey = this.config.storeDataKey ?? "items";
4877
+ const storeData = this.buildNestedObject(storeDataKey, entities);
4877
4878
  this.syncToStores(storeData, true);
4878
4879
  }
4879
4880
  return storeStates;
4880
4881
  }
4882
+ /**
4883
+ * Build a nested object from a dot-notation key path.
4884
+ * @example buildNestedObject('items', data) => { items: data }
4885
+ * @example buildNestedObject('nested.items', data) => { nested: { items: data } }
4886
+ */
4887
+ buildNestedObject(keyPath, value) {
4888
+ const keys = keyPath.split(".");
4889
+ const result = {};
4890
+ let current = result;
4891
+ for (let i = 0; i < keys.length - 1; i++) {
4892
+ current[keys[i]] = {};
4893
+ current = current[keys[i]];
4894
+ }
4895
+ current[keys[keys.length - 1]] = value;
4896
+ return result;
4897
+ }
4881
4898
  /**
4882
4899
  * Remove entity from store by ID.
4883
4900
  * Priority: storeHandlers.removeData > store.removeData
@@ -7928,6 +7945,8 @@ var init_FrontendExampleDomainService = __esm({
7928
7945
  responseErrorKey: "error",
7929
7946
  // Unwrap SuccessResponseStandard: extract 'data' from response.data
7930
7947
  responseDataKey: "data",
7948
+ // Store data key: wrap entities as { items: [...] } for store.setData()
7949
+ storeDataKey: "items",
7931
7950
  // Fetchers - using apiClient directly for testing/example purposes
7932
7951
  // In production, these would be imported from @plyaz/api services
7933
7952
  // Note: Validation is handled by validator class, mapping by mapper class