@jskit-ai/http-runtime 0.1.4

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 (38) hide show
  1. package/package.descriptor.mjs +83 -0
  2. package/package.json +24 -0
  3. package/src/client/index.js +14 -0
  4. package/src/client/providers/HttpClientRuntimeClientProvider.js +21 -0
  5. package/src/client/providers/HttpValidatorsClientProvider.js +14 -0
  6. package/src/client/validationErrors.js +23 -0
  7. package/src/server/providers/HttpClientRuntimeServiceProvider.js +21 -0
  8. package/src/server/providers/HttpValidatorsServiceProvider.js +14 -0
  9. package/src/shared/clientRuntime/client.js +632 -0
  10. package/src/shared/clientRuntime/errors.js +35 -0
  11. package/src/shared/clientRuntime/headers.js +28 -0
  12. package/src/shared/clientRuntime/index.js +4 -0
  13. package/src/shared/clientRuntime/retry.js +38 -0
  14. package/src/shared/index.js +30 -0
  15. package/src/shared/providers/singletonApiProvider.js +27 -0
  16. package/src/shared/support/fieldErrors.js +31 -0
  17. package/src/shared/validators/command.js +34 -0
  18. package/src/shared/validators/errorResponses.js +108 -0
  19. package/src/shared/validators/httpValidatorsApi.js +58 -0
  20. package/src/shared/validators/operationMessages.js +149 -0
  21. package/src/shared/validators/operationValidation.js +126 -0
  22. package/src/shared/validators/paginationQuery.js +32 -0
  23. package/src/shared/validators/resource.js +43 -0
  24. package/src/shared/validators/schemaUtils.js +9 -0
  25. package/src/shared/validators/typeboxFormats.js +43 -0
  26. package/test/client.test.js +246 -0
  27. package/test/command.test.js +49 -0
  28. package/test/entrypoints.boundary.test.js +36 -0
  29. package/test/errorResponses.test.js +84 -0
  30. package/test/operationMessages.test.js +93 -0
  31. package/test/operationValidation.test.js +137 -0
  32. package/test/paginationQuery.test.js +32 -0
  33. package/test/providerRuntime.httpClient.test.js +35 -0
  34. package/test/providerRuntime.validators.test.js +39 -0
  35. package/test/resource.test.js +94 -0
  36. package/test/retry.test.js +41 -0
  37. package/test/typeboxFormats.test.js +42 -0
  38. package/test/validationErrors.test.js +100 -0
