@adaptivestone/framework 5.0.0-rc.5 → 5.0.0-rc.7
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 +1 -0
- package/dist/codegen/appTypes.d.ts +6 -2
- package/dist/codegen/appTypes.js +63 -12
- package/dist/codegen/appTypes.js.map +1 -1
- package/dist/codegen/astConfig.d.ts +47 -0
- package/dist/codegen/astConfig.js +157 -0
- package/dist/codegen/astConfig.js.map +1 -0
- package/dist/codegen/index.js +1 -1
- package/dist/codegen/index.js.map +1 -1
- package/dist/models/User.d.ts +113 -555
- package/dist/models/User.js +34 -1
- package/dist/models/User.js.map +1 -1
- package/dist/modules/BaseModel.d.ts +41 -6
- package/dist/modules/BaseModel.js.map +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.js +10 -3
- package/dist/server.js.map +1 -1
- package/dist/tests/testHelpers.d.ts +166 -242
- package/package.json +1 -1
package/dist/models/User.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TFunction } from 'i18next';
|
|
2
|
-
import type { Schema } from 'mongoose';
|
|
2
|
+
import type { Model, Schema } from 'mongoose';
|
|
3
3
|
import type { ExtractProperty, GetModelTypeFromClass, GetModelTypeLiteFromSchema } from '../modules/BaseModel.ts';
|
|
4
4
|
import { BaseModel } from '../modules/BaseModel.ts';
|
|
5
5
|
/**
|
|
@@ -20,6 +20,49 @@ import { BaseModel } from '../modules/BaseModel.ts';
|
|
|
20
20
|
export declare const hashToken: (token: string) => string;
|
|
21
21
|
export type UserModelLite = GetModelTypeLiteFromSchema<typeof User.modelSchema, ExtractProperty<typeof User, 'schemaOptions'>>;
|
|
22
22
|
export type TUser = GetModelTypeFromClass<typeof User>;
|
|
23
|
+
/** A session-token sub-doc (`generateToken` / `getUserByToken`). */
|
|
24
|
+
type SessionToken = {
|
|
25
|
+
token?: string | null;
|
|
26
|
+
valid?: Date | null;
|
|
27
|
+
};
|
|
28
|
+
/** A verification / recovery sub-doc (carries an expiry, not a `valid` window). */
|
|
29
|
+
type ExpiringToken = {
|
|
30
|
+
token?: string | null;
|
|
31
|
+
until?: Date | null;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The document fields the framework's auth statics & instance methods actually
|
|
35
|
+
* read or write — typed **structurally**, not pinned to the framework's own
|
|
36
|
+
* schema. A project that replaces `User` (extra fields, an i18n `name`, a
|
|
37
|
+
* singular `role`, …) keeps the shipped auth logic callable on its model
|
|
38
|
+
* without casts, as long as it preserves these few fields. This is what lets
|
|
39
|
+
* `getModel('User').getUserByEmailAndPassword(…)` and friends type-check on a
|
|
40
|
+
* customized model instead of forcing a `this`-binding cast at every call site.
|
|
41
|
+
*/
|
|
42
|
+
export interface UserAuthDoc {
|
|
43
|
+
email?: string | null;
|
|
44
|
+
password?: string | null;
|
|
45
|
+
sessionTokens?: SessionToken[] | null;
|
|
46
|
+
verificationTokens?: ExpiringToken[] | null;
|
|
47
|
+
passwordRecoveryTokens?: ExpiringToken[] | null;
|
|
48
|
+
}
|
|
49
|
+
/** A hydrated {@link UserAuthDoc} the instance-side helpers bind to. */
|
|
50
|
+
export type UserAuthInstance = UserAuthDoc & {
|
|
51
|
+
save: () => Promise<unknown>;
|
|
52
|
+
};
|
|
53
|
+
/** Any Mongoose `User` model the auth statics can bind to: one whose documents
|
|
54
|
+
* carry {@link UserAuthDoc}. The framework's own `User` and a project's
|
|
55
|
+
* replacement both satisfy it. */
|
|
56
|
+
export type UserAuthModel = Model<UserAuthDoc>;
|
|
57
|
+
/**
|
|
58
|
+
* The fields `getPublic` reads, as a plain object (a `Pick` of the framework
|
|
59
|
+
* document — NOT the Mongoose `Document` type, whose invariance would reject an
|
|
60
|
+
* additive project model). Binding `this` to this keeps `getPublic`'s return
|
|
61
|
+
* types PRECISE for every caller while still letting a project model that keeps
|
|
62
|
+
* these fields reuse it. A model that reshapes them (e.g. an i18n `name`)
|
|
63
|
+
* doesn't match and overrides `getPublic` with its own public shape.
|
|
64
|
+
*/
|
|
65
|
+
export type UserPublicDoc = Pick<InstanceType<UserModelLite>, 'avatar' | 'name' | 'email' | 'id' | 'isVerified' | 'permissions' | 'locale'>;
|
|
23
66
|
/**
|
|
24
67
|
* Augmentation point so `req.appInfo.user` follows a project's OWN `User` model
|
|
25
68
|
* when it replaces the framework's. `npm run gen` emits this automatically into
|
|
@@ -44,6 +87,37 @@ export interface AppModels {
|
|
|
44
87
|
export type AppUser = AppModels extends {
|
|
45
88
|
User: infer U;
|
|
46
89
|
} ? U : InstanceType<TUser>;
|
|
90
|
+
/**
|
|
91
|
+
* The framework's default `User` model — and the intended customization point.
|
|
92
|
+
* Two supported ways to replace it with a project model (drop yours in the
|
|
93
|
+
* app's `models/` folder under the name `User`; codegen rebinds `getModel`,
|
|
94
|
+
* `req.appInfo.user`, and `AppModels` to it):
|
|
95
|
+
*
|
|
96
|
+
* 1. **Add fields** — `extends User`, spread the schema, append your own:
|
|
97
|
+
* ```ts
|
|
98
|
+
* class User extends FrameworkUser {
|
|
99
|
+
* static get modelSchema() {
|
|
100
|
+
* return { ...FrameworkUser.modelSchema, company: { type: String } } as const;
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
* The inherited auth statics & instance methods keep working as-is.
|
|
105
|
+
*
|
|
106
|
+
* 2. **Reshape fields** (e.g. an i18n `name`, a singular `role`) — TypeScript
|
|
107
|
+
* can't express a field-type *replacement* through `extends` (the static-side
|
|
108
|
+
* getter override is checked covariantly → TS2417), so **compose**: extend
|
|
109
|
+
* {@link BaseModel} and reuse the auth logic by spreading it in.
|
|
110
|
+
* ```ts
|
|
111
|
+
* class User extends BaseModel {
|
|
112
|
+
* static get modelSchema() { return { ...your reshaped schema } as const; }
|
|
113
|
+
* static get modelStatics() { return { ...FrameworkUser.modelStatics } as const; }
|
|
114
|
+
* static get modelInstanceMethods() { return { ...FrameworkUser.modelInstanceMethods } as const; }
|
|
115
|
+
* static initHooks(schema: Schema) { FrameworkUser.initHooks(schema); }
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
* The spread statics/methods are typed structurally ({@link UserAuthDoc} /
|
|
119
|
+
* {@link UserAuthModel}), so they stay callable on your model without casts.
|
|
120
|
+
*/
|
|
47
121
|
declare class User extends BaseModel {
|
|
48
122
|
static initHooks(schema: Schema): void;
|
|
49
123
|
static get modelSchema(): {
|
|
@@ -118,343 +192,31 @@ declare class User extends BaseModel {
|
|
|
118
192
|
* @param {string} password
|
|
119
193
|
* @returns {Promise<InstanceType<UserModelLite> | false>}
|
|
120
194
|
*/
|
|
121
|
-
readonly getUserByEmailAndPassword: <T extends
|
|
195
|
+
readonly getUserByEmailAndPassword: <T extends UserAuthModel>(this: T, email: string, password: string) => Promise<false | InstanceType<T>>;
|
|
122
196
|
/**
|
|
123
197
|
* Get user by token
|
|
124
198
|
* @param {string}
|
|
125
199
|
* @returns {Promise<InstanceType<UserModelLite> | false>}
|
|
126
200
|
*/
|
|
127
|
-
readonly getUserByToken: (this:
|
|
128
|
-
isVerified: boolean;
|
|
129
|
-
locale: string;
|
|
130
|
-
createdAt?: NativeDate | null | undefined;
|
|
131
|
-
updatedAt?: NativeDate | null | undefined;
|
|
132
|
-
name?: {
|
|
133
|
-
first?: string | null | undefined;
|
|
134
|
-
last?: string | null | undefined;
|
|
135
|
-
nick?: string | null | undefined;
|
|
136
|
-
} | null | undefined;
|
|
137
|
-
avatar?: string | null | undefined;
|
|
138
|
-
password?: string | null | undefined;
|
|
139
|
-
email?: string | null | undefined;
|
|
140
|
-
sessionTokens?: ({
|
|
141
|
-
valid?: NativeDate | null | undefined;
|
|
142
|
-
token?: string | null | undefined;
|
|
143
|
-
} & {
|
|
144
|
-
_id: import("mongoose").Types.ObjectId;
|
|
145
|
-
})[] | null | undefined;
|
|
146
|
-
verificationTokens?: ({
|
|
147
|
-
token?: string | null | undefined;
|
|
148
|
-
until?: NativeDate | null | undefined;
|
|
149
|
-
} & {
|
|
150
|
-
_id: import("mongoose").Types.ObjectId;
|
|
151
|
-
})[] | null | undefined;
|
|
152
|
-
passwordRecoveryTokens?: ({
|
|
153
|
-
token?: string | null | undefined;
|
|
154
|
-
until?: NativeDate | null | undefined;
|
|
155
|
-
} & {
|
|
156
|
-
_id: import("mongoose").Types.ObjectId;
|
|
157
|
-
})[] | null | undefined;
|
|
158
|
-
permissions?: string[] | null | undefined;
|
|
159
|
-
roles?: string[] | null | undefined;
|
|
160
|
-
languages?: string[] | null | undefined;
|
|
161
|
-
} & {
|
|
162
|
-
_id: import("mongoose").Types.ObjectId;
|
|
163
|
-
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
164
|
-
isVerified: boolean;
|
|
165
|
-
locale: string;
|
|
166
|
-
createdAt?: NativeDate | null | undefined;
|
|
167
|
-
updatedAt?: NativeDate | null | undefined;
|
|
168
|
-
name?: {
|
|
169
|
-
first?: string | null | undefined;
|
|
170
|
-
last?: string | null | undefined;
|
|
171
|
-
nick?: string | null | undefined;
|
|
172
|
-
} | null | undefined;
|
|
173
|
-
avatar?: string | null | undefined;
|
|
174
|
-
password?: string | null | undefined;
|
|
175
|
-
email?: string | null | undefined;
|
|
176
|
-
sessionTokens?: ({
|
|
177
|
-
valid?: NativeDate | null | undefined;
|
|
178
|
-
token?: string | null | undefined;
|
|
179
|
-
} & {
|
|
180
|
-
_id: import("mongoose").Types.ObjectId;
|
|
181
|
-
})[] | null | undefined;
|
|
182
|
-
verificationTokens?: ({
|
|
183
|
-
token?: string | null | undefined;
|
|
184
|
-
until?: NativeDate | null | undefined;
|
|
185
|
-
} & {
|
|
186
|
-
_id: import("mongoose").Types.ObjectId;
|
|
187
|
-
})[] | null | undefined;
|
|
188
|
-
passwordRecoveryTokens?: ({
|
|
189
|
-
token?: string | null | undefined;
|
|
190
|
-
until?: NativeDate | null | undefined;
|
|
191
|
-
} & {
|
|
192
|
-
_id: import("mongoose").Types.ObjectId;
|
|
193
|
-
})[] | null | undefined;
|
|
194
|
-
permissions?: string[] | null | undefined;
|
|
195
|
-
roles?: string[] | null | undefined;
|
|
196
|
-
languages?: string[] | null | undefined;
|
|
197
|
-
} & {
|
|
198
|
-
_id: import("mongoose").Types.ObjectId;
|
|
199
|
-
} & Required<{
|
|
200
|
-
_id: import("mongoose").Types.ObjectId;
|
|
201
|
-
}> & {
|
|
202
|
-
__v: number;
|
|
203
|
-
} & {
|
|
204
|
-
id: string;
|
|
205
|
-
})>;
|
|
201
|
+
readonly getUserByToken: <T extends UserAuthModel>(this: T, token: string) => Promise<false | InstanceType<T>>;
|
|
206
202
|
/**
|
|
207
203
|
* Get user by email
|
|
208
204
|
* @param {string}
|
|
209
205
|
* @returns {Promise<InstanceType<UserModelLite> | false>}
|
|
210
206
|
*/
|
|
211
|
-
readonly getUserByEmail: (this:
|
|
212
|
-
isVerified: boolean;
|
|
213
|
-
locale: string;
|
|
214
|
-
createdAt?: NativeDate | null | undefined;
|
|
215
|
-
updatedAt?: NativeDate | null | undefined;
|
|
216
|
-
name?: {
|
|
217
|
-
first?: string | null | undefined;
|
|
218
|
-
last?: string | null | undefined;
|
|
219
|
-
nick?: string | null | undefined;
|
|
220
|
-
} | null | undefined;
|
|
221
|
-
avatar?: string | null | undefined;
|
|
222
|
-
password?: string | null | undefined;
|
|
223
|
-
email?: string | null | undefined;
|
|
224
|
-
sessionTokens?: ({
|
|
225
|
-
valid?: NativeDate | null | undefined;
|
|
226
|
-
token?: string | null | undefined;
|
|
227
|
-
} & {
|
|
228
|
-
_id: import("mongoose").Types.ObjectId;
|
|
229
|
-
})[] | null | undefined;
|
|
230
|
-
verificationTokens?: ({
|
|
231
|
-
token?: string | null | undefined;
|
|
232
|
-
until?: NativeDate | null | undefined;
|
|
233
|
-
} & {
|
|
234
|
-
_id: import("mongoose").Types.ObjectId;
|
|
235
|
-
})[] | null | undefined;
|
|
236
|
-
passwordRecoveryTokens?: ({
|
|
237
|
-
token?: string | null | undefined;
|
|
238
|
-
until?: NativeDate | null | undefined;
|
|
239
|
-
} & {
|
|
240
|
-
_id: import("mongoose").Types.ObjectId;
|
|
241
|
-
})[] | null | undefined;
|
|
242
|
-
permissions?: string[] | null | undefined;
|
|
243
|
-
roles?: string[] | null | undefined;
|
|
244
|
-
languages?: string[] | null | undefined;
|
|
245
|
-
} & {
|
|
246
|
-
_id: import("mongoose").Types.ObjectId;
|
|
247
|
-
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
248
|
-
isVerified: boolean;
|
|
249
|
-
locale: string;
|
|
250
|
-
createdAt?: NativeDate | null | undefined;
|
|
251
|
-
updatedAt?: NativeDate | null | undefined;
|
|
252
|
-
name?: {
|
|
253
|
-
first?: string | null | undefined;
|
|
254
|
-
last?: string | null | undefined;
|
|
255
|
-
nick?: string | null | undefined;
|
|
256
|
-
} | null | undefined;
|
|
257
|
-
avatar?: string | null | undefined;
|
|
258
|
-
password?: string | null | undefined;
|
|
259
|
-
email?: string | null | undefined;
|
|
260
|
-
sessionTokens?: ({
|
|
261
|
-
valid?: NativeDate | null | undefined;
|
|
262
|
-
token?: string | null | undefined;
|
|
263
|
-
} & {
|
|
264
|
-
_id: import("mongoose").Types.ObjectId;
|
|
265
|
-
})[] | null | undefined;
|
|
266
|
-
verificationTokens?: ({
|
|
267
|
-
token?: string | null | undefined;
|
|
268
|
-
until?: NativeDate | null | undefined;
|
|
269
|
-
} & {
|
|
270
|
-
_id: import("mongoose").Types.ObjectId;
|
|
271
|
-
})[] | null | undefined;
|
|
272
|
-
passwordRecoveryTokens?: ({
|
|
273
|
-
token?: string | null | undefined;
|
|
274
|
-
until?: NativeDate | null | undefined;
|
|
275
|
-
} & {
|
|
276
|
-
_id: import("mongoose").Types.ObjectId;
|
|
277
|
-
})[] | null | undefined;
|
|
278
|
-
permissions?: string[] | null | undefined;
|
|
279
|
-
roles?: string[] | null | undefined;
|
|
280
|
-
languages?: string[] | null | undefined;
|
|
281
|
-
} & {
|
|
282
|
-
_id: import("mongoose").Types.ObjectId;
|
|
283
|
-
} & Required<{
|
|
284
|
-
_id: import("mongoose").Types.ObjectId;
|
|
285
|
-
}> & {
|
|
286
|
-
__v: number;
|
|
287
|
-
} & {
|
|
288
|
-
id: string;
|
|
289
|
-
})>;
|
|
207
|
+
readonly getUserByEmail: <T extends UserAuthModel>(this: T, email: string) => Promise<false | InstanceType<T>>;
|
|
290
208
|
/**
|
|
291
209
|
* Get user by password recovery token
|
|
292
210
|
* @param {string} passwordRecoveryToken
|
|
293
211
|
* @returns {Promise<InstanceType<UserModelLite> | false>}
|
|
294
212
|
*/
|
|
295
|
-
readonly getUserByPasswordRecoveryToken: (this:
|
|
296
|
-
isVerified: boolean;
|
|
297
|
-
locale: string;
|
|
298
|
-
createdAt?: NativeDate | null | undefined;
|
|
299
|
-
updatedAt?: NativeDate | null | undefined;
|
|
300
|
-
name?: {
|
|
301
|
-
first?: string | null | undefined;
|
|
302
|
-
last?: string | null | undefined;
|
|
303
|
-
nick?: string | null | undefined;
|
|
304
|
-
} | null | undefined;
|
|
305
|
-
avatar?: string | null | undefined;
|
|
306
|
-
password?: string | null | undefined;
|
|
307
|
-
email?: string | null | undefined;
|
|
308
|
-
sessionTokens?: ({
|
|
309
|
-
valid?: NativeDate | null | undefined;
|
|
310
|
-
token?: string | null | undefined;
|
|
311
|
-
} & {
|
|
312
|
-
_id: import("mongoose").Types.ObjectId;
|
|
313
|
-
})[] | null | undefined;
|
|
314
|
-
verificationTokens?: ({
|
|
315
|
-
token?: string | null | undefined;
|
|
316
|
-
until?: NativeDate | null | undefined;
|
|
317
|
-
} & {
|
|
318
|
-
_id: import("mongoose").Types.ObjectId;
|
|
319
|
-
})[] | null | undefined;
|
|
320
|
-
passwordRecoveryTokens?: ({
|
|
321
|
-
token?: string | null | undefined;
|
|
322
|
-
until?: NativeDate | null | undefined;
|
|
323
|
-
} & {
|
|
324
|
-
_id: import("mongoose").Types.ObjectId;
|
|
325
|
-
})[] | null | undefined;
|
|
326
|
-
permissions?: string[] | null | undefined;
|
|
327
|
-
roles?: string[] | null | undefined;
|
|
328
|
-
languages?: string[] | null | undefined;
|
|
329
|
-
} & {
|
|
330
|
-
_id: import("mongoose").Types.ObjectId;
|
|
331
|
-
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
332
|
-
isVerified: boolean;
|
|
333
|
-
locale: string;
|
|
334
|
-
createdAt?: NativeDate | null | undefined;
|
|
335
|
-
updatedAt?: NativeDate | null | undefined;
|
|
336
|
-
name?: {
|
|
337
|
-
first?: string | null | undefined;
|
|
338
|
-
last?: string | null | undefined;
|
|
339
|
-
nick?: string | null | undefined;
|
|
340
|
-
} | null | undefined;
|
|
341
|
-
avatar?: string | null | undefined;
|
|
342
|
-
password?: string | null | undefined;
|
|
343
|
-
email?: string | null | undefined;
|
|
344
|
-
sessionTokens?: ({
|
|
345
|
-
valid?: NativeDate | null | undefined;
|
|
346
|
-
token?: string | null | undefined;
|
|
347
|
-
} & {
|
|
348
|
-
_id: import("mongoose").Types.ObjectId;
|
|
349
|
-
})[] | null | undefined;
|
|
350
|
-
verificationTokens?: ({
|
|
351
|
-
token?: string | null | undefined;
|
|
352
|
-
until?: NativeDate | null | undefined;
|
|
353
|
-
} & {
|
|
354
|
-
_id: import("mongoose").Types.ObjectId;
|
|
355
|
-
})[] | null | undefined;
|
|
356
|
-
passwordRecoveryTokens?: ({
|
|
357
|
-
token?: string | null | undefined;
|
|
358
|
-
until?: NativeDate | null | undefined;
|
|
359
|
-
} & {
|
|
360
|
-
_id: import("mongoose").Types.ObjectId;
|
|
361
|
-
})[] | null | undefined;
|
|
362
|
-
permissions?: string[] | null | undefined;
|
|
363
|
-
roles?: string[] | null | undefined;
|
|
364
|
-
languages?: string[] | null | undefined;
|
|
365
|
-
} & {
|
|
366
|
-
_id: import("mongoose").Types.ObjectId;
|
|
367
|
-
} & Required<{
|
|
368
|
-
_id: import("mongoose").Types.ObjectId;
|
|
369
|
-
}> & {
|
|
370
|
-
__v: number;
|
|
371
|
-
} & {
|
|
372
|
-
id: string;
|
|
373
|
-
}>;
|
|
213
|
+
readonly getUserByPasswordRecoveryToken: <T extends UserAuthModel>(this: T, passwordRecoveryToken: string) => Promise<InstanceType<T>>;
|
|
374
214
|
/**
|
|
375
215
|
* Get user by verification token
|
|
376
216
|
* @param {string} verificationToken
|
|
377
217
|
* @returns {Promise<InstanceType<UserModelLite> | false>}
|
|
378
218
|
*/
|
|
379
|
-
readonly getUserByVerificationToken: (this:
|
|
380
|
-
isVerified: boolean;
|
|
381
|
-
locale: string;
|
|
382
|
-
createdAt?: NativeDate | null | undefined;
|
|
383
|
-
updatedAt?: NativeDate | null | undefined;
|
|
384
|
-
name?: {
|
|
385
|
-
first?: string | null | undefined;
|
|
386
|
-
last?: string | null | undefined;
|
|
387
|
-
nick?: string | null | undefined;
|
|
388
|
-
} | null | undefined;
|
|
389
|
-
avatar?: string | null | undefined;
|
|
390
|
-
password?: string | null | undefined;
|
|
391
|
-
email?: string | null | undefined;
|
|
392
|
-
sessionTokens?: ({
|
|
393
|
-
valid?: NativeDate | null | undefined;
|
|
394
|
-
token?: string | null | undefined;
|
|
395
|
-
} & {
|
|
396
|
-
_id: import("mongoose").Types.ObjectId;
|
|
397
|
-
})[] | null | undefined;
|
|
398
|
-
verificationTokens?: ({
|
|
399
|
-
token?: string | null | undefined;
|
|
400
|
-
until?: NativeDate | null | undefined;
|
|
401
|
-
} & {
|
|
402
|
-
_id: import("mongoose").Types.ObjectId;
|
|
403
|
-
})[] | null | undefined;
|
|
404
|
-
passwordRecoveryTokens?: ({
|
|
405
|
-
token?: string | null | undefined;
|
|
406
|
-
until?: NativeDate | null | undefined;
|
|
407
|
-
} & {
|
|
408
|
-
_id: import("mongoose").Types.ObjectId;
|
|
409
|
-
})[] | null | undefined;
|
|
410
|
-
permissions?: string[] | null | undefined;
|
|
411
|
-
roles?: string[] | null | undefined;
|
|
412
|
-
languages?: string[] | null | undefined;
|
|
413
|
-
} & {
|
|
414
|
-
_id: import("mongoose").Types.ObjectId;
|
|
415
|
-
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
416
|
-
isVerified: boolean;
|
|
417
|
-
locale: string;
|
|
418
|
-
createdAt?: NativeDate | null | undefined;
|
|
419
|
-
updatedAt?: NativeDate | null | undefined;
|
|
420
|
-
name?: {
|
|
421
|
-
first?: string | null | undefined;
|
|
422
|
-
last?: string | null | undefined;
|
|
423
|
-
nick?: string | null | undefined;
|
|
424
|
-
} | null | undefined;
|
|
425
|
-
avatar?: string | null | undefined;
|
|
426
|
-
password?: string | null | undefined;
|
|
427
|
-
email?: string | null | undefined;
|
|
428
|
-
sessionTokens?: ({
|
|
429
|
-
valid?: NativeDate | null | undefined;
|
|
430
|
-
token?: string | null | undefined;
|
|
431
|
-
} & {
|
|
432
|
-
_id: import("mongoose").Types.ObjectId;
|
|
433
|
-
})[] | null | undefined;
|
|
434
|
-
verificationTokens?: ({
|
|
435
|
-
token?: string | null | undefined;
|
|
436
|
-
until?: NativeDate | null | undefined;
|
|
437
|
-
} & {
|
|
438
|
-
_id: import("mongoose").Types.ObjectId;
|
|
439
|
-
})[] | null | undefined;
|
|
440
|
-
passwordRecoveryTokens?: ({
|
|
441
|
-
token?: string | null | undefined;
|
|
442
|
-
until?: NativeDate | null | undefined;
|
|
443
|
-
} & {
|
|
444
|
-
_id: import("mongoose").Types.ObjectId;
|
|
445
|
-
})[] | null | undefined;
|
|
446
|
-
permissions?: string[] | null | undefined;
|
|
447
|
-
roles?: string[] | null | undefined;
|
|
448
|
-
languages?: string[] | null | undefined;
|
|
449
|
-
} & {
|
|
450
|
-
_id: import("mongoose").Types.ObjectId;
|
|
451
|
-
} & Required<{
|
|
452
|
-
_id: import("mongoose").Types.ObjectId;
|
|
453
|
-
}> & {
|
|
454
|
-
__v: number;
|
|
455
|
-
} & {
|
|
456
|
-
id: string;
|
|
457
|
-
}>;
|
|
219
|
+
readonly getUserByVerificationToken: <T extends UserAuthModel>(this: T, verificationToken: string) => Promise<InstanceType<T>>;
|
|
458
220
|
};
|
|
459
221
|
static get modelInstanceMethods(): {
|
|
460
222
|
/**
|
|
@@ -479,84 +241,10 @@ declare class User extends BaseModel {
|
|
|
479
241
|
* @param {string} i18n.language
|
|
480
242
|
* @returns {Promise<boolean>}
|
|
481
243
|
*/
|
|
482
|
-
readonly sendPasswordRecoveryEmail: (this:
|
|
483
|
-
isVerified: boolean;
|
|
484
|
-
locale: string;
|
|
485
|
-
createdAt?: NativeDate | null | undefined;
|
|
486
|
-
updatedAt?: NativeDate | null | undefined;
|
|
244
|
+
readonly sendPasswordRecoveryEmail: (this: UserAuthInstance & {
|
|
487
245
|
name?: {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
nick?: string | null | undefined;
|
|
491
|
-
} | null | undefined;
|
|
492
|
-
avatar?: string | null | undefined;
|
|
493
|
-
password?: string | null | undefined;
|
|
494
|
-
email?: string | null | undefined;
|
|
495
|
-
sessionTokens?: ({
|
|
496
|
-
valid?: NativeDate | null | undefined;
|
|
497
|
-
token?: string | null | undefined;
|
|
498
|
-
} & {
|
|
499
|
-
_id: import("mongoose").Types.ObjectId;
|
|
500
|
-
})[] | null | undefined;
|
|
501
|
-
verificationTokens?: ({
|
|
502
|
-
token?: string | null | undefined;
|
|
503
|
-
until?: NativeDate | null | undefined;
|
|
504
|
-
} & {
|
|
505
|
-
_id: import("mongoose").Types.ObjectId;
|
|
506
|
-
})[] | null | undefined;
|
|
507
|
-
passwordRecoveryTokens?: ({
|
|
508
|
-
token?: string | null | undefined;
|
|
509
|
-
until?: NativeDate | null | undefined;
|
|
510
|
-
} & {
|
|
511
|
-
_id: import("mongoose").Types.ObjectId;
|
|
512
|
-
})[] | null | undefined;
|
|
513
|
-
permissions?: string[] | null | undefined;
|
|
514
|
-
roles?: string[] | null | undefined;
|
|
515
|
-
languages?: string[] | null | undefined;
|
|
516
|
-
} & {
|
|
517
|
-
_id: import("mongoose").Types.ObjectId;
|
|
518
|
-
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
519
|
-
isVerified: boolean;
|
|
520
|
-
locale: string;
|
|
521
|
-
createdAt?: NativeDate | null | undefined;
|
|
522
|
-
updatedAt?: NativeDate | null | undefined;
|
|
523
|
-
name?: {
|
|
524
|
-
first?: string | null | undefined;
|
|
525
|
-
last?: string | null | undefined;
|
|
526
|
-
nick?: string | null | undefined;
|
|
527
|
-
} | null | undefined;
|
|
528
|
-
avatar?: string | null | undefined;
|
|
529
|
-
password?: string | null | undefined;
|
|
530
|
-
email?: string | null | undefined;
|
|
531
|
-
sessionTokens?: ({
|
|
532
|
-
valid?: NativeDate | null | undefined;
|
|
533
|
-
token?: string | null | undefined;
|
|
534
|
-
} & {
|
|
535
|
-
_id: import("mongoose").Types.ObjectId;
|
|
536
|
-
})[] | null | undefined;
|
|
537
|
-
verificationTokens?: ({
|
|
538
|
-
token?: string | null | undefined;
|
|
539
|
-
until?: NativeDate | null | undefined;
|
|
540
|
-
} & {
|
|
541
|
-
_id: import("mongoose").Types.ObjectId;
|
|
542
|
-
})[] | null | undefined;
|
|
543
|
-
passwordRecoveryTokens?: ({
|
|
544
|
-
token?: string | null | undefined;
|
|
545
|
-
until?: NativeDate | null | undefined;
|
|
546
|
-
} & {
|
|
547
|
-
_id: import("mongoose").Types.ObjectId;
|
|
548
|
-
})[] | null | undefined;
|
|
549
|
-
permissions?: string[] | null | undefined;
|
|
550
|
-
roles?: string[] | null | undefined;
|
|
551
|
-
languages?: string[] | null | undefined;
|
|
552
|
-
} & {
|
|
553
|
-
_id: import("mongoose").Types.ObjectId;
|
|
554
|
-
} & Required<{
|
|
555
|
-
_id: import("mongoose").Types.ObjectId;
|
|
556
|
-
}> & {
|
|
557
|
-
__v: number;
|
|
558
|
-
} & {
|
|
559
|
-
id: string;
|
|
246
|
+
nick?: string | null;
|
|
247
|
+
} | null;
|
|
560
248
|
}, i18n: {
|
|
561
249
|
t: TFunction;
|
|
562
250
|
language: string;
|
|
@@ -568,84 +256,10 @@ declare class User extends BaseModel {
|
|
|
568
256
|
* @param {string} i18n.language
|
|
569
257
|
* @returns {Promise<boolean>}
|
|
570
258
|
*/
|
|
571
|
-
readonly sendVerificationEmail: (this:
|
|
572
|
-
isVerified: boolean;
|
|
573
|
-
locale: string;
|
|
574
|
-
createdAt?: NativeDate | null | undefined;
|
|
575
|
-
updatedAt?: NativeDate | null | undefined;
|
|
576
|
-
name?: {
|
|
577
|
-
first?: string | null | undefined;
|
|
578
|
-
last?: string | null | undefined;
|
|
579
|
-
nick?: string | null | undefined;
|
|
580
|
-
} | null | undefined;
|
|
581
|
-
avatar?: string | null | undefined;
|
|
582
|
-
password?: string | null | undefined;
|
|
583
|
-
email?: string | null | undefined;
|
|
584
|
-
sessionTokens?: ({
|
|
585
|
-
valid?: NativeDate | null | undefined;
|
|
586
|
-
token?: string | null | undefined;
|
|
587
|
-
} & {
|
|
588
|
-
_id: import("mongoose").Types.ObjectId;
|
|
589
|
-
})[] | null | undefined;
|
|
590
|
-
verificationTokens?: ({
|
|
591
|
-
token?: string | null | undefined;
|
|
592
|
-
until?: NativeDate | null | undefined;
|
|
593
|
-
} & {
|
|
594
|
-
_id: import("mongoose").Types.ObjectId;
|
|
595
|
-
})[] | null | undefined;
|
|
596
|
-
passwordRecoveryTokens?: ({
|
|
597
|
-
token?: string | null | undefined;
|
|
598
|
-
until?: NativeDate | null | undefined;
|
|
599
|
-
} & {
|
|
600
|
-
_id: import("mongoose").Types.ObjectId;
|
|
601
|
-
})[] | null | undefined;
|
|
602
|
-
permissions?: string[] | null | undefined;
|
|
603
|
-
roles?: string[] | null | undefined;
|
|
604
|
-
languages?: string[] | null | undefined;
|
|
605
|
-
} & {
|
|
606
|
-
_id: import("mongoose").Types.ObjectId;
|
|
607
|
-
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
608
|
-
isVerified: boolean;
|
|
609
|
-
locale: string;
|
|
610
|
-
createdAt?: NativeDate | null | undefined;
|
|
611
|
-
updatedAt?: NativeDate | null | undefined;
|
|
259
|
+
readonly sendVerificationEmail: (this: UserAuthInstance & {
|
|
612
260
|
name?: {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
nick?: string | null | undefined;
|
|
616
|
-
} | null | undefined;
|
|
617
|
-
avatar?: string | null | undefined;
|
|
618
|
-
password?: string | null | undefined;
|
|
619
|
-
email?: string | null | undefined;
|
|
620
|
-
sessionTokens?: ({
|
|
621
|
-
valid?: NativeDate | null | undefined;
|
|
622
|
-
token?: string | null | undefined;
|
|
623
|
-
} & {
|
|
624
|
-
_id: import("mongoose").Types.ObjectId;
|
|
625
|
-
})[] | null | undefined;
|
|
626
|
-
verificationTokens?: ({
|
|
627
|
-
token?: string | null | undefined;
|
|
628
|
-
until?: NativeDate | null | undefined;
|
|
629
|
-
} & {
|
|
630
|
-
_id: import("mongoose").Types.ObjectId;
|
|
631
|
-
})[] | null | undefined;
|
|
632
|
-
passwordRecoveryTokens?: ({
|
|
633
|
-
token?: string | null | undefined;
|
|
634
|
-
until?: NativeDate | null | undefined;
|
|
635
|
-
} & {
|
|
636
|
-
_id: import("mongoose").Types.ObjectId;
|
|
637
|
-
})[] | null | undefined;
|
|
638
|
-
permissions?: string[] | null | undefined;
|
|
639
|
-
roles?: string[] | null | undefined;
|
|
640
|
-
languages?: string[] | null | undefined;
|
|
641
|
-
} & {
|
|
642
|
-
_id: import("mongoose").Types.ObjectId;
|
|
643
|
-
} & Required<{
|
|
644
|
-
_id: import("mongoose").Types.ObjectId;
|
|
645
|
-
}> & {
|
|
646
|
-
__v: number;
|
|
647
|
-
} & {
|
|
648
|
-
id: string;
|
|
261
|
+
nick?: string | null;
|
|
262
|
+
} | null;
|
|
649
263
|
}, i18n: {
|
|
650
264
|
t: TFunction;
|
|
651
265
|
language: string;
|
|
@@ -653,91 +267,35 @@ declare class User extends BaseModel {
|
|
|
653
267
|
* Get public user data
|
|
654
268
|
* @returns {Object}
|
|
655
269
|
*/
|
|
656
|
-
readonly getPublic: (this:
|
|
657
|
-
isVerified: boolean;
|
|
658
|
-
locale: string;
|
|
659
|
-
createdAt?: NativeDate | null | undefined;
|
|
660
|
-
updatedAt?: NativeDate | null | undefined;
|
|
661
|
-
name?: {
|
|
662
|
-
first?: string | null | undefined;
|
|
663
|
-
last?: string | null | undefined;
|
|
664
|
-
nick?: string | null | undefined;
|
|
665
|
-
} | null | undefined;
|
|
666
|
-
avatar?: string | null | undefined;
|
|
667
|
-
password?: string | null | undefined;
|
|
668
|
-
email?: string | null | undefined;
|
|
669
|
-
sessionTokens?: ({
|
|
670
|
-
valid?: NativeDate | null | undefined;
|
|
671
|
-
token?: string | null | undefined;
|
|
672
|
-
} & {
|
|
673
|
-
_id: import("mongoose").Types.ObjectId;
|
|
674
|
-
})[] | null | undefined;
|
|
675
|
-
verificationTokens?: ({
|
|
676
|
-
token?: string | null | undefined;
|
|
677
|
-
until?: NativeDate | null | undefined;
|
|
678
|
-
} & {
|
|
679
|
-
_id: import("mongoose").Types.ObjectId;
|
|
680
|
-
})[] | null | undefined;
|
|
681
|
-
passwordRecoveryTokens?: ({
|
|
682
|
-
token?: string | null | undefined;
|
|
683
|
-
until?: NativeDate | null | undefined;
|
|
684
|
-
} & {
|
|
685
|
-
_id: import("mongoose").Types.ObjectId;
|
|
686
|
-
})[] | null | undefined;
|
|
687
|
-
permissions?: string[] | null | undefined;
|
|
688
|
-
roles?: string[] | null | undefined;
|
|
689
|
-
languages?: string[] | null | undefined;
|
|
690
|
-
} & {
|
|
691
|
-
_id: import("mongoose").Types.ObjectId;
|
|
692
|
-
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
693
|
-
isVerified: boolean;
|
|
694
|
-
locale: string;
|
|
695
|
-
createdAt?: NativeDate | null | undefined;
|
|
696
|
-
updatedAt?: NativeDate | null | undefined;
|
|
697
|
-
name?: {
|
|
698
|
-
first?: string | null | undefined;
|
|
699
|
-
last?: string | null | undefined;
|
|
700
|
-
nick?: string | null | undefined;
|
|
701
|
-
} | null | undefined;
|
|
702
|
-
avatar?: string | null | undefined;
|
|
703
|
-
password?: string | null | undefined;
|
|
704
|
-
email?: string | null | undefined;
|
|
705
|
-
sessionTokens?: ({
|
|
706
|
-
valid?: NativeDate | null | undefined;
|
|
707
|
-
token?: string | null | undefined;
|
|
708
|
-
} & {
|
|
709
|
-
_id: import("mongoose").Types.ObjectId;
|
|
710
|
-
})[] | null | undefined;
|
|
711
|
-
verificationTokens?: ({
|
|
712
|
-
token?: string | null | undefined;
|
|
713
|
-
until?: NativeDate | null | undefined;
|
|
714
|
-
} & {
|
|
715
|
-
_id: import("mongoose").Types.ObjectId;
|
|
716
|
-
})[] | null | undefined;
|
|
717
|
-
passwordRecoveryTokens?: ({
|
|
718
|
-
token?: string | null | undefined;
|
|
719
|
-
until?: NativeDate | null | undefined;
|
|
720
|
-
} & {
|
|
721
|
-
_id: import("mongoose").Types.ObjectId;
|
|
722
|
-
})[] | null | undefined;
|
|
723
|
-
permissions?: string[] | null | undefined;
|
|
724
|
-
roles?: string[] | null | undefined;
|
|
725
|
-
languages?: string[] | null | undefined;
|
|
726
|
-
} & {
|
|
727
|
-
_id: import("mongoose").Types.ObjectId;
|
|
728
|
-
} & Required<{
|
|
729
|
-
_id: import("mongoose").Types.ObjectId;
|
|
730
|
-
}> & {
|
|
731
|
-
__v: number;
|
|
732
|
-
} & {
|
|
733
|
-
id: string;
|
|
734
|
-
}) => {
|
|
270
|
+
readonly getPublic: (this: UserPublicDoc) => {
|
|
735
271
|
avatar: string | null | undefined;
|
|
736
|
-
name: {
|
|
272
|
+
name: import("../modules/BaseModel.ts").ApplyTsOverrides<{
|
|
737
273
|
first?: string | null | undefined;
|
|
738
274
|
last?: string | null | undefined;
|
|
739
275
|
nick?: string | null | undefined;
|
|
740
|
-
}
|
|
276
|
+
}, {
|
|
277
|
+
readonly first: {
|
|
278
|
+
readonly type: StringConstructor;
|
|
279
|
+
readonly maxlength: 255;
|
|
280
|
+
};
|
|
281
|
+
readonly last: {
|
|
282
|
+
readonly type: StringConstructor;
|
|
283
|
+
readonly maxlength: 255;
|
|
284
|
+
};
|
|
285
|
+
readonly nick: {
|
|
286
|
+
readonly minlength: 3;
|
|
287
|
+
readonly maxlength: 255;
|
|
288
|
+
readonly type: StringConstructor;
|
|
289
|
+
readonly index: {
|
|
290
|
+
readonly unique: true;
|
|
291
|
+
readonly partialFilterExpression: {
|
|
292
|
+
readonly 'name.nick': {
|
|
293
|
+
readonly $type: "string";
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
}> | null | undefined;
|
|
741
299
|
email: string | null | undefined;
|
|
742
300
|
id: string;
|
|
743
301
|
isVerified: boolean;
|
|
@@ -752,7 +310,7 @@ export declare const userHelpers: {
|
|
|
752
310
|
* @param {InstanceType<UserModelLite>} userMongoose
|
|
753
311
|
* @returns {Promise<{ token: string; until: number }>}
|
|
754
312
|
*/
|
|
755
|
-
generateUserVerificationToken: (userMongoose:
|
|
313
|
+
generateUserVerificationToken: (userMongoose: UserAuthInstance) => Promise<{
|
|
756
314
|
token: string;
|
|
757
315
|
until: number;
|
|
758
316
|
}>;
|
|
@@ -761,7 +319,7 @@ export declare const userHelpers: {
|
|
|
761
319
|
* @param {string}
|
|
762
320
|
* @returns {Promise<InstanceType<UserModelLite> | false>}
|
|
763
321
|
*/
|
|
764
|
-
generateUserPasswordRecoveryToken: (userMongoose:
|
|
322
|
+
generateUserPasswordRecoveryToken: (userMongoose: UserAuthInstance) => Promise<{
|
|
765
323
|
token: string;
|
|
766
324
|
until: number;
|
|
767
325
|
}>;
|