@aeriajs/builtins 0.0.277 → 0.0.278

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.
Files changed (53) hide show
  1. package/dist/authentication.js +6 -11
  2. package/dist/collections/file/description.js +10 -14
  3. package/dist/collections/file/download.js +21 -25
  4. package/dist/collections/file/index.js +15 -18
  5. package/dist/collections/file/insert.js +8 -12
  6. package/dist/collections/file/remove.js +7 -11
  7. package/dist/collections/file/removeAll.js +5 -9
  8. package/dist/collections/index.js +4 -20
  9. package/dist/collections/log/index.js +5 -8
  10. package/dist/collections/resourceUsage/index.js +2 -5
  11. package/dist/collections/user/activate.js +31 -35
  12. package/dist/collections/user/authenticate.js +29 -33
  13. package/dist/collections/user/createAccount.js +25 -29
  14. package/dist/collections/user/description.js +5 -8
  15. package/dist/collections/user/editProfile.js +12 -16
  16. package/dist/collections/user/getActivationLink.js +21 -26
  17. package/dist/collections/user/getCurrentUser.js +12 -16
  18. package/dist/collections/user/getInfo.js +22 -26
  19. package/dist/collections/user/getRedefinePasswordLink.js +15 -19
  20. package/dist/collections/user/index.d.ts +10 -10
  21. package/dist/collections/user/index.js +39 -42
  22. package/dist/collections/user/insert.js +16 -20
  23. package/dist/collections/user/redefinePassword.js +31 -35
  24. package/dist/functions/describe.js +21 -25
  25. package/dist/functions/index.js +1 -17
  26. package/dist/index.d.ts +15 -15
  27. package/dist/index.js +11 -29
  28. package/package.json +11 -17
  29. package/dist/authentication.mjs +0 -58
  30. package/dist/collections/file/description.mjs +0 -75
  31. package/dist/collections/file/download.mjs +0 -115
  32. package/dist/collections/file/index.mjs +0 -59
  33. package/dist/collections/file/insert.mjs +0 -44
  34. package/dist/collections/file/remove.mjs +0 -21
  35. package/dist/collections/file/removeAll.mjs +0 -22
  36. package/dist/collections/index.mjs +0 -5
  37. package/dist/collections/log/index.mjs +0 -55
  38. package/dist/collections/resourceUsage/index.mjs +0 -39
  39. package/dist/collections/user/activate.mjs +0 -119
  40. package/dist/collections/user/authenticate.mjs +0 -165
  41. package/dist/collections/user/createAccount.mjs +0 -93
  42. package/dist/collections/user/description.mjs +0 -149
  43. package/dist/collections/user/editProfile.mjs +0 -52
  44. package/dist/collections/user/getActivationLink.mjs +0 -88
  45. package/dist/collections/user/getCurrentUser.mjs +0 -57
  46. package/dist/collections/user/getInfo.mjs +0 -85
  47. package/dist/collections/user/getRedefinePasswordLink.mjs +0 -63
  48. package/dist/collections/user/index.mjs +0 -71
  49. package/dist/collections/user/insert.mjs +0 -70
  50. package/dist/collections/user/redefinePassword.mjs +0 -110
  51. package/dist/functions/describe.mjs +0 -95
  52. package/dist/functions/index.mjs +0 -2
  53. package/dist/index.mjs +0 -21
