@ruiapp/rapid-core
Advanced tools
Comparing version 0.1.26 to 0.1.27
@@ -1,2 +0,2 @@ | ||
import { RpdApplicationConfig } from "../types"; | ||
import { CreateEntityOptions, RpdApplicationConfig, RpdDataModel } from "../types"; | ||
import { IRpdServer, RapidPlugin } from "./server"; | ||
@@ -37,3 +37,5 @@ import { RouteContext } from "./routeContext"; | ||
beforeRunRouteActions(handlerContext: ActionHandlerContext): Promise<void>; | ||
/** 在创建实体前调用。 */ | ||
beforeCreateEntity(model: RpdDataModel, options: CreateEntityOptions): Promise<void>; | ||
} | ||
export default PluginManager; |
@@ -1,2 +0,2 @@ | ||
import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdDataModelProperty, RpdServerEventTypes } from "../types"; | ||
import { CreateEntityOptions, GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdDataModelProperty, RpdServerEventTypes } from "../types"; | ||
import { IPluginActionHandler, ActionHandler, ActionHandlerContext } from "./actionHandler"; | ||
@@ -29,2 +29,3 @@ import { Next, RouteContext } from "./routeContext"; | ||
beforeRunRouteActions(handlerContext: ActionHandlerContext): Promise<void>; | ||
beforeCreateEntity(model: RpdDataModel, options: CreateEntityOptions): Promise<void>; | ||
} | ||
@@ -98,2 +99,4 @@ export type RpdConfigurationItemTypes = "integer" | "text" | "boolean" | "date" | "datetime" | "json"; | ||
beforeRunRouteActions?: (server: IRpdServer, handlerContext: ActionHandlerContext) => Promise<any>; | ||
/** 在创建实体前调用。 */ | ||
beforeCreateEntity?: (server: IRpdServer, model: RpdDataModel, options: CreateEntityOptions) => Promise<any>; | ||
} |
@@ -13,2 +13,3 @@ export * from "./types"; | ||
export { default as RouteManagePlugin } from "./plugins/routeManage/RouteManagePlugin"; | ||
export { default as SequencePlugin } from "./plugins/sequence/SequencePlugin"; | ||
export { default as WebhooksPlugin } from "./plugins/webhooks/WebhooksPlugin"; | ||
@@ -15,0 +16,0 @@ export { default as AuthPlugin } from "./plugins/auth/AuthPlugin"; |
@@ -1,2 +0,2 @@ | ||
import { GetDataAccessorOptions, GetModelOptions, IDatabaseAccessor, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes, RapidServerConfig, RpdDataModelProperty } from "./types"; | ||
import { GetDataAccessorOptions, GetModelOptions, IDatabaseAccessor, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RpdApplicationConfig, RpdDataModel, RpdServerEventTypes, RapidServerConfig, RpdDataModelProperty, CreateEntityOptions } from "./types"; | ||
import { ActionHandler, ActionHandlerContext, IPluginActionHandler } from "./core/actionHandler"; | ||
@@ -44,2 +44,3 @@ import { IRpdServer, RapidPlugin } from "./core/server"; | ||
beforeRunRouteActions(handlerContext: ActionHandlerContext): Promise<void>; | ||
beforeCreateEntity(model: RpdDataModel, options: CreateEntityOptions): Promise<void>; | ||
} |
@@ -358,1 +358,44 @@ import { RapidPlugin } from "./core/server"; | ||
} | ||
export type SequenceSegmentConfig = SequenceLiteralSegmentConfig | SequenceYearSegmentConfig | SequenceMonthSegmentConfig | SequenceDayOfMonthSegmentConfig | SequenceDayOfWeekSegmentConfig | SequenceDayOfYearSegmentConfig | SequenceParameterSegmentConfig | SequenceAutoIncrementSegmentConfig; | ||
export type SequenceLiteralSegmentConfig = { | ||
type: "literal"; | ||
content: string; | ||
}; | ||
export type SequenceYearSegmentConfig = { | ||
type: "year"; | ||
padding?: string; | ||
length?: number; | ||
}; | ||
export type SequenceMonthSegmentConfig = { | ||
type: "month"; | ||
padding?: string; | ||
length?: number; | ||
}; | ||
export type SequenceDayOfMonthSegmentConfig = { | ||
type: "dayOfMonth"; | ||
padding?: string; | ||
length?: number; | ||
}; | ||
export type SequenceDayOfWeekSegmentConfig = { | ||
type: "dayOfWeek"; | ||
padding?: string; | ||
length?: number; | ||
}; | ||
export type SequenceDayOfYearSegmentConfig = { | ||
type: "dayOfYear"; | ||
padding?: string; | ||
length?: number; | ||
}; | ||
export type SequenceParameterSegmentConfig = { | ||
type: "parameter"; | ||
parameterName: string; | ||
padding?: string; | ||
length?: number; | ||
}; | ||
export type SequenceAutoIncrementSegmentConfig = { | ||
type: "autoIncrement"; | ||
scope: string; | ||
period: "forever" | "day" | "month" | "year"; | ||
padding?: string; | ||
length?: number; | ||
}; |
{ | ||
"name": "@ruiapp/rapid-core", | ||
"version": "0.1.26", | ||
"version": "0.1.27", | ||
"description": "", | ||
@@ -21,2 +21,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"dayjs": "^1.11.7", | ||
"jsonwebtoken": "^9.0.2", | ||
@@ -23,0 +24,0 @@ "koa-tree-router": "^0.12.1", |
@@ -1,2 +0,2 @@ | ||
import { RpdApplicationConfig } from "~/types"; | ||
import { CreateEntityOptions, RpdApplicationConfig, RpdDataModel } from "~/types"; | ||
import { IRpdServer, RapidPlugin } from "./server"; | ||
@@ -162,4 +162,16 @@ import { RouteContext } from "./routeContext"; | ||
} | ||
/** 在创建实体前调用。 */ | ||
async beforeCreateEntity( | ||
model: RpdDataModel, | ||
options: CreateEntityOptions, | ||
) { | ||
for (const plugin of this.#plugins) { | ||
if (plugin.beforeCreateEntity) { | ||
await plugin.beforeCreateEntity(this.#server, model, options); | ||
} | ||
} | ||
} | ||
} | ||
export default PluginManager; |
@@ -53,2 +53,3 @@ import { isArray, isObject } from "lodash"; | ||
const body = JSON.stringify(obj); | ||
this.headers.set("Content-Type", "application/json"); | ||
const responseHeaders = new Headers(this.headers); | ||
@@ -55,0 +56,0 @@ if (headers) { |
@@ -1,2 +0,2 @@ | ||
import { GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdDataModelProperty, RpdServerEventTypes } from "~/types"; | ||
import { CreateEntityOptions, GetDataAccessorOptions, GetModelOptions, IDatabaseConfig, IQueryBuilder, IRpdDataAccessor, RapidServerConfig, RpdApplicationConfig, RpdDataModel, RpdDataModelProperty, RpdServerEventTypes } from "~/types"; | ||
import { IPluginActionHandler, ActionHandler, ActionHandlerContext } from "./actionHandler"; | ||
@@ -51,2 +51,3 @@ import { Next, RouteContext } from "./routeContext"; | ||
beforeRunRouteActions(handlerContext: ActionHandlerContext): Promise<void>; | ||
beforeCreateEntity(model: RpdDataModel, options: CreateEntityOptions): Promise<void>; | ||
} | ||
@@ -143,2 +144,4 @@ | ||
beforeRunRouteActions?: (server: IRpdServer, handlerContext: ActionHandlerContext) => Promise<any>; | ||
/** 在创建实体前调用。 */ | ||
beforeCreateEntity?: (server: IRpdServer, model: RpdDataModel, options: CreateEntityOptions) => Promise<any>; | ||
} |
@@ -736,2 +736,5 @@ import { | ||
const model = this.getModel(); | ||
await this.#server.beforeCreateEntity(model, options); | ||
const newEntity = await createEntity(this.#server, this.#dataAccessor, options); | ||
@@ -738,0 +741,0 @@ |
@@ -20,2 +20,3 @@ import { fixBigIntJSONSerialize } from "./polyfill"; | ||
export { default as RouteManagePlugin } from "./plugins/routeManage/RouteManagePlugin"; | ||
export { default as SequencePlugin } from "./plugins/sequence/SequencePlugin"; | ||
export { default as WebhooksPlugin } from "./plugins/webhooks/WebhooksPlugin"; | ||
@@ -22,0 +23,0 @@ export { default as AuthPlugin } from "./plugins/auth/AuthPlugin"; |
@@ -14,2 +14,3 @@ import DataAccessor from "./dataAccess/dataAccessor"; | ||
RpdDataModelProperty, | ||
CreateEntityOptions, | ||
} from "./types"; | ||
@@ -325,2 +326,6 @@ | ||
} | ||
async beforeCreateEntity(model: RpdDataModel, options: CreateEntityOptions) { | ||
await this.#pluginManager.beforeCreateEntity(model, options); | ||
} | ||
} |
@@ -471,1 +471,63 @@ import { RapidPlugin } from "./core/server"; | ||
} | ||
export type SequenceSegmentConfig = | ||
| SequenceLiteralSegmentConfig | ||
| SequenceYearSegmentConfig | ||
| SequenceMonthSegmentConfig | ||
| SequenceDayOfMonthSegmentConfig | ||
| SequenceDayOfWeekSegmentConfig | ||
| SequenceDayOfYearSegmentConfig | ||
| SequenceParameterSegmentConfig | ||
| SequenceAutoIncrementSegmentConfig | ||
; | ||
export type SequenceLiteralSegmentConfig = { | ||
type: "literal", | ||
content: string; | ||
} | ||
export type SequenceYearSegmentConfig = { | ||
type: "year", | ||
padding?: string; | ||
length?: number; | ||
} | ||
export type SequenceMonthSegmentConfig = { | ||
type: "month", | ||
padding?: string; | ||
length?: number; | ||
} | ||
export type SequenceDayOfMonthSegmentConfig = { | ||
type: "dayOfMonth", | ||
padding?: string; | ||
length?: number; | ||
} | ||
export type SequenceDayOfWeekSegmentConfig = { | ||
type: "dayOfWeek", | ||
padding?: string; | ||
length?: number; | ||
} | ||
export type SequenceDayOfYearSegmentConfig = { | ||
type: "dayOfYear", | ||
padding?: string; | ||
length?: number; | ||
} | ||
export type SequenceParameterSegmentConfig = { | ||
type: "parameter", | ||
parameterName: string; | ||
padding?: string; | ||
length?: number; | ||
} | ||
export type SequenceAutoIncrementSegmentConfig = { | ||
type: "autoIncrement", | ||
scope: string; | ||
period: "forever" | "day" | "month" | "year"; | ||
padding?: string; | ||
length?: number; | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
475054
212
13253
7
+ Addeddayjs@^1.11.7
+ Addeddayjs@1.11.13(transitive)