@ruiapp/rapid-core 0.0.1
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/bootstrapApplicationConfig.d.ts +3 -0
- package/dist/core/eventManager.d.ts +7 -0
- package/dist/core/http-types.d.ts +3 -0
- package/dist/core/httpHandler.d.ts +18 -0
- package/dist/core/plugin.d.ts +6 -0
- package/dist/core/pluginManager.d.ts +27 -0
- package/dist/core/request.d.ts +15 -0
- package/dist/core/response.d.ts +17 -0
- package/dist/core/routeContext.d.ts +17 -0
- package/dist/core/routesBuilder.d.ts +4 -0
- package/dist/core/server.d.ts +83 -0
- package/dist/dataAccess/dataAccessor.d.ts +20 -0
- package/dist/dataAccess/entityManager.d.ts +6 -0
- package/dist/dataAccess/entityMapper.d.ts +3 -0
- package/dist/dataAccess/filterHelper.d.ts +2 -0
- package/dist/dataAccess/propertyMapper.d.ts +3 -0
- package/dist/deno-std/assert/assert.d.ts +2 -0
- package/dist/deno-std/assert/assertion_error.d.ts +4 -0
- package/dist/deno-std/datetime/to_imf.d.ts +17 -0
- package/dist/deno-std/http/cookie.d.ts +134 -0
- package/dist/helpers/entityHelpers.d.ts +1 -0
- package/dist/helpers/inputHelper.d.ts +1 -0
- package/dist/helpers/runCollectionEntityHttpHandler.d.ts +5 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3590 -0
- package/dist/plugins/authManager/httpHandlers/createSession.d.ts +8 -0
- package/dist/plugins/authManager/httpHandlers/deleteSession.d.ts +4 -0
- package/dist/plugins/authManager/httpHandlers/getMyProfile.d.ts +4 -0
- package/dist/plugins/authManager/httpHandlers/index.d.ts +5 -0
- package/dist/plugins/authManager/mod.d.ts +16 -0
- package/dist/plugins/authManager/models/AccessToken.d.ts +3 -0
- package/dist/plugins/authManager/models/index.d.ts +2 -0
- package/dist/plugins/authManager/routes/getMyProfile.d.ts +3 -0
- package/dist/plugins/authManager/routes/index.d.ts +2 -0
- package/dist/plugins/authManager/routes/signin.d.ts +3 -0
- package/dist/plugins/authManager/routes/signout.d.ts +3 -0
- package/dist/plugins/dataManager/httpHandlers/addEntityRelations.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/countCollectionEntities.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntity.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/deleteCollectionEntityById.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntities.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntityById.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/queryDatabase.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/removeEntityRelations.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/updateCollectionEntityById.d.ts +4 -0
- package/dist/plugins/dataManager/mod.d.ts +16 -0
- package/dist/plugins/metaManager/httpHandlers/getMetaModelDetail.d.ts +4 -0
- package/dist/plugins/metaManager/httpHandlers/listMetaModels.d.ts +4 -0
- package/dist/plugins/metaManager/mod.d.ts +15 -0
- package/dist/plugins/routeManager/httpHandlers/httpProxy.d.ts +4 -0
- package/dist/plugins/routeManager/httpHandlers/listMetaRoutes.d.ts +4 -0
- package/dist/plugins/routeManager/mod.d.ts +15 -0
- package/dist/plugins/webhooks/mod.d.ts +24 -0
- package/dist/plugins/webhooks/pluginConfig.d.ts +48 -0
- package/dist/polyfill.d.ts +1 -0
- package/dist/proxy/mod.d.ts +13 -0
- package/dist/proxy/types.d.ts +17 -0
- package/dist/queryBuilder/index.d.ts +1 -0
- package/dist/queryBuilder/queryBuilder.d.ts +34 -0
- package/dist/server.d.ts +31 -0
- package/dist/types.d.ts +327 -0
- package/dist/utilities/httpUtility.d.ts +1 -0
- package/dist/utilities/jwtUtility.d.ts +8 -0
- package/dist/utilities/rapidUtility.d.ts +2 -0
- package/dist/utilities/typeUtility.d.ts +3 -0
- package/package.json +29 -0
- package/rollup.config.js +20 -0
- package/src/bootstrapApplicationConfig.ts +524 -0
- package/src/core/eventManager.ts +21 -0
- package/src/core/http-types.ts +4 -0
- package/src/core/httpHandler.ts +29 -0
- package/src/core/plugin.ts +13 -0
- package/src/core/pluginManager.ts +143 -0
- package/src/core/request.ts +23 -0
- package/src/core/response.ts +77 -0
- package/src/core/routeContext.ts +38 -0
- package/src/core/routesBuilder.ts +86 -0
- package/src/core/server.ts +144 -0
- package/src/dataAccess/dataAccessor.ts +110 -0
- package/src/dataAccess/entityManager.ts +651 -0
- package/src/dataAccess/entityMapper.ts +74 -0
- package/src/dataAccess/filterHelper.ts +47 -0
- package/src/dataAccess/propertyMapper.ts +27 -0
- package/src/deno-std/assert/assert.ts +9 -0
- package/src/deno-std/assert/assertion_error.ts +7 -0
- package/src/deno-std/datetime/to_imf.ts +47 -0
- package/src/deno-std/http/cookie.ts +398 -0
- package/src/helpers/entityHelpers.ts +24 -0
- package/src/helpers/inputHelper.ts +11 -0
- package/src/helpers/runCollectionEntityHttpHandler.ts +34 -0
- package/src/index.ts +12 -0
- package/src/plugins/authManager/httpHandlers/createSession.ts +57 -0
- package/src/plugins/authManager/httpHandlers/deleteSession.ts +22 -0
- package/src/plugins/authManager/httpHandlers/getMyProfile.ts +43 -0
- package/src/plugins/authManager/httpHandlers/index.ts +10 -0
- package/src/plugins/authManager/mod.ts +56 -0
- package/src/plugins/authManager/models/AccessToken.ts +56 -0
- package/src/plugins/authManager/models/index.ts +5 -0
- package/src/plugins/authManager/routes/getMyProfile.ts +15 -0
- package/src/plugins/authManager/routes/index.ts +9 -0
- package/src/plugins/authManager/routes/signin.ts +15 -0
- package/src/plugins/authManager/routes/signout.ts +15 -0
- package/src/plugins/dataManager/httpHandlers/addEntityRelations.ts +76 -0
- package/src/plugins/dataManager/httpHandlers/countCollectionEntities.ts +22 -0
- package/src/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.ts +57 -0
- package/src/plugins/dataManager/httpHandlers/createCollectionEntity.ts +43 -0
- package/src/plugins/dataManager/httpHandlers/deleteCollectionEntityById.ts +38 -0
- package/src/plugins/dataManager/httpHandlers/findCollectionEntities.ts +35 -0
- package/src/plugins/dataManager/httpHandlers/findCollectionEntityById.ts +30 -0
- package/src/plugins/dataManager/httpHandlers/queryDatabase.ts +29 -0
- package/src/plugins/dataManager/httpHandlers/removeEntityRelations.ts +72 -0
- package/src/plugins/dataManager/httpHandlers/updateCollectionEntityById.ts +53 -0
- package/src/plugins/dataManager/mod.ts +150 -0
- package/src/plugins/metaManager/httpHandlers/getMetaModelDetail.ts +14 -0
- package/src/plugins/metaManager/httpHandlers/listMetaModels.ts +13 -0
- package/src/plugins/metaManager/mod.ts +419 -0
- package/src/plugins/routeManager/httpHandlers/httpProxy.ts +15 -0
- package/src/plugins/routeManager/httpHandlers/listMetaRoutes.ts +13 -0
- package/src/plugins/routeManager/mod.ts +97 -0
- package/src/plugins/webhooks/mod.ts +144 -0
- package/src/plugins/webhooks/pluginConfig.ts +74 -0
- package/src/polyfill.ts +5 -0
- package/src/proxy/mod.ts +47 -0
- package/src/proxy/types.ts +21 -0
- package/src/queryBuilder/index.ts +1 -0
- package/src/queryBuilder/queryBuilder.ts +424 -0
- package/src/server.ts +192 -0
- package/src/types.ts +438 -0
- package/src/utilities/httpUtility.ts +23 -0
- package/src/utilities/jwtUtility.ts +16 -0
- package/src/utilities/rapidUtility.ts +5 -0
- package/src/utilities/typeUtility.ts +11 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RpdServerEventTypes as EventTypes } from "~/types";
|
|
2
|
+
export default class EventManager {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
on<K extends keyof EventTypes>(eventName: K, listener: (...args: EventTypes[K]) => void): void;
|
|
6
|
+
emit<K extends keyof EventTypes>(eventName: K, ...args: EventTypes[K]): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IPluginInstance, RpdApplicationConfig } from "~/types";
|
|
2
|
+
import { IRpdServer } from "./server";
|
|
3
|
+
import { Next, RouteContext } from "./routeContext";
|
|
4
|
+
export interface HttpHandlerContext {
|
|
5
|
+
routerContext: RouteContext;
|
|
6
|
+
next: Next;
|
|
7
|
+
server: IRpdServer;
|
|
8
|
+
applicationConfig: RpdApplicationConfig;
|
|
9
|
+
input?: any;
|
|
10
|
+
output?: any;
|
|
11
|
+
status?: Response["status"];
|
|
12
|
+
}
|
|
13
|
+
export type PluginHttpHandler = (plugin: IPluginInstance, ctx: HttpHandlerContext, options: any) => void | Promise<void>;
|
|
14
|
+
export type HttpRequestHandler = (ctx: HttpHandlerContext, options: any) => void | Promise<void>;
|
|
15
|
+
export interface IPluginHttpHandler {
|
|
16
|
+
code: string;
|
|
17
|
+
handler: PluginHttpHandler;
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RpdApplicationConfig } from "~/types";
|
|
2
|
+
import { IRpdServer } from "./server";
|
|
3
|
+
export declare function loadPlugins(): Promise<void>;
|
|
4
|
+
/** 初始化插件时调用。 */
|
|
5
|
+
export declare function initPlugins(server: IRpdServer): Promise<void>;
|
|
6
|
+
/** 注册中间件 */
|
|
7
|
+
export declare function registerMiddlewares(server: IRpdServer): Promise<void>;
|
|
8
|
+
/** 注册接口动作处理程序 */
|
|
9
|
+
export declare function registerHttpHandlers(server: IRpdServer): Promise<void>;
|
|
10
|
+
/** 注册事件处理程序 */
|
|
11
|
+
export declare function registerEventHandlers(server: IRpdServer): Promise<void>;
|
|
12
|
+
/** 注册消息处理程序 */
|
|
13
|
+
export declare function registerMessageHandlers(server: IRpdServer): Promise<void>;
|
|
14
|
+
/** 注册任务处理程序 */
|
|
15
|
+
export declare function registerTaskProcessors(server: IRpdServer): Promise<void>;
|
|
16
|
+
/** 在加载应用前调用。 */
|
|
17
|
+
export declare function onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
18
|
+
/** 配置数据模型 */
|
|
19
|
+
export declare function configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
20
|
+
/** 配置模型属性 */
|
|
21
|
+
export declare function configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
22
|
+
/** 配置路由 */
|
|
23
|
+
export declare function configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
24
|
+
/** 在应用配置加载完成后调用。此时插件可以进行一些数据的初始化工作。 */
|
|
25
|
+
export declare function onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
26
|
+
/** 在应用准备完成后调用。此时服务器已经可以处理网络请求。 */
|
|
27
|
+
export declare function onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const GlobalRequest: {
|
|
2
|
+
new (input: URL | RequestInfo, init?: RequestInit): Request;
|
|
3
|
+
prototype: Request;
|
|
4
|
+
};
|
|
5
|
+
export interface RapidRequestBody {
|
|
6
|
+
type: string;
|
|
7
|
+
value: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class RapidRequest {
|
|
10
|
+
method: string;
|
|
11
|
+
url: URL;
|
|
12
|
+
hasBody: boolean;
|
|
13
|
+
constructor(init: RequestInit);
|
|
14
|
+
body(): RapidRequestBody;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpStatus } from "./http-types";
|
|
2
|
+
export declare const GlobalResponse: {
|
|
3
|
+
new (body?: BodyInit, init?: ResponseInit): Response;
|
|
4
|
+
prototype: Response;
|
|
5
|
+
error(): Response;
|
|
6
|
+
redirect(url: string | URL, status?: number): Response;
|
|
7
|
+
};
|
|
8
|
+
export declare class RapidResponse {
|
|
9
|
+
#private;
|
|
10
|
+
status: number;
|
|
11
|
+
body: BodyInit;
|
|
12
|
+
headers: Headers;
|
|
13
|
+
constructor(body?: BodyInit, init?: ResponseInit);
|
|
14
|
+
json(obj: any, status?: HttpStatus, headers?: HeadersInit): void;
|
|
15
|
+
redirect(location: string, status?: HttpStatus): void;
|
|
16
|
+
getResponse(): Response;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RapidRequest } from "./request";
|
|
2
|
+
import { RapidResponse } from "./response";
|
|
3
|
+
import { HttpStatus } from "./http-types";
|
|
4
|
+
export type Next = () => Promise<void>;
|
|
5
|
+
export declare class RouteContext {
|
|
6
|
+
readonly request: RapidRequest;
|
|
7
|
+
readonly response: RapidResponse;
|
|
8
|
+
readonly state: Record<string, any>;
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
status: HttpStatus;
|
|
12
|
+
params: Record<string, string>;
|
|
13
|
+
constructor(request: RapidRequest);
|
|
14
|
+
set(headerName: string, headerValue: string): void;
|
|
15
|
+
json(obj: any, status?: HttpStatus, headers?: HeadersInit): void;
|
|
16
|
+
redirect(url: string, status?: HttpStatus): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IPluginInstance, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes } from "~/types";
|
|
2
|
+
import { IPluginHttpHandler, HttpRequestHandler } from "./httpHandler";
|
|
3
|
+
import { Next } from "./routeContext";
|
|
4
|
+
export interface IRpdServer {
|
|
5
|
+
config: RapidServerConfig;
|
|
6
|
+
databaseConfig: IDatabaseConfig;
|
|
7
|
+
queryBuilder: IQueryBuilder;
|
|
8
|
+
queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
9
|
+
tryQueryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
10
|
+
registerMiddleware(middleware: any): void;
|
|
11
|
+
registerHttpHandler(plugin: IPluginInstance, options: IPluginHttpHandler): void;
|
|
12
|
+
getHttpHandlerByCode(code: string): HttpRequestHandler | undefined;
|
|
13
|
+
getDataAccessor<T = any>(options: GetDataAccessorOptions): IRpdDataAccessor<T>;
|
|
14
|
+
getApplicationConfig(): RpdApplicationConfig;
|
|
15
|
+
getModel(options: GetModelOptions): RpdDataModel | undefined;
|
|
16
|
+
registerEventHandler<K extends keyof RpdServerEventTypes>(eventName: K, listener: (...args: RpdServerEventTypes[K]) => void): this;
|
|
17
|
+
emitEvent<K extends keyof RpdServerEventTypes>(eventName: K, sender: IPluginInstance, payload: RpdServerEventTypes[K][1]): void;
|
|
18
|
+
handleRequest(request: Request, next: Next): Promise<Response>;
|
|
19
|
+
}
|
|
20
|
+
export type RpdConfigurationItemTypes = "integer" | "text" | "boolean" | "date" | "datetime" | "json";
|
|
21
|
+
export interface RpdConfigurationItemOptions {
|
|
22
|
+
/**
|
|
23
|
+
* 配置项名称。可以包含中文。
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* 配置项代码。
|
|
28
|
+
*/
|
|
29
|
+
code: string;
|
|
30
|
+
/**
|
|
31
|
+
* 配置项类型。
|
|
32
|
+
*/
|
|
33
|
+
type: RpdConfigurationItemTypes;
|
|
34
|
+
/**
|
|
35
|
+
* 是否必须有值。默认为 false。
|
|
36
|
+
*/
|
|
37
|
+
required?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 默认值。使用默认值的 JavaScript 字面量表示。
|
|
40
|
+
*/
|
|
41
|
+
defaultValue?: string;
|
|
42
|
+
}
|
|
43
|
+
export type RpdServerPluginExtendingAbilities = /** 是指提供处理网络请求的middleware的能力。 */ "extendMiddleware" | /** 是指增加系统中的集合的能力。 */ "extendModel" | /** 是指可以对模型增加属性的能力。 */ "extendProperty" | /** 是指增加接口动作的能力。 */ "extendHttpHandler" | /** 是指增加或者修改接口定义的能力。 */ "extendRoute" | /** 是指对实体数据进行标准化的能力。 */ "normalizeEntity" | /** 处理事件总线发送过来的事件的能力。 */ "handleEvent" | /** 处理消息队列发送过来的消息的能力。 */ "handleMessage" | /** 对特定任务进行处理的能力。 */ "processTask";
|
|
44
|
+
export interface RpdServerPluginConfigurableTargetOptions {
|
|
45
|
+
targetCode: string;
|
|
46
|
+
configurations: RpdConfigurationItemOptions[];
|
|
47
|
+
}
|
|
48
|
+
export interface IRpdServerPlugin {
|
|
49
|
+
/** 插件代码 */
|
|
50
|
+
code: string;
|
|
51
|
+
/** 插件描述 */
|
|
52
|
+
description: string;
|
|
53
|
+
/** 插件可以提供哪些扩展能力 */
|
|
54
|
+
extendingAbilities: RpdServerPluginExtendingAbilities[];
|
|
55
|
+
/** 插件可以配置的目标实体,以及和配置目标相关的配置项 */
|
|
56
|
+
configurableTargets?: RpdServerPluginConfigurableTargetOptions[];
|
|
57
|
+
/** 插件的全局配置项 */
|
|
58
|
+
configurations?: RpdConfigurationItemOptions[];
|
|
59
|
+
/** 初始化插件时调用。插件可以在此时进行一些内部对象的初始化工作。 */
|
|
60
|
+
initPlugin: (plugin: IPluginInstance, server: IRpdServer) => Promise<any>;
|
|
61
|
+
/** 注册中间件 */
|
|
62
|
+
registerMiddlewares?: (server: IRpdServer) => Promise<any>;
|
|
63
|
+
/** 注册接口动作处理程序 */
|
|
64
|
+
registerHttpHandlers?: (server: IRpdServer) => Promise<any>;
|
|
65
|
+
/** 注册事件处理程序 */
|
|
66
|
+
registerEventHandlers?: (server: IRpdServer) => Promise<any>;
|
|
67
|
+
/** 注册消息处理程序 */
|
|
68
|
+
registerMessageHandlers?: (server: IRpdServer) => Promise<any>;
|
|
69
|
+
/** 注册任务处理程序 */
|
|
70
|
+
registerTaskProcessors?: (server: IRpdServer) => Promise<any>;
|
|
71
|
+
/** 在加载应用前调用。 */
|
|
72
|
+
onLoadingApplication?: (server: IRpdServer, applicationConfig: RpdApplicationConfig) => Promise<any>;
|
|
73
|
+
/** 配置数据集合 */
|
|
74
|
+
configureModels?: (server: IRpdServer, applicationConfig: RpdApplicationConfig) => Promise<any>;
|
|
75
|
+
/** 配置模型属性 */
|
|
76
|
+
configureModelProperties?: (server: IRpdServer, applicationConfig: RpdApplicationConfig) => Promise<any>;
|
|
77
|
+
/** 配置路由 */
|
|
78
|
+
configureRoutes?: (server: IRpdServer, applicationConfig: RpdApplicationConfig) => Promise<any>;
|
|
79
|
+
/** 在应用配置加载完成后调用。此时插件可以进行一些数据的初始化工作。 */
|
|
80
|
+
onApplicationLoaded?: (server: IRpdServer, applicationConfig: RpdApplicationConfig) => Promise<any>;
|
|
81
|
+
/** 在应用准备完成后调用。此时服务器已经可以处理网络请求,可以对外广播消息。 */
|
|
82
|
+
onApplicationReady?: (server: IRpdServer, applicationConfig: RpdApplicationConfig) => Promise<any>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CountEntityOptions, FindEntityOptions, IRpdDataAccessor, RpdDataModel } from "~/types";
|
|
2
|
+
import QueryBuilder from "~/queryBuilder/queryBuilder";
|
|
3
|
+
export interface IDataAccessorOptions {
|
|
4
|
+
model: RpdDataModel;
|
|
5
|
+
queryBuilder: QueryBuilder;
|
|
6
|
+
}
|
|
7
|
+
export default class DataAccessor<T = any> implements IRpdDataAccessor<T> {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options: IDataAccessorOptions);
|
|
10
|
+
getModel(): RpdDataModel;
|
|
11
|
+
create(entity: Partial<T>): Promise<T>;
|
|
12
|
+
updateById(id: any, entity: Partial<T>): Promise<{
|
|
13
|
+
count: number;
|
|
14
|
+
}>;
|
|
15
|
+
find(options: FindEntityOptions): Promise<T[]>;
|
|
16
|
+
findOne(options: FindEntityOptions): Promise<T>;
|
|
17
|
+
findById(id: any): Promise<T | null>;
|
|
18
|
+
count(options: CountEntityOptions): Promise<any>;
|
|
19
|
+
deleteById(id: any): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CreateEntityOptions, FindEntityOptions, IRpdDataAccessor, UpdateEntityByIdOptions } from "~/types";
|
|
2
|
+
import { IRpdServer } from "~/core/server";
|
|
3
|
+
export declare function findEntities(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: FindEntityOptions): Promise<any[]>;
|
|
4
|
+
export declare function findEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: FindEntityOptions): Promise<any>;
|
|
5
|
+
export declare function createEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: CreateEntityOptions): Promise<any>;
|
|
6
|
+
export declare function updateEntityById(server: IRpdServer, dataAccessor: IRpdDataAccessor, options: UpdateEntityByIdOptions): Promise<any>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats the given date to IMF date time format. (Reference:
|
|
3
|
+
* https://tools.ietf.org/html/rfc7231#section-7.1.1.1).
|
|
4
|
+
* IMF is the time format to use when generating times in HTTP
|
|
5
|
+
* headers. The time being formatted must be in UTC for Format to
|
|
6
|
+
* generate the correct format.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { toIMF } from "https://deno.land/std@$STD_VERSION/datetime/to_imf.ts";
|
|
11
|
+
*
|
|
12
|
+
* toIMF(new Date(0)); // => returns "Thu, 01 Jan 1970 00:00:00 GMT"
|
|
13
|
+
* ```
|
|
14
|
+
* @param date Date to parse
|
|
15
|
+
* @return IMF date formatted string
|
|
16
|
+
*/
|
|
17
|
+
export declare function toIMF(date: Date): string;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export interface Cookie {
|
|
2
|
+
/** Name of the cookie. */
|
|
3
|
+
name: string;
|
|
4
|
+
/** Value of the cookie. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** The cookie's `Expires` attribute, either as an explicit date or UTC milliseconds.
|
|
7
|
+
* @example <caption>Explicit date:</caption>
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Cookie } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
|
11
|
+
* const cookie: Cookie = {
|
|
12
|
+
* name: 'name',
|
|
13
|
+
* value: 'value',
|
|
14
|
+
* // expires on Fri Dec 30 2022
|
|
15
|
+
* expires: new Date('2022-12-31')
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example <caption>UTC milliseconds</caption>
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { Cookie } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
|
23
|
+
* const cookie: Cookie = {
|
|
24
|
+
* name: 'name',
|
|
25
|
+
* value: 'value',
|
|
26
|
+
* // expires 10 seconds from now
|
|
27
|
+
* expires: Date.now() + 10000
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
expires?: Date | number;
|
|
32
|
+
/** The cookie's `Max-Age` attribute, in seconds. Must be a non-negative integer. A cookie with a `maxAge` of `0` expires immediately. */
|
|
33
|
+
maxAge?: number;
|
|
34
|
+
/** The cookie's `Domain` attribute. Specifies those hosts to which the cookie will be sent. */
|
|
35
|
+
domain?: string;
|
|
36
|
+
/** The cookie's `Path` attribute. A cookie with a path will only be included in the `Cookie` request header if the requested URL matches that path. */
|
|
37
|
+
path?: string;
|
|
38
|
+
/** The cookie's `Secure` attribute. If `true`, the cookie will only be included in the `Cookie` request header if the connection uses SSL and HTTPS. */
|
|
39
|
+
secure?: boolean;
|
|
40
|
+
/** The cookie's `HTTPOnly` attribute. If `true`, the cookie cannot be accessed via JavaScript. */
|
|
41
|
+
httpOnly?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Allows servers to assert that a cookie ought not to
|
|
44
|
+
* be sent along with cross-site requests.
|
|
45
|
+
*/
|
|
46
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
47
|
+
/** Additional key value pairs with the form "key=value" */
|
|
48
|
+
unparsed?: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse cookies of a header
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { getCookies } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
|
56
|
+
*
|
|
57
|
+
* const headers = new Headers();
|
|
58
|
+
* headers.set("Cookie", "full=of; tasty=chocolate");
|
|
59
|
+
*
|
|
60
|
+
* const cookies = getCookies(headers);
|
|
61
|
+
* console.log(cookies); // { full: "of", tasty: "chocolate" }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param headers The headers instance to get cookies from
|
|
65
|
+
* @return Object with cookie names as keys
|
|
66
|
+
*/
|
|
67
|
+
export declare function getCookies(headers: Headers): Record<string, string>;
|
|
68
|
+
/**
|
|
69
|
+
* Set the cookie header properly in the headers
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import {
|
|
74
|
+
* Cookie,
|
|
75
|
+
* setCookie,
|
|
76
|
+
* } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
|
77
|
+
*
|
|
78
|
+
* const headers = new Headers();
|
|
79
|
+
* const cookie: Cookie = { name: "Space", value: "Cat" };
|
|
80
|
+
* setCookie(headers, cookie);
|
|
81
|
+
*
|
|
82
|
+
* const cookieHeader = headers.get("set-cookie");
|
|
83
|
+
* console.log(cookieHeader); // Space=Cat
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param headers The headers instance to set the cookie to
|
|
87
|
+
* @param cookie Cookie to set
|
|
88
|
+
*/
|
|
89
|
+
export declare function setCookie(headers: Headers, cookie: Cookie): void;
|
|
90
|
+
/**
|
|
91
|
+
* Set the cookie header with empty value in the headers to delete it
|
|
92
|
+
*
|
|
93
|
+
* > Note: Deleting a `Cookie` will set its expiration date before now. Forcing
|
|
94
|
+
* > the browser to delete it.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* import { deleteCookie } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
|
99
|
+
*
|
|
100
|
+
* const headers = new Headers();
|
|
101
|
+
* deleteCookie(headers, "deno");
|
|
102
|
+
*
|
|
103
|
+
* const cookieHeader = headers.get("set-cookie");
|
|
104
|
+
* console.log(cookieHeader); // deno=; Expires=Thus, 01 Jan 1970 00:00:00 GMT
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @param headers The headers instance to delete the cookie from
|
|
108
|
+
* @param name Name of cookie
|
|
109
|
+
* @param attributes Additional cookie attributes
|
|
110
|
+
*/
|
|
111
|
+
export declare function deleteCookie(headers: Headers, name: string, attributes?: {
|
|
112
|
+
path?: string;
|
|
113
|
+
domain?: string;
|
|
114
|
+
}): void;
|
|
115
|
+
/**
|
|
116
|
+
* Parse set-cookies of a header
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { getSetCookies } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
|
121
|
+
*
|
|
122
|
+
* const headers = new Headers([
|
|
123
|
+
* ["Set-Cookie", "lulu=meow; Secure; Max-Age=3600"],
|
|
124
|
+
* ["Set-Cookie", "booya=kasha; HttpOnly; Path=/"],
|
|
125
|
+
* ]);
|
|
126
|
+
*
|
|
127
|
+
* const cookies = getSetCookies(headers);
|
|
128
|
+
* console.log(cookies); // [{ name: "lulu", value: "meow", secure: true, maxAge: 3600 }, { name: "booya", value: "kahsa", httpOnly: true, path: "/ }]
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param headers The headers instance to get set-cookies from
|
|
132
|
+
* @return List of cookies
|
|
133
|
+
*/
|
|
134
|
+
export declare function getSetCookies(headers: Headers): Cookie[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEntityPartChanges(before: any, after: any): Record<string, any> | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeInput(defaultInput: any, input: any, fixedInput: any): any;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IRpdDataAccessor, RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
+
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
3
|
+
type DataAccessHandler = (dataAccessor: IRpdDataAccessor, input: any) => Promise<any>;
|
|
4
|
+
export default function runCollectionEntityHttpHandler(ctx: HttpHandlerContext, options: RunEntityHttpHandlerOptions, code: string, handleDataAccess: DataAccessHandler): Promise<void>;
|
|
5
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * as RpdServer from "./server";
|
|
3
|
+
export * from "./server";
|
|
4
|
+
export * from "./core/request";
|
|
5
|
+
export * from "./core/routeContext";
|
|
6
|
+
export * from "./core/server";
|
|
7
|
+
export * as bootstrapApplicationConfig from "./bootstrapApplicationConfig";
|