@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 { TIME_CONSTANTS, FORMAT_CONSTANTS, FILE_CHECK_INTERVAL_DEFAULT, FEATURE_FLAG_CACHE_TTL_DEFAULT, FEATURE_FLAG_FILE_PATHS, FEATURE_FLAG_PROVIDERS, NUMERIC_CONSTANTS, HTTP_STATUS as HTTP_STATUS$1, DOWNLOAD_CONFIG, MATH_CONSTANTS, ISO_STANDARDS, CACHE_MAX_SIZE_DEFAULT, CACHE_CLEANUP_INTERVAL_DEFAULT, DEVELOPMENT_CONFIG, STAGING_CONFIG, PRODUCTION_CONFIG, FNV_CONSTANTS, FEATURES, HASH_SEED_CONSTANTS } from '@plyaz/config';
2
- import { ERROR_CODES as ERROR_CODES$1, HTTP_STATUS, NODE_ENVIRONMENTS, BACKEND_RUNTIMES, FRONTEND_RUNTIMES, ERROR_CATEGORY as ERROR_CATEGORY$1, CORE_EVENTS as CORE_EVENTS$1, PACKAGE_STATUS_CODES, API_ERROR_CODES, OPERATIONS, FEATURE_FLAG_PROVIDERS as FEATURE_FLAG_PROVIDERS$2, FEATURE_FLAG_METADATA } from '@plyaz/types';
2
+ import { ERROR_CODES as ERROR_CODES$1, HTTP_STATUS, NODE_ENVIRONMENTS, BACKEND_RUNTIMES, FRONTEND_RUNTIMES, UNIVERSAL_RUNTIMES, ERROR_CATEGORY as ERROR_CATEGORY$1, CORE_EVENTS as CORE_EVENTS$1, PACKAGE_STATUS_CODES, API_ERROR_CODES, OPERATIONS, FEATURE_FLAG_PROVIDERS as FEATURE_FLAG_PROVIDERS$2, FEATURE_FLAG_METADATA } from '@plyaz/types';
3
3
  import { EventEmitter } from 'events';
4
4
  import { evaluateAllFeatureFlags, createFeatureFlag, updateFeatureFlag, deleteFeatureFlag, fetchFeatureFlagRules, createApiClient, mergeConfigs, ApiPackageError, setDefaultApiClient } from '@plyaz/api/frontend';
5
5
  import { CorePackageError, StoragePackageError, NotificationPackageError, BaseError, DatabasePackageError, ValidationError, initializeErrorSystem, generateRequestId, ValidateAndFormatErrors, SuccessResponseStandard } from '@plyaz/errors';
@@ -2223,10 +2223,10 @@ var init_ServiceRegistry = __esm({
2223
2223
  const dedicatedDb = config.dedicatedDb;
2224
2224
  const isDedicated = dedicatedDb === true || typeof dedicatedDb === "object";
2225
2225
  const serviceKey = entry.service.serviceKey;
2226
- const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime);
2226
+ const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime) || UNIVERSAL_RUNTIMES.includes(_ServiceRegistry._runtime);
2227
2227
  if ((isDedicated || _ServiceRegistry._dbConfig) && !isBackendRuntime) {
2228
2228
  _ServiceRegistry.logger.warn(
2229
- `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.`
2229
+ `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.`
2230
2230
  );
2231
2231
  return void 0;
2232
2232
  }
@@ -2339,10 +2339,10 @@ var init_ServiceRegistry = __esm({
2339
2339
  const dedicatedStorage = config.dedicatedStorage;
2340
2340
  const isDedicated = dedicatedStorage === true || typeof dedicatedStorage === "object";
2341
2341
  const serviceKey = entry.service.serviceKey;
2342
- const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime);
2342
+ const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime) || UNIVERSAL_RUNTIMES.includes(_ServiceRegistry._runtime);
2343
2343
  if ((isDedicated || _ServiceRegistry._storageConfig) && !isBackendRuntime) {
2344
2344
  _ServiceRegistry.logger.warn(
2345
- `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.`
2345
+ `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.`
2346
2346
  );
2347
2347
  return void 0;
2348
2348
  }
@@ -2391,10 +2391,10 @@ var init_ServiceRegistry = __esm({
2391
2391
  const dedicatedNotifications = config.dedicatedNotifications;
2392
2392
  const isDedicated = dedicatedNotifications === true || typeof dedicatedNotifications === "object";
2393
2393
  const serviceKey = entry.service.serviceKey;
2394
- const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime);
2394
+ const isBackendRuntime = BACKEND_RUNTIMES.includes(_ServiceRegistry._runtime) || UNIVERSAL_RUNTIMES.includes(_ServiceRegistry._runtime);
2395
2395
  if ((isDedicated || _ServiceRegistry._notificationsConfig) && !isBackendRuntime) {
2396
2396
  _ServiceRegistry.logger.warn(
2397
- `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.`
2397
+ `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.`
2398
2398
  );
2399
2399
  return void 0;
2400
2400
  }
@@ -9200,11 +9200,13 @@ var init_FrontendFilesDomainService = __esm({
9200
9200
  logger4 = new PackageLogger({ packageName: "core", service: "FrontendFilesDomainService" });
9201
9201
  FrontendFilesDomainService = class _FrontendFilesDomainService extends BaseFrontendDomainService {
9202
9202
  constructor(config = {}, options) {
9203
+ const apiBasePath = config.apiBasePath || "/api";
9203
9204
  super({
9204
9205
  serviceName: "FrontendFilesDomainService",
9205
9206
  supportedRuntimes: ["frontend"],
9206
9207
  serviceConfig: {
9207
9208
  enabled: true,
9209
+ apiBasePath,
9208
9210
  responseDataKey: "data",
9209
9211
  ...config,
9210
9212
  // Configure fetchers for CRUD operations
@@ -9238,7 +9240,6 @@ var init_FrontendFilesDomainService = __esm({
9238
9240
  injected: options?.injected
9239
9241
  });
9240
9242
  this.eventPrefix = "files";
9241
- this.primaryStoreKey = STORE_KEYS.FILES;
9242
9243
  }
9243
9244
  static {
9244
9245
  __name(this, "FrontendFilesDomainService");
@@ -9246,9 +9247,25 @@ var init_FrontendFilesDomainService = __esm({
9246
9247
  static {
9247
9248
  this.serviceKey = "files-frontend";
9248
9249
  }
9250
+ static {
9251
+ /**
9252
+ * Primary store key for this service.
9253
+ * Used by ServiceRegistry to auto-inject the store.
9254
+ * Must be static for base class constructor to access.
9255
+ */
9256
+ this.primaryStoreKey = STORE_KEYS.FILES;
9257
+ }
9249
9258
  static async create(config = {}, options) {
9250
9259
  this.registerEventHandlers();
9251
- return new _FrontendFilesDomainService(config, options);
9260
+ const mergedConfig = {
9261
+ ...config,
9262
+ // Use || instead of ?? because api.baseURL may be '' (empty string) for same-origin requests.
9263
+ // The ?? operator only falls through on null/undefined, not empty strings.
9264
+ // An empty string is not a valid API path, so we treat it as "not provided" and fall through to default.
9265
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
9266
+ apiBasePath: config.apiBasePath || options?.apiClient?.options?.baseURL || "/api"
9267
+ };
9268
+ return new _FrontendFilesDomainService(mergedConfig, options);
9252
9269
  }
9253
9270
  isAvailable() {
9254
9271
  return this.isServiceEnabled && typeof window !== "undefined";