@distilled.cloud/core 0.30.3 → 1.0.0-rc.10

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 (216) hide show
  1. package/LICENSE +201 -0
  2. package/lib/api.d.ts +165 -0
  3. package/lib/api.d.ts.map +1 -0
  4. package/lib/api.js +190 -0
  5. package/lib/api.js.map +1 -0
  6. package/lib/category.d.ts +4 -4
  7. package/lib/category.js +4 -4
  8. package/lib/codegen/boolean-string-enums.d.ts +36 -0
  9. package/lib/codegen/boolean-string-enums.d.ts.map +1 -0
  10. package/lib/codegen/boolean-string-enums.js +94 -0
  11. package/lib/codegen/boolean-string-enums.js.map +1 -0
  12. package/lib/codegen/boolean-string-enums.test.d.ts +2 -0
  13. package/lib/codegen/boolean-string-enums.test.d.ts.map +1 -0
  14. package/lib/codegen/boolean-string-enums.test.js +147 -0
  15. package/lib/codegen/boolean-string-enums.test.js.map +1 -0
  16. package/lib/codegen/cli.d.ts +79 -0
  17. package/lib/codegen/cli.d.ts.map +1 -0
  18. package/lib/codegen/cli.js +149 -0
  19. package/lib/codegen/cli.js.map +1 -0
  20. package/lib/codegen/emit.d.ts +125 -0
  21. package/lib/codegen/emit.d.ts.map +1 -0
  22. package/lib/codegen/emit.js +101 -0
  23. package/lib/codegen/emit.js.map +1 -0
  24. package/lib/codegen/format.d.ts +23 -0
  25. package/lib/codegen/format.d.ts.map +1 -0
  26. package/lib/codegen/format.js +28 -0
  27. package/lib/codegen/format.js.map +1 -0
  28. package/lib/codegen/generator.d.ts +334 -0
  29. package/lib/codegen/generator.d.ts.map +1 -0
  30. package/lib/codegen/generator.js +813 -0
  31. package/lib/codegen/generator.js.map +1 -0
  32. package/lib/codegen/graph.d.ts +36 -0
  33. package/lib/codegen/graph.d.ts.map +1 -0
  34. package/lib/codegen/graph.js +136 -0
  35. package/lib/codegen/graph.js.map +1 -0
  36. package/lib/codegen/graphql-client.d.ts +62 -0
  37. package/lib/codegen/graphql-client.d.ts.map +1 -0
  38. package/lib/codegen/graphql-client.js +294 -0
  39. package/lib/codegen/graphql-client.js.map +1 -0
  40. package/lib/codegen/graphql-client.test.d.ts +2 -0
  41. package/lib/codegen/graphql-client.test.d.ts.map +1 -0
  42. package/lib/codegen/graphql-client.test.js +311 -0
  43. package/lib/codegen/graphql-client.test.js.map +1 -0
  44. package/lib/codegen/graphql.d.ts +207 -0
  45. package/lib/codegen/graphql.d.ts.map +1 -0
  46. package/lib/codegen/graphql.js +799 -0
  47. package/lib/codegen/graphql.js.map +1 -0
  48. package/lib/codegen/members.d.ts +25 -0
  49. package/lib/codegen/members.d.ts.map +1 -0
  50. package/lib/codegen/members.js +55 -0
  51. package/lib/codegen/members.js.map +1 -0
  52. package/lib/codegen/naming.d.ts +29 -0
  53. package/lib/codegen/naming.d.ts.map +1 -0
  54. package/lib/codegen/naming.js +74 -0
  55. package/lib/codegen/naming.js.map +1 -0
  56. package/lib/codegen/openapi-cli.d.ts +52 -0
  57. package/lib/codegen/openapi-cli.d.ts.map +1 -0
  58. package/lib/codegen/openapi-cli.js +109 -0
  59. package/lib/codegen/openapi-cli.js.map +1 -0
  60. package/lib/codegen/openapi.d.ts +178 -0
  61. package/lib/codegen/openapi.d.ts.map +1 -0
  62. package/lib/codegen/openapi.js +1377 -0
  63. package/lib/codegen/openapi.js.map +1 -0
  64. package/lib/codegen/operations.d.ts +24 -0
  65. package/lib/codegen/operations.d.ts.map +1 -0
  66. package/lib/codegen/operations.js +56 -0
  67. package/lib/codegen/operations.js.map +1 -0
  68. package/lib/codegen/pagination.d.ts +39 -0
  69. package/lib/codegen/pagination.d.ts.map +1 -0
  70. package/lib/codegen/pagination.js +33 -0
  71. package/lib/codegen/pagination.js.map +1 -0
  72. package/lib/codegen/patches.d.ts +65 -0
  73. package/lib/codegen/patches.d.ts.map +1 -0
  74. package/lib/codegen/patches.js +236 -0
  75. package/lib/codegen/patches.js.map +1 -0
  76. package/lib/codegen/patches.test.d.ts +2 -0
  77. package/lib/codegen/patches.test.d.ts.map +1 -0
  78. package/lib/codegen/patches.test.js +105 -0
  79. package/lib/codegen/patches.test.js.map +1 -0
  80. package/lib/codegen/prelude.d.ts +15 -0
  81. package/lib/codegen/prelude.d.ts.map +1 -0
  82. package/lib/codegen/prelude.js +60 -0
  83. package/lib/codegen/prelude.js.map +1 -0
  84. package/lib/codegen/proto.d.ts +121 -0
  85. package/lib/codegen/proto.d.ts.map +1 -0
  86. package/lib/codegen/proto.js +962 -0
  87. package/lib/codegen/proto.js.map +1 -0
  88. package/lib/codegen/rewrite-operation-ids.d.ts +131 -0
  89. package/lib/codegen/rewrite-operation-ids.d.ts.map +1 -0
  90. package/lib/codegen/rewrite-operation-ids.js +1079 -0
  91. package/lib/codegen/rewrite-operation-ids.js.map +1 -0
  92. package/lib/codegen/rewrite-operation-ids.test.d.ts +2 -0
  93. package/lib/codegen/rewrite-operation-ids.test.d.ts.map +1 -0
  94. package/lib/codegen/rewrite-operation-ids.test.js +533 -0
  95. package/lib/codegen/rewrite-operation-ids.test.js.map +1 -0
  96. package/lib/codegen/spec-path.d.ts +16 -0
  97. package/lib/codegen/spec-path.d.ts.map +1 -0
  98. package/lib/codegen/spec-path.js +101 -0
  99. package/lib/codegen/spec-path.js.map +1 -0
  100. package/lib/error-category.d.ts +28 -0
  101. package/lib/error-category.d.ts.map +1 -0
  102. package/lib/error-category.js +46 -0
  103. package/lib/error-category.js.map +1 -0
  104. package/lib/errors.d.ts +1 -0
  105. package/lib/errors.d.ts.map +1 -1
  106. package/lib/errors.js +18 -13
  107. package/lib/errors.js.map +1 -1
  108. package/lib/graphql.d.ts +284 -0
  109. package/lib/graphql.d.ts.map +1 -0
  110. package/lib/graphql.fixture.d.ts +249 -0
  111. package/lib/graphql.fixture.d.ts.map +1 -0
  112. package/lib/graphql.fixture.js +240 -0
  113. package/lib/graphql.fixture.js.map +1 -0
  114. package/lib/graphql.js +718 -0
  115. package/lib/graphql.js.map +1 -0
  116. package/lib/graphql.test.d.ts +2 -0
  117. package/lib/graphql.test.d.ts.map +1 -0
  118. package/lib/graphql.test.js +780 -0
  119. package/lib/graphql.test.js.map +1 -0
  120. package/lib/graphql.types.d.ts +2 -0
  121. package/lib/graphql.types.d.ts.map +1 -0
  122. package/lib/graphql.types.js +45 -0
  123. package/lib/graphql.types.js.map +1 -0
  124. package/lib/json-patch.d.ts +30 -30
  125. package/lib/json-patch.d.ts.map +1 -1
  126. package/lib/json-patch.js +73 -107
  127. package/lib/json-patch.js.map +1 -1
  128. package/lib/pagination.d.ts +77 -51
  129. package/lib/pagination.d.ts.map +1 -1
  130. package/lib/pagination.js +162 -94
  131. package/lib/pagination.js.map +1 -1
  132. package/lib/protocol-http.d.ts +74 -0
  133. package/lib/protocol-http.d.ts.map +1 -0
  134. package/lib/protocol-http.js +590 -0
  135. package/lib/protocol-http.js.map +1 -0
  136. package/lib/protocol-http.test.d.ts +2 -0
  137. package/lib/protocol-http.test.d.ts.map +1 -0
  138. package/lib/protocol-http.test.js +88 -0
  139. package/lib/protocol-http.test.js.map +1 -0
  140. package/lib/protocol-rest.d.ts +134 -0
  141. package/lib/protocol-rest.d.ts.map +1 -0
  142. package/lib/protocol-rest.js +256 -0
  143. package/lib/protocol-rest.js.map +1 -0
  144. package/lib/retry.d.ts +8 -2
  145. package/lib/retry.d.ts.map +1 -1
  146. package/lib/retry.js +22 -16
  147. package/lib/retry.js.map +1 -1
  148. package/lib/schema.d.ts +8 -9
  149. package/lib/schema.d.ts.map +1 -1
  150. package/lib/schema.js +8 -9
  151. package/lib/schema.js.map +1 -1
  152. package/lib/trait.d.ts +174 -0
  153. package/lib/trait.d.ts.map +1 -0
  154. package/lib/trait.js +123 -0
  155. package/lib/trait.js.map +1 -0
  156. package/package.json +24 -78
  157. package/src/api.ts +460 -0
  158. package/src/category.ts +4 -4
  159. package/src/codegen/boolean-string-enums.test.ts +168 -0
  160. package/src/codegen/boolean-string-enums.ts +106 -0
  161. package/src/codegen/cli.ts +285 -0
  162. package/src/codegen/emit.ts +203 -0
  163. package/src/codegen/format.ts +47 -0
  164. package/src/codegen/generator.ts +1283 -0
  165. package/src/codegen/graph.ts +151 -0
  166. package/src/codegen/graphql-client.test.ts +386 -0
  167. package/src/codegen/graphql-client.ts +419 -0
  168. package/src/codegen/graphql.ts +1217 -0
  169. package/src/codegen/members.ts +71 -0
  170. package/src/codegen/naming.ts +86 -0
  171. package/src/codegen/openapi-cli.ts +182 -0
  172. package/src/codegen/openapi.ts +1689 -0
  173. package/src/codegen/operations.ts +76 -0
  174. package/src/codegen/pagination.ts +71 -0
  175. package/src/codegen/patches.test.ts +130 -0
  176. package/src/codegen/patches.ts +291 -0
  177. package/src/codegen/prelude.ts +70 -0
  178. package/src/codegen/proto.ts +1128 -0
  179. package/src/codegen/rewrite-operation-ids.test.ts +563 -0
  180. package/src/codegen/rewrite-operation-ids.ts +1206 -0
  181. package/src/codegen/spec-path.ts +115 -0
  182. package/src/error-category.ts +84 -0
  183. package/src/errors.ts +22 -25
  184. package/src/graphql.fixture.ts +371 -0
  185. package/src/graphql.test.ts +974 -0
  186. package/src/graphql.ts +1321 -0
  187. package/src/graphql.types.ts +185 -0
  188. package/src/json-patch.ts +95 -122
  189. package/src/pagination.ts +217 -146
  190. package/src/protocol-http.test.ts +107 -0
  191. package/src/protocol-http.ts +735 -0
  192. package/src/protocol-rest.ts +391 -0
  193. package/src/retry.ts +21 -22
  194. package/src/schema.ts +9 -10
  195. package/src/trait.ts +274 -0
  196. package/README.md +0 -30
  197. package/lib/client.d.ts +0 -167
  198. package/lib/client.d.ts.map +0 -1
  199. package/lib/client.js +0 -659
  200. package/lib/client.js.map +0 -1
  201. package/lib/schemas.d.ts +0 -60
  202. package/lib/schemas.d.ts.map +0 -1
  203. package/lib/schemas.js +0 -79
  204. package/lib/schemas.js.map +0 -1
  205. package/lib/sensitive.d.ts +0 -71
  206. package/lib/sensitive.d.ts.map +0 -1
  207. package/lib/sensitive.js +0 -96
  208. package/lib/sensitive.js.map +0 -1
  209. package/lib/traits.d.ts +0 -421
  210. package/lib/traits.d.ts.map +0 -1
  211. package/lib/traits.js +0 -737
  212. package/lib/traits.js.map +0 -1
  213. package/src/client.ts +0 -1177
  214. package/src/schemas.ts +0 -128
  215. package/src/sensitive.ts +0 -119
  216. package/src/traits.ts +0 -996