@@ -0,0 +1,83 @@
1
+ export default Object.freeze({
2
+ "packageVersion": 1,
3
+ "packageId": "@jskit-ai/http-runtime",
4
+ "version": "0.1.4",
5
+ "dependsOn": [],
6
+ "capabilities": {
7
+ "provides": [
8
+ "validators.http",
9
+ "runtime.http-client"
10
+ ],
11
+ "requires": []
12
+ },
13
+ "runtime": {
14
+ "server": {
15
+ "providerEntrypoint": "src/server/providers/HttpValidatorsServiceProvider.js",
16
+ "providers": [
17
+ {
18
+ "entrypoint": "src/server/providers/HttpValidatorsServiceProvider.js",
19
+ "export": "HttpValidatorsServiceProvider"
20
+ },
21
+ {
22
+ "entrypoint": "src/server/providers/HttpClientRuntimeServiceProvider.js",
23
+ "export": "HttpClientRuntimeServiceProvider"
24
+ }
25
+ ]
26
+ },
27
+ "client": {
28
+ "providers": [
29
+ {
30
+ "entrypoint": "src/client/providers/HttpValidatorsClientProvider.js",
31
+ "export": "HttpValidatorsClientProvider"
32
+ },
33
+ {
34
+ "entrypoint": "src/client/providers/HttpClientRuntimeClientProvider.js",
35
+ "export": "HttpClientRuntimeClientProvider"
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ "metadata": {
41
+ "apiSummary": {
42
+ "surfaces": [
43
+ {
44
+ "subpath": "./client",
45
+ "summary": "Exports HTTP client runtime APIs (createHttpClient and transport helpers) plus client providers."
46
+ },
47
+ {
48
+ "subpath": "./server",
49
+ "summary": "Exports service providers only (HttpValidatorsServiceProvider, HttpClientRuntimeServiceProvider)."
50
+ },
51
+ {
52
+ "subpath": "./shared",
53
+ "summary": "Exports HTTP validator/schema utilities, with structured validator subpaths under ./shared/validators/*."
54
+ }
55
+ ],
56
+ "containerTokens": {
57
+ "server": [
58
+ "validators.http",
59
+ "runtime.http-client"
60
+ ],
61
+ "client": [
62
+ "validators.http.client",
63
+ "runtime.http-client.client"
64
+ ]
65
+ }
66
+ }
67
+ },
68
+ "mutations": {
69
+ "dependencies": {
70
+ "runtime": {
71
+ "@jskit-ai/kernel": "0.1.4",
72
+ "@fastify/type-provider-typebox": "^6.1.0",
73
+ "typebox": "^1.0.81"
74
+ },
75
+ "dev": {}
76
+ },
77
+ "packageJson": {
78
+ "scripts": {}
79
+ },
80
+ "procfile": {},
81
+ "files": []
82
+ }
83
+ });
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@jskit-ai/http-runtime",
3
+ "version": "0.1.4",
4
+ "type": "module",
5
+ "scripts": {
6
+ "test": "node --test"
7
+ },
8
+ "exports": {
9
+ "./client": "./src/client/index.js",
10
+ "./shared": "./src/shared/index.js",
11
+ "./shared/validators/errorResponses": "./src/shared/validators/errorResponses.js",
12
+ "./shared/validators/paginationQuery": "./src/shared/validators/paginationQuery.js",
13
+ "./shared/validators/command": "./src/shared/validators/command.js",
14
+ "./shared/validators/resource": "./src/shared/validators/resource.js",
15
+ "./shared/validators/typeboxFormats": "./src/shared/validators/typeboxFormats.js",
16
+ "./shared/validators/operationMessages": "./src/shared/validators/operationMessages.js",
17
+ "./shared/validators/operationValidation": "./src/shared/validators/operationValidation.js"
18
+ },
19
+ "dependencies": {
20
+ "@jskit-ai/kernel": "0.1.4",
21
+ "@fastify/type-provider-typebox": "^6.1.0",
22
+ "typebox": "^1.0.81"
23
+ }
24
+ }
@@ -0,0 +1,14 @@
1
+ export { createHttpClient } from "../shared/clientRuntime/client.js";
2
+ export {
3
+ normalizeFieldErrors,
4
+ resolveFieldErrors,
5
+ createValidationFailure
6
+ } from "./validationErrors.js";
7
+ export {
8
+ createHttpError,
9
+ createNetworkError
10
+ } from "../shared/clientRuntime/errors.js";
11
+ export { DEFAULT_RETRYABLE_CSRF_ERROR_CODES, shouldRetryForCsrfFailure } from "../shared/clientRuntime/retry.js";
12
+ export { normalizeHeaderName, hasHeader, setHeaderIfMissing } from "../shared/clientRuntime/headers.js";
13
+ export { HttpValidatorsClientProvider } from "./providers/HttpValidatorsClientProvider.js";
14
+ export { HttpClientRuntimeClientProvider } from "./providers/HttpClientRuntimeClientProvider.js";
@@ -0,0 +1,21 @@
1
+ import * as httpClientRuntime from "../../shared/clientRuntime/index.js";
2
+
3
+ const HTTP_CLIENT_RUNTIME_CLIENT_API = Object.freeze({
4
+ ...httpClientRuntime
5
+ });
6
+
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);
16
+ }
17
+
18
+ boot() {}
19
+ }
20
+
21
+ export { HttpClientRuntimeClientProvider };
@@ -0,0 +1,14 @@
1
+ import { SingletonApiProvider } from "../../shared/providers/singletonApiProvider.js";
2
+ import { HTTP_VALIDATORS_API } from "../../shared/validators/httpValidatorsApi.js";
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
+ }
13
+
14
+ export { HttpValidatorsClientProvider };
@@ -0,0 +1,23 @@
1
+ import { resolveFieldErrors, normalizeFieldErrors } from "../shared/support/fieldErrors.js";
2
+
3
+ function createValidationFailure({
4
+ error = "Validation failed.",
5
+ code = "validation_failed",
6
+ fieldErrors = {}
7
+ } = {}) {
8
+ const normalizedFieldErrors = normalizeFieldErrors(fieldErrors);
9
+ return {
10
+ error: String(error || "Validation failed.").trim() || "Validation failed.",
11
+ code: String(code || "validation_failed").trim() || "validation_failed",
12
+ fieldErrors: normalizedFieldErrors,
13
+ details: {
14
+ fieldErrors: normalizedFieldErrors
15
+ }
16
+ };
17
+ }
18
+
19
+ export {
20
+ normalizeFieldErrors,
21
+ resolveFieldErrors,
22
+ createValidationFailure
23
+ };
@@ -0,0 +1,21 @@
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 };
@@ -0,0 +1,14 @@
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 };