@jskit-ai/http-runtime 0.1.156 → 0.1.158
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 +8 -30
- package/src/client/providers/HttpClientRuntimeClientProvider.js +11 -12
- package/src/client/providers/HttpValidatorsClientProvider.js +12 -10
- package/src/server/providers/HttpClientProvider.js +16 -0
- package/src/server/providers/HttpValidatorsProvider.js +16 -0
- package/test/entrypoints.boundary.test.js +8 -8
- package/test/providerRuntime.httpClient.test.js +16 -29
- package/test/providerRuntime.validators.test.js +16 -33
- package/src/server/providers/HttpClientRuntimeServiceProvider.js +0 -21
- package/src/server/providers/HttpValidatorsServiceProvider.js +0 -14
- package/src/shared/providers/singletonApiProvider.js +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/http-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.158",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./shared/validators/operationValidation": "./src/shared/validators/operationValidation.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@jskit-ai/kernel": "0.1.
|
|
21
|
+
"@jskit-ai/kernel": "0.1.160",
|
|
22
22
|
"json-rest-schema": "^1.0.17"
|
|
23
23
|
},
|
|
24
24
|
"jskit": {
|
|
@@ -32,15 +32,14 @@
|
|
|
32
32
|
},
|
|
33
33
|
"runtime": {
|
|
34
34
|
"server": {
|
|
35
|
-
"providerEntrypoint": "src/server/providers/HttpValidatorsServiceProvider.js",
|
|
36
35
|
"providers": [
|
|
37
36
|
{
|
|
38
|
-
"entrypoint": "src/server/providers/
|
|
39
|
-
"export": "
|
|
37
|
+
"entrypoint": "src/server/providers/HttpValidatorsProvider.js",
|
|
38
|
+
"export": "HttpValidatorsProvider"
|
|
40
39
|
},
|
|
41
40
|
{
|
|
42
|
-
"entrypoint": "src/server/providers/
|
|
43
|
-
"export": "
|
|
41
|
+
"entrypoint": "src/server/providers/HttpClientProvider.js",
|
|
42
|
+
"export": "HttpClientProvider"
|
|
44
43
|
}
|
|
45
44
|
]
|
|
46
45
|
},
|
|
@@ -66,35 +65,14 @@
|
|
|
66
65
|
},
|
|
67
66
|
{
|
|
68
67
|
"subpath": "./server",
|
|
69
|
-
"summary": "
|
|
68
|
+
"summary": "Provides named HTTP validation and server-side HTTP client capabilities."
|
|
70
69
|
},
|
|
71
70
|
{
|
|
72
71
|
"subpath": "./shared",
|
|
73
72
|
"summary": "Exports HTTP validator/schema utilities, with structured validator subpaths under ./shared/validators/*."
|
|
74
73
|
}
|
|
75
|
-
]
|
|
76
|
-
"containerTokens": {
|
|
77
|
-
"server": [
|
|
78
|
-
"runtime.http-client"
|
|
79
|
-
],
|
|
80
|
-
"client": [
|
|
81
|
-
"runtime.http-client.client"
|
|
82
|
-
]
|
|
83
|
-
}
|
|
74
|
+
]
|
|
84
75
|
}
|
|
85
|
-
},
|
|
86
|
-
"mutations": {
|
|
87
|
-
"dependencies": {
|
|
88
|
-
"runtime": {
|
|
89
|
-
"@jskit-ai/kernel": "0.1.158"
|
|
90
|
-
},
|
|
91
|
-
"dev": {}
|
|
92
|
-
},
|
|
93
|
-
"packageJson": {
|
|
94
|
-
"scripts": {}
|
|
95
|
-
},
|
|
96
|
-
"procfile": {},
|
|
97
|
-
"files": []
|
|
98
76
|
}
|
|
99
77
|
}
|
|
100
78
|
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
1
2
|
import * as httpClientRuntime from "../../shared/clientRuntime/index.js";
|
|
2
3
|
|
|
3
4
|
const HTTP_CLIENT_RUNTIME_CLIENT_API = Object.freeze({
|
|
4
5
|
...httpClientRuntime
|
|
5
6
|
});
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
const HttpClientRuntimeClientProvider = defineProvider({
|
|
9
|
+
id: "runtime.http-client.client",
|
|
10
|
+
provides: {
|
|
11
|
+
httpClient: "runtime.http-client.client"
|
|
12
|
+
},
|
|
13
|
+
setup() {
|
|
14
|
+
return {
|
|
15
|
+
httpClient: HTTP_CLIENT_RUNTIME_CLIENT_API
|
|
16
|
+
};
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
boot() {}
|
|
19
|
-
}
|
|
18
|
+
});
|
|
20
19
|
|
|
21
20
|
export { HttpClientRuntimeClientProvider };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
2
2
|
import { HTTP_VALIDATORS_API } from "../../shared/validators/httpValidatorsApi.js";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
4
|
+
const HttpValidatorsClientProvider = defineProvider({
|
|
5
|
+
id: "validators.http.client",
|
|
6
|
+
provides: {
|
|
7
|
+
validators: "validators.http.client"
|
|
8
|
+
},
|
|
9
|
+
setup() {
|
|
10
|
+
return {
|
|
11
|
+
validators: HTTP_VALIDATORS_API
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
13
15
|
|
|
14
16
|
export { HttpValidatorsClientProvider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
2
|
+
import * as httpClient from "../../shared/clientRuntime/index.js";
|
|
3
|
+
|
|
4
|
+
const HttpClientProvider = defineProvider({
|
|
5
|
+
id: "runtime.http-client",
|
|
6
|
+
provides: {
|
|
7
|
+
httpClient: "runtime.http-client"
|
|
8
|
+
},
|
|
9
|
+
setup() {
|
|
10
|
+
return {
|
|
11
|
+
httpClient: Object.freeze({ ...httpClient })
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { HttpClientProvider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
2
|
+
import { HTTP_VALIDATORS_API } from "../../shared/validators/httpValidatorsApi.js";
|
|
3
|
+
|
|
4
|
+
const HttpValidatorsProvider = defineProvider({
|
|
5
|
+
id: "validators.http",
|
|
6
|
+
provides: {
|
|
7
|
+
validators: "validators.http"
|
|
8
|
+
},
|
|
9
|
+
setup() {
|
|
10
|
+
return {
|
|
11
|
+
validators: HTTP_VALIDATORS_API
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { HttpValidatorsProvider };
|
|
@@ -4,8 +4,8 @@ import test from "node:test";
|
|
|
4
4
|
|
|
5
5
|
import * as clientApi from "../src/client/index.js";
|
|
6
6
|
import * as sharedApi from "../src/shared/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { HttpValidatorsProvider } from "../src/server/providers/HttpValidatorsProvider.js";
|
|
8
|
+
import { HttpClientProvider } from "../src/server/providers/HttpClientProvider.js";
|
|
9
9
|
|
|
10
10
|
test("package exports include explicit shared entrypoint and no server barrel", async () => {
|
|
11
11
|
const packageJson = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
@@ -17,14 +17,14 @@ test("package exports include explicit shared entrypoint and no server barrel",
|
|
|
17
17
|
test("client entrypoint exports client runtime helpers and client providers only", () => {
|
|
18
18
|
assert.equal(typeof clientApi.createHttpClient, "function");
|
|
19
19
|
assert.equal(typeof clientApi.createTransientRetryHttpClient, "function");
|
|
20
|
-
assert.equal(
|
|
21
|
-
assert.equal(
|
|
20
|
+
assert.equal(clientApi.HttpValidatorsClientProvider.id, "validators.http.client");
|
|
21
|
+
assert.equal(clientApi.HttpClientRuntimeClientProvider.id, "runtime.http-client.client");
|
|
22
22
|
assert.equal(typeof clientApi.withStandardErrorResponses, "undefined");
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
test("server provider modules export
|
|
26
|
-
assert.equal(
|
|
27
|
-
assert.equal(
|
|
25
|
+
test("server provider modules export declarative providers only", () => {
|
|
26
|
+
assert.equal(HttpValidatorsProvider.id, "validators.http");
|
|
27
|
+
assert.equal(HttpClientProvider.id, "runtime.http-client");
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
test("shared entrypoint exports shared validators only", () => {
|
|
@@ -41,5 +41,5 @@ test("shared entrypoint exports shared validators only", () => {
|
|
|
41
41
|
assert.equal(typeof sharedApi.createJsonApiResourceRouteContract, "function");
|
|
42
42
|
assert.equal(typeof sharedApi.withJsonApiErrorResponses, "function");
|
|
43
43
|
assert.equal(typeof sharedApi.createHttpClient, "undefined");
|
|
44
|
-
assert.equal(typeof sharedApi.
|
|
44
|
+
assert.equal(typeof sharedApi.HttpValidatorsProvider, "undefined");
|
|
45
45
|
});
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { createCapabilityRuntime, defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
5
|
+
import { HttpClientProvider } from "../src/server/providers/HttpClientProvider.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
test("HttpClientProvider provides the server HTTP client API", async () => {
|
|
8
|
+
let httpClient;
|
|
9
|
+
const consumer = defineProvider({
|
|
10
|
+
id: "test.http-client.consumer",
|
|
11
|
+
requires: { value: "runtime.http-client" },
|
|
12
|
+
setup({ value }) {
|
|
13
|
+
httpClient = value;
|
|
14
|
+
return {};
|
|
13
15
|
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
provider.register(app);
|
|
21
|
-
|
|
22
|
-
assert.equal(app.singletons.has("runtime.http-client"), true);
|
|
23
|
-
const api = app.singletons.get("runtime.http-client");
|
|
24
|
-
assert.equal(typeof api.createHttpClient, "function");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("HttpClientRuntimeClientProvider registers client http client api", () => {
|
|
28
|
-
const app = createSingletonApp();
|
|
29
|
-
const provider = new HttpClientRuntimeClientProvider();
|
|
30
|
-
provider.register(app);
|
|
31
|
-
|
|
32
|
-
assert.equal(app.singletons.has("runtime.http-client.client"), true);
|
|
33
|
-
const api = app.singletons.get("runtime.http-client.client");
|
|
34
|
-
assert.equal(typeof api.createHttpClient, "function");
|
|
16
|
+
});
|
|
17
|
+
const runtime = createCapabilityRuntime({ providers: [HttpClientProvider, consumer] });
|
|
18
|
+
await runtime.start();
|
|
19
|
+
assert.equal(typeof httpClient.createHttpClient, "function");
|
|
20
|
+
assert.equal(typeof httpClient.shouldRetryForCsrfFailure, "function");
|
|
21
|
+
await runtime.shutdown();
|
|
35
22
|
});
|
|
@@ -1,39 +1,22 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { createCapabilityRuntime, defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
5
|
+
import { HttpValidatorsProvider } from "../src/server/providers/HttpValidatorsProvider.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
test("HttpValidatorsProvider provides the shared validator API", async () => {
|
|
8
|
+
let validators;
|
|
9
|
+
const consumer = defineProvider({
|
|
10
|
+
id: "test.http-validators.consumer",
|
|
11
|
+
requires: { value: "validators.http" },
|
|
12
|
+
setup({ value }) {
|
|
13
|
+
validators = value;
|
|
14
|
+
return {};
|
|
13
15
|
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
provider.register(app);
|
|
21
|
-
|
|
22
|
-
assert.equal(app.singletons.has("validators.http"), true);
|
|
23
|
-
const api = app.singletons.get("validators.http");
|
|
24
|
-
assert.equal(typeof api.withStandardErrorResponses, "function");
|
|
25
|
-
assert.equal(typeof api.createResource, "function");
|
|
26
|
-
assert.equal(typeof api.createCommand, "function");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("HttpValidatorsClientProvider registers client validators api", () => {
|
|
30
|
-
const app = createSingletonApp();
|
|
31
|
-
const provider = new HttpValidatorsClientProvider();
|
|
32
|
-
provider.register(app);
|
|
33
|
-
|
|
34
|
-
assert.equal(app.singletons.has("validators.http.client"), true);
|
|
35
|
-
const api = app.singletons.get("validators.http.client");
|
|
36
|
-
assert.equal(typeof api.withStandardErrorResponses, "function");
|
|
37
|
-
assert.equal(typeof api.createResource, "function");
|
|
38
|
-
assert.equal(typeof api.createCommand, "function");
|
|
16
|
+
});
|
|
17
|
+
const runtime = createCapabilityRuntime({ providers: [HttpValidatorsProvider, consumer] });
|
|
18
|
+
await runtime.start();
|
|
19
|
+
assert.equal(typeof validators.enumSchema, "function");
|
|
20
|
+
assert.equal(typeof validators.createResource, "function");
|
|
21
|
+
await runtime.shutdown();
|
|
39
22
|
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as httpClientRuntime from "../../shared/clientRuntime/index.js";
|
|
2
|
-
|
|
3
|
-
const HTTP_CLIENT_RUNTIME_API = Object.freeze({
|
|
4
|
-
...httpClientRuntime
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
class HttpClientRuntimeServiceProvider {
|
|
8
|
-
static id = "runtime.http-client";
|
|
9
|
-
|
|
10
|
-
register(app) {
|
|
11
|
-
if (!app || typeof app.singleton !== "function") {
|
|
12
|
-
throw new Error("HttpClientRuntimeServiceProvider requires application singleton().");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
app.singleton("runtime.http-client", () => HTTP_CLIENT_RUNTIME_API);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
boot() {}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { HttpClientRuntimeServiceProvider };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SingletonApiProvider } from "../../shared/providers/singletonApiProvider.js";
|
|
2
|
-
import { HTTP_VALIDATORS_API } from "../../shared/validators/httpValidatorsApi.js";
|
|
3
|
-
|
|
4
|
-
class HttpValidatorsServiceProvider extends SingletonApiProvider {
|
|
5
|
-
static id = "validators.http";
|
|
6
|
-
|
|
7
|
-
static bindingToken = "validators.http";
|
|
8
|
-
|
|
9
|
-
static api = HTTP_VALIDATORS_API;
|
|
10
|
-
|
|
11
|
-
static providerName = "HttpValidatorsServiceProvider";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { HttpValidatorsServiceProvider };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class SingletonApiProvider {
|
|
2
|
-
static bindingToken = "";
|
|
3
|
-
|
|
4
|
-
static api = null;
|
|
5
|
-
|
|
6
|
-
static providerName = "SingletonApiProvider";
|
|
7
|
-
|
|
8
|
-
register(app) {
|
|
9
|
-
if (!app || typeof app.singleton !== "function") {
|
|
10
|
-
throw new Error(`${this.constructor.providerName} requires application singleton().`);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const bindingToken = String(this.constructor.bindingToken || "").trim();
|
|
14
|
-
if (!bindingToken) {
|
|
15
|
-
throw new Error(`${this.constructor.providerName} requires static bindingToken.`);
|
|
16
|
-
}
|
|
17
|
-
if (!this.constructor.api || typeof this.constructor.api !== "object") {
|
|
18
|
-
throw new Error(`${this.constructor.providerName} requires static api object.`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
app.singleton(bindingToken, () => this.constructor.api);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
boot() {}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { SingletonApiProvider };
|