@aeriajs/builtins 0.0.75 → 0.0.77

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 (41) hide show
  1. package/dist/collections/file/description.d.ts +2 -2
  2. package/dist/collections/file/description.js +2 -2
  3. package/dist/collections/file/description.mjs +2 -2
  4. package/dist/collections/file/download.js +3 -2
  5. package/dist/collections/file/download.mjs +3 -3
  6. package/dist/collections/file/index.d.ts +36 -36
  7. package/dist/collections/file/insert.d.ts +2 -2
  8. package/dist/collections/file/insert.js +3 -2
  9. package/dist/collections/file/insert.mjs +3 -3
  10. package/dist/collections/file/remove.js +3 -2
  11. package/dist/collections/file/remove.mjs +3 -3
  12. package/dist/collections/file/removeAll.js +3 -2
  13. package/dist/collections/file/removeAll.mjs +3 -3
  14. package/dist/collections/log/index.d.ts +1 -1
  15. package/dist/collections/resourceUsage/index.d.ts +1 -1
  16. package/dist/collections/user/activate.d.ts +1 -1
  17. package/dist/collections/user/activate.js +3 -2
  18. package/dist/collections/user/activate.mjs +3 -3
  19. package/dist/collections/user/authenticate.js +4 -8
  20. package/dist/collections/user/authenticate.mjs +0 -4
  21. package/dist/collections/user/createAccount.js +3 -3
  22. package/dist/collections/user/createAccount.mjs +2 -3
  23. package/dist/collections/user/description.d.ts +2 -2
  24. package/dist/collections/user/description.js +2 -2
  25. package/dist/collections/user/description.mjs +2 -2
  26. package/dist/collections/user/getCurrentUser.d.ts +107 -0
  27. package/dist/collections/user/getCurrentUser.js +26 -0
  28. package/dist/collections/user/getCurrentUser.mjs +23 -0
  29. package/dist/collections/user/getInfo.js +3 -2
  30. package/dist/collections/user/getInfo.mjs +3 -3
  31. package/dist/collections/user/index.d.ts +486 -69
  32. package/dist/collections/user/index.js +14 -8
  33. package/dist/collections/user/index.mjs +14 -8
  34. package/dist/collections/user/insert.d.ts +2 -2
  35. package/dist/collections/user/insert.js +0 -3
  36. package/dist/collections/user/insert.mjs +1 -4
  37. package/dist/functions/describe.d.ts +2 -2
  38. package/dist/functions/describe.js +1 -2
  39. package/dist/functions/describe.mjs +1 -2
  40. package/dist/index.d.ts +524 -107
  41. package/package.json +6 -8
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
- import { defineExposedFunction } from "@aeriajs/core";
3
2
  import { isLeft, unwrapEither, left, right } from "@aeriajs/common";
4
3
  import { validate } from "@aeriajs/validation";
5
4
  import * as bcrypt from "bcrypt";
