@distilled.cloud/core 1.0.0-rc.2 → 1.0.0-rc.21

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/LICENSE +201 -0
  2. package/README.md +33 -0
  3. package/lib/_bundle/aws.js +2 -0
  4. package/lib/_bundle/aws.js.map +1 -0
  5. package/lib/_bundle/base.js +5 -0
  6. package/lib/_bundle/base.js.map +1 -0
  7. package/lib/_bundle/graphql.js +3 -0
  8. package/lib/_bundle/graphql.js.map +1 -0
  9. package/lib/_bundle/grpc.js +3 -0
  10. package/lib/_bundle/grpc.js.map +1 -0
  11. package/lib/_bundle/rest.js +2 -0
  12. package/lib/_bundle/rest.js.map +1 -0
  13. package/lib/_bundle/xml.js +4 -0
  14. package/lib/_bundle/xml.js.map +1 -0
  15. package/lib/annotations.d.ts +17 -0
  16. package/lib/annotations.d.ts.map +1 -0
  17. package/lib/annotations.js +2 -0
  18. package/lib/annotations.js.map +1 -0
  19. package/lib/api.d.ts +220 -51
  20. package/lib/api.d.ts.map +1 -1
  21. package/lib/api.js +1 -178
  22. package/lib/category.d.ts +19 -16
  23. package/lib/category.d.ts.map +1 -1
  24. package/lib/category.js +1 -280
  25. package/lib/chunks.d.ts +3 -0
  26. package/lib/chunks.d.ts.map +1 -0
  27. package/lib/chunks.js +1 -0
  28. package/lib/config.d.ts +81 -0
  29. package/lib/config.d.ts.map +1 -0
  30. package/lib/config.js +1 -0
  31. package/lib/crypto.d.ts +76 -0
  32. package/lib/crypto.d.ts.map +1 -0
  33. package/lib/crypto.js +1 -0
  34. package/lib/error-category.d.ts +1 -1
  35. package/lib/error-category.d.ts.map +1 -1
  36. package/lib/error-category.js +1 -46
  37. package/lib/errors.d.ts +99 -74
  38. package/lib/errors.d.ts.map +1 -1
  39. package/lib/errors.js +1 -186
  40. package/lib/graphql.d.ts +420 -0
  41. package/lib/graphql.d.ts.map +1 -0
  42. package/lib/graphql.js +1 -0
  43. package/lib/graphql.types.d.ts +11 -0
  44. package/lib/graphql.types.d.ts.map +1 -0
  45. package/lib/graphql.types.js +1 -0
  46. package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
  47. package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
  48. package/lib/grpc-transport-cloudflare-http2.js +6 -0
  49. package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
  50. package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
  51. package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
  52. package/lib/grpc-transport-cloudflare-sockets.js +5 -0
  53. package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
  54. package/lib/grpc-transport-node-http2.d.ts +19 -0
  55. package/lib/grpc-transport-node-http2.d.ts.map +1 -0
  56. package/lib/grpc-transport-node-http2.js +2 -0
  57. package/lib/grpc-transport-node-http2.js.map +1 -0
  58. package/lib/grpc-transport.d.ts +111 -0
  59. package/lib/grpc-transport.d.ts.map +1 -0
  60. package/lib/grpc-transport.js +1 -0
  61. package/lib/hpack.d.ts +34 -0
  62. package/lib/hpack.d.ts.map +1 -0
  63. package/lib/hpack.js +2 -0
  64. package/lib/hpack.js.map +1 -0
  65. package/lib/index.d.ts +32 -0
  66. package/lib/index.d.ts.map +1 -0
  67. package/lib/index.js +17 -0
  68. package/lib/max-message-bytes.d.ts +42 -0
  69. package/lib/max-message-bytes.d.ts.map +1 -0
  70. package/lib/max-message-bytes.js +2 -0
  71. package/lib/max-message-bytes.js.map +1 -0
  72. package/lib/ndjson.d.ts +3 -0
  73. package/lib/ndjson.d.ts.map +1 -0
  74. package/lib/ndjson.js +2 -0
  75. package/lib/ndjson.js.map +1 -0
  76. package/lib/pagination.d.ts +105 -25
  77. package/lib/pagination.d.ts.map +1 -1
  78. package/lib/pagination.js +1 -182
  79. package/lib/plain-values.d.ts +21 -0
  80. package/lib/plain-values.d.ts.map +1 -0
  81. package/lib/plain-values.js +2 -0
  82. package/lib/plain-values.js.map +1 -0
  83. package/lib/protobuf.d.ts +85 -0
  84. package/lib/protobuf.d.ts.map +1 -0
  85. package/lib/protobuf.js +1 -0
  86. package/lib/protocol-grpc.d.ts +123 -0
  87. package/lib/protocol-grpc.d.ts.map +1 -0
  88. package/lib/protocol-grpc.js +1 -0
  89. package/lib/protocol-http.d.ts +206 -25
  90. package/lib/protocol-http.d.ts.map +1 -1
  91. package/lib/protocol-http.js +1 -554
  92. package/lib/protocol-rest.d.ts +258 -64
  93. package/lib/protocol-rest.d.ts.map +1 -1
  94. package/lib/protocol-rest.js +1 -242
  95. package/lib/protocol.d.ts +113 -0
  96. package/lib/protocol.d.ts.map +1 -0
  97. package/lib/protocol.js +0 -0
  98. package/lib/query.d.ts +29 -0
  99. package/lib/query.d.ts.map +1 -0
  100. package/lib/query.js +1 -0
  101. package/lib/response-validation-strict.d.ts +48 -0
  102. package/lib/response-validation-strict.d.ts.map +1 -0
  103. package/lib/response-validation-strict.js +1 -0
  104. package/lib/response-validation.d.ts +86 -0
  105. package/lib/response-validation.d.ts.map +1 -0
  106. package/lib/response-validation.js +1 -0
  107. package/lib/retry-after.d.ts +4 -4
  108. package/lib/retry-after.d.ts.map +1 -1
  109. package/lib/retry-after.js +1 -112
  110. package/lib/retry-state.d.ts +26 -0
  111. package/lib/retry-state.d.ts.map +1 -0
  112. package/lib/retry-state.js +2 -0
  113. package/lib/retry-state.js.map +1 -0
  114. package/lib/retry.d.ts +141 -42
  115. package/lib/retry.d.ts.map +1 -1
  116. package/lib/retry.js +1 -210
  117. package/lib/schema-lite-impl.d.ts +179 -0
  118. package/lib/schema-lite-impl.d.ts.map +1 -0
  119. package/lib/schema-lite-impl.js +1 -0
  120. package/lib/schema-lite-typed.d.ts +41 -0
  121. package/lib/schema-lite-typed.d.ts.map +1 -0
  122. package/lib/schema-lite-typed.js +1 -0
  123. package/lib/schema-lite.d.ts +41 -0
  124. package/lib/schema-lite.d.ts.map +1 -0
  125. package/lib/schema-lite.js +1 -0
  126. package/lib/schema.d.ts +21 -7
  127. package/lib/schema.d.ts.map +1 -1
  128. package/lib/schema.js +1 -48
  129. package/lib/sdk-error.d.ts +31 -0
  130. package/lib/sdk-error.d.ts.map +1 -0
  131. package/lib/sdk-error.js +1 -0
  132. package/lib/send.d.ts +37 -0
  133. package/lib/send.d.ts.map +1 -0
  134. package/lib/send.js +2 -0
  135. package/lib/send.js.map +1 -0
  136. package/lib/sensitive.d.ts +28 -0
  137. package/lib/sensitive.d.ts.map +1 -0
  138. package/lib/sensitive.js +2 -0
  139. package/lib/sensitive.js.map +1 -0
  140. package/lib/telemetry-debug.d.ts +6 -0
  141. package/lib/telemetry-debug.d.ts.map +1 -0
  142. package/lib/telemetry-debug.js +2 -0
  143. package/lib/telemetry-debug.js.map +1 -0
  144. package/lib/telemetry-hooks.d.ts +32 -0
  145. package/lib/telemetry-hooks.d.ts.map +1 -0
  146. package/lib/telemetry-hooks.js +2 -0
  147. package/lib/telemetry-hooks.js.map +1 -0
  148. package/lib/telemetry-host-rules.d.ts +23 -0
  149. package/lib/telemetry-host-rules.d.ts.map +1 -0
  150. package/lib/telemetry-host-rules.js +2 -0
  151. package/lib/telemetry-host-rules.js.map +1 -0
  152. package/lib/telemetry-lambda-context.d.ts +17 -0
  153. package/lib/telemetry-lambda-context.d.ts.map +1 -0
  154. package/lib/telemetry-lambda-context.js +2 -0
  155. package/lib/telemetry-lambda-context.js.map +1 -0
  156. package/lib/telemetry-message-context.d.ts +52 -0
  157. package/lib/telemetry-message-context.d.ts.map +1 -0
  158. package/lib/telemetry-message-context.js +2 -0
  159. package/lib/telemetry-message-context.js.map +1 -0
  160. package/lib/telemetry-metrics.d.ts +6 -0
  161. package/lib/telemetry-metrics.d.ts.map +1 -0
  162. package/lib/telemetry-metrics.js +2 -0
  163. package/lib/telemetry-metrics.js.map +1 -0
  164. package/lib/telemetry-name-template.d.ts +13 -0
  165. package/lib/telemetry-name-template.d.ts.map +1 -0
  166. package/lib/telemetry-name-template.js +2 -0
  167. package/lib/telemetry-name-template.js.map +1 -0
  168. package/lib/telemetry-stream.d.ts +11 -0
  169. package/lib/telemetry-stream.d.ts.map +1 -0
  170. package/lib/telemetry-stream.js +2 -0
  171. package/lib/telemetry-stream.js.map +1 -0
  172. package/lib/telemetry-xray.d.ts +28 -0
  173. package/lib/telemetry-xray.d.ts.map +1 -0
  174. package/lib/telemetry-xray.js +2 -0
  175. package/lib/telemetry-xray.js.map +1 -0
  176. package/lib/telemetry.d.ts +317 -0
  177. package/lib/telemetry.d.ts.map +1 -0
  178. package/lib/telemetry.js +3 -0
  179. package/lib/telemetry.js.map +1 -0
  180. package/lib/token-cache.d.ts +31 -0
  181. package/lib/token-cache.d.ts.map +1 -0
  182. package/lib/token-cache.js +2 -0
  183. package/lib/token-cache.js.map +1 -0
  184. package/lib/trait.d.ts +94 -20
  185. package/lib/trait.d.ts.map +1 -1
  186. package/lib/trait.js +1 -107
  187. package/lib/unknown-error.d.ts +18 -0
  188. package/lib/unknown-error.d.ts.map +1 -0
  189. package/lib/unknown-error.js +1 -0
  190. package/lib/xml.d.ts +44 -0
  191. package/lib/xml.d.ts.map +1 -0
  192. package/lib/xml.js +1 -0
  193. package/package.json +13 -13
  194. package/src/annotations.ts +53 -0
  195. package/src/api.ts +1597 -234
  196. package/src/category.ts +97 -134
  197. package/src/chunks.ts +30 -0
  198. package/src/config.ts +261 -0
  199. package/src/crypto.ts +202 -0
  200. package/src/error-category.ts +16 -29
  201. package/src/errors.ts +99 -77
  202. package/src/graphql.ts +1817 -0
  203. package/src/graphql.types.ts +120 -0
  204. package/src/grpc-transport-cloudflare-http2.ts +569 -0
  205. package/src/grpc-transport-cloudflare-sockets.ts +368 -0
  206. package/src/grpc-transport-node-http2.ts +307 -0
  207. package/src/grpc-transport.ts +287 -0
  208. package/src/hpack.ts +331 -0
  209. package/src/index.ts +31 -0
  210. package/src/max-message-bytes.ts +58 -0
  211. package/src/ndjson.ts +55 -0
  212. package/src/pagination.ts +379 -94
  213. package/src/plain-values.ts +70 -0
  214. package/src/protobuf.ts +1367 -0
  215. package/src/protocol-grpc.ts +811 -0
  216. package/src/protocol-http.ts +1045 -371
  217. package/src/protocol-rest.ts +908 -255
  218. package/src/protocol.ts +150 -0
  219. package/src/query.ts +39 -0
  220. package/src/response-validation-strict.ts +333 -0
  221. package/src/response-validation.ts +161 -0
  222. package/src/retry-after.ts +8 -14
  223. package/src/retry-state.ts +105 -0
  224. package/src/retry.ts +260 -145
  225. package/src/schema-lite-impl.ts +621 -0
  226. package/src/schema-lite-typed.ts +44 -0
  227. package/src/schema-lite.ts +45 -0
  228. package/src/schema.ts +259 -15
  229. package/src/sdk-error.ts +37 -0
  230. package/src/send.ts +156 -0
  231. package/src/sensitive.ts +188 -0
  232. package/src/telemetry-debug.ts +179 -0
  233. package/src/telemetry-hooks.ts +33 -0
  234. package/src/telemetry-host-rules.ts +39 -0
  235. package/src/telemetry-lambda-context.ts +46 -0
  236. package/src/telemetry-message-context.ts +170 -0
  237. package/src/telemetry-metrics.ts +69 -0
  238. package/src/telemetry-name-template.ts +26 -0
  239. package/src/telemetry-stream.ts +100 -0
  240. package/src/telemetry-xray.ts +66 -0
  241. package/src/telemetry.ts +800 -0
  242. package/src/token-cache.ts +117 -0
  243. package/src/trait.ts +139 -67
  244. package/src/unknown-error.ts +38 -0
  245. package/src/xml.ts +346 -0
  246. package/lib/api.js.map +0 -1
  247. package/lib/category.js.map +0 -1
  248. package/lib/codegen/cli.d.ts +0 -29
  249. package/lib/codegen/cli.d.ts.map +0 -1
  250. package/lib/codegen/cli.js +0 -165
  251. package/lib/codegen/cli.js.map +0 -1
  252. package/lib/codegen/emit.d.ts +0 -129
  253. package/lib/codegen/emit.d.ts.map +0 -1
  254. package/lib/codegen/emit.js +0 -105
  255. package/lib/codegen/emit.js.map +0 -1
  256. package/lib/codegen/format.d.ts +0 -23
  257. package/lib/codegen/format.d.ts.map +0 -1
  258. package/lib/codegen/format.js +0 -28
  259. package/lib/codegen/format.js.map +0 -1
  260. package/lib/codegen/generator.d.ts +0 -334
  261. package/lib/codegen/generator.d.ts.map +0 -1
  262. package/lib/codegen/generator.js +0 -691
  263. package/lib/codegen/generator.js.map +0 -1
  264. package/lib/codegen/graph.d.ts +0 -36
  265. package/lib/codegen/graph.d.ts.map +0 -1
  266. package/lib/codegen/graph.js +0 -136
  267. package/lib/codegen/graph.js.map +0 -1
  268. package/lib/codegen/members.d.ts +0 -25
  269. package/lib/codegen/members.d.ts.map +0 -1
  270. package/lib/codegen/members.js +0 -55
  271. package/lib/codegen/members.js.map +0 -1
  272. package/lib/codegen/naming.d.ts +0 -29
  273. package/lib/codegen/naming.d.ts.map +0 -1
  274. package/lib/codegen/naming.js +0 -74
  275. package/lib/codegen/naming.js.map +0 -1
  276. package/lib/codegen/openapi-cli.d.ts +0 -38
  277. package/lib/codegen/openapi-cli.d.ts.map +0 -1
  278. package/lib/codegen/openapi-cli.js +0 -107
  279. package/lib/codegen/openapi-cli.js.map +0 -1
  280. package/lib/codegen/openapi.d.ts +0 -115
  281. package/lib/codegen/openapi.d.ts.map +0 -1
  282. package/lib/codegen/openapi.js +0 -1220
  283. package/lib/codegen/openapi.js.map +0 -1
  284. package/lib/codegen/operations.d.ts +0 -24
  285. package/lib/codegen/operations.d.ts.map +0 -1
  286. package/lib/codegen/operations.js +0 -56
  287. package/lib/codegen/operations.js.map +0 -1
  288. package/lib/codegen/pagination.d.ts +0 -39
  289. package/lib/codegen/pagination.d.ts.map +0 -1
  290. package/lib/codegen/pagination.js +0 -33
  291. package/lib/codegen/pagination.js.map +0 -1
  292. package/lib/codegen/prelude.d.ts +0 -15
  293. package/lib/codegen/prelude.d.ts.map +0 -1
  294. package/lib/codegen/prelude.js +0 -60
  295. package/lib/codegen/prelude.js.map +0 -1
  296. package/lib/error-category.js.map +0 -1
  297. package/lib/errors.js.map +0 -1
  298. package/lib/json-patch.d.ts +0 -44
  299. package/lib/json-patch.d.ts.map +0 -1
  300. package/lib/json-patch.js +0 -174
  301. package/lib/json-patch.js.map +0 -1
  302. package/lib/pagination.js.map +0 -1
  303. package/lib/protocol-http.js.map +0 -1
  304. package/lib/protocol-rest.js.map +0 -1
  305. package/lib/retry-after.js.map +0 -1
  306. package/lib/retry.js.map +0 -1
  307. package/lib/schema.js.map +0 -1
  308. package/lib/trait.js.map +0 -1
  309. package/src/codegen/cli.ts +0 -268
  310. package/src/codegen/emit.ts +0 -207
  311. package/src/codegen/format.ts +0 -47
  312. package/src/codegen/generator.ts +0 -1153
  313. package/src/codegen/graph.ts +0 -151
  314. package/src/codegen/members.ts +0 -71
  315. package/src/codegen/naming.ts +0 -86
  316. package/src/codegen/openapi-cli.ts +0 -166
  317. package/src/codegen/openapi.ts +0 -1450
  318. package/src/codegen/operations.ts +0 -76
  319. package/src/codegen/pagination.ts +0 -71
  320. package/src/codegen/prelude.ts +0 -70
  321. package/src/json-patch.ts +0 -222