@@ -1,47 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAccount = exports.createAccountContract = exports.CreateAccountError = void 0;
4
- const types_1 = require("@aeriajs/types");
5
- const validation_1 = require("@aeriajs/validation");
6
- const bcrypt = require("bcryptjs");
7
- const core_1 = require("@aeriajs/core");
8
- const description_js_1 = require("./description.js");
9
- exports.CreateAccountError = {
1
+ import { defineContract, HTTPStatus, ACError, functionSchemas, endpointErrorSchema, resultSchema } from '@aeriajs/types';
2
+ import { validate } from '@aeriajs/validation';
3
+ import * as bcrypt from 'bcryptjs';
4
+ import { insert as originalInsert } from '@aeriajs/core';
5
+ import { description } from './description.js';
6
+ export const CreateAccountError = {
10
7
  SignupDisallowed: 'SIGNUP_DISALLOWED',
11
8
  };
12
- exports.createAccountContract = (0, types_1.defineContract)({
9
+ export const createAccountContract = defineContract({
13
10
  payload: {
14
11
  type: 'object',
15
12
  required: [],
16
13
  additionalProperties: true,
17
- properties: description_js_1.description.properties,
14
+ properties: description.properties,
18
15
  },
19
16
  response: [
20
- types_1.functionSchemas.insertError(),
21
- (0, types_1.endpointErrorSchema)({
17
+ functionSchemas.insertError(),
18
+ endpointErrorSchema({
22
19
  httpStatus: [
23
- types_1.HTTPStatus.Forbidden,
24
- types_1.HTTPStatus.UnprocessableContent,
20
+ HTTPStatus.Forbidden,
21
+ HTTPStatus.UnprocessableContent,
25
22
  ],
26
23
  code: [
27
- types_1.ACError.MalformedInput,
28
- types_1.ACError.OwnershipError,
29
- exports.CreateAccountError.SignupDisallowed,
24
+ ACError.MalformedInput,
25
+ ACError.OwnershipError,
26
+ CreateAccountError.SignupDisallowed,
30
27
  ],
31
28
  }),
32
- (0, types_1.resultSchema)({
29
+ resultSchema({
33
30
  $ref: 'user',
34
31
  }),
35
32
  ],
36
33
  });
37
- const createAccount = async (payload, context) => {
34
+ export const createAccount = async (payload, context) => {
38
35
  const userCandidate = Object.assign({}, payload);
39
36
  if (!context.config.security.allowSignup) {
40
- return context.error(types_1.HTTPStatus.Forbidden, {
41
- code: exports.CreateAccountError.SignupDisallowed,
37
+ return context.error(HTTPStatus.Forbidden, {
38
+ code: CreateAccountError.SignupDisallowed,
42
39
  });
43
40
  }
44
- const { error, result: user } = (0, validation_1.validate)(userCandidate, {
41
+ const { error, result: user } = validate(userCandidate, {
45
42
  type: 'object',
46
43
  required: [
47
44
  'name',
@@ -60,8 +57,8 @@ const createAccount = async (payload, context) => {
60
57
  },
61
58
  });
62
59
  if (error) {
63
- return context.error(types_1.HTTPStatus.UnprocessableContent, {
64
- code: types_1.ACError.MalformedInput,
60
+ return context.error(HTTPStatus.UnprocessableContent, {
61
+ code: ACError.MalformedInput,
65
62
  details: error,
66
63
  });
67
64
  }
@@ -76,8 +73,8 @@ const createAccount = async (payload, context) => {
76
73
  email: user.email,
77
74
  });
78
75
  if (userWithExistingEmail) {
79
- return context.error(types_1.HTTPStatus.Forbidden, {
80
- code: types_1.ACError.OwnershipError,
76
+ return context.error(HTTPStatus.Forbidden, {
77
+ code: ACError.OwnershipError,
81
78
  });
82
79
  }
83
80
  if (!context.token.authenticated) {
@@ -85,7 +82,7 @@ const createAccount = async (payload, context) => {
85
82
  self_registered: true,
86
83
  });
87
84
  }
88
- return (0, core_1.insert)({
85
+ return originalInsert({
89
86
  what: {
90
87
  ...user,
91
88
  ...defaults,
@@ -93,4 +90,3 @@ const createAccount = async (payload, context) => {
93
90
  },
94
91
  }, context);
95
92
  };
96
- exports.createAccount = createAccount;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.description = void 0;
4
- const core_1 = require("@aeriajs/core");
5
- const description_js_1 = require("../file/description.js");
1
+ import { defineDescription, ObjectId } from '@aeriajs/core';
2
+ import { getFileLink } from '../file/description.js';
6
3
  /**
7
4
  * This description complies with JWT claims specified in RFC-7519.
8
5
  * Reference: https://www.iana.org/assignments/jwt/jwt.xhtml#claims
9
6
  */
10
- exports.description = (0, core_1.defineDescription)({
7
+ export const description = defineDescription({
11
8
  $id: 'user',
12
9
  icon: 'users',
13
10
  required: [
@@ -78,8 +75,8 @@ exports.description = (0, core_1.defineDescription)({
78
75
  picture: {
79
76
  type: 'getter',
80
77
  getter: (doc) => {
81
- if ('picture_file' in doc && doc.picture_file && typeof doc.picture_file === 'object' && '_id' in doc.picture_file && doc.picture_file._id instanceof core_1.ObjectId) {
82
- return (0, description_js_1.getFileLink)(doc.picture_file._id);
78
+ if ('picture_file' in doc && doc.picture_file && typeof doc.picture_file === 'object' && '_id' in doc.picture_file && doc.picture_file._id instanceof ObjectId) {
79
+ return getFileLink(doc.picture_file._id);
83
80
  }
84
81
  },
85
82
  },
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.editProfile = exports.editProfileContract = void 0;
4
- const types_1 = require("@aeriajs/types");
5
- const core_1 = require("@aeriajs/core");
6
- const bcrypt = require("bcryptjs");
7
- const description_js_1 = require("./description.js");
8
- exports.editProfileContract = (0, types_1.defineContract)({
1
+ import { HTTPStatus, ACError, defineContract, functionSchemas, resultSchema } from '@aeriajs/types';
2
+ import { insert as originalInsert } from '@aeriajs/core';
3
+ import * as bcrypt from 'bcryptjs';
4
+ import { description } from './description.js';
5
+ export const editProfileContract = defineContract({
9
6
  payload: {
10
7
  type: 'object',
11
8
  required: [],
12
9
  properties: {
13
- ...description_js_1.description.properties,
10
+ ...description.properties,
14
11
  picture_file: {
15
12
  type: 'string',
16
13
  format: 'objectid',
@@ -18,13 +15,13 @@ exports.editProfileContract = (0, types_1.defineContract)({
18
15
  },
19
16
  },
20
17
  response: [
21
- types_1.functionSchemas.insertError(),
22
- (0, types_1.resultSchema)({
18
+ functionSchemas.insertError(),
19
+ resultSchema({
23
20
  $ref: 'user',
24
21
  }),
25
22
  ],
26
23
  });
27
- const editProfile = async (payload, context) => {
24
+ export const editProfile = async (payload, context) => {
28
25
  const mutableProperties = context.config.security.mutableUserProperties;
29
26
  if (!context.token.sub) {
30
27
  throw new Error;
@@ -41,15 +38,14 @@ const editProfile = async (payload, context) => {
41
38
  const whatPropKeyArray = Object.keys(payload).filter((prop) => prop !== '_id');
42
39
  const hasImmutableProps = whatPropKeyArray.some((prop) => !(mutableProperties.includes(prop)));
43
40
  if (hasImmutableProps) {
44
- return context.error(types_1.HTTPStatus.Forbidden, {
45
- code: types_1.ACError.TargetImmutable,
41
+ return context.error(HTTPStatus.Forbidden, {
42
+ code: ACError.TargetImmutable,
46
43
  });
47
44
  }
48
- return (0, core_1.insert)({
45
+ return originalInsert({
49
46
  what: {
50
47
  ...payload,
51
48
  _id: context.token.sub,
52
49
  },
53
50
  }, context);
54
51
  };
55
- exports.editProfile = editProfile;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getActivationLink = exports.getActivationToken = exports.getActivationLinkContract = void 0;
4
- const core_1 = require("@aeriajs/core");
5
- const types_1 = require("@aeriajs/types");
6
- const activate_js_1 = require("./activate.js");
7
- exports.getActivationLinkContract = (0, types_1.defineContract)({
1
+ import { signToken } from '@aeriajs/core';
2
+ import { Result, HTTPStatus, defineContract, resultSchema, endpointErrorSchema, functionSchemas } from '@aeriajs/types';
3
+ import { ActivationError } from './activate.js';
4
+ export const getActivationLinkContract = defineContract({
8
5
  payload: {
9
6
  type: 'object',
10
7
  required: ['userId'],
@@ -19,18 +16,18 @@ exports.getActivationLinkContract = (0, types_1.defineContract)({
19
16
  },
20
17
  },
21
18
  response: [
22
- types_1.functionSchemas.getError(),
23
- (0, types_1.endpointErrorSchema)({
19
+ functionSchemas.getError(),
20
+ endpointErrorSchema({
24
21
  httpStatus: [
25
- types_1.HTTPStatus.BadRequest,
26
- types_1.HTTPStatus.Forbidden,
22
+ HTTPStatus.BadRequest,
23
+ HTTPStatus.Forbidden,
27
24
  ],
28
25
  code: [
29
- activate_js_1.ActivationError.InvalidLink,
30
- activate_js_1.ActivationError.AlreadyActiveUser,
26
+ ActivationError.InvalidLink,
27
+ ActivationError.AlreadyActiveUser,
31
28
  ],
32
29
  }),
33
- (0, types_1.resultSchema)({
30
+ resultSchema({
34
31
  type: 'object',
35
32
  properties: {
36
33
  url: {
@@ -40,25 +37,24 @@ exports.getActivationLinkContract = (0, types_1.defineContract)({
40
37
  }),
41
38
  ],
42
39
  });
43
- const getActivationToken = async (userId, context) => {
40
+ export const getActivationToken = async (userId, context) => {
44
41
  if (context.calledFunction === 'getActivationToken') {
45
42
  throw new Error('cannot be called externally');
46
43
  }
47
44
  if (!context.config.secret) {
48
45
  throw new Error('config.secret is not set');
49
46
  }
50
- const token = await (0, core_1.signToken)({
47
+ const token = await signToken({
51
48
  data: userId,
52
49
  }, context.config.secret, {
53
50
  expiresIn: context.config.security.linkTokenExpiration,
54
51
  });
55
52
  return token;
56
53
  };
57
- exports.getActivationToken = getActivationToken;
58
- const getActivationLink = async (payload, context) => {
54
+ export const getActivationLink = async (payload, context) => {
59
55
  if (!context.config.webPublicUrl) {
60
- return context.error(types_1.HTTPStatus.BadRequest, {
61
- code: activate_js_1.ActivationError.InvalidLink,
56
+ return context.error(HTTPStatus.BadRequest, {
57
+ code: ActivationError.InvalidLink,
62
58
  });
63
59
  }
64
60
  const { error, result: user } = await context.collections.user.functions.get({
@@ -68,14 +64,14 @@ const getActivationLink = async (payload, context) => {
68
64
  project: ['active'],
69
65
  });
70
66
  if (error) {
71
- return types_1.Result.error(error);
67
+ return Result.error(error);
72
68
  }
73
69
  if (user.active) {
74
- return context.error(types_1.HTTPStatus.Forbidden, {
75
- code: activate_js_1.ActivationError.AlreadyActiveUser,
70
+ return context.error(HTTPStatus.Forbidden, {
71
+ code: ActivationError.AlreadyActiveUser,
76
72
  });
77
73
  }
78
- const activationToken = await (0, exports.getActivationToken)(payload.userId.toString(), context);
74
+ const activationToken = await getActivationToken(payload.userId.toString(), context);
79
75
  const url = new URL(`${context.config.webPublicUrl}/user/activation`);
80
76
  url.searchParams.set('u', payload.userId.toString());
81
77
  url.searchParams.set('t', activationToken);
@@ -85,8 +81,7 @@ const getActivationLink = async (payload, context) => {
85
81
  if (payload.redirect) {
86
82
  url.searchParams.set('next', payload.redirect);
87
83
  }
88
- return types_1.Result.result({
84
+ return Result.result({
89
85
  url: url.toString(),
90
86
  });
91
87
  };
92
- exports.getActivationLink = getActivationLink;
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCurrentUser = exports.getCurrentUserContract = exports.ActivationError = void 0;
4
- const types_1 = require("@aeriajs/types");
5
- const core_1 = require("@aeriajs/core");
6
- const authentication_js_1 = require("../../authentication.js");
7
- exports.ActivationError = {
1
+ import { Result, defineContract, resultSchema } from '@aeriajs/types';
2
+ import { get } from '@aeriajs/core';
3
+ import { defaultSuccessfulAuthentication } from '../../authentication.js';
4
+ export const ActivationError = {
8
5
  UserNotFound: 'USER_NOT_FOUND',
9
6
  AlreadyActiveUser: 'ALREADY_ACTIVE_USER',
10
7
  InvalidLink: 'INVALID_LINK',
11
8
  };
12
- exports.getCurrentUserContract = (0, types_1.defineContract)({
9
+ export const getCurrentUserContract = defineContract({
13
10
  response: [
14
- (0, types_1.resultSchema)({
11
+ resultSchema({
15
12
  $ref: 'user',
16
13
  }),
17
- (0, types_1.resultSchema)({
14
+ resultSchema({
18
15
  type: 'object',
19
16
  properties: {
20
17
  _id: {
@@ -39,15 +36,15 @@ exports.getCurrentUserContract = (0, types_1.defineContract)({
39
36
  }),
40
37
  ],
41
38
  });
42
- const getCurrentUser = async (_payload, context) => {
39
+ export const getCurrentUser = async (_payload, context) => {
43
40
  if (!context.token.authenticated) {
44
41
  throw new Error();
45
42
  }
46
43
  if (!context.token.sub) {
47
- const { user } = await (0, authentication_js_1.defaultSuccessfulAuthentication)();
48
- return types_1.Result.result(user);
44
+ const { user } = await defaultSuccessfulAuthentication();
45
+ return Result.result(user);
49
46
  }
50
- const { error, result: user } = await (0, core_1.get)({
47
+ const { error, result: user } = await get({
51
48
  filters: {
52
49
  _id: context.token.sub,
53
50
  },
@@ -55,6 +52,5 @@ const getCurrentUser = async (_payload, context) => {
55
52
  if (error) {
56
53
  throw new Error();
57
54
  }
58
- return types_1.Result.result(user);
55
+ return Result.result(user);
59
56
  };
60
- exports.getCurrentUser = getCurrentUser;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInfo = exports.getInfoContract = exports.ActivationError = void 0;
4
- const types_1 = require("@aeriajs/types");
5
- const core_1 = require("@aeriajs/core");
6
- exports.ActivationError = {
1
+ import { Result, HTTPStatus, defineContract, resultSchema, endpointErrorSchema } from '@aeriajs/types';
2
+ import { decodeToken, ObjectId } from '@aeriajs/core';
3
+ export const ActivationError = {
7
4
  UserNotFound: 'USER_NOT_FOUND',
8
5
  AlreadyActiveUser: 'ALREADY_ACTIVE_USER',
9
6
  InvalidLink: 'INVALID_LINK',
10
7
  InvalidToken: 'INVALID_TOKEN',
11
8
  };
12
- exports.getInfoContract = (0, types_1.defineContract)({
9
+ export const getInfoContract = defineContract({
13
10
  payload: {
14
11
  type: 'object',
15
12
  required: [],
@@ -23,19 +20,19 @@ exports.getInfoContract = (0, types_1.defineContract)({
23
20
  },
24
21
  },
25
22
  response: [
26
- (0, types_1.endpointErrorSchema)({
23
+ endpointErrorSchema({
27
24
  httpStatus: [
28
- types_1.HTTPStatus.NotFound,
29
- types_1.HTTPStatus.Unauthorized,
30
- types_1.HTTPStatus.UnprocessableContent,
25
+ HTTPStatus.NotFound,
26
+ HTTPStatus.Unauthorized,
27
+ HTTPStatus.UnprocessableContent,
31
28
  ],
32
29
  code: [
33
- exports.ActivationError.InvalidLink,
34
- exports.ActivationError.InvalidToken,
35
- exports.ActivationError.UserNotFound,
30
+ ActivationError.InvalidLink,
31
+ ActivationError.InvalidToken,
32
+ ActivationError.UserNotFound,
36
33
  ],
37
34
  }),
38
- (0, types_1.resultSchema)({
35
+ resultSchema({
39
36
  type: 'object',
40
37
  required: [
41
38
  'name',
@@ -55,31 +52,30 @@ exports.getInfoContract = (0, types_1.defineContract)({
55
52
  }),
56
53
  ],
57
54
  });
58
- const getInfo = async (payload, context) => {
55
+ export const getInfo = async (payload, context) => {
59
56
  const { userId, token, } = payload;
60
57
  if (!userId || !token) {
61
- return context.error(types_1.HTTPStatus.NotFound, {
62
- code: exports.ActivationError.InvalidLink,
58
+ return context.error(HTTPStatus.NotFound, {
59
+ code: ActivationError.InvalidLink,
63
60
  });
64
61
  }
65
62
  const user = await context.collection.model.findOne({
66
- _id: new core_1.ObjectId(userId),
63
+ _id: new ObjectId(userId),
67
64
  });
68
65
  if (!user) {
69
- return context.error(types_1.HTTPStatus.NotFound, {
70
- code: exports.ActivationError.UserNotFound,
66
+ return context.error(HTTPStatus.NotFound, {
67
+ code: ActivationError.UserNotFound,
71
68
  });
72
69
  }
73
- const decoded = await (0, core_1.decodeToken)(token, context.config.secret).catch(console.trace);
70
+ const decoded = await decodeToken(token, context.config.secret).catch(console.trace);
74
71
  if (!decoded) {
75
- return context.error(types_1.HTTPStatus.Unauthorized, {
76
- code: exports.ActivationError.InvalidToken,
72
+ return context.error(HTTPStatus.Unauthorized, {
73
+ code: ActivationError.InvalidToken,
77
74
  });
78
75
  }
79
- return types_1.Result.result({
76
+ return Result.result({
80
77
  name: user.name,
81
78
  email: user.email,
82
79
  active: user.active,
83
80
  });
84
81
  };
85
- exports.getInfo = getInfo;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRedefinePasswordLink = exports.getRedefinePasswordLinkContract = void 0;
4
- const types_1 = require("@aeriajs/types");
5
- const redefinePassword_js_1 = require("./redefinePassword.js");
6
- const getActivationLink_js_1 = require("./getActivationLink.js");
7
- exports.getRedefinePasswordLinkContract = (0, types_1.defineContract)({
1
+ import { Result, HTTPStatus, resultSchema, functionSchemas, endpointErrorSchema, defineContract } from '@aeriajs/types';
2
+ import { RedefinePasswordError } from './redefinePassword.js';
3
+ import { getActivationToken } from './getActivationLink.js';
4
+ export const getRedefinePasswordLinkContract = defineContract({
8
5
  payload: {
9
6
  type: 'object',
10
7
  required: ['userId'],
@@ -19,12 +16,12 @@ exports.getRedefinePasswordLinkContract = (0, types_1.defineContract)({
19
16
  },
20
17
  },
21
18
  response: [
22
- types_1.functionSchemas.getError(),
23
- (0, types_1.endpointErrorSchema)({
24
- httpStatus: [types_1.HTTPStatus.Forbidden],
25
- code: [redefinePassword_js_1.RedefinePasswordError.UserNotActive],
19
+ functionSchemas.getError(),
20
+ endpointErrorSchema({
21
+ httpStatus: [HTTPStatus.Forbidden],
22
+ code: [RedefinePasswordError.UserNotActive],
26
23
  }),
27
- (0, types_1.resultSchema)({
24
+ resultSchema({
28
25
  type: 'object',
29
26
  properties: {
30
27
  url: {
@@ -34,7 +31,7 @@ exports.getRedefinePasswordLinkContract = (0, types_1.defineContract)({
34
31
  }),
35
32
  ],
36
33
  });
37
- const getRedefinePasswordLink = async (payload, context) => {
34
+ export const getRedefinePasswordLink = async (payload, context) => {
38
35
  if (!context.config.webPublicUrl) {
39
36
  throw new Error('config.webPublicUrl is not set');
40
37
  }
@@ -45,14 +42,14 @@ const getRedefinePasswordLink = async (payload, context) => {
45
42
  project: ['active'],
46
43
  });
47
44
  if (error) {
48
- return types_1.Result.error(error);
45
+ return Result.error(error);
49
46
  }
50
47
  if (!user.active) {
51
- return context.error(types_1.HTTPStatus.Forbidden, {
52
- code: redefinePassword_js_1.RedefinePasswordError.UserNotActive,
48
+ return context.error(HTTPStatus.Forbidden, {
49
+ code: RedefinePasswordError.UserNotActive,
53
50
  });
54
51
  }
55
- const redefineToken = await (0, getActivationLink_js_1.getActivationToken)(payload.userId.toString(), context);
52
+ const redefineToken = await getActivationToken(payload.userId.toString(), context);
56
53
  const url = new URL(`${context.config.webPublicUrl}/user/redefine-password`);
57
54
  url.searchParams.set('step', 'password'),
58
55
  url.searchParams.set('u', payload.userId.toString());
@@ -60,8 +57,7 @@ const getRedefinePasswordLink = async (payload, context) => {
60
57
  if (payload.redirect) {
61
58
  url.searchParams.set('next', payload.redirect);
62
59
  }
63
- return types_1.Result.result({
60
+ return Result.result({
64
61
  url: url.toString(),
65
62
  });
66
63
  };
67
- exports.getRedefinePasswordLink = getRedefinePasswordLink;
@@ -338,7 +338,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
338
338
  email: string;
339
339
  active: boolean;
340
340
  phone_number: string;
341
- picture_file: import("@aeriajs/core").ObjectId;
341
+ picture_file: import("bson").ObjectId;
342
342
  given_name: never;
343
343
  family_name: never;
344
344
  }, never>>, context: Omit<Context, "token">) => ({} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
@@ -1599,7 +1599,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
1599
1599
  readonly format: "objectid";
1600
1600
  };
1601
1601
  }, {}>> & {
1602
- userId: import("@aeriajs/core").ObjectId;
1602
+ userId: import("bson").ObjectId;
1603
1603
  }, never>;
1604
1604
  error: undefined;
1605
1605
  }, never>) | Promise<({} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
@@ -1696,7 +1696,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
1696
1696
  readonly format: "objectid";
1697
1697
  };
1698
1698
  }, {}>> & {
1699
- userId: import("@aeriajs/core").ObjectId;
1699
+ userId: import("bson").ObjectId;
1700
1700
  }, never>;
1701
1701
  error: undefined;
1702
1702
  }, never>)>;
@@ -2986,7 +2986,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
2986
2986
  readonly type: "string";
2987
2987
  };
2988
2988
  }, {}>> & {
2989
- userId: import("@aeriajs/core").ObjectId;
2989
+ userId: import("bson").ObjectId;
2990
2990
  redirect: string;
2991
2991
  }, never>, "userId"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
2992
2992
  readonly userId: {
@@ -2997,7 +2997,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
2997
2997
  readonly type: "string";
2998
2998
  };
2999
2999
  }, {}>> & {
3000
- userId: import("@aeriajs/core").ObjectId;
3000
+ userId: import("bson").ObjectId;
3001
3001
  redirect: string;
3002
3002
  }, never>>, context: Omit<Context, "token">) => ({} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
3003
3003
  readonly _tag: {
@@ -3337,7 +3337,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
3337
3337
  readonly type: "string";
3338
3338
  };
3339
3339
  }, {}>> & {
3340
- userId: import("@aeriajs/core").ObjectId;
3340
+ userId: import("bson").ObjectId;
3341
3341
  redirect: string;
3342
3342
  }, never>, "userId"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
3343
3343
  readonly userId: {
@@ -3348,7 +3348,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
3348
3348
  readonly type: "string";
3349
3349
  };
3350
3350
  }, {}>> & {
3351
- userId: import("@aeriajs/core").ObjectId;
3351
+ userId: import("bson").ObjectId;
3352
3352
  redirect: string;
3353
3353
  }, never>>, context: Omit<Context, "token">) => ({} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
3354
3354
  readonly _tag: {
@@ -3693,7 +3693,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
3693
3693
  }, {}>> & {
3694
3694
  password: string;
3695
3695
  token: string;
3696
- userId: import("@aeriajs/core").ObjectId;
3696
+ userId: import("bson").ObjectId;
3697
3697
  }, never>>, context: Omit<Context, "token">) => ({} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
3698
3698
  readonly _tag: {
3699
3699
  readonly const: "Error";
@@ -3857,7 +3857,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
3857
3857
  readonly format: "objectid";
3858
3858
  };
3859
3859
  }, {}>> & {
3860
- userId: import("@aeriajs/core").ObjectId;
3860
+ userId: import("bson").ObjectId;
3861
3861
  }, never>;
3862
3862
  error: undefined;
3863
3863
  }, never>) | Promise<({} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
@@ -4023,7 +4023,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
4023
4023
  readonly format: "objectid";
4024
4024
  };
4025
4025
  }, {}>> & {
4026
- userId: import("@aeriajs/core").ObjectId;
4026
+ userId: import("bson").ObjectId;
4027
4027
  }, never>;
4028
4028
  error: undefined;
4029
4029
  }, never>)>;