@plyaz/core 1.8.0 → 1.8.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.
- package/dist/domain/base/BaseFrontendDomainService.d.ts +29 -1
- package/dist/domain/base/BaseFrontendDomainService.d.ts.map +1 -1
- package/dist/domain/example/FrontendExampleDomainService.d.ts +6 -4
- package/dist/domain/example/FrontendExampleDomainService.d.ts.map +1 -1
- package/dist/entry-backend.js +55 -11
- package/dist/entry-backend.js.map +1 -1
- package/dist/entry-backend.mjs +55 -11
- package/dist/entry-backend.mjs.map +1 -1
- package/dist/entry-frontend-browser.js +55 -11
- package/dist/entry-frontend-browser.js.map +1 -1
- package/dist/entry-frontend-browser.mjs +55 -11
- package/dist/entry-frontend-browser.mjs.map +1 -1
- package/dist/entry-frontend.js +55 -11
- package/dist/entry-frontend.js.map +1 -1
- package/dist/entry-frontend.mjs +55 -11
- package/dist/entry-frontend.mjs.map +1 -1
- package/dist/index.js +55 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -11
- package/dist/index.mjs.map +1 -1
- package/dist/init/ServiceRegistry.d.ts.map +1 -1
- package/dist/init/nestjs/index.js +9 -3
- package/dist/init/nestjs/index.js.map +1 -1
- package/dist/init/nestjs/index.mjs +9 -3
- package/dist/init/nestjs/index.mjs.map +1 -1
- package/dist/services/ApiClientService.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -422,7 +422,7 @@ function getConfigForEnvironment(env) {
|
|
|
422
422
|
}
|
|
423
423
|
__name(getConfigForEnvironment, "getConfigForEnvironment");
|
|
424
424
|
function validateBaseURL(mergedConfig, errors) {
|
|
425
|
-
if (
|
|
425
|
+
if (mergedConfig.baseURL === void 0 || mergedConfig.baseURL === null) {
|
|
426
426
|
errors.push("baseURL is required in API configuration (apiConfig parameter)");
|
|
427
427
|
}
|
|
428
428
|
}
|
|
@@ -2255,10 +2255,16 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2255
2255
|
return initPromise;
|
|
2256
2256
|
}
|
|
2257
2257
|
/** Build stores for service injection */
|
|
2258
|
-
|
|
2258
|
+
// eslint-disable-next-line complexity
|
|
2259
|
+
static buildStoresForService(config, entry) {
|
|
2259
2260
|
const allKeys = /* @__PURE__ */ new Set();
|
|
2260
2261
|
if (config.store) {
|
|
2261
2262
|
allKeys.add(config.store);
|
|
2263
|
+
} else if ("primaryStoreKey" in entry.service && typeof entry.service.primaryStoreKey === "string") {
|
|
2264
|
+
allKeys.add(entry.service.primaryStoreKey);
|
|
2265
|
+
_ServiceRegistry.logger.debug(
|
|
2266
|
+
`Auto-resolved store key '${entry.service.primaryStoreKey}' from service class`
|
|
2267
|
+
);
|
|
2262
2268
|
}
|
|
2263
2269
|
if (config.readStores) {
|
|
2264
2270
|
config.readStores.forEach((key) => allKeys.add(key));
|
|
@@ -2296,7 +2302,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2296
2302
|
const observability = _ServiceRegistry.buildObservabilityConfig(config, entry);
|
|
2297
2303
|
const storage = await _ServiceRegistry.buildStorageConfig(config, entry);
|
|
2298
2304
|
const notifications = await _ServiceRegistry.buildNotificationsConfig(config, entry);
|
|
2299
|
-
const stores = _ServiceRegistry.buildStoresForService(config);
|
|
2305
|
+
const stores = _ServiceRegistry.buildStoresForService(config, entry);
|
|
2300
2306
|
let observabilityInstance = observability?.instance;
|
|
2301
2307
|
if (observability?.dedicated && observability.config) {
|
|
2302
2308
|
observabilityInstance = await _ServiceRegistry.createDedicatedObservability(
|
|
@@ -4267,13 +4273,14 @@ var BaseDomainService = class {
|
|
|
4267
4273
|
);
|
|
4268
4274
|
}
|
|
4269
4275
|
};
|
|
4270
|
-
var BaseFrontendDomainService = class extends BaseDomainService {
|
|
4276
|
+
var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDomainService {
|
|
4271
4277
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4272
4278
|
// Constructor
|
|
4273
4279
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4274
4280
|
// eslint-disable-next-line complexity
|
|
4275
4281
|
constructor(config) {
|
|
4276
|
-
|
|
4282
|
+
const resolvedConfig = _BaseFrontendDomainService.resolveApiClientConfig(config);
|
|
4283
|
+
super(resolvedConfig);
|
|
4277
4284
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4278
4285
|
// Store Properties
|
|
4279
4286
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -4299,6 +4306,11 @@ var BaseFrontendDomainService = class extends BaseDomainService {
|
|
|
4299
4306
|
const serviceConfig = config.serviceConfig;
|
|
4300
4307
|
if (serviceConfig.store !== void 0) {
|
|
4301
4308
|
this.primaryStoreKey = serviceConfig.store;
|
|
4309
|
+
} else {
|
|
4310
|
+
const staticKey = this.constructor.primaryStoreKey;
|
|
4311
|
+
if (staticKey) {
|
|
4312
|
+
this.primaryStoreKey = staticKey;
|
|
4313
|
+
}
|
|
4302
4314
|
}
|
|
4303
4315
|
if (serviceConfig.readStores !== void 0) {
|
|
4304
4316
|
this.readStoreKeys = Array.from(
|
|
@@ -4344,6 +4356,36 @@ var BaseFrontendDomainService = class extends BaseDomainService {
|
|
|
4344
4356
|
static {
|
|
4345
4357
|
__name(this, "BaseFrontendDomainService");
|
|
4346
4358
|
}
|
|
4359
|
+
/**
|
|
4360
|
+
* Auto-resolve apiClientConfig from serviceConfig.apiBasePath if not explicitly provided.
|
|
4361
|
+
* This reduces boilerplate in child services - they only need to set apiBasePath in config.
|
|
4362
|
+
*
|
|
4363
|
+
* Priority:
|
|
4364
|
+
* 1. Explicit apiClientConfig.baseURL (full control)
|
|
4365
|
+
* 2. serviceConfig.apiBasePath (auto-constructed, merged with injected options)
|
|
4366
|
+
* 3. undefined (no API client)
|
|
4367
|
+
*
|
|
4368
|
+
* When auto-constructing, merges injected API options (headers, timeout, etc.)
|
|
4369
|
+
* with the service's apiBasePath as baseURL.
|
|
4370
|
+
*/
|
|
4371
|
+
static resolveApiClientConfig(config) {
|
|
4372
|
+
if (config.apiClientConfig?.baseURL) {
|
|
4373
|
+
return config;
|
|
4374
|
+
}
|
|
4375
|
+
const apiBasePath = config.serviceConfig.apiBasePath;
|
|
4376
|
+
if (apiBasePath) {
|
|
4377
|
+
const injectedOptions = config.injected?.api ? {} : config.apiClientConfig ?? {};
|
|
4378
|
+
return {
|
|
4379
|
+
...config,
|
|
4380
|
+
apiClientConfig: {
|
|
4381
|
+
...injectedOptions,
|
|
4382
|
+
baseURL: apiBasePath
|
|
4383
|
+
// Service's apiBasePath always takes precedence
|
|
4384
|
+
}
|
|
4385
|
+
};
|
|
4386
|
+
}
|
|
4387
|
+
return config;
|
|
4388
|
+
}
|
|
4347
4389
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4348
4390
|
// Store Management (Public API)
|
|
4349
4391
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -6121,8 +6163,6 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6121
6163
|
super({
|
|
6122
6164
|
serviceName: "ExampleFrontendService",
|
|
6123
6165
|
supportedRuntimes: ["frontend"],
|
|
6124
|
-
// API client config - uses injected options or creates from apiBasePath
|
|
6125
|
-
apiClientConfig: options?.apiClient?.options ?? { baseURL: apiBasePath },
|
|
6126
6166
|
serviceConfig: {
|
|
6127
6167
|
enabled: true,
|
|
6128
6168
|
apiBasePath,
|
|
@@ -6186,10 +6226,6 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6186
6226
|
* Required by BaseFrontendDomainService
|
|
6187
6227
|
*/
|
|
6188
6228
|
this.eventPrefix = "example";
|
|
6189
|
-
/**
|
|
6190
|
-
* Primary store key - the store this service can mutate
|
|
6191
|
-
*/
|
|
6192
|
-
this.primaryStoreKey = STORE_KEYS.EXAMPLE;
|
|
6193
6229
|
/**
|
|
6194
6230
|
* Read-only store keys - inherits error and featureFlags from base
|
|
6195
6231
|
* No need to redeclare them - they're always included by default
|
|
@@ -6212,6 +6248,14 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6212
6248
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6213
6249
|
this.serviceKey = SERVICE_KEYS.EXAMPLE_FRONTEND;
|
|
6214
6250
|
}
|
|
6251
|
+
static {
|
|
6252
|
+
/**
|
|
6253
|
+
* Primary store key for this service.
|
|
6254
|
+
* Used by ServiceRegistry to auto-inject the store if not specified in config.
|
|
6255
|
+
* Also used by base class constructor to set instance primaryStoreKey.
|
|
6256
|
+
*/
|
|
6257
|
+
this.primaryStoreKey = STORE_KEYS.EXAMPLE;
|
|
6258
|
+
}
|
|
6215
6259
|
/**
|
|
6216
6260
|
* Factory method for ServiceRegistry auto-initialization.
|
|
6217
6261
|
* Creates and initializes the service instance.
|