@jskit-ai/json-rest-api-core 0.1.103 → 0.1.104
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.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.104",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"./server/jsonRestApiHost": "./src/server/jsonRestApiHost.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
13
|
-
"@jskit-ai/kernel": "0.1.
|
|
14
|
-
"@jskit-ai/resource-crud-core": "0.1.
|
|
12
|
+
"@jskit-ai/database-runtime": "0.1.160",
|
|
13
|
+
"@jskit-ai/kernel": "0.1.160",
|
|
14
|
+
"@jskit-ai/resource-crud-core": "0.1.102",
|
|
15
15
|
"hooked-api": "1.x.x",
|
|
16
16
|
"json-rest-api": "^1.0.27"
|
|
17
17
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"kind": "runtime",
|
|
21
21
|
"capabilities": {
|
|
22
22
|
"provides": [
|
|
23
|
-
"json-rest-api
|
|
23
|
+
"runtime.json-rest-api"
|
|
24
24
|
],
|
|
25
25
|
"requires": [
|
|
26
26
|
"runtime.database"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"server": {
|
|
31
31
|
"providers": [
|
|
32
32
|
{
|
|
33
|
-
"entrypoint": "src/server/
|
|
34
|
-
"export": "
|
|
33
|
+
"entrypoint": "src/server/JsonRestApiProvider.js",
|
|
34
|
+
"export": "JsonRestApiProvider"
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
37
|
},
|
|
@@ -44,28 +44,10 @@
|
|
|
44
44
|
"surfaces": [
|
|
45
45
|
{
|
|
46
46
|
"subpath": "./server",
|
|
47
|
-
"summary": "
|
|
47
|
+
"summary": "Provides runtime.json-rest-api and exports focused resource/query helpers, including server-only row policies."
|
|
48
48
|
}
|
|
49
|
-
]
|
|
50
|
-
"containerTokens": {
|
|
51
|
-
"server": [
|
|
52
|
-
"internal.json-rest-api"
|
|
53
|
-
],
|
|
54
|
-
"client": []
|
|
55
|
-
}
|
|
49
|
+
]
|
|
56
50
|
}
|
|
57
|
-
},
|
|
58
|
-
"mutations": {
|
|
59
|
-
"dependencies": {
|
|
60
|
-
"runtime": {},
|
|
61
|
-
"dev": {}
|
|
62
|
-
},
|
|
63
|
-
"packageJson": {
|
|
64
|
-
"scripts": {}
|
|
65
|
-
},
|
|
66
|
-
"procfile": {},
|
|
67
|
-
"files": [],
|
|
68
|
-
"text": []
|
|
69
51
|
}
|
|
70
52
|
}
|
|
71
53
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
2
|
+
import { createJsonRestApiHost } from "./jsonRestApiHost.js";
|
|
3
|
+
|
|
4
|
+
const JsonRestApiProvider = defineProvider({
|
|
5
|
+
id: "runtime.json-rest-api",
|
|
6
|
+
requires: {
|
|
7
|
+
database: "runtime.database"
|
|
8
|
+
},
|
|
9
|
+
provides: {
|
|
10
|
+
jsonRestApi: "runtime.json-rest-api"
|
|
11
|
+
},
|
|
12
|
+
async setup({ database }) {
|
|
13
|
+
return {
|
|
14
|
+
jsonRestApi: await createJsonRestApiHost({ knex: database.knex })
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { JsonRestApiProvider };
|
|
@@ -18,8 +18,6 @@ import {
|
|
|
18
18
|
} from "@jskit-ai/kernel/shared/support/jsonApiFieldsets";
|
|
19
19
|
import { AppError } from "@jskit-ai/kernel/server/runtime/errors";
|
|
20
20
|
|
|
21
|
-
const INTERNAL_JSON_REST_API = "internal.json-rest-api";
|
|
22
|
-
|
|
23
21
|
const JSON_REST_AUTOFILTER_PRESETS = Object.freeze({
|
|
24
22
|
public: Object.freeze([]),
|
|
25
23
|
workspace: Object.freeze([
|
|
@@ -837,23 +835,7 @@ async function createJsonRestApiHost({ knex }) {
|
|
|
837
835
|
return api;
|
|
838
836
|
}
|
|
839
837
|
|
|
840
|
-
async function registerJsonRestApiHost(app) {
|
|
841
|
-
if (!app || typeof app.instance !== "function" || typeof app.make !== "function" || typeof app.has !== "function") {
|
|
842
|
-
throw new Error("registerJsonRestApiHost requires application instance()/make()/has().");
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
if (app.has(INTERNAL_JSON_REST_API)) {
|
|
846
|
-
return app.make(INTERNAL_JSON_REST_API);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
const knex = app.make("jskit.database.knex");
|
|
850
|
-
const api = await createJsonRestApiHost({ knex });
|
|
851
|
-
app.instance(INTERNAL_JSON_REST_API, api);
|
|
852
|
-
return api;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
838
|
export {
|
|
856
|
-
INTERNAL_JSON_REST_API,
|
|
857
839
|
JSON_REST_AUTOFILTER_PRESETS,
|
|
858
840
|
addResourceIfMissing,
|
|
859
841
|
buildJsonRestQueryParams,
|
|
@@ -867,6 +849,5 @@ export {
|
|
|
867
849
|
returnBadRequestWhenJsonRestFieldsetInvalid,
|
|
868
850
|
resolveWorkspaceScopeValue,
|
|
869
851
|
resolveUserScopeValue,
|
|
870
|
-
createJsonRestApiHost
|
|
871
|
-
registerJsonRestApiHost
|
|
852
|
+
createJsonRestApiHost
|
|
872
853
|
};
|
|
@@ -6,7 +6,6 @@ import { normalizeRecordId } from "@jskit-ai/kernel/shared/support/normalize";
|
|
|
6
6
|
import { RestApiFieldsetError } from "json-rest-api";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
INTERNAL_JSON_REST_API,
|
|
10
9
|
addResourceIfMissing,
|
|
11
10
|
buildJsonRestQueryParams,
|
|
12
11
|
createJsonApiInputRecord,
|
|
@@ -16,13 +15,12 @@ import {
|
|
|
16
15
|
createJsonRestApiHost,
|
|
17
16
|
extractJsonRestCollectionRows,
|
|
18
17
|
isJsonRestResourceMissingError,
|
|
19
|
-
registerJsonRestApiHost,
|
|
20
18
|
returnNullWhenJsonRestResourceMissing,
|
|
21
19
|
returnBadRequestWhenJsonRestFieldsetInvalid,
|
|
22
20
|
resolveWorkspaceScopeValue,
|
|
23
21
|
resolveUserScopeValue
|
|
24
22
|
} from "../src/server/jsonRestApiHost.js";
|
|
25
|
-
import {
|
|
23
|
+
import { JsonRestApiProvider } from "../src/server/JsonRestApiProvider.js";
|
|
26
24
|
|
|
27
25
|
test("package exports include explicit server jsonRestApiHost entrypoint only", async () => {
|
|
28
26
|
const packageJson = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
@@ -38,7 +36,6 @@ test("server jsonRestApiHost entrypoint exposes only the focused host API", asyn
|
|
|
38
36
|
});
|
|
39
37
|
|
|
40
38
|
test("server entrypoint exports shared host helpers", () => {
|
|
41
|
-
assert.equal(INTERNAL_JSON_REST_API, "internal.json-rest-api");
|
|
42
39
|
assert.equal(typeof addResourceIfMissing, "function");
|
|
43
40
|
assert.equal(typeof buildJsonRestQueryParams, "function");
|
|
44
41
|
assert.equal(typeof createJsonApiInputRecord, "function");
|
|
@@ -48,12 +45,13 @@ test("server entrypoint exports shared host helpers", () => {
|
|
|
48
45
|
assert.equal(typeof createJsonRestApiHost, "function");
|
|
49
46
|
assert.equal(typeof extractJsonRestCollectionRows, "function");
|
|
50
47
|
assert.equal(typeof isJsonRestResourceMissingError, "function");
|
|
51
|
-
assert.equal(typeof registerJsonRestApiHost, "function");
|
|
52
48
|
assert.equal(typeof returnNullWhenJsonRestResourceMissing, "function");
|
|
53
49
|
assert.equal(typeof returnBadRequestWhenJsonRestFieldsetInvalid, "function");
|
|
54
50
|
assert.equal(typeof resolveWorkspaceScopeValue, "function");
|
|
55
51
|
assert.equal(typeof resolveUserScopeValue, "function");
|
|
56
|
-
assert.equal(
|
|
52
|
+
assert.equal(JsonRestApiProvider.id, "runtime.json-rest-api");
|
|
53
|
+
assert.deepEqual(JsonRestApiProvider.requires, { database: "runtime.database" });
|
|
54
|
+
assert.deepEqual(JsonRestApiProvider.provides, { jsonRestApi: "runtime.json-rest-api" });
|
|
57
55
|
});
|
|
58
56
|
|
|
59
57
|
test("createJsonRestContext returns a mutable clone for frozen JSKIT execution context", () => {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { registerJsonRestApiHost } from "./jsonRestApiHost.js";
|
|
2
|
-
|
|
3
|
-
class JsonRestApiCoreServiceProvider {
|
|
4
|
-
static id = "json-rest-api.core";
|
|
5
|
-
|
|
6
|
-
async boot(app) {
|
|
7
|
-
await registerJsonRestApiHost(app);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { JsonRestApiCoreServiceProvider };
|