@andrewcaires/api 4.5.1 → 5.0.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 +352 -289
- package/dist/index.esm.js +2 -2
- package/package.json +13 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,178 +1,166 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @andrewcaires/api
|
|
2
|
+
* @andrewcaires/api v5.0.0
|
|
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
|
-
import {
|
|
8
|
-
import { Application as Application$1, Context, IStore, IUpload, IFile } from '@andrewcaires/express';
|
|
9
|
-
import { WhereOptions, Model as Model$1, CreateOptions, Attributes, FindOptions, UpdateOptions, FindAttributeOptions, ModelStatic } from 'sequelize';
|
|
10
|
-
import { Model, Sequelize } from '@andrewcaires/sequelize';
|
|
7
|
+
import { Context, Application as Application$1, IOptions, IStore } from '@andrewcaires/express';
|
|
11
8
|
import { Hash, Env as Env$1 } from '@andrewcaires/node';
|
|
9
|
+
import { Model, Sequelize } from '@andrewcaires/sequelize';
|
|
10
|
+
import { TypeAnyObject, TypeObjectString, TypeAnyFunction, TypeAnyConstructor, EventEmitter, TypeObject, ValidationBase } from '@andrewcaires/utils.js';
|
|
12
11
|
import { WebSocketServer } from 'ws';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
declare abstract class Controller extends EventEmitter {
|
|
16
|
-
static readonly ATTRIBUTES: unique symbol;
|
|
17
|
-
static readonly PERMISSIONS: unique symbol;
|
|
18
|
-
}
|
|
12
|
+
import { Model as Model$1, CreateOptions, Attributes, FindOptions, UpdateOptions, ModelStatic, FindAttributeOptions } from 'sequelize';
|
|
13
|
+
import { Store, SessionData } from 'express-session';
|
|
19
14
|
|
|
20
|
-
declare class
|
|
21
|
-
readonly id:
|
|
15
|
+
declare class RegisterModel extends Model {
|
|
16
|
+
readonly id: string;
|
|
22
17
|
secret: string;
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
expired_at: number;
|
|
19
|
+
state: boolean;
|
|
25
20
|
readonly created_at: Date;
|
|
26
21
|
readonly updated_at: Date;
|
|
27
22
|
readonly deleted_at: Date | null;
|
|
28
|
-
user_id:
|
|
29
|
-
user:
|
|
23
|
+
user_id: string;
|
|
24
|
+
user: UserModel;
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
declare class
|
|
33
|
-
readonly id:
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
declare class UserAuthModel extends Model {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
secret: string;
|
|
30
|
+
ip_address: string;
|
|
31
|
+
user_agent: string;
|
|
32
|
+
revoked_at: Date | null;
|
|
36
33
|
readonly created_at: Date;
|
|
37
34
|
readonly updated_at: Date;
|
|
38
35
|
readonly deleted_at: Date | null;
|
|
39
|
-
user_id:
|
|
40
|
-
user:
|
|
36
|
+
user_id: string;
|
|
37
|
+
user: UserModel;
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
declare class
|
|
44
|
-
readonly id:
|
|
40
|
+
declare class PermissionModel extends Model {
|
|
41
|
+
readonly id: string;
|
|
45
42
|
name: string;
|
|
46
|
-
|
|
43
|
+
key: string;
|
|
47
44
|
tag: string;
|
|
48
45
|
description: string;
|
|
49
46
|
state: boolean;
|
|
50
47
|
readonly created_at: Date;
|
|
51
48
|
readonly updated_at: Date;
|
|
52
49
|
readonly deleted_at: Date | null;
|
|
53
|
-
groups_permissions: Array<
|
|
50
|
+
groups_permissions: Array<GroupPermissionModel>;
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
declare class
|
|
53
|
+
declare class GroupPermissionModel extends Model {
|
|
57
54
|
readonly created_at: Date;
|
|
58
|
-
group_id:
|
|
59
|
-
group:
|
|
60
|
-
permission_id:
|
|
61
|
-
permission:
|
|
55
|
+
group_id: string;
|
|
56
|
+
group: GroupModel;
|
|
57
|
+
permission_id: string;
|
|
58
|
+
permission: PermissionModel;
|
|
62
59
|
}
|
|
63
60
|
|
|
64
|
-
declare class
|
|
65
|
-
readonly id:
|
|
61
|
+
declare class GroupModel extends Model {
|
|
62
|
+
readonly id: string;
|
|
66
63
|
name: string;
|
|
64
|
+
key: string;
|
|
67
65
|
description: string;
|
|
68
66
|
state: boolean;
|
|
69
67
|
readonly created_at: Date;
|
|
70
68
|
readonly updated_at: Date;
|
|
71
69
|
readonly deleted_at: Date | null;
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
users_groups: Array<UserGroupModel>;
|
|
71
|
+
groups_Permission: Array<GroupPermissionModel>;
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
declare class
|
|
74
|
+
declare class UserGroupModel extends Model {
|
|
77
75
|
readonly created_at: Date;
|
|
78
|
-
group_id:
|
|
79
|
-
group:
|
|
80
|
-
user_id:
|
|
81
|
-
user:
|
|
76
|
+
group_id: string;
|
|
77
|
+
group: GroupModel;
|
|
78
|
+
user_id: string;
|
|
79
|
+
user: UserModel;
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
declare class
|
|
85
|
-
|
|
82
|
+
declare class UserPasswordModel extends Model {
|
|
83
|
+
readonly id: string;
|
|
84
|
+
value: string;
|
|
85
|
+
state: boolean;
|
|
86
86
|
readonly created_at: Date;
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
readonly updated_at: Date;
|
|
88
|
+
readonly deleted_at: Date | null;
|
|
89
|
+
user_id: string;
|
|
90
|
+
user: UserModel;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
declare class
|
|
92
|
-
readonly id:
|
|
93
|
+
declare class UserModel extends Model {
|
|
94
|
+
readonly id: string;
|
|
93
95
|
name: string;
|
|
94
96
|
email: string;
|
|
95
97
|
username: string;
|
|
96
|
-
password: string;
|
|
97
|
-
salt: string;
|
|
98
|
-
token: string;
|
|
99
|
-
avatar: string;
|
|
100
|
-
date: string;
|
|
101
98
|
description: string;
|
|
102
99
|
state: boolean;
|
|
103
100
|
readonly created_at: Date;
|
|
104
101
|
readonly updated_at: Date;
|
|
105
102
|
readonly deleted_at: Date | null;
|
|
106
|
-
audits: Array<
|
|
107
|
-
|
|
108
|
-
registers: Array<
|
|
109
|
-
users_groups: Array<
|
|
110
|
-
|
|
103
|
+
audits: Array<AuditModel>;
|
|
104
|
+
users_auths: Array<UserAuthModel>;
|
|
105
|
+
registers: Array<RegisterModel>;
|
|
106
|
+
users_groups: Array<UserGroupModel>;
|
|
107
|
+
users_passwords: Array<UserPasswordModel>;
|
|
111
108
|
}
|
|
112
109
|
|
|
113
|
-
declare class
|
|
114
|
-
readonly id:
|
|
115
|
-
type:
|
|
110
|
+
declare class AuditModel extends Model {
|
|
111
|
+
readonly id: string;
|
|
112
|
+
type: "CREATE" | "DELETE" | "UPDATE";
|
|
116
113
|
model: string;
|
|
117
114
|
record: string;
|
|
118
115
|
data: TypeAnyObject;
|
|
119
116
|
previously: TypeAnyObject;
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
full_url: string;
|
|
118
|
+
ip_address: string;
|
|
122
119
|
user_agent: string;
|
|
123
120
|
state: boolean;
|
|
124
121
|
readonly created_at: Date;
|
|
125
122
|
readonly updated_at: Date;
|
|
126
123
|
readonly deleted_at: Date | null;
|
|
127
|
-
user_id:
|
|
128
|
-
user:
|
|
124
|
+
user_id: string;
|
|
125
|
+
user: UserModel;
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
declare class
|
|
128
|
+
declare class ConfigModel extends Model {
|
|
129
|
+
readonly id: string;
|
|
132
130
|
key: string;
|
|
133
131
|
value: string;
|
|
134
132
|
readonly created_at: Date;
|
|
135
133
|
readonly updated_at: Date;
|
|
136
|
-
static all(): Promise<TypeObjectString>;
|
|
137
|
-
static del(key: string, user?: User): Promise<boolean>;
|
|
138
|
-
static get(key: string, value?: string): Promise<string>;
|
|
139
|
-
static set(key: string, value: string, user?: User): Promise<void>;
|
|
140
134
|
}
|
|
141
135
|
|
|
142
|
-
declare class
|
|
143
|
-
readonly id:
|
|
144
|
-
|
|
145
|
-
|
|
136
|
+
declare class ForgotModel extends Model {
|
|
137
|
+
readonly id: string;
|
|
138
|
+
secret: string;
|
|
139
|
+
expired_at: number;
|
|
146
140
|
state: boolean;
|
|
147
141
|
readonly created_at: Date;
|
|
148
142
|
readonly updated_at: Date;
|
|
149
143
|
readonly deleted_at: Date | null;
|
|
150
|
-
user_id:
|
|
151
|
-
user:
|
|
144
|
+
user_id: string;
|
|
145
|
+
user: UserModel;
|
|
152
146
|
}
|
|
153
147
|
|
|
154
|
-
declare class
|
|
155
|
-
readonly id:
|
|
156
|
-
|
|
157
|
-
source: string;
|
|
148
|
+
declare class LogModel extends Model {
|
|
149
|
+
readonly id: string;
|
|
150
|
+
level: "info" | "warn" | "error";
|
|
158
151
|
message: string;
|
|
152
|
+
source: string;
|
|
159
153
|
readonly created_at: Date;
|
|
160
|
-
static write(message: string, source?: string, show?: boolean): Promise<void>;
|
|
161
|
-
static error(message: string, source?: string, show?: boolean): Promise<void>;
|
|
162
|
-
static info(message: string, source?: string, show?: boolean): Promise<void>;
|
|
163
|
-
static success(message: string, source?: string, show?: boolean): Promise<void>;
|
|
164
|
-
static warning(message: string, source?: string, show?: boolean): Promise<void>;
|
|
165
|
-
private static writeRaw;
|
|
166
154
|
}
|
|
167
155
|
|
|
168
|
-
declare class
|
|
156
|
+
declare class MigrationModel extends Model {
|
|
169
157
|
model: string;
|
|
170
158
|
version: string;
|
|
171
159
|
readonly created_at: Date;
|
|
172
160
|
readonly updated_at: Date;
|
|
173
161
|
}
|
|
174
162
|
|
|
175
|
-
declare class
|
|
163
|
+
declare class SessionModel extends Model {
|
|
176
164
|
session: string;
|
|
177
165
|
json: string;
|
|
178
166
|
expired: number;
|
|
@@ -180,36 +168,30 @@ declare class Session extends Model {
|
|
|
180
168
|
readonly updated_at: Date;
|
|
181
169
|
}
|
|
182
170
|
|
|
183
|
-
declare class
|
|
184
|
-
readonly
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
171
|
+
declare class UserMetadataModel extends Model {
|
|
172
|
+
readonly id: string;
|
|
173
|
+
key: string;
|
|
174
|
+
value: string;
|
|
175
|
+
readonly created_at: Date;
|
|
176
|
+
readonly updated_at: Date;
|
|
177
|
+
readonly deleted_at: Date | null;
|
|
178
|
+
user_id: string;
|
|
179
|
+
user: UserModel;
|
|
192
180
|
}
|
|
193
181
|
|
|
194
|
-
declare
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
permission(ctx: Context, route: string, user: User): Promise<void>;
|
|
204
|
-
permissions(user: User, where?: WhereOptions): Promise<Array<Permission>>;
|
|
205
|
-
session(ctx: Context, user_agent: string, store: IStore): Promise<void>;
|
|
206
|
-
sync(): Promise<void>;
|
|
207
|
-
upload(ctx: Context, options: IUpload): void;
|
|
208
|
-
validation(ctx: Context, options: TypeObject<ValidationBase>): Promise<void>;
|
|
182
|
+
declare class UserProfileModel extends Model {
|
|
183
|
+
readonly id: string;
|
|
184
|
+
key: string;
|
|
185
|
+
value: string;
|
|
186
|
+
readonly created_at: Date;
|
|
187
|
+
readonly updated_at: Date;
|
|
188
|
+
readonly deleted_at: Date | null;
|
|
189
|
+
user_id: string;
|
|
190
|
+
user: UserModel;
|
|
209
191
|
}
|
|
210
192
|
|
|
211
193
|
interface ArgumentsModel<M extends Model$1<M>> {
|
|
212
|
-
ctx
|
|
194
|
+
ctx?: Context;
|
|
213
195
|
}
|
|
214
196
|
|
|
215
197
|
interface ArgumentsModelCreate<M extends Model$1<M>> extends ArgumentsModel<M> {
|
|
@@ -218,65 +200,201 @@ interface ArgumentsModelCreate<M extends Model$1<M>> extends ArgumentsModel<M> {
|
|
|
218
200
|
}
|
|
219
201
|
|
|
220
202
|
interface ArgumentsModelDelete<M extends Model$1<M>> extends ArgumentsModel<M> {
|
|
203
|
+
id?: string | number;
|
|
221
204
|
options?: FindOptions<Attributes<M>>;
|
|
222
205
|
}
|
|
223
206
|
|
|
224
|
-
type
|
|
207
|
+
type CallbackModelFindAll<M> = (_records: Array<M>) => Array<any> | Promise<Array<any>>;
|
|
225
208
|
|
|
226
209
|
interface ArgumentsModelFindAll<M extends Model$1<any>> extends ArgumentsModel<M> {
|
|
227
210
|
options?: FindOptions<Attributes<M>>;
|
|
228
|
-
callback?:
|
|
229
|
-
scope?: string;
|
|
211
|
+
callback?: CallbackModelFindAll<M>;
|
|
230
212
|
advanced?: boolean;
|
|
231
|
-
attributes?: Array<string>;
|
|
232
213
|
limited?: boolean;
|
|
233
214
|
}
|
|
234
215
|
|
|
235
|
-
type
|
|
216
|
+
type CallbackModelFindOne<M> = (_records: M) => any | Promise<any>;
|
|
236
217
|
|
|
237
218
|
interface ArgumentsModelFindOne<M extends Model$1<M>> extends ArgumentsModel<M> {
|
|
238
219
|
options?: FindOptions<Attributes<M>>;
|
|
239
|
-
callback?:
|
|
240
|
-
scope?: string;
|
|
220
|
+
callback?: CallbackModelFindOne<M>;
|
|
241
221
|
}
|
|
242
222
|
|
|
243
223
|
interface ArgumentsModelUpdate<M extends Model$1<M>> extends ArgumentsModel<M> {
|
|
224
|
+
id?: string | number;
|
|
244
225
|
options?: UpdateOptions<Attributes<M>>;
|
|
245
226
|
body?: TypeAnyObject;
|
|
246
227
|
}
|
|
247
228
|
|
|
229
|
+
interface ResultModelFindAll<M extends Model<M>> {
|
|
230
|
+
count: number;
|
|
231
|
+
records: Array<M>;
|
|
232
|
+
}
|
|
233
|
+
|
|
248
234
|
interface IAuthParameters {
|
|
249
|
-
auth?:
|
|
235
|
+
auth?: UserAuthModel;
|
|
250
236
|
decode?: TypeAnyObject;
|
|
251
|
-
|
|
252
|
-
forgot?: Forgot;
|
|
237
|
+
forgot?: ForgotModel;
|
|
253
238
|
token?: string;
|
|
254
|
-
user?:
|
|
239
|
+
user?: UserModel;
|
|
255
240
|
}
|
|
256
241
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
242
|
+
declare module "express-serve-static-core" {
|
|
243
|
+
interface Request {
|
|
244
|
+
auth?: UserAuthModel;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare module "express-serve-static-core" {
|
|
249
|
+
interface Request {
|
|
250
|
+
groups?: Array<string>;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare module "express-serve-static-core" {
|
|
255
|
+
interface Request {
|
|
256
|
+
permissions?: Array<string>;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
declare module "express-serve-static-core" {
|
|
261
|
+
interface Request {
|
|
262
|
+
profile?: TypeObjectString;
|
|
263
|
+
}
|
|
260
264
|
}
|
|
261
265
|
|
|
262
|
-
declare
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
266
|
+
declare module "express-serve-static-core" {
|
|
267
|
+
interface Request {
|
|
268
|
+
user?: UserModel;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare class Loggable {
|
|
273
|
+
get log(): (message: string) => void;
|
|
274
|
+
static get log(): (message: string) => void;
|
|
275
|
+
get error(): (error: any) => void;
|
|
276
|
+
static get error(): (error: any) => void;
|
|
277
|
+
private static logError;
|
|
278
|
+
private static logInfo;
|
|
279
|
+
private static source;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare class Config extends Loggable {
|
|
283
|
+
static all(): Promise<TypeObjectString>;
|
|
284
|
+
static del(key: string, user?: UserModel): Promise<boolean>;
|
|
285
|
+
static get(key: string, value?: string): Promise<string>;
|
|
286
|
+
static set(key: string, value: string, user?: UserModel): Promise<void>;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
declare class Log {
|
|
290
|
+
protected static colors: TypeAnyObject;
|
|
291
|
+
static error(message: string, source?: string, show?: boolean): Promise<void>;
|
|
292
|
+
static info(message: string, source?: string, show?: boolean): Promise<void>;
|
|
293
|
+
static warn(message: string, source?: string, show?: boolean): Promise<void>;
|
|
294
|
+
private static writeRaw;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
declare class SessionStore extends Store {
|
|
298
|
+
private loop;
|
|
299
|
+
constructor();
|
|
300
|
+
all: (callback: TypeAnyFunction) => Promise<void>;
|
|
301
|
+
clear: (callback: TypeAnyFunction) => Promise<void>;
|
|
302
|
+
destroy: (session_id: string, callback: TypeAnyFunction) => Promise<void>;
|
|
303
|
+
expired: () => Promise<void>;
|
|
304
|
+
get: (session_id: string, callback: TypeAnyFunction) => Promise<void>;
|
|
305
|
+
length: (callback: TypeAnyFunction) => Promise<void>;
|
|
306
|
+
set: (session_id: any, session: SessionData, callback: TypeAnyFunction) => Promise<void>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface Service extends Loggable {
|
|
310
|
+
}
|
|
311
|
+
declare abstract class Service {
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare class AuthService extends Service {
|
|
315
|
+
create(user: UserModel): Promise<IAuthParameters>;
|
|
316
|
+
destroy(auth?: UserAuthModel): Promise<boolean>;
|
|
317
|
+
renew(token: string): Promise<IAuthParameters>;
|
|
318
|
+
user(token: string): Promise<IAuthParameters>;
|
|
319
|
+
private options;
|
|
320
|
+
private verify;
|
|
321
|
+
key(value: string): Promise<IAuthParameters>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
declare class ModelService<M extends Model$1<any>> extends Service {
|
|
325
|
+
protected model: ModelStatic<M>;
|
|
326
|
+
protected attributes: Array<string>;
|
|
327
|
+
protected filter: FindAttributeOptions;
|
|
328
|
+
constructor(model: ModelStatic<M>, attributes?: FindAttributeOptions);
|
|
329
|
+
create({ ctx, options, body }: ArgumentsModelCreate<M>): Promise<M | null>;
|
|
330
|
+
delete({ ctx, options, id: _id }: ArgumentsModelDelete<M>): Promise<number>;
|
|
331
|
+
private filterAttributes;
|
|
332
|
+
findAll({ ctx, options, callback, advanced, limited }: ArgumentsModelFindAll<M>): Promise<ResultModelFindAll<M>>;
|
|
333
|
+
findOne({ ctx, options, callback }: ArgumentsModelFindOne<M>): Promise<M | null>;
|
|
334
|
+
getAttributes(options: FindAttributeOptions): Array<string>;
|
|
335
|
+
update({ ctx, options, body, id: _id }: ArgumentsModelUpdate<M>): Promise<boolean>;
|
|
336
|
+
name(): string;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
declare class UserService extends Service {
|
|
340
|
+
getMetadata(user_id: string): Promise<TypeObjectString>;
|
|
341
|
+
getProfile(user_id: string): Promise<TypeObjectString>;
|
|
342
|
+
getGroups(user_id: string): Promise<Array<string>>;
|
|
343
|
+
getPermissions(user_id: string): Promise<Array<string>>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare class Application extends Application$1 {
|
|
347
|
+
readonly hash: Hash;
|
|
348
|
+
authService: AuthService;
|
|
349
|
+
userService: UserService;
|
|
350
|
+
private _webSocket?;
|
|
351
|
+
constructor(controllers: Array<object | TypeAnyConstructor<object>>, options?: IOptions);
|
|
352
|
+
error(error: any, source?: string): void;
|
|
353
|
+
log(message: string, source?: string): void;
|
|
354
|
+
listen(): Promise<void>;
|
|
355
|
+
migrations(database: Sequelize): Promise<void>;
|
|
356
|
+
websocket(): WebSocketServer | undefined;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
interface BaseController extends Loggable {
|
|
360
|
+
}
|
|
361
|
+
declare abstract class BaseController extends EventEmitter {
|
|
362
|
+
protected readonly permissions: Array<string>;
|
|
363
|
+
name(): string;
|
|
364
|
+
session(ctx: Context, user_agent: string, store: IStore): Promise<void>;
|
|
272
365
|
sync(): Promise<void>;
|
|
273
|
-
|
|
274
|
-
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
declare abstract class ModelController<M extends Model$1<any>> extends BaseController {
|
|
369
|
+
protected readonly attributes: Array<string>;
|
|
370
|
+
protected abstract readonly model: ModelStatic<M>;
|
|
371
|
+
protected readonly permissions: Array<string>;
|
|
372
|
+
private service;
|
|
373
|
+
protected create(options: ArgumentsModelCreate<M>): Promise<M | null>;
|
|
374
|
+
protected delete(options: ArgumentsModelDelete<M>): Promise<number>;
|
|
375
|
+
protected findAll(options: ArgumentsModelFindAll<M>): Promise<ResultModelFindAll<M>>;
|
|
376
|
+
protected findOne(options: ArgumentsModelFindOne<M>): Promise<M | null>;
|
|
377
|
+
sync(): Promise<void>;
|
|
378
|
+
protected update(options: ArgumentsModelUpdate<M>): Promise<boolean>;
|
|
275
379
|
name(): string;
|
|
276
|
-
scope(name?: string): ModelStatic<M>;
|
|
277
380
|
}
|
|
278
381
|
|
|
279
|
-
declare
|
|
382
|
+
declare class AuditsController extends ModelController<AuditModel> {
|
|
383
|
+
protected readonly model: typeof AuditModel;
|
|
384
|
+
protected all(ctx: Context, type: string, table: string): Promise<void>;
|
|
385
|
+
protected get(ctx: Context): Promise<void>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare class AuthController extends BaseController {
|
|
389
|
+
protected readonly authService: AuthService;
|
|
390
|
+
constructor(authService: AuthService);
|
|
391
|
+
protected login(ctx: Context, user_agent: string, username: string, password: string, remember: boolean, app: Application): Promise<void>;
|
|
392
|
+
protected logout(ctx: Context, auth: UserAuthModel, user: UserModel, app: Application): Promise<void>;
|
|
393
|
+
protected renew(ctx: Context, user_agent: string, old: string, app: Application): Promise<void>;
|
|
394
|
+
protected user(ctx: Context, user: UserModel): Promise<void>;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
declare abstract class CrudController<M extends Model$1<any>> extends ModelController<M> {
|
|
280
398
|
private _crud;
|
|
281
399
|
CrudArgumentsCreate(ctx: Context): ArgumentsModelUpdate<M>;
|
|
282
400
|
CrudArgumentsFindAll(ctx: Context): ArgumentsModelFindAll<M>;
|
|
@@ -294,212 +412,157 @@ declare abstract class ControllerCrud<M extends Model$1<any>> extends Controller
|
|
|
294
412
|
protected validationUpdate(ctx: Context): Promise<void>;
|
|
295
413
|
}
|
|
296
414
|
|
|
297
|
-
declare class
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
static readonly API_BODYPARSER_INFLATE: boolean;
|
|
301
|
-
static readonly API_BODYPARSER_LIMIT: string;
|
|
302
|
-
static readonly API_BODYPARSER_TYPE: string;
|
|
303
|
-
static readonly API_CONSOLE_ERROR: boolean;
|
|
304
|
-
static readonly API_DATABASE_URL: string;
|
|
305
|
-
static readonly API_DATABASE_LOG: boolean;
|
|
306
|
-
static readonly API_DATABASE_AUDIT: boolean;
|
|
307
|
-
static readonly API_DATABASE_PREFIX: string;
|
|
308
|
-
static readonly API_DATABASE_TIMEZONE: string;
|
|
309
|
-
static readonly API_HTTP_CRT: string;
|
|
310
|
-
static readonly API_HTTP_KEY: string;
|
|
311
|
-
static readonly API_HTTP_PORT: number;
|
|
312
|
-
static readonly API_HTTP_PUBLIC: string;
|
|
313
|
-
static readonly API_HTTP_CROSS: boolean;
|
|
314
|
-
static readonly API_HTTP_HYBRID: boolean;
|
|
315
|
-
static readonly API_HTTP_NOTFOUND: string;
|
|
316
|
-
static readonly API_HTTP_PATH: string;
|
|
317
|
-
static readonly API_HTTP_REDIRECT: string;
|
|
318
|
-
static readonly API_KEY_HASH: string;
|
|
319
|
-
static readonly API_KEY_HEADER: string;
|
|
320
|
-
static readonly API_MODEL_LIMIT: number;
|
|
321
|
-
static readonly API_MODEL_LIMIT_MAX: number;
|
|
322
|
-
static readonly API_SLEEP_AUTH: number;
|
|
323
|
-
static readonly API_SLEEP_FORGOT: number;
|
|
324
|
-
static readonly API_SLEEP_REGISTRY: number;
|
|
325
|
-
static readonly API_SESSION_NAME: string;
|
|
326
|
-
static readonly API_SESSION_LIFETIME: number;
|
|
327
|
-
static readonly API_SESSION_SECRET: string;
|
|
328
|
-
static readonly API_TOKEN_CRT: string;
|
|
329
|
-
static readonly API_TOKEN_KEY: string;
|
|
330
|
-
static readonly API_TOKEN_FORGOT: number;
|
|
331
|
-
static readonly API_TOKEN_HEADER: string;
|
|
332
|
-
static readonly API_TOKEN_HEADER_KEY: string;
|
|
333
|
-
static readonly API_TOKEN_LIFETIME: number;
|
|
334
|
-
static readonly API_TOKEN_RENEW: number;
|
|
335
|
-
static readonly API_UPLOAD_COUNT: number;
|
|
336
|
-
static readonly API_UPLOAD_FIELD: string;
|
|
337
|
-
static readonly API_UPLOAD_SIZE: number;
|
|
338
|
-
static readonly API_UPLOAD_TEMP: string;
|
|
339
|
-
static readonly API_USER_HISTORY: boolean;
|
|
340
|
-
static readonly API_WEBSOCKET_START: boolean;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
declare class AuditsController extends ControllerModel<Audit> {
|
|
344
|
-
model(): typeof Audit;
|
|
345
|
-
protected all(ctx: Context, type: string, table: string): Promise<void>;
|
|
346
|
-
protected get(ctx: Context): Promise<void>;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
declare class AuthController extends ControllerBase {
|
|
350
|
-
protected login(ctx: Context, user_agent: string, username: string, password: string, app: Application): Promise<void>;
|
|
351
|
-
protected logout(ctx: Context, auth: Auth, user: User, app: Application): Promise<void>;
|
|
352
|
-
protected renew(ctx: Context, user_agent: string, old: string, app: Application): Promise<void>;
|
|
353
|
-
protected user(ctx: Context, user: User): Promise<void>;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
declare class FilesController extends ControllerBase {
|
|
357
|
-
protected [ControllerBase.PERMISSIONS]: Array<string>;
|
|
358
|
-
directory(): string;
|
|
415
|
+
declare class FilesController extends BaseController {
|
|
416
|
+
protected readonly directory: string;
|
|
417
|
+
protected readonly permissions: Array<string>;
|
|
359
418
|
protected files(ctx: Context): Promise<TypeAnyObject | void>;
|
|
360
|
-
protected access(ctx: Context, name: string, user: User): Promise<void>;
|
|
361
419
|
private info;
|
|
362
420
|
name(): string;
|
|
363
421
|
sync(): Promise<void>;
|
|
364
422
|
}
|
|
365
423
|
|
|
366
|
-
declare class ForgotController extends
|
|
424
|
+
declare class ForgotController extends BaseController {
|
|
367
425
|
protected check(ctx: Context, token: string): Promise<void>;
|
|
368
426
|
protected forgot(ctx: Context, username: string, app: Application): Promise<void>;
|
|
369
427
|
protected reset(ctx: Context, token: string, password: string, app: Application): Promise<void>;
|
|
370
428
|
private find;
|
|
371
429
|
}
|
|
372
430
|
|
|
373
|
-
declare class GroupsController extends
|
|
431
|
+
declare class GroupsController extends CrudController<GroupModel> {
|
|
432
|
+
protected readonly model: typeof GroupModel;
|
|
374
433
|
private schemaCreate;
|
|
375
434
|
private schemaUpdate;
|
|
376
|
-
model(): typeof Group;
|
|
377
|
-
CrudArgumentsFindAll(ctx: Context): ArgumentsModelFindAll<Group>;
|
|
378
435
|
CrudValidationCreate(): TypeObject<ValidationBase>;
|
|
379
436
|
CrudValidationUpdate(): TypeObject<ValidationBase>;
|
|
380
437
|
}
|
|
381
438
|
|
|
382
|
-
declare class GroupsPermissionsController extends
|
|
383
|
-
model
|
|
439
|
+
declare class GroupsPermissionsController extends ModelController<GroupPermissionModel> {
|
|
440
|
+
protected readonly model: typeof GroupPermissionModel;
|
|
384
441
|
protected all(ctx: Context, group_id: string): Promise<void>;
|
|
385
|
-
protected me(ctx: Context, user:
|
|
386
|
-
protected set(ctx: Context, id: string, permissions: Array<
|
|
442
|
+
protected me(ctx: Context, user: UserModel): Promise<void>;
|
|
443
|
+
protected set(ctx: Context, id: string, permissions: Array<string>): Promise<void>;
|
|
387
444
|
}
|
|
388
445
|
|
|
389
|
-
declare class LogsController extends
|
|
390
|
-
protected
|
|
391
|
-
|
|
392
|
-
protected all(ctx: Context
|
|
446
|
+
declare class LogsController extends ModelController<LogModel> {
|
|
447
|
+
protected readonly model: typeof LogModel;
|
|
448
|
+
protected readonly permissions: Array<string>;
|
|
449
|
+
protected all(ctx: Context): Promise<void>;
|
|
393
450
|
}
|
|
394
451
|
|
|
395
|
-
declare class PermissionsController extends
|
|
452
|
+
declare class PermissionsController extends CrudController<PermissionModel> {
|
|
453
|
+
protected readonly model: typeof PermissionModel;
|
|
396
454
|
private schemaCreate;
|
|
397
455
|
private schemaUpdate;
|
|
398
|
-
model(): typeof Permission;
|
|
399
|
-
CrudArgumentsFindAll(ctx: Context): ArgumentsModelFindAll<Permission>;
|
|
400
456
|
CrudValidationCreate(): TypeObject<ValidationBase>;
|
|
401
457
|
CrudValidationUpdate(): TypeObject<ValidationBase>;
|
|
402
458
|
}
|
|
403
459
|
|
|
404
|
-
declare class RegisterController extends
|
|
460
|
+
declare class RegisterController extends BaseController {
|
|
405
461
|
protected register(ctx: Context, body: TypeAnyObject, app: Application): Promise<void>;
|
|
406
462
|
protected confirm(ctx: Context, token: string, app: Application): Promise<void>;
|
|
407
463
|
protected send(ctx: Context, username: string, app: Application): Promise<void>;
|
|
408
464
|
private getId;
|
|
409
465
|
}
|
|
410
466
|
|
|
411
|
-
declare class SetupController extends
|
|
412
|
-
protected setup(ctx: Context
|
|
467
|
+
declare class SetupController extends BaseController {
|
|
468
|
+
protected setup(ctx: Context): Promise<void>;
|
|
413
469
|
}
|
|
414
470
|
|
|
415
|
-
declare class UsersController extends
|
|
471
|
+
declare class UsersController extends ModelController<UserModel> {
|
|
472
|
+
protected readonly model: typeof UserModel;
|
|
416
473
|
path: string;
|
|
417
|
-
model(): typeof User;
|
|
418
474
|
constructor();
|
|
419
|
-
protected avatar(ctx: Context,
|
|
420
|
-
protected avatar_del(ctx: Context, user: User, audit: TypeAnyObject): Promise<void>;
|
|
421
|
-
protected password(ctx: Context, oldPassword: string, newPassword: string, user: User, audit: TypeAnyObject): Promise<void>;
|
|
422
|
-
protected token(ctx: Context, user: User, app: Application): Promise<void>;
|
|
423
|
-
protected token_del(ctx: Context, id: string, audit: TypeAnyObject): Promise<void>;
|
|
424
|
-
protected token_get(ctx: Context, id: string, app: Application): Promise<void>;
|
|
425
|
-
protected token_renew(ctx: Context, id: string, audit: TypeAnyObject, app: Application): Promise<void>;
|
|
475
|
+
protected avatar(ctx: Context, user: UserModel): Promise<void>;
|
|
426
476
|
private token_new;
|
|
427
|
-
protected add(ctx: Context
|
|
477
|
+
protected add(ctx: Context): Promise<void>;
|
|
428
478
|
protected all(ctx: Context): Promise<void>;
|
|
429
|
-
protected del(ctx: Context, id: string, user:
|
|
479
|
+
protected del(ctx: Context, id: string, user: UserModel): Promise<void>;
|
|
430
480
|
protected get(ctx: Context): Promise<void>;
|
|
431
|
-
protected set(ctx: Context
|
|
481
|
+
protected set(ctx: Context): Promise<void>;
|
|
432
482
|
}
|
|
433
483
|
|
|
434
|
-
declare class UsersGroupsController extends
|
|
435
|
-
model
|
|
484
|
+
declare class UsersGroupsController extends ModelController<UserGroupModel> {
|
|
485
|
+
protected readonly model: typeof UserGroupModel;
|
|
436
486
|
protected all(ctx: Context, user_id: string): Promise<void>;
|
|
437
|
-
protected me(ctx: Context, user:
|
|
438
|
-
protected set(ctx: Context, id: string, groups: Array<
|
|
487
|
+
protected me(ctx: Context, user: UserModel): Promise<void>;
|
|
488
|
+
protected set(ctx: Context, id: string, groups: Array<string>): Promise<void>;
|
|
439
489
|
}
|
|
440
490
|
|
|
441
|
-
declare const
|
|
491
|
+
declare const sequelize: Sequelize;
|
|
442
492
|
|
|
443
|
-
declare const
|
|
493
|
+
declare const CanCreate: (name?: string) => MethodDecorator;
|
|
444
494
|
|
|
445
|
-
declare const
|
|
495
|
+
declare const CanDelete: (name?: string) => MethodDecorator;
|
|
446
496
|
|
|
447
|
-
declare const
|
|
497
|
+
declare const canFactory: (key: string) => (name?: string) => MethodDecorator;
|
|
448
498
|
|
|
449
|
-
declare
|
|
450
|
-
export namespace Express {
|
|
451
|
-
interface Request {
|
|
452
|
-
auth?: Auth;
|
|
453
|
-
user?: User;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
499
|
+
declare const CanRead: (name?: string) => MethodDecorator;
|
|
457
500
|
|
|
458
|
-
declare
|
|
459
|
-
protected static error(error: any): void;
|
|
460
|
-
}
|
|
501
|
+
declare const CanUpdate: (name?: string) => MethodDecorator;
|
|
461
502
|
|
|
462
|
-
declare
|
|
463
|
-
static user(key: string, app: Application): Promise<IAuthParameters>;
|
|
464
|
-
}
|
|
503
|
+
declare const HasGroups: (...groups: Array<string>) => MethodDecorator;
|
|
465
504
|
|
|
466
|
-
declare
|
|
467
|
-
private static options;
|
|
468
|
-
static create(user: User): Promise<IAuthParameters>;
|
|
469
|
-
static destroy(auth?: Auth): Promise<boolean>;
|
|
470
|
-
static renew(token: string): Promise<IAuthParameters>;
|
|
471
|
-
static user(token: string): Promise<IAuthParameters>;
|
|
472
|
-
private static verify;
|
|
473
|
-
}
|
|
505
|
+
declare const HasPermissions: (...permissions: Array<string>) => MethodDecorator;
|
|
474
506
|
|
|
475
|
-
declare const
|
|
507
|
+
declare const IsAuthenticated: () => MethodDecorator;
|
|
476
508
|
|
|
477
|
-
declare const
|
|
478
|
-
afterCreate: (record: Model, options: TypeAnyObject) => Promise<void>;
|
|
479
|
-
afterUpdate: (record: Model, options: TypeAnyObject) => Promise<void>;
|
|
480
|
-
afterDestroy: (record: Model, options: TypeAnyObject) => Promise<void>;
|
|
481
|
-
};
|
|
509
|
+
declare const ReqAuth: (key?: string) => ParameterDecorator;
|
|
482
510
|
|
|
483
|
-
declare const
|
|
484
|
-
http: Buffer<ArrayBufferLike> | undefined;
|
|
485
|
-
token: Buffer<ArrayBufferLike> | undefined;
|
|
486
|
-
};
|
|
487
|
-
declare const key: {
|
|
488
|
-
http: Buffer<ArrayBufferLike> | undefined;
|
|
489
|
-
token: Buffer<ArrayBufferLike> | undefined;
|
|
490
|
-
};
|
|
511
|
+
declare const ReqGroup: (key?: string) => ParameterDecorator;
|
|
491
512
|
|
|
492
|
-
declare
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
513
|
+
declare const ReqGroups: (key?: string) => ParameterDecorator;
|
|
514
|
+
|
|
515
|
+
declare const ReqPermission: (key?: string) => ParameterDecorator;
|
|
516
|
+
|
|
517
|
+
declare const ReqPermissions: (key?: string) => ParameterDecorator;
|
|
518
|
+
|
|
519
|
+
declare const ReqUser: (key?: string) => ParameterDecorator;
|
|
520
|
+
|
|
521
|
+
declare const Audit: (active?: boolean) => ClassDecorator;
|
|
522
|
+
|
|
523
|
+
declare class Env extends Env$1 {
|
|
524
|
+
static readonly BASE_NAME: string;
|
|
525
|
+
static readonly CONSOLE_ERROR: boolean;
|
|
526
|
+
static readonly DATABASE_URI: string;
|
|
527
|
+
static readonly DATABASE_LOG: boolean;
|
|
528
|
+
static readonly DATABASE_AUDIT: boolean;
|
|
529
|
+
static readonly DATABASE_PREFIX: string;
|
|
530
|
+
static readonly DATABASE_TIMEZONE: string;
|
|
531
|
+
static readonly HTTP_CRT: Buffer<ArrayBufferLike> | null;
|
|
532
|
+
static readonly HTTP_KEY: Buffer<ArrayBufferLike> | null;
|
|
533
|
+
static readonly TOKEN_CRT: Buffer<ArrayBufferLike> | null;
|
|
534
|
+
static readonly TOKEN_KEY: Buffer<ArrayBufferLike> | null;
|
|
535
|
+
static readonly API_BODYPARSER_STRICT: boolean;
|
|
536
|
+
static readonly API_BODYPARSER_INFLATE: boolean;
|
|
537
|
+
static readonly API_BODYPARSER_LIMIT: string;
|
|
538
|
+
static readonly API_BODYPARSER_TYPE: string;
|
|
539
|
+
static readonly API_HTTP_PORT: number;
|
|
540
|
+
static readonly API_HTTP_PUBLIC: string;
|
|
541
|
+
static readonly API_HTTP_CROSS: boolean;
|
|
542
|
+
static readonly API_HTTP_HYBRID: boolean;
|
|
543
|
+
static readonly API_HTTP_NOTFOUND: string;
|
|
544
|
+
static readonly API_HTTP_PATH: string;
|
|
545
|
+
static readonly API_HTTP_REDIRECT: string;
|
|
546
|
+
static readonly API_KEY_HASH: string;
|
|
547
|
+
static readonly API_KEY_HEADER: string;
|
|
548
|
+
static readonly API_MODEL_LIMIT: number;
|
|
549
|
+
static readonly API_MODEL_LIMIT_MAX: number;
|
|
550
|
+
static readonly API_SLEEP_AUTH: number;
|
|
551
|
+
static readonly API_SLEEP_FORGOT: number;
|
|
552
|
+
static readonly API_SLEEP_REGISTRY: number;
|
|
553
|
+
static readonly API_SESSION_NAME: string;
|
|
554
|
+
static readonly API_SESSION_LIFETIME: number;
|
|
555
|
+
static readonly API_SESSION_SECRET: string;
|
|
556
|
+
static readonly API_TOKEN_COOKIE: string;
|
|
557
|
+
static readonly API_TOKEN_COOKIE_SET: boolean;
|
|
558
|
+
static readonly API_TOKEN_FORGOT: number;
|
|
559
|
+
static readonly API_TOKEN_HEADER: string;
|
|
560
|
+
static readonly API_TOKEN_HEADER_KEY: string;
|
|
561
|
+
static readonly API_TOKEN_LIFETIME: number;
|
|
562
|
+
static readonly API_TOKEN_RENEW: number;
|
|
563
|
+
static readonly API_USER_HISTORY: boolean;
|
|
564
|
+
static readonly API_WEBSOCKET_START: boolean;
|
|
502
565
|
}
|
|
503
566
|
|
|
504
|
-
export { Application, Audit, AuditsController,
|
|
505
|
-
export type { ArgumentsModel, ArgumentsModelCreate, ArgumentsModelDelete, ArgumentsModelFindAll, ArgumentsModelFindOne, ArgumentsModelUpdate,
|
|
567
|
+
export { Application, Audit, AuditModel, AuditsController, AuthController, AuthService, BaseController, CanCreate, CanDelete, CanRead, CanUpdate, Config, ConfigModel, CrudController, Env, FilesController, ForgotController, ForgotModel, GroupModel, GroupPermissionModel, GroupsController, GroupsPermissionsController, HasGroups, HasPermissions, IsAuthenticated, Log, LogModel, Loggable, LogsController, MigrationModel, ModelController, ModelService, PermissionModel, PermissionsController, RegisterController, RegisterModel, ReqAuth, ReqGroup, ReqGroups, ReqPermission, ReqPermissions, ReqUser, Service, SessionModel, SessionStore, SetupController, UserAuthModel, UserGroupModel, UserMetadataModel, UserModel, UserPasswordModel, UserProfileModel, UserService, UsersController, UsersGroupsController, canFactory, sequelize };
|
|
568
|
+
export type { ArgumentsModel, ArgumentsModelCreate, ArgumentsModelDelete, ArgumentsModelFindAll, ArgumentsModelFindOne, ArgumentsModelUpdate, CallbackModelFindAll, CallbackModelFindOne, IAuthParameters, ResultModelFindAll };
|