@andrewcaires/api 5.4.0 → 5.4.2
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 +22 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +80 -5
- package/dist/index.esm.js +2 -2
- package/package.json +9 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @andrewcaires/api v5.4.
|
|
2
|
+
* @andrewcaires/api v5.4.2
|
|
3
3
|
* Simple api for small applications using express, jsonwebtoken, sequelize and websocket
|
|
4
4
|
* (c) 2026 Andrew Caires
|
|
5
5
|
* @license: MIT
|
|
@@ -174,6 +174,14 @@ declare enum LogLevels {
|
|
|
174
174
|
ERROR = "error"
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
declare enum PageTypes {
|
|
178
|
+
PAGE = "page",
|
|
179
|
+
GROUP = "group",
|
|
180
|
+
DIVIDER = "divider",
|
|
181
|
+
HIDDEN = "hidden",
|
|
182
|
+
EXTERNAL = "external"
|
|
183
|
+
}
|
|
184
|
+
|
|
177
185
|
declare enum TenantStatus {
|
|
178
186
|
ACTIVE = "active",
|
|
179
187
|
PENDING = "pending",
|
|
@@ -190,6 +198,18 @@ declare enum UserStatus {
|
|
|
190
198
|
ARCHIVED = "archived"
|
|
191
199
|
}
|
|
192
200
|
|
|
201
|
+
interface WorkerCliRequest {
|
|
202
|
+
name: string;
|
|
203
|
+
}
|
|
204
|
+
interface WorkerDeclaration {
|
|
205
|
+
name: string;
|
|
206
|
+
}
|
|
207
|
+
type WorkerHandlerResult = unknown | Promise<unknown>;
|
|
208
|
+
type WorkerHandler = () => WorkerHandlerResult;
|
|
209
|
+
interface WorkerRegistered extends WorkerDeclaration {
|
|
210
|
+
run: WorkerHandler;
|
|
211
|
+
}
|
|
212
|
+
|
|
193
213
|
declare class RegisterModel extends Model$1 {
|
|
194
214
|
readonly id: string;
|
|
195
215
|
hash: string;
|
|
@@ -215,6 +235,26 @@ declare class UserAuthModel extends Model$1 {
|
|
|
215
235
|
user: UserModel;
|
|
216
236
|
}
|
|
217
237
|
|
|
238
|
+
declare class PageModel extends Model$1 {
|
|
239
|
+
readonly id: string;
|
|
240
|
+
type: PageTypes;
|
|
241
|
+
name: string;
|
|
242
|
+
description: string;
|
|
243
|
+
icon: string;
|
|
244
|
+
path: string;
|
|
245
|
+
position: number;
|
|
246
|
+
active: boolean;
|
|
247
|
+
metadata: TypeAnyObject;
|
|
248
|
+
readonly created_at: Date;
|
|
249
|
+
readonly updated_at: Date;
|
|
250
|
+
readonly deleted_at: Date | null;
|
|
251
|
+
page_id: string;
|
|
252
|
+
page: PageModel;
|
|
253
|
+
pages: Array<PageModel>;
|
|
254
|
+
permission_id: string;
|
|
255
|
+
permission: PermissionModel;
|
|
256
|
+
}
|
|
257
|
+
|
|
218
258
|
declare class PermissionModel extends Model$1 {
|
|
219
259
|
readonly id: string;
|
|
220
260
|
name: string;
|
|
@@ -225,6 +265,7 @@ declare class PermissionModel extends Model$1 {
|
|
|
225
265
|
readonly updated_at: Date;
|
|
226
266
|
readonly deleted_at: Date | null;
|
|
227
267
|
groups_permissions: Array<GroupPermissionModel>;
|
|
268
|
+
pages: Array<PageModel>;
|
|
228
269
|
}
|
|
229
270
|
|
|
230
271
|
declare class GroupPermissionModel extends Model$1 {
|
|
@@ -495,7 +536,9 @@ declare class ModelService<M extends Model<any>> extends Service {
|
|
|
495
536
|
|
|
496
537
|
declare class UserService extends Service {
|
|
497
538
|
private hashOptions;
|
|
498
|
-
|
|
539
|
+
canAssignPassword(user_id: string, password: string): Promise<boolean>;
|
|
540
|
+
checkPassword(user_id: string, password: string): Promise<boolean>;
|
|
541
|
+
createPassword(user_id: string, value: string, ctx?: Context): Promise<boolean>;
|
|
499
542
|
getGroups(user_id: string, tenant_id?: string | null): Promise<Array<string>>;
|
|
500
543
|
getPermissions(user_id: string, tenant_id?: string | null): Promise<Array<string>>;
|
|
501
544
|
getTenants(user_id: string): Promise<Array<{
|
|
@@ -508,10 +551,17 @@ declare class Application<T extends ApplicationEvents = ApplicationEvents> exten
|
|
|
508
551
|
authService: AuthService;
|
|
509
552
|
userService: UserService;
|
|
510
553
|
private _webSocket?;
|
|
554
|
+
private _prepared;
|
|
511
555
|
constructor(controllers: Array<object | TypeAnyConstructor<object>>, options?: ExpressOptions);
|
|
512
556
|
error(error: any, source?: string): void;
|
|
513
557
|
log(message: string, source?: string): void;
|
|
514
558
|
listen(): Promise<void>;
|
|
559
|
+
prepare(): Promise<void>;
|
|
560
|
+
run(argv?: Array<string>): Promise<unknown>;
|
|
561
|
+
runWorker(name: string): Promise<unknown>;
|
|
562
|
+
workerCliRequest(argv?: Array<string>): WorkerCliRequest | undefined;
|
|
563
|
+
private getCliOption;
|
|
564
|
+
private writeWorkerResult;
|
|
515
565
|
migrations(database: Sequelize): Promise<void>;
|
|
516
566
|
websocket(): WebSocketServer | undefined;
|
|
517
567
|
}
|
|
@@ -644,6 +694,16 @@ declare class McpController extends BaseController {
|
|
|
644
694
|
private getAllowedOrigin;
|
|
645
695
|
}
|
|
646
696
|
|
|
697
|
+
declare class PagesController extends CrudController<PageModel> {
|
|
698
|
+
protected readonly model: typeof PageModel;
|
|
699
|
+
private schemaCreate;
|
|
700
|
+
private schemaUpdate;
|
|
701
|
+
CrudValidateCreate(): TypeObject<ValidationBase>;
|
|
702
|
+
CrudValidateUpdate(): TypeObject<ValidationBase>;
|
|
703
|
+
protected position(ctx: Context, pages: Array<TypeAnyObject>): Promise<void>;
|
|
704
|
+
private checkPages;
|
|
705
|
+
}
|
|
706
|
+
|
|
647
707
|
declare class PermissionsController extends CrudController<PermissionModel> {
|
|
648
708
|
protected readonly model: typeof PermissionModel;
|
|
649
709
|
protected groupModelService: ModelService<GroupModel>;
|
|
@@ -923,6 +983,9 @@ declare const discoverMcpTools: (controllers: Array<object>) => Array<McpRegiste
|
|
|
923
983
|
|
|
924
984
|
declare class TestController extends BaseController {
|
|
925
985
|
protected json(ctx: Context): Promise<void>;
|
|
986
|
+
protected workerSum(): Promise<{
|
|
987
|
+
value: number;
|
|
988
|
+
}>;
|
|
926
989
|
protected sum(args: TypeAnyObject, _context: McpToolContext): Promise<{
|
|
927
990
|
value: number;
|
|
928
991
|
}>;
|
|
@@ -982,9 +1045,12 @@ declare class UsersController extends ModelController<UserModel> {
|
|
|
982
1045
|
protected readonly model: typeof UserModel;
|
|
983
1046
|
protected readonly permissions: string[];
|
|
984
1047
|
path: string;
|
|
1048
|
+
protected readonly userService: UserService;
|
|
985
1049
|
constructor();
|
|
986
1050
|
protected avatar(ctx: Context, user: UserModel): Promise<void>;
|
|
987
1051
|
protected avatar_del(ctx: Context, user: UserModel): Promise<void>;
|
|
1052
|
+
protected password(ctx: Context, oldPassword: string, newPassword: string, user: UserModel): Promise<void>;
|
|
1053
|
+
protected password_admin(ctx: Context, password: string, user_id: string): Promise<void>;
|
|
988
1054
|
protected add(ctx: Context): Promise<void>;
|
|
989
1055
|
protected all(ctx: Context): Promise<void>;
|
|
990
1056
|
protected rows(ctx: Context): Promise<void>;
|
|
@@ -1068,6 +1134,15 @@ declare const McpTool: (options: McpToolOptions) => MethodDecorator;
|
|
|
1068
1134
|
|
|
1069
1135
|
declare const Audit: (active?: boolean) => ClassDecorator;
|
|
1070
1136
|
|
|
1137
|
+
declare const WORKER_METADATA: unique symbol;
|
|
1138
|
+
interface WorkerMetadata extends WorkerDeclaration {
|
|
1139
|
+
propertyKey: string | symbol;
|
|
1140
|
+
}
|
|
1141
|
+
declare const Worker: (name: string) => MethodDecorator;
|
|
1142
|
+
declare const getWorkerMetadata: (target: object | TypeAnyConstructor<object>) => Array<WorkerMetadata>;
|
|
1143
|
+
declare const discoverWorkers: (controllers: Array<object>) => Array<WorkerRegistered>;
|
|
1144
|
+
declare const runWorker: (controllers: Array<object>, name: string) => Promise<unknown>;
|
|
1145
|
+
|
|
1071
1146
|
declare class Env extends Env$1 {
|
|
1072
1147
|
static readonly AUDIT_IGNORE: string[];
|
|
1073
1148
|
static readonly BASE_NAME: string;
|
|
@@ -1095,6 +1170,7 @@ declare class Env extends Env$1 {
|
|
|
1095
1170
|
static readonly PASSWORD_MEMORY_COST: number;
|
|
1096
1171
|
static readonly PASSWORD_PARALLELISM: number;
|
|
1097
1172
|
static readonly PASSWORD_PEPPER: string;
|
|
1173
|
+
static readonly PASSWORD_REUSE: boolean;
|
|
1098
1174
|
static readonly PASSWORD_TIME_COST: number;
|
|
1099
1175
|
static readonly SLEEP_AUTH: number;
|
|
1100
1176
|
static readonly SLEEP_FORGOT: number;
|
|
@@ -1117,9 +1193,8 @@ declare class Env extends Env$1 {
|
|
|
1117
1193
|
static readonly API_SESSION_NAME: string;
|
|
1118
1194
|
static readonly API_SESSION_LIFETIME: number;
|
|
1119
1195
|
static readonly API_SESSION_SECRET: string;
|
|
1120
|
-
static readonly API_USER_HISTORY: boolean;
|
|
1121
1196
|
static readonly API_WEBSOCKET_START: boolean;
|
|
1122
1197
|
}
|
|
1123
1198
|
|
|
1124
|
-
export { Application, Audit, AuditModel, AuditTypes, AuditsController, AuthController, AuthService, BaseController, CanCreate, CanDelete, CanRead, CanUpdate, Config, ConfigModel, CrudController, Env, FilesController, ForgotController, ForgotModel, GroupModel, GroupPermissionModel, GroupTypes, GroupsController, GroupsPermissionsController, HasGroups, HasPermissions, HasScope, HealthController, IsAuthenticated, Log, LogLevels, LogModel, Loggable, LogsController, MCP_DEFAULT_PROTOCOL_VERSION, MCP_HTTP_ALLOW, MCP_HTTP_ALLOWED_METHODS, MCP_HTTP_DEFAULT_ALLOWED_HEADERS, MCP_PROTOCOL_VERSION_HEADER, MCP_SESSION_ID_HEADER, MCP_SUPPORTED_PROTOCOL_VERSIONS, MCP_TOOL_METADATA, McpController, McpError, McpErrorCode, McpHttpHandler, McpInternalError, McpInvalidParamsError, McpInvalidRequestError, McpInvalidSessionError, McpMethodNotFoundError, McpParseError, McpServerError, McpSessionStore, McpTool, McpToolNotFoundError, McpToolRegistry, MigrationModel, ModelController, ModelService, PermissionModel, PermissionsController, RegisterController, RegisterModel, ReqAccess, ReqGroup, ReqGroups, ReqPermission, ReqPermissions, ReqTenant, ReqTenants, ReqUser, Secret, SecretModel, Service, SessionModel, SessionStore, SetupController, TenantModel, TenantStatus, TenantsController, TestController, UserAuthModel, UserGroupModel, UserKeyModel, UserModel, UserPasswordModel, UserService, UserStatus, UserTenantModel, UsersController, UsersGroupsController, UsersKeysController, UsersTenantsController, assertValidMcpToolDefinition, canFactory, discoverMcpTools, getMcpToolMetadata, isJsonParseError, isJsonRpcId, jsonParseErrorResponse, jsonRpcError, jsonRpcErrorFromCode, jsonRpcResult, parseJsonRpcRequest, sequelize };
|
|
1125
|
-
export type { ApplicationEvents, AuthEvents, AuthResult, ForgotEvents, McpCallToolResult, McpDecoratedToolHandler, McpHttpHandlerOptions, McpHttpResponse, McpJsonRpcErrorBody, McpJsonRpcErrorResult, McpJsonRpcId, McpJsonRpcRequest, McpJsonRpcResult, McpLogger, McpNormalizedValidation, McpProtocolVersion, McpRegisteredTool, McpSession, McpToolCallLog, McpToolContext, McpToolDeclaration, McpToolDefinition, McpToolHandlerResult, McpToolInput, McpToolMetadata, McpToolOptions, McpToolOutput, ModelArgumentsBase, ModelArgumentsCount, ModelArgumentsCreate, ModelArgumentsDelete, ModelArgumentsFindAll, ModelArgumentsFindOne, ModelArgumentsInclude, ModelArgumentsUpdate, ModelCallbackFindAll, ModelCallbackFindOne, ModelOptions, ModelResultFindAll, RegisterEvents };
|
|
1199
|
+
export { Application, Audit, AuditModel, AuditTypes, AuditsController, AuthController, AuthService, BaseController, CanCreate, CanDelete, CanRead, CanUpdate, Config, ConfigModel, CrudController, Env, FilesController, ForgotController, ForgotModel, GroupModel, GroupPermissionModel, GroupTypes, GroupsController, GroupsPermissionsController, HasGroups, HasPermissions, HasScope, HealthController, IsAuthenticated, Log, LogLevels, LogModel, Loggable, LogsController, MCP_DEFAULT_PROTOCOL_VERSION, MCP_HTTP_ALLOW, MCP_HTTP_ALLOWED_METHODS, MCP_HTTP_DEFAULT_ALLOWED_HEADERS, MCP_PROTOCOL_VERSION_HEADER, MCP_SESSION_ID_HEADER, MCP_SUPPORTED_PROTOCOL_VERSIONS, MCP_TOOL_METADATA, McpController, McpError, McpErrorCode, McpHttpHandler, McpInternalError, McpInvalidParamsError, McpInvalidRequestError, McpInvalidSessionError, McpMethodNotFoundError, McpParseError, McpServerError, McpSessionStore, McpTool, McpToolNotFoundError, McpToolRegistry, MigrationModel, ModelController, ModelService, PageModel, PageTypes, PagesController, PermissionModel, PermissionsController, RegisterController, RegisterModel, ReqAccess, ReqGroup, ReqGroups, ReqPermission, ReqPermissions, ReqTenant, ReqTenants, ReqUser, Secret, SecretModel, Service, SessionModel, SessionStore, SetupController, TenantModel, TenantStatus, TenantsController, TestController, UserAuthModel, UserGroupModel, UserKeyModel, UserModel, UserPasswordModel, UserService, UserStatus, UserTenantModel, UsersController, UsersGroupsController, UsersKeysController, UsersTenantsController, WORKER_METADATA, Worker, assertValidMcpToolDefinition, canFactory, discoverMcpTools, discoverWorkers, getMcpToolMetadata, getWorkerMetadata, isJsonParseError, isJsonRpcId, jsonParseErrorResponse, jsonRpcError, jsonRpcErrorFromCode, jsonRpcResult, parseJsonRpcRequest, runWorker, sequelize };
|
|
1200
|
+
export type { ApplicationEvents, AuthEvents, AuthResult, ForgotEvents, McpCallToolResult, McpDecoratedToolHandler, McpHttpHandlerOptions, McpHttpResponse, McpJsonRpcErrorBody, McpJsonRpcErrorResult, McpJsonRpcId, McpJsonRpcRequest, McpJsonRpcResult, McpLogger, McpNormalizedValidation, McpProtocolVersion, McpRegisteredTool, McpSession, McpToolCallLog, McpToolContext, McpToolDeclaration, McpToolDefinition, McpToolHandlerResult, McpToolInput, McpToolMetadata, McpToolOptions, McpToolOutput, ModelArgumentsBase, ModelArgumentsCount, ModelArgumentsCreate, ModelArgumentsDelete, ModelArgumentsFindAll, ModelArgumentsFindOne, ModelArgumentsInclude, ModelArgumentsUpdate, ModelCallbackFindAll, ModelCallbackFindOne, ModelOptions, ModelResultFindAll, RegisterEvents, WorkerCliRequest, WorkerDeclaration, WorkerHandler, WorkerHandlerResult, WorkerMetadata, WorkerRegistered };
|