@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
package/dist/index.mjs
CHANGED
|
@@ -631,7 +631,7 @@ function getConfigForEnvironment(env) {
|
|
|
631
631
|
}
|
|
632
632
|
__name(getConfigForEnvironment, "getConfigForEnvironment");
|
|
633
633
|
function validateBaseURL(mergedConfig, errors) {
|
|
634
|
-
if (
|
|
634
|
+
if (mergedConfig.baseURL === void 0 || mergedConfig.baseURL === null) {
|
|
635
635
|
errors.push("baseURL is required in API configuration (apiConfig parameter)");
|
|
636
636
|
}
|
|
637
637
|
}
|
|
@@ -2483,10 +2483,16 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2483
2483
|
return initPromise;
|
|
2484
2484
|
}
|
|
2485
2485
|
/** Build stores for service injection */
|
|
2486
|
-
|
|
2486
|
+
// eslint-disable-next-line complexity
|
|
2487
|
+
static buildStoresForService(config, entry) {
|
|
2487
2488
|
const allKeys = /* @__PURE__ */ new Set();
|
|
2488
2489
|
if (config.store) {
|
|
2489
2490
|
allKeys.add(config.store);
|
|
2491
|
+
} else if ("primaryStoreKey" in entry.service && typeof entry.service.primaryStoreKey === "string") {
|
|
2492
|
+
allKeys.add(entry.service.primaryStoreKey);
|
|
2493
|
+
_ServiceRegistry.logger.debug(
|
|
2494
|
+
`Auto-resolved store key '${entry.service.primaryStoreKey}' from service class`
|
|
2495
|
+
);
|
|
2490
2496
|
}
|
|
2491
2497
|
if (config.readStores) {
|
|
2492
2498
|
config.readStores.forEach((key) => allKeys.add(key));
|
|
@@ -2524,7 +2530,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2524
2530
|
const observability = _ServiceRegistry.buildObservabilityConfig(config, entry);
|
|
2525
2531
|
const storage = await _ServiceRegistry.buildStorageConfig(config, entry);
|
|
2526
2532
|
const notifications = await _ServiceRegistry.buildNotificationsConfig(config, entry);
|
|
2527
|
-
const stores = _ServiceRegistry.buildStoresForService(config);
|
|
2533
|
+
const stores = _ServiceRegistry.buildStoresForService(config, entry);
|
|
2528
2534
|
let observabilityInstance = observability?.instance;
|
|
2529
2535
|
if (observability?.dedicated && observability.config) {
|
|
2530
2536
|
observabilityInstance = await _ServiceRegistry.createDedicatedObservability(
|
|
@@ -4495,13 +4501,14 @@ var BaseDomainService = class {
|
|
|
4495
4501
|
);
|
|
4496
4502
|
}
|
|
4497
4503
|
};
|
|
4498
|
-
var BaseFrontendDomainService = class extends BaseDomainService {
|
|
4504
|
+
var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDomainService {
|
|
4499
4505
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4500
4506
|
// Constructor
|
|
4501
4507
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4502
4508
|
// eslint-disable-next-line complexity
|
|
4503
4509
|
constructor(config) {
|
|
4504
|
-
|
|
4510
|
+
const resolvedConfig = _BaseFrontendDomainService.resolveApiClientConfig(config);
|
|
4511
|
+
super(resolvedConfig);
|
|
4505
4512
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4506
4513
|
// Store Properties
|
|
4507
4514
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -4527,6 +4534,11 @@ var BaseFrontendDomainService = class extends BaseDomainService {
|
|
|
4527
4534
|
const serviceConfig = config.serviceConfig;
|
|
4528
4535
|
if (serviceConfig.store !== void 0) {
|
|
4529
4536
|
this.primaryStoreKey = serviceConfig.store;
|
|
4537
|
+
} else {
|
|
4538
|
+
const staticKey = this.constructor.primaryStoreKey;
|
|
4539
|
+
if (staticKey) {
|
|
4540
|
+
this.primaryStoreKey = staticKey;
|
|
4541
|
+
}
|
|
4530
4542
|
}
|
|
4531
4543
|
if (serviceConfig.readStores !== void 0) {
|
|
4532
4544
|
this.readStoreKeys = Array.from(
|
|
@@ -4572,6 +4584,36 @@ var BaseFrontendDomainService = class extends BaseDomainService {
|
|
|
4572
4584
|
static {
|
|
4573
4585
|
__name(this, "BaseFrontendDomainService");
|
|
4574
4586
|
}
|
|
4587
|
+
/**
|
|
4588
|
+
* Auto-resolve apiClientConfig from serviceConfig.apiBasePath if not explicitly provided.
|
|
4589
|
+
* This reduces boilerplate in child services - they only need to set apiBasePath in config.
|
|
4590
|
+
*
|
|
4591
|
+
* Priority:
|
|
4592
|
+
* 1. Explicit apiClientConfig.baseURL (full control)
|
|
4593
|
+
* 2. serviceConfig.apiBasePath (auto-constructed, merged with injected options)
|
|
4594
|
+
* 3. undefined (no API client)
|
|
4595
|
+
*
|
|
4596
|
+
* When auto-constructing, merges injected API options (headers, timeout, etc.)
|
|
4597
|
+
* with the service's apiBasePath as baseURL.
|
|
4598
|
+
*/
|
|
4599
|
+
static resolveApiClientConfig(config) {
|
|
4600
|
+
if (config.apiClientConfig?.baseURL) {
|
|
4601
|
+
return config;
|
|
4602
|
+
}
|
|
4603
|
+
const apiBasePath = config.serviceConfig.apiBasePath;
|
|
4604
|
+
if (apiBasePath) {
|
|
4605
|
+
const injectedOptions = config.injected?.api ? {} : config.apiClientConfig ?? {};
|
|
4606
|
+
return {
|
|
4607
|
+
...config,
|
|
4608
|
+
apiClientConfig: {
|
|
4609
|
+
...injectedOptions,
|
|
4610
|
+
baseURL: apiBasePath
|
|
4611
|
+
// Service's apiBasePath always takes precedence
|
|
4612
|
+
}
|
|
4613
|
+
};
|
|
4614
|
+
}
|
|
4615
|
+
return config;
|
|
4616
|
+
}
|
|
4575
4617
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4576
4618
|
// Store Management (Public API)
|
|
4577
4619
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -12748,8 +12790,6 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
12748
12790
|
super({
|
|
12749
12791
|
serviceName: "ExampleFrontendService",
|
|
12750
12792
|
supportedRuntimes: ["frontend"],
|
|
12751
|
-
// API client config - uses injected options or creates from apiBasePath
|
|
12752
|
-
apiClientConfig: options?.apiClient?.options ?? { baseURL: apiBasePath },
|
|
12753
12793
|
serviceConfig: {
|
|
12754
12794
|
enabled: true,
|
|
12755
12795
|
apiBasePath,
|
|
@@ -12813,10 +12853,6 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
12813
12853
|
* Required by BaseFrontendDomainService
|
|
12814
12854
|
*/
|
|
12815
12855
|
this.eventPrefix = "example";
|
|
12816
|
-
/**
|
|
12817
|
-
* Primary store key - the store this service can mutate
|
|
12818
|
-
*/
|
|
12819
|
-
this.primaryStoreKey = STORE_KEYS.EXAMPLE;
|
|
12820
12856
|
/**
|
|
12821
12857
|
* Read-only store keys - inherits error and featureFlags from base
|
|
12822
12858
|
* No need to redeclare them - they're always included by default
|
|
@@ -12839,6 +12875,14 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
12839
12875
|
// ─────────────────────────────────────────────────────────────────────────
|
|
12840
12876
|
this.serviceKey = SERVICE_KEYS.EXAMPLE_FRONTEND;
|
|
12841
12877
|
}
|
|
12878
|
+
static {
|
|
12879
|
+
/**
|
|
12880
|
+
* Primary store key for this service.
|
|
12881
|
+
* Used by ServiceRegistry to auto-inject the store if not specified in config.
|
|
12882
|
+
* Also used by base class constructor to set instance primaryStoreKey.
|
|
12883
|
+
*/
|
|
12884
|
+
this.primaryStoreKey = STORE_KEYS.EXAMPLE;
|
|
12885
|
+
}
|
|
12842
12886
|
/**
|
|
12843
12887
|
* Factory method for ServiceRegistry auto-initialization.
|
|
12844
12888
|
* Creates and initializes the service instance.
|