@plyaz/core 1.8.2 → 1.8.4
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/BaseDomainService.d.ts +1 -1
- package/dist/domain/base/BaseFrontendDomainService.d.ts +26 -0
- package/dist/domain/base/BaseFrontendDomainService.d.ts.map +1 -1
- package/dist/domain/example/FrontendExampleDomainService.d.ts.map +1 -1
- package/dist/domain/featureFlags/FrontendFeatureFlagDomainService.d.ts.map +1 -1
- package/dist/entry-backend.js +66 -14
- package/dist/entry-backend.js.map +1 -1
- package/dist/entry-backend.mjs +66 -14
- package/dist/entry-backend.mjs.map +1 -1
- package/dist/entry-frontend-browser.js +66 -14
- package/dist/entry-frontend-browser.js.map +1 -1
- package/dist/entry-frontend-browser.mjs +66 -14
- package/dist/entry-frontend-browser.mjs.map +1 -1
- package/dist/entry-frontend.js +66 -14
- package/dist/entry-frontend.js.map +1 -1
- package/dist/entry-frontend.mjs +66 -14
- package/dist/entry-frontend.mjs.map +1 -1
- package/dist/index.js +66 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -14
- package/dist/index.mjs.map +1 -1
- package/dist/init/CoreInitializer.d.ts.map +1 -1
- package/dist/init/nestjs/index.js +15 -2
- package/dist/init/nestjs/index.js.map +1 -1
- package/dist/init/nestjs/index.mjs +15 -2
- package/dist/init/nestjs/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -36555,6 +36555,13 @@ var Core = class _Core {
|
|
|
36555
36555
|
/** Create fetch flags function */
|
|
36556
36556
|
static createFetchFlagsFn(config, verbose) {
|
|
36557
36557
|
return async () => {
|
|
36558
|
+
if (config?.provider !== "api") {
|
|
36559
|
+
_Core.log(
|
|
36560
|
+
`Feature flags using ${config?.provider ?? "default"} provider (no API fetch)`,
|
|
36561
|
+
verbose
|
|
36562
|
+
);
|
|
36563
|
+
return config?.defaults ?? {};
|
|
36564
|
+
}
|
|
36558
36565
|
try {
|
|
36559
36566
|
const client = ApiClientService.getClient();
|
|
36560
36567
|
const endpoint = config?.apiEndpoint ?? "/feature-flags";
|
|
@@ -36574,6 +36581,7 @@ var Core = class _Core {
|
|
|
36574
36581
|
/**
|
|
36575
36582
|
* Initialize feature flags slice within root store
|
|
36576
36583
|
*/
|
|
36584
|
+
// eslint-disable-next-line complexity
|
|
36577
36585
|
static async initializeFeatureFlags(config, verbose) {
|
|
36578
36586
|
if (config?.enabled === false) {
|
|
36579
36587
|
_Core.log("Feature flags disabled by configuration", verbose);
|
|
@@ -36586,11 +36594,16 @@ var Core = class _Core {
|
|
|
36586
36594
|
);
|
|
36587
36595
|
}
|
|
36588
36596
|
_Core._flagConfig = config ?? {};
|
|
36589
|
-
|
|
36597
|
+
const isApiProvider = config?.provider === "api";
|
|
36598
|
+
_Core.log(
|
|
36599
|
+
`Initializing feature flags from root store (provider: ${config?.provider ?? "default"})...`,
|
|
36600
|
+
verbose
|
|
36601
|
+
);
|
|
36590
36602
|
const state = _Core._rootStore.getState();
|
|
36591
36603
|
await state.featureFlags.initialize({
|
|
36592
36604
|
defaults: _Core._flagConfig.defaults,
|
|
36593
|
-
polling
|
|
36605
|
+
// Only enable polling for API provider
|
|
36606
|
+
polling: isApiProvider ? _Core._flagConfig.polling : void 0,
|
|
36594
36607
|
fetchFn: _Core.createFetchFlagsFn(_Core._flagConfig, verbose),
|
|
36595
36608
|
onFlagChange: _Core._flagConfig.onFlagChange,
|
|
36596
36609
|
onError: _Core._flagConfig.onError
|
|
@@ -37053,9 +37066,12 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
37053
37066
|
this._primaryStore = primaryStore;
|
|
37054
37067
|
this.logDebug(`Connected primary store: '${this.primaryStoreKey}'`);
|
|
37055
37068
|
} else {
|
|
37056
|
-
|
|
37057
|
-
|
|
37058
|
-
|
|
37069
|
+
const isServer = typeof globalThis.window === "undefined";
|
|
37070
|
+
if (!isServer) {
|
|
37071
|
+
this.logWarn(
|
|
37072
|
+
`Primary store '${this.primaryStoreKey}' not found. Store mutations (setData/updateData/setLoading) will be disabled. Configure stores in PlyazProvider to enable store integration.`
|
|
37073
|
+
);
|
|
37074
|
+
}
|
|
37059
37075
|
}
|
|
37060
37076
|
}
|
|
37061
37077
|
for (const key of this.readStoreKeys) {
|
|
@@ -37110,6 +37126,36 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
37110
37126
|
}
|
|
37111
37127
|
return config;
|
|
37112
37128
|
}
|
|
37129
|
+
/**
|
|
37130
|
+
* Initialize service and wait for API client to be ready.
|
|
37131
|
+
* Call this in child service's static create() method after constructing the instance.
|
|
37132
|
+
*
|
|
37133
|
+
* @param service - The service instance to initialize
|
|
37134
|
+
* @returns The initialized service (same instance, for chaining)
|
|
37135
|
+
*
|
|
37136
|
+
* @example
|
|
37137
|
+
* ```typescript
|
|
37138
|
+
* static async create(config, options): Promise<MyService> {
|
|
37139
|
+
* const service = new MyService(config, options);
|
|
37140
|
+
* return this.initializeService(service);
|
|
37141
|
+
* }
|
|
37142
|
+
* ```
|
|
37143
|
+
*/
|
|
37144
|
+
static async initializeService(service) {
|
|
37145
|
+
await service.ensureApiClientInitialized();
|
|
37146
|
+
return service;
|
|
37147
|
+
}
|
|
37148
|
+
/**
|
|
37149
|
+
* Ensure service is ready for operations.
|
|
37150
|
+
* Checks enabled/available status AND waits for API client initialization.
|
|
37151
|
+
* Call this at the start of all CRUD methods.
|
|
37152
|
+
*
|
|
37153
|
+
* @throws CorePackageError if service is not enabled or available
|
|
37154
|
+
*/
|
|
37155
|
+
async ensureReady() {
|
|
37156
|
+
this.assertReady();
|
|
37157
|
+
await this.ensureApiClientInitialized();
|
|
37158
|
+
}
|
|
37113
37159
|
// ─────────────────────────────────────────────────────────────────────────
|
|
37114
37160
|
// Store Management (Public API)
|
|
37115
37161
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -37582,7 +37628,7 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
37582
37628
|
*/
|
|
37583
37629
|
// eslint-disable-next-line complexity
|
|
37584
37630
|
async fetchAll(query, options) {
|
|
37585
|
-
this.
|
|
37631
|
+
await this.ensureReady();
|
|
37586
37632
|
const startTime = Date.now();
|
|
37587
37633
|
if (!this.config.fetchers?.fetchAll) {
|
|
37588
37634
|
throw new errors.CorePackageError(
|
|
@@ -37667,7 +37713,7 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
37667
37713
|
*/
|
|
37668
37714
|
// eslint-disable-next-line complexity
|
|
37669
37715
|
async fetchById(id, options) {
|
|
37670
|
-
this.
|
|
37716
|
+
await this.ensureReady();
|
|
37671
37717
|
const startTime = Date.now();
|
|
37672
37718
|
if (!this.config.fetchers?.fetchById) {
|
|
37673
37719
|
throw new errors.CorePackageError(
|
|
@@ -37728,7 +37774,7 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
37728
37774
|
*/
|
|
37729
37775
|
// eslint-disable-next-line complexity, max-lines-per-function
|
|
37730
37776
|
async create(data, options) {
|
|
37731
|
-
this.
|
|
37777
|
+
await this.ensureReady();
|
|
37732
37778
|
const startTime = Date.now();
|
|
37733
37779
|
if (!this.config.fetchers?.create) {
|
|
37734
37780
|
throw new errors.CorePackageError(
|
|
@@ -37821,7 +37867,7 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
37821
37867
|
*/
|
|
37822
37868
|
// eslint-disable-next-line complexity, max-lines-per-function
|
|
37823
37869
|
async update(id, data, options) {
|
|
37824
|
-
this.
|
|
37870
|
+
await this.ensureReady();
|
|
37825
37871
|
const startTime = Date.now();
|
|
37826
37872
|
if (!this.config.fetchers?.update) {
|
|
37827
37873
|
throw new errors.CorePackageError(
|
|
@@ -37910,7 +37956,7 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
37910
37956
|
*/
|
|
37911
37957
|
// eslint-disable-next-line complexity
|
|
37912
37958
|
async delete(id, options) {
|
|
37913
|
-
this.
|
|
37959
|
+
await this.ensureReady();
|
|
37914
37960
|
const startTime = Date.now();
|
|
37915
37961
|
if (!this.config.fetchers?.delete) {
|
|
37916
37962
|
throw new errors.CorePackageError(
|
|
@@ -44076,7 +44122,10 @@ var FrontendFeatureFlagDomainService = class _FrontendFeatureFlagDomainService e
|
|
|
44076
44122
|
}
|
|
44077
44123
|
/** Build API client for feature flags */
|
|
44078
44124
|
static async buildApiClient(config, options) {
|
|
44079
|
-
const apiBasePath =
|
|
44125
|
+
const apiBasePath = (
|
|
44126
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
44127
|
+
config.apiBasePath || options?.apiClient?.options?.baseURL || "/feature-flags"
|
|
44128
|
+
);
|
|
44080
44129
|
return frontend.createApiClient({ ...options?.apiClient?.options, baseURL: apiBasePath });
|
|
44081
44130
|
}
|
|
44082
44131
|
/** Build feature flag provider */
|
|
@@ -45280,9 +45329,8 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
45280
45329
|
// ─────────────────────────────────────────────────────────────────────────
|
|
45281
45330
|
// Constructor
|
|
45282
45331
|
// ─────────────────────────────────────────────────────────────────────────
|
|
45283
|
-
// eslint-disable-next-line complexity
|
|
45284
45332
|
constructor(config = {}, options) {
|
|
45285
|
-
const apiBasePath = config.apiBasePath
|
|
45333
|
+
const apiBasePath = config.apiBasePath || "/api/examples";
|
|
45286
45334
|
super({
|
|
45287
45335
|
serviceName: "ExampleFrontendService",
|
|
45288
45336
|
supportedRuntimes: ["frontend"],
|
|
@@ -45386,7 +45434,11 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
45386
45434
|
static async create(config, options) {
|
|
45387
45435
|
const mergedConfig = {
|
|
45388
45436
|
...config,
|
|
45389
|
-
|
|
45437
|
+
// Use || instead of ?? because api.baseURL may be '' (empty string) for same-origin requests.
|
|
45438
|
+
// The ?? operator only falls through on null/undefined, not empty strings.
|
|
45439
|
+
// An empty string is not a valid API path, so we treat it as "not provided" and fall through to default.
|
|
45440
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
45441
|
+
apiBasePath: config.apiBasePath || options?.apiClient?.options?.baseURL || "/api/examples"
|
|
45390
45442
|
};
|
|
45391
45443
|
const service = new _FrontendExampleDomainService(mergedConfig, options);
|
|
45392
45444
|
if (mergedConfig.autoFetch) {
|