fluidapi 0.0.3

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 (321) hide show
  1. package/FUNCTIONS.md +85 -0
  2. package/README.md +429 -0
  3. package/RUNTIMES.md +48 -0
  4. package/esm/core.d.ts +10 -0
  5. package/esm/core.d.ts.map +1 -0
  6. package/esm/core.js +13 -0
  7. package/esm/core.js.map +1 -0
  8. package/esm/funcs/metadata-get-jwks.d.ts +18 -0
  9. package/esm/funcs/metadata-get-jwks.d.ts.map +1 -0
  10. package/esm/funcs/metadata-get-jwks.js +67 -0
  11. package/esm/funcs/metadata-get-jwks.js.map +1 -0
  12. package/esm/funcs/metadata-health-check.d.ts +15 -0
  13. package/esm/funcs/metadata-health-check.d.ts.map +1 -0
  14. package/esm/funcs/metadata-health-check.js +64 -0
  15. package/esm/funcs/metadata-health-check.js.map +1 -0
  16. package/esm/funcs/tokens-issue-fluid-token.d.ts +25 -0
  17. package/esm/funcs/tokens-issue-fluid-token.d.ts.map +1 -0
  18. package/esm/funcs/tokens-issue-fluid-token.js +87 -0
  19. package/esm/funcs/tokens-issue-fluid-token.js.map +1 -0
  20. package/esm/funcs/tokens-issue-token.d.ts +31 -0
  21. package/esm/funcs/tokens-issue-token.d.ts.map +1 -0
  22. package/esm/funcs/tokens-issue-token.js +93 -0
  23. package/esm/funcs/tokens-issue-token.js.map +1 -0
  24. package/esm/funcs/tokens-issue-user-token.d.ts +37 -0
  25. package/esm/funcs/tokens-issue-user-token.d.ts.map +1 -0
  26. package/esm/funcs/tokens-issue-user-token.js +97 -0
  27. package/esm/funcs/tokens-issue-user-token.js.map +1 -0
  28. package/esm/hooks/hooks.d.ts +25 -0
  29. package/esm/hooks/hooks.d.ts.map +1 -0
  30. package/esm/hooks/hooks.js +82 -0
  31. package/esm/hooks/hooks.js.map +1 -0
  32. package/esm/hooks/index.d.ts +3 -0
  33. package/esm/hooks/index.d.ts.map +1 -0
  34. package/esm/hooks/index.js +6 -0
  35. package/esm/hooks/index.js.map +1 -0
  36. package/esm/hooks/registration.d.ts +3 -0
  37. package/esm/hooks/registration.d.ts.map +1 -0
  38. package/esm/hooks/registration.js +12 -0
  39. package/esm/hooks/registration.js.map +1 -0
  40. package/esm/hooks/types.d.ts +76 -0
  41. package/esm/hooks/types.d.ts.map +1 -0
  42. package/esm/hooks/types.js +5 -0
  43. package/esm/hooks/types.js.map +1 -0
  44. package/esm/index.d.ts +6 -0
  45. package/esm/index.d.ts.map +1 -0
  46. package/esm/index.js +8 -0
  47. package/esm/index.js.map +1 -0
  48. package/esm/lib/base64.d.ts +10 -0
  49. package/esm/lib/base64.d.ts.map +1 -0
  50. package/esm/lib/base64.js +31 -0
  51. package/esm/lib/base64.js.map +1 -0
  52. package/esm/lib/config.d.ts +57 -0
  53. package/esm/lib/config.d.ts.map +1 -0
  54. package/esm/lib/config.js +50 -0
  55. package/esm/lib/config.js.map +1 -0
  56. package/esm/lib/dlv.d.ts +14 -0
  57. package/esm/lib/dlv.d.ts.map +1 -0
  58. package/esm/lib/dlv.js +46 -0
  59. package/esm/lib/dlv.js.map +1 -0
  60. package/esm/lib/encodings.d.ts +53 -0
  61. package/esm/lib/encodings.d.ts.map +1 -0
  62. package/esm/lib/encodings.js +370 -0
  63. package/esm/lib/encodings.js.map +1 -0
  64. package/esm/lib/env.d.ts +14 -0
  65. package/esm/lib/env.d.ts.map +1 -0
  66. package/esm/lib/env.js +43 -0
  67. package/esm/lib/env.js.map +1 -0
  68. package/esm/lib/files.d.ts +13 -0
  69. package/esm/lib/files.d.ts.map +1 -0
  70. package/esm/lib/files.js +73 -0
  71. package/esm/lib/files.js.map +1 -0
  72. package/esm/lib/http.d.ts +67 -0
  73. package/esm/lib/http.d.ts.map +1 -0
  74. package/esm/lib/http.js +209 -0
  75. package/esm/lib/http.js.map +1 -0
  76. package/esm/lib/is-plain-object.d.ts +2 -0
  77. package/esm/lib/is-plain-object.d.ts.map +1 -0
  78. package/esm/lib/is-plain-object.js +38 -0
  79. package/esm/lib/is-plain-object.js.map +1 -0
  80. package/esm/lib/logger.d.ts +6 -0
  81. package/esm/lib/logger.d.ts.map +1 -0
  82. package/esm/lib/logger.js +5 -0
  83. package/esm/lib/logger.js.map +1 -0
  84. package/esm/lib/matchers.d.ts +59 -0
  85. package/esm/lib/matchers.d.ts.map +1 -0
  86. package/esm/lib/matchers.js +202 -0
  87. package/esm/lib/matchers.js.map +1 -0
  88. package/esm/lib/primitives.d.ts +26 -0
  89. package/esm/lib/primitives.d.ts.map +1 -0
  90. package/esm/lib/primitives.js +103 -0
  91. package/esm/lib/primitives.js.map +1 -0
  92. package/esm/lib/retries.d.ts +38 -0
  93. package/esm/lib/retries.d.ts.map +1 -0
  94. package/esm/lib/retries.js +150 -0
  95. package/esm/lib/retries.js.map +1 -0
  96. package/esm/lib/schemas.d.ts +21 -0
  97. package/esm/lib/schemas.d.ts.map +1 -0
  98. package/esm/lib/schemas.js +57 -0
  99. package/esm/lib/schemas.js.map +1 -0
  100. package/esm/lib/sdks.d.ts +63 -0
  101. package/esm/lib/sdks.d.ts.map +1 -0
  102. package/esm/lib/sdks.js +258 -0
  103. package/esm/lib/sdks.js.map +1 -0
  104. package/esm/lib/security.d.ts +80 -0
  105. package/esm/lib/security.d.ts.map +1 -0
  106. package/esm/lib/security.js +122 -0
  107. package/esm/lib/security.js.map +1 -0
  108. package/esm/lib/url.d.ts +5 -0
  109. package/esm/lib/url.d.ts.map +1 -0
  110. package/esm/lib/url.js +22 -0
  111. package/esm/lib/url.js.map +1 -0
  112. package/esm/models/error-response.d.ts +17 -0
  113. package/esm/models/error-response.d.ts.map +1 -0
  114. package/esm/models/error-response.js +15 -0
  115. package/esm/models/error-response.js.map +1 -0
  116. package/esm/models/errors/error-response.d.ts +21 -0
  117. package/esm/models/errors/error-response.d.ts.map +1 -0
  118. package/esm/models/errors/error-response.js +37 -0
  119. package/esm/models/errors/error-response.js.map +1 -0
  120. package/esm/models/errors/fluidapi-default-error.d.ts +10 -0
  121. package/esm/models/errors/fluidapi-default-error.d.ts.map +1 -0
  122. package/esm/models/errors/fluidapi-default-error.js +30 -0
  123. package/esm/models/errors/fluidapi-default-error.js.map +1 -0
  124. package/esm/models/errors/fluidapi-error.d.ts +19 -0
  125. package/esm/models/errors/fluidapi-error.d.ts.map +1 -0
  126. package/esm/models/errors/fluidapi-error.js +26 -0
  127. package/esm/models/errors/fluidapi-error.js.map +1 -0
  128. package/esm/models/errors/http-client-errors.d.ts +44 -0
  129. package/esm/models/errors/http-client-errors.d.ts.map +1 -0
  130. package/esm/models/errors/http-client-errors.js +56 -0
  131. package/esm/models/errors/http-client-errors.js.map +1 -0
  132. package/esm/models/errors/index.d.ts +7 -0
  133. package/esm/models/errors/index.d.ts.map +1 -0
  134. package/esm/models/errors/index.js +10 -0
  135. package/esm/models/errors/index.js.map +1 -0
  136. package/esm/models/errors/response-validation-error.d.ts +26 -0
  137. package/esm/models/errors/response-validation-error.d.ts.map +1 -0
  138. package/esm/models/errors/response-validation-error.js +37 -0
  139. package/esm/models/errors/response-validation-error.js.map +1 -0
  140. package/esm/models/errors/sdk-validation-error.d.ts +21 -0
  141. package/esm/models/errors/sdk-validation-error.d.ts.map +1 -0
  142. package/esm/models/errors/sdk-validation-error.js +52 -0
  143. package/esm/models/errors/sdk-validation-error.js.map +1 -0
  144. package/esm/models/health-response.d.ts +10 -0
  145. package/esm/models/health-response.d.ts.map +1 -0
  146. package/esm/models/health-response.js +14 -0
  147. package/esm/models/health-response.js.map +1 -0
  148. package/esm/models/index.d.ts +8 -0
  149. package/esm/models/index.d.ts.map +1 -0
  150. package/esm/models/index.js +11 -0
  151. package/esm/models/index.js.map +1 -0
  152. package/esm/models/issue-token-request.d.ts +31 -0
  153. package/esm/models/issue-token-request.d.ts.map +1 -0
  154. package/esm/models/issue-token-request.js +27 -0
  155. package/esm/models/issue-token-request.js.map +1 -0
  156. package/esm/models/jwk-set.d.ts +21 -0
  157. package/esm/models/jwk-set.d.ts.map +1 -0
  158. package/esm/models/jwk-set.js +26 -0
  159. package/esm/models/jwk-set.js.map +1 -0
  160. package/esm/models/operations/index.d.ts +4 -0
  161. package/esm/models/operations/index.d.ts.map +1 -0
  162. package/esm/models/operations/index.js +7 -0
  163. package/esm/models/operations/index.js.map +1 -0
  164. package/esm/models/operations/issue-fluid-token.d.ts +15 -0
  165. package/esm/models/operations/issue-fluid-token.d.ts.map +1 -0
  166. package/esm/models/operations/issue-fluid-token.js +16 -0
  167. package/esm/models/operations/issue-fluid-token.js.map +1 -0
  168. package/esm/models/operations/issue-token.d.ts +15 -0
  169. package/esm/models/operations/issue-token.d.ts.map +1 -0
  170. package/esm/models/operations/issue-token.js +16 -0
  171. package/esm/models/operations/issue-token.js.map +1 -0
  172. package/esm/models/operations/issue-user-token.d.ts +15 -0
  173. package/esm/models/operations/issue-user-token.d.ts.map +1 -0
  174. package/esm/models/operations/issue-user-token.js +16 -0
  175. package/esm/models/operations/issue-user-token.js.map +1 -0
  176. package/esm/models/token-data.d.ts +29 -0
  177. package/esm/models/token-data.d.ts.map +1 -0
  178. package/esm/models/token-data.js +30 -0
  179. package/esm/models/token-data.js.map +1 -0
  180. package/esm/models/user-token-data.d.ts +12 -0
  181. package/esm/models/user-token-data.d.ts.map +1 -0
  182. package/esm/models/user-token-data.js +23 -0
  183. package/esm/models/user-token-data.js.map +1 -0
  184. package/esm/models/user-token-request.d.ts +25 -0
  185. package/esm/models/user-token-request.d.ts.map +1 -0
  186. package/esm/models/user-token-request.js +26 -0
  187. package/esm/models/user-token-request.js.map +1 -0
  188. package/esm/sdk/index.d.ts +2 -0
  189. package/esm/sdk/index.d.ts.map +1 -0
  190. package/esm/sdk/index.js +5 -0
  191. package/esm/sdk/index.js.map +1 -0
  192. package/esm/sdk/metadata.d.ts +16 -0
  193. package/esm/sdk/metadata.d.ts.map +1 -0
  194. package/esm/sdk/metadata.js +25 -0
  195. package/esm/sdk/metadata.js.map +1 -0
  196. package/esm/sdk/sdk.d.ts +10 -0
  197. package/esm/sdk/sdk.d.ts.map +1 -0
  198. package/esm/sdk/sdk.js +17 -0
  199. package/esm/sdk/sdk.js.map +1 -0
  200. package/esm/sdk/tokens.d.ts +63 -0
  201. package/esm/sdk/tokens.d.ts.map +1 -0
  202. package/esm/sdk/tokens.js +74 -0
  203. package/esm/sdk/tokens.js.map +1 -0
  204. package/esm/types/async.d.ts +23 -0
  205. package/esm/types/async.d.ts.map +1 -0
  206. package/esm/types/async.js +28 -0
  207. package/esm/types/async.js.map +1 -0
  208. package/esm/types/blobs.d.ts +4 -0
  209. package/esm/types/blobs.d.ts.map +1 -0
  210. package/esm/types/blobs.js +25 -0
  211. package/esm/types/blobs.js.map +1 -0
  212. package/esm/types/const-date-time.d.ts +3 -0
  213. package/esm/types/const-date-time.d.ts.map +1 -0
  214. package/esm/types/const-date-time.js +10 -0
  215. package/esm/types/const-date-time.js.map +1 -0
  216. package/esm/types/default-to-zero-value.d.ts +12 -0
  217. package/esm/types/default-to-zero-value.d.ts.map +1 -0
  218. package/esm/types/default-to-zero-value.js +31 -0
  219. package/esm/types/default-to-zero-value.js.map +1 -0
  220. package/esm/types/enums.d.ts +9 -0
  221. package/esm/types/enums.d.ts.map +1 -0
  222. package/esm/types/enums.js +27 -0
  223. package/esm/types/enums.js.map +1 -0
  224. package/esm/types/fp.d.ts +31 -0
  225. package/esm/types/fp.d.ts.map +1 -0
  226. package/esm/types/fp.js +31 -0
  227. package/esm/types/fp.js.map +1 -0
  228. package/esm/types/index.d.ts +10 -0
  229. package/esm/types/index.d.ts.map +1 -0
  230. package/esm/types/index.js +10 -0
  231. package/esm/types/index.js.map +1 -0
  232. package/esm/types/operations.d.ts +27 -0
  233. package/esm/types/operations.d.ts.map +1 -0
  234. package/esm/types/operations.js +77 -0
  235. package/esm/types/operations.js.map +1 -0
  236. package/esm/types/primitives.d.ts +11 -0
  237. package/esm/types/primitives.d.ts.map +1 -0
  238. package/esm/types/primitives.js +132 -0
  239. package/esm/types/primitives.js.map +1 -0
  240. package/esm/types/rfcdate.d.ts +21 -0
  241. package/esm/types/rfcdate.d.ts.map +1 -0
  242. package/esm/types/rfcdate.js +43 -0
  243. package/esm/types/rfcdate.js.map +1 -0
  244. package/esm/types/smart-union.d.ts +7 -0
  245. package/esm/types/smart-union.d.ts.map +1 -0
  246. package/esm/types/smart-union.js +117 -0
  247. package/esm/types/smart-union.js.map +1 -0
  248. package/esm/types/streams.d.ts +2 -0
  249. package/esm/types/streams.d.ts.map +1 -0
  250. package/esm/types/streams.js +15 -0
  251. package/esm/types/streams.js.map +1 -0
  252. package/esm/types/unrecognized.d.ts +16 -0
  253. package/esm/types/unrecognized.d.ts.map +1 -0
  254. package/esm/types/unrecognized.js +31 -0
  255. package/esm/types/unrecognized.js.map +1 -0
  256. package/examples/metadataHealthCheck.example.ts +24 -0
  257. package/jsr.json +27 -0
  258. package/package.json +62 -0
  259. package/src/core.ts +13 -0
  260. package/src/funcs/metadata-get-jwks.ts +145 -0
  261. package/src/funcs/metadata-health-check.ts +142 -0
  262. package/src/funcs/tokens-issue-fluid-token.ts +175 -0
  263. package/src/funcs/tokens-issue-token.ts +181 -0
  264. package/src/funcs/tokens-issue-user-token.ts +184 -0
  265. package/src/hooks/hooks.ts +132 -0
  266. package/src/hooks/index.ts +6 -0
  267. package/src/hooks/registration.ts +14 -0
  268. package/src/hooks/types.ts +107 -0
  269. package/src/index.ts +9 -0
  270. package/src/lib/base64.ts +39 -0
  271. package/src/lib/config.ts +94 -0
  272. package/src/lib/dlv.ts +53 -0
  273. package/src/lib/encodings.ts +501 -0
  274. package/src/lib/env.ts +53 -0
  275. package/src/lib/files.ts +82 -0
  276. package/src/lib/http.ts +323 -0
  277. package/src/lib/is-plain-object.ts +43 -0
  278. package/src/lib/logger.ts +9 -0
  279. package/src/lib/matchers.ts +353 -0
  280. package/src/lib/primitives.ts +150 -0
  281. package/src/lib/retries.ts +218 -0
  282. package/src/lib/schemas.ts +94 -0
  283. package/src/lib/sdks.ts +406 -0
  284. package/src/lib/security.ts +236 -0
  285. package/src/lib/url.ts +33 -0
  286. package/src/models/error-response.ts +36 -0
  287. package/src/models/errors/error-response.ts +56 -0
  288. package/src/models/errors/fluidapi-default-error.ts +40 -0
  289. package/src/models/errors/fluidapi-error.ts +35 -0
  290. package/src/models/errors/http-client-errors.ts +62 -0
  291. package/src/models/errors/index.ts +10 -0
  292. package/src/models/errors/response-validation-error.ts +50 -0
  293. package/src/models/errors/sdk-validation-error.ts +54 -0
  294. package/src/models/health-response.ts +31 -0
  295. package/src/models/index.ts +11 -0
  296. package/src/models/issue-token-request.ts +66 -0
  297. package/src/models/jwk-set.ts +57 -0
  298. package/src/models/operations/index.ts +7 -0
  299. package/src/models/operations/issue-fluid-token.ts +37 -0
  300. package/src/models/operations/issue-token.ts +37 -0
  301. package/src/models/operations/issue-user-token.ts +37 -0
  302. package/src/models/token-data.ts +65 -0
  303. package/src/models/user-token-data.ts +45 -0
  304. package/src/models/user-token-request.ts +60 -0
  305. package/src/sdk/index.ts +5 -0
  306. package/src/sdk/metadata.ts +38 -0
  307. package/src/sdk/sdk.ts +19 -0
  308. package/src/sdk/tokens.ts +100 -0
  309. package/src/types/async.ts +68 -0
  310. package/src/types/blobs.ts +33 -0
  311. package/src/types/const-date-time.ts +15 -0
  312. package/src/types/default-to-zero-value.ts +33 -0
  313. package/src/types/enums.ts +45 -0
  314. package/src/types/fp.ts +50 -0
  315. package/src/types/index.ts +13 -0
  316. package/src/types/operations.ts +105 -0
  317. package/src/types/primitives.ts +168 -0
  318. package/src/types/rfcdate.ts +54 -0
  319. package/src/types/smart-union.ts +153 -0
  320. package/src/types/streams.ts +21 -0
  321. package/src/types/unrecognized.ts +35 -0
