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