@aeriajs/builtins 0.0.57 → 0.0.59

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.
@@ -85,8 +85,10 @@ export declare const tempFile: Omit<import("@aeriajs/types").Collection<{
85
85
  };
86
86
  };
87
87
  };
88
- functions: {};
89
- functionContracts: {};
88
+ functions: Record<string, unknown> & {};
89
+ functionContracts: {
90
+ [x: string]: import("@aeriajs/types").Contract | undefined;
91
+ };
90
92
  accessControl: import("@aeriajs/types").AccessControl;
91
93
  };
92
94
  export declare const file: Omit<import("@aeriajs/types").Collection<{
@@ -1,45 +1,110 @@
1
1
  export declare const resourceUsage: Omit<import("@aeriajs/types").Collection<{
2
2
  description: {
3
3
  readonly $id: "resourceUsage";
4
- readonly required: readonly [];
4
+ readonly required: readonly ["usage"];
5
5
  readonly properties: {
6
- readonly hits: {
7
- readonly type: "integer";
6
+ readonly user: {
7
+ readonly $ref: "user";
8
8
  };
9
- readonly last_maximum_reach: {
9
+ readonly address: {
10
10
  readonly type: "string";
11
- readonly format: "date-time";
11
+ };
12
+ readonly usage: {
13
+ readonly type: "object";
14
+ readonly additionalProperties: {
15
+ readonly type: "object";
16
+ readonly properties: {
17
+ readonly hits: {
18
+ readonly type: "integer";
19
+ };
20
+ readonly points: {
21
+ readonly type: "integer";
22
+ };
23
+ readonly last_reach: {
24
+ readonly type: "string";
25
+ readonly format: "date-time";
26
+ };
27
+ readonly last_maximum_reach: {
28
+ readonly type: "string";
29
+ readonly format: "date-time";
30
+ };
31
+ };
32
+ };
12
33
  };
13
34
  };
14
35
  };
15
36
  }>, "description" | "functions" | "item"> & {
16
37
  item: import("@aeriajs/types").SchemaWithId<{
17
38
  readonly $id: "resourceUsage";
18
- readonly required: readonly [];
39
+ readonly required: readonly ["usage"];
19
40
  readonly properties: {
20
- readonly hits: {
21
- readonly type: "integer";
41
+ readonly user: {
42
+ readonly $ref: "user";
22
43
  };
23
- readonly last_maximum_reach: {
44
+ readonly address: {
24
45
  readonly type: "string";
25
- readonly format: "date-time";
46
+ };
47
+ readonly usage: {
48
+ readonly type: "object";
49
+ readonly additionalProperties: {
50
+ readonly type: "object";
51
+ readonly properties: {
52
+ readonly hits: {
53
+ readonly type: "integer";
54
+ };
55
+ readonly points: {
56
+ readonly type: "integer";
57
+ };
58
+ readonly last_reach: {
59
+ readonly type: "string";
60
+ readonly format: "date-time";
61
+ };
62
+ readonly last_maximum_reach: {
63
+ readonly type: "string";
64
+ readonly format: "date-time";
65
+ };
66
+ };
67
+ };
26
68
  };
27
69
  };
28
70
  }>;
29
71
  description: {
30
72
  readonly $id: "resourceUsage";
31
- readonly required: readonly [];
73
+ readonly required: readonly ["usage"];
32
74
  readonly properties: {
33
- readonly hits: {
34
- readonly type: "integer";
75
+ readonly user: {
76
+ readonly $ref: "user";
35
77
  };
36
- readonly last_maximum_reach: {
78
+ readonly address: {
37
79
  readonly type: "string";
38
- readonly format: "date-time";
80
+ };
81
+ readonly usage: {
82
+ readonly type: "object";
83
+ readonly additionalProperties: {
84
+ readonly type: "object";
85
+ readonly properties: {
86
+ readonly hits: {
87
+ readonly type: "integer";
88
+ };
89
+ readonly points: {
90
+ readonly type: "integer";
91
+ };
92
+ readonly last_reach: {
93
+ readonly type: "string";
94
+ readonly format: "date-time";
95
+ };
96
+ readonly last_maximum_reach: {
97
+ readonly type: "string";
98
+ readonly format: "date-time";
99
+ };
100
+ };
101
+ };
39
102
  };
40
103
  };
41
104
  };
42
- functions: {};
43
- functionContracts: {};
105
+ functions: Record<string, unknown> & {};
106
+ functionContracts: {
107
+ [x: string]: import("@aeriajs/types").Contract | undefined;
108
+ };
44
109
  accessControl: import("@aeriajs/types").AccessControl;
45
110
  };
@@ -5,14 +5,35 @@ const api_1 = require("@aeriajs/api");
5
5
  exports.resourceUsage = (0, api_1.defineCollection)({
6
6
  description: {
7
7
  $id: 'resourceUsage',
8
- required: [],
8
+ required: ['usage'],
9
9
  properties: {
10
- hits: {
11
- type: 'integer',
10
+ user: {
11
+ $ref: 'user',
12
12
  },
13
- last_maximum_reach: {
13
+ address: {
14
14
  type: 'string',
15
- format: 'date-time',
15
+ },
16
+ usage: {
17
+ type: 'object',
18
+ additionalProperties: {
19
+ type: 'object',
20
+ properties: {
21
+ hits: {
22
+ type: 'integer',
23
+ },
24
+ points: {
25
+ type: 'integer',
26
+ },
27
+ last_reach: {
28
+ type: 'string',
29
+ format: 'date-time',
30
+ },
31
+ last_maximum_reach: {
32
+ type: 'string',
33
+ format: 'date-time',
34
+ },
35
+ },
36
+ },
16
37
  },
17
38
  },
18
39
  },
@@ -3,14 +3,35 @@ import { defineCollection } from "@aeriajs/api";
3
3
  export const resourceUsage = defineCollection({
4
4
  description: {
5
5
  $id: "resourceUsage",
6
- required: [],
6
+ required: ["usage"],
7
7
  properties: {
8
- hits: {
9
- type: "integer"
8
+ user: {
9
+ $ref: "user"
10
10
  },
11
- last_maximum_reach: {
12
- type: "string",
13
- format: "date-time"
11
+ address: {
12
+ type: "string"
13
+ },
14
+ usage: {
15
+ type: "object",
16
+ additionalProperties: {
17
+ type: "object",
18
+ properties: {
19
+ hits: {
20
+ type: "integer"
21
+ },
22
+ points: {
23
+ type: "integer"
24
+ },
25
+ last_reach: {
26
+ type: "string",
27
+ format: "date-time"
28
+ },
29
+ last_maximum_reach: {
30
+ type: "string",
31
+ format: "date-time"
32
+ }
33
+ }
34
+ }
14
35
  }
15
36
  }
16
37
  }
@@ -1,6 +1,6 @@
1
1
  import type { Context, SchemaWithId } from '@aeriajs/types';
2
2
  import type { description } from './description.js';
3
- import { type ObjectId } from '@aeriajs/api';
3
+ import type { ObjectId } from '@aeriajs/api';
4
4
  type Props = {
5
5
  email: string;
6
6
  password: string;
@@ -25,12 +25,17 @@ const getUser = async (userId, context) => {
25
25
  roles: leanUser.roles,
26
26
  userinfo: {},
27
27
  };
28
- if (context.config.logSuccessfulAuthentications) {
29
- await context.log('successful authentication', {
30
- email: leanUser.email,
31
- roles: leanUser.roles,
32
- _id: leanUser._id,
33
- });
28
+ if (context.config.security) {
29
+ if (context.config.security.authenticationRateLimiting) {
30
+ //
31
+ }
32
+ if (context.config.security.logSuccessfulAuthentications) {
33
+ await context.log('successful authentication', {
34
+ email: leanUser.email,
35
+ roles: leanUser.roles,
36
+ _id: leanUser._id,
37
+ });
38
+ }
34
39
  }
35
40
  if (context.config.tokenUserProperties) {
36
41
  const pick = (obj, properties) => properties.reduce((a, prop) => {
@@ -23,12 +23,16 @@ const getUser = async (userId, context) => {
23
23
  roles: leanUser.roles,
24
24
  userinfo: {}
25
25
  };
26
- if (context.config.logSuccessfulAuthentications) {
27
- await context.log("successful authentication", {
28
- email: leanUser.email,
29
- roles: leanUser.roles,
30
- _id: leanUser._id
31
- });
26
+ if (context.config.security) {
27
+ if (context.config.security.authenticationRateLimiting) {
28
+ }
29
+ if (context.config.security.logSuccessfulAuthentications) {
30
+ await context.log("successful authentication", {
31
+ email: leanUser.email,
32
+ roles: leanUser.roles,
33
+ _id: leanUser._id
34
+ });
35
+ }
32
36
  }
33
37
  if (context.config.tokenUserProperties) {
34
38
  const pick = (obj, properties) => properties.reduce((a, prop) => {
@@ -1,4 +1,4 @@
1
- import type { Context } from '@aeriajs/types';
1
+ import type { RouteContext } from '@aeriajs/types';
2
2
  import type { Description } from '@aeriajs/types';
3
3
  type Payload = {
4
4
  collections?: string[];
@@ -7,7 +7,7 @@ type Payload = {
7
7
  revalidate?: boolean;
8
8
  router?: boolean;
9
9
  };
10
- export declare const describe: (contextOrPayload: Context | Payload) => Promise<import("@aeriajs/types").GenericResponse | import("@aeriajs/types").Left<import("../collections/user/authenticate.js").AuthenticationErrors> | {
10
+ export declare const describe: (contextOrPayload: RouteContext | Payload) => Promise<import("@aeriajs/types").GenericResponse | import("@aeriajs/types").Left<import("../collections/user/authenticate.js").AuthenticationErrors> | {
11
11
  descriptions: Record<string, Description>;
12
12
  roles?: string[] | undefined;
13
13
  auth?: Partial<{
@@ -11,7 +11,7 @@ const describe = async (contextOrPayload) => {
11
11
  const props = 'request' in contextOrPayload
12
12
  ? contextOrPayload.request.payload
13
13
  : contextOrPayload;
14
- if (props.revalidate) {
14
+ if ('request' in contextOrPayload && props.revalidate) {
15
15
  const authEither = await (0, authenticate_js_1.authenticate)({
16
16
  revalidate: true,
17
17
  }, await (0, api_1.createContext)({
@@ -7,7 +7,7 @@ import { authenticate } from "../collections/user/authenticate.mjs";
7
7
  export const describe = async (contextOrPayload) => {
8
8
  const result = {};
9
9
  const props = "request" in contextOrPayload ? contextOrPayload.request.payload : contextOrPayload;
10
- if (props.revalidate) {
10
+ if ("request" in contextOrPayload && props.revalidate) {
11
11
  const authEither = await authenticate({
12
12
  revalidate: true
13
13
  }, await createContext({
package/dist/index.d.ts CHANGED
@@ -971,8 +971,10 @@ export declare const collections: {
971
971
  };
972
972
  };
973
973
  };
974
- functions: {};
975
- functionContracts: {};
974
+ functions: Record<string, unknown> & {};
975
+ functionContracts: {
976
+ [x: string]: import("@aeriajs/types").Contract | undefined;
977
+ };
976
978
  accessControl: import("@aeriajs/types").AccessControl;
977
979
  };
978
980
  log: Omit<import("@aeriajs/types").Collection<{
@@ -1078,46 +1080,111 @@ export declare const collections: {
1078
1080
  resourceUsage: Omit<import("@aeriajs/types").Collection<{
1079
1081
  description: {
1080
1082
  readonly $id: "resourceUsage";
1081
- readonly required: readonly [];
1083
+ readonly required: readonly ["usage"];
1082
1084
  readonly properties: {
1083
- readonly hits: {
1084
- readonly type: "integer";
1085
+ readonly user: {
1086
+ readonly $ref: "user";
1085
1087
  };
1086
- readonly last_maximum_reach: {
1088
+ readonly address: {
1087
1089
  readonly type: "string";
1088
- readonly format: "date-time";
1090
+ };
1091
+ readonly usage: {
1092
+ readonly type: "object";
1093
+ readonly additionalProperties: {
1094
+ readonly type: "object";
1095
+ readonly properties: {
1096
+ readonly hits: {
1097
+ readonly type: "integer";
1098
+ };
1099
+ readonly points: {
1100
+ readonly type: "integer";
1101
+ };
1102
+ readonly last_reach: {
1103
+ readonly type: "string";
1104
+ readonly format: "date-time";
1105
+ };
1106
+ readonly last_maximum_reach: {
1107
+ readonly type: "string";
1108
+ readonly format: "date-time";
1109
+ };
1110
+ };
1111
+ };
1089
1112
  };
1090
1113
  };
1091
1114
  };
1092
1115
  }>, "description" | "functions" | "item"> & {
1093
1116
  item: import("@aeriajs/types").SchemaWithId<{
1094
1117
  readonly $id: "resourceUsage";
1095
- readonly required: readonly [];
1118
+ readonly required: readonly ["usage"];
1096
1119
  readonly properties: {
1097
- readonly hits: {
1098
- readonly type: "integer";
1120
+ readonly user: {
1121
+ readonly $ref: "user";
1099
1122
  };
1100
- readonly last_maximum_reach: {
1123
+ readonly address: {
1101
1124
  readonly type: "string";
1102
- readonly format: "date-time";
1125
+ };
1126
+ readonly usage: {
1127
+ readonly type: "object";
1128
+ readonly additionalProperties: {
1129
+ readonly type: "object";
1130
+ readonly properties: {
1131
+ readonly hits: {
1132
+ readonly type: "integer";
1133
+ };
1134
+ readonly points: {
1135
+ readonly type: "integer";
1136
+ };
1137
+ readonly last_reach: {
1138
+ readonly type: "string";
1139
+ readonly format: "date-time";
1140
+ };
1141
+ readonly last_maximum_reach: {
1142
+ readonly type: "string";
1143
+ readonly format: "date-time";
1144
+ };
1145
+ };
1146
+ };
1103
1147
  };
1104
1148
  };
1105
1149
  }>;
1106
1150
  description: {
1107
1151
  readonly $id: "resourceUsage";
1108
- readonly required: readonly [];
1152
+ readonly required: readonly ["usage"];
1109
1153
  readonly properties: {
1110
- readonly hits: {
1111
- readonly type: "integer";
1154
+ readonly user: {
1155
+ readonly $ref: "user";
1112
1156
  };
1113
- readonly last_maximum_reach: {
1157
+ readonly address: {
1114
1158
  readonly type: "string";
1115
- readonly format: "date-time";
1159
+ };
1160
+ readonly usage: {
1161
+ readonly type: "object";
1162
+ readonly additionalProperties: {
1163
+ readonly type: "object";
1164
+ readonly properties: {
1165
+ readonly hits: {
1166
+ readonly type: "integer";
1167
+ };
1168
+ readonly points: {
1169
+ readonly type: "integer";
1170
+ };
1171
+ readonly last_reach: {
1172
+ readonly type: "string";
1173
+ readonly format: "date-time";
1174
+ };
1175
+ readonly last_maximum_reach: {
1176
+ readonly type: "string";
1177
+ readonly format: "date-time";
1178
+ };
1179
+ };
1180
+ };
1116
1181
  };
1117
1182
  };
1118
1183
  };
1119
- functions: {};
1120
- functionContracts: {};
1184
+ functions: Record<string, unknown> & {};
1185
+ functionContracts: {
1186
+ [x: string]: import("@aeriajs/types").Contract | undefined;
1187
+ };
1121
1188
  accessControl: import("@aeriajs/types").AccessControl;
1122
1189
  };
1123
1190
  user: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/builtins",
3
- "version": "0.0.57",
3
+ "version": "0.0.59",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -36,22 +36,22 @@
36
36
  "bcrypt": "^5.1.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@aeriajs/access-control": "^0.0.29",
40
- "@aeriajs/api": "^0.0.57",
41
- "@aeriajs/common": "^0.0.29",
42
- "@aeriajs/entrypoint": "^0.0.29",
43
- "@aeriajs/types": "^0.0.26",
44
- "@aeriajs/validation": "^0.0.32",
39
+ "@aeriajs/access-control": "^0.0.31",
40
+ "@aeriajs/api": "^0.0.59",
41
+ "@aeriajs/common": "^0.0.31",
42
+ "@aeriajs/entrypoint": "^0.0.31",
43
+ "@aeriajs/types": "^0.0.28",
44
+ "@aeriajs/validation": "^0.0.34",
45
45
  "@types/bcrypt": "^5.0.2",
46
46
  "mongodb": "^6.5.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@aeriajs/access-control": "^0.0.29",
50
- "@aeriajs/api": "^0.0.57",
51
- "@aeriajs/common": "^0.0.29",
52
- "@aeriajs/entrypoint": "^0.0.29",
53
- "@aeriajs/types": "^0.0.26",
54
- "@aeriajs/validation": "^0.0.32"
49
+ "@aeriajs/access-control": "^0.0.31",
50
+ "@aeriajs/api": "^0.0.59",
51
+ "@aeriajs/common": "^0.0.31",
52
+ "@aeriajs/entrypoint": "^0.0.31",
53
+ "@aeriajs/types": "^0.0.28",
54
+ "@aeriajs/validation": "^0.0.34"
55
55
  },
56
56
  "scripts": {
57
57
  "test": "echo skipping",