effect 4.0.3 → 4.0.4

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 (207) hide show
  1. package/AGENTS.md +24 -0
  2. package/CLAUDE.md +24 -0
  3. package/ai-docs/package.json +2 -2
  4. package/ai-docs/src/52_graphql/10_basics.ts +111 -0
  5. package/ai-docs/src/52_graphql/20_testing.ts +45 -0
  6. package/ai-docs/src/52_graphql/30_batching.ts +116 -0
  7. package/ai-docs/src/52_graphql/40_aliased-batching.ts +122 -0
  8. package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
  9. package/ai-docs/src/52_graphql/index.md +6 -0
  10. package/dist/Context.d.ts.map +1 -1
  11. package/dist/Context.js +9 -0
  12. package/dist/Context.js.map +1 -1
  13. package/dist/RequestResolver.d.ts.map +1 -1
  14. package/dist/RequestResolver.js +4 -10
  15. package/dist/RequestResolver.js.map +1 -1
  16. package/dist/Scheduler.d.ts +9 -0
  17. package/dist/Scheduler.d.ts.map +1 -1
  18. package/dist/Scheduler.js +9 -0
  19. package/dist/Scheduler.js.map +1 -1
  20. package/dist/Schema.d.ts +8 -0
  21. package/dist/Schema.d.ts.map +1 -1
  22. package/dist/Schema.js +7 -0
  23. package/dist/Schema.js.map +1 -1
  24. package/dist/SchemaGetter.d.ts +4 -0
  25. package/dist/SchemaGetter.d.ts.map +1 -1
  26. package/dist/SchemaGetter.js +52 -33
  27. package/dist/SchemaGetter.js.map +1 -1
  28. package/dist/Sink.d.ts.map +1 -1
  29. package/dist/Sink.js +38 -17
  30. package/dist/Sink.js.map +1 -1
  31. package/dist/Stream.d.ts +11 -0
  32. package/dist/Stream.d.ts.map +1 -1
  33. package/dist/Stream.js +16 -1
  34. package/dist/Stream.js.map +1 -1
  35. package/dist/Utils.js +8 -3
  36. package/dist/Utils.js.map +1 -1
  37. package/dist/ai/AnthropicStructuredOutput.js +0 -2
  38. package/dist/ai/AnthropicStructuredOutput.js.map +1 -1
  39. package/dist/ai/Chat.d.ts +2 -2
  40. package/dist/ai/Chat.d.ts.map +1 -1
  41. package/dist/ai/LanguageModel.d.ts +38 -7
  42. package/dist/ai/LanguageModel.d.ts.map +1 -1
  43. package/dist/ai/LanguageModel.js +25 -7
  44. package/dist/ai/LanguageModel.js.map +1 -1
  45. package/dist/ai/McpServer.d.ts +55 -0
  46. package/dist/ai/McpServer.d.ts.map +1 -1
  47. package/dist/ai/McpServer.js +132 -22
  48. package/dist/ai/McpServer.js.map +1 -1
  49. package/dist/ai/Prompt.d.ts.map +1 -1
  50. package/dist/ai/Prompt.js +28 -5
  51. package/dist/ai/Prompt.js.map +1 -1
  52. package/dist/ai/Response.d.ts +4 -3
  53. package/dist/ai/Response.d.ts.map +1 -1
  54. package/dist/ai/Response.js.map +1 -1
  55. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  56. package/dist/cluster/ClusterWorkflowEngine.js +46 -8
  57. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  58. package/dist/cluster/Sharding.d.ts.map +1 -1
  59. package/dist/cluster/Sharding.js +6 -4
  60. package/dist/cluster/Sharding.js.map +1 -1
  61. package/dist/encoding/Sse.d.ts +6 -0
  62. package/dist/encoding/Sse.d.ts.map +1 -1
  63. package/dist/encoding/Sse.js +62 -70
  64. package/dist/encoding/Sse.js.map +1 -1
  65. package/dist/graphql/GraphQL.d.ts +349 -0
  66. package/dist/graphql/GraphQL.d.ts.map +1 -0
  67. package/dist/graphql/GraphQL.js +207 -0
  68. package/dist/graphql/GraphQL.js.map +1 -0
  69. package/dist/graphql/GraphQLClient.d.ts +562 -0
  70. package/dist/graphql/GraphQLClient.d.ts.map +1 -0
  71. package/dist/graphql/GraphQLClient.js +498 -0
  72. package/dist/graphql/GraphQLClient.js.map +1 -0
  73. package/dist/graphql/GraphQLClientError.d.ts +445 -0
  74. package/dist/graphql/GraphQLClientError.d.ts.map +1 -0
  75. package/dist/graphql/GraphQLClientError.js +479 -0
  76. package/dist/graphql/GraphQLClientError.js.map +1 -0
  77. package/dist/graphql/GraphQLGroup.d.ts +118 -0
  78. package/dist/graphql/GraphQLGroup.d.ts.map +1 -0
  79. package/dist/graphql/GraphQLGroup.js +109 -0
  80. package/dist/graphql/GraphQLGroup.js.map +1 -0
  81. package/dist/graphql/GraphQLMiddleware.d.ts +249 -0
  82. package/dist/graphql/GraphQLMiddleware.d.ts.map +1 -0
  83. package/dist/graphql/GraphQLMiddleware.js +130 -0
  84. package/dist/graphql/GraphQLMiddleware.js.map +1 -0
  85. package/dist/graphql/GraphQLProtocol.d.ts +731 -0
  86. package/dist/graphql/GraphQLProtocol.d.ts.map +1 -0
  87. package/dist/graphql/GraphQLProtocol.js +719 -0
  88. package/dist/graphql/GraphQLProtocol.js.map +1 -0
  89. package/dist/graphql/GraphQLResolver.d.ts +453 -0
  90. package/dist/graphql/GraphQLResolver.d.ts.map +1 -0
  91. package/dist/graphql/GraphQLResolver.js +552 -0
  92. package/dist/graphql/GraphQLResolver.js.map +1 -0
  93. package/dist/graphql/index.d.ts +40 -0
  94. package/dist/graphql/index.d.ts.map +1 -0
  95. package/dist/graphql/index.js +41 -0
  96. package/dist/graphql/index.js.map +1 -0
  97. package/dist/http/HttpClient.d.ts +15 -0
  98. package/dist/http/HttpClient.d.ts.map +1 -1
  99. package/dist/http/HttpClient.js +24 -10
  100. package/dist/http/HttpClient.js.map +1 -1
  101. package/dist/http/HttpEffect.d.ts.map +1 -1
  102. package/dist/http/HttpEffect.js +14 -7
  103. package/dist/http/HttpEffect.js.map +1 -1
  104. package/dist/http/HttpMiddleware.d.ts.map +1 -1
  105. package/dist/http/HttpMiddleware.js +31 -32
  106. package/dist/http/HttpMiddleware.js.map +1 -1
  107. package/dist/http/HttpRouter.d.ts +35 -0
  108. package/dist/http/HttpRouter.d.ts.map +1 -1
  109. package/dist/http/HttpRouter.js +35 -0
  110. package/dist/http/HttpRouter.js.map +1 -1
  111. package/dist/http/HttpServerResponse.d.ts +8 -6
  112. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  113. package/dist/http/HttpServerResponse.js +27 -16
  114. package/dist/http/HttpServerResponse.js.map +1 -1
  115. package/dist/http/Multipart.d.ts.map +1 -1
  116. package/dist/http/Multipart.js +15 -1
  117. package/dist/http/Multipart.js.map +1 -1
  118. package/dist/http-api/HttpApiScalar.d.ts +5 -0
  119. package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
  120. package/dist/http-api/HttpApiScalar.js.map +1 -1
  121. package/dist/internal/dateTime.js +40 -35
  122. package/dist/internal/dateTime.js.map +1 -1
  123. package/dist/internal/effect.js +8 -3
  124. package/dist/internal/effect.js.map +1 -1
  125. package/dist/internal/graphql.d.ts +2 -0
  126. package/dist/internal/graphql.d.ts.map +1 -0
  127. package/dist/internal/graphql.js +195 -0
  128. package/dist/internal/graphql.js.map +1 -0
  129. package/dist/internal/graphqlHeaders.d.ts +4 -0
  130. package/dist/internal/graphqlHeaders.d.ts.map +1 -0
  131. package/dist/internal/graphqlHeaders.js +11 -0
  132. package/dist/internal/graphqlHeaders.js.map +1 -0
  133. package/dist/internal/request.js +20 -1
  134. package/dist/internal/request.js.map +1 -1
  135. package/dist/internal/schema/toCodeDocument.js +4 -1
  136. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  137. package/dist/internal/schema/toJsonSchemaDocument.js +29 -5
  138. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
  139. package/dist/internal/version.js +1 -1
  140. package/dist/net/Host.d.ts +49 -0
  141. package/dist/net/Host.d.ts.map +1 -1
  142. package/dist/net/Host.js +55 -0
  143. package/dist/net/Host.js.map +1 -1
  144. package/dist/net/NetAddress.d.ts +8 -0
  145. package/dist/net/NetAddress.d.ts.map +1 -1
  146. package/dist/net/NetAddress.js +8 -0
  147. package/dist/net/NetAddress.js.map +1 -1
  148. package/dist/rpc/RpcServer.d.ts.map +1 -1
  149. package/dist/rpc/RpcServer.js +36 -9
  150. package/dist/rpc/RpcServer.js.map +1 -1
  151. package/dist/socket/Socket.d.ts +6 -0
  152. package/dist/socket/Socket.d.ts.map +1 -1
  153. package/dist/socket/Socket.js.map +1 -1
  154. package/dist/workflow/DurableDeferred.d.ts.map +1 -1
  155. package/dist/workflow/DurableDeferred.js +32 -3
  156. package/dist/workflow/DurableDeferred.js.map +1 -1
  157. package/dist/workflow/WorkflowEngine.d.ts +24 -2
  158. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  159. package/dist/workflow/WorkflowEngine.js +11 -2
  160. package/dist/workflow/WorkflowEngine.js.map +1 -1
  161. package/package.json +6 -3
  162. package/src/Context.ts +9 -0
  163. package/src/RequestResolver.ts +4 -10
  164. package/src/Scheduler.ts +9 -0
  165. package/src/Schema.ts +8 -0
  166. package/src/SchemaGetter.ts +47 -35
  167. package/src/Sink.ts +45 -18
  168. package/src/Stream.ts +33 -4
  169. package/src/Utils.ts +8 -5
  170. package/src/ai/AnthropicStructuredOutput.ts +2 -2
  171. package/src/ai/Chat.ts +2 -2
  172. package/src/ai/LanguageModel.ts +96 -24
  173. package/src/ai/McpServer.ts +244 -90
  174. package/src/ai/Prompt.ts +24 -10
  175. package/src/ai/Response.ts +6 -3
  176. package/src/cluster/ClusterWorkflowEngine.ts +51 -12
  177. package/src/cluster/Sharding.ts +12 -9
  178. package/src/encoding/Sse.ts +69 -79
  179. package/src/graphql/GraphQL.ts +494 -0
  180. package/src/graphql/GraphQLClient.ts +912 -0
  181. package/src/graphql/GraphQLClientError.ts +542 -0
  182. package/src/graphql/GraphQLGroup.ts +167 -0
  183. package/src/graphql/GraphQLMiddleware.ts +253 -0
  184. package/src/graphql/GraphQLProtocol.ts +1286 -0
  185. package/src/graphql/GraphQLResolver.ts +1010 -0
  186. package/src/graphql/index.ts +48 -0
  187. package/src/http/HttpClient.ts +54 -10
  188. package/src/http/HttpEffect.ts +11 -5
  189. package/src/http/HttpMiddleware.ts +33 -34
  190. package/src/http/HttpRouter.ts +35 -0
  191. package/src/http/HttpServerResponse.ts +28 -16
  192. package/src/http/Multipart.ts +17 -1
  193. package/src/http-api/HttpApiScalar.ts +5 -0
  194. package/src/internal/dateTime.ts +13 -10
  195. package/src/internal/effect.ts +8 -3
  196. package/src/internal/graphql.ts +263 -0
  197. package/src/internal/graphqlHeaders.ts +11 -0
  198. package/src/internal/request.ts +31 -3
  199. package/src/internal/schema/toCodeDocument.ts +7 -1
  200. package/src/internal/schema/toJsonSchemaDocument.ts +34 -2
  201. package/src/internal/version.ts +1 -1
  202. package/src/net/Host.ts +72 -0
  203. package/src/net/NetAddress.ts +9 -0
  204. package/src/rpc/RpcServer.ts +55 -15
  205. package/src/socket/Socket.ts +6 -0
  206. package/src/workflow/DurableDeferred.ts +43 -5
  207. package/src/workflow/WorkflowEngine.ts +48 -4
