@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.
package/dist/index.mjs CHANGED
@@ -4918,20 +4918,37 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
4918
4918
  return storeState;
4919
4919
  }
4920
4920
  /**
4921
- * Sync multiple entities to store using mapper.toStoreStateList.
4922
- * Converts entities to store format and syncs via setData (full replacement).
4921
+ * Sync multiple entities to store.
4922
+ * Uses storeDataKey config to wrap entities in the correct structure.
4923
4923
  *
4924
4924
  * @param entities - Entities to sync
4925
4925
  * @returns Array of converted store states
4926
4926
  */
4927
4927
  syncEntitiesToStore(entities) {
4928
4928
  const storeStates = entities.map((entity) => this.mapper.toStoreState(entity));
4929
- if (this._primaryStore && !this.storeHandlers?.disabled && this.mapper.toStoreStateList) {
4930
- const storeData = this.mapper.toStoreStateList(entities);
4929
+ if (this._primaryStore && !this.storeHandlers?.disabled) {
4930
+ const storeDataKey = this.config.storeDataKey ?? "items";
4931
+ const storeData = this.buildNestedObject(storeDataKey, entities);
4931
4932
  this.syncToStores(storeData, true);
4932
4933
  }
4933
4934
  return storeStates;
4934
4935
  }
4936
+ /**
4937
+ * Build a nested object from a dot-notation key path.
4938
+ * @example buildNestedObject('items', data) => { items: data }
4939
+ * @example buildNestedObject('nested.items', data) => { nested: { items: data } }
4940
+ */
4941
+ buildNestedObject(keyPath, value) {
4942
+ const keys = keyPath.split(".");
4943
+ const result = {};
4944
+ let current = result;
4945
+ for (let i = 0; i < keys.length - 1; i++) {
4946
+ current[keys[i]] = {};
4947
+ current = current[keys[i]];
4948
+ }
4949
+ current[keys[keys.length - 1]] = value;
4950
+ return result;
4951
+ }
4935
4952
  /**
4936
4953
  * Remove entity from store by ID.
4937
4954
  * Priority: storeHandlers.removeData > store.removeData
@@ -12930,6 +12947,8 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
12930
12947
  responseErrorKey: "error",
12931
12948
  // Unwrap SuccessResponseStandard: extract 'data' from response.data
12932
12949
  responseDataKey: "data",
12950
+ // Store data key: wrap entities as { items: [...] } for store.setData()
12951
+ storeDataKey: "items",
12933
12952
  // Fetchers - using apiClient directly for testing/example purposes
12934
12953
  // In production, these would be imported from @plyaz/api services
12935
12954
  // Note: Validation is handled by validator class, mapping by mapper class
@@ -15036,6 +15055,7 @@ var frontend_exports = {};
15036
15055
  __export(frontend_exports, {
15037
15056
  ApiProvider: () => ApiProvider,
15038
15057
  BaseFrontendDomainService: () => BaseFrontendDomainService,
15058
+ Core: () => Core,
15039
15059
  FrontendExampleDomainService: () => FrontendExampleDomainService,
15040
15060
  FrontendFeatureFlagDomainService: () => FrontendFeatureFlagDomainService,
15041
15061
  InitializationError: () => InitializationError,
@@ -15057,6 +15077,7 @@ __export(frontend_exports, {
15057
15077
  useHasService: () => useHasService,
15058
15078
  usePlyaz: () => usePlyaz,
15059
15079
  usePlyazReady: () => usePlyazReady,
15080
+ useRootStore: () => useRootStore,
15060
15081
  useService: () => useService,
15061
15082
  useServiceAsync: () => useServiceAsync,
15062
15083
  useServiceKeys: () => useServiceKeys,