@plyaz/core 1.9.7 → 1.10.0

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.
@@ -1,5 +1,5 @@
1
1
  import { HTTP_STATUS as HTTP_STATUS$1, CACHE_MAX_SIZE_DEFAULT, CACHE_CLEANUP_INTERVAL_DEFAULT, TIME_CONSTANTS, DEVELOPMENT_CONFIG, STAGING_CONFIG, PRODUCTION_CONFIG, MATH_CONSTANTS, ISO_STANDARDS, FNV_CONSTANTS } from '@plyaz/config';
2
- import { HTTP_STATUS, ERROR_CATEGORY, ERROR_CODES, CORE_EVENTS, PACKAGE_STATUS_CODES, API_ERROR_CODES, OPERATIONS, BACKEND_RUNTIMES, FRONTEND_RUNTIMES } from '@plyaz/types';
2
+ import { HTTP_STATUS, ERROR_CATEGORY, ERROR_CODES, CORE_EVENTS, PACKAGE_STATUS_CODES, API_ERROR_CODES, OPERATIONS, BACKEND_RUNTIMES, UNIVERSAL_RUNTIMES, FRONTEND_RUNTIMES } from '@plyaz/types';
3
3
  import { generateRequestId, CorePackageError, BaseError, initializeErrorSystem, ValidateAndFormatErrors, ValidationError } from '@plyaz/errors';
4
4
  import { PackageLogger } from '@plyaz/logger';
5
5
  import { mergeConfigs, createApiClient, ApiPackageError, setDefaultApiClient, evaluateAllFeatureFlags, createFeatureFlag, updateFeatureFlag, deleteFeatureFlag, fetchFeatureFlagRules, ApiProvider as ApiProvider$1 } from '@plyaz/api/frontend';
@@ -2081,10 +2081,10 @@ var ServiceRegistry = class _ServiceRegistry {
2081
2081
  const dedicatedDb = config.dedicatedDb;
2082
2082
  const isDedicated = dedicatedDb === true || typeof dedicatedDb === "object";
2083
2083
  const serviceKey = entry.service.serviceKey;
2084
- const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime);
2084
+ const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime) || UNIVERSAL_RUNTIMES.includes(_ServiceRegistry._runtime);
2085
2085
  if ((isDedicated || _ServiceRegistry._dbConfig) && !isBackendRuntime) {
2086
2086
  _ServiceRegistry.logger.warn(
2087
- `Service '${serviceKey}' is requesting database injection in '${_ServiceRegistry._runtime}' runtime. Database is only available in backend runtimes (${BACKEND_RUNTIMES.join(", ")}). This service will not have database access.`
2087
+ `Service '${serviceKey}' is requesting database injection in '${_ServiceRegistry._runtime}' runtime. Database is only available in backend runtimes (${BACKEND_RUNTIMES.join(", ")}) or universal runtimes (${UNIVERSAL_RUNTIMES.join(", ")}). This service will not have database access.`
2088
2088
  );
2089
2089
  return void 0;
2090
2090
  }
@@ -2197,10 +2197,10 @@ var ServiceRegistry = class _ServiceRegistry {
2197
2197
  const dedicatedStorage = config.dedicatedStorage;
2198
2198
  const isDedicated = dedicatedStorage === true || typeof dedicatedStorage === "object";
2199
2199
  const serviceKey = entry.service.serviceKey;
2200
- const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime);
2200
+ const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime) || UNIVERSAL_RUNTIMES.includes(_ServiceRegistry._runtime);
2201
2201
  if ((isDedicated || _ServiceRegistry._storageConfig) && !isBackendRuntime) {
2202
2202
  _ServiceRegistry.logger.warn(
2203
- `Service '${serviceKey}' is requesting storage injection in '${_ServiceRegistry._runtime}' runtime. Storage is only available in backend runtimes (${BACKEND_RUNTIMES.join(", ")}). This service will not have storage access.`
2203
+ `Service '${serviceKey}' is requesting storage injection in '${_ServiceRegistry._runtime}' runtime. Storage is only available in backend runtimes (${BACKEND_RUNTIMES.join(", ")}) or universal runtimes (${UNIVERSAL_RUNTIMES.join(", ")}). This service will not have storage access.`
2204
2204
  );
2205
2205
  return void 0;
2206
2206
  }