package/lib/api.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  import * as Context from "effect/Context";
2
2
  import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
3
+ import * as HttpClient from "effect/http/HttpClient";
4
+ import type * as HttpClientError from "effect/http/HttpClientError";
5
+ import type * as HttpClientRequest from "effect/http/HttpClientRequest";
4
6
  import * as S from "effect/Schema";
5
7
  import type * as AST from "effect/SchemaAST";
6
- import type * as Stream from "effect/Stream";
8
+ import * as Stream from "effect/Stream";
7
9
  import * as Pagination from "./pagination.ts";
8
- import { type Policy as RetryPolicy } from "./retry.ts";
9
- import * as HttpClient from "effect/unstable/http/HttpClient";
10
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
11
- import type * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
12
- import type * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
10
+ import type { Protocol } from "./protocol.ts";
11
+ import { type Policy as RetryPolicy, type RetryOverride } from "./retry.ts";
12
+ import { SdkError } from "./sdk-error.ts";
13
+ import * as Telemetry from "./telemetry.ts";
13
14
  /**
14
15
  * The view of an operation's config that protocols receive on every
15
16
  * encode/decode call. The object is the same memoized config instance for
@@ -34,36 +35,39 @@ export interface ProtocolOperationConfig {
34
35
  */
35
36
  readonly endpointHostPrefix?: string;
