@aeriajs/builtins 0.0.256 → 0.0.257

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 (40) hide show
  1. package/dist/collections/file/download.d.ts +56 -16
  2. package/dist/collections/file/download.js +40 -1
  3. package/dist/collections/file/download.mjs +40 -1
  4. package/dist/collections/file/index.d.ts +461 -20
  5. package/dist/collections/file/index.js +3 -0
  6. package/dist/collections/file/index.mjs +4 -1
  7. package/dist/collections/file/remove.d.ts +2 -2
  8. package/dist/collections/user/activate.d.ts +67 -33
  9. package/dist/collections/user/activate.js +45 -1
  10. package/dist/collections/user/activate.mjs +45 -1
  11. package/dist/collections/user/authenticate.d.ts +136 -41
  12. package/dist/collections/user/authenticate.js +98 -2
  13. package/dist/collections/user/authenticate.mjs +98 -2
  14. package/dist/collections/user/createAccount.d.ts +124 -111
  15. package/dist/collections/user/createAccount.js +27 -1
  16. package/dist/collections/user/createAccount.mjs +27 -1
  17. package/dist/collections/user/editProfile.d.ts +95 -103
  18. package/dist/collections/user/editProfile.js +21 -1
  19. package/dist/collections/user/editProfile.mjs +21 -1
  20. package/dist/collections/user/getActivationLink.d.ts +92 -60
  21. package/dist/collections/user/getActivationLink.js +39 -4
  22. package/dist/collections/user/getActivationLink.mjs +39 -3
  23. package/dist/collections/user/getCurrentUser.d.ts +43 -113
  24. package/dist/collections/user/getCurrentUser.js +31 -1
  25. package/dist/collections/user/getCurrentUser.mjs +31 -1
  26. package/dist/collections/user/getInfo.d.ts +71 -26
  27. package/dist/collections/user/getInfo.js +47 -1
  28. package/dist/collections/user/getInfo.mjs +47 -1
  29. package/dist/collections/user/getRedefinePasswordLink.d.ts +91 -55
  30. package/dist/collections/user/getRedefinePasswordLink.js +32 -2
  31. package/dist/collections/user/getRedefinePasswordLink.mjs +33 -3
  32. package/dist/collections/user/index.d.ts +3480 -630
  33. package/dist/collections/user/index.js +9 -21
  34. package/dist/collections/user/index.mjs +18 -30
  35. package/dist/collections/user/redefinePassword.d.ts +93 -34
  36. package/dist/collections/user/redefinePassword.js +46 -6
  37. package/dist/collections/user/redefinePassword.mjs +46 -6
  38. package/dist/functions/describe.d.ts +38 -12
  39. package/dist/index.d.ts +4397 -1106
  40. package/package.json +6 -6
@@ -1,124 +1,137 @@
1
- import type { Context, SchemaWithId, PackReferences } from '@aeriajs/types';
2
- import type { description } from './description.js';
1
+ import type { Context, ContractToFunction } from '@aeriajs/types';
2
+ import { description } from './description.js';
3
3
  export declare const CreateAccountError: {
4
4
  readonly SignupDisallowed: "SIGNUP_DISALLOWED";
5
5
  };