@@ -0,0 +1,175 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { FluidapiCore } from "../core.js";
7
+ import { encodeBodyForm } from "../lib/encodings.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import { FluidapiError } from "../models/errors/fluidapi-error.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/http-client-errors.js";
21
+ import * as errors from "../models/errors/index.js";
22
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
23
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
24
+ import * as models from "../models/index.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Issue Fluid-signed M2M token
31
+ *
32
+ * @remarks
33
+ * Validates client credentials against the Authorization Server and then
34
+ * generates a JWT signed by Fluid.
35
+ *
36
+ * This endpoint coexists with `/oauth2/token`.
37
+ * Use `/oauth2/token` when you want the standard Hydra-backed token flow.
38
+ * Use `/oauth2/token-fluid` when you need a Fluid-signed JWT carrying
39
+ * `workspace_id`, `tenant_id`, `client_id`, and `credential_type` claims for M2M calls.
40
+ */
41
+ export function tokensIssueFluidToken(
42
+ client: FluidapiCore,
43
+ request: models.IssueTokenRequest,
44
+ options?: RequestOptions,
45
+ ): APIPromise<
46
+ Result<
47
+ operations.IssueFluidTokenResponse,
48
+ | errors.ErrorResponse
49
+ | FluidapiError
50
+ | ResponseValidationError
51
+ | ConnectionError
52
+ | RequestAbortedError
53
+ | RequestTimeoutError
54
+ | InvalidRequestError
55
+ | UnexpectedClientError
56
+ | SDKValidationError
57
+ >
58
+ > {
59
+ return new APIPromise($do(
60
+ client,
61
+ request,
62
+ options,
63
+ ));
64
+ }
65
+
66
+ async function $do(
67
+ client: FluidapiCore,
68
+ request: models.IssueTokenRequest,
69
+ options?: RequestOptions,
70
+ ): Promise<
71
+ [
72
+ Result<
73
+ operations.IssueFluidTokenResponse,
74
+ | errors.ErrorResponse
75
+ | FluidapiError
76
+ | ResponseValidationError
77
+ | ConnectionError
78
+ | RequestAbortedError
79
+ | RequestTimeoutError
80
+ | InvalidRequestError
81
+ | UnexpectedClientError
82
+ | SDKValidationError
83
+ >,
84
+ APICall,
85
+ ]
86
+ > {
87
+ const parsed = safeParse(
88
+ request,
89
+ (value) => z.parse(models.IssueTokenRequest$outboundSchema, value),
90
+ "Input validation failed",
91
+ );
92
+ if (!parsed.ok) {
93
+ return [parsed, { status: "invalid" }];
94
+ }
95
+ const payload = parsed.value;
96
+
97
+ const body = Object.entries(payload || {}).map(([k, v]) => {
98
+ return encodeBodyForm(k, v, { charEncoding: "percent" });
99
+ }).join("&");
100
+
101
+ const path = pathToFunc("/oauth2/token-fluid")();
102
+
103
+ const headers = new Headers(compactMap({
104
+ "Content-Type": "application/x-www-form-urlencoded",
105
+ Accept: "application/json",
106
+ }));
107
+
108
+ const context = {
109
+ options: client._options,
110
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
111
+ operationID: "issueFluidToken",
112
+ oAuth2Scopes: null,
113
+
114
+ resolvedSecurity: null,
115
+
116
+ securitySource: null,
117
+ retryConfig: options?.retries
118
+ || client._options.retryConfig
119
+ || { strategy: "none" },
120
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
121
+ };
122
+
123
+ const requestRes = client._createRequest(context, {
124
+ method: "POST",
125
+ baseURL: options?.serverURL,
126
+ path: path,
127
+ headers: headers,
128
+ body: body,
129
+ userAgent: client._options.userAgent,
130
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
131
+ }, options);
132
+ if (!requestRes.ok) {
133
+ return [requestRes, { status: "invalid" }];
134
+ }
135
+ const req = requestRes.value;
136
+
137
+ const doResult = await client._do(req, {
138
+ context,
139
+ errorCodes: ["400", "401", "4XX", "502", "5XX"],
140
+ retryConfig: context.retryConfig,
141
+ retryCodes: context.retryCodes,
142
+ });
143
+ if (!doResult.ok) {
144
+ return [doResult, { status: "request-error", request: req }];
145
+ }
146
+ const response = doResult.value;
147
+
148
+ const responseFields = {
149
+ HttpMeta: { Response: response, Request: req },
150
+ };
151
+
152
+ const [result] = await M.match<
153
+ operations.IssueFluidTokenResponse,
154
+ | errors.ErrorResponse
155
+ | FluidapiError
156
+ | ResponseValidationError
157
+ | ConnectionError
158
+ | RequestAbortedError
159
+ | RequestTimeoutError
160
+ | InvalidRequestError
161
+ | UnexpectedClientError
162
+ | SDKValidationError
163
+ >(
164
+ M.json(200, operations.IssueFluidTokenResponse$inboundSchema),
165
+ M.jsonErr([400, 401], errors.ErrorResponse$inboundSchema),
166
+ M.jsonErr(502, errors.ErrorResponse$inboundSchema),
167
+ M.fail("4XX"),
168
+ M.fail("5XX"),
169
+ )(response, req, { extraFields: responseFields });
170
+ if (!result.ok) {
171
+ return [result, { status: "complete", request: req, response }];
172
+ }
173
+
174
+ return [result, { status: "complete", request: req, response }];
175
+ }
@@ -0,0 +1,181 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { FluidapiCore } from "../core.js";
7
+ import { encodeBodyForm } from "../lib/encodings.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import { FluidapiError } from "../models/errors/fluidapi-error.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/http-client-errors.js";
21
+ import * as errors from "../models/errors/index.js";
22
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
23
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
24
+ import * as models from "../models/index.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Issue access token (client_credentials)
31
+ *
32
+ * @remarks
33
+ * Standard OAuth2 token endpoint. Performs a `client_credentials` grant
34
+ * against the Authorization Server and returns the access token (JWT).
35
+ *
36
+ * The OAuth2 client must be registered first via
37
+ * `POST /v1/tenants/{tenant_id}/credentials`.
38
+ *
39
+ * ### Scope reduction
40
+ *
41
+ * By default the token is issued with all scopes configured for the tenant.
42
+ * You can request a subset by passing `scope` in the form body.
43
+ * Requesting a scope not in the tenant's allowlist returns `400 invalid_scope`.
44
+ *
45
+ * **Available scopes:** `fluid:api`
46
+ */
47
+ export function tokensIssueToken(
48
+ client: FluidapiCore,
49
+ request: models.IssueTokenRequest,
50
+ options?: RequestOptions,
51
+ ): APIPromise<
52
+ Result<
53
+ operations.IssueTokenResponse,
54
+ | errors.ErrorResponse
55
+ | FluidapiError
56
+ | ResponseValidationError
57
+ | ConnectionError
58
+ | RequestAbortedError
59
+ | RequestTimeoutError
60
+ | InvalidRequestError
61
+ | UnexpectedClientError
62
+ | SDKValidationError
63
+ >
64
+ > {
65
+ return new APIPromise($do(
66
+ client,
67
+ request,
68
+ options,
69
+ ));
70
+ }
71
+
72
+ async function $do(
73
+ client: FluidapiCore,
74
+ request: models.IssueTokenRequest,
75
+ options?: RequestOptions,
76
+ ): Promise<
77
+ [
78
+ Result<
79
+ operations.IssueTokenResponse,
80
+ | errors.ErrorResponse
81
+ | FluidapiError
82
+ | ResponseValidationError
83
+ | ConnectionError
84
+ | RequestAbortedError
85
+ | RequestTimeoutError
86
+ | InvalidRequestError
87
+ | UnexpectedClientError
88
+ | SDKValidationError
89
+ >,
90
+ APICall,
91
+ ]
92
+ > {
93
+ const parsed = safeParse(
94
+ request,
95
+ (value) => z.parse(models.IssueTokenRequest$outboundSchema, value),
96
+ "Input validation failed",
97
+ );
98
+ if (!parsed.ok) {
99
+ return [parsed, { status: "invalid" }];
100
+ }
101
+ const payload = parsed.value;
102
+
103
+ const body = Object.entries(payload || {}).map(([k, v]) => {
104
+ return encodeBodyForm(k, v, { charEncoding: "percent" });
105
+ }).join("&");
106
+
107
+ const path = pathToFunc("/oauth2/token")();
108
+
109
+ const headers = new Headers(compactMap({
110
+ "Content-Type": "application/x-www-form-urlencoded",
111
+ Accept: "application/json",
112
+ }));
113
+
114
+ const context = {
115
+ options: client._options,
116
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
117
+ operationID: "issueToken",
118
+ oAuth2Scopes: null,
119
+
120
+ resolvedSecurity: null,
121
+
122
+ securitySource: null,
123
+ retryConfig: options?.retries
124
+ || client._options.retryConfig
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ method: "POST",
131
+ baseURL: options?.serverURL,
132
+ path: path,
133
+ headers: headers,
134
+ body: body,
135
+ userAgent: client._options.userAgent,
136
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
137
+ }, options);
138
+ if (!requestRes.ok) {
139
+ return [requestRes, { status: "invalid" }];
140
+ }
141
+ const req = requestRes.value;
142
+
143
+ const doResult = await client._do(req, {
144
+ context,
145
+ errorCodes: ["400", "401", "4XX", "502", "5XX"],
146
+ retryConfig: context.retryConfig,
147
+ retryCodes: context.retryCodes,
148
+ });
149
+ if (!doResult.ok) {
150
+ return [doResult, { status: "request-error", request: req }];
151
+ }
152
+ const response = doResult.value;
153
+
154
+ const responseFields = {
155
+ HttpMeta: { Response: response, Request: req },
156
+ };
157
+
158
+ const [result] = await M.match<
159
+ operations.IssueTokenResponse,
160
+ | errors.ErrorResponse
161
+ | FluidapiError
162
+ | ResponseValidationError
163
+ | ConnectionError
164
+ | RequestAbortedError
165
+ | RequestTimeoutError
166
+ | InvalidRequestError
167
+ | UnexpectedClientError
168
+ | SDKValidationError
169
+ >(
170
+ M.json(200, operations.IssueTokenResponse$inboundSchema),
171
+ M.jsonErr([400, 401], errors.ErrorResponse$inboundSchema),
172
+ M.jsonErr(502, errors.ErrorResponse$inboundSchema),
173
+ M.fail("4XX"),
174
+ M.fail("5XX"),
175
+ )(response, req, { extraFields: responseFields });
176
+ if (!result.ok) {
177
+ return [result, { status: "complete", request: req, response }];
178
+ }
179
+
180
+ return [result, { status: "complete", request: req, response }];
181
+ }
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { FluidapiCore } from "../core.js";
7
+ import { encodeJSON } from "../lib/encodings.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import { FluidapiError } from "../models/errors/fluidapi-error.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/http-client-errors.js";
21
+ import * as errors from "../models/errors/index.js";
22
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
23
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
24
+ import * as models from "../models/index.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Issue end-user token
31
+ *
32
+ * @remarks
33
+ * Issues a JWT for an end user (workspace user or customer user).
34
+ *
35
+ * Supported authentication modes:
36
+ * - `Authorization: Bearer <m2m_token>` — preferred. The token must be a
37
+ * Fluid-signed M2M JWT with `scope` including `fluid:api`.
38
+ * Canonical first-access provisioning via external lookup/create is only
39
+ * available in this mode.
40
+ * - HTTP Basic Auth with `client_id` + `client_secret`.
41
+ * In this mode the service does not perform canonical lookup/create.
42
+ *
43
+ * If `customer_external_id` is present, the JWT is issued with `scope: customer`.
44
+ * Otherwise it is issued with `scope: workspace`.
45
+ *
46
+ * When canonical first-access provisioning is enabled, `email` is required
47
+ * so the service can lookup or create the canonical user before issuing the token.
48
+ *
49
+ * When canonical provisioning is disabled by server configuration, the
50
+ * service may materialize local IAM context by assuming `external_id` is
51
+ * already the canonical `user_id`.
52
+ */
53
+ export function tokensIssueUserToken(
54
+ client: FluidapiCore,
55
+ request: models.UserTokenRequest,
56
+ options?: RequestOptions,
57
+ ): APIPromise<
58
+ Result<
59
+ operations.IssueUserTokenResponse,
60
+ | errors.ErrorResponse
61
+ | FluidapiError
62
+ | ResponseValidationError
63
+ | ConnectionError
64
+ | RequestAbortedError
65
+ | RequestTimeoutError
66
+ | InvalidRequestError
67
+ | UnexpectedClientError
68
+ | SDKValidationError
69
+ >
70
+ > {
71
+ return new APIPromise($do(
72
+ client,
73
+ request,
74
+ options,
75
+ ));
76
+ }
77
+
78
+ async function $do(
79
+ client: FluidapiCore,
80
+ request: models.UserTokenRequest,
81
+ options?: RequestOptions,
82
+ ): Promise<
83
+ [
84
+ Result<
85
+ operations.IssueUserTokenResponse,
86
+ | errors.ErrorResponse
87
+ | FluidapiError
88
+ | ResponseValidationError
89
+ | ConnectionError
90
+ | RequestAbortedError
91
+ | RequestTimeoutError
92
+ | InvalidRequestError
93
+ | UnexpectedClientError
94
+ | SDKValidationError
95
+ >,
96
+ APICall,
97
+ ]
98
+ > {
99
+ const parsed = safeParse(
100
+ request,
101
+ (value) => z.parse(models.UserTokenRequest$outboundSchema, value),
102
+ "Input validation failed",
103
+ );
104
+ if (!parsed.ok) {
105
+ return [parsed, { status: "invalid" }];
106
+ }
107
+ const payload = parsed.value;
108
+ const body = encodeJSON("body", payload, { explode: true });
109
+
110
+ const path = pathToFunc("/users/token")();
111
+
112
+ const headers = new Headers(compactMap({
113
+ "Content-Type": "application/json",
114
+ Accept: "application/json",
115
+ }));
116
+
117
+ const context = {
118
+ options: client._options,
119
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
120
+ operationID: "issueUserToken",
121
+ oAuth2Scopes: null,
122
+
123
+ resolvedSecurity: null,
124
+
125
+ securitySource: null,
126
+ retryConfig: options?.retries
127
+ || client._options.retryConfig
128
+ || { strategy: "none" },
129
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
130
+ };
131
+
132
+ const requestRes = client._createRequest(context, {
133
+ method: "POST",
134
+ baseURL: options?.serverURL,
135
+ path: path,
136
+ headers: headers,
137
+ body: body,
138
+ userAgent: client._options.userAgent,
139
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
140
+ }, options);
141
+ if (!requestRes.ok) {
142
+ return [requestRes, { status: "invalid" }];
143
+ }
144
+ const req = requestRes.value;
145
+
146
+ const doResult = await client._do(req, {
147
+ context,
148
+ errorCodes: ["400", "401", "403", "404", "409", "4XX", "502", "5XX"],
149
+ retryConfig: context.retryConfig,
150
+ retryCodes: context.retryCodes,
151
+ });
152
+ if (!doResult.ok) {
153
+ return [doResult, { status: "request-error", request: req }];
154
+ }
155
+ const response = doResult.value;
156
+
157
+ const responseFields = {
158
+ HttpMeta: { Response: response, Request: req },
159
+ };
160
+
161
+ const [result] = await M.match<
162
+ operations.IssueUserTokenResponse,
163
+ | errors.ErrorResponse
164
+ | FluidapiError
165
+ | ResponseValidationError
166
+ | ConnectionError
167
+ | RequestAbortedError
168
+ | RequestTimeoutError
169
+ | InvalidRequestError
170
+ | UnexpectedClientError
171
+ | SDKValidationError
172
+ >(
173
+ M.json(200, operations.IssueUserTokenResponse$inboundSchema),
174
+ M.jsonErr([400, 401, 403, 404, 409], errors.ErrorResponse$inboundSchema),
175
+ M.jsonErr(502, errors.ErrorResponse$inboundSchema),
176
+ M.fail("4XX"),
177
+ M.fail("5XX"),
178
+ )(response, req, { extraFields: responseFields });
179
+ if (!result.ok) {
180
+ return [result, { status: "complete", request: req, response }];
181
+ }
182
+
183
+ return [result, { status: "complete", request: req, response }];
184
+ }
@@ -0,0 +1,132 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { SDKOptions } from "../lib/config.js";
6
+ import { RequestInput } from "../lib/http.js";
7
+ import {
8
+ AfterErrorContext,
9
+ AfterErrorHook,
10
+ AfterSuccessContext,
11
+ AfterSuccessHook,
12
+ BeforeCreateRequestContext,
13
+ BeforeCreateRequestHook,
14
+ BeforeRequestContext,
15
+ BeforeRequestHook,
16
+ Hook,
17
+ Hooks,
18
+ SDKInitHook,
19
+ } from "./types.js";
20
+
21
+ import { initHooks } from "./registration.js";
22
+
23
+ export class SDKHooks implements Hooks {
24
+ sdkInitHooks: SDKInitHook[] = [];
25
+ beforeCreateRequestHooks: BeforeCreateRequestHook[] = [];
26
+ beforeRequestHooks: BeforeRequestHook[] = [];
27
+ afterSuccessHooks: AfterSuccessHook[] = [];
28
+ afterErrorHooks: AfterErrorHook[] = [];
29
+
30
+ constructor() {
31
+ const presetHooks: Array<Hook> = [];
32
+
33
+ for (const hook of presetHooks) {
34
+ if ("sdkInit" in hook) {
35
+ this.registerSDKInitHook(hook);
36
+ }
37
+ if ("beforeCreateRequest" in hook) {
38
+ this.registerBeforeCreateRequestHook(hook);
39
+ }
40
+ if ("beforeRequest" in hook) {
41
+ this.registerBeforeRequestHook(hook);
42
+ }
43
+ if ("afterSuccess" in hook) {
44
+ this.registerAfterSuccessHook(hook);
45
+ }
46
+ if ("afterError" in hook) {
47
+ this.registerAfterErrorHook(hook);
48
+ }
49
+ }
50
+ initHooks(this);
51
+ }
52
+
53
+ registerSDKInitHook(hook: SDKInitHook) {
54
+ this.sdkInitHooks.push(hook);
55
+ }
56
+
57
+ registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) {
58
+ this.beforeCreateRequestHooks.push(hook);
59
+ }
60
+
61
+ registerBeforeRequestHook(hook: BeforeRequestHook) {
62
+ this.beforeRequestHooks.push(hook);
63
+ }
64
+
65
+ registerAfterSuccessHook(hook: AfterSuccessHook) {
66
+ this.afterSuccessHooks.push(hook);
67
+ }
68
+
69
+ registerAfterErrorHook(hook: AfterErrorHook) {
70
+ this.afterErrorHooks.push(hook);
71
+ }
72
+
73
+ sdkInit(opts: SDKOptions): SDKOptions {
74
+ return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts);
75
+ }
76
+
77
+ beforeCreateRequest(
78
+ hookCtx: BeforeCreateRequestContext,
79
+ input: RequestInput,
80
+ ): RequestInput {
81
+ let inp = input;
82
+
83
+ for (const hook of this.beforeCreateRequestHooks) {
84
+ inp = hook.beforeCreateRequest(hookCtx, inp);
85
+ }
86
+
87
+ return inp;
88
+ }
89
+
90
+ async beforeRequest(
91
+ hookCtx: BeforeRequestContext,
92
+ request: Request,
93
+ ): Promise<Request> {
94
+ let req = request;
95
+
96
+ for (const hook of this.beforeRequestHooks) {
97
+ req = await hook.beforeRequest(hookCtx, req);
98
+ }
99
+
100
+ return req;
101
+ }
102
+
103
+ async afterSuccess(
104
+ hookCtx: AfterSuccessContext,
105
+ response: Response,
106
+ ): Promise<Response> {
107
+ let res = response;
108
+
109
+ for (const hook of this.afterSuccessHooks) {
110
+ res = await hook.afterSuccess(hookCtx, res);
111
+ }
112
+
113
+ return res;
114
+ }
115
+
116
+ async afterError(
117
+ hookCtx: AfterErrorContext,
118
+ response: Response | null,
119
+ error: unknown,
120
+ ): Promise<{ response: Response | null; error: unknown }> {
121
+ let res = response;
122
+ let err = error;
123
+
124
+ for (const hook of this.afterErrorHooks) {
125
+ const result = await hook.afterError(hookCtx, res, err);
126
+ res = result.response;
127
+ err = result.error;
128
+ }
129
+
130
+ return { response: res, error: err };
131
+ }
132
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ export * from "./hooks.js";
6
+ export * from "./types.js";
@@ -0,0 +1,14 @@
1
+ import { Hooks } from "./types.js";
2
+
3
+ /*
4
+ * This file is only ever generated once on the first generation and then is free to be modified.
5
+ * Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
6
+ * in this file or in separate files in the hooks folder.
7
+ */
8
+
9
+ // @ts-expect-error remove this line when you add your first hook and hooks is used
10
+ export function initHooks(hooks: Hooks) {
11
+ // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
12
+ // with an instance of a hook that implements that specific Hook interface
13
+ // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
14
+ }