@plyaz/core 1.9.0 → 1.9.2

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.
@@ -4699,20 +4699,37 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
4699
4699
  return storeState;
4700
4700
  }
4701
4701
  /**
4702
- * Sync multiple entities to store using mapper.toStoreStateList.
4703
- * Converts entities to store format and syncs via setData (full replacement).
4702
+ * Sync multiple entities to store.
4703
+ * Uses storeDataKey config to wrap entities in the correct structure.
4704
4704
  *
4705
4705
  * @param entities - Entities to sync
4706
4706
  * @returns Array of converted store states
4707
4707
  */
4708
4708
  syncEntitiesToStore(entities) {
4709
4709
  const storeStates = entities.map((entity) => this.mapper.toStoreState(entity));
4710
- if (this._primaryStore && !this.storeHandlers?.disabled && this.mapper.toStoreStateList) {
4711
- const storeData = this.mapper.toStoreStateList(entities);
4710
+ if (this._primaryStore && !this.storeHandlers?.disabled) {
4711
+ const storeDataKey = this.config.storeDataKey ?? "items";
4712
+ const storeData = this.buildNestedObject(storeDataKey, entities);
4712
4713
  this.syncToStores(storeData, true);
4713
4714
  }
4714
4715
  return storeStates;
4715
4716
  }
4717
+ /**
4718
+ * Build a nested object from a dot-notation key path.
4719
+ * @example buildNestedObject('items', data) => { items: data }
4720
+ * @example buildNestedObject('nested.items', data) => { nested: { items: data } }
4721
+ */
4722
+ buildNestedObject(keyPath, value) {
4723
+ const keys = keyPath.split(".");
4724
+ const result = {};
4725
+ let current = result;
4726
+ for (let i = 0; i < keys.length - 1; i++) {
4727
+ current[keys[i]] = {};
4728
+ current = current[keys[i]];
4729
+ }
4730
+ current[keys[keys.length - 1]] = value;
4731
+ return result;
4732
+ }
4716
4733
  /**
4717
4734
  * Remove entity from store by ID.
4718
4735
  * Priority: storeHandlers.removeData > store.removeData
@@ -6309,6 +6326,8 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
6309
6326
  responseErrorKey: "error",
6310
6327
  // Unwrap SuccessResponseStandard: extract 'data' from response.data
6311
6328
  responseDataKey: "data",
6329
+ // Store data key: wrap entities as { items: [...] } for store.setData()
6330
+ storeDataKey: "items",
6312
6331
  // Fetchers - using apiClient directly for testing/example purposes
6313
6332
  // In production, these would be imported from @plyaz/api services
6314
6333
  // Note: Validation is handled by validator class, mapping by mapper class
@@ -8373,6 +8392,7 @@ exports.InitializationError = InitializationError;
8373
8392
  exports.InitializationLoading = InitializationLoading;
8374
8393
  exports.PlyazContext = PlyazContext;
8375
8394
  exports.PlyazProvider = PlyazProvider;
8395
+ exports.ServiceRegistry = ServiceRegistry;
8376
8396
  exports.camelToSnake = camelToSnake;
8377
8397
  exports.createFeatureFlagFetcher = createFeatureFlagFetcher;
8378
8398
  exports.createFeatureFlagStoreConfig = createFeatureFlagStoreConfig;