@andrewcaires/api 5.3.3 → 5.3.5

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.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * @andrewcaires/api v5.3.3
2
+ * @andrewcaires/api v5.3.5
3
3
  * Simple api for small applications using express, jsonwebtoken, sequelize and websocket
4
4
  * (c) 2026 Andrew Caires
5
5
  * @license: MIT
6
6
  */
7
7
  import { Context, Application as Application$1, ExpressOptions, IStore, ResponseError } from '@andrewcaires/express';
8
- import { Hash, Env as Env$1 } from '@andrewcaires/node';
8
+ import { Encryptor, Env as Env$1 } from '@andrewcaires/node';
9
9
  import { ModelFindOptions, ModelUpdateOptions, Model as Model$1, Sequelize } from '@andrewcaires/sequelize';
10
10
  import { TypeAnyObject, TypeObjectString, TypeAnyFunction, TypeAnyConstructor, EventEmitter, TypeObject, ValidationBase, ValidationShape } from '@andrewcaires/utils.js';
11
11
  import { WebSocketServer } from 'ws';
@@ -264,7 +264,7 @@ declare class GroupModel extends Model$1 {
264
264
  readonly updated_at: Date;
265
265
  readonly deleted_at: Date | null;
266
266
  users_groups: Array<UserGroupModel>;
267
- groups_Permission: Array<GroupPermissionModel>;
267
+ groups_permissions: Array<GroupPermissionModel>;
268
268
  }
269
269
 
