@plyaz/core 1.9.2 → 1.9.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/BaseFrontendDomainService.d.ts +55 -0
- package/dist/domain/base/BaseFrontendDomainService.d.ts.map +1 -1
- package/dist/domain/example/FrontendExampleDomainService.d.ts +0 -12
- package/dist/domain/example/FrontendExampleDomainService.d.ts.map +1 -1
- package/dist/entry-backend.js +97 -49
- package/dist/entry-backend.js.map +1 -1
- package/dist/entry-backend.mjs +97 -49
- package/dist/entry-backend.mjs.map +1 -1
- package/dist/entry-frontend-browser.js +99 -47
- package/dist/entry-frontend-browser.js.map +1 -1
- package/dist/entry-frontend-browser.mjs +96 -47
- package/dist/entry-frontend-browser.mjs.map +1 -1
- package/dist/entry-frontend.js +99 -47
- package/dist/entry-frontend.js.map +1 -1
- package/dist/entry-frontend.mjs +96 -47
- package/dist/entry-frontend.mjs.map +1 -1
- package/dist/frontend/providers/PlyazProvider.d.ts +2 -0
- package/dist/frontend/providers/PlyazProvider.d.ts.map +1 -1
- package/dist/index.js +96 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@ import { ERROR_CODES as ERROR_CODES$1, ERROR_CATEGORY as ERROR_CATEGORY$1, API_E
|
|
|
8
8
|
import { OBSERVABILITY_METRICS } from '@plyaz/types/observability';
|
|
9
9
|
import { clearEventEmitter, setEventEmitter, initializeGlobalErrorHandler } from '@plyaz/errors/middleware';
|
|
10
10
|
import { STORE_KEYS, useRootStore, createStandaloneFeatureFlagStore } from '@plyaz/store';
|
|
11
|
+
export { useRootStore } from '@plyaz/store';
|
|
11
12
|
import { CORE_EVENTS as CORE_EVENTS$1, SERVICE_KEYS } from '@plyaz/types/core';
|
|
12
13
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
13
14
|
import { createContext, useState, useEffect, useCallback, useMemo, useContext } from 'react';
|
|
@@ -4372,6 +4373,7 @@ var BaseDomainService = class {
|
|
|
4372
4373
|
);
|
|
4373
4374
|
}
|
|
4374
4375
|
};
|
|
4376
|
+
var DEFAULT_POLLING_INTERVAL_MS = 3e4;
|
|
4375
4377
|
var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDomainService {
|
|
4376
4378
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4377
4379
|
// Constructor
|
|
@@ -4397,6 +4399,11 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
4397
4399
|
this._rollbackStack = [];
|
|
4398
4400
|
/** Maximum rollback stack size */
|
|
4399
4401
|
this._maxRollbackStackSize = 10;
|
|
4402
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
4403
|
+
// Polling Properties
|
|
4404
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
4405
|
+
/** Polling timer reference */
|
|
4406
|
+
this._pollingTimer = null;
|
|
4400
4407
|
this.storeHandlers = config.serviceConfig.storeHandlers;
|
|
4401
4408
|
this.optimisticConfig = config.serviceConfig.optimisticUpdates;
|
|
4402
4409
|
if (config.mapperClass) {
|
|
@@ -5423,6 +5430,87 @@ var BaseFrontendDomainService = class _BaseFrontendDomainService extends BaseDom
|
|
|
5423
5430
|
this.logDebug(`Event emitted: ${eventName}`, payload);
|
|
5424
5431
|
}
|
|
5425
5432
|
// ─────────────────────────────────────────────────────────────────────────
|
|
5433
|
+
// Polling (Generic Feature)
|
|
5434
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
5435
|
+
/**
|
|
5436
|
+
* Check if polling is currently active.
|
|
5437
|
+
*/
|
|
5438
|
+
get isPolling() {
|
|
5439
|
+
return this._pollingTimer !== null;
|
|
5440
|
+
}
|
|
5441
|
+
/**
|
|
5442
|
+
* Start polling for updates.
|
|
5443
|
+
* Uses `config.pollingInterval` if set, otherwise uses DEFAULT_POLLING_INTERVAL_MS (30s).
|
|
5444
|
+
* Polling calls fetchAll() at the configured interval.
|
|
5445
|
+
*
|
|
5446
|
+
* Override in subclass for custom polling behavior.
|
|
5447
|
+
*
|
|
5448
|
+
* @example
|
|
5449
|
+
* ```typescript
|
|
5450
|
+
* // Start polling with config interval
|
|
5451
|
+
* service.startPolling();
|
|
5452
|
+
*
|
|
5453
|
+
* // Or override in subclass for custom behavior
|
|
5454
|
+
* startPolling(): void {
|
|
5455
|
+
* super.startPolling();
|
|
5456
|
+
* // Custom polling logic
|
|
5457
|
+
* }
|
|
5458
|
+
* ```
|
|
5459
|
+
*/
|
|
5460
|
+
startPolling() {
|
|
5461
|
+
if (this._pollingTimer) return;
|
|
5462
|
+
const interval = this.config.pollingInterval || DEFAULT_POLLING_INTERVAL_MS;
|
|
5463
|
+
this._pollingTimer = setInterval(() => {
|
|
5464
|
+
this.fetchAll().catch((error) => {
|
|
5465
|
+
this.logError("Polling fetch failed", { error });
|
|
5466
|
+
});
|
|
5467
|
+
}, interval);
|
|
5468
|
+
this.logDebug("Polling started", { interval });
|
|
5469
|
+
}
|
|
5470
|
+
/**
|
|
5471
|
+
* Stop polling.
|
|
5472
|
+
* Safe to call even if polling is not active.
|
|
5473
|
+
*/
|
|
5474
|
+
stopPolling() {
|
|
5475
|
+
if (this._pollingTimer) {
|
|
5476
|
+
clearInterval(this._pollingTimer);
|
|
5477
|
+
this._pollingTimer = null;
|
|
5478
|
+
this.logDebug("Polling stopped");
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
5482
|
+
// Lifecycle Management
|
|
5483
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
5484
|
+
/**
|
|
5485
|
+
* Dispose service and cleanup resources.
|
|
5486
|
+
* Stops polling and performs base cleanup.
|
|
5487
|
+
*
|
|
5488
|
+
* Subclasses should override and call super.dispose() to ensure cleanup.
|
|
5489
|
+
*
|
|
5490
|
+
* @example
|
|
5491
|
+
* ```typescript
|
|
5492
|
+
* dispose(): void {
|
|
5493
|
+
* // Custom cleanup
|
|
5494
|
+
* this.customCleanup();
|
|
5495
|
+
* // Always call super
|
|
5496
|
+
* super.dispose();
|
|
5497
|
+
* }
|
|
5498
|
+
* ```
|
|
5499
|
+
*/
|
|
5500
|
+
dispose() {
|
|
5501
|
+
this.stopPolling();
|
|
5502
|
+
this.logInfo("Service disposed");
|
|
5503
|
+
}
|
|
5504
|
+
/**
|
|
5505
|
+
* Check if service is available.
|
|
5506
|
+
* Override in subclass for custom availability checks.
|
|
5507
|
+
*
|
|
5508
|
+
* @returns true if service is enabled and in a browser environment
|
|
5509
|
+
*/
|
|
5510
|
+
isAvailable() {
|
|
5511
|
+
return this.isServiceEnabled && typeof window !== "undefined";
|
|
5512
|
+
}
|
|
5513
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
5426
5514
|
// Error Handling Helpers
|
|
5427
5515
|
// ─────────────────────────────────────────────────────────────────────────
|
|
5428
5516
|
/**
|
|
@@ -6301,7 +6389,6 @@ var ExampleMapperClass = class extends BaseMapper {
|
|
|
6301
6389
|
};
|
|
6302
6390
|
|
|
6303
6391
|
// src/domain/example/FrontendExampleDomainService.ts
|
|
6304
|
-
var DEFAULT_POLLING_INTERVAL_MS = 3e4;
|
|
6305
6392
|
var FrontendExampleDomainService = class _FrontendExampleDomainService extends BaseFrontendDomainService {
|
|
6306
6393
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6307
6394
|
// Constructor
|
|
@@ -6376,15 +6463,6 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6376
6463
|
* Required by BaseFrontendDomainService
|
|
6377
6464
|
*/
|
|
6378
6465
|
this.eventPrefix = "example";
|
|
6379
|
-
/**
|
|
6380
|
-
* Read-only store keys - inherits error and featureFlags from base
|
|
6381
|
-
* No need to redeclare them - they're always included by default
|
|
6382
|
-
*/
|
|
6383
|
-
// protected readStoreKeys = [...super.readStoreKeys]; // Already includes ERROR, FEATURE_FLAGS
|
|
6384
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
6385
|
-
// Domain-Specific Properties
|
|
6386
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
6387
|
-
this.pollingTimer = null;
|
|
6388
6466
|
if (this.config.pollingInterval && this.config.pollingInterval > 0) {
|
|
6389
6467
|
this.startPolling();
|
|
6390
6468
|
}
|
|
@@ -6393,6 +6471,11 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6393
6471
|
__name(this, "FrontendExampleDomainService");
|
|
6394
6472
|
}
|
|
6395
6473
|
static {
|
|
6474
|
+
/**
|
|
6475
|
+
* Read-only store keys - inherits error and featureFlags from base
|
|
6476
|
+
* No need to redeclare them - they're always included by default
|
|
6477
|
+
*/
|
|
6478
|
+
// protected readStoreKeys = [...super.readStoreKeys]; // Already includes ERROR, FEATURE_FLAGS
|
|
6396
6479
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6397
6480
|
// Static: Service Registry Interface
|
|
6398
6481
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -6426,18 +6509,10 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6426
6509
|
return service;
|
|
6427
6510
|
}
|
|
6428
6511
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6429
|
-
// Abstract Implementations (Required by BaseDomainService)
|
|
6430
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
6431
|
-
isAvailable() {
|
|
6432
|
-
return this.isServiceEnabled && typeof window !== "undefined";
|
|
6433
|
-
}
|
|
6434
|
-
dispose() {
|
|
6435
|
-
this.stopPolling();
|
|
6436
|
-
this.logInfo("Service disposed");
|
|
6437
|
-
}
|
|
6438
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
6439
6512
|
// Lifecycle Hooks (Optional Override Examples)
|
|
6440
6513
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6514
|
+
// Note: isAvailable(), dispose(), startPolling(), stopPolling() are inherited
|
|
6515
|
+
// from BaseFrontendDomainService. Override here only if custom behavior needed.
|
|
6441
6516
|
/**
|
|
6442
6517
|
* After fetchAll - emit event (store sync handled automatically)
|
|
6443
6518
|
* Note: Base class automatically calls syncToStores() which uses storeHandlers
|
|
@@ -6485,35 +6560,9 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6485
6560
|
return CoreEventManager.on(event, handler);
|
|
6486
6561
|
}
|
|
6487
6562
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6488
|
-
// Polling (Domain-Specific Feature)
|
|
6489
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
6490
|
-
/**
|
|
6491
|
-
* Start polling for updates
|
|
6492
|
-
* Domain-specific feature - not part of base class
|
|
6493
|
-
*/
|
|
6494
|
-
startPolling() {
|
|
6495
|
-
if (this.pollingTimer) return;
|
|
6496
|
-
const interval = this.config.pollingInterval ?? DEFAULT_POLLING_INTERVAL_MS;
|
|
6497
|
-
this.pollingTimer = setInterval(() => {
|
|
6498
|
-
this.fetchAll().catch((error) => {
|
|
6499
|
-
this.logError("Polling fetch failed", { error });
|
|
6500
|
-
});
|
|
6501
|
-
}, interval);
|
|
6502
|
-
this.logDebug("Polling started", { interval });
|
|
6503
|
-
}
|
|
6504
|
-
/**
|
|
6505
|
-
* Stop polling
|
|
6506
|
-
*/
|
|
6507
|
-
stopPolling() {
|
|
6508
|
-
if (this.pollingTimer) {
|
|
6509
|
-
clearInterval(this.pollingTimer);
|
|
6510
|
-
this.pollingTimer = null;
|
|
6511
|
-
this.logDebug("Polling stopped");
|
|
6512
|
-
}
|
|
6513
|
-
}
|
|
6514
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
6515
6563
|
// Demo Methods - fetchAll() with Query Examples
|
|
6516
6564
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6565
|
+
// Note: startPolling() and stopPolling() are inherited from BaseFrontendDomainService
|
|
6517
6566
|
/**
|
|
6518
6567
|
* Demo: Fetch all examples with optional filters
|
|
6519
6568
|
* Demonstrates the fetchAll() method with typed query parameters
|