@appsemble/node-utils 0.23.0 → 0.23.2
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/README.md +3 -3
- package/koa.d.ts +2 -2
- package/koa.js +1 -1
- package/package.json +3 -3
- package/server/controllers/resources.js +10 -10
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.23.2)
|
|
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.23.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.23.2/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/koa.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ type HttpErrorCodes = keyof typeof errorStatusMap;
|
|
|
56
56
|
* @param message The message for in the response body.
|
|
57
57
|
* @param data Optional data to include.
|
|
58
58
|
*/
|
|
59
|
-
export declare function throwKoaError(ctx: Context, status: HttpErrorCodes, message
|
|
59
|
+
export declare function throwKoaError(ctx: Context, status: HttpErrorCodes, message?: string, data?: Record<string, any>): void;
|
|
60
60
|
/**
|
|
61
61
|
* Throw standard Koa error response when condition is met.
|
|
62
62
|
*
|
|
@@ -66,4 +66,4 @@ export declare function throwKoaError(ctx: Context, status: HttpErrorCodes, mess
|
|
|
66
66
|
* @param message The message for in the response body.
|
|
67
67
|
* @param data Optional data to include.
|
|
68
68
|
*/
|
|
69
|
-
export declare function assertKoaError(condition: boolean, ctx: Context, status: HttpErrorCodes, message
|
|
69
|
+
export declare function assertKoaError(condition: boolean, ctx: Context, status: HttpErrorCodes, message?: string, data?: Record<string, any>): void;
|
package/koa.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/node-utils",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
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.23.
|
|
42
|
-
"@appsemble/utils": "0.23.
|
|
41
|
+
"@appsemble/types": "0.23.2",
|
|
42
|
+
"@appsemble/utils": "0.23.2",
|
|
43
43
|
"@formatjs/fast-memoize": "^2.0.0",
|
|
44
44
|
"@fortawesome/fontawesome-free": "^6.0.0",
|
|
45
45
|
"@koa/cors": "^4.0.0",
|
|
@@ -19,7 +19,7 @@ export function createQueryResources(options) {
|
|
|
19
19
|
const { getApp, getAppResources, verifyResourceActionPermission } = options;
|
|
20
20
|
const app = await getApp({ context: ctx, query: { where: { id: appId } } });
|
|
21
21
|
const { order, where } = generateQuery(ctx, options);
|
|
22
|
-
const
|
|
22
|
+
const memberQuery = await verifyResourceActionPermission({
|
|
23
23
|
context: ctx,
|
|
24
24
|
app,
|
|
25
25
|
resourceType,
|
|
@@ -35,7 +35,7 @@ export function createQueryResources(options) {
|
|
|
35
35
|
and: [
|
|
36
36
|
where,
|
|
37
37
|
{
|
|
38
|
-
...
|
|
38
|
+
...memberQuery,
|
|
39
39
|
type: resourceType,
|
|
40
40
|
AppId: appId,
|
|
41
41
|
expires: { or: [{ gt: new Date() }, null] },
|
|
@@ -72,7 +72,7 @@ export function createCountResources(options) {
|
|
|
72
72
|
const action = 'count';
|
|
73
73
|
const { getApp, getAppResources, verifyResourceActionPermission } = options;
|
|
74
74
|
const app = await getApp({ context: ctx, query: { where: { id: appId } } });
|
|
75
|
-
const
|
|
75
|
+
const memberQuery = await verifyResourceActionPermission({
|
|
76
76
|
app,
|
|
77
77
|
context: ctx,
|
|
78
78
|
action,
|
|
@@ -86,7 +86,7 @@ export function createCountResources(options) {
|
|
|
86
86
|
and: [
|
|
87
87
|
where || {},
|
|
88
88
|
{
|
|
89
|
-
...
|
|
89
|
+
...memberQuery,
|
|
90
90
|
type: resourceType,
|
|
91
91
|
AppId: appId,
|
|
92
92
|
expires: { or: [{ gt: new Date() }, null] },
|
|
@@ -112,7 +112,7 @@ export function createGetResourceById(options) {
|
|
|
112
112
|
const app = await getApp({ context: ctx, query: { where: { id: appId } } });
|
|
113
113
|
const view = (_a = ctx.queryParams) === null || _a === void 0 ? void 0 : _a.view;
|
|
114
114
|
const resourceDefinition = getResourceDefinition(app, resourceType, ctx, view);
|
|
115
|
-
const
|
|
115
|
+
const memberQuery = await verifyResourceActionPermission({
|
|
116
116
|
app,
|
|
117
117
|
context: ctx,
|
|
118
118
|
action,
|
|
@@ -122,7 +122,7 @@ export function createGetResourceById(options) {
|
|
|
122
122
|
});
|
|
123
123
|
const findOptions = {
|
|
124
124
|
where: {
|
|
125
|
-
...
|
|
125
|
+
...memberQuery,
|
|
126
126
|
id: resourceId,
|
|
127
127
|
type: resourceType,
|
|
128
128
|
AppId: appId,
|
|
@@ -184,7 +184,7 @@ export function createUpdateResource(options) {
|
|
|
184
184
|
const action = 'update';
|
|
185
185
|
const app = await getApp({ context: ctx, query: { where: { id: appId } } });
|
|
186
186
|
const resourceDefinition = getResourceDefinition(app, resourceType, ctx);
|
|
187
|
-
const
|
|
187
|
+
const memberQuery = await verifyResourceActionPermission({
|
|
188
188
|
app,
|
|
189
189
|
context: ctx,
|
|
190
190
|
action,
|
|
@@ -194,7 +194,7 @@ export function createUpdateResource(options) {
|
|
|
194
194
|
});
|
|
195
195
|
const findOptions = {
|
|
196
196
|
where: {
|
|
197
|
-
...
|
|
197
|
+
...memberQuery,
|
|
198
198
|
id: resourceId,
|
|
199
199
|
type: resourceType,
|
|
200
200
|
AppId: appId,
|
|
@@ -232,7 +232,7 @@ export function createDeleteResource(options) {
|
|
|
232
232
|
const { deleteAppResource, getApp, getAppResource, verifyResourceActionPermission } = options;
|
|
233
233
|
const action = 'delete';
|
|
234
234
|
const app = await getApp({ context: ctx, query: { where: { id: appId } } });
|
|
235
|
-
const
|
|
235
|
+
const memberQuery = await verifyResourceActionPermission({
|
|
236
236
|
app,
|
|
237
237
|
context: ctx,
|
|
238
238
|
action,
|
|
@@ -242,7 +242,7 @@ export function createDeleteResource(options) {
|
|
|
242
242
|
});
|
|
243
243
|
const findOptions = {
|
|
244
244
|
where: {
|
|
245
|
-
...
|
|
245
|
+
...memberQuery,
|
|
246
246
|
id: resourceId,
|
|
247
247
|
type: resourceType,
|
|
248
248
|
AppId: appId,
|