6
- export const createAccount = defineExposedFunction(async (payload, context) => {
5
+ export const createAccount = async (payload, context) => {
7
6
  const user = Object.assign({}, payload);
8
7
  if (!context.config.security.allowSignup) {
9
8
  throw new Error("signup disallowed");
@@ -58,4 +57,4 @@ export const createAccount = defineExposedFunction(async (payload, context) => {
58
57
  throw new Error();
59
58
  }
60
59
  return right(newUser);
61
- });
60
+ };
@@ -76,12 +76,12 @@ export declare const description: {
76
76
  };
77
77
  readonly individualActions: {
78
78
  readonly 'ui:spawnEdit': {
79
- readonly name: "action.edit";
79
+ readonly label: "action.edit";
80
80
  readonly icon: "pencil";
81
81
  readonly translate: true;
82
82
  };
83
83
  readonly 'route:/dashboard/user/changepass': {
84
- readonly name: "change_password";
84
+ readonly label: "change_password";
85
85
  readonly icon: "key";
86
86
  readonly fetchItem: true;
87
87
  readonly translate: true;
@@ -108,12 +108,12 @@ exports.description = (0, core_1.defineDescription)({
108
108
  },
109
109
  individualActions: {
110
110
  'ui:spawnEdit': {
111
- name: 'action.edit',
111
+ label: 'action.edit',
112
112
  icon: 'pencil',
113
113
  translate: true,
114
114
  },
115
115
  'route:/dashboard/user/changepass': {
116
- name: 'change_password',
116
+ label: 'change_password',
117
117
  icon: 'key',
118
118
  fetchItem: true,
119
119
  translate: true,
@@ -102,12 +102,12 @@ export const description = defineDescription({
102
102
  },
103
103
  individualActions: {
104
104
  "ui:spawnEdit": {
105
- name: "action.edit",
105
+ label: "action.edit",
106
106
  icon: "pencil",
107
107
  translate: true
108
108
  },
109
109
  "route:/dashboard/user/changepass": {
110
- name: "change_password",
110
+ label: "change_password",
111
111
  icon: "key",
112
112
  fetchItem: true,
113
113
  translate: true
@@ -0,0 +1,107 @@
1
+ import type { Context, SchemaWithId } from '@aeriajs/types';
2
+ import type { description } from './description';
3
+ export declare enum ActivationErrors {
4
+ UserNotFound = "USER_NOT_FOUND",
5
+ AlreadyActiveUser = "ALREADY_ACTIVE_USER",
6
+ InvalidLink = "INVALID_LINK"
7
+ }
8
+ export declare const getCurrentUser: (_payload: undefined, context: Context<typeof description>) => Promise<import("@aeriajs/types").Left<{}> | import("@aeriajs/types").Right<SchemaWithId<{
9
+ readonly $id: "user";
10
+ readonly required: readonly ["name", "roles", "email"];
11
+ readonly form: readonly ["name", "active", "roles", "email", "phone_number", "picture_file"];
12
+ readonly indexes: readonly ["name"];
13
+ readonly freshItem: {
14
+ readonly active: true;
15
+ };
16
+ readonly properties: {
17
+ readonly name: {
18
+ readonly type: "string";
19
+ };
20
+ readonly given_name: {
21
+ readonly getter: (document: any) => string;
22
+ };
23
+ readonly family_name: {
24
+ readonly getter: (document: any) => string;
25
+ };
26
+ readonly active: {
27
+ readonly type: "boolean";
28
+ };
29
+ readonly roles: {
30
+ readonly type: "array";
31
+ readonly items: {
32
+ readonly type: "string";
33
+ };
34
+ readonly uniqueItems: true;
35
+ };
36
+ readonly email: {
37
+ readonly type: "string";
38
+ readonly inputType: "email";
39
+ readonly unique: true;
40
+ };
41
+ readonly password: {
42
+ readonly type: "string";
43
+ readonly inputType: "password";
44
+ readonly hidden: true;
45
+ };
46
+ readonly phone_number: {
47
+ readonly type: "string";
48
+ readonly mask: "(##) #####-####";
49
+ };
50
+ readonly picture_file: {
51
+ readonly $ref: "file";
52
+ readonly accept: readonly ["image/*"];
53
+ };
54
+ readonly picture: {
55
+ readonly getter: (value: any) => any;
56
+ };
57
+ readonly group: {
58
+ readonly type: "string";
59
+ };
60
+ readonly self_registered: {
61
+ readonly type: "boolean";
62
+ readonly readOnly: true;
63
+ };
64
+ readonly updated_at: {
65
+ readonly type: "string";
66
+ readonly format: "date-time";
67
+ };
68
+ };
69
+ readonly presets: readonly ["crud", "view", "duplicate"];
70
+ readonly layout: {
71
+ readonly name: "grid";
72
+ readonly options: {
73
+ readonly title: "name";
74
+ readonly badge: "roles";
75
+ readonly picture: "picture_file";
76
+ readonly information: "email";
77
+ readonly active: "active";
78
+ };
79
+ };
80
+ readonly individualActions: {
81
+ readonly 'ui:spawnEdit': {
82
+ readonly label: "action.edit";
83
+ readonly icon: "pencil";
84
+ readonly translate: true;
85
+ };
86
+ readonly 'route:/dashboard/user/changepass': {
87
+ readonly label: "change_password";
88
+ readonly icon: "key";
89
+ readonly fetchItem: true;
90
+ readonly translate: true;
91
+ };
92
+ };
93
+ readonly icon: "users";
94
+ readonly filters: readonly ["name", "roles", "email", "phone_number"];
95
+ readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
96
+ readonly tableMeta: readonly ["email"];
97
+ readonly formLayout: {
98
+ readonly fields: {
99
+ readonly given_name: {
100
+ readonly span: 3;
101
+ };
102
+ readonly family_name: {
103
+ readonly span: 3;
104
+ };
105
+ };
106
+ };
107
+ }>>>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentUser = exports.ActivationErrors = void 0;
4
+ const common_1 = require("@aeriajs/common");
5
+ var ActivationErrors;
6
+ (function (ActivationErrors) {
7
+ ActivationErrors["UserNotFound"] = "USER_NOT_FOUND";
8
+ ActivationErrors["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
9
+ ActivationErrors["InvalidLink"] = "INVALID_LINK";
10
+ })(ActivationErrors || (exports.ActivationErrors = ActivationErrors = {}));
11
+ const getCurrentUser = async (_payload, context) => {
12
+ if (!context.token.authenticated) {
13
+ return (0, common_1.left)({});
14
+ }
15
+ const user = await context.collections.user.functions.get({
16
+ filters: {
17
+ _id: context.token.sub,
18
+ },
19
+ });
20
+ if (!user) {
21
+ throw new Error();
22
+ }
23
+ const nonNullableUser = user;
24
+ return (0, common_1.right)(nonNullableUser);
25
+ };
26
+ exports.getCurrentUser = getCurrentUser;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ import { left, right } from "@aeriajs/common";
3
+ export var ActivationErrors = /* @__PURE__ */ ((ActivationErrors2) => {
4
+ ActivationErrors2["UserNotFound"] = "USER_NOT_FOUND";
5
+ ActivationErrors2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
6
+ ActivationErrors2["InvalidLink"] = "INVALID_LINK";
7
+ return ActivationErrors2;
8
+ })(ActivationErrors || {});
9
+ export const getCurrentUser = async (_payload, context) => {
10
+ if (!context.token.authenticated) {
11
+ return left({});
12
+ }
13
+ const user = await context.collections.user.functions.get({
14
+ filters: {
15
+ _id: context.token.sub
16
+ }
17
+ });
18
+ if (!user) {
19
+ throw new Error();
20
+ }
21
+ const nonNullableUser = user;
22
+ return right(nonNullableUser);
23
+ };
@@ -10,7 +10,7 @@ var ActivationErrors;
10
10
  ActivationErrors["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
11
11
  ActivationErrors["InvalidLink"] = "INVALID_LINK";
12
12
  })(ActivationErrors || (exports.ActivationErrors = ActivationErrors = {}));
13
- exports.getInfo = (0, core_1.defineExposedFunction)(async (payload, context) => {
13
+ const getInfo = async (payload, context) => {
14
14
  const { userId, token, } = payload;
15
15
  if (!userId || !token) {
16
16
  return (0, common_1.left)(ActivationErrors.InvalidLink);
@@ -32,4 +32,5 @@ exports.getInfo = (0, core_1.defineExposedFunction)(async (payload, context) =>
32
32
  name: user.name,
33
33
  email: user.email,
34
34
  });
35
- });
35
+ };
36
+ exports.getInfo = getInfo;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- import { defineExposedFunction, ObjectId } from "@aeriajs/core";
2
+ import { ObjectId } from "@aeriajs/core";
3
3
  import { left, right } from "@aeriajs/common";
4
4
  import * as bcrypt from "bcrypt";
5
5
  export var ActivationErrors = /* @__PURE__ */ ((ActivationErrors2) => {
@@ -8,7 +8,7 @@ export var ActivationErrors = /* @__PURE__ */ ((ActivationErrors2) => {
8
8
  ActivationErrors2["InvalidLink"] = "INVALID_LINK";
9
9
  return ActivationErrors2;
10
10
  })(ActivationErrors || {});
11
- export const getInfo = defineExposedFunction(async (payload, context) => {
11
+ export const getInfo = async (payload, context) => {
12
12
  const {
13
13
  userId,
14
14
  token
@@ -33,4 +33,4 @@ export const getInfo = defineExposedFunction(async (payload, context) => {
33
33
  name: user.name,
34
34
  email: user.email
35
35
  });
36
- });
36
+ };