@@ -0,0 +1,349 @@
1
+ import { type Pipeable } from "../Pipeable.ts";
2
+ import * as Schema from "../Schema.ts";
3
+ import type { GraphQLClientError } from "./GraphQLClientError.ts";
4
+ import type * as GraphQLMiddleware from "./GraphQLMiddleware.ts";
5
+ declare const TypeId = "~effect/graphql/GraphQL";
6
+ /**
7
+ * The three kinds of GraphQL operation.
8
+ *
9
+ * @stability experimental
10
+ * @category models
11
+ * @since 4.0.0
12
+ */
13
+ export type Kind = "query" | "mutation" | "subscription";
14
+ /**
15
+ * An operation document split into the pieces needed to rename and alias it
16
+ * without a GraphQL parser. The generator emits one for every query and
17
+ * mutation.
18
+ *
19
+ * **Details**
20
+ *
21
+ * A `body` is a {@link DocumentTemplate.Parts} array: literal text at even
22
+ * indices and, at odd indices, the variable names and fragment names that
23
+ * would be renamed if the operation were repeated under a prefix. Joining the
24
+ * pieces gives the printed document, which is what the operation sends.
25
+ *
26
+ * A fragment whose `body` has a name in it is per-slice: it references a
27
+ * variable, directly or through a fragment it spreads. Every other fragment is
28
+ * shared.
29
+ *
30
+ * @stability experimental
31
+ * @category models
32
+ * @since 4.0.0
33
+ */
34
+ export interface DocumentTemplate {
35
+ /** The variable definitions, in document order. */
36
+ readonly variables: ReadonlyArray<DocumentTemplate.Variable>;
37
+ /** The operation's directives, if it has any. */
38
+ readonly directives?: DocumentTemplate.Parts | undefined;
39
+ /** The root selections, in document order. */
40
+ readonly selections: ReadonlyArray<DocumentTemplate.Selection>;
41
+ /** The fragments the operation uses, in the order they follow it. */
42
+ readonly fragments: ReadonlyArray<DocumentTemplate.Fragment>;
43
+ }
44
+ /**
45
+ * The pieces of a {@link DocumentTemplate}.
46
+ *
47
+ * @stability experimental
48
+ * @since 4.0.0
49
+ */
50
+ export declare namespace DocumentTemplate {
51
+ /**
52
+ * Literal text at even indices and names to rename at odd indices.
53
+ *
54
+ * @stability experimental
55
+ * @category models
56
+ * @since 4.0.0
57
+ */
58
+ type Parts = ReadonlyArray<string>;
59
+ /**
60
+ * A variable definition: `$name:` followed by `body`, the type, default
61
+ * value and directives as printed.
62
+ *
63
+ * @stability experimental
64
+ * @category models
65
+ * @since 4.0.0
66
+ */
67
+ interface Variable {
68
+ readonly name: string;
69
+ readonly body: string;
70
+ }
71
+ /**
72
+ * A root selection. For a field, `body` is everything after its name and
73
+ * the response key is `alias ?? name`. A fragment spread or inline fragment
74
+ * has no `name`, and `body` is the whole selection.
75
+ *
76
+ * @stability experimental
77
+ * @category models
78
+ * @since 4.0.0
79
+ */
80
+ interface Selection {
81
+ readonly alias?: string | undefined;
82
+ readonly name?: string | undefined;
83
+ readonly body: Parts;
84
+ }
85
+ /**
86
+ * A fragment definition: `fragment` and `name`, followed by `body`, which
87
+ * starts at its type condition.
88
+ *
89
+ * @stability experimental
90
+ * @category models
91
+ * @since 4.0.0
92
+ */
93
+ interface Fragment {
94
+ readonly name: string;
95
+ readonly body: Parts;
96
+ }
97
+ }
98
+ /**
99
+ * A named GraphQL document with variable and result schemas and middleware.
100
+ * Variables are encoded before sending; results are decoded from `data`.
101
+ *
102
+ * @stability experimental
103
+ * @category models
104
+ * @since 4.0.0
105
+ */
106
+ export interface Operation<out K extends Kind, out Name extends string, out Variables extends Schema.Top, out Result extends Schema.Top, out Middleware = never> extends Pipeable {
107
+ readonly [TypeId]: typeof TypeId;
108
+ readonly kind: K;
109
+ readonly name: Name;
110
+ /** The printed document, sent as-is. It is never parsed at runtime. */
111
+ readonly document: string;
112
+ /** The template the document was joined from, if it was given as one. */
113
+ readonly template: DocumentTemplate | undefined;
114
+ readonly variables: Variables;
115
+ readonly result: Result;
116
+ /** Middleware attached to this operation, outermost first. */
117
+ readonly middlewares: ReadonlyArray<GraphQLMiddleware.AnyService>;
118
+ readonly "~middleware"?: Middleware;
119
+ /**
120
+ * Returns a copy of this operation with `middleware` attached. Operation
121
+ * middleware runs inside any group middleware; within the operation,
122
+ * middleware run in the order they were attached.
123
+ */
124
+ middleware<M extends GraphQLMiddleware.AnyService>(middleware: M): Operation<K, Name, Variables, Result, Middleware | M>;
125
+ }
126
+ /**
127
+ * Any operation, with its type parameters erased.
128
+ *
129
+ * @stability experimental
130
+ * @category utility types
131
+ * @since 4.0.0
132
+ */
133
+ export type Any = Operation<Kind, string, Schema.Top, Schema.Top, any>;
134
+ /**
135
+ * Extracts the union of middleware attached to an operation.
136
+ *
137
+ * @stability experimental
138
+ * @category utility types
139
+ * @since 4.0.0
140
+ */
141
+ export type Middleware<Op> = Op extends Operation<any, any, any, any, infer M> ? M : never;
142
+ /**
143
+ * The decoded variables type of an operation, which is what a client method
144
+ * takes.
145
+ *
146
+ * @stability experimental
147
+ * @category utility types
148
+ * @since 4.0.0
149
+ */
150
+ export type Variables<Op extends Any> = Op["variables"]["Type"];
151
+ /**
152
+ * The decoded result type of an operation.
153
+ *
154
+ * @stability experimental
155
+ * @category utility types
156
+ * @since 4.0.0
157
+ */
158
+ export type Result<Op extends Any> = Op["result"]["Type"];
159
+ /**
160
+ * The error type of a client method for an operation: `GraphQLClientError`
161
+ * plus the errors of every attached middleware.
162
+ *
163
+ * @stability experimental
164
+ * @category utility types
165
+ * @since 4.0.0
166
+ */
167
+ export type Error<Op extends Any> = GraphQLClientError | GraphQLMiddleware.Error<Middleware<Op>>;
168
+ /**
169
+ * The services a client method for an operation requires: the Schemas'
170
+ * encoding and decoding services plus the requirements of every attached
171
+ * middleware.
172
+ *
173
+ * @stability experimental
174
+ * @category utility types
175
+ * @since 4.0.0
176
+ */
177
+ export type Services<Op extends Any> = Op["variables"]["EncodingServices"] | Op["result"]["DecodingServices"] | GraphQLMiddleware.Requires<Middleware<Op>>;
178
+ /**
179
+ * The type of an operation after attaching middleware `M`.
180
+ *
181
+ * @stability experimental
182
+ * @category utility types
183
+ * @since 4.0.0
184
+ */
185
+ export type AddMiddleware<Op, M> = Op extends Operation<infer K, infer N, infer V, infer R, infer Old> ? Operation<K, N, V, R, Old | M> : never;
186
+ /**
187
+ * Tests whether a value is an {@link Operation}.
188
+ *
189
+ * @stability experimental
190
+ * @category guards
191
+ * @since 4.0.0
192
+ */
193
+ export declare const isOperation: (u: unknown) => u is Any;
194
+ /**
195
+ * Defines a query. The client accepts decoded variables and encodes them
196
+ * through their Schema, including custom scalar codecs. `variables` accepts
197
+ * struct fields or a Schema; omit it for an operation without variables.
198
+ * `document` accepts printed text or a {@link DocumentTemplate}, joined once
199
+ * when the operation is defined.
200
+ *
201
+ * **Example** (A query with variables)
202
+ *
203
+ * ```ts import.meta.vitest
204
+ * import { Schema } from "effect"
205
+ * import { GraphQL } from "effect/graphql"
206
+ *
207
+ * const RepoIssues = GraphQL.query("RepoIssues", {
208
+ * document: "query RepoIssues($owner:String!,$name:String!){repository(owner:$owner,name:$name){issues(first:10){nodes{number title}}}}",
209
+ * variables: { owner: Schema.String, name: Schema.String },
210
+ * result: Schema.Struct({
211
+ * repository: Schema.NullOr(Schema.Struct({
212
+ * issues: Schema.Struct({
213
+ * nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Struct({ number: Schema.Int, title: Schema.String }))))
214
+ * })
215
+ * }))
216
+ * })
217
+ * })
218
+ *
219
+ * RepoIssues.kind // => "query"
220
+ * RepoIssues.name // => "RepoIssues"
221
+ * ```
222
+ *
223
+ * @stability experimental
224
+ * @category constructors
225
+ * @since 4.0.0
226
+ */
227
+ export declare const query: <const Name extends string, Result extends Schema.Top, Variables extends Schema.Top | Schema.Struct.Fields = Schema.Struct<{}>>(name: Name, options: {
228
+ readonly document: string | DocumentTemplate;
229
+ readonly variables?: Variables | undefined;
230
+ readonly result: Result;
231
+ }) => Operation<"query", Name, Variables extends Schema.Struct.Fields ? Schema.Struct<Variables> : Variables, Result>;
232
+ /**
233
+ * Defines a mutation. Same shape as {@link query}.
234
+ *
235
+ * **Example** (A mutation)
236
+ *
237
+ * ```ts import.meta.vitest
238
+ * import { Schema } from "effect"
239
+ * import { GraphQL } from "effect/graphql"
240
+ *
241
+ * const AddComment = GraphQL.mutation("AddComment", {
242
+ * document: "mutation AddComment($subjectId:ID!,$body:String!){addComment(input:{subjectId:$subjectId,body:$body}){clientMutationId}}",
243
+ * variables: { subjectId: Schema.String, body: Schema.String },
244
+ * result: Schema.Struct({ addComment: Schema.NullOr(Schema.Struct({ clientMutationId: Schema.NullOr(Schema.String) })) })
245
+ * })
246
+ *
247
+ * AddComment.kind // => "mutation"
248
+ * ```
249
+ *
250
+ * @stability experimental
251
+ * @category constructors
252
+ * @since 4.0.0
253
+ */
254
+ export declare const mutation: <const Name extends string, Result extends Schema.Top, Variables extends Schema.Top | Schema.Struct.Fields = Schema.Struct<{}>>(name: Name, options: {
255
+ readonly document: string | DocumentTemplate;
256
+ readonly variables?: Variables | undefined;
257
+ readonly result: Result;
258
+ }) => Operation<"mutation", Name, Variables extends Schema.Struct.Fields ? Schema.Struct<Variables> : Variables, Result>;
259
+ /**
260
+ * Defines a subscription. The client method for a subscription returns a
261
+ * `Stream` of decoded events instead of an `Effect`.
262
+ *
263
+ * **Example** (A subscription)
264
+ *
265
+ * ```ts import.meta.vitest
266
+ * import { Schema } from "effect"
267
+ * import { GraphQL } from "effect/graphql"
268
+ *
269
+ * const IssueUpdated = GraphQL.subscription("IssueUpdated", {
270
+ * document: "subscription IssueUpdated($id:ID!){issueUpdated(id:$id){title}}",
271
+ * variables: { id: Schema.String },
272
+ * result: Schema.Struct({ issueUpdated: Schema.Struct({ title: Schema.String }) })
273
+ * })
274
+ *
275
+ * IssueUpdated.kind // => "subscription"
276
+ * ```
277
+ *
278
+ * @stability experimental
279
+ * @category constructors
280
+ * @since 4.0.0
281
+ */
282
+ export declare const subscription: <const Name extends string, Result extends Schema.Top, Variables extends Schema.Top | Schema.Struct.Fields = Schema.Struct<{}>>(name: Name, options: {
283
+ readonly document: string | DocumentTemplate;
284
+ readonly variables?: Variables | undefined;
285
+ readonly result: Result;
286
+ }) => Operation<"subscription", Name, Variables extends Schema.Struct.Fields ? Schema.Struct<Variables> : Variables, Result>;
287
+ /**
288
+ * The `__typename` Schema for the "every other type" member of a generated
289
+ * union.
290
+ *
291
+ * **Details**
292
+ *
293
+ * The type excludes selected names, allowing `__typename` narrowing. The
294
+ * decoder accepts any other string, including types added by the server
295
+ * later. Selected names are rejected so malformed selected results cannot
296
+ * fall through to the catch-all member.
297
+ *
298
+ * **Example** (The catch-all member of a union)
299
+ *
300
+ * ```ts import.meta.vitest
301
+ * import { Schema } from "effect"
302
+ * import { GraphQL } from "effect/graphql"
303
+ *
304
+ * type Node = "Issue" | "PullRequest" | "Repository"
305
+ *
306
+ * const OtherNode = Schema.Struct({
307
+ * __typename: GraphQL.otherTypename<Node>()(["Issue"]),
308
+ * id: Schema.String
309
+ * })
310
+ *
311
+ * Schema.decodeUnknownSync(OtherNode)({ __typename: "PullRequest", id: "1" }).__typename // => "PullRequest"
312
+ * Schema.decodeUnknownSync(OtherNode)({ __typename: "AddedLater", id: "2" }).__typename // => "AddedLater"
313
+ * Schema.is(OtherNode)({ __typename: "Issue", id: "3" }) // => false
314
+ * ```
315
+ *
316
+ * @stability experimental
317
+ * @category schemas
318
+ * @since 4.0.0
319
+ */
320
+ export declare const otherTypename: <All extends string>() => <const Selected extends ReadonlyArray<All>>(selected: Selected) => Schema.refine<Exclude<All, Selected[number]>, Schema.String>;
321
+ /**
322
+ * The Schema for a GraphQL enum in a result position.
323
+ *
324
+ * **Details**
325
+ *
326
+ * It is typed as the declared literals but decodes any string, so a value the
327
+ * server adds later does not fail the whole query. Inputs stay strict: the
328
+ * generator uses `Schema.Literals` for enums in variables and input objects.
329
+ *
330
+ * **Example** (An enum that tolerates new values)
331
+ *
332
+ * ```ts import.meta.vitest
333
+ * import { Schema } from "effect"
334
+ * import { GraphQL } from "effect/graphql"
335
+ *
336
+ * const IssueState = GraphQL.enumLiterals(["OPEN", "CLOSED"])
337
+ *
338
+ * Schema.decodeUnknownSync(IssueState)("OPEN") // => "OPEN"
339
+ * Schema.decodeUnknownSync(IssueState)("MERGED") // => "MERGED"
340
+ * Schema.is(IssueState)(42) // => false
341
+ * ```
342
+ *
343
+ * @stability experimental
344
+ * @category schemas
345
+ * @since 4.0.0
346
+ */
347
+ export declare const enumLiterals: <const Literals extends ReadonlyArray<string>>(literals: Literals) => Schema.refine<Literals[number], Schema.String>;
348
+ export {};
349
+ //# sourceMappingURL=GraphQL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphQL.d.ts","sourceRoot":"","sources":["../../src/graphql/GraphQL.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,gBAAgB,CAAA;AAE7D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAEhE,QAAA,MAAM,MAAM,4BAA4B,CAAA;AAExC;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,CAAA;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAC5D,iDAAiD;I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E,SAAS,CACZ,cAAc,EACd,IAAI,EACJ,SAAS,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,EAC7E,MAAM,CACyB,CAAA;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,SAAS,MAAM,QAC/C,KAAK,CAAC,QAAQ,SAAS,aAAa,CAAC,GAAG,CAAC,YAC9B,QAAQ,KACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAY7D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,CAAC,QAAQ,SAAS,aAAa,CAAC,MAAM,CAAC,YAC7D,QAAQ,KACjB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAO5C,CAAA"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Typed GraphQL operations for `GraphQLGroup` and `GraphQLClient.make`,
3
+ * written by hand or generated by `@effect/graphql-generator`.
4
+ *
5
+ * Includes the generator's lenient decoders, {@link otherTypename} and
6
+ * {@link enumLiterals}.
7
+ *
8
+ * @stability experimental
9
+ * @since 4.0.0
10
+ */
11
+ import * as internal from "../internal/graphql.js";
12
+ import { pipeArguments } from "../Pipeable.js";
13
+ import { hasProperty } from "../Predicate.js";
14
+ import * as Schema from "../Schema.js";
15
+ const TypeId = "~effect/graphql/GraphQL";
16
+ /**
17
+ * Tests whether a value is an {@link Operation}.
18
+ *
19
+ * @stability experimental
20
+ * @category guards
21
+ * @since 4.0.0
22
+ */
23
+ export const isOperation = u => hasProperty(u, TypeId);
24
+ const Proto = {
25
+ [TypeId]: TypeId,
26
+ pipe() {
27
+ return pipeArguments(this, arguments);
28
+ },
29
+ middleware(middleware) {
30
+ return makeProto({
31
+ ...this,
32
+ middlewares: [...this.middlewares, middleware]
33
+ });
34
+ }
35
+ };
36
+ // The middleware type of an operation is phantom and its Schemas are erased to
37
+ // `Schema.Top` here, so the typed constructors below state their operation
38
+ // type with one assertion each.
39
+ const makeProto = fields => Object.assign(Object.create(Proto), fields);
40
+ const makeOperation = kind => (name, options) => makeProto({
41
+ kind,
42
+ name,
43
+ document: typeof options.document === "string" ? options.document : internal.joinTemplate(kind, name, options.document),
44
+ template: typeof options.document === "string" ? undefined : options.document,
45
+ variables: options.variables === undefined ? Schema.Struct({}) : Schema.isSchema(options.variables) ? options.variables : Schema.Struct(options.variables),
46
+ result: options.result,
47
+ middlewares: []
48
+ });
49
+ /**
50
+ * Defines a query. The client accepts decoded variables and encodes them
51
+ * through their Schema, including custom scalar codecs. `variables` accepts
52
+ * struct fields or a Schema; omit it for an operation without variables.
53
+ * `document` accepts printed text or a {@link DocumentTemplate}, joined once
54
+ * when the operation is defined.
55
+ *
56
+ * **Example** (A query with variables)
57
+ *
58
+ * ```ts import.meta.vitest
59
+ * import { Schema } from "effect"
60
+ * import { GraphQL } from "effect/graphql"
61
+ *
62
+ * const RepoIssues = GraphQL.query("RepoIssues", {
63
+ * document: "query RepoIssues($owner:String!,$name:String!){repository(owner:$owner,name:$name){issues(first:10){nodes{number title}}}}",
64
+ * variables: { owner: Schema.String, name: Schema.String },
65
+ * result: Schema.Struct({
66
+ * repository: Schema.NullOr(Schema.Struct({
67
+ * issues: Schema.Struct({
68
+ * nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Struct({ number: Schema.Int, title: Schema.String }))))
69
+ * })
70
+ * }))
71
+ * })
72
+ * })
73
+ *
74
+ * RepoIssues.kind // => "query"
75
+ * RepoIssues.name // => "RepoIssues"
76
+ * ```
77
+ *
78
+ * @stability experimental
79
+ * @category constructors
80
+ * @since 4.0.0
81
+ */
82
+ export const query = /*#__PURE__*/makeOperation("query");
83
+ /**
84
+ * Defines a mutation. Same shape as {@link query}.
85
+ *
86
+ * **Example** (A mutation)
87
+ *
88
+ * ```ts import.meta.vitest
89
+ * import { Schema } from "effect"
90
+ * import { GraphQL } from "effect/graphql"
91
+ *
92
+ * const AddComment = GraphQL.mutation("AddComment", {
93
+ * document: "mutation AddComment($subjectId:ID!,$body:String!){addComment(input:{subjectId:$subjectId,body:$body}){clientMutationId}}",
94
+ * variables: { subjectId: Schema.String, body: Schema.String },
95
+ * result: Schema.Struct({ addComment: Schema.NullOr(Schema.Struct({ clientMutationId: Schema.NullOr(Schema.String) })) })
96
+ * })
97
+ *
98
+ * AddComment.kind // => "mutation"
99
+ * ```
100
+ *
101
+ * @stability experimental
102
+ * @category constructors
103
+ * @since 4.0.0
104
+ */
105
+ export const mutation = /*#__PURE__*/makeOperation("mutation");
106
+ /**
107
+ * Defines a subscription. The client method for a subscription returns a
108
+ * `Stream` of decoded events instead of an `Effect`.
109
+ *
110
+ * **Example** (A subscription)
111
+ *
112
+ * ```ts import.meta.vitest
113
+ * import { Schema } from "effect"
114
+ * import { GraphQL } from "effect/graphql"
115
+ *
116
+ * const IssueUpdated = GraphQL.subscription("IssueUpdated", {
117
+ * document: "subscription IssueUpdated($id:ID!){issueUpdated(id:$id){title}}",
118
+ * variables: { id: Schema.String },
119
+ * result: Schema.Struct({ issueUpdated: Schema.Struct({ title: Schema.String }) })
120
+ * })
121
+ *
122
+ * IssueUpdated.kind // => "subscription"
123
+ * ```
124
+ *
125
+ * @stability experimental
126
+ * @category constructors
127
+ * @since 4.0.0
128
+ */
129
+ export const subscription = /*#__PURE__*/makeOperation("subscription");
130
+ /**
131
+ * The `__typename` Schema for the "every other type" member of a generated
132
+ * union.
133
+ *
134
+ * **Details**
135
+ *
136
+ * The type excludes selected names, allowing `__typename` narrowing. The
137
+ * decoder accepts any other string, including types added by the server
138
+ * later. Selected names are rejected so malformed selected results cannot
139
+ * fall through to the catch-all member.
140
+ *
141
+ * **Example** (The catch-all member of a union)
142
+ *
143
+ * ```ts import.meta.vitest
144
+ * import { Schema } from "effect"
145
+ * import { GraphQL } from "effect/graphql"
146
+ *
147
+ * type Node = "Issue" | "PullRequest" | "Repository"
148
+ *
149
+ * const OtherNode = Schema.Struct({
150
+ * __typename: GraphQL.otherTypename<Node>()(["Issue"]),
151
+ * id: Schema.String
152
+ * })
153
+ *
154
+ * Schema.decodeUnknownSync(OtherNode)({ __typename: "PullRequest", id: "1" }).__typename // => "PullRequest"
155
+ * Schema.decodeUnknownSync(OtherNode)({ __typename: "AddedLater", id: "2" }).__typename // => "AddedLater"
156
+ * Schema.is(OtherNode)({ __typename: "Issue", id: "3" }) // => false
157
+ * ```
158
+ *
159
+ * @stability experimental
160
+ * @category schemas
161
+ * @since 4.0.0
162
+ */
163
+ export const otherTypename = () => selected => {
164
+ const rejected = new Set(selected);
165
+ // Type boundary: decoding is lenient by design. The guard passes any string
166
+ // other than the selected names, including names the server adds later, but
167
+ // the type only lists the names known when the code was generated.
168
+ return Schema.refine(name => !rejected.has(name), {
169
+ title: "otherTypename",
170
+ message: `Expected a __typename other than ${selected.map(s => `"${s}"`).join(", ")}`
171
+ })(Schema.String);
172
+ };
173
+ /**
174
+ * The Schema for a GraphQL enum in a result position.
175
+ *
176
+ * **Details**
177
+ *
178
+ * It is typed as the declared literals but decodes any string, so a value the
179
+ * server adds later does not fail the whole query. Inputs stay strict: the
180
+ * generator uses `Schema.Literals` for enums in variables and input objects.
181
+ *
182
+ * **Example** (An enum that tolerates new values)
183
+ *
184
+ * ```ts import.meta.vitest
185
+ * import { Schema } from "effect"
186
+ * import { GraphQL } from "effect/graphql"
187
+ *
188
+ * const IssueState = GraphQL.enumLiterals(["OPEN", "CLOSED"])
189
+ *
190
+ * Schema.decodeUnknownSync(IssueState)("OPEN") // => "OPEN"
191
+ * Schema.decodeUnknownSync(IssueState)("MERGED") // => "MERGED"
192
+ * Schema.is(IssueState)(42) // => false
193
+ * ```
194
+ *
195
+ * @stability experimental
196
+ * @category schemas
197
+ * @since 4.0.0
198
+ */
199
+ export const enumLiterals = literals =>
200
+ // Type boundary: decoding is lenient by design. The guard passes any string,
201
+ // including values the server adds later, but the type only lists the values
202
+ // known when the code was generated.
203
+ Schema.refine(_ => true)(Schema.String).annotate({
204
+ title: `enum(${literals.join(" | ")})`,
205
+ description: `One of ${literals.map(l => `"${l}"`).join(", ")}, or any string the server adds later`
206
+ });
207
+ //# sourceMappingURL=GraphQL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphQL.js","names":[],"sources":["../../src/graphql/GraphQL.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;AAUA,OAAO,KAAK,QAAQ,MAAM,wBAAwB;AAClD,SAAwB,aAAa,QAAQ,gBAAgB;AAC7D,SAAS,WAAW,QAAQ,iBAAiB;AAC7C,OAAO,KAAK,MAAM,MAAM,cAAc;AAItC,MAAM,MAAM,GAAG,yBAAyB;AAiNxC;;;;;;;AAOA,OAAO,MAAM,WAAW,GAAI,CAAU,IAAe,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC;AAE3E,MAAM,KAAK,GAAG;EACZ,CAAC,MAAM,GAAG,MAAM;EAChB,IAAI;IACF,OAAO,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC;EACvC,CAAC;EACD,UAAU,CAAY,UAAwC;IAC5D,OAAO,SAAS,CAAC;MAAE,GAAG,IAAI;MAAE,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU;IAAC,CAAE,CAAC;EAC/E;CACD;AAED;AACA;AACA;AACA,MAAM,SAAS,GAAI,MAAwD,IACzE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;AAE7C,MAAM,aAAa,GAA0B,IAAO,IACpD,CAKE,IAAU,EACV,OAIC,KAED,SAAS,CAAC;EACR,IAAI;EACJ,IAAI;EACJ,QAAQ,EAAE,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ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