@plyaz/core 1.8.1 → 1.8.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.
@@ -2002,10 +2002,16 @@ var ServiceRegistry = class _ServiceRegistry {
2002
2002
  return initPromise;
2003
2003
  }
2004
2004
  /** Build stores for service injection */
2005
- static buildStoresForService(config) {
2005
+ // eslint-disable-next-line complexity
2006
+ static buildStoresForService(config, entry) {
2006
2007
  const allKeys = /* @__PURE__ */ new Set();
2007
2008
  if (config.store) {
2008
2009
  allKeys.add(config.store);
2010
+ } else if ("primaryStoreKey" in entry.service && typeof entry.service.primaryStoreKey === "string") {
2011
+ allKeys.add(entry.service.primaryStoreKey);
2012
+ _ServiceRegistry.logger.debug(
2013
+ `Auto-resolved store key '${entry.service.primaryStoreKey}' from service class`
2014
+ );
2009
2015
  }
2010
2016
  if (config.readStores) {
2011
2017
  config.readStores.forEach((key) => allKeys.add(key));
@@ -2043,7 +2049,7 @@ var ServiceRegistry = class _ServiceRegistry {
2043
2049
  const observability = _ServiceRegistry.buildObservabilityConfig(config, entry);
2044
2050
  const storage = await _ServiceRegistry.buildStorageConfig(config, entry);
2045
2051
  const notifications = await _ServiceRegistry.buildNotificationsConfig(config, entry);
2046
- const stores = _ServiceRegistry.buildStoresForService(config);
2052
+ const stores = _ServiceRegistry.buildStoresForService(config, entry);
2047
2053
  let observabilityInstance = observability?.instance;
2048
2054
  if (observability?.dedicated && observability.config) {
2049
2055
  observabilityInstance = await _ServiceRegistry.createDedicatedObservability(
@@ -3572,6 +3578,13 @@ var Core = class _Core {
3572
3578
  /** Create fetch flags function */
3573
3579
  static createFetchFlagsFn(config, verbose) {
3574
3580
  return async () => {
3581
+ if (config?.provider !== "api") {
3582
+ _Core.log(
3583
+ `Feature flags using ${config?.provider ?? "default"} provider (no API fetch)`,
3584
+ verbose
3585
+ );
3586
+ return config?.defaults ?? {};
3587
+ }
3575
3588
  try {
3576
3589
  const client = ApiClientService.getClient();
3577
3590
  const endpoint = config?.apiEndpoint ?? "/feature-flags";
@@ -3591,6 +3604,7 @@ var Core = class _Core {
3591
3604
  /**
3592
3605
  * Initialize feature flags slice within root store
3593
3606
  */
3607
+ // eslint-disable-next-line complexity
3594
3608
  static async initializeFeatureFlags(config, verbose) {
3595
3609
  if (config?.enabled === false) {
3596
3610
  _Core.log("Feature flags disabled by configuration", verbose);
@@ -3603,11 +3617,16 @@ var Core = class _Core {
3603
3617
  );
3604
3618
  }
3605
3619
  _Core._flagConfig = config ?? {};
3606
- _Core.log("Initializing feature flags from root store...", verbose);
3620
+ const isApiProvider = config?.provider === "api";
3621
+ _Core.log(
3622
+ `Initializing feature flags from root store (provider: ${config?.provider ?? "default"})...`,
3623
+ verbose
3624
+ );
3607
3625
  const state = _Core._rootStore.getState();
3608
3626
  await state.featureFlags.initialize({
3609
3627
  defaults: _Core._flagConfig.defaults,
3610
- polling: _Core._flagConfig.polling,
3628
+ // Only enable polling for API provider
3629
+ polling: isApiProvider ? _Core._flagConfig.polling : void 0,
3611
3630
  fetchFn: _Core.createFetchFlagsFn(_Core._flagConfig, verbose),
3612
3631
  onFlagChange: _Core._flagConfig.onFlagChange,
3613
3632
  onError: _Core._flagConfig.onError