@appsemble/node-utils 0.28.13 → 0.29.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.
Files changed (4) hide show
  1. package/README.md +3 -3
  2. package/package.json +3 -3
  3. package/scim.d.ts +12 -18
  4. package/scim.js +18 -20
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.28.13/config/assets/logo.svg) Appsemble Node Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.29.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.28.13/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.28.13)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.29.2/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.29.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.28.13/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.29.2/LICENSE.md) ©
30
30
  [Appsemble](https://appsemble.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/node-utils",
3
- "version": "0.28.13",
3
+ "version": "0.29.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.28.13",
42
- "@appsemble/utils": "0.28.13",
41
+ "@appsemble/types": "0.29.2",
42
+ "@appsemble/utils": "0.29.2",
43
43
  "@formatjs/fast-memoize": "^2.0.0",
44
44
  "@fortawesome/fontawesome-free": "^6.0.0",
45
45
  "@koa/cors": "^4.0.0",
package/scim.d.ts CHANGED
@@ -1,26 +1,20 @@
1
+ import { type Context } from 'koa';
1
2
  /**
2
3
  * The SCIM protocol uses the HTTP response status codes defined in
3
4
  * [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6) to indicate
4
- * operation success or failure. In addition to returning an HTTP response code, implementers
5
+ * operation success or failure.
6
+ *
7
+ * In addition to returning an HTTP response code, implementers
5
8
  * **MUST** return the errors in the body of the response in a JSON format, using the attributes
6
- * described below. Error responses are identified using the following "schema" URI:
9
+ * described below.
10
+ *
11
+ * Error responses are identified using the following "schema" URI:
7
12
  * `"urn:ietf:params:scim:api:messages:2.0:Error"`.
8
13
  *
14
+ * @param condition The condition to check.
15
+ * @param ctx The Koa context used to throw the error response.
16
+ * @param status The HTTP status code (see [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6)) expressed as a JSON string.
17
+ * @param detail A detailed human-readable message.
9
18
  * @see https://datatracker.ietf.org/doc/html/rfc7644#section-3.12
10
19
  */
11
- export declare class SCIMError extends Error {
12
- schemas: string[];
13
- /**
14
- * The HTTP status code (see
15
- * [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6)) expressed as
16
- * a JSON string.
17
- */
18
- status: string;
19
- /**
20
- * A detailed human-readable message.
21
- */
22
- detail: string;
23
- constructor(status: number, detail: string);
24
- toJSON(): Pick<SCIMError, 'detail' | 'schemas' | 'status'>;
25
- }
26
- export declare function scimAssert(condition: unknown, status: number, detail: string): asserts condition;
20
+ export declare function scimAssert(condition: unknown, ctx: Context, status: number, detail: string): asserts condition;
package/scim.js CHANGED
@@ -1,32 +1,30 @@
1
1
  /**
2
2
  * The SCIM protocol uses the HTTP response status codes defined in
3
3
  * [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6) to indicate
4
- * operation success or failure. In addition to returning an HTTP response code, implementers
4
+ * operation success or failure.
5
+ *
6
+ * In addition to returning an HTTP response code, implementers
5
7
  * **MUST** return the errors in the body of the response in a JSON format, using the attributes
6
- * described below. Error responses are identified using the following "schema" URI:
8
+ * described below.
9
+ *
10
+ * Error responses are identified using the following "schema" URI:
7
11
  * `"urn:ietf:params:scim:api:messages:2.0:Error"`.
8
12
  *
13
+ * @param condition The condition to check.
14
+ * @param ctx The Koa context used to throw the error response.
15
+ * @param status The HTTP status code (see [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6)) expressed as a JSON string.
16
+ * @param detail A detailed human-readable message.
9
17
  * @see https://datatracker.ietf.org/doc/html/rfc7644#section-3.12
10
18
  */
11
- export class SCIMError extends Error {
12
- constructor(status, detail) {
13
- super(detail);
14
- this.schemas = ['urn:ietf:params:scim:api:messages:2.0:Error'];
15
- this.detail = detail;
16
- this.name = 'SCIMError';
17
- this.status = String(status);
18
- }
19
- toJSON() {
20
- return {
21
- detail: this.detail,
22
- schemas: this.schemas,
23
- status: this.status,
24
- };
25
- }
26
- }
27
- export function scimAssert(condition, status, detail) {
19
+ export function scimAssert(condition, ctx, status, detail) {
28
20
  if (!condition) {
29
- throw new SCIMError(status, detail);
21
+ ctx.status = status;
22
+ ctx.body = {
23
+ detail,
24
+ schemas: ['urn:ietf:params:scim:api:messages:2.0:Error'],
25
+ status,
26
+ };
27
+ ctx.throw();
30
28
  }
31
29
  }
32
30
  //# sourceMappingURL=scim.js.map