@jskit-ai/json-rest-api-core 0.1.84 → 0.1.85
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/package.descriptor.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Object.freeze({
|
|
2
2
|
packageVersion: 1,
|
|
3
3
|
packageId: "@jskit-ai/json-rest-api-core",
|
|
4
|
-
version: "0.1.
|
|
4
|
+
version: "0.1.85",
|
|
5
5
|
kind: "runtime",
|
|
6
6
|
description: "Shared internal json-rest-api host runtime with autofilter, query-projection, and row-policy support.",
|
|
7
7
|
dependsOn: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/json-rest-api-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.85",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"hooked-api": "1.x.x",
|
|
13
|
-
"json-rest-api": "^1.0.
|
|
14
|
-
"@jskit-ai/kernel": "0.1.
|
|
13
|
+
"json-rest-api": "^1.0.27",
|
|
14
|
+
"@jskit-ai/kernel": "0.1.141"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -2,6 +2,7 @@ import { Api } from "hooked-api";
|
|
|
2
2
|
import {
|
|
3
3
|
AutoFilterPlugin,
|
|
4
4
|
QueryProjectionsPlugin,
|
|
5
|
+
REST_API_FIELDSET_ERROR_CODE,
|
|
5
6
|
RestApiKnexPlugin,
|
|
6
7
|
RestApiPlugin,
|
|
7
8
|
RowPolicyPlugin
|
|
@@ -647,9 +648,7 @@ async function returnNullWhenJsonRestResourceMissing(run) {
|
|
|
647
648
|
}
|
|
648
649
|
|
|
649
650
|
function isJsonRestSparseFieldError(error = null) {
|
|
650
|
-
return
|
|
651
|
-
normalizeJsonRestText(error?.message)
|
|
652
|
-
);
|
|
651
|
+
return normalizeJsonRestText(error?.code) === REST_API_FIELDSET_ERROR_CODE;
|
|
653
652
|
}
|
|
654
653
|
|
|
655
654
|
async function returnBadRequestWhenJsonRestFieldsetInvalid(run) {
|
|
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import test from "node:test";
|
|
4
4
|
import { normalizeRecordId } from "@jskit-ai/kernel/shared/support/normalize";
|
|
5
|
+
import { RestApiFieldsetError } from "json-rest-api";
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
INTERNAL_JSON_REST_API,
|
|
@@ -27,7 +28,7 @@ test("package exports include explicit server jsonRestApiHost entrypoint only",
|
|
|
27
28
|
const exportsMap = packageJson && typeof packageJson === "object" ? packageJson.exports : {};
|
|
28
29
|
assert.equal(exportsMap["./server/jsonRestApiHost"], "./src/server/jsonRestApiHost.js");
|
|
29
30
|
assert.equal(exportsMap["./server"], undefined);
|
|
30
|
-
assert.equal(packageJson.dependencies?.["json-rest-api"], "^1.0.
|
|
31
|
+
assert.equal(packageJson.dependencies?.["json-rest-api"], "^1.0.27");
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
test("server jsonRestApiHost entrypoint no longer exports host-side JSON:API simplification helpers", async () => {
|
|
@@ -649,8 +650,11 @@ test("returnNullWhenJsonRestResourceMissing only swallows missing-resource error
|
|
|
649
650
|
);
|
|
650
651
|
});
|
|
651
652
|
|
|
652
|
-
test("invalid sparse fields become a stable 400 without
|
|
653
|
-
const sparseFieldError = new
|
|
653
|
+
test("typed invalid sparse fields become a stable 400 without message matching", async () => {
|
|
654
|
+
const sparseFieldError = new RestApiFieldsetError({
|
|
655
|
+
field: "passwordHash",
|
|
656
|
+
resourceType: "contacts"
|
|
657
|
+
});
|
|
654
658
|
|
|
655
659
|
await assert.rejects(
|
|
656
660
|
() => returnBadRequestWhenJsonRestFieldsetInvalid(async () => {
|
|
@@ -664,6 +668,14 @@ test("invalid sparse fields become a stable 400 without swallowing unrelated fai
|
|
|
664
668
|
}
|
|
665
669
|
);
|
|
666
670
|
|
|
671
|
+
const messageOnlyError = new Error(sparseFieldError.message);
|
|
672
|
+
await assert.rejects(
|
|
673
|
+
() => returnBadRequestWhenJsonRestFieldsetInvalid(async () => {
|
|
674
|
+
throw messageOnlyError;
|
|
675
|
+
}),
|
|
676
|
+
(error) => error === messageOnlyError
|
|
677
|
+
);
|
|
678
|
+
|
|
667
679
|
const unrelatedError = new Error("database unavailable");
|
|
668
680
|
await assert.rejects(
|
|
669
681
|
() => returnBadRequestWhenJsonRestFieldsetInvalid(async () => {
|