270
270
  declare class UserTenantModel extends Model$1 {
@@ -279,6 +279,7 @@ declare class UserTenantModel extends Model$1 {
279
279
  declare class TenantModel extends Model$1 {
280
280
  readonly id: string;
281
281
  name: string;
282
+ description: string;
282
283
  status: TenantStatus;
283
284
  metadata: TypeAnyObject;
284
285
  readonly created_at: Date;
@@ -480,7 +481,7 @@ declare class UserService extends Service {
480
481
  }
481
482
 
482
483
  declare class Application<T extends ApplicationEvents = ApplicationEvents> extends Application$1<T> {
483
- readonly hash: Hash;
484
+ readonly encryptor: Encryptor;
484
485
  authService: AuthService;
485
486
  userService: UserService;
486
487
  private _webSocket?;
@@ -521,7 +522,7 @@ declare abstract class ModelController<M extends Model<any>, T extends TypeAnyOb
521
522
  declare class AuditsController extends ModelController<AuditModel> {
522
523
  protected readonly model: typeof AuditModel;
523
524
  protected readonly permissions: string[];
524
- protected all(ctx: Context, type: string, table: string): Promise<void>;
525
+ protected all(ctx: Context): Promise<void>;
525
526
  protected get(ctx: Context): Promise<void>;
526
527
  }
527
528
 
@@ -572,17 +573,25 @@ declare class ForgotController extends BaseController<ForgotEvents> {
572
573
 
573
574
  declare class GroupsController extends CrudController<GroupModel> {
574
575
  protected readonly model: typeof GroupModel;
576
+ protected userModelService: ModelService<UserModel>;
575
577
  private schemaCreate;
576
578
  private schemaUpdate;
577
579
  CrudValidateCreate(): TypeObject<ValidationBase>;
578
580
  CrudValidateUpdate(): TypeObject<ValidationBase>;
581
+ sync(): Promise<void>;
582
+ protected users(ctx: Context, group_id: string): Promise<void>;
583
+ private checkGroup;
579
584
  }
580
585
 
581
- declare class GroupsPermissionsController extends ModelController<GroupPermissionModel> {
582
- protected readonly model: typeof GroupPermissionModel;
586
+ declare class GroupsPermissionsController extends ModelController<PermissionModel> {
587
+ protected readonly model: typeof PermissionModel;
583
588
  protected readonly permissions: never[];
589
+ protected add(ctx: Context, group_id: string, permissions: Array<string>): Promise<void>;
584
590
  protected all(ctx: Context, group_id: string): Promise<void>;
585
- protected set(ctx: Context, id: string, permissions: Array<string>): Promise<void>;
591
+ protected del(ctx: Context, group_id: string, permissions: Array<string>): Promise<void>;
592
+ protected set(ctx: Context, group_id: string, permissions: Array<string>): Promise<void>;
593
+ private addPermissions;
594
+ private checkGroup;
586
595
  }
587
596
 
588
597
  declare class HealthController {
@@ -616,10 +625,14 @@ declare class McpController extends BaseController {
616
625
 
617
626
  declare class PermissionsController extends CrudController<PermissionModel> {
618
627
  protected readonly model: typeof PermissionModel;
628
+ protected groupModelService: ModelService<GroupModel>;
619
629
  private schemaCreate;
620
630
  private schemaUpdate;
621
631
  CrudValidateCreate(): TypeObject<ValidationBase>;
622
632
  CrudValidateUpdate(): TypeObject<ValidationBase>;
633
+ sync(): Promise<void>;
634
+ protected groups(ctx: Context, permission_id: string): Promise<void>;
635
+ private checkPermission;
623
636
  }
624
637
 
625
638
  declare class RegisterController extends BaseController<RegisterEvents> {
@@ -634,6 +647,18 @@ declare class SetupController extends BaseController {
634
647
  protected setup(ctx: Context): Promise<void>;
635
648
  }
636
649
 
650
+ declare class TenantsController extends CrudController<TenantModel> {
651
+ protected readonly model: typeof TenantModel;
652
+ protected userModelService: ModelService<UserModel>;
653
+ private schemaCreate;
654
+ private schemaUpdate;
655
+ CrudValidateCreate(): TypeObject<ValidationBase>;
656
+ CrudValidateUpdate(): TypeObject<ValidationBase>;
657
+ sync(): Promise<void>;
658
+ protected users(ctx: Context, tenant_id: string): Promise<void>;
659
+ private checkTenant;
660
+ }
661
+
637
662
  declare const McpErrorCode: {
638
663
  readonly ParseError: -32700;
639
664
  readonly InvalidRequest: -32600;
@@ -909,11 +934,26 @@ declare class UsersController extends ModelController<UserModel> {
909
934
  protected set(ctx: Context): Promise<void>;
910
935
  }
911
936
 
912
- declare class UsersGroupsController extends ModelController<UserGroupModel> {
913
- protected readonly model: typeof UserGroupModel;
937
+ declare class UsersGroupsController extends ModelController<GroupModel> {
938
+ protected readonly model: typeof GroupModel;
939
+ protected readonly permissions: never[];
940
+ protected add(ctx: Context, user_id: string, groups: Array<string>): Promise<void>;
941
+ protected all(ctx: Context, user_id: string): Promise<void>;
942
+ protected del(ctx: Context, user_id: string, groups: Array<string>): Promise<void>;
943
+ protected set(ctx: Context, user_id: string, groups: Array<string>): Promise<void>;
944
+ private addGroups;
945
+ private checkUser;
946
+ }
947
+
948
+ declare class UsersTenantsController extends ModelController<TenantModel> {
949
+ protected readonly model: typeof TenantModel;
914
950
  protected readonly permissions: never[];
951
+ protected add(ctx: Context, user_id: string, tenants: Array<string>): Promise<void>;
915
952
  protected all(ctx: Context, user_id: string): Promise<void>;
916
- protected set(ctx: Context, id: string, groups: Array<string>): Promise<void>;
953
+ protected del(ctx: Context, user_id: string, tenants: Array<string>): Promise<void>;
954
+ protected set(ctx: Context, user_id: string, tenants: Array<string>): Promise<void>;
955
+ private addTenants;
956
+ private checkUser;
917
957
  }
918
958
 
919
959
  declare const sequelize: Sequelize;
@@ -959,6 +999,7 @@ declare class Env extends Env$1 {
959
999
  static readonly DATABASE_AUDIT: boolean;
960
1000
  static readonly DATABASE_PREFIX: string;
961
1001
  static readonly DATABASE_TIMEZONE: string;
1002
+ static readonly ENCRYPTION_SECRET: string;
962
1003
  static readonly HTTP_CROSS: string;
963
1004
  static readonly HTTP_PORT: number;
964
1005
  static readonly HTTP_PUBLIC: string;
@@ -993,7 +1034,6 @@ declare class Env extends Env$1 {
993
1034
  static readonly API_HTTP_NOTFOUND: string;
994
1035
  static readonly API_HTTP_PATH: string;
995
1036
  static readonly API_HTTP_REDIRECT: string;
996
- static readonly API_KEY_HASH: string;
997
1037
  static readonly API_SESSION_NAME: string;
998
1038
  static readonly API_SESSION_LIFETIME: number;
999
1039
  static readonly API_SESSION_SECRET: string;
@@ -1003,5 +1043,5 @@ declare class Env extends Env$1 {
1003
1043
  static readonly API_WEBSOCKET_START: boolean;
1004
1044
  }
1005
1045
 
1006
- 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, HealthController, IsAuthenticated, Log, LogLevels, LogModel, Loggable, LogsController, MCP_DEFAULT_PROTOCOL_VERSION, MCP_HTTP_ALLOW, MCP_HTTP_ALLOWED_METHODS, 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, ReqAuth, ReqGroup, ReqGroups, ReqPermission, ReqPermissions, ReqUser, Service, SessionModel, SessionStore, SetupController, TenantModel, TenantStatus, TestController, UserAuthModel, UserGroupModel, UserModel, UserPasswordModel, UserService, UserStatus, UserTenantModel, UsersController, UsersGroupsController, assertValidMcpToolDefinition, canFactory, isJsonParseError, isJsonRpcId, jsonParseErrorResponse, jsonRpcError, jsonRpcErrorFromCode, jsonRpcResult, parseJsonRpcRequest, sequelize };
1046
+ 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, HealthController, IsAuthenticated, Log, LogLevels, LogModel, Loggable, LogsController, MCP_DEFAULT_PROTOCOL_VERSION, MCP_HTTP_ALLOW, MCP_HTTP_ALLOWED_METHODS, 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, ReqAuth, ReqGroup, ReqGroups, ReqPermission, ReqPermissions, ReqUser, Service, SessionModel, SessionStore, SetupController, TenantModel, TenantStatus, TenantsController, TestController, UserAuthModel, UserGroupModel, UserModel, UserPasswordModel, UserService, UserStatus, UserTenantModel, UsersController, UsersGroupsController, UsersTenantsController, assertValidMcpToolDefinition, canFactory, isJsonParseError, isJsonRpcId, jsonParseErrorResponse, jsonRpcError, jsonRpcErrorFromCode, jsonRpcResult, parseJsonRpcRequest, sequelize };
1007
1047
  export type { ApplicationEvents, AuthEvents, ForgotEvents, IAuthParameters, 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 };