@aeriajs/builtins 0.0.231 → 0.0.233

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 (36) hide show
  1. package/dist/authentication.d.ts +4 -4
  2. package/dist/authentication.js +4 -5
  3. package/dist/authentication.mjs +4 -5
  4. package/dist/collections/file/download.d.ts +7 -8
  5. package/dist/collections/file/download.js +4 -5
  6. package/dist/collections/file/download.mjs +4 -5
  7. package/dist/collections/file/index.d.ts +18 -18
  8. package/dist/collections/file/remove.d.ts +12 -12
  9. package/dist/collections/file/removeAll.d.ts +2 -2
  10. package/dist/collections/user/activate.d.ts +17 -17
  11. package/dist/collections/user/activate.js +10 -11
  12. package/dist/collections/user/activate.mjs +10 -11
  13. package/dist/collections/user/authenticate.d.ts +7 -8
  14. package/dist/collections/user/createAccount.d.ts +10 -10
  15. package/dist/collections/user/createAccount.js +4 -5
  16. package/dist/collections/user/createAccount.mjs +4 -5
  17. package/dist/collections/user/description.d.ts +1 -0
  18. package/dist/collections/user/description.js +1 -0
  19. package/dist/collections/user/description.mjs +2 -1
  20. package/dist/collections/user/editProfile.d.ts +4 -3
  21. package/dist/collections/user/getActivationLink.d.ts +13 -14
  22. package/dist/collections/user/getCurrentUser.d.ts +6 -5
  23. package/dist/collections/user/getCurrentUser.js +5 -6
  24. package/dist/collections/user/getCurrentUser.mjs +5 -6
  25. package/dist/collections/user/getInfo.d.ts +13 -13
  26. package/dist/collections/user/getInfo.js +9 -10
  27. package/dist/collections/user/getInfo.mjs +9 -10
  28. package/dist/collections/user/getRedefinePasswordLink.d.ts +11 -12
  29. package/dist/collections/user/index.d.ts +85 -78
  30. package/dist/collections/user/insert.d.ts +8 -9
  31. package/dist/collections/user/redefinePassword.d.ts +17 -17
  32. package/dist/collections/user/redefinePassword.js +10 -11
  33. package/dist/collections/user/redefinePassword.mjs +10 -11
  34. package/dist/functions/describe.d.ts +9 -9
  35. package/dist/index.d.ts +103 -96
  36. package/package.json +15 -15
@@ -6,10 +6,10 @@ export type SuccessfulAuthentication = {
6
6
  user: TokenableUser;
7
7
  token: TokenRecipient;
8
8
  };
9
- export declare enum AuthenticationError {
10
- InvalidCredentials = "INVALID_CREDENTIALS",
11
- InactiveUser = "INACTIVE_USER"
12
- }
9
+ export declare const AuthenticationError: {
10
+ readonly InvalidCredentials: "INVALID_CREDENTIALS";
11
+ readonly InactiveUser: "INACTIVE_USER";
12
+ };
13
13
  export declare const successfulAuthentication: <TUser extends TokenableUser>(user: TUser, context: RouteContext) => Promise<SuccessfulAuthentication>;
