@ruiapp/rapid-core 0.1.20 → 0.1.22
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/core/actionHandler.d.ts +2 -0
- package/dist/core/facility.d.ts +5 -0
- package/dist/core/request.d.ts +2 -1
- package/dist/core/routeContext.d.ts +3 -1
- package/dist/core/server.d.ts +5 -0
- package/dist/dataAccess/dataAccessor.d.ts +2 -1
- package/dist/facilities/log/LogFacility.d.ts +33 -0
- package/dist/index.js +116 -171
- package/dist/plugins/auth/AuthPlugin.d.ts +0 -9
- package/dist/plugins/dataManage/DataManagePlugin.d.ts +0 -10
- package/dist/plugins/metaManage/MetaManagePlugin.d.ts +0 -8
- package/dist/plugins/routeManage/RouteManagePlugin.d.ts +0 -9
- package/dist/plugins/webhooks/WebhooksPlugin.d.ts +0 -6
- package/dist/server.d.ts +8 -1
- package/package.json +4 -1
- package/src/core/actionHandler.ts +2 -0
- package/src/core/facility.ts +7 -0
- package/src/core/request.ts +6 -2
- package/src/core/routeContext.ts +5 -1
- package/src/core/routesBuilder.ts +7 -2
- package/src/core/server.ts +8 -0
- package/src/dataAccess/dataAccessor.ts +6 -2
- package/src/facilities/log/LogFacility.ts +36 -0
- package/src/helpers/runCollectionEntityActionHandler.ts +3 -7
- package/src/plugins/auth/AuthPlugin.ts +3 -30
- package/src/plugins/dataManage/DataManagePlugin.ts +0 -31
- package/src/plugins/dataManage/actionHandlers/addEntityRelations.ts +3 -7
- package/src/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.ts +3 -7
- package/src/plugins/dataManage/actionHandlers/createCollectionEntity.ts +3 -7
- package/src/plugins/dataManage/actionHandlers/deleteCollectionEntityById.ts +2 -2
- package/src/plugins/dataManage/actionHandlers/findCollectionEntityById.ts +2 -2
- package/src/plugins/dataManage/actionHandlers/queryDatabase.ts +3 -7
- package/src/plugins/dataManage/actionHandlers/removeEntityRelations.ts +2 -6
- package/src/plugins/dataManage/actionHandlers/updateCollectionEntityById.ts +3 -8
- package/src/plugins/entityAccessControl/EntityAccessControlPlugin.ts +3 -0
- package/src/plugins/metaManage/MetaManagePlugin.ts +10 -33
- package/src/plugins/routeManage/RouteManagePlugin.ts +4 -30
- package/src/plugins/routeManage/actionHandlers/httpProxy.ts +2 -1
- package/src/plugins/webhooks/WebhooksPlugin.ts +24 -34
- package/src/server.ts +46 -9
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { RpdApplicationConfig } from "../types";
|
|
2
2
|
import { IRpdServer, RapidPlugin } from "./server";
|
|
3
3
|
import { Next, RouteContext } from "./routeContext";
|
|
4
|
+
import { Logger } from "../facilities/log/LogFacility";
|
|
4
5
|
export interface ActionHandlerContext {
|
|
6
|
+
logger: Logger;
|
|
5
7
|
routerContext: RouteContext;
|
|
6
8
|
next: Next;
|
|
7
9
|
server: IRpdServer;
|
package/dist/core/request.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IRpdServer } from "./server";
|
|
1
2
|
export declare const GlobalRequest: {
|
|
2
3
|
new (input: URL | RequestInfo, init?: RequestInit): Request;
|
|
3
4
|
prototype: Request;
|
|
@@ -10,7 +11,7 @@ export declare class RapidRequest {
|
|
|
10
11
|
#private;
|
|
11
12
|
method: string;
|
|
12
13
|
url: URL;
|
|
13
|
-
constructor(req: Request);
|
|
14
|
+
constructor(server: IRpdServer, req: Request);
|
|
14
15
|
parseBody(): Promise<void>;
|
|
15
16
|
get rawRequest(): Request;
|
|
16
17
|
get headers(): Headers;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { RapidRequest } from "./request";
|
|
2
2
|
import { RapidResponse } from "./response";
|
|
3
3
|
import { HttpStatus } from "./http-types";
|
|
4
|
+
import { IRpdServer } from "./server";
|
|
4
5
|
export type Next = () => Promise<void>;
|
|
5
6
|
export declare class RouteContext {
|
|
7
|
+
#private;
|
|
6
8
|
readonly request: RapidRequest;
|
|
7
9
|
readonly response: RapidResponse;
|
|
8
10
|
readonly state: Record<string, any>;
|
|
@@ -10,7 +12,7 @@ export declare class RouteContext {
|
|
|
10
12
|
path: string;
|
|
11
13
|
params: Record<string, string>;
|
|
12
14
|
routeConfig: any;
|
|
13
|
-
constructor(request: RapidRequest);
|
|
15
|
+
constructor(server: IRpdServer, request: RapidRequest);
|
|
14
16
|
set(headerName: string, headerValue: string): void;
|
|
15
17
|
json(obj: any, status?: HttpStatus, headers?: HeadersInit): void;
|
|
16
18
|
redirect(url: string, status?: HttpStatus): void;
|
package/dist/core/server.d.ts
CHANGED
|
@@ -2,10 +2,15 @@ import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder
|
|
|
2
2
|
import { IPluginActionHandler, ActionHandler, ActionHandlerContext } from "./actionHandler";
|
|
3
3
|
import { Next, RouteContext } from "./routeContext";
|
|
4
4
|
import EntityManager from "../dataAccess/entityManager";
|
|
5
|
+
import { Logger } from "../facilities/log/LogFacility";
|
|
6
|
+
import { FacilityFactory } from "./facility";
|
|
5
7
|
export interface IRpdServer {
|
|
6
8
|
config: RapidServerConfig;
|
|
7
9
|
databaseConfig: IDatabaseConfig;
|
|
8
10
|
queryBuilder: IQueryBuilder;
|
|
11
|
+
getLogger(): Logger;
|
|
12
|
+
registerFacilityFactory(factory: FacilityFactory): any;
|
|
13
|
+
getFacility<TFacility = any>(name: string, options?: any): Promise<TFacility>;
|
|
9
14
|
queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
10
15
|
tryQueryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
11
16
|
registerMiddleware(middleware: any): void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CountEntityOptions, FindEntityOptions, IRpdDataAccessor, RpdDataModel, IDatabaseAccessor } from "../types";
|
|
2
2
|
import QueryBuilder from "../queryBuilder/queryBuilder";
|
|
3
|
+
import { IRpdServer } from "../core/server";
|
|
3
4
|
export interface IDataAccessorOptions {
|
|
4
5
|
model: RpdDataModel;
|
|
5
6
|
queryBuilder: QueryBuilder;
|
|
6
7
|
}
|
|
7
8
|
export default class DataAccessor<T = any> implements IRpdDataAccessor<T> {
|
|
8
9
|
#private;
|
|
9
|
-
constructor(databaseAccessor: IDatabaseAccessor, options: IDataAccessorOptions);
|
|
10
|
+
constructor(server: IRpdServer, databaseAccessor: IDatabaseAccessor, options: IDataAccessorOptions);
|
|
10
11
|
getModel(): RpdDataModel;
|
|
11
12
|
create(entity: Partial<T>): Promise<T>;
|
|
12
13
|
updateById(id: any, entity: Partial<T>): Promise<{
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import winston from "winston";
|
|
2
|
+
export interface Logger {
|
|
3
|
+
log: winston.LogMethod;
|
|
4
|
+
/**
|
|
5
|
+
* The service/app is going to stop or become unusable now. An operator should definitely look into this immediately.
|
|
6
|
+
*/
|
|
7
|
+
emerg: winston.LeveledLogMethod;
|
|
8
|
+
/**
|
|
9
|
+
* Fatal for a particular service, but the app continues servicing other requests. An operator should look at this immediately.
|
|
10
|
+
*/
|
|
11
|
+
crit: winston.LeveledLogMethod;
|
|
12
|
+
/**
|
|
13
|
+
* Fatal for a particular request, but the service/app continues servicing other requests. An operator should look at this soon(ish).
|
|
14
|
+
*/
|
|
15
|
+
error: winston.LeveledLogMethod;
|
|
16
|
+
/**
|
|
17
|
+
* A note on something that should probably be looked at by an operator eventually.
|
|
18
|
+
*/
|
|
19
|
+
warn: winston.LeveledLogMethod;
|
|
20
|
+
/**
|
|
21
|
+
* Detail on regular operation.
|
|
22
|
+
*/
|
|
23
|
+
info: winston.LeveledLogMethod;
|
|
24
|
+
/**
|
|
25
|
+
* Anything else, i.e. too verbose to be included in "info" level.
|
|
26
|
+
*/
|
|
27
|
+
debug: winston.LeveledLogMethod;
|
|
28
|
+
/**
|
|
29
|
+
* Logging from external libraries used by your app or very detailed application logging.
|
|
30
|
+
*/
|
|
31
|
+
verbose: winston.LeveledLogMethod;
|
|
32
|
+
child(options: Object): Logger;
|
|
33
|
+
}
|