36
37
  readonly pagination?: Pagination.PaginatedTrait;
38
+ /**
39
+ * How a server-streaming operation's body is framed, for protocols that
40
+ * read it per operation (core/protocol-rest takes a `StreamFraming`, e.g.
41
+ * `ndjson` from core/ndjson). Set only on the operations that stream, so
42
+ * programs that call none never bundle the framing.
43
+ */
44
+ readonly framing?: unknown;
45
+ /**
46
+ * One frame of `.stream()`, for an operation whose plain call has its own
47
+ * output and streams only when its input asks (see
48
+ * {@link OperationConfig.streamInput}). Protocols decode each frame
49
+ * against it instead of an element of the output's `items`.
50
+ */
51
+ readonly items?: S.Top;
37
52
  }
38
- declare const Protocol_base: Context.ServiceClass<Protocol, "Protocol", {
39
- readonly encode: (args: {
40
- readonly input: unknown;
41
- readonly inputAst: AST.AST;
42
- /** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
43
- readonly config: ProtocolOperationConfig;
44
- }) => Effect.Effect<HttpClientRequest.HttpClientRequest>;
45
- readonly decode: (args: {
46
- readonly response: HttpClientResponse.HttpClientResponse;
47
- readonly outputAst: AST.AST;
48
- /**
49
- * The operation's declared error classes (from `OperationConfig.errors`).
50
- * Protocols use these to surface wire failures as the operation's typed
51
- * errors — e.g. by consulting matcher metadata stamped on the class.
52
- */
53
- readonly errors: ReadonlyArray<ApiErrorClass>;
54
- /** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
55
- readonly config: ProtocolOperationConfig;
56
- }) => Effect.Effect<unknown>;
57
- }>;
58
- /**
59
- * The Protocol service knows how to turn a value into an HTTP request using
60
- * only the input schema's trait annotations, and how to turn a response back
61
- * into an output value using the output schema's trait annotations.
62
- *
63
- * Swap implementations by providing a different `Layer<Protocol>`.
53
+ /**
54
+ * One operation as a protocol's {@link Protocol.call} sees it. Built once per
55
+ * operation on its first call; the same object is passed on every call.
64
56
  */
65
- export declare class Protocol extends Protocol_base {
57
+ export interface PreparedOperation {
58
+ readonly config: ProtocolOperationConfig;
59
+ readonly inputAst: AST.AST;
60
+ readonly outputAst: AST.AST;
61
+ readonly errors: ReadonlyArray<ApiErrorClass>;
62
+ /** Per-operation slot owned by the operation's protocol (compiled codecs). */
63
+ compiled?: unknown;
66
64
  }
65
+ /**
66
+ * Run `f` on the value of `effect` -- directly when `effect` is already a
67
+ * successful `Exit` (e.g. a `Credentials` service holding
68
+ * `Effect.succeed(config)`), so a resolved value costs no fiber step.
69
+ */
70
+ export declare const withValue: <A, E, R, B, E2, R2>(effect: Effect.Effect<A, E, R>, f: (a: A) => Effect.Effect<B, E2, R2>) => Effect.Effect<B, E | E2, R | R2>;
67
71
  export type ApiErrorClass = {
68
72
  new (...args: any[]): {
69
73
  readonly _tag: string;
@@ -71,35 +75,58 @@ export type ApiErrorClass = {
71
75
  };
72
76
  };
73
77
  /**
74
- * The shape of a generated SDK operation — usable two ways (mirrors the
78
+ * The shape of a generated SDK operation -- usable two ways (mirrors the
75
79
  * distilled repo's OperationMethod):
76
80
  *
77
- * 1. Direct call: `yield* operation(input)` — an Effect with requirements.
78
- * 2. Yield first: `const fn = yield* operation` — captures the current
81
+ * 1. Direct call: `yield* operation(input)` -- an Effect with requirements.
82
+ * 2. Yield first: `const fn = yield* operation` -- captures the current
79
83
  * context and returns a requirement-free call function.
80
84
  *
81
85
  * Generated service files annotate every exported operation with this type
82
86
  * explicitly (against their hand-emitted interfaces), so the compiler never
83
87
  * has to infer it back out of the schema generics.
84
88
  */
85
- export type OperationMethod<I, O, E, R> = Effect.Effect<(input: I) => Effect.Effect<O, E, never>, never, R> & ((input: I) => Effect.Effect<O, E, R>);
86
- export interface OperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> {
89
+ export type OperationMethod<I, O, E, R> = Effect.Effect<(input: I) => Effect.Effect<O, E, never>, never, R> & ((input: I) => Effect.Effect<O, E, R>) & OperationSchemas<I, O>;
90
+ /**
91
+ * An operation's request and response schemas, built on first access.
92
+ * Generated modules export operations, errors and types; the schemas
93
+ * themselves are module-private, so this is how to reach them as values.
94
+ */
95
+ export interface OperationSchemas<I, O> {
96
+ readonly input: S.Codec<I, any>;
97
+ readonly output: S.Codec<O, any>;
98
+ }
99
+ export interface OperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[], SE extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> {
87
100
  input?: I;
88
101
  output?: O;
102
+ /** The errors declared on the operation: only this operation returns them. */
89
103
  errors?: E;
90
104
  /**
91
- * The protocol layer that knows how to encode/decode this operation's wire
92
- * format. Built once per process and shared across all operations that
93
- * reference the same layer value — it must resolve call-dependent services
94
- * (credentials etc.) inside encode/decode, not at build time.
105
+ * The errors declared on the operation's service: the same list on every
106
+ * operation of the service. The protocol matches a failed response
107
+ * against the operation's classes, then these.
108
+ */
109
+ serviceErrors?: SE;
110
+ /**
111
+ * What encodes and decodes this operation's wire format: a protocol
112
+ * (core/protocol), an object whose type states the errors the protocol
113
+ * declares (`PE`) and what its methods read (`PR`), so the operation's
114
+ * type gets them from the protocol. It resolves call-dependent services
115
+ * (credentials etc.) inside encode/decode, on the calling fiber.
95
116
  */
96
- protocol: Layer.Layer<Protocol, PE, PR>;
117
+ protocol: Protocol<PE, PR>;
97
118
  /**
98
119
  * SDK-specific retry service tag (see `core/retry`). When provided and the
99
120
  * caller's context carries a policy under this tag, every call is retried
100
121
  * per that policy (e.g. `Layer.succeed(Cloudflare.Retry.Retry, factory)`).
101
122
  */
102
123
  retry?: Context.Key<any, RetryPolicy>;
124
+ /**
125
+ * The operation's `distilled.retry#policy` trait (the service's, with the
126
+ * operation's on top): numbers that replace the default policy's when the
127
+ * caller's context carries no policy. A caller's policy ignores it.
128
+ */
129
+ retryPolicy?: RetryOverride;
103
130
  /**
104
131
  * The wire operation name for RPC-style protocols (see
105
132
  * {@link ProtocolOperationConfig.operationName}).
@@ -110,14 +137,54 @@ export interface OperationConfig<I extends S.Top, O extends S.Top, PE, PR, E ext
110
137
  * {@link ProtocolOperationConfig.endpointHostPrefix}).
111
138
  */
112
139
  endpointHostPrefix?: string;
140
+ /** The service's `com.distilled.telemetry#service` trait (a module const). */
141
+ telemetry?: Telemetry.ServiceTelemetry;
142
+ /**
143
+ * The operation's `com.distilled.telemetry#operation` trait, with its
144
+ * input rules; only what differs from the service's rules when it names
145
+ * its `op` (a string is just the op).
146
+ */
147
+ span?: Telemetry.SpanConfig | string;
148
+ /** The body framing of a server-streaming operation (see {@link ProtocolOperationConfig.framing}). */
149
+ framing?: unknown;
150
+ /** One frame of `.stream()` (see {@link ProtocolOperationConfig.items}). */
151
+ items?: S.Top;
152
+ /**
153
+ * Input members `.stream()` sets over the caller's, for an operation that
154
+ * streams only when its input asks (Boat's `executeSandboxCommand` with
155
+ * `stream: true`). The plain call sends the caller's input as given.
156
+ */
157
+ streamInput?: Readonly<Record<string, unknown>>;
113
158
  }
114
- export declare function make<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, PE, PR, E>): OperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, InstanceType<E[number]> | PE | HttpClientError.HttpClientError, PR | HttpClient.HttpClient>;
159
+ /**
160
+ * The span facts an operation's calls carry (name, kind, fixed attributes,
161
+ * input rules), as the runtime builds them from its generated config. For
162
+ * tests and tooling.
163
+ */
164
+ export declare const describeOperation: (op: unknown) => Telemetry.OperationInfo;
165
+ /**
166
+ * The HTTP request a call to `op` with `input` would send, built by the
167
+ * operation's protocol (`Protocol.encode`) and not sent: no retry, no span,
168
+ * no response. It fails as the call would before sending (bad input,
169
+ * credentials, endpoint), or with {@link SdkError} when the operation can't
170
+ * be loaded; the operation's type does not tell those failures from a
171
+ * response's, so the error is `unknown`. Presigning builds on it.
172
+ */
173
+ export declare const encodeRequest: <I, O, E, R>(op: OperationMethod<I, O, E, R>, input: I) => Effect.Effect<HttpClientRequest.HttpClientRequest, unknown, R>;
174
+ /**
175
+ * What an operation `make` builds can fail with: its own errors, its
176
+ * service's, its protocol's, the HTTP client's, and {@link SdkError}, which
177
+ * `make` itself fails with when the operation's config can't be loaded or
178
+ * its protocol can't stream.
179
+ */
180
+ export type MadeError<E extends readonly ApiErrorClass[], SE extends readonly ApiErrorClass[], PE> = InstanceType<E[number]> | InstanceType<SE[number]> | PE | HttpClientError.HttpClientError | SdkError;
181
+ export declare function make<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly [], const SE extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, PE, PR, E, SE>): OperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, MadeError<E, SE, PE>, PR | HttpClient.HttpClient>;
115
182
  /**
116
183
  * STRUCTURAL fallback for the element type `.items()` yields: the array
117
184
  * element of the page response itself, or of its `result` member.
118
185
  *
119
186
  * It can only see shapes it was taught, so any other envelope
120
- * (`{ branches: […] }`, `{ data: […] }`, …) lands on `unknown` — which is
187
+ * (`{ branches: [...] }`, `{ data: [...] }`, ...) lands on `unknown` -- which is
121
188
  * why generators pass the item type EXPLICITLY as
122
189
  * {@link PaginatedOperationMethod}'s `Item` argument, resolved from the
123
190
  * pagination trait's `items` path against the response shape. This default
@@ -133,7 +200,7 @@ export type PaginatedItem<A> = A extends ReadonlyArray<infer Item> ? Item : A ex
133
200
  * `.pages(input)` streaming every page response and `.items(input)` streaming
134
201
  * the individual items across pages.
135
202
  *
136
- * Used twice in {@link PaginatedOperationMethod} — once with the operation's
203
+ * Used twice in {@link PaginatedOperationMethod} -- once with the operation's
137
204
  * requirements (`R`) for the direct-call style, once with `R = never` for the
138
205
  * value `yield* operation` hands back, which has the caller's context baked in.
139
206
  */
@@ -144,12 +211,12 @@ export interface PaginatedCall<I, O, E, R, Item> {
144
211
  }
145
212
  /**
146
213
  * A paginated operation: usable both ways an {@link OperationMethod} is, with
147
- * `.pages` / `.items` on BOTH — the operation object for
214
+ * `.pages` / `.items` on BOTH -- the operation object for
148
215
  * `yield* op.items(input)`, and the requirement-free call function for
149
216
  * `const op = yield* operation; yield* op.items(input)` (distilled #145).
150
217
  */
151
- export type PaginatedOperationMethod<I, O, E, R, Item = PaginatedItem<O>> = Effect.Effect<PaginatedCall<I, O, E, never, Item>, never, R> & PaginatedCall<I, O, E, R, Item>;
152
- export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> extends OperationConfig<I, O, PE, PR, E> {
218
+ export type PaginatedOperationMethod<I, O, E, R, Item = PaginatedItem<O>> = Effect.Effect<PaginatedCall<I, O, E, never, Item>, never, R> & PaginatedCall<I, O, E, R, Item> & OperationSchemas<I, O>;
219
+ export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[], SE extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> extends OperationConfig<I, O, PE, PR, E, SE> {
153
220
  /** How to advance between pages (mirrors the `smithy.api#paginated` trait). */
154
221
  pagination: Pagination.PaginatedTrait;
155
222
  }
@@ -160,6 +227,108 @@ export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE,
160
227
  * traversal on the first empty page); the default dispatches on
161
228
  * `pagination.mode`.
162
229
  */
163
- export declare function makePaginated<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => PaginatedOperationConfig<I, O, PE, PR, E>, strategy?: Pagination.PaginationStrategy): PaginatedOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, InstanceType<E[number]> | PE | HttpClientError.HttpClientError, PR | HttpClient.HttpClient>;
230
+ export declare function makePaginated<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly [], const SE extends readonly ApiErrorClass[] = readonly []>(configFn: () => PaginatedOperationConfig<I, O, PE, PR, E, SE>, strategy?: Pagination.PaginationStrategy): PaginatedOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, MadeError<E, SE, PE>, PR | HttpClient.HttpClient>;
231
+ /** The message type of a server-streaming output, `{ items: Message[] }`. */
232
+ export type StreamedItem<O> = O extends {
233
+ readonly items: ReadonlyArray<infer Item>;
234
+ } ? Item : O extends {
235
+ readonly items?: ReadonlyArray<infer Item> | undefined;
236
+ } ? Item : unknown;
237
+ /**
238
+ * The callable half of a server-streaming operation: the call, which
239
+ * collects the whole stream into `{ items }`, plus `.stream(input)`, which
240
+ * emits each message as it arrives.
241
+ */
242
+ export interface StreamingCall<I, O, E, R, Item> {
243
+ (input: I): Effect.Effect<O, E, R>;
244
+ readonly stream: (input: I) => Stream.Stream<Item, E, R>;
245
+ }
246
+ /**
247
+ * A server-streaming operation: usable both ways an {@link OperationMethod}
248
+ * is, with `.stream` on both the operation and the requirement-free call
249
+ * function `yield* operation` returns.
250
+ */
251
+ export type StreamingOperationMethod<I, O, E, R, Item = StreamedItem<O>> = Effect.Effect<StreamingCall<I, O, E, never, Item>, never, R> & StreamingCall<I, O, E, R, Item> & OperationSchemas<I, O>;
252
+ /** The `.stream()` of an operation its protocol can't stream: fails with {@link SdkError}. */
253
+ export declare const cannotStream: (operation: Pick<PreparedOperation, "config">) => Stream.Stream<never, SdkError>;
254
+ /**
255
+ * Like {@link make}, for a server-streaming RPC whose output is `{ items }`:
256
+ * calling it collects the stream, and `.stream(input)` emits each message as
257
+ * the protocol receives it (see {@link Protocol.stream}).
258
+ *
259
+ * An operation that streams only when its input asks keeps its own output:
260
+ * its config sets `items` (one frame) and `streamInput` (what `.stream()`
261
+ * sends), and the plain call is a normal call.
262
+ */
263
+ export declare function makeStreaming<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly [], const SE extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, PE, PR, E, SE>): StreamingOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, MadeError<E, SE, PE>, PR | HttpClient.HttpClient>;
264
+ /**
265
+ * Generated operations described by data instead of code.
266
+ *
267
+ * A service module holds each operation as one arrow that is both the
268
+ * callable operation and the holder of its description:
269
+ *
270
+ * export const getFile = API.op((i) => i === API.D ? ['{input:#1,...};__more', [__0, __4, ...]] : API.call(getFile, i));
271
+ *
272
+ * Called with {@link D}, it returns `[data, refs]`: `;`-separated entries
273
+ * in a small expression language (below) and the values they name. `refs[0]`
274
+ * is the schema-lite `at` (lazy schema wrapper). Schemas reached by more
275
+ * than one operation live in shared holders, `function __d3() { return
276
+ * [data, refs]; }`, named in `refs` so a bundler keeps only the holders an
277
+ * operation reaches. Entry 0 of an operation is its config; the rest are
278
+ * schemas and thunk bodies. Evaluating an entry calls the same
279
+ * constructors the code form called, in the same order, so the result is
280
+ * the same schema.
281
+ *
282
+ * Importing a module allocates one function per operation and one per
283
+ * holder; the data stays text in the module source until first use. A
284
+ * holder's refs may also be values built from module code on first use
285
+ * (service traits, endpoint rules), which its value entries name.
286
+ *
287
+ * Grammar (`;` never appears outside an entry separator; strings escape it):
288
+ *
289
+ * $N refs[N]
290
+ * #N #R:N schema entry N of this holder / of the holder refs[R] (lazy, memoized)
291
+ * ~N ~R:N value entry N of this holder / of refs[R] (a constant, evaluated once)
292
+ * >N thunk `() => entry N`
293
+ * "..." -1.5 true false null JSON literal u undefined
294
+ * {k:e,"k":e} object [e,e] array
295
+ * e(a,b) call e.name member e.name(a,b) method call e@"X" e.annotate({ identifier: "X" })
296
+ */
297
+ export declare const D: unique symbol;
298
+ type DataFn = (i?: unknown) => any;
299
+ /** A schema of a holder, for module-level code (error classes) that names one at import. */
300
+ export declare const schema: (fn: DataFn, j: number) => any;
301
+ /**
302
+ * The data of an operation whose name recurs in its strings: `%` in them
303
+ * stands for `stem` (a literal `%` is escaped).
304
+ */
305
+ export declare const named: (stem: string, data: string, refs: unknown) => [string, unknown];
306
+ /** An operation described by data (see the region header). */
307
+ export declare const op: (fn: DataFn) => any;
308
+ /** A paginated operation described by data; its config may name a `strategy`. */
309
+ export declare const opPaginated: (fn: DataFn) => any;
310
+ /** A server-streaming operation described by data. */
311
+ export declare const opStreaming: (fn: DataFn) => any;
312
+ /** The call path of a data operation. */
313
+ export declare const call: (op: unknown, input: unknown) => Effect.Effect<any, any, any>;
314
+ /** An error class described by data (see {@link errorBase}). */
315
+ export declare const error: (fn: DataFn) => any;
316
+ /**
317
+ * The body of a data error class: with `new`, an instance of the built
318
+ * base whose prototype is `newTarget`'s; called plainly, the class's data.
319
+ */
320
+ export declare const newError: (props: unknown, newTarget: Function | undefined, data: unknown) => any;
321
+ /**
322
+ * The placeholders of a lazy service module (see the region header): `o()`
323
+ * and `e()` make the next operation / error class. A placeholder finds its
324
+ * data by its index; it closes over nothing of its own, so it costs one
325
+ * function.
326
+ */
327
+ export declare const lazyService: (url: string, spec: string, kinds: string, ns?: readonly any[], at?: number, len?: number) => {
328
+ readonly o: () => any;
329
+ readonly e: (name: string) => any;
330
+ readonly E: any;
331
+ };
332
+ export declare const lazyNamespace: (url: string, spec: string) => any;
164
333
  export {};
165
334
  //# sourceMappingURL=api.d.ts.map
package/lib/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAI7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAe,KAAK,MAAM,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,UAAU,MAAM,iCAAiC,CA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M,IAAI,OAAQ,OAAO,SAAS,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAC3B,CAAC;AAiDpD,gEAAgE;AAChE,eAAO,MAAM,KAAK,OAAQ,MAAM,KAAG,GAA+C,CAAC;AAEnF;;;GAGG;AACH,eAAO,MAAM,QAAQ,UAAW,OAAO,aAAa,QAAQ,GAAG,SAAS,QAAQ,OAAO,KAAG,GACT,CAAC;AA4XlF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QACjB,MAAM,QACL,MAAM,SACL,MAAM,OACR,SAAS,GAAG,EAAE,OACd,MAAM,QACL,MAAM,KACX;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAA;CA8B7E,CAAC;AAqBF,eAAO,MAAM,aAAa,QAAS,MAAM,QAAQ,MAAM,KAAG,GAiBvD,CAAC"}
package/lib/api.js CHANGED
@@ -1,178 +1 @@
1
- import * as Context from "effect/Context";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Option from "effect/Option";
5
- import * as S from "effect/Schema";
6
- import { pipeArguments } from "effect/Pipeable";
7
- import * as Ref from "effect/Ref";
8
- import * as Scope from "effect/Scope";
9
- import { SingleShotGen } from "effect/Utils";
10
- import * as Pagination from "./pagination.js";
11
- import { makeDefault } from "./retry.js";
12
- import * as HttpClient from "effect/unstable/http/HttpClient";
13
- /**
14
- * The Protocol service knows how to turn a value into an HTTP request using
15
- * only the input schema's trait annotations, and how to turn a response back
16
- * into an output value using the output schema's trait annotations.
17
- *
18
- * Swap implementations by providing a different `Layer<Protocol>`.
19
- */
20
- export class Protocol extends Context.Service()("Protocol") {
21
- }
22
- // NOTE: request/response ASTs are handed to the protocol RAW (Suspend nodes
23
- // included). Pre-resolving Suspends here would drop annotations that sit on
24
- // intermediate nodes — e.g. a bare-payload response whose payload type is
25
- // itself a suspended schema carries its EnvelopePayloadRoot marker on the
26
- // inner Suspend, and unwrapping it silently degrades decode to the struct
27
- // path. The protocol helpers (core/protocol-http getAnn/getProps) descend
28
- // Suspends themselves, and `Suspend.thunk` memoizes, so raw ASTs cost
29
- // nothing extra.
30
- /**
31
- * Protocol layers are built once per process and shared by every operation
32
- * call (keyed by layer value identity — generated operations all reference the
33
- * same module-level layer const). The build runs against a process-lifetime
34
- * scope, and concurrent first calls are deduplicated through a private
35
- * MemoMap.
36
- *
37
- * Contract for protocol implementations: the layer build must not capture
38
- * per-call context. Anything call-dependent — credentials, per-request
39
- * options — must be resolved inside `encode`/`decode`, which execute on the
40
- * calling fiber and therefore see the caller's services on every request.
41
- */
42
- const protocolMemoMap = Layer.makeMemoMapUnsafe();
43
- const protocolScope = Scope.makeUnsafe();
44
- const protocolContexts = new WeakMap();
45
- const protocolContext = (layer) => {
46
- const cached = protocolContexts.get(layer);
47
- if (cached)
48
- return Effect.succeed(cached);
49
- return Effect.map(Layer.buildWithMemoMap(layer, protocolMemoMap, protocolScope), (ctx) => {
50
- protocolContexts.set(layer, ctx);
51
- return ctx;
52
- });
53
- };
54
- /**
55
- * Wrap one operation call with the caller-provided retry policy, if the
56
- * operation declares a retry tag and the context carries a policy for it.
57
- */
58
- const applyRetry = (base, retryKey) => retryKey === undefined
59
- ? base
60
- : Effect.flatMap(Effect.serviceOption(retryKey), (opt) => Effect.gen(function* () {
61
- const lastError = yield* Ref.make(undefined);
62
- // No policy in context → makeDefault (transient/throttling/server
63
- // errors, capped exponential backoff + jitter, honors server
64
- // retryAfter hints). Mirrors the distilled client.
65
- const policy = Option.isSome(opt) ? opt.value : makeDefault;
66
- const opts = typeof policy === "function" ? policy(lastError) : policy;
67
- if (!opts.while)
68
- return yield* base;
69
- return yield* base.pipe(Effect.tapError((e) => Ref.set(lastError, e)), Effect.retry({
70
- while: (e) => opts.while(e),
71
- ...(opts.schedule ? { schedule: opts.schedule } : {}),
72
- }));
73
- }));
74
- export function make(configFn) {
75
- let prepared;
76
- const prepare = () => {
77
- if (prepared)
78
- return prepared;
79
- const cfg = configFn();
80
- prepared = {
81
- cfg,
82
- inputAst: cfg.input.ast,
83
- outputAst: cfg.output.ast,
84
- };
85
- return prepared;
86
- };
87
- const fn = (input) => Effect.suspend(() => {
88
- const { cfg, inputAst, outputAst } = prepare();
89
- const call = Effect.flatMap(protocolContext(cfg.protocol), (protocolCtx) => Effect.gen(function* () {
90
- const protocol = yield* Protocol;
91
- const client = yield* HttpClient.HttpClient;
92
- const request = yield* protocol.encode({
93
- input,
94
- inputAst,
95
- config: cfg,
96
- });
97
- const response = yield* client.execute(request);
98
- return yield* protocol.decode({
99
- response,
100
- outputAst,
101
- errors: cfg.errors ?? [],
102
- config: cfg,
103
- });
104
- }).pipe(Effect.provideContext(protocolCtx)));
105
- return applyRetry(call, cfg.retry);
106
- });
107
- // Make the operation itself yieldable: `yield* operation` captures the
108
- // current context and returns a requirement-free call function (mirrors
109
- // the distilled repo's OperationMethod).
110
- const Proto = {
111
- [Symbol.iterator]() {
112
- return new SingleShotGen(this.asEffect());
113
- },
114
- pipe() {
115
- return pipeArguments(this.asEffect(), arguments);
116
- },
117
- asEffect() {
118
- return Effect.map(Effect.context(), (context) => (input) => Effect.provideContext(fn(input), context));
119
- },
120
- };
121
- Object.assign(fn, Proto);
122
- // Debug/introspection surface carried over from the distilled client:
123
- // the operation's metadata is readable off the exported callable
124
- // (e.g. `iam.listRoles.input` / `.output` / `.errors` / `.operationName`
125
- // / `.pagination`). Lazy getters, so importing a service module doesn't
126
- // force its suspended schemas.
127
- Object.defineProperties(fn, {
128
- input: { get: () => prepare().cfg.input, configurable: true },
129
- output: { get: () => prepare().cfg.output, configurable: true },
130
- errors: { get: () => prepare().cfg.errors ?? [], configurable: true },
131
- operationName: {
132
- get: () => prepare().cfg.operationName,
133
- configurable: true,
134
- },
135
- pagination: {
136
- get: () => prepare().cfg.pagination,
137
- configurable: true,
138
- },
139
- });
140
- return fn;
141
- }
142
- /**
143
- * Like {@link make}, plus `.pages()` / `.items()` streaming built on the
144
- * operation's pagination trait. The SDK can pass a provider-specific
145
- * {@link Pagination.PaginationStrategy} (e.g. Cloudflare stops page-mode
146
- * traversal on the first empty page); the default dispatches on
147
- * `pagination.mode`.
148
- */
149
- export function makePaginated(configFn, strategy) {
150
- const fn = make(configFn);
151
- // configFn is a cheap object literal over already-constructed consts —
152
- // re-invoking it here just reads the pagination trait (memoized).
153
- let pagination;
154
- const pag = () => (pagination ??= configFn().pagination);
155
- const paginate = strategy ?? Pagination.paginateWithDefaults;
156
- // The streams are built over a CALL FUNCTION, so the same code serves both
157
- // call styles: the operation itself (requirements intact), and the
158
- // context-bound function `yield* operation` hands back — whose streams
159
- // inherit that captured context and so need nothing after the yield.
160
- const withStreams = (call) => {
161
- const pages = (input) => paginate(call, input, pag());
162
- const items = (input) => {
163
- const p = pag();
164
- return p.items
165
- ? Pagination.extractItems(pages(input), p.items)
166
- : pages(input);
167
- };
168
- return Object.assign(call, { pages, items });
169
- };
170
- // `yield* operation` runs through `make`'s Proto.asEffect, which builds a
171
- // fresh arrow and would drop `.pages` / `.items` (distilled #145). Override
172
- // it here — Proto's `[Symbol.iterator]`/`pipe` dispatch on `this`, so both
173
- // pick this up. Only paginated operations pay for it.
174
- fn.asEffect = () => Effect.map(Effect.context(), (context) => withStreams((input) => Effect.provideContext(fn(input), context)));
175
- return withStreams(fn);
176
- }
177
- //#endregion
178
- //# sourceMappingURL=api.js.map
1
+ export { api$D as D, api$call as call, api$cannotStream as cannotStream, api$describeOperation as describeOperation, api$encodeRequest as encodeRequest, api$error as error, api$lazyNamespace as lazyNamespace, api$lazyService as lazyService, api$make as make, api$makePaginated as makePaginated, api$makeStreaming as makeStreaming, api$named as named, api$newError as newError, api$op as op, api$opPaginated as opPaginated, api$opStreaming as opStreaming, api$schema as schema, api$withValue as withValue } from "./_bundle/base.js";
package/lib/category.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * ```ts
10
10
  * import * as Category from "@distilled.cloud/core/category";
11
11
  *
12
- * export class Unauthorized extends Schema.TaggedErrorClass<Unauthorized>()(
12
+ * export class Unauthorized extends Schema.TaggedError<Unauthorized>()(
13
13
  * "Unauthorized",
14
14
  * { message: Schema.String },
15
15
  * ).pipe(Category.withAuthError) {}
@@ -56,7 +56,7 @@ export interface RetryableInfo {
56
56
  *
57
57
  * @example
58
58
  * ```ts
59
- * export class MyError extends Schema.TaggedErrorClass<MyError>()(
59
+ * export class MyError extends Schema.TaggedError<MyError>()(
60
60
  * "MyError",
61
61
  * { message: Schema.String },
62
62
  * ).pipe(Category.withCategory(Category.AuthError)) {}
@@ -76,13 +76,13 @@ export declare const withCategory: <Categories extends Array<Category>>(...categ
76
76
  * @example
77
77
  * ```ts
78
78
  * // Standard retryable error
79
- * export class TransientError extends Schema.TaggedErrorClass<TransientError>()(
79
+ * export class TransientError extends Schema.TaggedError<TransientError>()(
80
80
  * "TransientError",
81
81
  * { message: Schema.String },
82
82
  * ).pipe(Category.withRetryable()) {}
83
83
  *
84
84
  * // Throttling error (uses longer backoff)
85
- * export class RateLimitError extends Schema.TaggedErrorClass<RateLimitError>()(
85
+ * export class RateLimitError extends Schema.TaggedError<RateLimitError>()(
86
86
  * "RateLimitError",
87
87
  * { message: Schema.String },
88
88
  * ).pipe(Category.withRetryable({ throttling: true })) {}
@@ -237,18 +237,21 @@ export declare const isRetryable: (error: unknown) => boolean;
237
237
  */
238
238
  export declare const isThrottling: (error: unknown) => boolean;
239
239
  /**
240
- * Check if an error is a transient error that should be automatically retried.
241
- * Transient errors include:
242
- * - Errors marked with withRetryable()
243
- * - RetryableError category
244
- * - ThrottlingError (rate limiting)
245
- * - ServerError (5xx responses)
246
- * - NetworkError (connection issues)
247
- * - TimeoutError (request timed out)
248
- * - LockedError (423 - resource temporarily locked)
249
- * - Effect `HttpClientError` with `reason._tag === "TransportError"`
250
- * (undici connect/read timeout, socket reset, DNS failure, premature
251
- * stream close)
240
+ * Check if an error should be retried automatically. Only errors that say
241
+ * so are retried; an HTTP status alone does not make an error retryable:
242
+ *
243
+ * - errors marked with `withRetryable()` (Smithy `@retryable`, a patch, or
244
+ * the SDK's own error classes);
245
+ * - the `RetryableError` and `ThrottlingError` categories (`ThrottlingError`
246
+ * is HTTP 429, the server's own "try again later");
247
+ * - the `NetworkError` category: the request failed on the way, before any
248
+ * server answered;
249
+ * - an Effect `HttpClientError` with `reason._tag === "TransportError"`
250
+ * (connect timeout, socket reset, DNS failure, premature stream close),
251
+ * which no spec can mark.
252
+ *
253
+ * `ServerError`, `TimeoutError` and `LockedError` describe an
254
+ * error; they do not retry it.
252
255
  */
253
256
  export declare const isTransientError: (error: unknown) => boolean;
254
257
  export type AllKeys<E> = E extends {