@andrewcaires/api 5.4.4 → 5.6.0
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/index.cjs.js +2 -2
- package/dist/index.d.ts +99 -26
- package/dist/index.esm.js +2 -2
- package/package.json +13 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @andrewcaires/api v5.
|
|
2
|
+
* @andrewcaires/api v5.6.0
|
|
3
3
|
* Simple api for small applications using express, jsonwebtoken, sequelize and websocket
|
|
4
4
|
* (c) 2026 Andrew Caires
|
|
5
5
|
* @license: MIT
|
|
@@ -258,28 +258,53 @@ declare class PageModel extends Model$1 {
|
|
|
258
258
|
declare class PermissionModel extends Model$1 {
|
|
259
259
|
readonly id: string;
|
|
260
260
|
name: string;
|
|
261
|
+
permission: string;
|
|
261
262
|
description: string;
|
|
262
263
|
active: boolean;
|
|
263
264
|
metadata: TypeAnyObject;
|
|
264
265
|
readonly created_at: Date;
|
|
265
266
|
readonly updated_at: Date;
|
|
266
267
|
readonly deleted_at: Date | null;
|
|
267
|
-
|
|
268
|
+
roles_permissions: Array<RolePermissionModel>;
|
|
268
269
|
pages: Array<PageModel>;
|
|
269
270
|
}
|
|
270
271
|
|
|
271
|
-
declare class
|
|
272
|
+
declare class RolePermissionModel extends Model$1 {
|
|
272
273
|
readonly id: string;
|
|
273
274
|
readonly created_at: Date;
|
|
274
|
-
group_id: string;
|
|
275
|
-
group: GroupModel;
|
|
276
275
|
permission_id: string;
|
|
277
276
|
permission: PermissionModel;
|
|
277
|
+
role_id: string;
|
|
278
|
+
role: RoleModel;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
declare class RoleModel extends Model$1 {
|
|
282
|
+
readonly id: string;
|
|
283
|
+
name: string;
|
|
284
|
+
role: string;
|
|
285
|
+
description: string;
|
|
286
|
+
active: boolean;
|
|
287
|
+
metadata: TypeAnyObject;
|
|
288
|
+
readonly created_at: Date;
|
|
289
|
+
readonly updated_at: Date;
|
|
290
|
+
readonly deleted_at: Date | null;
|
|
291
|
+
groups_roles: Array<GroupRoleModel>;
|
|
292
|
+
roles_permissions: Array<RolePermissionModel>;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare class GroupRoleModel extends Model$1 {
|
|
296
|
+
readonly id: string;
|
|
297
|
+
readonly created_at: Date;
|
|
298
|
+
group_id: string;
|
|
299
|
+
group: GroupModel;
|
|
300
|
+
role_id: string;
|
|
301
|
+
role: RoleModel;
|
|
278
302
|
}
|
|
279
303
|
|
|
280
304
|
declare class GroupModel extends Model$1 {
|
|
281
305
|
readonly id: string;
|
|
282
306
|
name: string;
|
|
307
|
+
group: string;
|
|
283
308
|
description: string;
|
|
284
309
|
type: GroupTypes;
|
|
285
310
|
active: boolean;
|
|
@@ -288,7 +313,7 @@ declare class GroupModel extends Model$1 {
|
|
|
288
313
|
readonly updated_at: Date;
|
|
289
314
|
readonly deleted_at: Date | null;
|
|
290
315
|
users_groups: Array<UserGroupModel>;
|
|
291
|
-
|
|
316
|
+
groups_roles: Array<GroupRoleModel>;
|
|
292
317
|
}
|
|
293
318
|
|
|
294
319
|
declare class UserTenantModel extends Model$1 {
|
|
@@ -494,17 +519,21 @@ declare class AuthService extends Service {
|
|
|
494
519
|
private readonly options;
|
|
495
520
|
private readonly userAttributes;
|
|
496
521
|
private readonly userService;
|
|
497
|
-
|
|
498
|
-
|
|
522
|
+
apiAuth(ctx: Context): Promise<AuthResult>;
|
|
523
|
+
apiKeyAuth(key: string): Promise<AuthResult>;
|
|
524
|
+
apiTokenAuth(token: string): Promise<AuthResult>;
|
|
525
|
+
createApiKey(ctx: Context, name: string, expires_at: Date, user: UserModel): Promise<{
|
|
526
|
+
id: string;
|
|
527
|
+
key: string;
|
|
528
|
+
}>;
|
|
499
529
|
createApiToken(ctx: Context, user: UserModel): Promise<{
|
|
500
530
|
token: string;
|
|
501
531
|
}>;
|
|
532
|
+
deleteApiKey(ctx: Context, id: string, user: UserModel): Promise<boolean>;
|
|
502
533
|
renewApiToken(token: string): Promise<{
|
|
503
534
|
token: string;
|
|
504
535
|
}>;
|
|
505
|
-
|
|
506
|
-
apiKeyAuth(key: string): Promise<AuthResult>;
|
|
507
|
-
apiTokenAuth(token: string): Promise<AuthResult>;
|
|
536
|
+
revokeApiKey(ctx: Context, id: string, user: UserModel): Promise<boolean>;
|
|
508
537
|
private attachAuthContext;
|
|
509
538
|
private safeEqual;
|
|
510
539
|
private verifyJwt;
|
|
@@ -541,6 +570,7 @@ declare class UserService extends Service {
|
|
|
541
570
|
createPassword(user_id: string, value: string, ctx?: Context): Promise<boolean>;
|
|
542
571
|
getGroups(user_id: string, tenant_id?: string | null): Promise<Array<string>>;
|
|
543
572
|
getPermissions(user_id: string, tenant_id?: string | null): Promise<Array<string>>;
|
|
573
|
+
getGroupPermissions(group_id: string): Promise<Array<string>>;
|
|
544
574
|
getTenants(user_id: string): Promise<Array<{
|
|
545
575
|
id: string;
|
|
546
576
|
name: string;
|
|
@@ -595,6 +625,7 @@ declare class AuditsController extends ModelController<AuditModel> {
|
|
|
595
625
|
protected readonly model: typeof AuditModel;
|
|
596
626
|
protected readonly permissions: string[];
|
|
597
627
|
protected all(ctx: Context): Promise<void>;
|
|
628
|
+
protected record(ctx: Context, record: string): Promise<void>;
|
|
598
629
|
protected get(ctx: Context): Promise<void>;
|
|
599
630
|
}
|
|
600
631
|
|
|
@@ -655,16 +686,22 @@ declare class GroupsController extends CrudController<GroupModel> {
|
|
|
655
686
|
private checkGroup;
|
|
656
687
|
}
|
|
657
688
|
|
|
658
|
-
declare class GroupsPermissionsController extends
|
|
659
|
-
|
|
689
|
+
declare class GroupsPermissionsController extends BaseController {
|
|
690
|
+
private readonly userService;
|
|
691
|
+
protected all(ctx: Context, group_id: string): Promise<void>;
|
|
692
|
+
private checkGroup;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
declare class GroupsRolesController extends ModelController<RoleModel> {
|
|
696
|
+
protected readonly model: typeof RoleModel;
|
|
660
697
|
protected readonly permissions: never[];
|
|
661
|
-
protected add(ctx: Context, group_id: string,
|
|
698
|
+
protected add(ctx: Context, group_id: string, roles: Array<string>): Promise<void>;
|
|
662
699
|
protected all(ctx: Context, group_id: string): Promise<void>;
|
|
663
|
-
protected del(ctx: Context, group_id: string,
|
|
664
|
-
protected set(ctx: Context, group_id: string,
|
|
665
|
-
private
|
|
700
|
+
protected del(ctx: Context, group_id: string, roles: Array<string>): Promise<void>;
|
|
701
|
+
protected set(ctx: Context, group_id: string, roles: Array<string>): Promise<void>;
|
|
702
|
+
private addRoles;
|
|
666
703
|
private checkGroup;
|
|
667
|
-
private
|
|
704
|
+
private checkRoles;
|
|
668
705
|
}
|
|
669
706
|
|
|
670
707
|
declare class HealthController {
|
|
@@ -716,6 +753,18 @@ declare class PermissionsController extends CrudController<PermissionModel> {
|
|
|
716
753
|
private checkPermission;
|
|
717
754
|
}
|
|
718
755
|
|
|
756
|
+
declare class ProfileController extends ModelController<UserModel> {
|
|
757
|
+
protected readonly model: typeof UserModel;
|
|
758
|
+
protected readonly permissions: string[];
|
|
759
|
+
path: string;
|
|
760
|
+
protected readonly userService: UserService;
|
|
761
|
+
constructor();
|
|
762
|
+
protected user(ctx: Context): Promise<void>;
|
|
763
|
+
protected avatar(ctx: Context, user: UserModel): Promise<void>;
|
|
764
|
+
protected avatar_del(ctx: Context, user: UserModel): Promise<void>;
|
|
765
|
+
protected password(ctx: Context, oldPassword: string, newPassword: string, user: UserModel): Promise<void>;
|
|
766
|
+
}
|
|
767
|
+
|
|
719
768
|
declare class RegisterController extends BaseController<RegisterEvents> {
|
|
720
769
|
protected register(ctx: Context, body: TypeAnyObject, app: Application): Promise<void>;
|
|
721
770
|
protected confirm(ctx: Context, token: string, app: Application): Promise<void>;
|
|
@@ -723,6 +772,30 @@ declare class RegisterController extends BaseController<RegisterEvents> {
|
|
|
723
772
|
private getId;
|
|
724
773
|
}
|
|
725
774
|
|
|
775
|
+
declare class RolesController extends CrudController<RoleModel> {
|
|
776
|
+
protected readonly model: typeof RoleModel;
|
|
777
|
+
protected groupModelService: ModelService<GroupModel>;
|
|
778
|
+
private schemaCreate;
|
|
779
|
+
private schemaUpdate;
|
|
780
|
+
CrudValidateCreate(): TypeObject<ValidationBase>;
|
|
781
|
+
CrudValidateUpdate(): TypeObject<ValidationBase>;
|
|
782
|
+
sync(): Promise<void>;
|
|
783
|
+
protected groups(ctx: Context, role_id: string): Promise<void>;
|
|
784
|
+
private checkRole;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
declare class RolesPermissionsController extends ModelController<PermissionModel> {
|
|
788
|
+
protected readonly model: typeof PermissionModel;
|
|
789
|
+
protected readonly permissions: never[];
|
|
790
|
+
protected add(ctx: Context, role_id: string, permissions: Array<string>): Promise<void>;
|
|
791
|
+
protected all(ctx: Context, role_id: string): Promise<void>;
|
|
792
|
+
protected del(ctx: Context, role_id: string, permissions: Array<string>): Promise<void>;
|
|
793
|
+
protected set(ctx: Context, role_id: string, permissions: Array<string>): Promise<void>;
|
|
794
|
+
private addPermissions;
|
|
795
|
+
private checkPermissions;
|
|
796
|
+
private checkRole;
|
|
797
|
+
}
|
|
798
|
+
|
|
726
799
|
declare class SetupController extends BaseController {
|
|
727
800
|
protected readonly userService: UserService;
|
|
728
801
|
protected setup(ctx: Context): Promise<void>;
|
|
@@ -1043,14 +1116,8 @@ declare class TestController extends BaseController {
|
|
|
1043
1116
|
|
|
1044
1117
|
declare class UsersController extends ModelController<UserModel> {
|
|
1045
1118
|
protected readonly model: typeof UserModel;
|
|
1046
|
-
protected readonly permissions: string[];
|
|
1047
|
-
path: string;
|
|
1048
1119
|
protected readonly userService: UserService;
|
|
1049
|
-
|
|
1050
|
-
protected avatar(ctx: Context, user: UserModel): Promise<void>;
|
|
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>;
|
|
1120
|
+
protected password(ctx: Context, password: string, user_id: string): Promise<void>;
|
|
1054
1121
|
protected add(ctx: Context): Promise<void>;
|
|
1055
1122
|
protected all(ctx: Context): Promise<void>;
|
|
1056
1123
|
protected rows(ctx: Context): Promise<void>;
|
|
@@ -1076,8 +1143,14 @@ declare class UsersKeysController extends ModelController<UserKeyModel> {
|
|
|
1076
1143
|
protected readonly permissions: string[];
|
|
1077
1144
|
protected add(ctx: Context, user: UserModel, body: TypeAnyObject, app: Application): Promise<void>;
|
|
1078
1145
|
protected add_admin(ctx: Context, id: string, body: TypeAnyObject, app: Application): Promise<void>;
|
|
1146
|
+
protected revoke(ctx: Context, id: string, user: UserModel, app: Application): Promise<void>;
|
|
1147
|
+
protected revoke_admin(ctx: Context, id: string, key: string, app: Application): Promise<void>;
|
|
1148
|
+
protected del(ctx: Context, id: string, user: UserModel, app: Application): Promise<void>;
|
|
1149
|
+
protected del_admin(ctx: Context, id: string, key: string, app: Application): Promise<void>;
|
|
1079
1150
|
protected all(ctx: Context, user: UserModel): Promise<void>;
|
|
1151
|
+
protected get(ctx: Context, user: UserModel): Promise<void>;
|
|
1080
1152
|
protected all_admin(ctx: Context, id: string): Promise<void>;
|
|
1153
|
+
protected get_admin(ctx: Context, id: string): Promise<void>;
|
|
1081
1154
|
private checkUser;
|
|
1082
1155
|
}
|
|
1083
1156
|
|
|
@@ -1196,5 +1269,5 @@ declare class Env extends Env$1 {
|
|
|
1196
1269
|
static readonly API_WEBSOCKET_START: boolean;
|
|
1197
1270
|
}
|
|
1198
1271
|
|
|
1199
|
-
export { Application, Audit, AuditModel, AuditTypes, AuditsController, AuthController, AuthService, BaseController, CanCreate, CanDelete, CanRead, CanUpdate, Config, ConfigModel, CrudController, Env, FilesController, ForgotController, ForgotModel, GroupModel,
|
|
1272
|
+
export { Application, Audit, AuditModel, AuditTypes, AuditsController, AuthController, AuthService, BaseController, CanCreate, CanDelete, CanRead, CanUpdate, Config, ConfigModel, CrudController, Env, FilesController, ForgotController, ForgotModel, GroupModel, GroupRoleModel, GroupTypes, GroupsController, GroupsPermissionsController, GroupsRolesController, 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, ProfileController, RegisterController, RegisterModel, ReqAccess, ReqGroup, ReqGroups, ReqPermission, ReqPermissions, ReqTenant, ReqTenants, ReqUser, RoleModel, RolePermissionModel, RolesController, RolesPermissionsController, 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
1273
|
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 };
|