@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.
Files changed (313) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +78 -0
  3. package/dist/credentials.d.ts +32 -0
  4. package/dist/credentials.d.ts.map +1 -0
  5. package/dist/credentials.js +66 -0
  6. package/dist/credentials.js.map +1 -0
  7. package/dist/credentials.test.d.ts +2 -0
  8. package/dist/credentials.test.d.ts.map +1 -0
  9. package/dist/credentials.test.js +29 -0
  10. package/dist/credentials.test.js.map +1 -0
  11. package/dist/errors.d.ts +57 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +37 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/index.d.ts +30 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +30 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/protocol.d.ts +18 -0
  20. package/dist/protocol.d.ts.map +1 -0
  21. package/dist/protocol.js +96 -0
  22. package/dist/protocol.js.map +1 -0
  23. package/dist/protocol.test.d.ts +2 -0
  24. package/dist/protocol.test.d.ts.map +1 -0
  25. package/dist/protocol.test.js +78 -0
  26. package/dist/protocol.test.js.map +1 -0
  27. package/dist/retry.d.ts +60 -0
  28. package/dist/retry.d.ts.map +1 -0
  29. package/dist/retry.js +53 -0
  30. package/dist/retry.js.map +1 -0
  31. package/dist/services/alias.d.ts +73 -0
  32. package/dist/services/alias.d.ts.map +1 -0
  33. package/dist/services/alias.js +91 -0
  34. package/dist/services/alias.js.map +1 -0
  35. package/dist/services/approle.d.ts +918 -0
  36. package/dist/services/approle.d.ts.map +1 -0
  37. package/dist/services/approle.js +1206 -0
  38. package/dist/services/approle.js.map +1 -0
  39. package/dist/services/auditing.d.ts +97 -0
  40. package/dist/services/auditing.d.ts.map +1 -0
  41. package/dist/services/auditing.js +158 -0
  42. package/dist/services/auditing.js.map +1 -0
  43. package/dist/services/auth.d.ts +160 -0
  44. package/dist/services/auth.d.ts.map +1 -0
  45. package/dist/services/auth.js +169 -0
  46. package/dist/services/auth.js.map +1 -0
  47. package/dist/services/collect.d.ts +35 -0
  48. package/dist/services/collect.d.ts.map +1 -0
  49. package/dist/services/collect.js +46 -0
  50. package/dist/services/collect.js.map +1 -0
  51. package/dist/services/configure.d.ts +35 -0
  52. package/dist/services/configure.d.ts.map +1 -0
  53. package/dist/services/configure.js +43 -0
  54. package/dist/services/configure.js.map +1 -0
  55. package/dist/services/cors.d.ts +54 -0
  56. package/dist/services/cors.d.ts.map +1 -0
  57. package/dist/services/cors.js +65 -0
  58. package/dist/services/cors.js.map +1 -0
  59. package/dist/services/cubbyhole.d.ts +40 -0
  60. package/dist/services/cubbyhole.d.ts.map +1 -0
  61. package/dist/services/cubbyhole.js +56 -0
  62. package/dist/services/cubbyhole.js.map +1 -0
  63. package/dist/services/database.d.ts +278 -0
  64. package/dist/services/database.d.ts.map +1 -0
  65. package/dist/services/database.js +384 -0
  66. package/dist/services/database.js.map +1 -0
  67. package/dist/services/decode.d.ts +18 -0
  68. package/dist/services/decode.d.ts.map +1 -0
  69. package/dist/services/decode.js +24 -0
  70. package/dist/services/decode.js.map +1 -0
  71. package/dist/services/entity.d.ts +257 -0
  72. package/dist/services/entity.d.ts.map +1 -0
  73. package/dist/services/entity.js +313 -0
  74. package/dist/services/entity.js.map +1 -0
  75. package/dist/services/generate.d.ts +136 -0
  76. package/dist/services/generate.d.ts.map +1 -0
  77. package/dist/services/generate.js +188 -0
  78. package/dist/services/generate.js.map +1 -0
  79. package/dist/services/group.d.ts +244 -0
  80. package/dist/services/group.d.ts.map +1 -0
  81. package/dist/services/group.js +277 -0
  82. package/dist/services/group.js.map +1 -0
  83. package/dist/services/ha.d.ts +17 -0
  84. package/dist/services/ha.d.ts.map +1 -0
  85. package/dist/services/ha.js +24 -0
  86. package/dist/services/ha.js.map +1 -0
  87. package/dist/services/index.d.ts +54 -0
  88. package/dist/services/index.d.ts.map +1 -0
  89. package/dist/services/index.js +55 -0
  90. package/dist/services/index.js.map +1 -0
  91. package/dist/services/initialize.d.ts +34 -0
  92. package/dist/services/initialize.d.ts.map +1 -0
  93. package/dist/services/initialize.js +31 -0
  94. package/dist/services/initialize.js.map +1 -0
  95. package/dist/services/internal.d.ts +131 -0
  96. package/dist/services/internal.d.ts.map +1 -0
  97. package/dist/services/internal.js +199 -0
  98. package/dist/services/internal.js.map +1 -0
  99. package/dist/services/jwt.d.ts +684 -0
  100. package/dist/services/jwt.d.ts.map +1 -0
  101. package/dist/services/jwt.js +801 -0
  102. package/dist/services/jwt.js.map +1 -0
  103. package/dist/services/kubernetes.d.ts +166 -0
  104. package/dist/services/kubernetes.d.ts.map +1 -0
  105. package/dist/services/kubernetes.js +187 -0
  106. package/dist/services/kubernetes.js.map +1 -0
  107. package/dist/services/kv.d.ts +519 -0
  108. package/dist/services/kv.d.ts.map +1 -0
  109. package/dist/services/kv.js +655 -0
  110. package/dist/services/kv.js.map +1 -0
  111. package/dist/services/leader.d.ts +21 -0
  112. package/dist/services/leader.d.ts.map +1 -0
  113. package/dist/services/leader.js +29 -0
  114. package/dist/services/leader.js.map +1 -0
  115. package/dist/services/leases.d.ts +185 -0
  116. package/dist/services/leases.d.ts.map +1 -0
  117. package/dist/services/leases.js +238 -0
  118. package/dist/services/leases.js.map +1 -0
  119. package/dist/services/locked.d.ts +27 -0
  120. package/dist/services/locked.d.ts.map +1 -0
  121. package/dist/services/locked.js +42 -0
  122. package/dist/services/locked.js.map +1 -0
  123. package/dist/services/loggers.d.ts +69 -0
  124. package/dist/services/loggers.d.ts.map +1 -0
  125. package/dist/services/loggers.js +100 -0
  126. package/dist/services/loggers.js.map +1 -0
  127. package/dist/services/mfa.d.ts +386 -0
  128. package/dist/services/mfa.d.ts.map +1 -0
  129. package/dist/services/mfa.js +553 -0
  130. package/dist/services/mfa.js.map +1 -0
  131. package/dist/services/misc.d.ts +103 -0
  132. package/dist/services/misc.d.ts.map +1 -0
  133. package/dist/services/misc.js +120 -0
  134. package/dist/services/misc.js.map +1 -0
  135. package/dist/services/mounts.d.ts +173 -0
  136. package/dist/services/mounts.d.ts.map +1 -0
  137. package/dist/services/mounts.js +168 -0
  138. package/dist/services/mounts.js.map +1 -0
  139. package/dist/services/namespaces.d.ts +257 -0
  140. package/dist/services/namespaces.d.ts.map +1 -0
  141. package/dist/services/namespaces.js +320 -0
  142. package/dist/services/namespaces.js.map +1 -0
  143. package/dist/services/oidc.d.ts +509 -0
  144. package/dist/services/oidc.d.ts.map +1 -0
  145. package/dist/services/oidc.js +718 -0
  146. package/dist/services/oidc.js.map +1 -0
  147. package/dist/services/persona.d.ts +73 -0
  148. package/dist/services/persona.d.ts.map +1 -0
  149. package/dist/services/persona.js +91 -0
  150. package/dist/services/persona.js.map +1 -0
  151. package/dist/services/pki.d.ts +5783 -0
  152. package/dist/services/pki.d.ts.map +1 -0
  153. package/dist/services/pki.js +4995 -0
  154. package/dist/services/pki.js.map +1 -0
  155. package/dist/services/plugins.d.ts +203 -0
  156. package/dist/services/plugins.d.ts.map +1 -0
  157. package/dist/services/plugins.js +237 -0
  158. package/dist/services/plugins.js.map +1 -0
  159. package/dist/services/policies.d.ts +250 -0
  160. package/dist/services/policies.d.ts.map +1 -0
  161. package/dist/services/policies.js +312 -0
  162. package/dist/services/policies.js.map +1 -0
  163. package/dist/services/pprof.d.ts +104 -0
  164. package/dist/services/pprof.d.ts.map +1 -0
  165. package/dist/services/pprof.js +161 -0
  166. package/dist/services/pprof.js.map +1 -0
  167. package/dist/services/query.d.ts +65 -0
  168. package/dist/services/query.d.ts.map +1 -0
  169. package/dist/services/query.js +66 -0
  170. package/dist/services/query.js.map +1 -0
  171. package/dist/services/rate.d.ts +102 -0
  172. package/dist/services/rate.d.ts.map +1 -0
  173. package/dist/services/rate.js +129 -0
  174. package/dist/services/rate.js.map +1 -0
  175. package/dist/services/raw.d.ts +85 -0
  176. package/dist/services/raw.d.ts.map +1 -0
  177. package/dist/services/raw.js +116 -0
  178. package/dist/services/raw.js.map +1 -0
  179. package/dist/services/read.d.ts +87 -0
  180. package/dist/services/read.d.ts.map +1 -0
  181. package/dist/services/read.js +123 -0
  182. package/dist/services/read.js.map +1 -0
  183. package/dist/services/rekey.d.ts +184 -0
  184. package/dist/services/rekey.d.ts.map +1 -0
  185. package/dist/services/rekey.js +243 -0
  186. package/dist/services/rekey.js.map +1 -0
  187. package/dist/services/reload.d.ts +15 -0
  188. package/dist/services/reload.d.ts.map +1 -0
  189. package/dist/services/reload.js +27 -0
  190. package/dist/services/reload.js.map +1 -0
  191. package/dist/services/remount.d.ts +18 -0
  192. package/dist/services/remount.d.ts.map +1 -0
  193. package/dist/services/remount.js +30 -0
  194. package/dist/services/remount.js.map +1 -0
  195. package/dist/services/root.d.ts +134 -0
  196. package/dist/services/root.d.ts.map +1 -0
  197. package/dist/services/root.js +180 -0
  198. package/dist/services/root.js.map +1 -0
  199. package/dist/services/rotate.d.ts +367 -0
  200. package/dist/services/rotate.d.ts.map +1 -0
  201. package/dist/services/rotate.js +473 -0
  202. package/dist/services/rotate.js.map +1 -0
  203. package/dist/services/seal.d.ts +29 -0
  204. package/dist/services/seal.d.ts.map +1 -0
  205. package/dist/services/seal.js +37 -0
  206. package/dist/services/seal.js.map +1 -0
  207. package/dist/services/ssh.d.ts +491 -0
  208. package/dist/services/ssh.d.ts.map +1 -0
  209. package/dist/services/ssh.js +582 -0
  210. package/dist/services/ssh.js.map +1 -0
  211. package/dist/services/status.d.ts +17 -0
  212. package/dist/services/status.d.ts.map +1 -0
  213. package/dist/services/status.js +25 -0
  214. package/dist/services/status.js.map +1 -0
  215. package/dist/services/step.d.ts +14 -0
  216. package/dist/services/step.d.ts.map +1 -0
  217. package/dist/services/step.js +21 -0
  218. package/dist/services/step.js.map +1 -0
  219. package/dist/services/system.d.ts +33 -0
  220. package/dist/services/system.d.ts.map +1 -0
  221. package/dist/services/system.js +47 -0
  222. package/dist/services/system.js.map +1 -0
  223. package/dist/services/token.d.ts +408 -0
  224. package/dist/services/token.d.ts.map +1 -0
  225. package/dist/services/token.js +415 -0
  226. package/dist/services/token.js.map +1 -0
  227. package/dist/services/ui.d.ts +70 -0
  228. package/dist/services/ui.d.ts.map +1 -0
  229. package/dist/services/ui.js +95 -0
  230. package/dist/services/ui.js.map +1 -0
  231. package/dist/services/update.d.ts +25 -0
  232. package/dist/services/update.d.ts.map +1 -0
  233. package/dist/services/update.js +36 -0
  234. package/dist/services/update.js.map +1 -0
  235. package/dist/services/userpass.d.ts +151 -0
  236. package/dist/services/userpass.d.ts.map +1 -0
  237. package/dist/services/userpass.js +177 -0
  238. package/dist/services/userpass.js.map +1 -0
  239. package/dist/services/version.d.ts +22 -0
  240. package/dist/services/version.d.ts.map +1 -0
  241. package/dist/services/version.js +28 -0
  242. package/dist/services/version.js.map +1 -0
  243. package/dist/services/workflows.d.ts +122 -0
  244. package/dist/services/workflows.d.ts.map +1 -0
  245. package/dist/services/workflows.js +149 -0
  246. package/dist/services/workflows.js.map +1 -0
  247. package/dist/traits.d.ts +11 -0
  248. package/dist/traits.d.ts.map +1 -0
  249. package/dist/traits.js +12 -0
  250. package/dist/traits.js.map +1 -0
  251. package/package.json +75 -0
  252. package/src/credentials.test.ts +36 -0
  253. package/src/credentials.ts +100 -0
  254. package/src/errors.ts +73 -0
  255. package/src/index.ts +33 -0
  256. package/src/protocol.test.ts +123 -0
  257. package/src/protocol.ts +120 -0
  258. package/src/retry.ts +84 -0
  259. package/src/services/alias.ts +208 -0
  260. package/src/services/approle.ts +2750 -0
  261. package/src/services/auditing.ts +318 -0
  262. package/src/services/auth.ts +416 -0
  263. package/src/services/collect.ts +103 -0
  264. package/src/services/configure.ts +94 -0
  265. package/src/services/cors.ts +155 -0
  266. package/src/services/cubbyhole.ts +117 -0
  267. package/src/services/database.ts +854 -0
  268. package/src/services/decode.ts +49 -0
  269. package/src/services/entity.ts +744 -0
  270. package/src/services/generate.ts +409 -0
  271. package/src/services/group.ts +677 -0
  272. package/src/services/ha.ts +52 -0
  273. package/src/services/index.ts +54 -0
  274. package/src/services/initialize.ts +76 -0
  275. package/src/services/internal.ts +425 -0
  276. package/src/services/jwt.ts +1838 -0
  277. package/src/services/kubernetes.ts +446 -0
  278. package/src/services/kv.ts +1480 -0
  279. package/src/services/leader.ts +57 -0
  280. package/src/services/leases.ts +532 -0
  281. package/src/services/locked.ts +86 -0
  282. package/src/services/loggers.ts +215 -0
  283. package/src/services/mfa.ts +1193 -0
  284. package/src/services/misc.ts +286 -0
  285. package/src/services/mounts.ts +428 -0
  286. package/src/services/namespaces.ts +707 -0
  287. package/src/services/oidc.ts +1613 -0
  288. package/src/services/persona.ts +210 -0
  289. package/src/services/pki.ts +13320 -0
  290. package/src/services/plugins.ts +549 -0
  291. package/src/services/policies.ts +689 -0
  292. package/src/services/pprof.ts +351 -0
  293. package/src/services/query.ts +170 -0
  294. package/src/services/rate.ts +303 -0
  295. package/src/services/raw.ts +244 -0
  296. package/src/services/read.ts +266 -0
  297. package/src/services/rekey.ts +540 -0
  298. package/src/services/reload.ts +51 -0
  299. package/src/services/remount.ts +58 -0
  300. package/src/services/root.ts +393 -0
  301. package/src/services/rotate.ts +1088 -0
  302. package/src/services/seal.ts +75 -0
  303. package/src/services/ssh.ts +1351 -0
  304. package/src/services/status.ts +51 -0
  305. package/src/services/step.ts +43 -0
  306. package/src/services/system.ts +98 -0
  307. package/src/services/token.ts +1046 -0
  308. package/src/services/ui.ts +207 -0
  309. package/src/services/update.ts +73 -0
  310. package/src/services/userpass.ts +410 -0
  311. package/src/services/version.ts +60 -0
  312. package/src/services/workflows.ts +327 -0
  313. package/src/traits.ts +45 -0
@@ -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
+ }));