@homeflare/distilled-openbao 0.2.0
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/LICENSE +201 -0
- package/README.md +78 -0
- package/dist/credentials.d.ts +32 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +66 -0
- package/dist/credentials.js.map +1 -0
- package/dist/credentials.test.d.ts +2 -0
- package/dist/credentials.test.d.ts.map +1 -0
- package/dist/credentials.test.js +29 -0
- package/dist/credentials.test.js.map +1 -0
- package/dist/errors.d.ts +57 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +37 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +18 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +96 -0
- package/dist/protocol.js.map +1 -0
- package/dist/protocol.test.d.ts +2 -0
- package/dist/protocol.test.d.ts.map +1 -0
- package/dist/protocol.test.js +78 -0
- package/dist/protocol.test.js.map +1 -0
- package/dist/retry.d.ts +60 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +53 -0
- package/dist/retry.js.map +1 -0
- package/dist/services/alias.d.ts +73 -0
- package/dist/services/alias.d.ts.map +1 -0
- package/dist/services/alias.js +91 -0
- package/dist/services/alias.js.map +1 -0
- package/dist/services/approle.d.ts +918 -0
- package/dist/services/approle.d.ts.map +1 -0
- package/dist/services/approle.js +1206 -0
- package/dist/services/approle.js.map +1 -0
- package/dist/services/auditing.d.ts +97 -0
- package/dist/services/auditing.d.ts.map +1 -0
- package/dist/services/auditing.js +158 -0
- package/dist/services/auditing.js.map +1 -0
- package/dist/services/auth.d.ts +160 -0
- package/dist/services/auth.d.ts.map +1 -0
- package/dist/services/auth.js +169 -0
- package/dist/services/auth.js.map +1 -0
- package/dist/services/collect.d.ts +35 -0
- package/dist/services/collect.d.ts.map +1 -0
- package/dist/services/collect.js +46 -0
- package/dist/services/collect.js.map +1 -0
- package/dist/services/configure.d.ts +35 -0
- package/dist/services/configure.d.ts.map +1 -0
- package/dist/services/configure.js +43 -0
- package/dist/services/configure.js.map +1 -0
- package/dist/services/cors.d.ts +54 -0
- package/dist/services/cors.d.ts.map +1 -0
- package/dist/services/cors.js +65 -0
- package/dist/services/cors.js.map +1 -0
- package/dist/services/cubbyhole.d.ts +40 -0
- package/dist/services/cubbyhole.d.ts.map +1 -0
- package/dist/services/cubbyhole.js +56 -0
- package/dist/services/cubbyhole.js.map +1 -0
- package/dist/services/database.d.ts +278 -0
- package/dist/services/database.d.ts.map +1 -0
- package/dist/services/database.js +384 -0
- package/dist/services/database.js.map +1 -0
- package/dist/services/decode.d.ts +18 -0
- package/dist/services/decode.d.ts.map +1 -0
- package/dist/services/decode.js +24 -0
- package/dist/services/decode.js.map +1 -0
- package/dist/services/entity.d.ts +257 -0
- package/dist/services/entity.d.ts.map +1 -0
- package/dist/services/entity.js +313 -0
- package/dist/services/entity.js.map +1 -0
- package/dist/services/generate.d.ts +136 -0
- package/dist/services/generate.d.ts.map +1 -0
- package/dist/services/generate.js +188 -0
- package/dist/services/generate.js.map +1 -0
- package/dist/services/group.d.ts +244 -0
- package/dist/services/group.d.ts.map +1 -0
- package/dist/services/group.js +277 -0
- package/dist/services/group.js.map +1 -0
- package/dist/services/ha.d.ts +17 -0
- package/dist/services/ha.d.ts.map +1 -0
- package/dist/services/ha.js +24 -0
- package/dist/services/ha.js.map +1 -0
- package/dist/services/index.d.ts +54 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +55 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/initialize.d.ts +34 -0
- package/dist/services/initialize.d.ts.map +1 -0
- package/dist/services/initialize.js +31 -0
- package/dist/services/initialize.js.map +1 -0
- package/dist/services/internal.d.ts +131 -0
- package/dist/services/internal.d.ts.map +1 -0
- package/dist/services/internal.js +199 -0
- package/dist/services/internal.js.map +1 -0
- package/dist/services/jwt.d.ts +684 -0
- package/dist/services/jwt.d.ts.map +1 -0
- package/dist/services/jwt.js +801 -0
- package/dist/services/jwt.js.map +1 -0
- package/dist/services/kubernetes.d.ts +166 -0
- package/dist/services/kubernetes.d.ts.map +1 -0
- package/dist/services/kubernetes.js +187 -0
- package/dist/services/kubernetes.js.map +1 -0
- package/dist/services/kv.d.ts +519 -0
- package/dist/services/kv.d.ts.map +1 -0
- package/dist/services/kv.js +655 -0
- package/dist/services/kv.js.map +1 -0
- package/dist/services/leader.d.ts +21 -0
- package/dist/services/leader.d.ts.map +1 -0
- package/dist/services/leader.js +29 -0
- package/dist/services/leader.js.map +1 -0
- package/dist/services/leases.d.ts +185 -0
- package/dist/services/leases.d.ts.map +1 -0
- package/dist/services/leases.js +238 -0
- package/dist/services/leases.js.map +1 -0
- package/dist/services/locked.d.ts +27 -0
- package/dist/services/locked.d.ts.map +1 -0
- package/dist/services/locked.js +42 -0
- package/dist/services/locked.js.map +1 -0
- package/dist/services/loggers.d.ts +69 -0
- package/dist/services/loggers.d.ts.map +1 -0
- package/dist/services/loggers.js +100 -0
- package/dist/services/loggers.js.map +1 -0
- package/dist/services/mfa.d.ts +386 -0
- package/dist/services/mfa.d.ts.map +1 -0
- package/dist/services/mfa.js +553 -0
- package/dist/services/mfa.js.map +1 -0
- package/dist/services/misc.d.ts +103 -0
- package/dist/services/misc.d.ts.map +1 -0
- package/dist/services/misc.js +120 -0
- package/dist/services/misc.js.map +1 -0
- package/dist/services/mounts.d.ts +173 -0
- package/dist/services/mounts.d.ts.map +1 -0
- package/dist/services/mounts.js +168 -0
- package/dist/services/mounts.js.map +1 -0
- package/dist/services/namespaces.d.ts +257 -0
- package/dist/services/namespaces.d.ts.map +1 -0
- package/dist/services/namespaces.js +320 -0
- package/dist/services/namespaces.js.map +1 -0
- package/dist/services/oidc.d.ts +509 -0
- package/dist/services/oidc.d.ts.map +1 -0
- package/dist/services/oidc.js +718 -0
- package/dist/services/oidc.js.map +1 -0
- package/dist/services/persona.d.ts +73 -0
- package/dist/services/persona.d.ts.map +1 -0
- package/dist/services/persona.js +91 -0
- package/dist/services/persona.js.map +1 -0
- package/dist/services/pki.d.ts +5783 -0
- package/dist/services/pki.d.ts.map +1 -0
- package/dist/services/pki.js +4995 -0
- package/dist/services/pki.js.map +1 -0
- package/dist/services/plugins.d.ts +203 -0
- package/dist/services/plugins.d.ts.map +1 -0
- package/dist/services/plugins.js +237 -0
- package/dist/services/plugins.js.map +1 -0
- package/dist/services/policies.d.ts +250 -0
- package/dist/services/policies.d.ts.map +1 -0
- package/dist/services/policies.js +312 -0
- package/dist/services/policies.js.map +1 -0
- package/dist/services/pprof.d.ts +104 -0
- package/dist/services/pprof.d.ts.map +1 -0
- package/dist/services/pprof.js +161 -0
- package/dist/services/pprof.js.map +1 -0
- package/dist/services/query.d.ts +65 -0
- package/dist/services/query.d.ts.map +1 -0
- package/dist/services/query.js +66 -0
- package/dist/services/query.js.map +1 -0
- package/dist/services/rate.d.ts +102 -0
- package/dist/services/rate.d.ts.map +1 -0
- package/dist/services/rate.js +129 -0
- package/dist/services/rate.js.map +1 -0
- package/dist/services/raw.d.ts +85 -0
- package/dist/services/raw.d.ts.map +1 -0
- package/dist/services/raw.js +116 -0
- package/dist/services/raw.js.map +1 -0
- package/dist/services/read.d.ts +87 -0
- package/dist/services/read.d.ts.map +1 -0
- package/dist/services/read.js +123 -0
- package/dist/services/read.js.map +1 -0
- package/dist/services/rekey.d.ts +184 -0
- package/dist/services/rekey.d.ts.map +1 -0
- package/dist/services/rekey.js +243 -0
- package/dist/services/rekey.js.map +1 -0
- package/dist/services/reload.d.ts +15 -0
- package/dist/services/reload.d.ts.map +1 -0
- package/dist/services/reload.js +27 -0
- package/dist/services/reload.js.map +1 -0
- package/dist/services/remount.d.ts +18 -0
- package/dist/services/remount.d.ts.map +1 -0
- package/dist/services/remount.js +30 -0
- package/dist/services/remount.js.map +1 -0
- package/dist/services/root.d.ts +134 -0
- package/dist/services/root.d.ts.map +1 -0
- package/dist/services/root.js +180 -0
- package/dist/services/root.js.map +1 -0
- package/dist/services/rotate.d.ts +367 -0
- package/dist/services/rotate.d.ts.map +1 -0
- package/dist/services/rotate.js +473 -0
- package/dist/services/rotate.js.map +1 -0
- package/dist/services/seal.d.ts +29 -0
- package/dist/services/seal.d.ts.map +1 -0
- package/dist/services/seal.js +37 -0
- package/dist/services/seal.js.map +1 -0
- package/dist/services/ssh.d.ts +491 -0
- package/dist/services/ssh.d.ts.map +1 -0
- package/dist/services/ssh.js +582 -0
- package/dist/services/ssh.js.map +1 -0
- package/dist/services/status.d.ts +17 -0
- package/dist/services/status.d.ts.map +1 -0
- package/dist/services/status.js +25 -0
- package/dist/services/status.js.map +1 -0
- package/dist/services/step.d.ts +14 -0
- package/dist/services/step.d.ts.map +1 -0
- package/dist/services/step.js +21 -0
- package/dist/services/step.js.map +1 -0
- package/dist/services/system.d.ts +33 -0
- package/dist/services/system.d.ts.map +1 -0
- package/dist/services/system.js +47 -0
- package/dist/services/system.js.map +1 -0
- package/dist/services/token.d.ts +408 -0
- package/dist/services/token.d.ts.map +1 -0
- package/dist/services/token.js +415 -0
- package/dist/services/token.js.map +1 -0
- package/dist/services/ui.d.ts +70 -0
- package/dist/services/ui.d.ts.map +1 -0
- package/dist/services/ui.js +95 -0
- package/dist/services/ui.js.map +1 -0
- package/dist/services/update.d.ts +25 -0
- package/dist/services/update.d.ts.map +1 -0
- package/dist/services/update.js +36 -0
- package/dist/services/update.js.map +1 -0
- package/dist/services/userpass.d.ts +151 -0
- package/dist/services/userpass.d.ts.map +1 -0
- package/dist/services/userpass.js +177 -0
- package/dist/services/userpass.js.map +1 -0
- package/dist/services/version.d.ts +22 -0
- package/dist/services/version.d.ts.map +1 -0
- package/dist/services/version.js +28 -0
- package/dist/services/version.js.map +1 -0
- package/dist/services/workflows.d.ts +122 -0
- package/dist/services/workflows.d.ts.map +1 -0
- package/dist/services/workflows.js +149 -0
- package/dist/services/workflows.js.map +1 -0
- package/dist/traits.d.ts +11 -0
- package/dist/traits.d.ts.map +1 -0
- package/dist/traits.js +12 -0
- package/dist/traits.js.map +1 -0
- package/package.json +75 -0
- package/src/credentials.test.ts +36 -0
- package/src/credentials.ts +100 -0
- package/src/errors.ts +73 -0
- package/src/index.ts +33 -0
- package/src/protocol.test.ts +123 -0
- package/src/protocol.ts +120 -0
- package/src/retry.ts +84 -0
- package/src/services/alias.ts +208 -0
- package/src/services/approle.ts +2750 -0
- package/src/services/auditing.ts +318 -0
- package/src/services/auth.ts +416 -0
- package/src/services/collect.ts +103 -0
- package/src/services/configure.ts +94 -0
- package/src/services/cors.ts +155 -0
- package/src/services/cubbyhole.ts +117 -0
- package/src/services/database.ts +854 -0
- package/src/services/decode.ts +49 -0
- package/src/services/entity.ts +744 -0
- package/src/services/generate.ts +409 -0
- package/src/services/group.ts +677 -0
- package/src/services/ha.ts +52 -0
- package/src/services/index.ts +54 -0
- package/src/services/initialize.ts +76 -0
- package/src/services/internal.ts +425 -0
- package/src/services/jwt.ts +1838 -0
- package/src/services/kubernetes.ts +446 -0
- package/src/services/kv.ts +1480 -0
- package/src/services/leader.ts +57 -0
- package/src/services/leases.ts +532 -0
- package/src/services/locked.ts +86 -0
- package/src/services/loggers.ts +215 -0
- package/src/services/mfa.ts +1193 -0
- package/src/services/misc.ts +286 -0
- package/src/services/mounts.ts +428 -0
- package/src/services/namespaces.ts +707 -0
- package/src/services/oidc.ts +1613 -0
- package/src/services/persona.ts +210 -0
- package/src/services/pki.ts +13320 -0
- package/src/services/plugins.ts +549 -0
- package/src/services/policies.ts +689 -0
- package/src/services/pprof.ts +351 -0
- package/src/services/query.ts +170 -0
- package/src/services/rate.ts +303 -0
- package/src/services/raw.ts +244 -0
- package/src/services/read.ts +266 -0
- package/src/services/rekey.ts +540 -0
- package/src/services/reload.ts +51 -0
- package/src/services/remount.ts +58 -0
- package/src/services/root.ts +393 -0
- package/src/services/rotate.ts +1088 -0
- package/src/services/seal.ts +75 -0
- package/src/services/ssh.ts +1351 -0
- package/src/services/status.ts +51 -0
- package/src/services/step.ts +43 -0
- package/src/services/system.ts +98 -0
- package/src/services/token.ts +1046 -0
- package/src/services/ui.ts +207 -0
- package/src/services/update.ts +73 -0
- package/src/services/userpass.ts +410 -0
- package/src/services/version.ts +60 -0
- package/src/services/workflows.ts +327 -0
- package/src/traits.ts +45 -0
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenBaoProtocol — the shared bearer-REST protocol instantiated for
|
|
3
|
+
* OpenBao.
|
|
4
|
+
*
|
|
5
|
+
* OpenBao wraps every "logical" response (the vast majority — reads,
|
|
6
|
+
* mount/auth/role CRUD) in an envelope: `{ request_id, lease_id,
|
|
7
|
+
* renewable, lease_duration, data: {...}, wrap_info, warnings, auth }`.
|
|
8
|
+
* The generated response schemas describe the INNER `data` shape only — the
|
|
9
|
+
* OpenAPI document OpenBao's own generator produces documents just that
|
|
10
|
+
* (measured against `.generated-specs/policies.json`'s
|
|
11
|
+
* `PoliciesReadAclPolicyResponse`, which has no `request_id`/`lease_id`/etc
|
|
12
|
+
* member at all) — so `transformResponse` below unwraps `data` before
|
|
13
|
+
* decoding, exactly the rule the kit's hand-rolled client already applies
|
|
14
|
+
* (`packages/alchemy/src/openbao/bao-http.ts`'s `baoRead`: take `data` when
|
|
15
|
+
* it is an object, the whole body otherwise). A handful of endpoints are
|
|
16
|
+
* NOT logical responses and have no `data` envelope at all — `sys/health`,
|
|
17
|
+
* `sys/seal-status`, `sys/leader` answer their fields at the top level — so
|
|
18
|
+
* the unwrap only fires when `data` is actually present and an object,
|
|
19
|
+
* which leaves those untouched.
|
|
20
|
+
*
|
|
21
|
+
* ⚠️ NOT YET HANDLED: auth/login responses (`auth/<mount>/login`, and every
|
|
22
|
+
* `*-login` operation) wrap their payload under `auth`, not `data` — this
|
|
23
|
+
* protocol does not unwrap that shape yet. No migrated family calls a login
|
|
24
|
+
* endpoint through this SDK today; add an `auth`-aware unwrap (or a
|
|
25
|
+
* dedicated response trait) before one does.
|
|
26
|
+
*
|
|
27
|
+
* Failures carry `{"errors": [...]}` — zero or more strings, and often
|
|
28
|
+
* literally empty (measured 2026-09-24: OpenBao 2.6.2 answers a missing ACL
|
|
29
|
+
* policy read with `404 {"errors":[]}`, no text). There is normally no
|
|
30
|
+
* machine-readable code, so typed errors beyond the status-derived ones
|
|
31
|
+
* match on status, or on message when OpenBao actually supplies one — see
|
|
32
|
+
* `patches/`.
|
|
33
|
+
*
|
|
34
|
+
* Authentication is a single header, `X-Vault-Token`, plus an optional
|
|
35
|
+
* `X-Vault-Namespace` when the credential carries one — the estate always
|
|
36
|
+
* does (`BAO_NAMESPACE=homeflare`). A namespace does not change a mounted
|
|
37
|
+
* backend's own path shape (see `stacks/distilled-submodules/spec-repos/
|
|
38
|
+
* openbao/fetch-specs.ts`'s module docs for how that was confirmed), so it
|
|
39
|
+
* is purely a request header here, never a path segment.
|
|
40
|
+
*/
|
|
41
|
+
import * as Effect from "effect/Effect";
|
|
42
|
+
import type * as Layer from "effect/Layer";
|
|
43
|
+
import * as Redacted from "effect/Redacted";
|
|
44
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
45
|
+
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
46
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
47
|
+
import type { ConfigError } from "@distilled.cloud/core/errors";
|
|
48
|
+
import {
|
|
49
|
+
makeRestProtocol,
|
|
50
|
+
type RestErrorEnvelope,
|
|
51
|
+
} from "@distilled.cloud/core/protocol-rest";
|
|
52
|
+
import { Credentials, type Config } from "./credentials.ts";
|
|
53
|
+
import { UnknownOpenBaoError, type DefaultErrors } from "./errors.ts";
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Error channel shared by every generated OpenBao operation. Generated
|
|
57
|
+
* service files annotate operations with `API.OperationMethod<I, O,
|
|
58
|
+
* OpenBaoOpError, OpenBaoOpContext>` explicitly so the compiler never infers
|
|
59
|
+
* these back out of the schema generics.
|
|
60
|
+
*/
|
|
61
|
+
export type OpenBaoOpError =
|
|
62
|
+
| DefaultErrors
|
|
63
|
+
| ConfigError
|
|
64
|
+
| HttpClientError.HttpClientError;
|
|
65
|
+
|
|
66
|
+
/** Context (requirements) shared by every generated OpenBao operation. */
|
|
67
|
+
export type OpenBaoOpContext = Credentials | HttpClient.HttpClient;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* OpenBao error bodies are `{"errors": [...]}`. Several strings are joined
|
|
71
|
+
* (`"; "`) rather than only the first kept, so a matcher's `includes` still
|
|
72
|
+
* sees text further down the list; an empty array (the common 404 shape)
|
|
73
|
+
* yields no `message`, and the protocol's own `HTTP <status>` fallback
|
|
74
|
+
* covers it. A response that arrives without that envelope (a proxy 502, an
|
|
75
|
+
* HTML error page) falls through to the same fallback.
|
|
76
|
+
*/
|
|
77
|
+
const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
|
|
78
|
+
if (body === null || typeof body !== "object") return undefined;
|
|
79
|
+
const b = body as Record<string, unknown>;
|
|
80
|
+
if (!Array.isArray(b.errors)) return undefined;
|
|
81
|
+
const messages = b.errors.filter((e): e is string => typeof e === "string");
|
|
82
|
+
return { message: messages.length > 0 ? messages.join("; ") : undefined };
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** Unwrap the `data` envelope — see this file's module docs. */
|
|
86
|
+
const transformResponse = (body: unknown): unknown => {
|
|
87
|
+
if (body === null || typeof body !== "object") return body;
|
|
88
|
+
const data = (body as Record<string, unknown>).data;
|
|
89
|
+
return typeof data === "object" && data !== null ? data : body;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const OpenBaoProtocol: Layer.Layer<API.Protocol> =
|
|
93
|
+
makeRestProtocol<Config>({
|
|
94
|
+
// Resolved on the CALLING fiber per request (the layer is memoized per
|
|
95
|
+
// process); the Credentials service holds an effect, so a token rotated
|
|
96
|
+
// between calls is picked up without rebuilding the layer.
|
|
97
|
+
credentials: Effect.gen(function* () {
|
|
98
|
+
const resolve = yield* Credentials;
|
|
99
|
+
return yield* resolve;
|
|
100
|
+
}),
|
|
101
|
+
baseUrl: (creds) => creds.apiBaseUrl,
|
|
102
|
+
headers: (creds) => ({
|
|
103
|
+
"X-Vault-Token": Redacted.value(creds.token),
|
|
104
|
+
...(creds.namespace ? { "X-Vault-Namespace": creds.namespace } : {}),
|
|
105
|
+
Accept: "application/json",
|
|
106
|
+
}),
|
|
107
|
+
errorEnvelope,
|
|
108
|
+
transformResponse,
|
|
109
|
+
unknownError: ({ code, message, body }) =>
|
|
110
|
+
new UnknownOpenBaoError({
|
|
111
|
+
code:
|
|
112
|
+
typeof code === "string"
|
|
113
|
+
? code
|
|
114
|
+
: code !== undefined
|
|
115
|
+
? String(code)
|
|
116
|
+
: undefined,
|
|
117
|
+
message,
|
|
118
|
+
body,
|
|
119
|
+
}),
|
|
120
|
+
});
|
package/src/retry.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenBao retry surface — a veneer over `@distilled.cloud/core/retry`.
|
|
3
|
+
*
|
|
4
|
+
* The `Retry` service tag is threaded into every generated operation via
|
|
5
|
+
* `API.make({ retry: Retry })`, so a caller-installed policy applies to all
|
|
6
|
+
* OpenBao calls below it and core's `makeDefault` is the fallback when none
|
|
7
|
+
* is provided.
|
|
8
|
+
*
|
|
9
|
+
* ⚠️ THIS IS NOT THE ESTATE'S CONCURRENCY GATE. The kit's own
|
|
10
|
+
* `packages/alchemy/src/openbao/bao-http.ts` caps in-flight OpenBao
|
|
11
|
+
* exchanges at 8 process-wide (`BaoGate`, a `Semaphore`) after a real
|
|
12
|
+
* outage: unbounded Alchemy fan-out took the dev listener's socket down
|
|
13
|
+
* (measured 2026-09-14). That cap is `HttpClient` middleware, not a retry
|
|
14
|
+
* policy, and stays exactly where it is — the kit's Effect runtime provides
|
|
15
|
+
* the gated `HttpClient.HttpClient` layer underneath whichever protocol
|
|
16
|
+
* (hand-rolled or this SDK) issues the request, so it keeps applying
|
|
17
|
+
* unchanged to every call this package makes.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import * as OpenBao from "@distilled.cloud/openbao";
|
|
22
|
+
*
|
|
23
|
+
* myEffect.pipe(OpenBao.Retry.transient);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import * as Context from "effect/Context";
|
|
27
|
+
import * as Effect from "effect/Effect";
|
|
28
|
+
import * as Layer from "effect/Layer";
|
|
29
|
+
import * as Retries from "@distilled.cloud/core/retry";
|
|
30
|
+
|
|
31
|
+
export type Options = Retries.Options;
|
|
32
|
+
export type Factory = Retries.Factory;
|
|
33
|
+
export type Policy = Retries.Policy;
|
|
34
|
+
|
|
35
|
+
/** Context tag for configuring retry behavior of OpenBao API calls. */
|
|
36
|
+
export class Retry extends Context.Service<Retry, Policy>()("OpenBaoRetry") {}
|
|
37
|
+
|
|
38
|
+
/** Provides a custom retry policy to every OpenBao API call below it. */
|
|
39
|
+
export const policy: {
|
|
40
|
+
(
|
|
41
|
+
options: Options,
|
|
42
|
+
): <A, E, R>(
|
|
43
|
+
effect: Effect.Effect<A, E, R>,
|
|
44
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
45
|
+
(
|
|
46
|
+
factory: Factory,
|
|
47
|
+
): <A, E, R>(
|
|
48
|
+
effect: Effect.Effect<A, E, R>,
|
|
49
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
50
|
+
} = (optionsOrFactory: Options | Factory) =>
|
|
51
|
+
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
52
|
+
|
|
53
|
+
/** Disables all automatic retries. */
|
|
54
|
+
export const none: <A, E, R>(
|
|
55
|
+
effect: Effect.Effect<A, E, R>,
|
|
56
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>> = Effect.provide(
|
|
57
|
+
Layer.succeed(Retry, { while: () => false }),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The default retry policy (core's): transient/throttling/retryable errors,
|
|
62
|
+
* capped exponential backoff with jitter, server `retryAfter` hints honored
|
|
63
|
+
* with precedence.
|
|
64
|
+
*/
|
|
65
|
+
export const makeDefault: Factory = Retries.makeDefault;
|
|
66
|
+
|
|
67
|
+
export const jittered = Retries.jittered;
|
|
68
|
+
export const capped = Retries.capped;
|
|
69
|
+
|
|
70
|
+
/** Retry options that retry all throttling errors indefinitely. */
|
|
71
|
+
export const throttlingOptions: Options = Retries.throttlingOptions;
|
|
72
|
+
|
|
73
|
+
/** Retries all throttling errors indefinitely (honoring server hints). */
|
|
74
|
+
export const throttling: <A, E, R>(
|
|
75
|
+
effect: Effect.Effect<A, E, R>,
|
|
76
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>> = policy(Retries.throttlingFactory);
|
|
77
|
+
|
|
78
|
+
/** Retry options that retry all transient errors indefinitely. */
|
|
79
|
+
export const transientOptions: Options = Retries.transientOptions;
|
|
80
|
+
|
|
81
|
+
/** Retries all transient errors indefinitely (honoring server hints). */
|
|
82
|
+
export const transient: <A, E, R>(
|
|
83
|
+
effect: Effect.Effect<A, E, R>,
|
|
84
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>> = policy(Retries.transientFactory);
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-openbao, generated — see fetch-specs.ts). Do not edit.
|
|
2
|
+
import * as S from "@distilled.cloud/core/schema";
|
|
3
|
+
import * as API from "@distilled.cloud/core/api";
|
|
4
|
+
import * as T from "../traits.ts";
|
|
5
|
+
import {
|
|
6
|
+
OpenBaoProtocol,
|
|
7
|
+
type OpenBaoOpError,
|
|
8
|
+
type OpenBaoOpContext,
|
|
9
|
+
} from "../protocol.ts";
|
|
10
|
+
import * as Retry from "../retry.ts";
|
|
11
|
+
|
|
12
|
+
export type { OpenBaoOpError, OpenBaoOpContext };
|
|
13
|
+
|
|
14
|
+
export interface AliasDeleteByIdRequest {
|
|
15
|
+
/** ID of the alias */
|
|
16
|
+
id: string;
|
|
17
|
+
}
|
|
18
|
+
export const AliasDeleteByIdRequest = /*@__PURE__*/ S.suspend(() =>
|
|
19
|
+
S.Struct({
|
|
20
|
+
id: S.String.pipe(T.Label()),
|
|
21
|
+
}).pipe(
|
|
22
|
+
T.Http({ method: "DELETE", uri: "/identity/alias/id/{id}", code: 200 }),
|
|
23
|
+
),
|
|
24
|
+
).annotate({
|
|
25
|
+
identifier: "AliasDeleteByIdRequest",
|
|
26
|
+
}) as any as S.Schema<AliasDeleteByIdRequest>;
|
|
27
|
+
|
|
28
|
+
export interface AliasDeleteByIdResponse {}
|
|
29
|
+
export const AliasDeleteByIdResponse = /*@__PURE__*/ S.suspend(() =>
|
|
30
|
+
S.Struct({}),
|
|
31
|
+
).annotate({
|
|
32
|
+
identifier: "AliasDeleteByIdResponse",
|
|
33
|
+
}) as any as S.Schema<AliasDeleteByIdResponse>;
|
|
34
|
+
|
|
35
|
+
export type AliasListByIdRequestList = "true";
|
|
36
|
+
export const AliasListByIdRequestList = S.String;
|
|
37
|
+
|
|
38
|
+
export interface AliasListByIdRequest {
|
|
39
|
+
/** Must be set to `true` */
|
|
40
|
+
list: AliasListByIdRequestList | (string & {});
|
|
41
|
+
}
|
|
42
|
+
export const AliasListByIdRequest = /*@__PURE__*/ S.suspend(() =>
|
|
43
|
+
S.Struct({
|
|
44
|
+
list: AliasListByIdRequestList.pipe(T.Query()),
|
|
45
|
+
}).pipe(T.Http({ method: "GET", uri: "/identity/alias/id", code: 200 })),
|
|
46
|
+
).annotate({
|
|
47
|
+
identifier: "AliasListByIdRequest",
|
|
48
|
+
}) as any as S.Schema<AliasListByIdRequest>;
|
|
49
|
+
|
|
50
|
+
export interface AliasListByIdResponse {}
|
|
51
|
+
export const AliasListByIdResponse = /*@__PURE__*/ S.suspend(() =>
|
|
52
|
+
S.Struct({}),
|
|
53
|
+
).annotate({
|
|
54
|
+
identifier: "AliasListByIdResponse",
|
|
55
|
+
}) as any as S.Schema<AliasListByIdResponse>;
|
|
56
|
+
|
|
57
|
+
export interface AliasReadByIdRequest {
|
|
58
|
+
/** ID of the alias */
|
|
59
|
+
id: string;
|
|
60
|
+
}
|
|
61
|
+
export const AliasReadByIdRequest = /*@__PURE__*/ S.suspend(() =>
|
|
62
|
+
S.Struct({
|
|
63
|
+
id: S.String.pipe(T.Label()),
|
|
64
|
+
}).pipe(T.Http({ method: "GET", uri: "/identity/alias/id/{id}", code: 200 })),
|
|
65
|
+
).annotate({
|
|
66
|
+
identifier: "AliasReadByIdRequest",
|
|
67
|
+
}) as any as S.Schema<AliasReadByIdRequest>;
|
|
68
|
+
|
|
69
|
+
export interface AliasReadByIdResponse {}
|
|
70
|
+
export const AliasReadByIdResponse = /*@__PURE__*/ S.suspend(() =>
|
|
71
|
+
S.Struct({}),
|
|
72
|
+
).annotate({
|
|
73
|
+
identifier: "AliasReadByIdResponse",
|
|
74
|
+
}) as any as S.Schema<AliasReadByIdResponse>;
|
|
75
|
+
|
|
76
|
+
export interface AliasUpdateByIdRequest {
|
|
77
|
+
/** ID of the alias */
|
|
78
|
+
id: string;
|
|
79
|
+
/** Entity ID to which this alias should be tied to */
|
|
80
|
+
canonical_id?: string;
|
|
81
|
+
/** Entity ID to which this alias should be tied to. This field is deprecated in favor of 'canonical_id'. */
|
|
82
|
+
entity_id?: string;
|
|
83
|
+
/** Mount accessor to which this alias belongs to */
|
|
84
|
+
mount_accessor?: string;
|
|
85
|
+
/** Name of the alias */
|
|
86
|
+
name?: string;
|
|
87
|
+
}
|
|
88
|
+
export const AliasUpdateByIdRequest = /*@__PURE__*/ S.suspend(() =>
|
|
89
|
+
S.Struct({
|
|
90
|
+
id: S.String.pipe(T.Label()),
|
|
91
|
+
canonical_id: S.optional(S.String),
|
|
92
|
+
entity_id: S.optional(S.String),
|
|
93
|
+
mount_accessor: S.optional(S.String),
|
|
94
|
+
name: S.optional(S.String),
|
|
95
|
+
}).pipe(
|
|
96
|
+
T.Http({ method: "POST", uri: "/identity/alias/id/{id}", code: 200 }),
|
|
97
|
+
),
|
|
98
|
+
).annotate({
|
|
99
|
+
identifier: "AliasUpdateByIdRequest",
|
|
100
|
+
}) as any as S.Schema<AliasUpdateByIdRequest>;
|
|
101
|
+
|
|
102
|
+
export interface AliasUpdateByIdResponse {}
|
|
103
|
+
export const AliasUpdateByIdResponse = /*@__PURE__*/ S.suspend(() =>
|
|
104
|
+
S.Struct({}),
|
|
105
|
+
).annotate({
|
|
106
|
+
identifier: "AliasUpdateByIdResponse",
|
|
107
|
+
}) as any as S.Schema<AliasUpdateByIdResponse>;
|
|
108
|
+
|
|
109
|
+
export interface CreateAliasRequest {
|
|
110
|
+
/** Entity ID to which this alias belongs to */
|
|
111
|
+
canonical_id?: string;
|
|
112
|
+
/** Entity ID to which this alias belongs to. This field is deprecated in favor of 'canonical_id'. */
|
|
113
|
+
entity_id?: string;
|
|
114
|
+
/** ID of the alias */
|
|
115
|
+
id?: string;
|
|
116
|
+
/** Mount accessor to which this alias belongs to */
|
|
117
|
+
mount_accessor?: string;
|
|
118
|
+
/** Name of the alias */
|
|
119
|
+
name?: string;
|
|
120
|
+
}
|
|
121
|
+
export const CreateAliasRequest = /*@__PURE__*/ S.suspend(() =>
|
|
122
|
+
S.Struct({
|
|
123
|
+
canonical_id: S.optional(S.String),
|
|
124
|
+
entity_id: S.optional(S.String),
|
|
125
|
+
id: S.optional(S.String),
|
|
126
|
+
mount_accessor: S.optional(S.String),
|
|
127
|
+
name: S.optional(S.String),
|
|
128
|
+
}).pipe(T.Http({ method: "POST", uri: "/identity/alias", code: 200 })),
|
|
129
|
+
).annotate({
|
|
130
|
+
identifier: "CreateAliasRequest",
|
|
131
|
+
}) as any as S.Schema<CreateAliasRequest>;
|
|
132
|
+
|
|
133
|
+
export interface CreateAliasResponse {}
|
|
134
|
+
export const CreateAliasResponse = /*@__PURE__*/ S.suspend(() =>
|
|
135
|
+
S.Struct({}),
|
|
136
|
+
).annotate({
|
|
137
|
+
identifier: "CreateAliasResponse",
|
|
138
|
+
}) as any as S.Schema<CreateAliasResponse>;
|
|
139
|
+
|
|
140
|
+
export type AliasDeleteByIdError = OpenBaoOpError;
|
|
141
|
+
export const aliasDeleteById: API.OperationMethod<
|
|
142
|
+
AliasDeleteByIdRequest,
|
|
143
|
+
AliasDeleteByIdResponse,
|
|
144
|
+
AliasDeleteByIdError,
|
|
145
|
+
OpenBaoOpContext
|
|
146
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
147
|
+
input: AliasDeleteByIdRequest,
|
|
148
|
+
output: AliasDeleteByIdResponse,
|
|
149
|
+
errors: [],
|
|
150
|
+
protocol: OpenBaoProtocol,
|
|
151
|
+
retry: Retry.Retry,
|
|
152
|
+
}));
|
|
153
|
+
|
|
154
|
+
export type AliasListByIdError = OpenBaoOpError;
|
|
155
|
+
export const aliasListById: API.OperationMethod<
|
|
156
|
+
AliasListByIdRequest,
|
|
157
|
+
AliasListByIdResponse,
|
|
158
|
+
AliasListByIdError,
|
|
159
|
+
OpenBaoOpContext
|
|
160
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
161
|
+
input: AliasListByIdRequest,
|
|
162
|
+
output: AliasListByIdResponse,
|
|
163
|
+
errors: [],
|
|
164
|
+
protocol: OpenBaoProtocol,
|
|
165
|
+
retry: Retry.Retry,
|
|
166
|
+
}));
|
|
167
|
+
|
|
168
|
+
export type AliasReadByIdError = OpenBaoOpError;
|
|
169
|
+
export const aliasReadById: API.OperationMethod<
|
|
170
|
+
AliasReadByIdRequest,
|
|
171
|
+
AliasReadByIdResponse,
|
|
172
|
+
AliasReadByIdError,
|
|
173
|
+
OpenBaoOpContext
|
|
174
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
175
|
+
input: AliasReadByIdRequest,
|
|
176
|
+
output: AliasReadByIdResponse,
|
|
177
|
+
errors: [],
|
|
178
|
+
protocol: OpenBaoProtocol,
|
|
179
|
+
retry: Retry.Retry,
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
export type AliasUpdateByIdError = OpenBaoOpError;
|
|
183
|
+
export const aliasUpdateById: API.OperationMethod<
|
|
184
|
+
AliasUpdateByIdRequest,
|
|
185
|
+
AliasUpdateByIdResponse,
|
|
186
|
+
AliasUpdateByIdError,
|
|
187
|
+
OpenBaoOpContext
|
|
188
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
189
|
+
input: AliasUpdateByIdRequest,
|
|
190
|
+
output: AliasUpdateByIdResponse,
|
|
191
|
+
errors: [],
|
|
192
|
+
protocol: OpenBaoProtocol,
|
|
193
|
+
retry: Retry.Retry,
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
export type CreateAliasError = OpenBaoOpError;
|
|
197
|
+
export const createAlias: API.OperationMethod<
|
|
198
|
+
CreateAliasRequest,
|
|
199
|
+
CreateAliasResponse,
|
|
200
|
+
CreateAliasError,
|
|
201
|
+
OpenBaoOpContext
|
|
202
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
203
|
+
input: CreateAliasRequest,
|
|
204
|
+
output: CreateAliasResponse,
|
|
205
|
+
errors: [],
|
|
206
|
+
protocol: OpenBaoProtocol,
|
|
207
|
+
retry: Retry.Retry,
|
|
208
|
+
}));
|