package/lib/traits.d.ts DELETED
@@ -1,421 +0,0 @@
1
- import * as AST from "effect/SchemaAST";
2
- /**
3
- * Internal symbol for annotation metadata storage.
4
- */
5
- declare const annotationMetaSymbol: unique symbol;
6
- /**
7
- * Any type that has an .annotate() method returning itself.
8
- * This includes Schema.Schema and Schema.PropertySignature.
9
- */
10
- type Annotatable = {
11
- annotate(annotations: unknown): Annotatable;
12
- };
13
- /**
14
- * An Annotation is a callable that can be used with .pipe() AND
15
- * has symbol properties so it works directly with Schema.Struct/Class.
16
- *
17
- * The index signatures allow TypeScript to accept this as a valid annotations object.
18
- */
19
- export interface Annotation {
20
- <A extends Annotatable>(schema: A): A;
21
- readonly [annotationMetaSymbol]: Array<{
22
- symbol: symbol;
23
- value: unknown;
24
- }>;
25
- readonly [key: symbol]: unknown;
26
- readonly [key: string]: unknown;
27
- }
28
- /**
29
- * Create an annotation builder for a given symbol and value.
30
- * This is the core primitive used to build all trait annotations.
31
- */
32
- export declare function makeAnnotation<T>(sym: symbol, value: T): Annotation;
33
- /**
34
- * Combine multiple annotations into one.
35
- * Use when you need multiple annotations on the same schema.
36
- *
37
- * @example
38
- * ```ts
39
- * const MyInput = Schema.Struct({
40
- * id: Schema.String.pipe(T.all(T.PathParam(), T.Required())),
41
- * });
42
- * ```
43
- */
44
- export declare function all(...annotations: Annotation[]): Annotation;
45
- /** Symbol for HTTP operation metadata (method + path template) */
46
- export declare const httpSymbol: unique symbol;
47
- /** HTTP method type */
48
- export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
49
- /** HTTP trait configuration */
50
- export interface HttpTrait {
51
- /** HTTP method */
52
- method: HttpMethod;
53
- /** Path template with {param} placeholders */
54
- path: string;
55
- /**
56
- * Request body content type. Recognized values:
57
- * - `"multipart"` — `multipart/form-data` (file uploads)
58
- * - `"form-urlencoded"` — `application/x-www-form-urlencoded`
59
- * - `"binary"` — `application/octet-stream` (raw byte body
60
- * accepting `Blob | Uint8Array | ArrayBuffer |
61
- * string | Stream<Uint8Array> | ReadableStream`)
62
- * - `undefined` — JSON
63
- */
64
- contentType?: string;
65
- /**
66
- * Explicit `Content-Type` for a `contentType: "binary"` request body when the
67
- * API requires a specific media type rather than the generic
68
- * `application/octet-stream` (e.g. `application/x-ndjson` for Vectorize
69
- * insert/upsert). Ignored unless `contentType === "binary"`; a caller-supplied
70
- * `content-type` header still wins.
71
- */
72
- bodyMediaType?: string;
73
- /**
74
- * Response body content type. Recognized values:
75
- * - `"binary"` — `application/octet-stream` download. The runtime
76
- * bypasses JSON decoding and returns the body as an
77
- * Effect `Stream.Stream<Uint8Array>`.
78
- * - `undefined` — JSON / text decoded through the operation's output
79
- * schema.
80
- */
81
- responseContentType?: string;
82
- /** Whether the request has a body (used by GCP generator) */
83
- hasBody?: boolean;
84
- /**
85
- * Default value for a versioned API's `api-version` query parameter, baked in
86
- * at generation time. When set, the client injects `?api-version=<value>` on
87
- * every request for this operation unless the caller already supplied one.
88
- * Used by APIs like Azure ARM where `api-version` is required on every call
89
- * and differs per resource provider.
90
- */
91
- apiVersion?: string;
92
- }
93
- /**
94
- * Http trait - defines the HTTP method and path template for an operation.
95
- * Path parameters are specified using {paramName} syntax.
96
- *
97
- * @example
98
- * ```ts
99
- * const GetDatabaseInput = Schema.Struct({
100
- * organization: Schema.String.pipe(T.PathParam()),
101
- * database: Schema.String.pipe(T.PathParam()),
102
- * }).pipe(
103
- * T.Http({ method: "GET", path: "/organizations/{organization}/databases/{database}" })
104
- * );
105
- * ```
106
- */
107
- export declare const Http: (trait: HttpTrait) => Annotation;
108
- /** Symbol for path parameter annotation */
109
- export declare const pathParamSymbol: unique symbol;
110
- /**
111
- * PathParam trait - marks a field as a path parameter.
112
- * The field name is used as the placeholder name in the path template.
113
- *
114
- * @example
115
- * ```ts
116
- * const Input = Schema.Struct({
117
- * organization: Schema.String.pipe(T.PathParam()),
118
- * }).pipe(
119
- * T.Http({ method: "GET", path: "/organizations/{organization}" })
120
- * );
121
- * ```
122
- */
123
- export declare const PathParam: () => Annotation;
124
- /** Symbol for query parameter annotation */
125
- export declare const queryParamSymbol: unique symbol;
126
- /**
127
- * QueryParam trait - marks a field as a query parameter.
128
- * Optionally specify a different wire name.
129
- *
130
- * @example
131
- * ```ts
132
- * const Input = Schema.Struct({
133
- * perPage: Schema.optional(Schema.Number).pipe(T.QueryParam("per_page")),
134
- * });
135
- * ```
136
- */
137
- export declare const QueryParam: (name?: string) => Annotation;
138
- /** Symbol for header parameter annotation */
139
- export declare const headerParamSymbol: unique symbol;
140
- /**
141
- * HeaderParam trait - marks a field as a header parameter.
142
- * Specify the header name.
143
- *
144
- * @example
145
- * ```ts
146
- * const Input = Schema.Struct({
147
- * apiToken: Schema.String.pipe(T.HeaderParam("X-API-Token")),
148
- * });
149
- * ```
150
- */
151
- export declare const HeaderParam: (name: string) => Annotation;
152
- /**
153
- * HttpPath - alias for PathParam that also carries the wire name.
154
- * Used in generated code: `Schema.String.pipe(T.HttpPath("account_id"))`
155
- */
156
- export declare const HttpPath: (name: string) => Annotation;
157
- /**
158
- * HttpQuery - alias for QueryParam with an explicit wire name.
159
- * Used in generated code: `Schema.optional(Schema.String).pipe(T.HttpQuery("per_page"))`
160
- */
161
- export declare const HttpQuery: (name: string) => Annotation;
162
- /**
163
- * HttpHeader - alias for HeaderParam.
164
- * Used in generated code: `Schema.String.pipe(T.HttpHeader("X-Custom-Header"))`
165
- */
166
- export declare const HttpHeader: (name: string) => Annotation;
167
- /** Symbol for HTTP body annotation */
168
- export declare const httpBodySymbol: unique symbol;
169
- /**
170
- * HttpBody - marks a field as the raw HTTP body.
171
- * Used for operations where a field IS the entire request body
172
- * (not a named field within a JSON body).
173
- */
174
- export declare const HttpBody: () => Annotation;
175
- /** Symbol for binary response body annotation */
176
- export declare const binaryResponseBodySymbol: unique symbol;
177
- /**
178
- * BinaryResponseBody - marks a response struct field as the raw binary body
179
- * of an `application/octet-stream` download. The runtime fills the field
180
- * with an Effect `Stream.Stream<Uint8Array>` of the response body. Sibling
181
- * fields annotated with `T.HttpResponseHeader` are populated from the
182
- * matching response headers.
183
- */
184
- export declare const BinaryResponseBody: () => Annotation;
185
- /** Symbol for response header annotation */
186
- export declare const responseHeaderSymbol: unique symbol;
187
- /**
188
- * HttpResponseHeader - marks a response struct field as a value pulled from
189
- * a named HTTP response header (e.g. `etag`, `content-type`). The runtime
190
- * populates the field with the (lowercased) header value if present, and
191
- * leaves it `undefined` otherwise. Mirror of `T.HttpHeader` for response-
192
- * side header extraction.
193
- *
194
- * Currently consumed by binary-download operations (operations whose
195
- * `T.Http({ responseContentType: "binary" })` trait is set), where the
196
- * response struct's shape is `{ body: Stream.Stream<Uint8Array>, ...headers }`.
197
- */
198
- export declare const HttpResponseHeader: (name: string) => Annotation;
199
- /** Symbol for GraphQL operation metadata (query string + operation name) */
200
- export declare const graphqlOpSymbol: unique symbol;
201
- /** GraphQL operation type */
202
- export type GraphQLOpType = "query" | "mutation";
203
- /** GraphQL operation trait configuration */
204
- export interface GraphQLOpTrait {
205
- /** The full GraphQL operation document (e.g., `query getUser($id: ID!) { ... }`) */
206
- query: string;
207
- /** The operation name — used to extract the response from `data.<operationName>` */
208
- operationName: string;
209
- /** Whether this is a query or a mutation */
210
- type: GraphQLOpType;
211
- }
212
- /**
213
- * GraphQLOp trait - declares an operation as GraphQL. When present, the client
214
- * wraps the request body as `{ query, operationName, variables: <inputs> }` and
215
- * extracts the response from `data.<operationName>`. The Http trait's path is
216
- * still used as the GraphQL endpoint (typically `/graphql`).
217
- *
218
- * @example
219
- * ```ts
220
- * const GetUserInput = Schema.Struct({
221
- * id: Schema.String,
222
- * }).pipe(
223
- * T.Http({ method: "POST", path: "/graphql" }),
224
- * T.GraphQLOp({
225
- * query: "query getUser($id: ID!) { user(id: $id) { id name } }",
226
- * operationName: "getUser",
227
- * type: "query",
228
- * }),
229
- * );
230
- * ```
231
- */
232
- export declare const GraphQLOp: (trait: GraphQLOpTrait) => Annotation;
233
- /** Symbol for response body path transformation */
234
- export declare const responsePathSymbol: unique symbol;
235
- /**
236
- * ResponsePath - decode the response from a nested path within the raw body.
237
- * Useful for providers that wrap successful responses in envelopes like
238
- * `{ result: <payload>, result_info: ... }`.
239
- */
240
- export declare const ResponsePath: (path: string) => Annotation;
241
- /** Symbol for form data file annotation */
242
- export declare const httpFormDataFileSymbol: unique symbol;
243
- /**
244
- * HttpFormDataFile - marks a field as a file upload in multipart form data.
245
- */
246
- export declare const HttpFormDataFile: () => Annotation;
247
- /** Symbol for "do not follow redirects; treat 3xx Location header as success body" */
248
- export declare const httpNoFollowRedirectSymbol: unique symbol;
249
- /**
250
- * Configuration for the `NoFollowRedirect` trait.
251
- */
252
- export interface NoFollowRedirectTrait {
253
- /**
254
- * The field name on the success-side output schema that should receive the
255
- * value of the response's `Location` header when the server returns a
256
- * 3xx redirect. Defaults to `"url"`.
257
- *
258
- * Concretely: when an operation carrying this trait gets a 3xx response,
259
- * the runtime client constructs `{ [locationField]: <Location header> }`
260
- * and feeds that into the output schema decoder, instead of trying to
261
- * decode the redirect body (which would normally be HTML or empty).
262
- */
263
- locationField?: string;
264
- }
265
- /**
266
- * NoFollowRedirect trait - opts an operation out of the underlying HTTP
267
- * client's automatic redirect-following.
268
- *
269
- * Some endpoints — notably OAuth/SSO authorize endpoints — return their
270
- * useful result as a `Location` header on a 302 response. The default
271
- * `fetch` follows that redirect to the IdP's HTML login page, so by the
272
- * time the client sees a body it's no longer the SDK's expected JSON.
273
- *
274
- * Marking an operation with this trait makes the runtime client:
275
- * 1. Issue the request with `redirect: "manual"` so the 3xx surfaces
276
- * to user code.
277
- * 2. On a 3xx, build a synthetic body `{ [locationField]: <Location> }`
278
- * and decode that into the output schema (default field name `"url"`).
279
- *
280
- * @example
281
- * ```ts
282
- * const SsoAuthorizeInput = Schema.Struct({...}).pipe(
283
- * T.Http({ method: "GET", path: "/sso/authorize" }),
284
- * T.NoFollowRedirect(),
285
- * );
286
- * const SsoAuthorizeOutput = Schema.Struct({ url: Schema.String });
287
- * ```
288
- */
289
- export declare const NoFollowRedirect: (trait?: NoFollowRedirectTrait) => Annotation;
290
- /** Symbol for API error code mapping */
291
- export declare const apiErrorCodeSymbol: unique symbol;
292
- /**
293
- * ApiErrorCode trait - maps an error class to an API error code.
294
- * Used to match API error responses to typed error classes.
295
- *
296
- * @example
297
- * ```ts
298
- * class NotFoundError extends Schema.TaggedErrorClass<NotFoundError>()(
299
- * "NotFoundError",
300
- * { message: Schema.String },
301
- * ).pipe(T.ApiErrorCode("not_found")) {}
302
- * ```
303
- */
304
- export declare const ApiErrorCode: (code: string) => Annotation;
305
- /** Symbol for service metadata */
306
- export declare const serviceSymbol: unique symbol;
307
- /** Service metadata */
308
- export interface ServiceTrait {
309
- name: string;
310
- version?: string;
311
- baseUrl?: string;
312
- /** GCP-specific: Root URL for the service */
313
- rootUrl?: string;
314
- /** GCP-specific: Service path appended to root URL */
315
- servicePath?: string;
316
- /** Allow additional properties for provider-specific metadata */
317
- [key: string]: unknown;
318
- }
319
- /**
320
- * Service trait - attaches service metadata to a schema.
321
- */
322
- export declare const Service: (trait: ServiceTrait) => Annotation;
323
- /**
324
- * Get annotation value from an AST node, following encoding chain if needed.
325
- */
326
- export declare const getAnnotation: <T>(ast: AST.AST, symbol: symbol) => T | undefined;
327
- /**
328
- * Get HTTP trait from a schema's AST.
329
- */
330
- export declare const getHttpTrait: (ast: AST.AST) => HttpTrait | undefined;
331
- export declare const getResponsePath: (ast: AST.AST) => string | undefined;
332
- /**
333
- * Get GraphQL operation trait from a schema's AST.
334
- */
335
- export declare const getGraphQLOp: (ast: AST.AST) => GraphQLOpTrait | undefined;
336
- /**
337
- * Get the `NoFollowRedirect` trait config from an input schema's AST, if any.
338
- */
339
- export declare const getNoFollowRedirect: (ast: AST.AST) => NoFollowRedirectTrait | undefined;
340
- /**
341
- * Check if a PropertySignature has the pathParam annotation.
342
- * Works for both PathParam() (annotation value = true) and HttpPath("wire_name") (annotation value = string).
343
- */
344
- export declare const isPathParam: (prop: AST.PropertySignature) => boolean;
345
- /**
346
- * Get query param name from a PropertySignature (returns true if unnamed, string if named).
347
- */
348
- export declare const getQueryParam: (prop: AST.PropertySignature) => string | boolean | undefined;
349
- /**
350
- * Get header param name from a PropertySignature.
351
- */
352
- export declare const getHeaderParam: (prop: AST.PropertySignature) => string | undefined;
353
- /**
354
- * Get API error code from an error class AST.
355
- */
356
- export declare const getApiErrorCode: (ast: AST.AST) => string | undefined;
357
- /**
358
- * Get service metadata from a schema's AST.
359
- */
360
- export declare const getServiceTrait: (ast: AST.AST) => ServiceTrait | undefined;
361
- /**
362
- * Extract path parameters from a schema's struct properties.
363
- * Returns an array of field names that have the PathParam annotation.
364
- */
365
- export declare const getPathParams: (ast: AST.AST) => string[];
366
- /**
367
- * Build the request path by substituting path parameters into the template.
368
- * Simple version that assumes input keys match template placeholders.
369
- * For schema-aware path building (with camelCase → wire_name mapping), use buildPathFromSchema.
370
- */
371
- export declare const buildPath: (template: string, input: Record<string, unknown>) => string;
372
- /**
373
- * Extract AST property signatures from a schema AST, following encoding chain and suspends.
374
- */
375
- export declare const getStructProps: (ast: AST.AST) => AST.PropertySignature[];
376
- /**
377
- * Get the path parameter wire name from a PropertySignature.
378
- * - For HttpPath("wire_name"), returns the wire name string.
379
- * - For PathParam(), returns the property name (since annotation is `true`).
380
- * - Returns undefined if not a path param.
381
- */
382
- export declare const getPathParamWireName: (prop: AST.PropertySignature) => string | undefined;
383
- /**
384
- * Result of categorizing a schema's input properties by their HTTP binding.
385
- */
386
- export interface RequestParts {
387
- /** Resolved path with all parameters substituted */
388
- path: string;
389
- /** Query parameters: wire_name → string value */
390
- query: Record<string, string | string[]>;
391
- /** Header parameters: header-name → string value */
392
- headers: Record<string, string>;
393
- /** Body: remaining non-path/query/header properties, with wire-name keys where applicable */
394
- body: Record<string, unknown> | undefined;
395
- /** Whether the body should use multipart/form-data */
396
- isMultipart: boolean;
397
- }
398
- export declare const buildRequestParts: (ast: AST.AST, httpTrait: HttpTrait, rawInput: Record<string, unknown>, inputSchema?: any) => RequestParts;
399
- /**
400
- * Build the response object for a binary-download operation
401
- * (`T.Http({ responseContentType: "binary" })`).
402
- *
403
- * The output schema is expected to be a Struct with one field annotated
404
- * `T.BinaryResponseBody()` (the `body` field — populated with the supplied
405
- * `Stream`) and zero-or-more sibling fields annotated
406
- * `T.HttpResponseHeader(name)` (populated by reading the named response
407
- * header). Header lookups are case-insensitive.
408
- *
409
- * Header values are coerced to the field's declared primitive type so that
410
- * `content-length` lands as a `number`, `last-modified` as a `Date` (when
411
- * the schema declares `Schema.Date`), etc. Anything more exotic stays a
412
- * raw string.
413
- */
414
- export declare const buildBinaryResponse: (ast: AST.AST, body: unknown, responseHeaders: Record<string, string>) => Record<string, unknown>;
415
- /**
416
- * Helper to get a value from an object using a dot-separated path.
417
- * Used for pagination traits and nested property access.
418
- */
419
- export declare const getPath: (obj: unknown, path: string) => unknown;
420
- export {};
421
- //# sourceMappingURL=traits.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAMxC;;GAEG;AACH,QAAA,MAAM,oBAAoB,eAAiD,CAAC;AAE5E;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,QAAQ,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,CAAC;CAC7C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACtC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC;QAAE,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