@jskit-ai/http-runtime 0.1.157 → 0.1.159

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/http-runtime",
3
- "version": "0.1.157",
3
+ "version": "0.1.159",
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.159",
21
+ "@jskit-ai/kernel": "0.1.161",
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/HttpValidatorsServiceProvider.js",
39
- "export": "HttpValidatorsServiceProvider"
37
+ "entrypoint": "src/server/providers/HttpValidatorsProvider.js",
38
+ "export": "HttpValidatorsProvider"
40
39
  },
41
40
  {
42
- "entrypoint": "src/server/providers/HttpClientRuntimeServiceProvider.js",
43
- "export": "HttpClientRuntimeServiceProvider"
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": "Exports service providers only (HttpValidatorsServiceProvider, HttpClientRuntimeServiceProvider)."
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.159"
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
- class HttpClientRuntimeClientProvider {
8
- static id = "runtime.http-client.client";
9
-
10
- register(app) {
11
- if (!app || typeof app.singleton !== "function") {
12
- throw new Error("HttpClientRuntimeClientProvider requires application singleton().");
13
- }
14
-
15
- app.singleton("runtime.http-client.client", () => HTTP_CLIENT_RUNTIME_CLIENT_API);
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 { SingletonApiProvider } from "../../shared/providers/singletonApiProvider.js";
1
+ import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
2
2
  import { HTTP_VALIDATORS_API } from "../../shared/validators/httpValidatorsApi.js";
3
3
 
4
- class HttpValidatorsClientProvider extends SingletonApiProvider {
5
- static id = "validators.http.client";
6
-
7
- static bindingToken = "validators.http.client";
8
-
9
- static api = HTTP_VALIDATORS_API;
10
-
11
- static providerName = "HttpValidatorsClientProvider";
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 { HttpValidatorsServiceProvider } from "../src/server/providers/HttpValidatorsServiceProvider.js";
8
- import { HttpClientRuntimeServiceProvider } from "../src/server/providers/HttpClientRuntimeServiceProvider.js";
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(typeof clientApi.HttpValidatorsClientProvider, "function");
21
- assert.equal(typeof clientApi.HttpClientRuntimeClientProvider, "function");
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 server providers only", () => {
26
- assert.equal(typeof HttpValidatorsServiceProvider, "function");
27
- assert.equal(typeof HttpClientRuntimeServiceProvider, "function");
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.HttpValidatorsServiceProvider, "undefined");
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 { HttpClientRuntimeServiceProvider } from "../src/server/providers/HttpClientRuntimeServiceProvider.js";
5
- import { HttpClientRuntimeClientProvider } from "../src/client/providers/HttpClientRuntimeClientProvider.js";
4
+ import { createCapabilityRuntime, defineProvider } from "@jskit-ai/kernel/shared/capabilities";
5
+ import { HttpClientProvider } from "../src/server/providers/HttpClientProvider.js";
6
6
 
7
- function createSingletonApp() {
8
- const singletons = new Map();
9
- return {
10
- singletons,
11
- singleton(token, factory) {
12
- singletons.set(token, factory(this));
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
- test("HttpClientRuntimeServiceProvider registers runtime http client api", () => {
18
- const app = createSingletonApp();
19
- const provider = new HttpClientRuntimeServiceProvider();
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 { HttpValidatorsServiceProvider } from "../src/server/providers/HttpValidatorsServiceProvider.js";
5
- import { HttpValidatorsClientProvider } from "../src/client/providers/HttpValidatorsClientProvider.js";
4
+ import { createCapabilityRuntime, defineProvider } from "@jskit-ai/kernel/shared/capabilities";
5
+ import { HttpValidatorsProvider } from "../src/server/providers/HttpValidatorsProvider.js";
6
6
 
7
- function createSingletonApp() {
8
- const singletons = new Map();
9
- return {
10
- singletons,
11
- singleton(token, factory) {
12
- singletons.set(token, factory(this));
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
- test("HttpValidatorsServiceProvider registers shared validators api", () => {
18
- const app = createSingletonApp();
19
- const provider = new HttpValidatorsServiceProvider();
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 };