-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logging): create StarkLogging module. Fixed imports
- Loading branch information
Showing
35 changed files
with
1,601 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { StarkCoreApplicationState } from "./starkCoreApplicationState"; |
25 changes: 25 additions & 0 deletions
25
packages/stark-core/src/common/store/starkCoreApplicationState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Interface defining the shape of the application state of Stark Core (i.e., what's stored in Redux by Stark) | ||
*/ | ||
import { StarkLogging } from "../../logging/entities/index"; | ||
// import {StarkSession} from "../../session/entities"; | ||
// import {StarkSettings} from "../../settings/entities"; | ||
|
||
export interface StarkCoreApplicationState | ||
extends StarkLoggingApplicationState /*, StarkSessionApplicationState, StarkSettingsApplicationState*/ { | ||
// starkApplicationMetadata: StarkApplicationMetadata; | ||
// starkLogging: StarkLogging; | ||
// starkSession: StarkSession; | ||
// starkSettings: StarkSettings; | ||
// starkUser: StarkUser; // not stored in Redux | ||
} | ||
export interface StarkLoggingApplicationState { | ||
starkLogging: StarkLogging; | ||
} | ||
|
||
// export interface StarkSessionApplicationState { | ||
// starkSession: StarkSession; | ||
// } | ||
// export interface StarkSettingsApplicationState { | ||
// starkSettings: StarkSettings; | ||
// } |
150 changes: 150 additions & 0 deletions
150
packages/stark-core/src/configuration/entities/application/app-config.entity.intf.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
"use strict"; | ||
|
||
import { StarkBackend } from "../../../http/entities/backend"; | ||
|
||
export const starkAppConfigConstantName: string = "StarkAppConfig"; | ||
/** | ||
* Minimal set of configuration options for Stark applications. | ||
* An implementation should be instantiated and be available under the name defined in the constants. | ||
*/ | ||
export interface StarkApplicationConfig { | ||
/** | ||
* Url of the state defined as root of the router state tree definition | ||
*/ | ||
rootStateUrl: string; | ||
|
||
/** | ||
* Name of the state defined as root of the router state tree definition | ||
*/ | ||
rootStateName: string; | ||
|
||
/** | ||
* Name of the state defined as home (homepage) | ||
*/ | ||
homeStateName: string; | ||
|
||
/** | ||
* Name of the state to be navigated to on generic errors | ||
*/ | ||
errorStateName: string; | ||
|
||
/** | ||
* Enable Angular's debug runtime information | ||
* @link https://docs.angularjs.org/guide/production#disabling-debug-data | ||
* @link https://docs.angularjs.org/api/ng/provider/$compileProvider#debugInfoEnabled | ||
*/ | ||
angularDebugInfoEnabled: boolean; | ||
|
||
/** | ||
* Enable logging of debug level messages | ||
*/ | ||
debugLoggingEnabled: boolean; | ||
|
||
/** | ||
* When the number of log messages reaches the loggingFlushPersistSize value, | ||
* the log messages are sent to the back-end and removed from the redux store. | ||
* Default: 15 | ||
*/ | ||
loggingFlushPersistSize: number; | ||
|
||
/** | ||
* The loggingFlushApplicationId uniquely identifies the application. | ||
* It makes that the back-end can recognize your application. | ||
*/ | ||
loggingFlushApplicationId: string; | ||
|
||
/** | ||
* The loggingFlushResourceName defines the name of the logging resource on the back-end. Default: "logging" | ||
*/ | ||
loggingFlushResourceName: string; | ||
|
||
/** | ||
* Enable router logging | ||
*/ | ||
routerLoggingEnabled: boolean; | ||
|
||
/** | ||
* Timeout period before the session is ended if no user interaction occurs | ||
*/ | ||
sessionTimeout: number; | ||
|
||
/** | ||
* Seconds before the session is ended (due to no user interaction) when the timeout warning event will be emitted. | ||
* Default: 15 | ||
*/ | ||
sessionTimeoutWarningPeriod: number; | ||
|
||
/** | ||
* Interval in seconds between every "keepalive" ping. Default: 15 | ||
*/ | ||
keepAliveInterval: number; | ||
|
||
/** | ||
* Url where the "keepalive" pings should be sent to | ||
*/ | ||
keepAliveUrl: string; | ||
|
||
/** | ||
* Url to be navigated to logout the user | ||
*/ | ||
logoutUrl: string; | ||
|
||
/** | ||
* Base Url of the application | ||
*/ | ||
baseUrl: string; | ||
|
||
/** | ||
* The language to be used as default. | ||
* If a translation key is not found in the current language, the one from the default language is used as fallback | ||
*/ | ||
defaultLanguage: string; | ||
|
||
/** | ||
* Whether the application is public or private. | ||
* Public applications don't require authentication and usually provide read-only access to information | ||
*/ | ||
publicApp: boolean; | ||
|
||
/** | ||
* Option to disable the logging flush if it not needed for the application. | ||
* default: false | ||
*/ | ||
loggingFlushDisabled?: boolean; | ||
|
||
/** | ||
* Option to disable the keepAlive if it not needed for the application. | ||
* default: false | ||
*/ | ||
keepAliveDisabled?: boolean; | ||
|
||
/** | ||
* Backends that the application will interact to. | ||
*/ | ||
backends: Map<string, StarkBackend>; | ||
|
||
/** | ||
* Get a back-end by name | ||
* @param name name of the back-end object to get | ||
* @returns StarkBackend The requested backend | ||
*/ | ||
getBackend(name: string): StarkBackend; | ||
|
||
/** | ||
* Add a back-end | ||
* @param backend back-end object to add | ||
*/ | ||
addBackend(backend: StarkBackend): void; | ||
|
||
/** | ||
* Define all back-ends | ||
* @param backends the array of back-end objects | ||
*/ | ||
setBackends(backends: StarkBackend[]): void; | ||
|
||
/*** | ||
* Get all currently defined back-end objects | ||
* @returns Map<string,StarkBackend> A Map containing the different backends | ||
*/ | ||
getBackends(): Map<string, StarkBackend>; | ||
} |
159 changes: 159 additions & 0 deletions
159
packages/stark-core/src/configuration/entities/application/app-config.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
"use strict"; | ||
|
||
import { IsBoolean, IsDefined, IsNotEmpty, IsNumber, IsString, IsUrl, Matches, Min, /* ValidateIf,*/ validateSync } from "class-validator"; | ||
import { autoserialize, autoserializeAs } from "cerialize"; | ||
import { StarkApplicationConfig } from "./app-config.entity.intf"; | ||
import { StarkBackend, StarkBackendImpl } from "../../../http/entities/backend/index"; | ||
import { stringMap } from "../../../serialization/index"; | ||
import { StarkValidationErrorsUtil } from "../../../util/index"; | ||
// import {StarkMapIsValid, StarkMapNotEmpty} from "../../../validation/decorators"; | ||
|
||
export class StarkApplicationConfigImpl implements StarkApplicationConfig { | ||
@IsDefined() | ||
@IsString() | ||
@autoserialize | ||
public rootStateUrl: string; | ||
|
||
@IsDefined() | ||
@IsString() | ||
@autoserialize | ||
public rootStateName: string; | ||
|
||
@IsDefined() | ||
@IsString() | ||
@autoserialize | ||
public homeStateName: string; | ||
|
||
@IsDefined() | ||
@IsString() | ||
@autoserialize | ||
public errorStateName: string; | ||
|
||
@IsDefined() | ||
@IsBoolean() | ||
@autoserialize | ||
public angularDebugInfoEnabled: boolean; | ||
|
||
@IsDefined() | ||
@IsBoolean() | ||
@autoserialize | ||
public debugLoggingEnabled: boolean; | ||
|
||
@IsNumber() | ||
@Min(1) | ||
@autoserialize | ||
public loggingFlushPersistSize: number; | ||
|
||
@IsDefined() | ||
@IsString() | ||
@autoserialize | ||
public loggingFlushApplicationId: string; | ||
|
||
@IsDefined() | ||
@IsString() | ||
@autoserialize | ||
public loggingFlushResourceName: string; | ||
|
||
@IsDefined() | ||
@IsBoolean() | ||
@autoserialize | ||
public routerLoggingEnabled: boolean; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
@Matches(/^[a-z]{2}$/) | ||
@autoserialize | ||
public defaultLanguage: string; | ||
|
||
@IsDefined() | ||
@IsNumber() | ||
@autoserialize | ||
public sessionTimeout: number; | ||
|
||
@IsNumber() | ||
@autoserialize | ||
public sessionTimeoutWarningPeriod: number; | ||
|
||
@IsNumber() | ||
@autoserialize | ||
public keepAliveInterval: number; | ||
|
||
// @ValidateIf((keepAliveUrl: string) => typeof keepAliveUrl === "string") | ||
@IsUrl() | ||
@autoserialize | ||
public keepAliveUrl: string; | ||
|
||
@IsDefined() | ||
@IsUrl() | ||
@autoserialize | ||
public logoutUrl: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
@autoserialize | ||
public baseUrl: string; | ||
|
||
@IsDefined() | ||
@IsBoolean() | ||
@autoserialize | ||
public publicApp: boolean; | ||
|
||
// @ValidateIf((loggingFlushDisabled: boolean) => typeof loggingFlushDisabled === "boolean") | ||
@IsBoolean() | ||
@autoserialize | ||
public loggingFlushDisabled: boolean; | ||
|
||
// @ValidateIf((keepAliveDisabled: boolean) => typeof keepAliveDisabled === "boolean") | ||
@IsBoolean() | ||
@autoserialize | ||
public keepAliveDisabled: boolean; | ||
//FIXME Import StarkMapIsValid & StarkMapNotEmpty from validation/decorators | ||
// @StarkMapNotEmpty() | ||
// @StarkMapIsValid() | ||
@autoserializeAs(stringMap(StarkBackendImpl)) // using custom serialization type (stringMap) to handle ES6 Maps | ||
public backends: Map<string, StarkBackend> = new Map<string, StarkBackend>(); | ||
|
||
public constructor() { | ||
// Default values | ||
// FIXME: DEVELOPMENT env variable? | ||
/*if (DEVELOPMENT) { | ||
this.loggingFlushPersistSize = 500; | ||
} else {*/ | ||
this.loggingFlushPersistSize = 15; | ||
// } | ||
|
||
this.loggingFlushResourceName = "logging"; | ||
this.sessionTimeoutWarningPeriod = 15; | ||
this.keepAliveInterval = 15; | ||
} | ||
|
||
public addBackend(backend: StarkBackend): void { | ||
if (!backend) { | ||
throw new Error("A backend instance must be provided"); | ||
} | ||
|
||
StarkValidationErrorsUtil.throwOnError(validateSync(backend), "The backend instance provided is not valid."); | ||
|
||
this.backends.set(backend.name, backend); | ||
} | ||
|
||
public setBackends(backends: StarkBackend[]): void { | ||
this.backends = new Map<string, StarkBackend>(); | ||
|
||
for (const backend of backends) { | ||
this.addBackend(backend); | ||
} | ||
} | ||
|
||
public getBackend(name: string): StarkBackend { | ||
const backend: StarkBackend | undefined = this.backends.get(name); | ||
if (backend === undefined) { | ||
throw new Error("Backend " + name + " is undefined."); | ||
} | ||
return backend; | ||
} | ||
|
||
public getBackends(): Map<string, StarkBackend> { | ||
return this.backends; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/stark-core/src/configuration/entities/application/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"use strict"; | ||
|
||
export * from "./app-config.entity.intf"; | ||
export * from "./app-config.entity"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
export * from "./language/index"; | ||
export * from "./metadata/index"; | ||
export * from "./application/index"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.