@@ -2249,10 +2249,10 @@ var ServiceRegistry = class _ServiceRegistry {
2249
2249
  const dedicatedNotifications = config.dedicatedNotifications;
2250
2250
  const isDedicated = dedicatedNotifications === true || typeof dedicatedNotifications === "object";
2251
2251
  const serviceKey = entry.service.serviceKey;
2252
- const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime);
2252
+ const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime) || UNIVERSAL_RUNTIMES.includes(_ServiceRegistry._runtime);
2253
2253
  if ((isDedicated || _ServiceRegistry._notificationsConfig) && !isBackendRuntime) {
2254
2254
  _ServiceRegistry.logger.warn(
2255
- `Service '${serviceKey}' is requesting notifications injection in '${_ServiceRegistry._runtime}' runtime. Notifications is only available in backend runtimes (${BACKEND_RUNTIMES.join(", ")}). This service will not have notifications access.`
2255
+ `Service '${serviceKey}' is requesting notifications injection in '${_ServiceRegistry._runtime}' runtime. Notifications is only available in backend runtimes (${BACKEND_RUNTIMES.join(", ")}) or universal runtimes (${UNIVERSAL_RUNTIMES.join(", ")}). This service will not have notifications access.`
2256
2256
  );
2257
2257
  return void 0;
2258
2258
  }
@@ -7249,11 +7249,13 @@ var FilesMapper = new FilesMapperClass();
7249
7249
  var logger4 = new PackageLogger({ packageName: "core", service: "FrontendFilesDomainService" });
7250
7250
  var FrontendFilesDomainService = class _FrontendFilesDomainService extends BaseFrontendDomainService {
7251
7251
  constructor(config = {}, options) {
7252
+ const apiBasePath = config.apiBasePath || "/api";
7252
7253
  super({
7253
7254
  serviceName: "FrontendFilesDomainService",
7254
7255
  supportedRuntimes: ["frontend"],
7255
7256
  serviceConfig: {
7256
7257
  enabled: true,
7258
+ apiBasePath,
7257
7259
  responseDataKey: "data",
7258
7260
  ...config,
7259
7261
  // Configure fetchers for CRUD operations
@@ -7287,7 +7289,6 @@ var FrontendFilesDomainService = class _FrontendFilesDomainService extends BaseF
7287
7289
  injected: options?.injected
7288
7290
  });
7289
7291
  this.eventPrefix = "files";
7290
- this.primaryStoreKey = STORE_KEYS.FILES;
7291
7292
  }
7292
7293
  static {
7293
7294
  __name(this, "FrontendFilesDomainService");
@@ -7295,9 +7296,25 @@ var FrontendFilesDomainService = class _FrontendFilesDomainService extends BaseF
7295
7296
  static {
7296
7297
  this.serviceKey = "files-frontend";
7297
7298
  }
7299
+ static {
7300
+ /**
7301
+ * Primary store key for this service.
7302
+ * Used by ServiceRegistry to auto-inject the store.
7303
+ * Must be static for base class constructor to access.
7304
+ */
7305
+ this.primaryStoreKey = STORE_KEYS.FILES;
7306
+ }
7298
7307
  static async create(config = {}, options) {
7299
7308
  this.registerEventHandlers();
7300
- return new _FrontendFilesDomainService(config, options);
7309
+ const mergedConfig = {
7310
+ ...config,
7311
+ // Use || instead of ?? because api.baseURL may be '' (empty string) for same-origin requests.
7312
+ // The ?? operator only falls through on null/undefined, not empty strings.
7313
+ // An empty string is not a valid API path, so we treat it as "not provided" and fall through to default.
7314
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
7315
+ apiBasePath: config.apiBasePath || options?.apiClient?.options?.baseURL || "/api"
7316
+ };
7317
+ return new _FrontendFilesDomainService(mergedConfig, options);
7301
7318
  }
7302
7319
  isAvailable() {
7303
7320
  return this.isServiceEnabled && typeof window !== "undefined";