@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.
@@ -83,6 +83,7 @@
83
83
  * ```
84
84
  */
85
85
  import { type ReactElement } from 'react';
86
+ import { useRootStore } from '@plyaz/store';
86
87
  import { Core } from '../../init/CoreInitializer';
87
88
  import { ApiClientService } from '../../services/ApiClientService';
88
89
  import { CoreEventManager } from '../../events/CoreEventManager';
@@ -302,4 +303,6 @@ export declare function useHasService(key: string): boolean;
302
303
  */
303
304
  export declare function useServiceKeys(): string[];
304
305
  export { PlyazContext };
306
+ export { Core };
307
+ export { useRootStore };
305
308
  //# sourceMappingURL=PlyazProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlyazProvider.d.ts","sourceRoot":"","sources":["../../../src/frontend/providers/PlyazProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AAIH,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAIlB,qBAAqB,EACrB,sBAAsB,IAAI,kBAAkB,EAC5C,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAU3B;;;GAGG;AACH,UAAU,iBAAkB,SAAQ,IAAI,CAAC,qBAAqB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACxF,0CAA0C;IAC1C,GAAG,EAAE,OAAO,gBAAgB,GAAG,IAAI,CAAC;IACpC,gCAAgC;IAChC,MAAM,EAAE,OAAO,gBAAg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B,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAGzC;AAMD,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -37414,20 +37414,37 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
37414
37414
  return storeState;
37415
37415
  }
37416
37416
  /**
37417
- * Sync multiple entities to store using mapper.toStoreStateList.
37418
- * Converts entities to store format and syncs via setData (full replacement).
37417
+ * Sync multiple entities to store.
37418
+ * Uses storeDataKey config to wrap entities in the correct structure.
37419
37419
  *
37420
37420
  * @param entities - Entities to sync
37421
37421
  * @returns Array of converted store states
37422
37422
  */
37423
37423
  syncEntitiesToStore(entities) {
37424
37424
  const storeStates = entities.map((entity) => this.mapper.toStoreState(entity));
37425
- if (this._primaryStore && !this.storeHandlers?.disabled && this.mapper.toStoreStateList) {
37426
- const storeData = this.mapper.toStoreStateList(entities);
37425
+ if (this._primaryStore && !this.storeHandlers?.disabled) {
37426
+ const storeDataKey = this.config.storeDataKey ?? "items";
37427
+ const storeData = this.buildNestedObject(storeDataKey, entities);
37427
37428
  this.syncToStores(storeData, true);
37428
37429
  }
37429
37430
  return storeStates;
37430
37431
  }
37432
+ /**
37433
+ * Build a nested object from a dot-notation key path.
37434
+ * @example buildNestedObject('items', data) => { items: data }
37435
+ * @example buildNestedObject('nested.items', data) => { nested: { items: data } }
37436
+ */
37437
+ buildNestedObject(keyPath, value) {
37438
+ const keys = keyPath.split(".");
37439
+ const result2 = {};
37440
+ let current = result2;
37441
+ for (let i = 0; i < keys.length - 1; i++) {
37442
+ current[keys[i]] = {};
37443
+ current = current[keys[i]];
37444
+ }
37445
+ current[keys[keys.length - 1]] = value;
37446
+ return result2;
37447
+ }
37431
37448
  /**
37432
37449
  * Remove entity from store by ID.
37433
37450
  * Priority: storeHandlers.removeData > store.removeData
@@ -45426,6 +45443,8 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
45426
45443
  responseErrorKey: "error",
45427
45444
  // Unwrap SuccessResponseStandard: extract 'data' from response.data
45428
45445
  responseDataKey: "data",
45446
+ // Store data key: wrap entities as { items: [...] } for store.setData()
45447
+ storeDataKey: "items",
45429
45448
  // Fetchers - using apiClient directly for testing/example purposes
45430
45449
  // In production, these would be imported from @plyaz/api services
45431
45450
  // Note: Validation is handled by validator class, mapping by mapper class
@@ -47565,6 +47584,7 @@ var frontend_exports = {};
47565
47584
  __export(frontend_exports, {
47566
47585
  ApiProvider: () => ApiProvider,
47567
47586
  BaseFrontendDomainService: () => BaseFrontendDomainService,
47587
+ Core: () => Core,
47568
47588
  FrontendExampleDomainService: () => FrontendExampleDomainService,
47569
47589
  FrontendFeatureFlagDomainService: () => FrontendFeatureFlagDomainService,
47570
47590
  InitializationError: () => InitializationError,
@@ -47586,6 +47606,7 @@ __export(frontend_exports, {
47586
47606
  useHasService: () => useHasService,
47587
47607
  usePlyaz: () => usePlyaz,
47588
47608
  usePlyazReady: () => usePlyazReady,
47609
+ useRootStore: () => store.useRootStore,
47589
47610
  useService: () => useService,
47590
47611
  useServiceAsync: () => useServiceAsync,
47591
47612
  useServiceKeys: () => useServiceKeys,