@theholocron/http-client 1.58.0-alpha.4 → 1.58.0-alpha.9
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/README.md +4 -0
- package/dist/index.d.mts +18 -3
- package/dist/index.mjs +8 -1
- package/dist/testing.d.mts +9 -0
- package/dist/testing.mjs +4 -0
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<!-- alex disable fires -->
|
|
2
|
+
|
|
1
3
|
# @theholocron/http-client
|
|
2
4
|
|
|
3
5
|
Shared HTTP primitives for theholocron tooling — REST client factory, token resolver, and base error types. Used internally by `@theholocron/cli` and all plugin packages; publish your own clients on top of it.
|
|
@@ -91,6 +93,8 @@ It is per process, not per client, so nothing has to be handed to each client. I
|
|
|
91
93
|
|
|
92
94
|
### `createResolveToken(config)`
|
|
93
95
|
|
|
96
|
+
> **Deprecated.** The token resolver, `AuthError` and the input types now live in `@theholocron/kyber/secrets`, which has no dependency on a client library; this copy stays until the next major release.
|
|
97
|
+
|
|
94
98
|
Factory for the standard token resolution used by all holocron plugins. Resolution order:
|
|
95
99
|
|
|
96
100
|
1. `cliToken` — value from `--token` CLI flag
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Thrown by a token resolver when no token was found in any source.
|
|
4
|
+
*
|
|
5
|
+
* @deprecated Moved to `AuthError` in `@theholocron/kyber/secrets`; this copy will be removed in the next major.
|
|
6
|
+
*/
|
|
3
7
|
export declare class AuthError extends Error {
|
|
4
8
|
/** The error name, `AuthError`. */
|
|
5
9
|
name: string;
|
|
6
10
|
}
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Where `resolveToken` looks for a token.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Moved to `ResolveTokenInput` in `@theholocron/kyber/secrets`; this copy will be removed in the next major.
|
|
15
|
+
*/
|
|
8
16
|
interface ResolveTokenInput {
|
|
9
17
|
/** From `--token` CLI flag. */
|
|
10
18
|
cliToken?: string;
|
|
@@ -15,7 +23,11 @@ interface ResolveTokenInput {
|
|
|
15
23
|
/** Active org name — drives namespaced keyring lookup (`<service>.<org>`). */
|
|
16
24
|
org?: string;
|
|
17
25
|
}
|
|
18
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* How `createResolveToken` finds a vendor's token.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Moved to `ResolveTokenConfig` in `@theholocron/kyber/secrets`; this copy will be removed in the next major.
|
|
30
|
+
*/
|
|
19
31
|
interface ResolveTokenConfig {
|
|
20
32
|
/** HOLOCRON_* env var (e.g. `"HOLOCRON_GH_TOKEN"`). */
|
|
21
33
|
envName: string;
|
|
@@ -32,6 +44,9 @@ interface ResolveTokenConfig {
|
|
|
32
44
|
* Returns a `resolveToken(input?)` function wired to the given env vars
|
|
33
45
|
* and keyring service. Plugins call this once at module level.
|
|
34
46
|
*
|
|
47
|
+
* @deprecated Moved to `createResolveToken` in `@theholocron/kyber/secrets`, which also reads the variables a
|
|
48
|
+
* `credentials` provider returned and takes the org variable's name; this copy will be removed in the next major.
|
|
49
|
+
*
|
|
35
50
|
* @remarks
|
|
36
51
|
* The resolver tries, in order: the `cliToken` input (the `--token` flag), the
|
|
37
52
|
* `HOLOCRON_*` env var, the vendor's own env var, the keyring entry
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { createEnvLookup, firstEnv } from "@theholocron/env-utils/lookup";
|
|
2
2
|
import { NoopErrorSink, NoopLogger } from "@theholocron/observability/core";
|
|
3
3
|
// src/auth-resolver.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Thrown by a token resolver when no token was found in any source.
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Moved to `AuthError` in `@theholocron/kyber/secrets`; this copy will be removed in the next major.
|
|
8
|
+
*/
|
|
5
9
|
var AuthError = class extends Error {
|
|
6
10
|
/** The error name, `AuthError`. */
|
|
7
11
|
name = "AuthError";
|
|
@@ -10,6 +14,9 @@ var AuthError = class extends Error {
|
|
|
10
14
|
* Returns a `resolveToken(input?)` function wired to the given env vars
|
|
11
15
|
* and keyring service. Plugins call this once at module level.
|
|
12
16
|
*
|
|
17
|
+
* @deprecated Moved to `createResolveToken` in `@theholocron/kyber/secrets`, which also reads the variables a
|
|
18
|
+
* `credentials` provider returned and takes the org variable's name; this copy will be removed in the next major.
|
|
19
|
+
*
|
|
13
20
|
* @remarks
|
|
14
21
|
* The resolver tries, in order: the `cliToken` input (the `--token` flag), the
|
|
15
22
|
* `HOLOCRON_*` env var, the vendor's own env var, the keyring entry
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
/** One request a stubbed `fetch` received. */
|
|
1
2
|
export interface FetchCall {
|
|
3
|
+
/** The address that was requested. */
|
|
2
4
|
url: string;
|
|
5
|
+
/** The HTTP method, upper-cased; `GET` when none was given. */
|
|
3
6
|
method: string;
|
|
7
|
+
/** The request headers, as given. */
|
|
4
8
|
headers: Record<string, string>;
|
|
9
|
+
/** The body: parsed when it was a JSON string, as given otherwise, and `null` when there was none. */
|
|
5
10
|
body: unknown;
|
|
6
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A `fetch` that answers each call with the next of `responses` (a 200 with an empty body once they run out) and
|
|
14
|
+
* records every call it receives.
|
|
15
|
+
*/
|
|
7
16
|
export declare function stubFetch(responses: Array<{
|
|
8
17
|
status?: number;
|
|
9
18
|
body?: unknown;
|
package/dist/testing.mjs
CHANGED
|
@@ -3,6 +3,10 @@ import { vi } from "vitest";
|
|
|
3
3
|
/* v8 ignore file -- exercised by other packages' test suites, not this package's own; a source-level
|
|
4
4
|
* directive survives regardless of which vitest config resolves (local vs. shared), unlike a
|
|
5
5
|
* config-file `coverage.exclude` entry. */
|
|
6
|
+
/**
|
|
7
|
+
* A `fetch` that answers each call with the next of `responses` (a 200 with an empty body once they run out) and
|
|
8
|
+
* records every call it receives.
|
|
9
|
+
*/
|
|
6
10
|
function stubFetch(responses) {
|
|
7
11
|
const calls = [];
|
|
8
12
|
let i = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/http-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.9",
|
|
4
4
|
"description": "Shared HTTP primitives for theholocron — REST client factory, auth resolver, and error types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -36,23 +36,23 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@theholocron/env-utils": "^1.
|
|
40
|
-
"@theholocron/observability": "^0.
|
|
39
|
+
"@theholocron/env-utils": "^1.17.0-alpha.1",
|
|
40
|
+
"@theholocron/observability": "^0.7.0-alpha.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^26",
|
|
44
44
|
"@vitest/coverage-v8": "^5.0.5",
|
|
45
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
46
|
-
"eslint": "^10.
|
|
47
|
-
"eslint-plugin-n": "^18.
|
|
48
|
-
"globals": "^17.
|
|
49
|
-
"tsdown": "^0.23.
|
|
45
|
+
"@vitest/eslint-plugin": "^1.6.28",
|
|
46
|
+
"eslint": "^10.14.0",
|
|
47
|
+
"eslint-plugin-n": "^18.5.0",
|
|
48
|
+
"globals": "^17.14.0",
|
|
49
|
+
"tsdown": "^0.23.4",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
51
|
"vitest": "^5.0.5",
|
|
52
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.
|
|
53
|
-
"@theholocron/tsdown-config": "^8.9.0-alpha.
|
|
54
|
-
"@theholocron/
|
|
55
|
-
"@theholocron/
|
|
52
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.8",
|
|
53
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.8",
|
|
54
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.8",
|
|
55
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.8"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"vitest": ">=4.0.0"
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
|
-
"
|
|
73
|
-
"
|
|
72
|
+
"build": "tsdown && node ../scripts/check-bundle-size.mjs",
|
|
73
|
+
"lint:code": "eslint .",
|
|
74
|
+
"test:unit": "vitest run --coverage",
|
|
74
75
|
"test:watch": "vitest",
|
|
75
|
-
"
|
|
76
|
-
"verification.unitTests": "vitest run"
|
|
76
|
+
"typecheck": "tsc --noEmit"
|
|
77
77
|
}
|
|
78
78
|
}
|