14
14
  export declare const defaultSuccessfulAuthentication: () => Promise<{
15
15
  user: {
@@ -2,11 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultSuccessfulAuthentication = exports.successfulAuthentication = exports.AuthenticationError = void 0;
4
4
  const core_1 = require("@aeriajs/core");
5
- var AuthenticationError;
6
- (function (AuthenticationError) {
7
- AuthenticationError["InvalidCredentials"] = "INVALID_CREDENTIALS";
8
- AuthenticationError["InactiveUser"] = "INACTIVE_USER";
9
- })(AuthenticationError || (exports.AuthenticationError = AuthenticationError = {}));
5
+ exports.AuthenticationError = {
6
+ InvalidCredentials: 'INVALID_CREDENTIALS',
7
+ InactiveUser: 'INACTIVE_USER',
8
+ };
10
9
  const successfulAuthentication = async (user, context) => {
11
10
  const tokenContent = {
12
11
  sub: user._id,
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  import { signToken } from "@aeriajs/core";
3
- export var AuthenticationError = /* @__PURE__ */ ((AuthenticationError2) => {
4
- AuthenticationError2["InvalidCredentials"] = "INVALID_CREDENTIALS";
5
- AuthenticationError2["InactiveUser"] = "INACTIVE_USER";
6
- return AuthenticationError2;
7
- })(AuthenticationError || {});
3
+ export const AuthenticationError = {
4
+ InvalidCredentials: "INVALID_CREDENTIALS",
5
+ InactiveUser: "INACTIVE_USER"
6
+ };
8
7
  export const successfulAuthentication = async (user, context) => {
9
8
  const tokenContent = {
10
9
  sub: user._id,
@@ -1,20 +1,19 @@
1
1
  import type { Context } from '@aeriajs/types';
2
2
  import type { description } from './description.js';
3
- import { HTTPStatus, ACError } from '@aeriajs/types';
4
3
  import * as fs from 'node:fs';
5
- export declare enum DownloadError {
6
- RangeNotSatisfiable = "RANGE_NOT_SATISFIABLE"
7
- }
4
+ export declare const DownloadError: {
5
+ readonly RangeNotSatisfiable: "RANGE_NOT_SATISFIABLE";
6
+ };
8
7
  export declare const download: (payload: {
9
8
  fileId: string;
10
9
  options: readonly ("picture" | "download")[];
11
10
  noHeaders?: boolean;
12
11
  }, context: Context<typeof description>) => Promise<import("@aeriajs/types").Result.Error<{
13
- readonly code: ACError.ResourceNotFound;
12
+ readonly code: "RESOURCE_NOT_FOUND";
14
13
  } & {
15
- httpStatus: HTTPStatus.NotFound;
14
+ httpStatus: 404;
16
15
  }> | import("@aeriajs/types").Result.Error<{
17
- readonly code: DownloadError;
16
+ readonly code: "RANGE_NOT_SATISFIABLE";
18
17
  } & {
19
- httpStatus: HTTPStatus.RangeNotSatisfiable;
18
+ httpStatus: 416;
20
19
  }> | fs.ReadStream>;
@@ -4,10 +4,9 @@ exports.download = exports.DownloadError = void 0;
4
4
  const types_1 = require("@aeriajs/types");
5
5
  const core_1 = require("@aeriajs/core");
6
6
  const fs = require("node:fs");
7
- var DownloadError;
8
- (function (DownloadError) {
9
- DownloadError["RangeNotSatisfiable"] = "RANGE_NOT_SATISFIABLE";
10
- })(DownloadError || (exports.DownloadError = DownloadError = {}));
7
+ exports.DownloadError = {
8
+ RangeNotSatisfiable: 'RANGE_NOT_SATISFIABLE',
9
+ };
11
10
  const download = async (payload, context) => {
12
11
  const { fileId, options = [] } = payload;
13
12
  const file = await context.collection.model.findOne({
@@ -54,7 +53,7 @@ const download = async (payload, context) => {
54
53
  'content-range': `bytes */${stat.size}`,
55
54
  });
56
55
  return context.error(types_1.HTTPStatus.RangeNotSatisfiable, {
57
- code: DownloadError.RangeNotSatisfiable,
56
+ code: exports.DownloadError.RangeNotSatisfiable,
58
57
  });
59
58
  }
60
59
  const chunkSize = (end - start) + 1;
@@ -2,10 +2,9 @@
2
2
  import { HTTPStatus, ACError } from "@aeriajs/types";
3
3
  import { ObjectId } from "@aeriajs/core";
4
4
  import * as fs from "node:fs";
5
- export var DownloadError = /* @__PURE__ */ ((DownloadError2) => {
6
- DownloadError2["RangeNotSatisfiable"] = "RANGE_NOT_SATISFIABLE";
7
- return DownloadError2;
8
- })(DownloadError || {});
5
+ export const DownloadError = {
6
+ RangeNotSatisfiable: "RANGE_NOT_SATISFIABLE"
7
+ };
9
8
  export const download = async (payload, context) => {
10
9
  const { fileId, options = [] } = payload;
11
10
  const file = await context.collection.model.findOne({
@@ -49,7 +48,7 @@ export const download = async (payload, context) => {
49
48
  "content-range": `bytes */${stat.size}`
50
49
  });
51
50
  return context.error(HTTPStatus.RangeNotSatisfiable, {
52
- code: "RANGE_NOT_SATISFIABLE" /* RangeNotSatisfiable */
51
+ code: DownloadError.RangeNotSatisfiable
53
52
  });
54
53
  }
55
54
  const chunkSize = end - start + 1;
@@ -230,34 +230,34 @@ export declare const file: Omit<import("@aeriajs/types").Collection<never>, "fun
230
230
  options: readonly ("picture" | "download")[];
231
231
  noHeaders?: boolean;
232
232
  }, context: import("@aeriajs/types").Context<typeof description>) => Promise<import("@aeriajs/types").Result.Error<{
233
- readonly code: import("@aeriajs/types").ACError.ResourceNotFound;
233
+ readonly code: "RESOURCE_NOT_FOUND";
234
234
  } & {
235
- httpStatus: import("@aeriajs/types").HTTPStatus.NotFound;
235
+ httpStatus: 404;
236
236
  }> | import("@aeriajs/types").Result.Error<{
237
- readonly code: import("./download.js").DownloadError;
237
+ readonly code: "RANGE_NOT_SATISFIABLE";
238
238
  } & {
239
- httpStatus: import("@aeriajs/types").HTTPStatus.RangeNotSatisfiable;
239
+ httpStatus: 416;
240
240
  }> | import("fs").ReadStream>;
241
241
  remove: (payload: import("@aeriajs/types").RemovePayload<import("@aeriajs/types").SchemaWithId<typeof description>>, context: import("@aeriajs/types").Context<typeof description>) => Promise<{
242
242
  readonly _tag: "Result";
243
243
  readonly error: undefined;
244
244
  readonly result: import("mongodb").WithId<Omit<import("@aeriajs/types").PackReferences<import("@aeriajs/types").SchemaWithId<import("@aeriajs/types").Description>>, "_id">> | null;
245
245
  } | import("@aeriajs/types").Result.Error<{
246
- readonly code: import("@aeriajs/types").ACError.ResourceNotFound;
246
+ readonly code: "RESOURCE_NOT_FOUND";
247
247
  } & {
248
- httpStatus: import("@aeriajs/types").HTTPStatus.NotFound;
248
+ httpStatus: 404;
249
249
  }> | import("@aeriajs/types").Result.Error<{
250
- readonly code: import("@aeriajs/types").ACError.OwnershipError;
250
+ readonly code: "OWNERSHIP_ERROR";
251
251
  } & {
252
- httpStatus: import("@aeriajs/types").HTTPStatus.Forbidden;
252
+ httpStatus: 403;
253
253
  }> | {
254
254
  readonly _tag: "Error";
255
255
  readonly error: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
256
256
  readonly httpStatus: {
257
- readonly enum: [import("@aeriajs/types").HTTPStatus.Forbidden, import("@aeriajs/types").HTTPStatus.NotFound, import("@aeriajs/types").HTTPStatus.BadRequest];
257
+ readonly enum: [403, 404, 400];
258
258
  };
259
259
  readonly code: {
260
- readonly enum: [import("@aeriajs/types").ACError.ResourceNotFound, import("@aeriajs/types").ACError.OwnershipError, import("@aeriajs/types").ACError.InsecureOperator, import("@aeriajs/types").ACError.MalformedInput];
260
+ readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
261
261
  };
262
262
  readonly message: {
263
263
  readonly type: "string";
@@ -267,16 +267,16 @@ export declare const file: Omit<import("@aeriajs/types").Collection<never>, "fun
267
267
  readonly additionalProperties: true;
268
268
  };
269
269
  }>> & {
270
- code: import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput;
271
- httpStatus: import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound;
270
+ code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
271
+ httpStatus: 403 | 400 | 404;
272
272
  message: string;
273
273
  details: any;
274
274
  }, never>, "code" | "httpStatus"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
275
275
  readonly httpStatus: {
276
- readonly enum: [import("@aeriajs/types").HTTPStatus.Forbidden, import("@aeriajs/types").HTTPStatus.NotFound, import("@aeriajs/types").HTTPStatus.BadRequest];
276
+ readonly enum: [403, 404, 400];
277
277
  };
278
278
  readonly code: {
279
- readonly enum: [import("@aeriajs/types").ACError.ResourceNotFound, import("@aeriajs/types").ACError.OwnershipError, import("@aeriajs/types").ACError.InsecureOperator, import("@aeriajs/types").ACError.MalformedInput];
279
+ readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
280
280
  };
281
281
  readonly message: {
282
282
  readonly type: "string";
@@ -286,8 +286,8 @@ export declare const file: Omit<import("@aeriajs/types").Collection<never>, "fun
286
286
  readonly additionalProperties: true;
287
287
  };
288
288
  }>> & {
289
- code: import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput;
290
- httpStatus: import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound;
289
+ code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
290
+ httpStatus: 403 | 400 | 404;
291
291
  message: string;
292
292
  details: any;
293
293
  }, never>>;
@@ -298,9 +298,9 @@ export declare const file: Omit<import("@aeriajs/types").Collection<never>, "fun
298
298
  readonly error: undefined;
299
299
  readonly result: import("mongodb").DeleteResult;
300
300
  } | import("@aeriajs/types").Result.Error<{
301
- readonly code: import("@aeriajs/types").ACError.OwnershipError;
301
+ readonly code: "OWNERSHIP_ERROR";
302
302
  } & {
303
- httpStatus: import("@aeriajs/types").HTTPStatus.Forbidden;
303
+ httpStatus: 403;
304
304
  }>>;
305
305
  };
306
306
  contracts: {
@@ -6,21 +6,21 @@ export declare const remove: (payload: RemovePayload<SchemaWithId<typeof descrip
6
6
  readonly error: undefined;
7
7
  readonly result: import("mongodb").WithId<Omit<import("@aeriajs/types").PackReferences<SchemaWithId<import("@aeriajs/types").Description>>, "_id">> | null;
8
8
  } | Result.Error<{
9
- readonly code: import("@aeriajs/types").ACError.ResourceNotFound;
9
+ readonly code: "RESOURCE_NOT_FOUND";
10
10
  } & {
11
- httpStatus: import("@aeriajs/types").HTTPStatus.NotFound;
11
+ httpStatus: 404;
12
12
  }> | Result.Error<{
13
- readonly code: import("@aeriajs/types").ACError.OwnershipError;
13
+ readonly code: "OWNERSHIP_ERROR";
14
14
  } & {
15
- httpStatus: import("@aeriajs/types").HTTPStatus.Forbidden;
15
+ httpStatus: 403;
16
16
  }> | {
17
17
  readonly _tag: "Error";
18
18
  readonly error: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
19
19
  readonly httpStatus: {
20
- readonly enum: [import("@aeriajs/types").HTTPStatus.Forbidden, import("@aeriajs/types").HTTPStatus.NotFound, import("@aeriajs/types").HTTPStatus.BadRequest];
20
+ readonly enum: [403, 404, 400];
21
21
  };
22
22
  readonly code: {
23
- readonly enum: [import("@aeriajs/types").ACError.ResourceNotFound, import("@aeriajs/types").ACError.OwnershipError, import("@aeriajs/types").ACError.InsecureOperator, import("@aeriajs/types").ACError.MalformedInput];
23
+ readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
24
24
  };
25
25
  readonly message: {
26
26
  readonly type: "string";
@@ -30,16 +30,16 @@ export declare const remove: (payload: RemovePayload<SchemaWithId<typeof descrip
30
30
  readonly additionalProperties: true;
31
31
  };
32
32
  }>> & {
33
- code: import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput;
34
- httpStatus: import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound;
33
+ code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
34
+ httpStatus: 403 | 400 | 404;
35
35
  message: string;
36
36
  details: any;
37
37
  }, never>, "code" | "httpStatus"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
38
38
  readonly httpStatus: {
39
- readonly enum: [import("@aeriajs/types").HTTPStatus.Forbidden, import("@aeriajs/types").HTTPStatus.NotFound, import("@aeriajs/types").HTTPStatus.BadRequest];
39
+ readonly enum: [403, 404, 400];
40
40
  };
41
41
  readonly code: {
42
- readonly enum: [import("@aeriajs/types").ACError.ResourceNotFound, import("@aeriajs/types").ACError.OwnershipError, import("@aeriajs/types").ACError.InsecureOperator, import("@aeriajs/types").ACError.MalformedInput];
42
+ readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
43
43
  };
44
44
  readonly message: {
45
45
  readonly type: "string";
@@ -49,8 +49,8 @@ export declare const remove: (payload: RemovePayload<SchemaWithId<typeof descrip
49
49
  readonly additionalProperties: true;
50
50
  };
51
51
  }>> & {
52
- code: import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput;
53
- httpStatus: import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound;
52
+ code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
53
+ httpStatus: 403 | 400 | 404;
54
54
  message: string;
55
55
  details: any;
56
56
  }, never>>;
@@ -5,7 +5,7 @@ export declare const removeAll: (payload: RemoveAllPayload<SchemaWithId<typeof d
5
5
  readonly error: undefined;
6
6
  readonly result: import("mongodb").DeleteResult;
7
7
  } | import("@aeriajs/types").Result.Error<{
8
- readonly code: import("@aeriajs/types").ACError.OwnershipError;
8
+ readonly code: "OWNERSHIP_ERROR";
9
9
  } & {
10
- httpStatus: import("@aeriajs/types").HTTPStatus.Forbidden;
10
+ httpStatus: 403;
11
11
  }>>;
@@ -1,37 +1,37 @@
1
1
  import type { Context } from '@aeriajs/types';
2
2
  import type { description } from './description.js';
3
3
  import { ObjectId } from '@aeriajs/core';
4
- import { Result, ACError, HTTPStatus } from '@aeriajs/types';
5
- export declare enum ActivationError {
6
- UserNotFound = "USER_NOT_FOUND",
7
- AlreadyActiveUser = "ALREADY_ACTIVE_USER",
8
- InvalidLink = "INVALID_LINK",
9
- InvalidToken = "INVALID_TOKEN"
10
- }
4
+ import { Result } from '@aeriajs/types';
5
+ export declare const ActivationError: {
6
+ readonly UserNotFound: "USER_NOT_FOUND";
7
+ readonly AlreadyActiveUser: "ALREADY_ACTIVE_USER";
8
+ readonly InvalidLink: "INVALID_LINK";
9
+ readonly InvalidToken: "INVALID_TOKEN";
10
+ };
11
11
  export declare const activate: (payload: {
12
12
  password?: string;
13
13
  userId?: string;
14
14
  token?: string;
15
15
  }, context: Context<typeof description>) => Promise<Result.Error<{
16
- readonly code: ActivationError.InvalidLink;
16
+ readonly code: "INVALID_LINK";
17
17
  } & {
18
- httpStatus: HTTPStatus.NotFound;
18
+ httpStatus: 404;
19
19
  }> | Result.Error<{
20
- readonly code: ActivationError.UserNotFound;
20
+ readonly code: "USER_NOT_FOUND";
21
21
  } & {
22
- httpStatus: HTTPStatus.NotFound;
22
+ httpStatus: 404;
23
23
  }> | Result.Error<{
24
- readonly code: ActivationError.AlreadyActiveUser;
24
+ readonly code: "ALREADY_ACTIVE_USER";
25
25
  } & {
26
- httpStatus: HTTPStatus.Forbidden;
26
+ httpStatus: 403;
27
27
  }> | Result.Error<{
28
- readonly code: ActivationError.InvalidToken;
28
+ readonly code: "INVALID_TOKEN";
29
29
  } & {
30
- httpStatus: HTTPStatus.Unauthorized;
30
+ httpStatus: 401;
31
31
  }> | Result.Error<{
32
- readonly code: ACError.MalformedInput;
32
+ readonly code: "MALFORMED_INPUT";
33
33
  } & {
34
- httpStatus: HTTPStatus.UnprocessableContent;
34
+ httpStatus: 422;
35
35
  }> | {
36
36
  readonly _tag: "Result";
37
37
  readonly error: undefined;
@@ -4,13 +4,12 @@ exports.activate = exports.ActivationError = void 0;
4
4
  const core_1 = require("@aeriajs/core");
5
5
  const types_1 = require("@aeriajs/types");
6
6
  const bcrypt = require("bcrypt");
7
- var ActivationError;
8
- (function (ActivationError) {
9
- ActivationError["UserNotFound"] = "USER_NOT_FOUND";
10
- ActivationError["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
11
- ActivationError["InvalidLink"] = "INVALID_LINK";
12
- ActivationError["InvalidToken"] = "INVALID_TOKEN";
13
- })(ActivationError || (exports.ActivationError = ActivationError = {}));
7
+ exports.ActivationError = {
8
+ UserNotFound: 'USER_NOT_FOUND',
9
+ AlreadyActiveUser: 'ALREADY_ACTIVE_USER',
10
+ InvalidLink: 'INVALID_LINK',
11
+ InvalidToken: 'INVALID_TOKEN',
12
+ };
14
13
  const activate = async (payload, context) => {
15
14
  const { userId, token, password, } = payload;
16
15
  if (!context.config.secret) {
@@ -18,7 +17,7 @@ const activate = async (payload, context) => {
18
17
  }
19
18
  if (!userId || !token) {
20
19
  return context.error(types_1.HTTPStatus.NotFound, {
21
- code: ActivationError.InvalidLink,
20
+ code: exports.ActivationError.InvalidLink,
22
21
  });
23
22
  }
24
23
  const user = await context.collection.model.findOne({
@@ -31,18 +30,18 @@ const activate = async (payload, context) => {
31
30
  });
32
31
  if (!user) {
33
32
  return context.error(types_1.HTTPStatus.NotFound, {
34
- code: ActivationError.UserNotFound,
33
+ code: exports.ActivationError.UserNotFound,
35
34
  });
36
35
  }
37
36
  if (user.active) {
38
37
  return context.error(types_1.HTTPStatus.Forbidden, {
39
- code: ActivationError.AlreadyActiveUser,
38
+ code: exports.ActivationError.AlreadyActiveUser,
40
39
  });
41
40
  }
42
41
  const decoded = await (0, core_1.decodeToken)(token, context.config.secret);
43
42
  if (!decoded) {
44
43
  return context.error(types_1.HTTPStatus.Unauthorized, {
45
- code: ActivationError.InvalidToken,
44
+ code: exports.ActivationError.InvalidToken,
46
45
  });
47
46
  }
48
47
  if (!user.password) {
@@ -2,13 +2,12 @@
2
2
  import { decodeToken, ObjectId } from "@aeriajs/core";
3
3
  import { Result, ACError, HTTPStatus } from "@aeriajs/types";
4
4
  import * as bcrypt from "bcrypt";
5
- export var ActivationError = /* @__PURE__ */ ((ActivationError2) => {
6
- ActivationError2["UserNotFound"] = "USER_NOT_FOUND";
7
- ActivationError2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
8
- ActivationError2["InvalidLink"] = "INVALID_LINK";
9
- ActivationError2["InvalidToken"] = "INVALID_TOKEN";
10
- return ActivationError2;
11
- })(ActivationError || {});
5
+ export const ActivationError = {
6
+ UserNotFound: "USER_NOT_FOUND",
7
+ AlreadyActiveUser: "ALREADY_ACTIVE_USER",
8
+ InvalidLink: "INVALID_LINK",
9
+ InvalidToken: "INVALID_TOKEN"
10
+ };
12
11
  export const activate = async (payload, context) => {
13
12
  const {
14
13
  userId,
@@ -20,7 +19,7 @@ export const activate = async (payload, context) => {
20
19
  }
21
20
  if (!userId || !token) {
22
21
  return context.error(HTTPStatus.NotFound, {
23
- code: "INVALID_LINK" /* InvalidLink */
22
+ code: ActivationError.InvalidLink
24
23
  });
25
24
  }
26
25
  const user = await context.collection.model.findOne({
@@ -33,18 +32,18 @@ export const activate = async (payload, context) => {
33
32
  });
34
33
  if (!user) {
35
34
  return context.error(HTTPStatus.NotFound, {
36
- code: "USER_NOT_FOUND" /* UserNotFound */
35
+ code: ActivationError.UserNotFound
37
36
  });
38
37
  }
39
38
  if (user.active) {
40
39
  return context.error(HTTPStatus.Forbidden, {
41
- code: "ALREADY_ACTIVE_USER" /* AlreadyActiveUser */
40
+ code: ActivationError.AlreadyActiveUser
42
41
  });
43
42
  }
44
43
  const decoded = await decodeToken(token, context.config.secret);
45
44
  if (!decoded) {
46
45
  return context.error(HTTPStatus.Unauthorized, {
47
- code: "INVALID_TOKEN" /* InvalidToken */
46
+ code: ActivationError.InvalidToken
48
47
  });
49
48
  }
50
49
  if (!user.password) {
@@ -1,7 +1,6 @@
1
1
  import type { Context, TokenRecipient } from '@aeriajs/types';
2
2
  import type { description } from './description.js';
3
- import { Result, HTTPStatus, ACError } from '@aeriajs/types';
4
- import { AuthenticationError } from '../../authentication.js';
3
+ import { Result } from '@aeriajs/types';
5
4
  type Props = {
6
5
  email: string;
7
6
  password: string;
@@ -10,9 +9,9 @@ type Props = {
10
9
  revalidate: true;
11
10
  };
12
11
  export declare const authenticate: (props: Props, context: Context<typeof description>) => Promise<Result.Error<{
13
- readonly code: ACError.AuthorizationError;
12
+ readonly code: "AUTHORIZATION_ERROR";
14
13
  } & {
15
- httpStatus: HTTPStatus.Unauthorized;
14
+ httpStatus: 401;
16
15
  }> | {
17
16
  readonly _tag: "Result";
18
17
  readonly error: undefined;
@@ -34,12 +33,12 @@ export declare const authenticate: (props: Props, context: Context<typeof descri
34
33
  readonly error: undefined;
35
34
  readonly result: import("../../authentication.js").SuccessfulAuthentication;
36
35
  } | Result.Error<{
37
- readonly code: AuthenticationError.InvalidCredentials;
36
+ readonly code: "INVALID_CREDENTIALS";
38
37
  } & {
39
- httpStatus: HTTPStatus.Unauthorized;
38
+ httpStatus: 401;
40
39
  }> | Result.Error<{
41
- readonly code: AuthenticationError.InactiveUser;
40
+ readonly code: "INACTIVE_USER";
42
41
  } & {
43
- httpStatus: HTTPStatus.Unauthorized;
42
+ httpStatus: 401;
44
43
  }>>;
45
44
  export {};
@@ -1,22 +1,21 @@
1
1
  import type { Context, SchemaWithId, PackReferences } from '@aeriajs/types';
2
2
  import type { description } from './description.js';
3
- import { HTTPStatus, ACError } from '@aeriajs/types';
4
- export declare enum CreateAccountError {
5
- SignupDisallowed = "SIGNUP_DISALLOWED"
6
- }
3
+ export declare const CreateAccountError: {
4
+ readonly SignupDisallowed: "SIGNUP_DISALLOWED";
5
+ };
7
6
  export declare const createAccount: (payload: Partial<PackReferences<SchemaWithId<typeof description>>> & Record<string, unknown>, context: Context<typeof description>) => Promise<import("@aeriajs/types").Result.Error<{
8
- readonly code: CreateAccountError;
7
+ readonly code: "SIGNUP_DISALLOWED";
9
8
  } & {
10
- httpStatus: HTTPStatus.Forbidden;
9
+ httpStatus: 403;
11
10
  }> | import("@aeriajs/types").Result.Error<{
12
- readonly code: ACError.MalformedInput;
11
+ readonly code: "MALFORMED_INPUT";
13
12
  readonly details: import("@aeriajs/types").PropertyValidationError | import("@aeriajs/types").ValidationError;
14
13
  } & {
15
- httpStatus: HTTPStatus.BadRequest;
14
+ httpStatus: 400;
16
15
  }> | import("@aeriajs/types").Result.Error<{
17
- readonly code: ACError.OwnershipError;
16
+ readonly code: "OWNERSHIP_ERROR";
18
17
  } & {
19
- httpStatus: HTTPStatus.Forbidden;
18
+ httpStatus: 403;
20
19
  }> | import("@aeriajs/types").InsertReturnType<SchemaWithId<{
21
20
  readonly $id: "user";
22
21
  readonly icon: "users";
@@ -85,6 +84,7 @@ export declare const createAccount: (payload: Partial<PackReferences<SchemaWithI
85
84
  readonly picture: "picture_file";
86
85
  readonly information: "email";
87
86
  readonly active: "active";
87
+ readonly translateBadge: true;
88
88
  };
89
89
  };
90
90
  readonly individualActions: {
@@ -5,15 +5,14 @@ const types_1 = require("@aeriajs/types");
5
5
  const validation_1 = require("@aeriajs/validation");
6
6
  const bcrypt = require("bcrypt");
7
7
  const core_1 = require("@aeriajs/core");
8
- var CreateAccountError;
9
- (function (CreateAccountError) {
10
- CreateAccountError["SignupDisallowed"] = "SIGNUP_DISALLOWED";
11
- })(CreateAccountError || (exports.CreateAccountError = CreateAccountError = {}));
8
+ exports.CreateAccountError = {
9
+ SignupDisallowed: 'SIGNUP_DISALLOWED',
10
+ };
12
11
  const createAccount = async (payload, context) => {
13
12
  const userCandidate = Object.assign({}, payload);
14
13
  if (!context.config.security.allowSignup) {
15
14
  return context.error(types_1.HTTPStatus.Forbidden, {
16
- code: CreateAccountError.SignupDisallowed,
15
+ code: exports.CreateAccountError.SignupDisallowed,
17
16
  });
18
17
  }
19
18
  const { error, result: user } = (0, validation_1.validate)(userCandidate, {
@@ -3,15 +3,14 @@ import { HTTPStatus, ACError } from "@aeriajs/types";
3
3
  import { validate } from "@aeriajs/validation";
4
4
  import * as bcrypt from "bcrypt";
5
5
  import { insert as originalInsert } from "@aeriajs/core";
6
- export var CreateAccountError = /* @__PURE__ */ ((CreateAccountError2) => {
7
- CreateAccountError2["SignupDisallowed"] = "SIGNUP_DISALLOWED";
8
- return CreateAccountError2;
9
- })(CreateAccountError || {});
6
+ export const CreateAccountError = {
7
+ SignupDisallowed: "SIGNUP_DISALLOWED"
8
+ };
10
9
  export const createAccount = async (payload, context) => {
11
10
  const userCandidate = Object.assign({}, payload);
12
11
  if (!context.config.security.allowSignup) {
13
12
  return context.error(HTTPStatus.Forbidden, {
14
- code: "SIGNUP_DISALLOWED" /* SignupDisallowed */
13
+ code: CreateAccountError.SignupDisallowed
15
14
  });
16
15
  }
17
16
  const { error, result: user } = validate(userCandidate, {
@@ -70,6 +70,7 @@ export declare const description: {
70
70
  readonly picture: "picture_file";
71
71
  readonly information: "email";
72
72
  readonly active: "active";
73
+ readonly translateBadge: true;
73
74
  };
74
75
  };
75
76
  readonly individualActions: {
@@ -101,6 +101,7 @@ exports.description = (0, core_1.defineDescription)({
101
101
  picture: 'picture_file',
102
102
  information: 'email',
103
103
  active: 'active',
104
+ translateBadge: true,
104
105
  },
105
106
  },
106
107
  individualActions: {
@@ -94,7 +94,8 @@ export const description = defineDescription({
94
94
  badge: "roles",
95
95
  picture: "picture_file",
96
96
  information: "email",
97
- active: "active"
97
+ active: "active",
98
+ translateBadge: true
98
99
  }
99
100
  },
100
101
  individualActions: {
@@ -1,5 +1,5 @@
1
1
  import type { description } from './description.js';
2
- import { HTTPStatus, ACError, type Context, type SchemaWithId, type PackReferences } from '@aeriajs/types';
2
+ import { type Context, type SchemaWithId, type PackReferences } from '@aeriajs/types';
3
3
  export declare const editProfile: (payload: Partial<PackReferences<SchemaWithId<typeof description>>> & Record<string, unknown>, context: Context<typeof description>) => Promise<import("@aeriajs/types").InsertReturnType<SchemaWithId<{
4
4
  readonly $id: "user";
5
5
  readonly icon: "users";
@@ -68,6 +68,7 @@ export declare const editProfile: (payload: Partial<PackReferences<SchemaWithId<
68
68
  readonly picture: "picture_file";
69
69
  readonly information: "email";
70
70
  readonly active: "active";
71
+ readonly translateBadge: true;
71
72
  };
72
73
  };
73
74
  readonly individualActions: {
@@ -105,7 +106,7 @@ export declare const editProfile: (payload: Partial<PackReferences<SchemaWithId<
105
106
  };
106
107
  };
107
108
  }>> | import("@aeriajs/types").Result.Error<{
108
- readonly code: ACError.TargetImmutable;
109
+ readonly code: "TARGET_IMMUTABLE";
109
110
  } & {
110
- httpStatus: HTTPStatus.Forbidden;
111
+ httpStatus: 403;
111
112
  }>>;