@andrewcaires/api 5.0.5 → 5.1.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 +215 -217
- package/dist/index.esm.js +2 -2
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,200 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @andrewcaires/api v5.0
|
|
2
|
+
* @andrewcaires/api v5.1.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
7
|
import { Context, Application as Application$1, IOptions, IStore } from '@andrewcaires/express';
|
|
8
8
|
import { Hash, Env as Env$1 } from '@andrewcaires/node';
|
|
9
|
-
import {
|
|
9
|
+
import { ModelFindOptions, ModelUpdateOptions, Model as Model$1, Sequelize } from '@andrewcaires/sequelize';
|
|
10
10
|
import { TypeAnyObject, TypeObjectString, TypeAnyFunction, TypeAnyConstructor, EventEmitter, TypeObject, ValidationBase } from '@andrewcaires/utils.js';
|
|
11
11
|
import { WebSocketServer } from 'ws';
|
|
12
|
-
import { Model
|
|
12
|
+
import { Model, CreateOptions, Attributes, FindOptions, IncludeOptions, FindAttributeOptions, ModelStatic } from 'sequelize';
|
|
13
13
|
import { Store, SessionData } from 'express-session';
|
|
14
14
|
|
|
15
|
-
declare class RegisterModel extends Model {
|
|
16
|
-
readonly id: string;
|
|
17
|
-
secret: string;
|
|
18
|
-
expired_at: number;
|
|
19
|
-
state: boolean;
|
|
20
|
-
readonly created_at: Date;
|
|
21
|
-
readonly updated_at: Date;
|
|
22
|
-
readonly deleted_at: Date | null;
|
|
23
|
-
user_id: string;
|
|
24
|
-
user: UserModel;
|
|
25
|
-
}
|
|
26
|
-
|
|
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;
|
|
33
|
-
readonly created_at: Date;
|
|
34
|
-
readonly updated_at: Date;
|
|
35
|
-
readonly deleted_at: Date | null;
|
|
36
|
-
user_id: string;
|
|
37
|
-
user: UserModel;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
declare class PermissionModel extends Model {
|
|
41
|
-
readonly id: string;
|
|
42
|
-
name: string;
|
|
43
|
-
key: string;
|
|
44
|
-
tags: string;
|
|
45
|
-
description: string;
|
|
46
|
-
state: boolean;
|
|
47
|
-
readonly created_at: Date;
|
|
48
|
-
readonly updated_at: Date;
|
|
49
|
-
readonly deleted_at: Date | null;
|
|
50
|
-
groups_permissions: Array<GroupPermissionModel>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
declare class GroupPermissionModel extends Model {
|
|
54
|
-
readonly id: string;
|
|
55
|
-
readonly created_at: Date;
|
|
56
|
-
group_id: string;
|
|
57
|
-
group: GroupModel;
|
|
58
|
-
permission_id: string;
|
|
59
|
-
permission: PermissionModel;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
declare class GroupModel extends Model {
|
|
63
|
-
readonly id: string;
|
|
64
|
-
name: string;
|
|
65
|
-
key: string;
|
|
66
|
-
tags: string;
|
|
67
|
-
description: string;
|
|
68
|
-
state: boolean;
|
|
69
|
-
readonly created_at: Date;
|
|
70
|
-
readonly updated_at: Date;
|
|
71
|
-
readonly deleted_at: Date | null;
|
|
72
|
-
users_groups: Array<UserGroupModel>;
|
|
73
|
-
groups_Permission: Array<GroupPermissionModel>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
declare class UserGroupModel extends Model {
|
|
77
|
-
readonly id: string;
|
|
78
|
-
readonly created_at: Date;
|
|
79
|
-
group_id: string;
|
|
80
|
-
group: GroupModel;
|
|
81
|
-
user_id: string;
|
|
82
|
-
user: UserModel;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
declare class UserPasswordModel extends Model {
|
|
86
|
-
readonly id: string;
|
|
87
|
-
value: string;
|
|
88
|
-
state: boolean;
|
|
89
|
-
readonly created_at: Date;
|
|
90
|
-
readonly updated_at: Date;
|
|
91
|
-
readonly deleted_at: Date | null;
|
|
92
|
-
user_id: string;
|
|
93
|
-
user: UserModel;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
declare class UserProfileModel extends Model {
|
|
97
|
-
readonly id: string;
|
|
98
|
-
data: TypeAnyObject;
|
|
99
|
-
readonly created_at: Date;
|
|
100
|
-
readonly updated_at: Date;
|
|
101
|
-
readonly deleted_at: Date | null;
|
|
102
|
-
user_id: string;
|
|
103
|
-
user: UserModel;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
declare class UserModel extends Model {
|
|
107
|
-
readonly id: string;
|
|
108
|
-
name: string;
|
|
109
|
-
email: string;
|
|
110
|
-
username: string;
|
|
111
|
-
description: string;
|
|
112
|
-
state: boolean;
|
|
113
|
-
readonly created_at: Date;
|
|
114
|
-
readonly updated_at: Date;
|
|
115
|
-
readonly deleted_at: Date | null;
|
|
116
|
-
audits: Array<AuditModel>;
|
|
117
|
-
users_auths: Array<UserAuthModel>;
|
|
118
|
-
registers: Array<RegisterModel>;
|
|
119
|
-
users_groups: Array<UserGroupModel>;
|
|
120
|
-
users_passwords: Array<UserPasswordModel>;
|
|
121
|
-
users_profiles: Array<UserProfileModel>;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
declare class AuditModel extends Model {
|
|
125
|
-
readonly id: string;
|
|
126
|
-
type: "CREATE" | "DELETE" | "UPDATE";
|
|
127
|
-
model: string;
|
|
128
|
-
record: string;
|
|
129
|
-
data: TypeAnyObject;
|
|
130
|
-
previously: TypeAnyObject;
|
|
131
|
-
full_url: string;
|
|
132
|
-
ip_address: string;
|
|
133
|
-
user_agent: string;
|
|
134
|
-
app_name: string;
|
|
135
|
-
state: boolean;
|
|
136
|
-
readonly created_at: Date;
|
|
137
|
-
readonly updated_at: Date;
|
|
138
|
-
readonly deleted_at: Date | null;
|
|
139
|
-
user_id: string;
|
|
140
|
-
user: UserModel;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
declare class ConfigModel extends Model {
|
|
144
|
-
readonly id: string;
|
|
145
|
-
key: string;
|
|
146
|
-
value: string;
|
|
147
|
-
readonly created_at: Date;
|
|
148
|
-
readonly updated_at: Date;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
declare class ForgotModel extends Model {
|
|
152
|
-
readonly id: string;
|
|
153
|
-
secret: string;
|
|
154
|
-
expired_at: number;
|
|
155
|
-
state: boolean;
|
|
156
|
-
readonly created_at: Date;
|
|
157
|
-
readonly updated_at: Date;
|
|
158
|
-
readonly deleted_at: Date | null;
|
|
159
|
-
user_id: string;
|
|
160
|
-
user: UserModel;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
declare class LogModel extends Model {
|
|
164
|
-
readonly id: string;
|
|
165
|
-
level: "info" | "warn" | "error";
|
|
166
|
-
message: string;
|
|
167
|
-
source: string;
|
|
168
|
-
readonly created_at: Date;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
declare class MigrationModel extends Model {
|
|
172
|
-
readonly id: string;
|
|
173
|
-
model: string;
|
|
174
|
-
version: string;
|
|
175
|
-
readonly created_at: Date;
|
|
176
|
-
readonly updated_at: Date;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
declare class SessionModel extends Model {
|
|
180
|
-
readonly id: string;
|
|
181
|
-
session: string;
|
|
182
|
-
json: string;
|
|
183
|
-
expired: number;
|
|
184
|
-
readonly created_at: Date;
|
|
185
|
-
readonly updated_at: Date;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
declare class UserMetadataModel extends Model {
|
|
189
|
-
readonly id: string;
|
|
190
|
-
data: TypeAnyObject;
|
|
191
|
-
readonly created_at: Date;
|
|
192
|
-
readonly updated_at: Date;
|
|
193
|
-
readonly deleted_at: Date | null;
|
|
194
|
-
user_id: string;
|
|
195
|
-
user: UserModel;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
15
|
interface IAuthParameters {
|
|
199
16
|
auth?: UserAuthModel;
|
|
200
17
|
decode?: TypeAnyObject;
|
|
@@ -292,36 +109,35 @@ declare module "express-serve-static-core" {
|
|
|
292
109
|
}
|
|
293
110
|
}
|
|
294
111
|
|
|
295
|
-
interface ModelArgumentsBase<M extends Model
|
|
112
|
+
interface ModelArgumentsBase<M extends Model<M>> {
|
|
296
113
|
ctx?: Context;
|
|
297
114
|
}
|
|
298
115
|
|
|
299
|
-
interface ModelArgumentsCount<M extends Model
|
|
116
|
+
interface ModelArgumentsCount<M extends Model<any>> extends ModelArgumentsBase<M> {
|
|
300
117
|
options?: ModelFindOptions<M>;
|
|
301
118
|
}
|
|
302
119
|
|
|
303
|
-
interface ModelArgumentsCreate<M extends Model
|
|
120
|
+
interface ModelArgumentsCreate<M extends Model<M>> extends ModelArgumentsBase<M> {
|
|
304
121
|
body?: TypeAnyObject;
|
|
305
122
|
options?: CreateOptions<Attributes<M>>;
|
|
306
123
|
}
|
|
307
124
|
|
|
308
|
-
interface ModelArgumentsDelete<M extends Model
|
|
125
|
+
interface ModelArgumentsDelete<M extends Model<M>> extends ModelArgumentsBase<M> {
|
|
309
126
|
id?: string | number;
|
|
310
127
|
options?: FindOptions<Attributes<M>>;
|
|
311
128
|
}
|
|
312
129
|
|
|
313
130
|
type ModelCallbackFindAll<M> = (_records: Array<M>) => Array<any> | Promise<Array<any>>;
|
|
314
131
|
|
|
315
|
-
interface ModelArgumentsFindAll<M extends Model
|
|
132
|
+
interface ModelArgumentsFindAll<M extends Model<any>> extends ModelArgumentsBase<M> {
|
|
316
133
|
callback?: ModelCallbackFindAll<M>;
|
|
317
|
-
limited?: boolean;
|
|
318
134
|
options?: FindOptions<Attributes<M>>;
|
|
319
135
|
query?: boolean;
|
|
320
136
|
}
|
|
321
137
|
|
|
322
138
|
type ModelCallbackFindOne<M> = (_records: M) => any | Promise<any>;
|
|
323
139
|
|
|
324
|
-
interface ModelArgumentsFindOne<M extends Model
|
|
140
|
+
interface ModelArgumentsFindOne<M extends Model<M>> extends ModelArgumentsBase<M> {
|
|
325
141
|
callback?: ModelCallbackFindOne<M>;
|
|
326
142
|
id?: string | number;
|
|
327
143
|
options?: FindOptions<Attributes<M>>;
|
|
@@ -332,7 +148,7 @@ interface ModelArgumentsInclude extends Omit<IncludeOptions, "model">, ModelArgu
|
|
|
332
148
|
name?: string;
|
|
333
149
|
}
|
|
334
150
|
|
|
335
|
-
interface ModelArgumentsUpdate<M extends Model
|
|
151
|
+
interface ModelArgumentsUpdate<M extends Model<M>> extends ModelArgumentsBase<M> {
|
|
336
152
|
body?: TypeAnyObject;
|
|
337
153
|
id?: string | number;
|
|
338
154
|
options?: ModelUpdateOptions<M>;
|
|
@@ -344,11 +160,188 @@ interface ModelOptions {
|
|
|
344
160
|
search?: Array<string>;
|
|
345
161
|
}
|
|
346
162
|
|
|
347
|
-
interface ModelResultFindAll<M extends Model<M>> {
|
|
163
|
+
interface ModelResultFindAll<M extends Model$1<M>> {
|
|
348
164
|
count: number;
|
|
349
165
|
records: Array<M>;
|
|
350
166
|
}
|
|
351
167
|
|
|
168
|
+
declare enum AuditTypes {
|
|
169
|
+
CREATE = "CREATE",
|
|
170
|
+
DELETE = "DELETE",
|
|
171
|
+
UPDATE = "UPDATE"
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
declare enum Loglevels {
|
|
175
|
+
INFO = "info",
|
|
176
|
+
WARN = "warn",
|
|
177
|
+
ERROR = "error"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare enum UserStatus {
|
|
181
|
+
ACTIVE = "active",
|
|
182
|
+
PENDING = "pending",
|
|
183
|
+
DISABLED = "disabled",
|
|
184
|
+
LOCKED = "locked",
|
|
185
|
+
ARCHIVED = "archived"
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare class RegisterModel extends Model$1 {
|
|
189
|
+
readonly id: string;
|
|
190
|
+
secret: string;
|
|
191
|
+
expired_at: number;
|
|
192
|
+
active: boolean;
|
|
193
|
+
readonly created_at: Date;
|
|
194
|
+
readonly updated_at: Date;
|
|
195
|
+
readonly deleted_at: Date | null;
|
|
196
|
+
user_id: string;
|
|
197
|
+
user: UserModel;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare class UserAuthModel extends Model$1 {
|
|
201
|
+
readonly id: string;
|
|
202
|
+
secret: string;
|
|
203
|
+
ip_address: string;
|
|
204
|
+
user_agent: string;
|
|
205
|
+
revoked_at: Date | null;
|
|
206
|
+
readonly created_at: Date;
|
|
207
|
+
readonly updated_at: Date;
|
|
208
|
+
readonly deleted_at: Date | null;
|
|
209
|
+
user_id: string;
|
|
210
|
+
user: UserModel;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare class PermissionModel extends Model$1 {
|
|
214
|
+
readonly id: string;
|
|
215
|
+
name: string;
|
|
216
|
+
description: string;
|
|
217
|
+
active: boolean;
|
|
218
|
+
readonly created_at: Date;
|
|
219
|
+
readonly updated_at: Date;
|
|
220
|
+
readonly deleted_at: Date | null;
|
|
221
|
+
groups_permissions: Array<GroupPermissionModel>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare class GroupPermissionModel extends Model$1 {
|
|
225
|
+
readonly id: string;
|
|
226
|
+
readonly created_at: Date;
|
|
227
|
+
group_id: string;
|
|
228
|
+
group: GroupModel;
|
|
229
|
+
permission_id: string;
|
|
230
|
+
permission: PermissionModel;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
declare class GroupModel extends Model$1 {
|
|
234
|
+
readonly id: string;
|
|
235
|
+
name: string;
|
|
236
|
+
description: string;
|
|
237
|
+
active: boolean;
|
|
238
|
+
readonly created_at: Date;
|
|
239
|
+
readonly updated_at: Date;
|
|
240
|
+
readonly deleted_at: Date | null;
|
|
241
|
+
users_groups: Array<UserGroupModel>;
|
|
242
|
+
groups_Permission: Array<GroupPermissionModel>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
declare class UserGroupModel extends Model$1 {
|
|
246
|
+
readonly id: string;
|
|
247
|
+
readonly created_at: Date;
|
|
248
|
+
group_id: string;
|
|
249
|
+
group: GroupModel;
|
|
250
|
+
user_id: string;
|
|
251
|
+
user: UserModel;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class UserPasswordModel extends Model$1 {
|
|
255
|
+
readonly id: string;
|
|
256
|
+
hash: string;
|
|
257
|
+
revoked_at: Date | null;
|
|
258
|
+
readonly created_at: Date;
|
|
259
|
+
readonly updated_at: Date;
|
|
260
|
+
readonly deleted_at: Date | null;
|
|
261
|
+
user_id: string;
|
|
262
|
+
user: UserModel;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
declare class UserModel extends Model$1 {
|
|
266
|
+
readonly id: string;
|
|
267
|
+
name: string;
|
|
268
|
+
username: string;
|
|
269
|
+
email: string;
|
|
270
|
+
notes: string;
|
|
271
|
+
status: UserStatus;
|
|
272
|
+
metadata: TypeAnyObject;
|
|
273
|
+
readonly created_at: Date;
|
|
274
|
+
readonly updated_at: Date;
|
|
275
|
+
readonly deleted_at: Date | null;
|
|
276
|
+
audits: Array<AuditModel>;
|
|
277
|
+
users_auths: Array<UserAuthModel>;
|
|
278
|
+
registers: Array<RegisterModel>;
|
|
279
|
+
users_groups: Array<UserGroupModel>;
|
|
280
|
+
users_passwords: Array<UserPasswordModel>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
declare class AuditModel extends Model$1 {
|
|
284
|
+
readonly id: string;
|
|
285
|
+
type: AuditTypes;
|
|
286
|
+
model: string;
|
|
287
|
+
record: string;
|
|
288
|
+
currently: TypeAnyObject;
|
|
289
|
+
previously: TypeAnyObject;
|
|
290
|
+
full_url: string;
|
|
291
|
+
ip_address: string;
|
|
292
|
+
user_agent: string;
|
|
293
|
+
source: string;
|
|
294
|
+
readonly created_at: Date;
|
|
295
|
+
readonly updated_at: Date;
|
|
296
|
+
readonly deleted_at: Date | null;
|
|
297
|
+
user_id: string;
|
|
298
|
+
user: UserModel;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
declare class ConfigModel extends Model$1 {
|
|
302
|
+
readonly id: string;
|
|
303
|
+
key: string;
|
|
304
|
+
value: string;
|
|
305
|
+
readonly created_at: Date;
|
|
306
|
+
readonly updated_at: Date;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
declare class ForgotModel extends Model$1 {
|
|
310
|
+
readonly id: string;
|
|
311
|
+
secret: string;
|
|
312
|
+
expired_at: number;
|
|
313
|
+
state: boolean;
|
|
314
|
+
readonly created_at: Date;
|
|
315
|
+
readonly updated_at: Date;
|
|
316
|
+
readonly deleted_at: Date | null;
|
|
317
|
+
user_id: string;
|
|
318
|
+
user: UserModel;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
declare class LogModel extends Model$1 {
|
|
322
|
+
readonly id: string;
|
|
323
|
+
level: Loglevels;
|
|
324
|
+
message: string;
|
|
325
|
+
source: string;
|
|
326
|
+
readonly created_at: Date;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare class MigrationModel extends Model$1 {
|
|
330
|
+
readonly id: string;
|
|
331
|
+
model: string;
|
|
332
|
+
version: string;
|
|
333
|
+
readonly created_at: Date;
|
|
334
|
+
readonly updated_at: Date;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
declare class SessionModel extends Model$1 {
|
|
338
|
+
readonly id: string;
|
|
339
|
+
data: TypeAnyObject;
|
|
340
|
+
expired_at: Date;
|
|
341
|
+
readonly created_at: Date;
|
|
342
|
+
readonly updated_at: Date;
|
|
343
|
+
}
|
|
344
|
+
|
|
352
345
|
declare class Loggable {
|
|
353
346
|
get log(): (message: string) => void;
|
|
354
347
|
static get log(): (message: string) => void;
|
|
@@ -375,15 +368,14 @@ declare class Log {
|
|
|
375
368
|
}
|
|
376
369
|
|
|
377
370
|
declare class SessionStore extends Store {
|
|
378
|
-
private loop;
|
|
379
371
|
constructor();
|
|
380
372
|
all: (callback: TypeAnyFunction) => Promise<void>;
|
|
381
373
|
clear: (callback: TypeAnyFunction) => Promise<void>;
|
|
382
|
-
destroy: (
|
|
374
|
+
destroy: (id: string, callback: TypeAnyFunction) => Promise<void>;
|
|
383
375
|
expired: () => Promise<void>;
|
|
384
|
-
get: (
|
|
376
|
+
get: (id: string, callback: TypeAnyFunction) => Promise<void>;
|
|
385
377
|
length: (callback: TypeAnyFunction) => Promise<void>;
|
|
386
|
-
set: (
|
|
378
|
+
set: (id: any, data: SessionData, callback: TypeAnyFunction) => Promise<void>;
|
|
387
379
|
}
|
|
388
380
|
|
|
389
381
|
interface Service extends Loggable {
|
|
@@ -392,6 +384,7 @@ declare abstract class Service {
|
|
|
392
384
|
}
|
|
393
385
|
|
|
394
386
|
declare class AuthService extends Service {
|
|
387
|
+
private readonly userAttributes;
|
|
395
388
|
create(user: UserModel): Promise<IAuthParameters>;
|
|
396
389
|
destroy(auth?: UserAuthModel): Promise<boolean>;
|
|
397
390
|
renew(token: string): Promise<IAuthParameters>;
|
|
@@ -401,7 +394,7 @@ declare class AuthService extends Service {
|
|
|
401
394
|
key(value: string): Promise<IAuthParameters>;
|
|
402
395
|
}
|
|
403
396
|
|
|
404
|
-
declare class ModelService<M extends Model
|
|
397
|
+
declare class ModelService<M extends Model<any>> extends Service {
|
|
405
398
|
protected model: ModelStatic<M>;
|
|
406
399
|
protected attributes: Array<string>;
|
|
407
400
|
protected permissions: Array<string>;
|
|
@@ -426,9 +419,11 @@ declare class ModelService<M extends Model$1<any>> extends Service {
|
|
|
426
419
|
}
|
|
427
420
|
|
|
428
421
|
declare class UserService extends Service {
|
|
429
|
-
|
|
430
|
-
|
|
422
|
+
private hashOptions;
|
|
423
|
+
createPassword(user_id: string, value: string, ctx?: Context): Promise<void>;
|
|
424
|
+
private findAllPermission;
|
|
431
425
|
getGroups(user_id: string): Promise<Array<string>>;
|
|
426
|
+
getGroupsPermissions(user_id: string): Promise<TypeAnyObject>;
|
|
432
427
|
getPermissions(user_id: string): Promise<Array<string>>;
|
|
433
428
|
}
|
|
434
429
|
|
|
@@ -454,7 +449,7 @@ declare abstract class BaseController<T extends TypeAnyObject = TypeAnyObject> e
|
|
|
454
449
|
sync(): Promise<void>;
|
|
455
450
|
}
|
|
456
451
|
|
|
457
|
-
declare abstract class ModelController<M extends Model
|
|
452
|
+
declare abstract class ModelController<M extends Model<any>, T extends TypeAnyObject = TypeAnyObject> extends BaseController<T> {
|
|
458
453
|
protected readonly attributes: Array<string>;
|
|
459
454
|
protected abstract readonly model: ModelStatic<M>;
|
|
460
455
|
protected readonly permissions: Array<string>;
|
|
@@ -487,7 +482,7 @@ declare class AuthController extends BaseController<AuthEvents> {
|
|
|
487
482
|
protected user(ctx: Context, user: UserModel): Promise<void>;
|
|
488
483
|
}
|
|
489
484
|
|
|
490
|
-
declare abstract class CrudController<M extends Model
|
|
485
|
+
declare abstract class CrudController<M extends Model<any>, T extends TypeAnyObject = TypeAnyObject> extends ModelController<M, T> {
|
|
491
486
|
private _crud;
|
|
492
487
|
CrudArgumentsCountAll(ctx: Context): ModelArgumentsUpdate<M>;
|
|
493
488
|
CrudArgumentsCreate(ctx: Context): ModelArgumentsUpdate<M>;
|
|
@@ -529,7 +524,7 @@ declare class GroupsController extends CrudController<GroupModel> {
|
|
|
529
524
|
private schemaCreate;
|
|
530
525
|
private schemaUpdate;
|
|
531
526
|
CrudValidateCreate(): TypeObject<ValidationBase>;
|
|
532
|
-
|
|
527
|
+
CrudValidateUpdate(): TypeObject<ValidationBase>;
|
|
533
528
|
}
|
|
534
529
|
|
|
535
530
|
declare class GroupsPermissionsController extends ModelController<GroupPermissionModel> {
|
|
@@ -539,6 +534,10 @@ declare class GroupsPermissionsController extends ModelController<GroupPermissio
|
|
|
539
534
|
protected set(ctx: Context, id: string, permissions: Array<string>): Promise<void>;
|
|
540
535
|
}
|
|
541
536
|
|
|
537
|
+
declare class HealthController {
|
|
538
|
+
protected ping(ctx: Context): Promise<void>;
|
|
539
|
+
}
|
|
540
|
+
|
|
542
541
|
declare class LogsController extends ModelController<LogModel> {
|
|
543
542
|
protected readonly model: typeof LogModel;
|
|
544
543
|
protected readonly permissions: Array<string>;
|
|
@@ -561,6 +560,8 @@ declare class RegisterController extends BaseController<RegisterEvents> {
|
|
|
561
560
|
}
|
|
562
561
|
|
|
563
562
|
declare class SetupController extends BaseController {
|
|
563
|
+
protected readonly userService: UserService;
|
|
564
|
+
constructor(userService: UserService);
|
|
564
565
|
protected setup(ctx: Context): Promise<void>;
|
|
565
566
|
}
|
|
566
567
|
|
|
@@ -585,21 +586,13 @@ declare class UsersGroupsController extends ModelController<UserGroupModel> {
|
|
|
585
586
|
protected set(ctx: Context, id: string, groups: Array<string>): Promise<void>;
|
|
586
587
|
}
|
|
587
588
|
|
|
588
|
-
declare class UsersProfilesController extends ModelController<UserProfileModel> {
|
|
589
|
-
protected readonly model: typeof UserProfileModel;
|
|
590
|
-
protected readonly permissions: never[];
|
|
591
|
-
protected all(ctx: Context): Promise<void>;
|
|
592
|
-
protected get(ctx: Context, user_id: string): Promise<void>;
|
|
593
|
-
protected set(ctx: Context, id: string, body: TypeAnyObject): Promise<void>;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
589
|
declare const sequelize: Sequelize;
|
|
597
590
|
|
|
598
591
|
declare const CanCreate: (name?: string) => MethodDecorator;
|
|
599
592
|
|
|
600
593
|
declare const CanDelete: (name?: string) => MethodDecorator;
|
|
601
594
|
|
|
602
|
-
declare const canFactory: (
|
|
595
|
+
declare const canFactory: (permission: string) => (name?: string) => MethodDecorator;
|
|
603
596
|
|
|
604
597
|
declare const CanRead: (name?: string) => MethodDecorator;
|
|
605
598
|
|
|
@@ -633,23 +626,29 @@ declare class Env extends Env$1 {
|
|
|
633
626
|
static readonly DATABASE_AUDIT: boolean;
|
|
634
627
|
static readonly DATABASE_PREFIX: string;
|
|
635
628
|
static readonly DATABASE_TIMEZONE: string;
|
|
629
|
+
static readonly HTTP_CROSS: string;
|
|
636
630
|
static readonly HTTP_CRT: Buffer<ArrayBufferLike> | null;
|
|
637
631
|
static readonly HTTP_KEY: Buffer<ArrayBufferLike> | null;
|
|
638
632
|
static readonly MODEL_LIMIT: number;
|
|
639
633
|
static readonly MODEL_LIMIT_MAX: number;
|
|
634
|
+
static readonly PASSWORD_ALGORITHM: number;
|
|
635
|
+
static readonly PASSWORD_MEMORY_COST: number;
|
|
636
|
+
static readonly PASSWORD_PARALLELISM: number;
|
|
637
|
+
static readonly PASSWORD_PEPPER: string;
|
|
638
|
+
static readonly PASSWORD_TIME_COST: number;
|
|
640
639
|
static readonly SLEEP_AUTH: number;
|
|
641
640
|
static readonly SLEEP_FORGOT: number;
|
|
642
641
|
static readonly SLEEP_REGISTRY: number;
|
|
643
642
|
static readonly TOKEN_CRT: Buffer<ArrayBufferLike> | null;
|
|
644
643
|
static readonly TOKEN_KEY: Buffer<ArrayBufferLike> | null;
|
|
645
644
|
static readonly TOKEN_TTL: number;
|
|
645
|
+
static readonly TOKEN_TYPE: string;
|
|
646
646
|
static readonly API_BODYPARSER_STRICT: boolean;
|
|
647
647
|
static readonly API_BODYPARSER_INFLATE: boolean;
|
|
648
648
|
static readonly API_BODYPARSER_LIMIT: string;
|
|
649
649
|
static readonly API_BODYPARSER_TYPE: string;
|
|
650
650
|
static readonly API_HTTP_PORT: number;
|
|
651
651
|
static readonly API_HTTP_PUBLIC: string;
|
|
652
|
-
static readonly API_HTTP_CROSS: boolean;
|
|
653
652
|
static readonly API_HTTP_HYBRID: boolean;
|
|
654
653
|
static readonly API_HTTP_NOTFOUND: string;
|
|
655
654
|
static readonly API_HTTP_PATH: string;
|
|
@@ -663,11 +662,10 @@ declare class Env extends Env$1 {
|
|
|
663
662
|
static readonly API_TOKEN_COOKIE_SET: boolean;
|
|
664
663
|
static readonly API_TOKEN_FORGOT: number;
|
|
665
664
|
static readonly API_TOKEN_HEADER: string;
|
|
666
|
-
static readonly API_TOKEN_HEADER_KEY: string;
|
|
667
665
|
static readonly API_TOKEN_RENEW: number;
|
|
668
666
|
static readonly API_USER_HISTORY: boolean;
|
|
669
667
|
static readonly API_WEBSOCKET_START: boolean;
|
|
670
668
|
}
|
|
671
669
|
|
|
672
|
-
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,
|
|
670
|
+
export { Application, Audit, AuditModel, AuditTypes, AuditsController, AuthController, AuthService, BaseController, CanCreate, CanDelete, CanRead, CanUpdate, Config, ConfigModel, CrudController, Env, FilesController, ForgotController, ForgotModel, GroupModel, GroupPermissionModel, GroupsController, GroupsPermissionsController, HasGroups, HasPermissions, HealthController, IsAuthenticated, Log, LogModel, Loggable, Loglevels, LogsController, MigrationModel, ModelController, ModelService, PermissionModel, PermissionsController, RegisterController, RegisterModel, ReqAuth, ReqGroup, ReqGroups, ReqPermission, ReqPermissions, ReqUser, Service, SessionModel, SessionStore, SetupController, UserAuthModel, UserGroupModel, UserModel, UserPasswordModel, UserService, UserStatus, UsersController, UsersGroupsController, canFactory, sequelize };
|
|
673
671
|
export type { ApplicationEvents, AuthEvents, ForgotEvents, IAuthParameters, ModelArgumentsBase, ModelArgumentsCount, ModelArgumentsCreate, ModelArgumentsDelete, ModelArgumentsFindAll, ModelArgumentsFindOne, ModelArgumentsInclude, ModelArgumentsUpdate, ModelCallbackFindAll, ModelCallbackFindOne, ModelOptions, ModelResultFindAll, RegisterEvents };
|