@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 CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.23.0/config/assets/logo.svg) Appsemble Node Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.23.2/config/assets/logo.svg) Appsemble Node Utilities
2
2
 
3
3
  > NodeJS utilities used by Appsemble internally.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/node-utils)](https://www.npmjs.com/package/@appsemble/node-utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.23.0/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.23.0)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.23.2/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.23.2)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](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.0/LICENSE.md) ©
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: string, data?: Record<string, any>): void;
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: string, data?: Record<string, any>): void;
69
+ export declare function assertKoaError(condition: boolean, ctx: Context, status: HttpErrorCodes, message?: string, data?: Record<string, any>): void;
package/koa.js CHANGED
@@ -78,7 +78,7 @@ export function throwKoaError(ctx, status, message, data) {
78
78
  ctx.response.status = status;
79
79
  ctx.response.body = {
80
80
  error: errorStatusMap[status],
81
- message,
81
+ message: message || errorStatusMap[status],
82
82
  statusCode: status,
83
83
  data,
84
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/node-utils",
3
- "version": "0.23.0",
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.0",
42
- "@appsemble/utils": "0.23.0",
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 userQuery = await verifyResourceActionPermission({
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
- ...userQuery,
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 userQuery = await verifyResourceActionPermission({
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
- ...userQuery,
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 userQuery = await verifyResourceActionPermission({
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
- ...userQuery,
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 userQuery = await verifyResourceActionPermission({
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
- ...userQuery,
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 userQuery = await verifyResourceActionPermission({
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
- ...userQuery,
245
+ ...memberQuery,
246
246
  id: resourceId,
247
247
  type: resourceType,
248
248
  AppId: appId,