@plyaz/core 1.10.0 → 1.11.0
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/files/BackendFilesDomainService.d.ts +10 -13
- package/dist/domain/files/BackendFilesDomainService.d.ts.map +1 -1
- package/dist/entry-backend.js +348 -189
- package/dist/entry-backend.js.map +1 -1
- package/dist/entry-backend.mjs +245 -86
- package/dist/entry-backend.mjs.map +1 -1
- package/dist/entry-frontend-browser.js +75 -17
- package/dist/entry-frontend-browser.js.map +1 -1
- package/dist/entry-frontend-browser.mjs +75 -17
- package/dist/entry-frontend-browser.mjs.map +1 -1
- package/dist/entry-frontend.js +75 -17
- package/dist/entry-frontend.js.map +1 -1
- package/dist/entry-frontend.mjs +75 -17
- package/dist/entry-frontend.mjs.map +1 -1
- package/dist/frontend/providers/PlyazProvider.d.ts.map +1 -1
- package/dist/index.js +1284 -1114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1236 -1066
- package/dist/index.mjs.map +1 -1
- package/dist/init/CoreInitializer.d.ts +16 -0
- package/dist/init/CoreInitializer.d.ts.map +1 -1
- package/dist/init/nestjs/index.js +105 -12
- package/dist/init/nestjs/index.js.map +1 -1
- package/dist/init/nestjs/index.mjs +105 -12
- package/dist/init/nestjs/index.mjs.map +1 -1
- package/dist/services/DbService.d.ts +12 -0
- package/dist/services/DbService.d.ts.map +1 -1
- package/dist/services/NotificationService.d.ts +8 -0
- package/dist/services/NotificationService.d.ts.map +1 -1
- package/dist/services/StorageService.d.ts +8 -0
- package/dist/services/StorageService.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/entry-frontend.js
CHANGED
|
@@ -2980,6 +2980,11 @@ var Core = class _Core {
|
|
|
2980
2980
|
environment: globalEnvironment,
|
|
2981
2981
|
runtime,
|
|
2982
2982
|
apiClient: apiConfig ? { baseURL: apiConfig.baseURL, ...apiConfig } : void 0,
|
|
2983
|
+
db: options.db,
|
|
2984
|
+
cache: options.cache,
|
|
2985
|
+
storage: options.storage,
|
|
2986
|
+
notifications: options.notifications,
|
|
2987
|
+
observability: options.observability,
|
|
2983
2988
|
services: mergedServices,
|
|
2984
2989
|
stores: {
|
|
2985
2990
|
// Returns specific slice from namespaced root store (type-safe)
|
|
@@ -3789,26 +3794,76 @@ var Core = class _Core {
|
|
|
3789
3794
|
errorStore,
|
|
3790
3795
|
_Core.buildErrorHandlerConfig(_Core._errorConfig)
|
|
3791
3796
|
);
|
|
3797
|
+
_Core.setupErrorEventSubscription(verbose);
|
|
3798
|
+
_Core.setupErrorStoreSubscription(verbose);
|
|
3799
|
+
_Core.log("Global error handler initialized with CoreEventManager integration", verbose);
|
|
3800
|
+
if (_Core._errorConfig.httpHandler !== false) {
|
|
3801
|
+
await _Core.createHttpErrorHandler(_Core._errorConfig, verbose);
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
/**
|
|
3805
|
+
* Log serialized errors with full details.
|
|
3806
|
+
*/
|
|
3807
|
+
static logErrors(errors, prefix = "ErrorStore") {
|
|
3808
|
+
for (const err of errors) {
|
|
3809
|
+
_Core.logger.error(`[${prefix}] ${err.code}: ${err.message}`, {
|
|
3810
|
+
id: err.id,
|
|
3811
|
+
code: err.code,
|
|
3812
|
+
message: err.message,
|
|
3813
|
+
category: err.category,
|
|
3814
|
+
source: err.source,
|
|
3815
|
+
status: err.status,
|
|
3816
|
+
isRetryable: err.isRetryable,
|
|
3817
|
+
context: err.context,
|
|
3818
|
+
timestamp: err.timestamp
|
|
3819
|
+
});
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
/**
|
|
3823
|
+
* Setup SYSTEM.ERROR event subscription for error store updates.
|
|
3824
|
+
* Backend: Also logs errors with full details.
|
|
3825
|
+
* Frontend: Only updates store (logging handled by store subscription).
|
|
3826
|
+
*/
|
|
3827
|
+
static setupErrorEventSubscription(verbose) {
|
|
3828
|
+
const isBackend = types.BACKEND_RUNTIMES.includes(_Core._coreServices.runtime);
|
|
3792
3829
|
const errorEventCleanup = CoreEventManager.on(
|
|
3793
3830
|
core.CORE_EVENTS.SYSTEM.ERROR,
|
|
3794
3831
|
(event) => {
|
|
3795
3832
|
if (!_Core._rootStore) return;
|
|
3796
3833
|
try {
|
|
3797
3834
|
const { errors } = event.data;
|
|
3798
|
-
if (errors
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
}
|
|
3835
|
+
if (!errors || errors.length === 0) return;
|
|
3836
|
+
_Core._rootStore.getState().errors.addErrors(errors);
|
|
3837
|
+
if (isBackend) _Core.logErrors(errors);
|
|
3838
|
+
_Core.log(`Added ${errors.length} error(s) to store`, verbose);
|
|
3802
3839
|
} catch (e) {
|
|
3803
3840
|
_Core.logger.error("Failed to handle error event", { error: e });
|
|
3804
3841
|
}
|
|
3805
3842
|
}
|
|
3806
3843
|
);
|
|
3807
3844
|
_Core._eventCleanupFns.push(errorEventCleanup);
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3845
|
+
}
|
|
3846
|
+
/**
|
|
3847
|
+
* Setup error store subscription for frontend logging.
|
|
3848
|
+
* Logs new errors when they're added to the store.
|
|
3849
|
+
* Only active for non-backend runtimes (browser, nextjs, nuxt, edge).
|
|
3850
|
+
*/
|
|
3851
|
+
static setupErrorStoreSubscription(verbose) {
|
|
3852
|
+
const isFrontend = !types.BACKEND_RUNTIMES.includes(_Core._coreServices.runtime);
|
|
3853
|
+
if (!isFrontend || !_Core._rootStore) return;
|
|
3854
|
+
let prevErrorCount = 0;
|
|
3855
|
+
const storeUnsubscribe = _Core._rootStore.subscribe((state) => {
|
|
3856
|
+
const currentCount = state.errors.errorCount;
|
|
3857
|
+
if (currentCount <= prevErrorCount) {
|
|
3858
|
+
prevErrorCount = currentCount;
|
|
3859
|
+
return;
|
|
3860
|
+
}
|
|
3861
|
+
const newErrors = state.errors.errors.slice(0, currentCount - prevErrorCount);
|
|
3862
|
+
_Core.logErrors(newErrors, "ErrorStore:FE");
|
|
3863
|
+
prevErrorCount = currentCount;
|
|
3864
|
+
});
|
|
3865
|
+
_Core._eventCleanupFns.push(storeUnsubscribe);
|
|
3866
|
+
_Core.log("Error store subscription initialized for frontend", verbose);
|
|
3812
3867
|
}
|
|
3813
3868
|
/**
|
|
3814
3869
|
* Create HTTP error handler based on detected runtime.
|
|
@@ -6772,7 +6827,7 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6772
6827
|
// Constructor
|
|
6773
6828
|
// ─────────────────────────────────────────────────────────────────────────
|
|
6774
6829
|
constructor(config = {}, options) {
|
|
6775
|
-
const apiBasePath = config.apiBasePath || "
|
|
6830
|
+
const apiBasePath = config.apiBasePath || "";
|
|
6776
6831
|
super({
|
|
6777
6832
|
serviceName: "ExampleFrontendService",
|
|
6778
6833
|
supportedRuntimes: ["frontend"],
|
|
@@ -6797,20 +6852,20 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6797
6852
|
// Note: Use relative paths since apiClient.baseURL is already set to apiBasePath
|
|
6798
6853
|
fetchers: {
|
|
6799
6854
|
fetchAll: /* @__PURE__ */ __name(async (query) => {
|
|
6800
|
-
return this.apiClient.get("", { params: query });
|
|
6855
|
+
return this.apiClient.get("/examples", { params: query });
|
|
6801
6856
|
}, "fetchAll"),
|
|
6802
6857
|
fetchById: /* @__PURE__ */ __name(async (id) => {
|
|
6803
|
-
return this.apiClient.get(
|
|
6858
|
+
return this.apiClient.get(`/examples/${id}`);
|
|
6804
6859
|
}, "fetchById"),
|
|
6805
6860
|
create: /* @__PURE__ */ __name(async (data) => {
|
|
6806
|
-
return this.apiClient.post("", data);
|
|
6861
|
+
return this.apiClient.post("/examples", data);
|
|
6807
6862
|
}, "create"),
|
|
6808
6863
|
update: /* @__PURE__ */ __name(async (payload) => {
|
|
6809
6864
|
const { id, data } = payload;
|
|
6810
|
-
return this.apiClient.patch(
|
|
6865
|
+
return this.apiClient.patch(`/examples/${id}`, data);
|
|
6811
6866
|
}, "update"),
|
|
6812
6867
|
delete: /* @__PURE__ */ __name(async (id) => {
|
|
6813
|
-
return this.apiClient.delete(
|
|
6868
|
+
return this.apiClient.delete(`/examples/${id}`);
|
|
6814
6869
|
}, "delete")
|
|
6815
6870
|
}
|
|
6816
6871
|
// Store handlers - customize how data syncs to store
|
|
@@ -6878,7 +6933,7 @@ var FrontendExampleDomainService = class _FrontendExampleDomainService extends B
|
|
|
6878
6933
|
// The ?? operator only falls through on null/undefined, not empty strings.
|
|
6879
6934
|
// An empty string is not a valid API path, so we treat it as "not provided" and fall through to default.
|
|
6880
6935
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
6881
|
-
apiBasePath: config.apiBasePath || options?.apiClient?.options?.baseURL || "
|
|
6936
|
+
apiBasePath: config.apiBasePath || options?.apiClient?.options?.baseURL || ""
|
|
6882
6937
|
};
|
|
6883
6938
|
const service = new _FrontendExampleDomainService(mergedConfig, options);
|
|
6884
6939
|
if (mergedConfig.autoFetch) {
|
|
@@ -7250,7 +7305,7 @@ var FilesMapper = new FilesMapperClass();
|
|
|
7250
7305
|
var logger4 = new logger$1.PackageLogger({ packageName: "core", service: "FrontendFilesDomainService" });
|
|
7251
7306
|
var FrontendFilesDomainService = class _FrontendFilesDomainService extends BaseFrontendDomainService {
|
|
7252
7307
|
constructor(config = {}, options) {
|
|
7253
|
-
const apiBasePath = config.apiBasePath || "
|
|
7308
|
+
const apiBasePath = config.apiBasePath || "";
|
|
7254
7309
|
super({
|
|
7255
7310
|
serviceName: "FrontendFilesDomainService",
|
|
7256
7311
|
supportedRuntimes: ["frontend"],
|
|
@@ -7313,7 +7368,7 @@ var FrontendFilesDomainService = class _FrontendFilesDomainService extends BaseF
|
|
|
7313
7368
|
// The ?? operator only falls through on null/undefined, not empty strings.
|
|
7314
7369
|
// An empty string is not a valid API path, so we treat it as "not provided" and fall through to default.
|
|
7315
7370
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
7316
|
-
apiBasePath: config.apiBasePath || options?.apiClient?.options?.baseURL || "
|
|
7371
|
+
apiBasePath: config.apiBasePath || options?.apiClient?.options?.baseURL || ""
|
|
7317
7372
|
};
|
|
7318
7373
|
return new _FrontendFilesDomainService(mergedConfig, options);
|
|
7319
7374
|
}
|
|
@@ -9074,7 +9129,10 @@ async function initializeServices(config) {
|
|
|
9074
9129
|
globalThis.console.log("[PlyazProvider] Initializing domain services...");
|
|
9075
9130
|
}
|
|
9076
9131
|
await ServiceRegistry.initialize({
|
|
9132
|
+
environment: config.environment,
|
|
9133
|
+
runtime: config.runtime ?? detectRuntime(),
|
|
9077
9134
|
apiClient: { baseURL: config.api.baseURL },
|
|
9135
|
+
observability: config.observability,
|
|
9078
9136
|
services: config.services,
|
|
9079
9137
|
// Provide store registry for injecting stores into services
|
|
9080
9138
|
stores: createStoreRegistry()
|