6
- export declare const createAccount: (payload: Partial<PackReferences<SchemaWithId<typeof description>>> & Record<string, unknown>, context: Context<typeof description>) => Promise<import("@aeriajs/types").Result.Error<{
7
- readonly code: "SIGNUP_DISALLOWED";
8
- } & {
9
- httpStatus: 403;
10
- }> | import("@aeriajs/types").Result.Error<{
11
- readonly code: "MALFORMED_INPUT";
12
- readonly details: import("@aeriajs/types").PropertyValidationError | import("@aeriajs/types").ValidationError;
13
- } & {
14
- httpStatus: 422;
15
- }> | import("@aeriajs/types").Result.Error<{
16
- readonly code: "OWNERSHIP_ERROR";
17
- } & {
18
- httpStatus: 403;
19
- }> | import("@aeriajs/types").InsertReturnType<SchemaWithId<{
20
- readonly $id: "user";
21
- readonly icon: "users";
22
- readonly required: readonly ["name", "roles", "email"];
23
- readonly form: readonly ["name", "active", "roles", "email", "phone_number", "picture_file"];
24
- readonly indexes: readonly ["name"];
25
- readonly unique: readonly ["email"];
26
- readonly properties: {
27
- readonly name: {
28
- readonly type: "string";
29
- readonly minLength: 1;
30
- };
31
- readonly given_name: {
32
- readonly getter: (doc: object) => string | undefined;
33
- };
34
- readonly family_name: {
35
- readonly getter: (doc: object) => string | undefined;
36
- };
37
- readonly active: {
38
- readonly type: "boolean";
39
- };
40
- readonly roles: {
41
- readonly type: "array";
42
- readonly items: {
6
+ export declare const createAccountContract: {
7
+ readonly payload: {
8
+ readonly type: "object";
9
+ readonly required: readonly [];
10
+ readonly additionalProperties: true;
11
+ readonly properties: {
12
+ readonly name: {
43
13
  readonly type: "string";
14
+ readonly minLength: 1;
15
+ };
16
+ readonly given_name: {
17
+ readonly getter: (doc: object) => string | undefined;
18
+ };
19
+ readonly family_name: {
20
+ readonly getter: (doc: object) => string | undefined;
21
+ };
22
+ readonly active: {
23
+ readonly type: "boolean";
24
+ };
25
+ readonly roles: {
26
+ readonly type: "array";
27
+ readonly items: {
28
+ readonly type: "string";
29
+ };
30
+ readonly uniqueItems: true;
31
+ readonly minItems: 1;
32
+ };
33
+ readonly email: {
34
+ readonly type: "string";
35
+ readonly inputType: "email";
36
+ readonly minLength: 3;
37
+ };
38
+ readonly password: {
39
+ readonly type: "string";
40
+ readonly inputType: "password";
41
+ readonly hidden: true;
42
+ };
43
+ readonly phone_number: {
44
+ readonly type: "string";
45
+ readonly mask: "(##) #####-####";
46
+ };
47
+ readonly picture_file: {
48
+ readonly $ref: "file";
49
+ readonly accept: readonly ["image/*"];
50
+ };
51
+ readonly picture: {
52
+ readonly getter: (doc: object) => Promise<string> | undefined;
53
+ };
54
+ readonly self_registered: {
55
+ readonly type: "boolean";
56
+ readonly readOnly: true;
57
+ };
58
+ readonly updated_at: {
59
+ readonly type: "string";
60
+ readonly format: "date-time";
44
61
  };
45
- readonly uniqueItems: true;
46
- readonly minItems: 1;
47
- };
48
- readonly email: {
49
- readonly type: "string";
50
- readonly inputType: "email";
51
- readonly minLength: 3;
52
- };
53
- readonly password: {
54
- readonly type: "string";
55
- readonly inputType: "password";
56
- readonly hidden: true;
57
- };
58
- readonly phone_number: {
59
- readonly type: "string";
60
- readonly mask: "(##) #####-####";
61
- };
62
- readonly picture_file: {
63
- readonly $ref: "file";
64
- readonly accept: readonly ["image/*"];
65
- };
66
- readonly picture: {
67
- readonly getter: (doc: object) => Promise<string> | undefined;
68
- };
69
- readonly self_registered: {
70
- readonly type: "boolean";
71
- readonly readOnly: true;
72
- };
73
- readonly updated_at: {
74
- readonly type: "string";
75
- readonly format: "date-time";
76
- };
77
- };
78
- readonly presets: readonly ["crud", "duplicate"];
79
- readonly layout: {
80
- readonly name: "grid";
81
- readonly options: {
82
- readonly title: "name";
83
- readonly badge: "roles";
84
- readonly picture: "picture_file";
85
- readonly information: "email";
86
- readonly active: "active";
87
- readonly translateBadge: true;
88
62
  };
89
63
  };
90
- readonly individualActions: {
91
- readonly changePassword: {
92
- readonly label: "change_password";
93
- readonly icon: "key";
94
- readonly translate: true;
95
- readonly route: {
96
- readonly name: "/dashboard/user/changepass";
97
- readonly fetchItem: true;
64
+ readonly response: [{
65
+ readonly type: "object";
66
+ readonly properties: {
67
+ readonly _tag: {
68
+ readonly const: "Error";
69
+ };
70
+ readonly result: {
71
+ readonly const: undefined;
72
+ };
73
+ readonly error: {
74
+ readonly type: "object";
75
+ readonly required: readonly ["httpStatus", "code"];
76
+ readonly properties: {
77
+ readonly httpStatus: {
78
+ readonly enum: [403, 404, 422, 400, 500];
79
+ };
80
+ readonly code: {
81
+ readonly enum: ["INSECURE_OPERATOR", "OWNERSHIP_ERROR", "RESOURCE_NOT_FOUND", "TARGET_IMMUTABLE", "MALFORMED_INPUT", "UNIQUENESS_VIOLATED", "EMPTY_TARGET", "INVALID_PROPERTIES", "MISSING_PROPERTIES", "INVALID_DOCUMENT_ID", "INVALID_TEMPFILE"];
82
+ };
83
+ readonly message: {
84
+ readonly type: "string";
85
+ };
86
+ readonly details: {
87
+ readonly type: "object";
88
+ readonly additionalProperties: true;
89
+ };
90
+ };
98
91
  };
99
92
  };
100
- readonly copyRedefinePasswordLink: {
101
- readonly label: "copy_redefine_password_link";
102
- readonly icon: "link";
103
- readonly translate: true;
104
- };
105
- readonly copyActivationLink: {
106
- readonly label: "copy_activation_link";
107
- readonly icon: "link";
108
- readonly translate: true;
93
+ }, {
94
+ readonly type: "object";
95
+ readonly properties: {
96
+ readonly _tag: {
97
+ readonly const: "Error";
98
+ };
99
+ readonly result: {
100
+ readonly const: undefined;
101
+ };
102
+ readonly error: {
103
+ readonly type: "object";
104
+ readonly required: readonly ["httpStatus", "code"];
105
+ readonly properties: {
106
+ readonly httpStatus: {
107
+ readonly enum: [403, 422];
108
+ };
109
+ readonly code: {
110
+ readonly enum: ["MALFORMED_INPUT", "OWNERSHIP_ERROR", "SIGNUP_DISALLOWED"];
111
+ };
112
+ readonly message: {
113
+ readonly type: "string";
114
+ };
115
+ readonly details: {
116
+ readonly type: "object";
117
+ readonly additionalProperties: true;
118
+ };
119
+ };
120
+ };
109
121
  };
110
- };
111
- readonly filters: readonly ["name", "roles", "email", "phone_number"];
112
- readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
113
- readonly tableMeta: readonly ["email"];
114
- readonly formLayout: {
115
- readonly fields: {
116
- readonly given_name: {
117
- readonly span: 3;
122
+ }, {
123
+ readonly type: "object";
124
+ readonly properties: {
125
+ readonly _tag: {
126
+ readonly const: "Result";
118
127
  };
119
- readonly family_name: {
120
- readonly span: 3;
128
+ readonly error: {
129
+ readonly const: undefined;
130
+ };
131
+ readonly result: {
132
+ readonly $ref: "user";
121
133
  };
122
134
  };
123
- };
124
- }>>>;
135
+ }];
136
+ };
137
+ export declare const createAccount: ContractToFunction<typeof createAccountContract, Context<typeof description>>;
@@ -1,13 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAccount = exports.CreateAccountError = void 0;
3
+ exports.createAccount = exports.createAccountContract = exports.CreateAccountError = void 0;
4
4
  const types_1 = require("@aeriajs/types");
5
5
  const validation_1 = require("@aeriajs/validation");
6
6
  const bcrypt = require("bcryptjs");
7
7
  const core_1 = require("@aeriajs/core");
8
+ const description_js_1 = require("./description.js");
8
9
  exports.CreateAccountError = {
9
10
  SignupDisallowed: 'SIGNUP_DISALLOWED',
10
11
  };
12
+ exports.createAccountContract = (0, types_1.defineContract)({
13
+ payload: {
14
+ type: 'object',
15
+ required: [],
16
+ additionalProperties: true,
17
+ properties: description_js_1.description.properties,
18
+ },
19
+ response: [
20
+ types_1.functionSchemas.insertError(),
21
+ (0, types_1.endpointErrorSchema)({
22
+ httpStatus: [
23
+ types_1.HTTPStatus.Forbidden,
24
+ types_1.HTTPStatus.UnprocessableContent,
25
+ ],
26
+ code: [
27
+ types_1.ACError.MalformedInput,
28
+ types_1.ACError.OwnershipError,
29
+ exports.CreateAccountError.SignupDisallowed,
30
+ ],
31
+ }),
32
+ (0, types_1.resultSchema)({
33
+ $ref: 'user',
34
+ }),
35
+ ],
36
+ });
11
37
  const createAccount = async (payload, context) => {
12
38
  const userCandidate = Object.assign({}, payload);
13
39
  if (!context.config.security.allowSignup) {
@@ -1,11 +1,37 @@
1
1
  "use strict";
2
- import { HTTPStatus, ACError } from "@aeriajs/types";
2
+ import { defineContract, HTTPStatus, ACError, functionSchemas, endpointErrorSchema, resultSchema } from "@aeriajs/types";
3
3
  import { validate } from "@aeriajs/validation";
4
4
  import * as bcrypt from "bcryptjs";
5
5
  import { insert as originalInsert } from "@aeriajs/core";
6
+ import { description } from "./description.mjs";
6
7
  export const CreateAccountError = {
7
8
  SignupDisallowed: "SIGNUP_DISALLOWED"
8
9
  };
10
+ export const createAccountContract = defineContract({
11
+ payload: {
12
+ type: "object",
13
+ required: [],
14
+ additionalProperties: true,
15
+ properties: description.properties
16
+ },
17
+ response: [
18
+ functionSchemas.insertError(),
19
+ endpointErrorSchema({
20
+ httpStatus: [
21
+ HTTPStatus.Forbidden,
22
+ HTTPStatus.UnprocessableContent
23
+ ],
24
+ code: [
25
+ ACError.MalformedInput,
26
+ ACError.OwnershipError,
27
+ CreateAccountError.SignupDisallowed
28
+ ]
29
+ }),
30
+ resultSchema({
31
+ $ref: "user"
32
+ })
33
+ ]
34
+ });
9
35
  export const createAccount = async (payload, context) => {
10
36
  const userCandidate = Object.assign({}, payload);
11
37
  if (!context.config.security.allowSignup) {
@@ -1,112 +1,104 @@
1
- import type { description } from './description.js';
2
- import { type Context, type SchemaWithId, type PackReferences } from '@aeriajs/types';
3
- export declare const editProfile: (payload: Partial<PackReferences<SchemaWithId<typeof description>>>, context: Context<typeof description>) => Promise<import("@aeriajs/types").InsertReturnType<SchemaWithId<{
4
- readonly $id: "user";
5
- readonly icon: "users";
6
- readonly required: readonly ["name", "roles", "email"];
7
- readonly form: readonly ["name", "active", "roles", "email", "phone_number", "picture_file"];
8
- readonly indexes: readonly ["name"];
9
- readonly unique: readonly ["email"];
10
- readonly properties: {
11
- readonly name: {
12
- readonly type: "string";
13
- readonly minLength: 1;
14
- };
15
- readonly given_name: {
16
- readonly getter: (doc: object) => string | undefined;
17
- };
18
- readonly family_name: {
19
- readonly getter: (doc: object) => string | undefined;
20
- };
21
- readonly active: {
22
- readonly type: "boolean";
23
- };
24
- readonly roles: {
25
- readonly type: "array";
26
- readonly items: {
1
+ import type { Context, ContractToFunction } from '@aeriajs/types';
2
+ import { description } from './description.js';
3
+ export declare const editProfileContract: {
4
+ readonly payload: {
5
+ readonly type: "object";
6
+ readonly required: readonly [];
7
+ readonly properties: {
8
+ readonly picture_file: {
27
9
  readonly type: "string";
10
+ readonly format: "objectid";
28
11
  };
29
- readonly uniqueItems: true;
30
- readonly minItems: 1;
31
- };
32
- readonly email: {
33
- readonly type: "string";
34
- readonly inputType: "email";
35
- readonly minLength: 3;
36
- };
37
- readonly password: {
38
- readonly type: "string";
39
- readonly inputType: "password";
40
- readonly hidden: true;
41
- };
42
- readonly phone_number: {
43
- readonly type: "string";
44
- readonly mask: "(##) #####-####";
45
- };
46
- readonly picture_file: {
47
- readonly $ref: "file";
48
- readonly accept: readonly ["image/*"];
49
- };
50
- readonly picture: {
51
- readonly getter: (doc: object) => Promise<string> | undefined;
52
- };
53
- readonly self_registered: {
54
- readonly type: "boolean";
55
- readonly readOnly: true;
56
- };
57
- readonly updated_at: {
58
- readonly type: "string";
59
- readonly format: "date-time";
60
- };
61
- };
62
- readonly presets: readonly ["crud", "duplicate"];
63
- readonly layout: {
64
- readonly name: "grid";
65
- readonly options: {
66
- readonly title: "name";
67
- readonly badge: "roles";
68
- readonly picture: "picture_file";
69
- readonly information: "email";
70
- readonly active: "active";
71
- readonly translateBadge: true;
72
- };
73
- };
74
- readonly individualActions: {
75
- readonly changePassword: {
76
- readonly label: "change_password";
77
- readonly icon: "key";
78
- readonly translate: true;
79
- readonly route: {
80
- readonly name: "/dashboard/user/changepass";
81
- readonly fetchItem: true;
12
+ readonly name: {
13
+ readonly type: "string";
14
+ readonly minLength: 1;
82
15
  };
83
- };
84
- readonly copyRedefinePasswordLink: {
85
- readonly label: "copy_redefine_password_link";
86
- readonly icon: "link";
87
- readonly translate: true;
88
- };
89
- readonly copyActivationLink: {
90
- readonly label: "copy_activation_link";
91
- readonly icon: "link";
92
- readonly translate: true;
93
- };
94
- };
95
- readonly filters: readonly ["name", "roles", "email", "phone_number"];
96
- readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
97
- readonly tableMeta: readonly ["email"];
98
- readonly formLayout: {
99
- readonly fields: {
100
16
  readonly given_name: {
101
- readonly span: 3;
17
+ readonly getter: (doc: object) => string | undefined;
102
18
  };
103
19
  readonly family_name: {
104
- readonly span: 3;
20
+ readonly getter: (doc: object) => string | undefined;
21
+ };
22
+ readonly active: {
23
+ readonly type: "boolean";
24
+ };
25
+ readonly roles: {
26
+ readonly type: "array";
27
+ readonly items: {
28
+ readonly type: "string";
29
+ };
30
+ readonly uniqueItems: true;
31
+ readonly minItems: 1;
32
+ };
33
+ readonly email: {
34
+ readonly type: "string";
35
+ readonly inputType: "email";
36
+ readonly minLength: 3;
37
+ };
38
+ readonly password: {
39
+ readonly type: "string";
40
+ readonly inputType: "password";
41
+ readonly hidden: true;
42
+ };
43
+ readonly phone_number: {
44
+ readonly type: "string";
45
+ readonly mask: "(##) #####-####";
46
+ };
47
+ readonly picture: {
48
+ readonly getter: (doc: object) => Promise<string> | undefined;
49
+ };
50
+ readonly self_registered: {
51
+ readonly type: "boolean";
52
+ readonly readOnly: true;
53
+ };
54
+ readonly updated_at: {
55
+ readonly type: "string";
56
+ readonly format: "date-time";
105
57
  };
106
58
  };
107
59
  };
108
- }>> | import("@aeriajs/types").Result.Error<{
109
- readonly code: "TARGET_IMMUTABLE";
110
- } & {
111
- httpStatus: 403;
112
- }>>;
60
+ readonly response: [{
61
+ readonly type: "object";
62
+ readonly properties: {
63
+ readonly _tag: {
64
+ readonly const: "Error";
65
+ };
66
+ readonly result: {
67
+ readonly const: undefined;
68
+ };
69
+ readonly error: {
70
+ readonly type: "object";
71
+ readonly required: readonly ["httpStatus", "code"];
72
+ readonly properties: {
73
+ readonly httpStatus: {
74
+ readonly enum: [403, 404, 422, 400, 500];
75
+ };
76
+ readonly code: {
77
+ readonly enum: ["INSECURE_OPERATOR", "OWNERSHIP_ERROR", "RESOURCE_NOT_FOUND", "TARGET_IMMUTABLE", "MALFORMED_INPUT", "UNIQUENESS_VIOLATED", "EMPTY_TARGET", "INVALID_PROPERTIES", "MISSING_PROPERTIES", "INVALID_DOCUMENT_ID", "INVALID_TEMPFILE"];
78
+ };
79
+ readonly message: {
80
+ readonly type: "string";
81
+ };
82
+ readonly details: {
83
+ readonly type: "object";
84
+ readonly additionalProperties: true;
85
+ };
86
+ };
87
+ };
88
+ };
89
+ }, {
90
+ readonly type: "object";
91
+ readonly properties: {
92
+ readonly _tag: {
93
+ readonly const: "Result";
94
+ };
95
+ readonly error: {
96
+ readonly const: undefined;
97
+ };
98
+ readonly result: {
99
+ readonly $ref: "user";
100
+ };
101
+ };
102
+ }];
103
+ };
104
+ export declare const editProfile: ContractToFunction<typeof editProfileContract, Context<typeof description>>;
@@ -1,9 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.editProfile = void 0;
3
+ exports.editProfile = exports.editProfileContract = void 0;
4
4
  const types_1 = require("@aeriajs/types");
5
5
  const core_1 = require("@aeriajs/core");
6
6
  const bcrypt = require("bcryptjs");
7
+ const description_js_1 = require("./description.js");
8
+ exports.editProfileContract = (0, types_1.defineContract)({
9
+ payload: {
10
+ type: 'object',
11
+ required: [],
12
+ properties: {
13
+ ...description_js_1.description.properties,
14
+ picture_file: {
15
+ type: 'string',
16
+ format: 'objectid',
17
+ },
18
+ },
19
+ },
20
+ response: [
21
+ types_1.functionSchemas.insertError(),
22
+ (0, types_1.resultSchema)({
23
+ $ref: 'user',
24
+ }),
25
+ ],
26
+ });
7
27
  const editProfile = async (payload, context) => {
8
28
  const mutableProperties = context.config.security.mutableUserProperties;
9
29
  if (!context.token.sub) {
@@ -1,7 +1,27 @@
1
1
  "use strict";
2
- import { HTTPStatus, ACError } from "@aeriajs/types";
2
+ import { HTTPStatus, ACError, defineContract, functionSchemas, resultSchema } from "@aeriajs/types";
3
3
  import { insert as originalInsert } from "@aeriajs/core";
4
4
  import * as bcrypt from "bcryptjs";
5
+ import { description } from "./description.mjs";
6
+ export const editProfileContract = defineContract({
7
+ payload: {
8
+ type: "object",
9
+ required: [],
10
+ properties: {
11
+ ...description.properties,
12
+ picture_file: {
13
+ type: "string",
14
+ format: "objectid"
15
+ }
16
+ }
17
+ },
18
+ response: [
19
+ functionSchemas.insertError(),
20
+ resultSchema({
21
+ $ref: "user"
22
+ })
23
+ ]
24
+ });
5
25
  export const editProfile = async (payload, context) => {
6
26
  const mutableProperties = context.config.security.mutableUserProperties;
7
27
  if (!context.token.sub) {