@flusys/ng-core 3.0.0 → 4.0.0-lts
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/README.md +2 -3
- package/fesm2022/flusys-ng-core.mjs +56 -82
- package/fesm2022/flusys-ng-core.mjs.map +1 -1
- package/package.json +3 -2
- package/types/flusys-ng-core.d.ts +25 -114
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
## Package Information
|
|
10
10
|
|
|
11
11
|
- **Package:** `@flusys/ng-core`
|
|
12
|
-
- **Version:**
|
|
12
|
+
- **Version:** 4.0.0-rc
|
|
13
13
|
- **Peer Dependencies:** `@angular/*: >=21.0.0`, `primeng: >=21.0.0`
|
|
14
14
|
- **Build Command:** `npm run build:ng-core`
|
|
15
15
|
|
|
@@ -271,7 +271,6 @@ export class UserApiService extends BaseApiService {
|
|
|
271
271
|
Root configuration component. Include once at app root.
|
|
272
272
|
|
|
273
273
|
- **Selector:** `lib-app-config`
|
|
274
|
-
- **Change Detection:** `OnPush`
|
|
275
274
|
|
|
276
275
|
**Provides:** Global loading progress bar (fixed top, 4px, z-index 998), toast notifications (success uses primary color), confirm dialogs.
|
|
277
276
|
|
|
@@ -339,4 +338,4 @@ export const appConfig: ApplicationConfig = {
|
|
|
339
338
|
|
|
340
339
|
---
|
|
341
340
|
|
|
342
|
-
**Last Updated:** 2026-02-25 | **Version:** 3.0.
|
|
341
|
+
**Last Updated:** 2026-02-25 | **Version:** 3.0.1 | **Angular:** 21
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, computed, Injectable, inject,
|
|
2
|
+
import { signal, computed, Injectable, inject, Component, InjectionToken, PLATFORM_ID } from '@angular/core';
|
|
3
3
|
import * as i2 from 'primeng/toast';
|
|
4
4
|
import { ToastModule } from 'primeng/toast';
|
|
5
5
|
import { ConfirmDialog } from 'primeng/confirmdialog';
|
|
@@ -50,11 +50,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
50
50
|
class LibAppConfigComponent {
|
|
51
51
|
apiLoaderService = inject(ApiLoaderService);
|
|
52
52
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: LibAppConfigComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
53
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.5", type: LibAppConfigComponent, isStandalone: true, selector: "lib-app-config", ngImport: i0, template: "@if (apiLoaderService.show()) {\n<p-progressBar mode=\"indeterminate\" />\n}\n<p-toast />\n<p-confirmdialog />\n", styles: [":host ::ng-deep .p-progressbar{position:fixed;height:4px;z-index:998;left:0;right:0}:host ::ng-deep .p-toast-message-success{background:color-mix(in srgb,var(--p-primary-color),transparent 84%)!important;border-color:var(--p-primary-color)!important;color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon{color:var(--p-primary-color)!important;fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon svg{color:var(--p-primary-color)!important;fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon path{fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button{color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button .p-toast-close-icon{color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button:hover{background:color-mix(in srgb,var(--p-primary-color),transparent 70%)!important;color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button:focus{box-shadow:0 0 0 .2rem color-mix(in srgb,var(--p-primary-color),transparent 50%)!important}:host ::ng-deep .p-toast-message-success .p-toast-detail{color:var(--p-text-color)!important}\n"], dependencies: [{ kind: "component", type: ConfirmDialog, selector: "p-confirmDialog, p-confirmdialog, p-confirm-dialog", inputs: ["header", "icon", "message", "style", "styleClass", "maskStyleClass", "acceptIcon", "acceptLabel", "closeAriaLabel", "acceptAriaLabel", "acceptVisible", "rejectIcon", "rejectLabel", "rejectAriaLabel", "rejectVisible", "acceptButtonStyleClass", "rejectButtonStyleClass", "closeOnEscape", "dismissableMask", "blockScroll", "rtl", "closable", "appendTo", "key", "autoZIndex", "baseZIndex", "transitionOptions", "focusTrap", "defaultFocus", "breakpoints", "modal", "visible", "position", "draggable"], outputs: ["onHide"] }, { kind: "ngmodule", type: ProgressBarModule }, { kind: "component", type: i1.ProgressBar, selector: "p-progressBar, p-progressbar, p-progress-bar", inputs: ["value", "showValue", "styleClass", "valueStyleClass", "unit", "mode", "color"] }, { kind: "ngmodule", type: ToastModule }, { kind: "component", type: i2.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "motionOptions", "breakpoints"], outputs: ["onClose"] }]
|
|
53
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.5", type: LibAppConfigComponent, isStandalone: true, selector: "lib-app-config", ngImport: i0, template: "@if (apiLoaderService.show()) {\n<p-progressBar mode=\"indeterminate\" />\n}\n<p-toast />\n<p-confirmdialog />\n", styles: [":host ::ng-deep .p-progressbar{position:fixed;height:4px;z-index:998;left:0;right:0}:host ::ng-deep .p-toast{top:60px!important}:host ::ng-deep .p-toast-message-success{background:color-mix(in srgb,var(--p-primary-color),transparent 84%)!important;border-color:var(--p-primary-color)!important;color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon{color:var(--p-primary-color)!important;fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon svg{color:var(--p-primary-color)!important;fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon path{fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button{color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button .p-toast-close-icon{color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button:hover{background:color-mix(in srgb,var(--p-primary-color),transparent 70%)!important;color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button:focus{box-shadow:0 0 0 .2rem color-mix(in srgb,var(--p-primary-color),transparent 50%)!important}:host ::ng-deep .p-toast-message-success .p-toast-detail{color:var(--p-text-color)!important}\n"], dependencies: [{ kind: "component", type: ConfirmDialog, selector: "p-confirmDialog, p-confirmdialog, p-confirm-dialog", inputs: ["header", "icon", "message", "style", "styleClass", "maskStyleClass", "acceptIcon", "acceptLabel", "closeAriaLabel", "acceptAriaLabel", "acceptVisible", "rejectIcon", "rejectLabel", "rejectAriaLabel", "rejectVisible", "acceptButtonStyleClass", "rejectButtonStyleClass", "closeOnEscape", "dismissableMask", "blockScroll", "rtl", "closable", "appendTo", "key", "autoZIndex", "baseZIndex", "transitionOptions", "focusTrap", "defaultFocus", "breakpoints", "modal", "visible", "position", "draggable"], outputs: ["onHide"] }, { kind: "ngmodule", type: ProgressBarModule }, { kind: "component", type: i1.ProgressBar, selector: "p-progressBar, p-progressbar, p-progress-bar", inputs: ["value", "showValue", "styleClass", "valueStyleClass", "unit", "mode", "color"] }, { kind: "ngmodule", type: ToastModule }, { kind: "component", type: i2.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "motionOptions", "breakpoints"], outputs: ["onClose"] }] });
|
|
54
54
|
}
|
|
55
55
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: LibAppConfigComponent, decorators: [{
|
|
56
56
|
type: Component,
|
|
57
|
-
args: [{ selector: 'lib-app-config',
|
|
57
|
+
args: [{ selector: 'lib-app-config', imports: [ConfirmDialog, ProgressBarModule, ToastModule], template: "@if (apiLoaderService.show()) {\n<p-progressBar mode=\"indeterminate\" />\n}\n<p-toast />\n<p-confirmdialog />\n", styles: [":host ::ng-deep .p-progressbar{position:fixed;height:4px;z-index:998;left:0;right:0}:host ::ng-deep .p-toast{top:60px!important}:host ::ng-deep .p-toast-message-success{background:color-mix(in srgb,var(--p-primary-color),transparent 84%)!important;border-color:var(--p-primary-color)!important;color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon{color:var(--p-primary-color)!important;fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon svg{color:var(--p-primary-color)!important;fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-message-icon path{fill:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button{color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button .p-toast-close-icon{color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button:hover{background:color-mix(in srgb,var(--p-primary-color),transparent 70%)!important;color:var(--p-primary-color)!important}:host ::ng-deep .p-toast-message-success .p-toast-close-button:focus{box-shadow:0 0 0 .2rem color-mix(in srgb,var(--p-primary-color),transparent 50%)!important}:host ::ng-deep .p-toast-message-success .p-toast-detail{color:var(--p-text-color)!important}\n"] }]
|
|
58
58
|
}] });
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -79,6 +79,10 @@ function apiLoaderInterceptor(req, next) {
|
|
|
79
79
|
return next(cleanReq).pipe(finalize(() => loaderService.decrease(loaderTag)));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
const TRANSLATE_ADAPTER = new InjectionToken('TRANSLATE_ADAPTER');
|
|
83
|
+
/** Registry for fallback messages when localization is not active */
|
|
84
|
+
const FALLBACK_MESSAGES_REGISTRY = new InjectionToken('FALLBACK_MESSAGES_REGISTRY');
|
|
85
|
+
|
|
82
86
|
/**
|
|
83
87
|
* HTTP context token to skip global error toast.
|
|
84
88
|
* Use when component handles error display locally.
|
|
@@ -121,6 +125,7 @@ const SKIP_ERROR_TOAST = new HttpContextToken(() => false);
|
|
|
121
125
|
function errorCatchingInterceptor(req, next) {
|
|
122
126
|
const messageService = inject(MessageService);
|
|
123
127
|
const platformId = inject(PLATFORM_ID);
|
|
128
|
+
const translateAdapter = inject(TRANSLATE_ADAPTER, { optional: true });
|
|
124
129
|
const isBrowser = isPlatformBrowser(platformId);
|
|
125
130
|
// Skip error display for check-login (expected to fail when not logged in)
|
|
126
131
|
const isCheckLogin = req.url.includes('/check-login');
|
|
@@ -136,7 +141,7 @@ function errorCatchingInterceptor(req, next) {
|
|
|
136
141
|
}
|
|
137
142
|
// Display error message for other errors
|
|
138
143
|
if (isBrowser) {
|
|
139
|
-
const { summary, detail } = extractErrorInfo(error);
|
|
144
|
+
const { summary, detail } = extractErrorInfo(error, translateAdapter);
|
|
140
145
|
messageService.add({
|
|
141
146
|
severity: 'error',
|
|
142
147
|
summary,
|
|
@@ -148,12 +153,19 @@ function errorCatchingInterceptor(req, next) {
|
|
|
148
153
|
}
|
|
149
154
|
/**
|
|
150
155
|
* Extract error summary and detail from HTTP error response.
|
|
151
|
-
* Uses backend response format: { message, error, statusCode }
|
|
156
|
+
* Uses backend response format: { message, messageKey, messageParams, error, statusCode }
|
|
157
|
+
* If messageKey is present and translate adapter is available, translates the message.
|
|
152
158
|
*/
|
|
153
|
-
function extractErrorInfo(error) {
|
|
154
|
-
//
|
|
159
|
+
function extractErrorInfo(error, translateAdapter) {
|
|
160
|
+
// Check if we have a messageKey for translation
|
|
161
|
+
const messageKey = error.error?.messageKey;
|
|
162
|
+
const messageParams = error.error?.messageParams ?? error.error?.messageVariables;
|
|
155
163
|
let detail;
|
|
156
|
-
if (
|
|
164
|
+
if (messageKey && translateAdapter) {
|
|
165
|
+
// Use translated message if available
|
|
166
|
+
detail = translateAdapter.translate(messageKey, messageParams);
|
|
167
|
+
}
|
|
168
|
+
else if (typeof error.error?.message === 'string') {
|
|
157
169
|
detail = error.error.message;
|
|
158
170
|
}
|
|
159
171
|
else if (Array.isArray(error.error?.message)) {
|
|
@@ -164,7 +176,9 @@ function extractErrorInfo(error) {
|
|
|
164
176
|
detail = error.message;
|
|
165
177
|
}
|
|
166
178
|
else {
|
|
167
|
-
detail =
|
|
179
|
+
detail = translateAdapter
|
|
180
|
+
? translateAdapter.translate('shared.unexpected.error')
|
|
181
|
+
: 'shared.unexpected.error';
|
|
168
182
|
}
|
|
169
183
|
// Extract summary/title from backend response or use default based on status
|
|
170
184
|
let summary;
|
|
@@ -174,133 +188,93 @@ function extractErrorInfo(error) {
|
|
|
174
188
|
}
|
|
175
189
|
else {
|
|
176
190
|
// Fallback to status-based title
|
|
177
|
-
summary = getDefaultSummary(error.status);
|
|
191
|
+
summary = getDefaultSummary(error.status, translateAdapter);
|
|
178
192
|
}
|
|
179
193
|
return { summary, detail };
|
|
180
194
|
}
|
|
181
195
|
/**
|
|
182
|
-
* Get default error summary based on HTTP status code
|
|
196
|
+
* Get default error summary based on HTTP status code.
|
|
197
|
+
* Uses TRANSLATE_ADAPTER for localization when available.
|
|
183
198
|
*/
|
|
184
|
-
function getDefaultSummary(status) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
case 504:
|
|
199
|
-
return 'Service Unavailable';
|
|
200
|
-
default:
|
|
201
|
-
return 'Error';
|
|
199
|
+
function getDefaultSummary(status, translateAdapter) {
|
|
200
|
+
const keyMap = {
|
|
201
|
+
400: 'shared.error.bad.request',
|
|
202
|
+
404: 'shared.error.not.found',
|
|
203
|
+
409: 'shared.error.conflict',
|
|
204
|
+
422: 'shared.error.validation.error',
|
|
205
|
+
500: 'shared.error.server.error',
|
|
206
|
+
502: 'shared.error.service.unavailable',
|
|
207
|
+
503: 'shared.error.service.unavailable',
|
|
208
|
+
504: 'shared.error.service.unavailable',
|
|
209
|
+
};
|
|
210
|
+
const key = keyMap[status] || 'shared.error';
|
|
211
|
+
if (translateAdapter) {
|
|
212
|
+
return translateAdapter.translate(key);
|
|
202
213
|
}
|
|
214
|
+
// Fallback to key when no translator available
|
|
215
|
+
return key;
|
|
203
216
|
}
|
|
204
217
|
|
|
205
|
-
/**
|
|
206
|
-
* App Configuration Token
|
|
207
|
-
* Use this to inject app config in services/components
|
|
208
|
-
*/
|
|
209
218
|
const APP_CONFIG = new InjectionToken('APP_CONFIG');
|
|
210
|
-
/**
|
|
211
|
-
* Get database mode from config
|
|
212
|
-
* Derived from multiTenant.enabled
|
|
213
|
-
*/
|
|
214
219
|
function getDatabaseMode(config) {
|
|
215
220
|
return config.multiTenant.enabled ? 'multi-tenant' : 'single';
|
|
216
221
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Check if a service is enabled
|
|
219
|
-
*/
|
|
220
222
|
function isServiceEnabled(config, serviceName) {
|
|
221
223
|
const service = config.services[serviceName];
|
|
222
224
|
return service?.enabled ?? false;
|
|
223
225
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Check if a feature is enabled (alias for isServiceEnabled with strict types)
|
|
226
|
-
*/
|
|
227
226
|
function isFeatureEnabled(config, feature) {
|
|
228
227
|
return isServiceEnabled(config, feature);
|
|
229
228
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Get service base URL or fallback to default apiBaseUrl
|
|
232
|
-
*/
|
|
233
229
|
function getServiceUrl(config, serviceName) {
|
|
234
230
|
if (isServiceEnabled(config, serviceName)) {
|
|
235
231
|
const service = config.services[serviceName];
|
|
236
|
-
return service.
|
|
232
|
+
return service?.baseUrl ?? config.apiBaseUrl;
|
|
237
233
|
}
|
|
238
234
|
return config.apiBaseUrl;
|
|
239
235
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Check if company feature is enabled
|
|
242
|
-
*/
|
|
243
236
|
function isCompanyFeatureEnabled(config) {
|
|
244
237
|
return config.enableCompanyFeature ?? false;
|
|
245
238
|
}
|
|
246
|
-
/**
|
|
247
|
-
* Check if storage feature is enabled
|
|
248
|
-
*/
|
|
249
239
|
function isStorageFeatureEnabled(config) {
|
|
250
240
|
return isServiceEnabled(config, 'storage');
|
|
251
241
|
}
|
|
252
|
-
/**
|
|
253
|
-
* Check if form-builder feature is enabled
|
|
254
|
-
*/
|
|
255
242
|
function isFormBuilderFeatureEnabled(config) {
|
|
256
243
|
return isServiceEnabled(config, 'formBuilder');
|
|
257
244
|
}
|
|
258
|
-
/**
|
|
259
|
-
* Check if email feature is enabled
|
|
260
|
-
*/
|
|
261
245
|
function isEmailFeatureEnabled(config) {
|
|
262
246
|
return isServiceEnabled(config, 'email');
|
|
263
247
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
248
|
+
function isEventManagerFeatureEnabled(config) {
|
|
249
|
+
return isServiceEnabled(config, 'eventManager');
|
|
250
|
+
}
|
|
251
|
+
function isNotificationFeatureEnabled(config) {
|
|
252
|
+
return isServiceEnabled(config, 'notification');
|
|
253
|
+
}
|
|
254
|
+
function getNotificationSocketUrl(config) {
|
|
255
|
+
const service = config.services.notification;
|
|
256
|
+
if (!service?.enabled)
|
|
257
|
+
return null;
|
|
258
|
+
return service.socketUrl ?? service.baseUrl;
|
|
259
|
+
}
|
|
268
260
|
function getPermissionMode(config) {
|
|
269
261
|
return config.permissionMode ?? 'full';
|
|
270
262
|
}
|
|
271
|
-
/**
|
|
272
|
-
* Get default storage config ID from config
|
|
273
|
-
* Used for file upload operations when no storageConfigId is provided
|
|
274
|
-
*/
|
|
275
263
|
function getDefaultStorageConfigId(config) {
|
|
276
264
|
return config.services.storage?.defaultStorageConfigId;
|
|
277
265
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Check if sign-up/registration is enabled
|
|
280
|
-
* @default true
|
|
281
|
-
*/
|
|
282
266
|
function isSignUpEnabled(config) {
|
|
283
267
|
return config.enableSignUp ?? true;
|
|
284
268
|
}
|
|
285
|
-
/**
|
|
286
|
-
* Get default company slug for registration
|
|
287
|
-
*/
|
|
288
269
|
function getDefaultCompanySlug(config) {
|
|
289
270
|
return config.registrationDefaults?.companySlug;
|
|
290
271
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Get default branch slug for registration
|
|
293
|
-
*/
|
|
294
272
|
function getDefaultBranchSlug(config) {
|
|
295
273
|
return config.registrationDefaults?.branchSlug;
|
|
296
274
|
}
|
|
297
|
-
/**
|
|
298
|
-
* Get registration defaults
|
|
299
|
-
*/
|
|
300
275
|
function getRegistrationDefaults(config) {
|
|
301
276
|
return config.registrationDefaults;
|
|
302
277
|
}
|
|
303
|
-
// Default branding constants
|
|
304
278
|
const DEFAULT_APP_NAME = 'FLUSYS';
|
|
305
279
|
const DEFAULT_AUTHOR = {
|
|
306
280
|
name: 'Flusys',
|
|
@@ -355,5 +329,5 @@ class BaseApiService {
|
|
|
355
329
|
* Generated bundle index. Do not edit.
|
|
356
330
|
*/
|
|
357
331
|
|
|
358
|
-
export { APP_CONFIG, ApiLoaderService, BaseApiService, DEFAULT_APP_NAME, DEFAULT_AUTHOR, LibAppConfigComponent, SKIP_ERROR_TOAST, apiLoaderInterceptor, errorCatchingInterceptor, getDatabaseMode, getDefaultBranchSlug, getDefaultCompanySlug, getDefaultStorageConfigId, getPermissionMode, getRegistrationDefaults, getServiceUrl, isCompanyFeatureEnabled, isEmailFeatureEnabled, isFeatureEnabled, isFormBuilderFeatureEnabled, isServiceEnabled, isSignUpEnabled, isStorageFeatureEnabled };
|
|
332
|
+
export { APP_CONFIG, ApiLoaderService, BaseApiService, DEFAULT_APP_NAME, DEFAULT_AUTHOR, FALLBACK_MESSAGES_REGISTRY, LibAppConfigComponent, SKIP_ERROR_TOAST, TRANSLATE_ADAPTER, apiLoaderInterceptor, errorCatchingInterceptor, getDatabaseMode, getDefaultBranchSlug, getDefaultCompanySlug, getDefaultStorageConfigId, getNotificationSocketUrl, getPermissionMode, getRegistrationDefaults, getServiceUrl, isCompanyFeatureEnabled, isEmailFeatureEnabled, isEventManagerFeatureEnabled, isFeatureEnabled, isFormBuilderFeatureEnabled, isNotificationFeatureEnabled, isServiceEnabled, isSignUpEnabled, isStorageFeatureEnabled };
|
|
359
333
|
//# sourceMappingURL=flusys-ng-core.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flusys-ng-core.mjs","sources":["../../../projects/ng-core/services/api-loader.service.ts","../../../projects/ng-core/components/lib-app-config/lib-app-config.component.ts","../../../projects/ng-core/components/lib-app-config/lib-app-config.component.html","../../../projects/ng-core/interceptors/api-loader.interceptor.ts","../../../projects/ng-core/interceptors/error-catching.interceptor.ts","../../../projects/ng-core/interfaces/app-config.interface.ts","../../../projects/ng-core/services/base-api.service.ts","../../../projects/ng-core/public-api.ts","../../../projects/ng-core/flusys-ng-core.ts"],"sourcesContent":["import { computed, Injectable, Signal, signal } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class ApiLoaderService {\n private readonly loaders = signal<Record<string, number>>({});\n readonly DEFAULT_TAG = 'default';\n\n // Global loading state\n readonly show: Signal<boolean> = computed(() => {\n const loaders = this.loaders();\n return Object.values(loaders).some((count) => count > 0);\n });\n\n // Get specific loader as a signal\n getLoader(name: string): Signal<boolean> {\n return computed(() => (this.loaders()[name] ?? 0) > 0);\n }\n\n increase(name: string = this.DEFAULT_TAG): void {\n this.loaders.update((loaders) => ({\n ...loaders,\n [name]: (loaders[name] ?? 0) + 1,\n }));\n }\n\n decrease(name: string = this.DEFAULT_TAG): void {\n this.loaders.update((loaders) => {\n const current = loaders[name] ?? 0;\n return { ...loaders, [name]: Math.max(0, current - 1) };\n });\n }\n}\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { ToastModule } from 'primeng/toast';\nimport { ConfirmDialog } from 'primeng/confirmdialog';\nimport { ApiLoaderService } from '../../services/api-loader.service';\nimport { ProgressBarModule } from 'primeng/progressbar';\n\n/**\n * Root configuration component providing global UI elements.\n * Include once at app root for global toast, confirm dialog, and loader.\n */\n@Component({\n selector: 'lib-app-config',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ConfirmDialog, ProgressBarModule, ToastModule],\n templateUrl: './lib-app-config.component.html',\n styleUrl: './lib-app-config.component.scss',\n})\nexport class LibAppConfigComponent {\n readonly apiLoaderService = inject(ApiLoaderService);\n}\n","@if (apiLoaderService.show()) {\n<p-progressBar mode=\"indeterminate\" />\n}\n<p-toast />\n<p-confirmdialog />\n","import { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { ApiLoaderService } from '../services/api-loader.service';\nimport { Observable } from 'rxjs';\nimport { finalize } from 'rxjs/operators';\n\n/**\n * Interceptor that tracks loading state for HTTP requests.\n * Uses 'x-loader-tag' header to group related requests.\n *\n * @example\n * ```typescript\n * http.get('/api/users', {\n * headers: new HttpHeaders({ 'x-loader-tag': 'users-list' })\n * });\n * // In template: apiLoaderService.getLoader('users-list')\n * ```\n */\nexport function apiLoaderInterceptor(\n req: HttpRequest<unknown>,\n next: HttpHandlerFn\n): Observable<HttpEvent<unknown>> {\n const loaderService = inject(ApiLoaderService);\n const loaderTag = req.headers.get('x-loader-tag') ?? loaderService.DEFAULT_TAG;\n\n loaderService.increase(loaderTag);\n\n const cleanReq = req.clone({\n headers: req.headers.delete('x-loader-tag'),\n });\n\n return next(cleanReq).pipe(\n finalize(() => loaderService.decrease(loaderTag))\n );\n}\n","import {\n HttpErrorResponse,\n HttpEvent,\n HttpHandlerFn,\n HttpRequest,\n HttpContextToken,\n} from '@angular/common/http';\nimport { inject, PLATFORM_ID } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { MessageService } from 'primeng/api';\nimport { catchError, Observable, throwError } from 'rxjs';\n\n/**\n * HTTP context token to skip global error toast.\n * Use when component handles error display locally.\n *\n * @example\n * ```typescript\n * this.http.post(url, data, {\n * context: new HttpContext().set(SKIP_ERROR_TOAST, true)\n * });\n * ```\n */\nexport const SKIP_ERROR_TOAST = new HttpContextToken<boolean>(() => false);\n\n/**\n * Error Catching Interceptor\n * Displays error messages for failed HTTP requests using backend response.\n *\n * Features:\n * - Uses backend's error title (error.error.error) as summary\n * - Uses backend's error message (error.error.message) as detail\n * - Falls back to sensible defaults based on status code\n * - Skip with SKIP_ERROR_TOAST context token for local handling\n *\n * NOTE: This interceptor only handles error display.\n * For 401 handling and token refresh, use tokenRefreshInterceptor from @flusys/ng-auth.\n *\n * @example\n * ```typescript\n * // In app.config.ts\n * provideHttpClient(\n * withFetch(),\n * withInterceptors([\n * authInterceptor, // from @flusys/ng-auth\n * tokenRefreshInterceptor, // from @flusys/ng-auth\n * errorCatchingInterceptor, // from @flusys/ng-core\n * apiLoaderInterceptor, // from @flusys/ng-core\n * ])\n * )\n * ```\n */\nexport function errorCatchingInterceptor(\n req: HttpRequest<unknown>,\n next: HttpHandlerFn\n): Observable<HttpEvent<unknown>> {\n const messageService = inject(MessageService);\n const platformId = inject(PLATFORM_ID);\n const isBrowser = isPlatformBrowser(platformId);\n\n // Skip error display for check-login (expected to fail when not logged in)\n const isCheckLogin = req.url.includes('/check-login');\n // Skip if component handles error locally\n const skipErrorToast = req.context.get(SKIP_ERROR_TOAST);\n\n return next(req).pipe(\n catchError((error: HttpErrorResponse) => {\n // Skip 401 errors - handled by tokenRefreshInterceptor in ng-auth\n // Skip 403 errors - handled by permission denied UI in components\n // Skip check-login errors - expected behavior\n // Skip if component handles error locally\n if (error.status === 401 || error.status === 403 || isCheckLogin || skipErrorToast) {\n return throwError(() => error);\n }\n\n // Display error message for other errors\n if (isBrowser) {\n const { summary, detail } = extractErrorInfo(error);\n messageService.add({\n severity: 'error',\n summary,\n detail,\n });\n }\n\n return throwError(() => error);\n })\n );\n}\n\n/**\n * Extract error summary and detail from HTTP error response.\n * Uses backend response format: { message, error, statusCode }\n */\nfunction extractErrorInfo(error: HttpErrorResponse): { summary: string; detail: string } {\n // Extract message from backend response\n let detail: string;\n if (typeof error.error?.message === 'string') {\n detail = error.error.message;\n } else if (Array.isArray(error.error?.message)) {\n // NestJS validation errors come as array\n detail = error.error.message[0];\n } else if (error.message) {\n detail = error.message;\n } else {\n detail = 'An unexpected error occurred.';\n }\n\n // Extract summary/title from backend response or use default based on status\n let summary: string;\n if (typeof error.error?.error === 'string') {\n // Backend sends error type (e.g., \"Not Found\", \"Bad Request\", \"Validation Error\")\n summary = error.error.error;\n } else {\n // Fallback to status-based title\n summary = getDefaultSummary(error.status);\n }\n\n return { summary, detail };\n}\n\n/**\n * Get default error summary based on HTTP status code\n */\nfunction getDefaultSummary(status: number): string {\n switch (status) {\n case 400:\n return 'Bad Request';\n case 404:\n return 'Not Found';\n case 409:\n return 'Conflict';\n case 422:\n return 'Validation Error';\n case 500:\n return 'Server Error';\n case 502:\n case 503:\n case 504:\n return 'Service Unavailable';\n default:\n return 'Error';\n }\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * IAM Permission Mode - controls permission system behavior\n */\nexport type PermissionMode = 'rbac' | 'direct' | 'full';\n\n/**\n * Service Configuration Interface\n */\nexport interface IServiceConfig {\n baseUrl: string;\n enabled: boolean;\n}\n\n/**\n * Storage Service Configuration Interface\n * Extends base service config with storage-specific options\n */\nexport interface IStorageServiceConfig extends IServiceConfig {\n /**\n * Default storage config ID from backend storage_config table\n * Used when no storageConfigId is provided to upload operations\n * If not set, backend will use company/branch default config\n */\n defaultStorageConfigId?: string;\n}\n\n/**\n * Author/Brand Configuration\n */\nexport interface IAuthorConfig {\n name: string;\n url: string;\n}\n\n/**\n * Registration Defaults Configuration\n * Pre-fills and disables fields on registration page\n */\nexport interface IRegistrationDefaults {\n /** Pre-fill company code field and make it readonly */\n companySlug?: string;\n /** Pre-fill branch code field and make it readonly */\n branchSlug?: string;\n}\n\n/**\n * App Configuration Interface\n * Centralized configuration for feature toggles and behavior control\n */\nexport interface IAppConfig {\n /** Application name */\n appName: string;\n\n /** Author/Brand info for footer attribution */\n author?: IAuthorConfig;\n\n /** Default API base URL (fallback) */\n apiBaseUrl: string;\n\n /**\n * Enable company feature across the app\n * When true, enables company selection/switching in layout and feature modules\n */\n enableCompanyFeature: boolean;\n\n /**\n * Enable user sign-up/registration\n * When false: hides \"Sign Up\" link on login page and protects registration route\n * @default true\n */\n enableSignUp?: boolean;\n\n /**\n * Registration defaults for pre-filling company/branch fields\n * When set: pre-fills fields and makes them readonly\n */\n registrationDefaults?: IRegistrationDefaults;\n\n /**\n * Service-specific base URLs\n * If a service exists in this object, its feature is enabled\n * Database mode is determined by multiTenant.enabled\n */\n services: {\n auth: IServiceConfig;\n administration: IServiceConfig;\n iam: IServiceConfig;\n storage: IStorageServiceConfig;\n formBuilder: IServiceConfig;\n email: IServiceConfig;\n };\n\n /**\n * Multi-tenant configuration\n * enabled: true → Database mode = multi-tenant\n * enabled: false → Database mode = single\n */\n multiTenant: {\n enabled: boolean;\n tenantHeader: string;\n tenantId?: string;\n };\n\n /**\n * IAM Permission Mode - controls permission system behavior\n * - 'rbac': Role-Based Access Control only (users get permissions via roles)\n * - 'direct': Direct action assignments only (actions assigned directly to users)\n * - 'full': Both RBAC and direct permissions (most flexible, default)\n */\n permissionMode?: PermissionMode;\n}\n\n/**\n * App Configuration Token\n * Use this to inject app config in services/components\n */\nexport const APP_CONFIG = new InjectionToken<IAppConfig>('APP_CONFIG');\n\n/**\n * Get database mode from config\n * Derived from multiTenant.enabled\n */\nexport function getDatabaseMode(config: IAppConfig): 'single' | 'multi-tenant' {\n return config.multiTenant.enabled ? 'multi-tenant' : 'single';\n}\n\n/**\n * Check if a service is enabled\n */\nexport function isServiceEnabled(\n config: IAppConfig,\n serviceName: 'auth' | 'iam' | 'storage' | (string & {}),\n): boolean {\n const service = config.services[serviceName as keyof typeof config.services];\n return service?.enabled ?? false;\n}\n\n/**\n * Check if a feature is enabled (alias for isServiceEnabled with strict types)\n */\nexport function isFeatureEnabled(\n config: IAppConfig,\n feature: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email',\n): boolean {\n return isServiceEnabled(config, feature);\n}\n\n/**\n * Get service base URL or fallback to default apiBaseUrl\n */\nexport function getServiceUrl(\n config: IAppConfig,\n serviceName: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email' | (string & {}),\n): string {\n if (isServiceEnabled(config, serviceName)) {\n const service = config.services[serviceName as keyof typeof config.services];\n return service.baseUrl;\n }\n return config.apiBaseUrl;\n}\n\n/**\n * Check if company feature is enabled\n */\nexport function isCompanyFeatureEnabled(config: IAppConfig): boolean {\n return config.enableCompanyFeature ?? false;\n}\n\n/**\n * Check if storage feature is enabled\n */\nexport function isStorageFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'storage');\n}\n\n/**\n * Check if form-builder feature is enabled\n */\nexport function isFormBuilderFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'formBuilder');\n}\n\n/**\n * Check if email feature is enabled\n */\nexport function isEmailFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'email');\n}\n\n/**\n * Get permission mode from config\n * Defaults to 'full' if not specified\n */\nexport function getPermissionMode(config: IAppConfig): PermissionMode {\n return config.permissionMode ?? 'full';\n}\n\n/**\n * Get default storage config ID from config\n * Used for file upload operations when no storageConfigId is provided\n */\nexport function getDefaultStorageConfigId(config: IAppConfig): string | undefined {\n return config.services.storage?.defaultStorageConfigId;\n}\n\n/**\n * Check if sign-up/registration is enabled\n * @default true\n */\nexport function isSignUpEnabled(config: IAppConfig): boolean {\n return config.enableSignUp ?? true;\n}\n\n/**\n * Get default company slug for registration\n */\nexport function getDefaultCompanySlug(config: IAppConfig): string | undefined {\n return config.registrationDefaults?.companySlug;\n}\n\n/**\n * Get default branch slug for registration\n */\nexport function getDefaultBranchSlug(config: IAppConfig): string | undefined {\n return config.registrationDefaults?.branchSlug;\n}\n\n/**\n * Get registration defaults\n */\nexport function getRegistrationDefaults(config: IAppConfig): IRegistrationDefaults | undefined {\n return config.registrationDefaults;\n}\n\n// Default branding constants\nexport const DEFAULT_APP_NAME = 'FLUSYS';\nexport const DEFAULT_AUTHOR: IAuthorConfig = {\n name: 'Flusys',\n url: 'https://flusys.vercel.app',\n};\n","import { inject } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { APP_CONFIG, getServiceUrl } from '../interfaces/app-config.interface';\n\n/**\n * Base API Service\n * Provides service-specific base URL resolution\n *\n * Note: This project uses POST-only RPC - all endpoints use POST, not REST verbs.\n *\n * Usage:\n * ```typescript\n * @Injectable({ providedIn: 'root' })\n * export class MyService extends BaseApiService {\n * constructor() {\n * super('my-service'); // Service name from config\n * }\n *\n * getData() {\n * return this.http.post(`${this.baseUrl}/data/get`, {});\n * }\n * }\n * ```\n */\nexport abstract class BaseApiService {\n protected readonly http = inject(HttpClient);\n protected readonly appConfig = inject(APP_CONFIG);\n protected readonly baseUrl: string;\n\n /**\n * @param serviceName - Service name from config (e.g., 'auth', 'iam', 'storage')\n */\n constructor(serviceName: string) {\n this.baseUrl = getServiceUrl(this.appConfig, serviceName);\n }\n\n /**\n * Get full URL for an endpoint\n * @param endpoint - API endpoint (e.g., '/users/get-all')\n * @returns Full URL (e.g., 'http://localhost:2002/users/get-all')\n */\n protected getUrl(endpoint: string): string {\n // Remove leading slash if present to avoid double slashes\n const cleanEndpoint = endpoint.startsWith('/') ? endpoint.substring(1) : endpoint;\n return `${this.baseUrl}/${cleanEndpoint}`;\n }\n}\n","// Components\nexport * from './components/public-api';\n\n// Interceptors\nexport * from './interceptors/public-api';\n\n// Interfaces\nexport * from './interfaces/public-api';\n\n// Services\nexport * from './services/public-api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAGa,gBAAgB,CAAA;AACV,IAAA,OAAO,GAAG,MAAM,CAAyB,EAAE,mDAAC;IACpD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AAC,MAAkB,EAAA;AAChD,IAAA,OAAO,MAAM,CAAC,YAAY,IAAI,IAAI;AACpC;AAEA;;AAEG;AACG,SAAU,qBAAqB,CAAC,MAAkB,EAAA;AACtD,IAAA,OAAO,MAAM,CAAC,oBAAoB,EAAE,WAAW;AACjD;AAEA;;AAEG;AACG,SAAU,oBAAoB,CAAC,MAAkB,EAAA;AACrD,IAAA,OAAO,MAAM,CAAC,oBAAoB,EAAE,UAAU;AAChD;AAEA;;AAEG;AACG,SAAU,uBAAuB,CAAC,MAAkB,EAAA;IACxD,OAAO,MAAM,CAAC,oBAAoB;AACpC;AAEA;AACO,MAAM,gBAAgB,GAAG;AACzB,MAAM,cAAc,GAAkB;AAC3C,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,GAAG,EAAE,2BAA2B;;;AC5OlC;;;;;;;;;;;;;;;;;;;AAmBG;MACmB,cAAc,CAAA;AACf,IAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AACzB,IAAA,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;AAC9B,IAAA,OAAO;AAE1B;;AAEG;AACH,IAAA,WAAA,CAAY,WAAmB,EAAA;QAC7B,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;IAC3D;AAEA;;;;AAIG;AACO,IAAA,MAAM,CAAC,QAAgB,EAAA;;QAE/B,MAAM,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ;AACjF,QAAA,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA,CAAA,EAAI,aAAa,EAAE;IAC3C;AACD;;AC9CD;;ACAA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"flusys-ng-core.mjs","sources":["../../../projects/ng-core/services/api-loader.service.ts","../../../projects/ng-core/components/lib-app-config/lib-app-config.component.ts","../../../projects/ng-core/components/lib-app-config/lib-app-config.component.html","../../../projects/ng-core/interceptors/api-loader.interceptor.ts","../../../projects/ng-core/interfaces/translate-adapter.interface.ts","../../../projects/ng-core/interceptors/error-catching.interceptor.ts","../../../projects/ng-core/interfaces/app-config.interface.ts","../../../projects/ng-core/services/base-api.service.ts","../../../projects/ng-core/public-api.ts","../../../projects/ng-core/flusys-ng-core.ts"],"sourcesContent":["import { computed, Injectable, Signal, signal } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class ApiLoaderService {\n private readonly loaders = signal<Record<string, number>>({});\n readonly DEFAULT_TAG = 'default';\n\n // Global loading state\n readonly show: Signal<boolean> = computed(() => {\n const loaders = this.loaders();\n return Object.values(loaders).some((count) => count > 0);\n });\n\n // Get specific loader as a signal\n getLoader(name: string): Signal<boolean> {\n return computed(() => (this.loaders()[name] ?? 0) > 0);\n }\n\n increase(name: string = this.DEFAULT_TAG): void {\n this.loaders.update((loaders) => ({\n ...loaders,\n [name]: (loaders[name] ?? 0) + 1,\n }));\n }\n\n decrease(name: string = this.DEFAULT_TAG): void {\n this.loaders.update((loaders) => {\n const current = loaders[name] ?? 0;\n return { ...loaders, [name]: Math.max(0, current - 1) };\n });\n }\n}\n","import { Component, inject } from '@angular/core';\nimport { ToastModule } from 'primeng/toast';\nimport { ConfirmDialog } from 'primeng/confirmdialog';\nimport { ApiLoaderService } from '../../services/api-loader.service';\nimport { ProgressBarModule } from 'primeng/progressbar';\n\n/**\n * Root configuration component providing global UI elements.\n * Include once at app root for global toast, confirm dialog, and loader.\n */\n@Component({\n selector: 'lib-app-config',\n imports: [ConfirmDialog, ProgressBarModule, ToastModule],\n templateUrl: './lib-app-config.component.html',\n styleUrl: './lib-app-config.component.scss',\n})\nexport class LibAppConfigComponent {\n readonly apiLoaderService = inject(ApiLoaderService);\n}\n","@if (apiLoaderService.show()) {\n<p-progressBar mode=\"indeterminate\" />\n}\n<p-toast />\n<p-confirmdialog />\n","import { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { ApiLoaderService } from '../services/api-loader.service';\nimport { Observable } from 'rxjs';\nimport { finalize } from 'rxjs/operators';\n\n/**\n * Interceptor that tracks loading state for HTTP requests.\n * Uses 'x-loader-tag' header to group related requests.\n *\n * @example\n * ```typescript\n * http.get('/api/users', {\n * headers: new HttpHeaders({ 'x-loader-tag': 'users-list' })\n * });\n * // In template: apiLoaderService.getLoader('users-list')\n * ```\n */\nexport function apiLoaderInterceptor(\n req: HttpRequest<unknown>,\n next: HttpHandlerFn\n): Observable<HttpEvent<unknown>> {\n const loaderService = inject(ApiLoaderService);\n const loaderTag = req.headers.get('x-loader-tag') ?? loaderService.DEFAULT_TAG;\n\n loaderService.increase(loaderTag);\n\n const cleanReq = req.clone({\n headers: req.headers.delete('x-loader-tag'),\n });\n\n return next(cleanReq).pipe(\n finalize(() => loaderService.decrease(loaderTag))\n );\n}\n","import { InjectionToken, Signal } from '@angular/core';\n\nexport interface ITranslateAdapter {\n /** Current language code signal - read this to create reactive dependency */\n readonly languageCode: Signal<string>;\n translate(key: string, params?: Record<string, string | number>): string;\n}\n\nexport const TRANSLATE_ADAPTER = new InjectionToken<ITranslateAdapter>('TRANSLATE_ADAPTER');\n\n/** Registry for fallback messages when localization is not active */\nexport const FALLBACK_MESSAGES_REGISTRY = new InjectionToken<Record<string, string>>(\n 'FALLBACK_MESSAGES_REGISTRY',\n);\n","import {\n HttpErrorResponse,\n HttpEvent,\n HttpHandlerFn,\n HttpRequest,\n HttpContextToken,\n} from '@angular/common/http';\nimport { inject, PLATFORM_ID } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { MessageService } from 'primeng/api';\nimport { catchError, Observable, throwError } from 'rxjs';\nimport { ITranslateAdapter, TRANSLATE_ADAPTER } from '../interfaces/translate-adapter.interface';\n\n/**\n * HTTP context token to skip global error toast.\n * Use when component handles error display locally.\n *\n * @example\n * ```typescript\n * this.http.post(url, data, {\n * context: new HttpContext().set(SKIP_ERROR_TOAST, true)\n * });\n * ```\n */\nexport const SKIP_ERROR_TOAST = new HttpContextToken<boolean>(() => false);\n\n/**\n * Error Catching Interceptor\n * Displays error messages for failed HTTP requests using backend response.\n *\n * Features:\n * - Uses backend's error title (error.error.error) as summary\n * - Uses backend's error message (error.error.message) as detail\n * - Falls back to sensible defaults based on status code\n * - Skip with SKIP_ERROR_TOAST context token for local handling\n *\n * NOTE: This interceptor only handles error display.\n * For 401 handling and token refresh, use tokenRefreshInterceptor from @flusys/ng-auth.\n *\n * @example\n * ```typescript\n * // In app.config.ts\n * provideHttpClient(\n * withFetch(),\n * withInterceptors([\n * authInterceptor, // from @flusys/ng-auth\n * tokenRefreshInterceptor, // from @flusys/ng-auth\n * errorCatchingInterceptor, // from @flusys/ng-core\n * apiLoaderInterceptor, // from @flusys/ng-core\n * ])\n * )\n * ```\n */\nexport function errorCatchingInterceptor(\n req: HttpRequest<unknown>,\n next: HttpHandlerFn\n): Observable<HttpEvent<unknown>> {\n const messageService = inject(MessageService);\n const platformId = inject(PLATFORM_ID);\n const translateAdapter = inject(TRANSLATE_ADAPTER, { optional: true });\n const isBrowser = isPlatformBrowser(platformId);\n\n // Skip error display for check-login (expected to fail when not logged in)\n const isCheckLogin = req.url.includes('/check-login');\n // Skip if component handles error locally\n const skipErrorToast = req.context.get(SKIP_ERROR_TOAST);\n\n return next(req).pipe(\n catchError((error: HttpErrorResponse) => {\n // Skip 401 errors - handled by tokenRefreshInterceptor in ng-auth\n // Skip 403 errors - handled by permission denied UI in components\n // Skip check-login errors - expected behavior\n // Skip if component handles error locally\n if (error.status === 401 || error.status === 403 || isCheckLogin || skipErrorToast) {\n return throwError(() => error);\n }\n\n // Display error message for other errors\n if (isBrowser) {\n const { summary, detail } = extractErrorInfo(error, translateAdapter);\n messageService.add({\n severity: 'error',\n summary,\n detail,\n });\n }\n\n return throwError(() => error);\n })\n );\n}\n\n/**\n * Extract error summary and detail from HTTP error response.\n * Uses backend response format: { message, messageKey, messageParams, error, statusCode }\n * If messageKey is present and translate adapter is available, translates the message.\n */\nfunction extractErrorInfo(\n error: HttpErrorResponse,\n translateAdapter: ITranslateAdapter | null\n): { summary: string; detail: string } {\n // Check if we have a messageKey for translation\n const messageKey = error.error?.messageKey;\n const messageParams = error.error?.messageParams ?? error.error?.messageVariables;\n\n let detail: string;\n if (messageKey && translateAdapter) {\n // Use translated message if available\n detail = translateAdapter.translate(messageKey, messageParams);\n } else if (typeof error.error?.message === 'string') {\n detail = error.error.message;\n } else if (Array.isArray(error.error?.message)) {\n // NestJS validation errors come as array\n detail = error.error.message[0];\n } else if (error.message) {\n detail = error.message;\n } else {\n detail = translateAdapter\n ? translateAdapter.translate('shared.unexpected.error')\n : 'shared.unexpected.error';\n }\n\n // Extract summary/title from backend response or use default based on status\n let summary: string;\n if (typeof error.error?.error === 'string') {\n // Backend sends error type (e.g., \"Not Found\", \"Bad Request\", \"Validation Error\")\n summary = error.error.error;\n } else {\n // Fallback to status-based title\n summary = getDefaultSummary(error.status, translateAdapter);\n }\n\n return { summary, detail };\n}\n\n/**\n * Get default error summary based on HTTP status code.\n * Uses TRANSLATE_ADAPTER for localization when available.\n */\nfunction getDefaultSummary(status: number, translateAdapter: ITranslateAdapter | null): string {\n const keyMap: Record<number, string> = {\n 400: 'shared.error.bad.request',\n 404: 'shared.error.not.found',\n 409: 'shared.error.conflict',\n 422: 'shared.error.validation.error',\n 500: 'shared.error.server.error',\n 502: 'shared.error.service.unavailable',\n 503: 'shared.error.service.unavailable',\n 504: 'shared.error.service.unavailable',\n };\n\n const key = keyMap[status] || 'shared.error';\n\n if (translateAdapter) {\n return translateAdapter.translate(key);\n }\n\n // Fallback to key when no translator available\n return key;\n}\n","import { InjectionToken } from '@angular/core';\n\nexport type PermissionMode = 'rbac' | 'direct' | 'full';\n\nexport interface IServiceConfig {\n baseUrl: string;\n enabled: boolean;\n}\n\nexport interface IStorageServiceConfig extends IServiceConfig {\n /** Default storage config ID (falls back to company/branch default if not set) */\n defaultStorageConfigId?: string;\n}\n\nexport interface INotificationServiceConfig extends IServiceConfig {\n /** WebSocket URL (defaults to baseUrl if not set) */\n socketUrl?: string;\n}\n\nexport interface IAuthorConfig {\n name: string;\n url: string;\n}\n\nexport interface IRegistrationDefaults {\n companySlug?: string;\n branchSlug?: string;\n}\n\nexport interface IAppConfig {\n appName: string;\n author?: IAuthorConfig;\n apiBaseUrl: string;\n enableCompanyFeature: boolean;\n /** @default true */\n enableSignUp?: boolean;\n registrationDefaults?: IRegistrationDefaults;\n services: {\n auth: IServiceConfig;\n administration: IServiceConfig;\n iam: IServiceConfig;\n storage: IStorageServiceConfig;\n formBuilder: IServiceConfig;\n email: IServiceConfig;\n eventManager: IServiceConfig;\n notification?: INotificationServiceConfig;\n };\n multiTenant: {\n enabled: boolean;\n tenantHeader: string;\n tenantId?: string;\n };\n /** 'rbac' | 'direct' | 'full' (default: 'full') */\n permissionMode?: PermissionMode;\n}\n\nexport const APP_CONFIG = new InjectionToken<IAppConfig>('APP_CONFIG');\n\nexport function getDatabaseMode(config: IAppConfig): 'single' | 'multi-tenant' {\n return config.multiTenant.enabled ? 'multi-tenant' : 'single';\n}\n\nexport function isServiceEnabled(\n config: IAppConfig,\n serviceName: 'auth' | 'iam' | 'storage' | (string & {}),\n): boolean {\n const service = config.services[serviceName as keyof typeof config.services];\n return service?.enabled ?? false;\n}\n\nexport function isFeatureEnabled(\n config: IAppConfig,\n feature: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email' | 'eventManager' | 'notification',\n): boolean {\n return isServiceEnabled(config, feature);\n}\n\nexport function getServiceUrl(\n config: IAppConfig,\n serviceName: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email' | 'eventManager' | 'notification' | (string & {}),\n): string {\n if (isServiceEnabled(config, serviceName)) {\n const service = config.services[serviceName as keyof typeof config.services];\n return service?.baseUrl ?? config.apiBaseUrl;\n }\n return config.apiBaseUrl;\n}\n\nexport function isCompanyFeatureEnabled(config: IAppConfig): boolean {\n return config.enableCompanyFeature ?? false;\n}\n\nexport function isStorageFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'storage');\n}\n\nexport function isFormBuilderFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'formBuilder');\n}\n\nexport function isEmailFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'email');\n}\n\nexport function isEventManagerFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'eventManager');\n}\n\nexport function isNotificationFeatureEnabled(config: IAppConfig): boolean {\n return isServiceEnabled(config, 'notification');\n}\n\nexport function getNotificationSocketUrl(config: IAppConfig): string | null {\n const service = config.services.notification;\n if (!service?.enabled) return null;\n return service.socketUrl ?? service.baseUrl;\n}\n\nexport function getPermissionMode(config: IAppConfig): PermissionMode {\n return config.permissionMode ?? 'full';\n}\n\nexport function getDefaultStorageConfigId(config: IAppConfig): string | undefined {\n return config.services.storage?.defaultStorageConfigId;\n}\n\nexport function isSignUpEnabled(config: IAppConfig): boolean {\n return config.enableSignUp ?? true;\n}\n\nexport function getDefaultCompanySlug(config: IAppConfig): string | undefined {\n return config.registrationDefaults?.companySlug;\n}\n\nexport function getDefaultBranchSlug(config: IAppConfig): string | undefined {\n return config.registrationDefaults?.branchSlug;\n}\n\nexport function getRegistrationDefaults(config: IAppConfig): IRegistrationDefaults | undefined {\n return config.registrationDefaults;\n}\n\nexport const DEFAULT_APP_NAME = 'FLUSYS';\nexport const DEFAULT_AUTHOR: IAuthorConfig = {\n name: 'Flusys',\n url: 'https://flusys.vercel.app',\n};\n","import { inject } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { APP_CONFIG, getServiceUrl } from '../interfaces/app-config.interface';\n\n/**\n * Base API Service\n * Provides service-specific base URL resolution\n *\n * Note: This project uses POST-only RPC - all endpoints use POST, not REST verbs.\n *\n * Usage:\n * ```typescript\n * @Injectable({ providedIn: 'root' })\n * export class MyService extends BaseApiService {\n * constructor() {\n * super('my-service'); // Service name from config\n * }\n *\n * getData() {\n * return this.http.post(`${this.baseUrl}/data/get`, {});\n * }\n * }\n * ```\n */\nexport abstract class BaseApiService {\n protected readonly http = inject(HttpClient);\n protected readonly appConfig = inject(APP_CONFIG);\n protected readonly baseUrl: string;\n\n /**\n * @param serviceName - Service name from config (e.g., 'auth', 'iam', 'storage')\n */\n constructor(serviceName: string) {\n this.baseUrl = getServiceUrl(this.appConfig, serviceName);\n }\n\n /**\n * Get full URL for an endpoint\n * @param endpoint - API endpoint (e.g., '/users/get-all')\n * @returns Full URL (e.g., 'http://localhost:2002/users/get-all')\n */\n protected getUrl(endpoint: string): string {\n // Remove leading slash if present to avoid double slashes\n const cleanEndpoint = endpoint.startsWith('/') ? endpoint.substring(1) : endpoint;\n return `${this.baseUrl}/${cleanEndpoint}`;\n }\n}\n","// Components\nexport * from './components/public-api';\n\n// Interceptors\nexport * from './interceptors/public-api';\n\n// Interfaces\nexport * from './interfaces/public-api';\n\n// Services\nexport * from './services/public-api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAGa,gBAAgB,CAAA;AACV,IAAA,OAAO,GAAG,MAAM,CAAyB,EAAE,mDAAC;IACpD,WAAW,GAAG,SAAS;;AAGvB,IAAA,IAAI,GAAoB,QAAQ,CAAC,MAAK;AAC7C,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE;AAC9B,QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,GAAG,CAAC,CAAC;AAC1D,IAAA,CAAC,gDAAC;;AAGF,IAAA,SAAS,CAAC,IAAY,EAAA;AACpB,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD;AAEA,IAAA,QAAQ,CAAC,IAAA,GAAe,IAAI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CAAC;IAC3D;AAEA;;;;AAIG;AACO,IAAA,MAAM,CAAC,QAAgB,EAAA;;QAE/B,MAAM,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ;AACjF,QAAA,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA,CAAA,EAAI,aAAa,EAAE;IAC3C;AACD;;AC9CD;;ACAA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/ng-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-lts",
|
|
4
4
|
"description": "Core utilities and services for FLUSYS Angular packages",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"@angular/core": ">=21.0.0",
|
|
9
9
|
"@primeuix/themes": ">=1.0.0",
|
|
10
10
|
"primeicons": ">=7.0.0",
|
|
11
|
-
"primeng": ">=21.0.0"
|
|
11
|
+
"primeng": ">=21.0.0",
|
|
12
|
+
"rxjs": "^7.8.0"
|
|
12
13
|
},
|
|
13
14
|
"sideEffects": false,
|
|
14
15
|
"module": "fesm2022/flusys-ng-core.mjs",
|
|
@@ -80,78 +80,35 @@ declare const SKIP_ERROR_TOAST: HttpContextToken<boolean>;
|
|
|
80
80
|
*/
|
|
81
81
|
declare function errorCatchingInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>>;
|
|
82
82
|
|
|
83
|
-
/**
|
|
84
|
-
* IAM Permission Mode - controls permission system behavior
|
|
85
|
-
*/
|
|
86
83
|
type PermissionMode = 'rbac' | 'direct' | 'full';
|
|
87
|
-
/**
|
|
88
|
-
* Service Configuration Interface
|
|
89
|
-
*/
|
|
90
84
|
interface IServiceConfig {
|
|
91
85
|
baseUrl: string;
|
|
92
86
|
enabled: boolean;
|
|
93
87
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Storage Service Configuration Interface
|
|
96
|
-
* Extends base service config with storage-specific options
|
|
97
|
-
*/
|
|
98
88
|
interface IStorageServiceConfig extends IServiceConfig {
|
|
99
|
-
/**
|
|
100
|
-
* Default storage config ID from backend storage_config table
|
|
101
|
-
* Used when no storageConfigId is provided to upload operations
|
|
102
|
-
* If not set, backend will use company/branch default config
|
|
103
|
-
*/
|
|
89
|
+
/** Default storage config ID (falls back to company/branch default if not set) */
|
|
104
90
|
defaultStorageConfigId?: string;
|
|
105
91
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
interface INotificationServiceConfig extends IServiceConfig {
|
|
93
|
+
/** WebSocket URL (defaults to baseUrl if not set) */
|
|
94
|
+
socketUrl?: string;
|
|
95
|
+
}
|
|
109
96
|
interface IAuthorConfig {
|
|
110
97
|
name: string;
|
|
111
98
|
url: string;
|
|
112
99
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Registration Defaults Configuration
|
|
115
|
-
* Pre-fills and disables fields on registration page
|
|
116
|
-
*/
|
|
117
100
|
interface IRegistrationDefaults {
|
|
118
|
-
/** Pre-fill company code field and make it readonly */
|
|
119
101
|
companySlug?: string;
|
|
120
|
-
/** Pre-fill branch code field and make it readonly */
|
|
121
102
|
branchSlug?: string;
|
|
122
103
|
}
|
|
123
|
-
/**
|
|
124
|
-
* App Configuration Interface
|
|
125
|
-
* Centralized configuration for feature toggles and behavior control
|
|
126
|
-
*/
|
|
127
104
|
interface IAppConfig {
|
|
128
|
-
/** Application name */
|
|
129
105
|
appName: string;
|
|
130
|
-
/** Author/Brand info for footer attribution */
|
|
131
106
|
author?: IAuthorConfig;
|
|
132
|
-
/** Default API base URL (fallback) */
|
|
133
107
|
apiBaseUrl: string;
|
|
134
|
-
/**
|
|
135
|
-
* Enable company feature across the app
|
|
136
|
-
* When true, enables company selection/switching in layout and feature modules
|
|
137
|
-
*/
|
|
138
108
|
enableCompanyFeature: boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Enable user sign-up/registration
|
|
141
|
-
* When false: hides "Sign Up" link on login page and protects registration route
|
|
142
|
-
* @default true
|
|
143
|
-
*/
|
|
109
|
+
/** @default true */
|
|
144
110
|
enableSignUp?: boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Registration defaults for pre-filling company/branch fields
|
|
147
|
-
* When set: pre-fills fields and makes them readonly
|
|
148
|
-
*/
|
|
149
111
|
registrationDefaults?: IRegistrationDefaults;
|
|
150
|
-
/**
|
|
151
|
-
* Service-specific base URLs
|
|
152
|
-
* If a service exists in this object, its feature is enabled
|
|
153
|
-
* Database mode is determined by multiTenant.enabled
|
|
154
|
-
*/
|
|
155
112
|
services: {
|
|
156
113
|
auth: IServiceConfig;
|
|
157
114
|
administration: IServiceConfig;
|
|
@@ -159,93 +116,47 @@ interface IAppConfig {
|
|
|
159
116
|
storage: IStorageServiceConfig;
|
|
160
117
|
formBuilder: IServiceConfig;
|
|
161
118
|
email: IServiceConfig;
|
|
119
|
+
eventManager: IServiceConfig;
|
|
120
|
+
notification?: INotificationServiceConfig;
|
|
162
121
|
};
|
|
163
|
-
/**
|
|
164
|
-
* Multi-tenant configuration
|
|
165
|
-
* enabled: true → Database mode = multi-tenant
|
|
166
|
-
* enabled: false → Database mode = single
|
|
167
|
-
*/
|
|
168
122
|
multiTenant: {
|
|
169
123
|
enabled: boolean;
|
|
170
124
|
tenantHeader: string;
|
|
171
125
|
tenantId?: string;
|
|
172
126
|
};
|
|
173
|
-
/**
|
|
174
|
-
* IAM Permission Mode - controls permission system behavior
|
|
175
|
-
* - 'rbac': Role-Based Access Control only (users get permissions via roles)
|
|
176
|
-
* - 'direct': Direct action assignments only (actions assigned directly to users)
|
|
177
|
-
* - 'full': Both RBAC and direct permissions (most flexible, default)
|
|
178
|
-
*/
|
|
127
|
+
/** 'rbac' | 'direct' | 'full' (default: 'full') */
|
|
179
128
|
permissionMode?: PermissionMode;
|
|
180
129
|
}
|
|
181
|
-
/**
|
|
182
|
-
* App Configuration Token
|
|
183
|
-
* Use this to inject app config in services/components
|
|
184
|
-
*/
|
|
185
130
|
declare const APP_CONFIG: InjectionToken<IAppConfig>;
|
|
186
|
-
/**
|
|
187
|
-
* Get database mode from config
|
|
188
|
-
* Derived from multiTenant.enabled
|
|
189
|
-
*/
|
|
190
131
|
declare function getDatabaseMode(config: IAppConfig): 'single' | 'multi-tenant';
|
|
191
|
-
/**
|
|
192
|
-
* Check if a service is enabled
|
|
193
|
-
*/
|
|
194
132
|
declare function isServiceEnabled(config: IAppConfig, serviceName: 'auth' | 'iam' | 'storage' | (string & {})): boolean;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
*/
|
|
198
|
-
declare function isFeatureEnabled(config: IAppConfig, feature: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email'): boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Get service base URL or fallback to default apiBaseUrl
|
|
201
|
-
*/
|
|
202
|
-
declare function getServiceUrl(config: IAppConfig, serviceName: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email' | (string & {})): string;
|
|
203
|
-
/**
|
|
204
|
-
* Check if company feature is enabled
|
|
205
|
-
*/
|
|
133
|
+
declare function isFeatureEnabled(config: IAppConfig, feature: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email' | 'eventManager' | 'notification'): boolean;
|
|
134
|
+
declare function getServiceUrl(config: IAppConfig, serviceName: 'auth' | 'administration' | 'iam' | 'storage' | 'formBuilder' | 'email' | 'eventManager' | 'notification' | (string & {})): string;
|
|
206
135
|
declare function isCompanyFeatureEnabled(config: IAppConfig): boolean;
|
|
207
|
-
/**
|
|
208
|
-
* Check if storage feature is enabled
|
|
209
|
-
*/
|
|
210
136
|
declare function isStorageFeatureEnabled(config: IAppConfig): boolean;
|
|
211
|
-
/**
|
|
212
|
-
* Check if form-builder feature is enabled
|
|
213
|
-
*/
|
|
214
137
|
declare function isFormBuilderFeatureEnabled(config: IAppConfig): boolean;
|
|
215
|
-
/**
|
|
216
|
-
* Check if email feature is enabled
|
|
217
|
-
*/
|
|
218
138
|
declare function isEmailFeatureEnabled(config: IAppConfig): boolean;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*/
|
|
139
|
+
declare function isEventManagerFeatureEnabled(config: IAppConfig): boolean;
|
|
140
|
+
declare function isNotificationFeatureEnabled(config: IAppConfig): boolean;
|
|
141
|
+
declare function getNotificationSocketUrl(config: IAppConfig): string | null;
|
|
223
142
|
declare function getPermissionMode(config: IAppConfig): PermissionMode;
|
|
224
|
-
/**
|
|
225
|
-
* Get default storage config ID from config
|
|
226
|
-
* Used for file upload operations when no storageConfigId is provided
|
|
227
|
-
*/
|
|
228
143
|
declare function getDefaultStorageConfigId(config: IAppConfig): string | undefined;
|
|
229
|
-
/**
|
|
230
|
-
* Check if sign-up/registration is enabled
|
|
231
|
-
* @default true
|
|
232
|
-
*/
|
|
233
144
|
declare function isSignUpEnabled(config: IAppConfig): boolean;
|
|
234
|
-
/**
|
|
235
|
-
* Get default company slug for registration
|
|
236
|
-
*/
|
|
237
145
|
declare function getDefaultCompanySlug(config: IAppConfig): string | undefined;
|
|
238
|
-
/**
|
|
239
|
-
* Get default branch slug for registration
|
|
240
|
-
*/
|
|
241
146
|
declare function getDefaultBranchSlug(config: IAppConfig): string | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* Get registration defaults
|
|
244
|
-
*/
|
|
245
147
|
declare function getRegistrationDefaults(config: IAppConfig): IRegistrationDefaults | undefined;
|
|
246
148
|
declare const DEFAULT_APP_NAME = "FLUSYS";
|
|
247
149
|
declare const DEFAULT_AUTHOR: IAuthorConfig;
|
|
248
150
|
|
|
151
|
+
interface ITranslateAdapter {
|
|
152
|
+
/** Current language code signal - read this to create reactive dependency */
|
|
153
|
+
readonly languageCode: Signal<string>;
|
|
154
|
+
translate(key: string, params?: Record<string, string | number>): string;
|
|
155
|
+
}
|
|
156
|
+
declare const TRANSLATE_ADAPTER: InjectionToken<ITranslateAdapter>;
|
|
157
|
+
/** Registry for fallback messages when localization is not active */
|
|
158
|
+
declare const FALLBACK_MESSAGES_REGISTRY: InjectionToken<Record<string, string>>;
|
|
159
|
+
|
|
249
160
|
/**
|
|
250
161
|
* Base API Service
|
|
251
162
|
* Provides service-specific base URL resolution
|
|
@@ -282,5 +193,5 @@ declare abstract class BaseApiService {
|
|
|
282
193
|
protected getUrl(endpoint: string): string;
|
|
283
194
|
}
|
|
284
195
|
|
|
285
|
-
export { APP_CONFIG, ApiLoaderService, BaseApiService, DEFAULT_APP_NAME, DEFAULT_AUTHOR, LibAppConfigComponent, SKIP_ERROR_TOAST, apiLoaderInterceptor, errorCatchingInterceptor, getDatabaseMode, getDefaultBranchSlug, getDefaultCompanySlug, getDefaultStorageConfigId, getPermissionMode, getRegistrationDefaults, getServiceUrl, isCompanyFeatureEnabled, isEmailFeatureEnabled, isFeatureEnabled, isFormBuilderFeatureEnabled, isServiceEnabled, isSignUpEnabled, isStorageFeatureEnabled };
|
|
286
|
-
export type { IAppConfig, IAuthorConfig, IRegistrationDefaults, IServiceConfig, IStorageServiceConfig, PermissionMode };
|
|
196
|
+
export { APP_CONFIG, ApiLoaderService, BaseApiService, DEFAULT_APP_NAME, DEFAULT_AUTHOR, FALLBACK_MESSAGES_REGISTRY, LibAppConfigComponent, SKIP_ERROR_TOAST, TRANSLATE_ADAPTER, apiLoaderInterceptor, errorCatchingInterceptor, getDatabaseMode, getDefaultBranchSlug, getDefaultCompanySlug, getDefaultStorageConfigId, getNotificationSocketUrl, getPermissionMode, getRegistrationDefaults, getServiceUrl, isCompanyFeatureEnabled, isEmailFeatureEnabled, isEventManagerFeatureEnabled, isFeatureEnabled, isFormBuilderFeatureEnabled, isNotificationFeatureEnabled, isServiceEnabled, isSignUpEnabled, isStorageFeatureEnabled };
|
|
197
|
+
export type { IAppConfig, IAuthorConfig, INotificationServiceConfig, IRegistrationDefaults, IServiceConfig, IStorageServiceConfig, ITranslateAdapter, PermissionMode };
|