@appsemble/node-utils 0.23.8 → 0.24.0
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.
- package/EmailError.d.ts +3 -0
- package/EmailError.js +8 -0
- package/README.md +3 -3
- package/app.d.ts +1 -1
- package/app.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +3 -3
- package/server/controllers/action.js +18 -3
- package/server/types.d.ts +2 -0
package/EmailError.d.ts
ADDED
package/EmailError.js
ADDED
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Node Utilities
|
|
2
2
|
|
|
3
3
|
> NodeJS utilities used by Appsemble internally.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/node-utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.24.0)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.24.0/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/app.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type Options } from './server/types.js';
|
|
|
10
10
|
* @param app The app for which to get the remapper context.
|
|
11
11
|
* @param language The preferred language for the context.
|
|
12
12
|
* @param userInfo The OAuth2 compatible user information.
|
|
13
|
-
* @param options The utility options.
|
|
13
|
+
* @param options The API utility options.
|
|
14
14
|
* @param context The koa context.
|
|
15
15
|
* @returns A localized remapper context for the app.
|
|
16
16
|
*/
|
package/app.js
CHANGED
|
@@ -11,7 +11,7 @@ const getPluralRules = memoize((locale, opts) => new Intl.PluralRules(locale, op
|
|
|
11
11
|
* @param app The app for which to get the remapper context.
|
|
12
12
|
* @param language The preferred language for the context.
|
|
13
13
|
* @param userInfo The OAuth2 compatible user information.
|
|
14
|
-
* @param options The utility options.
|
|
14
|
+
* @param options The API utility options.
|
|
15
15
|
* @param context The koa context.
|
|
16
16
|
* @returns A localized remapper context for the app.
|
|
17
17
|
*/
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -32,5 +32,6 @@ export * from './server/types.js';
|
|
|
32
32
|
export * from './koa.js';
|
|
33
33
|
export { bulmaVersion, faVersion, version } from './versions.cjs';
|
|
34
34
|
export * from './EmailQuotaExceededError.js';
|
|
35
|
+
export * from './EmailError.js';
|
|
35
36
|
export * from './authentication.js';
|
|
36
37
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/node-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "NodeJS utilities used by Appsemble internally.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"test": "vitest"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@appsemble/types": "0.
|
|
42
|
-
"@appsemble/utils": "0.
|
|
41
|
+
"@appsemble/types": "0.24.0",
|
|
42
|
+
"@appsemble/utils": "0.24.0",
|
|
43
43
|
"@formatjs/fast-memoize": "^2.0.0",
|
|
44
44
|
"@fortawesome/fontawesome-free": "^6.0.0",
|
|
45
45
|
"@koa/cors": "^4.0.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertKoaError, getRemapperContext, logger, throwKoaError, version, } from '@appsemble/node-utils';
|
|
2
|
-
import { defaultLocale,
|
|
2
|
+
import { defaultLocale, remap } from '@appsemble/utils';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { get, pick } from 'lodash-es';
|
|
5
5
|
import { EmailQuotaExceededError } from '../../EmailQuotaExceededError.js';
|
|
@@ -50,7 +50,7 @@ async function handleNotify(ctx, app, action, options) {
|
|
|
50
50
|
ctx.status = 204;
|
|
51
51
|
}
|
|
52
52
|
async function handleRequestProxy(ctx, app, action, useBody, options) {
|
|
53
|
-
var _a, _b;
|
|
53
|
+
var _a, _b, _c;
|
|
54
54
|
const { method, query, request: { body, headers }, user, } = ctx;
|
|
55
55
|
let data;
|
|
56
56
|
if (useBody) {
|
|
@@ -73,7 +73,22 @@ async function handleRequestProxy(ctx, app, action, useBody, options) {
|
|
|
73
73
|
email_verified: Boolean((_b = (_a = user.EmailAuthorizations) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.verified),
|
|
74
74
|
zoneinfo: user.timezone,
|
|
75
75
|
}, options, ctx);
|
|
76
|
-
let
|
|
76
|
+
let params;
|
|
77
|
+
try {
|
|
78
|
+
if (query.params) {
|
|
79
|
+
params = JSON.parse(query.params);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throwKoaError(ctx, 400, 'params should be a JSON object.');
|
|
84
|
+
}
|
|
85
|
+
let axiosConfig = {
|
|
86
|
+
method: (_c = action.method) !== null && _c !== void 0 ? _c : 'GET',
|
|
87
|
+
url: String(remap(action.url, data, remapperContext)),
|
|
88
|
+
params,
|
|
89
|
+
responseType: 'arraybuffer',
|
|
90
|
+
headers: {},
|
|
91
|
+
};
|
|
77
92
|
axiosConfig = await applyAppServiceSecrets({ axiosConfig, context: ctx, app });
|
|
78
93
|
if (axiosConfig.method.toUpperCase() !== method) {
|
|
79
94
|
throwKoaError(ctx, 400, 'Method does not match the request action method');
|
package/server/types.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ declare module 'koas-parameters' {
|
|
|
79
79
|
token: string;
|
|
80
80
|
appServiceId: number;
|
|
81
81
|
userId: string;
|
|
82
|
+
memberEmail: string;
|
|
82
83
|
trainingBlockId: number;
|
|
83
84
|
trainingId: number;
|
|
84
85
|
}
|
|
@@ -95,6 +96,7 @@ declare module 'koas-parameters' {
|
|
|
95
96
|
startIndex: number;
|
|
96
97
|
view: string;
|
|
97
98
|
resources: boolean;
|
|
99
|
+
roles: string[];
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
export type Operator = 'and' | 'not' | 'or';
|