spiceflow 1.1.17 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +236 -3
  2. package/dist/client/types.d.ts +1 -1
  3. package/dist/client/types.d.ts.map +1 -1
  4. package/dist/client.test.js +36 -1
  5. package/dist/client.test.js.map +1 -1
  6. package/dist/index.d.ts +2 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp-transport.d.ts +45 -0
  10. package/dist/mcp-transport.d.ts.map +1 -0
  11. package/dist/mcp-transport.js +107 -0
  12. package/dist/mcp-transport.js.map +1 -0
  13. package/dist/mcp.d.ts +36 -0
  14. package/dist/mcp.d.ts.map +1 -0
  15. package/dist/mcp.js +211 -0
  16. package/dist/mcp.js.map +1 -0
  17. package/dist/mcp.test.d.ts +2 -0
  18. package/dist/mcp.test.d.ts.map +1 -0
  19. package/dist/mcp.test.js +224 -0
  20. package/dist/mcp.test.js.map +1 -0
  21. package/dist/openapi.d.ts +14 -27
  22. package/dist/openapi.d.ts.map +1 -1
  23. package/dist/openapi.js +101 -49
  24. package/dist/openapi.js.map +1 -1
  25. package/dist/openapi.test.js +242 -18
  26. package/dist/openapi.test.js.map +1 -1
  27. package/dist/spiceflow.d.ts +5 -3
  28. package/dist/spiceflow.d.ts.map +1 -1
  29. package/dist/spiceflow.js +42 -10
  30. package/dist/spiceflow.js.map +1 -1
  31. package/dist/spiceflow.test.js +21 -3
  32. package/dist/spiceflow.test.js.map +1 -1
  33. package/dist/types.d.ts +7 -13
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/types.js.map +1 -1
  36. package/package.json +15 -2
  37. package/src/client/types.ts +3 -5
  38. package/src/client.test.ts +45 -2
  39. package/src/index.ts +2 -1
  40. package/src/mcp-transport.ts +148 -0
  41. package/src/mcp.test.ts +273 -0
  42. package/src/mcp.ts +270 -0
  43. package/src/openapi.test.ts +238 -18
  44. package/src/openapi.ts +136 -66
  45. package/src/spiceflow.test.ts +27 -3
  46. package/src/spiceflow.ts +83 -13
  47. package/src/types.ts +129 -140
@@ -7,11 +7,9 @@ test('openapi response', async () => {
7
7
  const app = await new Spiceflow()
8
8
  .use(
9
9
  openapi({
10
- documentation: {
11
- info: {
12
- title: 'Spiceflow Docs',
13
- version: '0.0.0',
14
- },
10
+ info: {
11
+ title: 'Spiceflow Docs',
12
+ version: '0.0.0',
15
13
  },
16
14
  }),
17
15
  )
@@ -53,6 +51,7 @@ test('openapi response', async () => {
53
51
  }),
54
52
  },
55
53
  )
54
+
56
55
  .get(
57
56
  '/queryParams',
58
57
  async (c) => {
@@ -87,6 +86,63 @@ test('openapi response', async () => {
87
86
  }),
88
87
  },
89
88
  )
89
+ .get(
90
+ '/stream',
91
+ async function* () {
92
+ for (let i = 0; i < 3; i++) {
93
+ yield { count: i }
94
+ await new Promise((resolve) => setTimeout(resolve, 10))
95
+ }
96
+ },
97
+ {
98
+ detail: {
99
+ description: 'This is a stream',
100
+ },
101
+ // response: z.object({
102
+ // count: z.number(),
103
+ // }),
104
+ },
105
+ )
106
+ .get(
107
+ '/streamWithSchema',
108
+ async function* () {
109
+ for (let i = 0; i < 3; i++) {
110
+ yield { count: i }
111
+ await new Promise((resolve) => setTimeout(resolve, 10))
112
+ }
113
+ },
114
+ {
115
+ detail: {
116
+ description: 'This is a stream with schema',
117
+ },
118
+ response: z.object({
119
+ count: z.number(),
120
+ }),
121
+ },
122
+ )
123
+ .post(
124
+ '/formWithSchemaForm',
125
+ () => {
126
+ const formData = new FormData()
127
+ formData.append('name', 'test')
128
+ formData.append('age', '25')
129
+ return new Response(formData, {
130
+ headers: {
131
+ 'content-type': 'multipart/form-data',
132
+ },
133
+ })
134
+ },
135
+ {
136
+ detail: {
137
+ description: 'This returns form data with schema',
138
+ },
139
+ response: z.object({
140
+ name: z.string(),
141
+ age: z.string(),
142
+ }),
143
+ type: 'multipart/form-data',
144
+ },
145
+ )
90
146
  .use(
91
147
  new Spiceflow({ basePath: '/two' }).get(
92
148
  '/ids/:id',
@@ -115,13 +171,11 @@ test('openapi response', async () => {
115
171
  "paths": {
116
172
  "/addBody": {
117
173
  "patch": {
118
- "operationId": "patchAddBody",
119
174
  "parameters": [],
120
175
  "requestBody": {
121
176
  "content": {
122
177
  "application/json": {
123
178
  "schema": {
124
- "$schema": "http://json-schema.org/draft-07/schema#",
125
179
  "additionalProperties": false,
126
180
  "properties": {
127
181
  "name": {
@@ -139,7 +193,6 @@ test('openapi response', async () => {
139
193
  },
140
194
  "responses": {
141
195
  "200": {
142
- "$schema": "http://json-schema.org/draft-07/schema#",
143
196
  "content": {
144
197
  "application/json": {
145
198
  "schema": {
@@ -154,19 +207,71 @@ test('openapi response', async () => {
154
207
  },
155
208
  "description": "",
156
209
  },
210
+ "default": {
211
+ "content": {
212
+ "*/*": {
213
+ "schema": {},
214
+ },
215
+ },
216
+ "description": "",
217
+ },
218
+ },
219
+ },
220
+ },
221
+ "/formWithSchemaForm": {
222
+ "post": {
223
+ "description": "This returns form data with schema",
224
+ "responses": {
225
+ "200": {
226
+ "content": {
227
+ "multipart/form-data": {
228
+ "schema": {
229
+ "properties": {
230
+ "age": {
231
+ "type": "string",
232
+ },
233
+ "name": {
234
+ "type": "string",
235
+ },
236
+ },
237
+ "required": [
238
+ "name",
239
+ "age",
240
+ ],
241
+ "type": "object",
242
+ },
243
+ },
244
+ },
245
+ "description": "",
246
+ },
247
+ "default": {
248
+ "content": {
249
+ "*/*": {
250
+ "schema": {},
251
+ },
252
+ },
253
+ "description": "",
254
+ },
157
255
  },
158
256
  },
159
257
  },
160
258
  "/one/ids/{id}": {
161
259
  "get": {
162
- "operationId": "getOneIdsById",
260
+ "parameters": [
261
+ {
262
+ "in": "path",
263
+ "name": "id",
264
+ "required": true,
265
+ "schema": {
266
+ "type": "string",
267
+ },
268
+ },
269
+ ],
163
270
  "responses": {
164
271
  "200": {
165
- "$schema": "http://json-schema.org/draft-07/schema#",
166
272
  "content": {
167
273
  "application/json": {
168
274
  "schema": {
169
- "$schema": "http://json-schema.org/draft-07/schema#",
170
275
  "type": "string",
171
276
  },
172
277
  },
@@ -174,7 +279,6 @@ test('openapi response', async () => {
174
279
  "description": "",
175
280
  },
176
281
  "404": {
177
- "$schema": "http://json-schema.org/draft-07/schema#",
178
282
  "content": {
179
283
  "application/json": {
180
284
  "schema": {
@@ -192,17 +296,41 @@ test('openapi response', async () => {
192
296
  },
193
297
  "description": "",
194
298
  },
299
+ "default": {
300
+ "content": {
301
+ "*/*": {
302
+ "schema": {},
303
+ },
304
+ },
305
+ "description": "",
306
+ },
195
307
  },
196
308
  },
197
309
  },
198
310
  "/openapi": {
199
311
  "get": {
200
- "operationId": "getOpenapi",
312
+ "responses": {
313
+ "200": {
314
+ "content": {
315
+ "*/*": {
316
+ "schema": {},
317
+ },
318
+ },
319
+ "description": "",
320
+ },
321
+ "default": {
322
+ "content": {
323
+ "*/*": {
324
+ "schema": {},
325
+ },
326
+ },
327
+ "description": "",
328
+ },
329
+ },
201
330
  },
202
331
  },
203
332
  "/queryParams": {
204
333
  "get": {
205
- "operationId": "getQueryParams",
206
334
  "parameters": [
207
335
  {
208
336
  "in": "query",
@@ -215,7 +343,6 @@ test('openapi response', async () => {
215
343
  ],
216
344
  "responses": {
217
345
  "200": {
218
- "$schema": "http://json-schema.org/draft-07/schema#",
219
346
  "content": {
220
347
  "application/json": {
221
348
  "schema": {
@@ -230,6 +357,14 @@ test('openapi response', async () => {
230
357
  },
231
358
  "description": "",
232
359
  },
360
+ "default": {
361
+ "content": {
362
+ "*/*": {
363
+ "schema": {},
364
+ },
365
+ },
366
+ "description": "",
367
+ },
233
368
  },
234
369
  },
235
370
  "post": {
@@ -240,7 +375,6 @@ test('openapi response', async () => {
240
375
  "content": {
241
376
  "application/json": {
242
377
  "schema": {
243
- "$schema": "http://json-schema.org/draft-07/schema#",
244
378
  "additionalProperties": false,
245
379
  "properties": {
246
380
  "name": {
@@ -258,7 +392,6 @@ test('openapi response', async () => {
258
392
  },
259
393
  "responses": {
260
394
  "200": {
261
- "$schema": "http://json-schema.org/draft-07/schema#",
262
395
  "content": {
263
396
  "application/json": {
264
397
  "schema": {
@@ -273,12 +406,81 @@ test('openapi response', async () => {
273
406
  },
274
407
  "description": "",
275
408
  },
409
+ "default": {
410
+ "content": {
411
+ "*/*": {
412
+ "schema": {},
413
+ },
414
+ },
415
+ "description": "",
416
+ },
417
+ },
418
+ },
419
+ },
420
+ "/stream": {
421
+ "get": {
422
+ "description": "This is a stream",
423
+ "responses": {
424
+ "200": {
425
+ "content": {
426
+ "*/*": {
427
+ "schema": {},
428
+ },
429
+ },
430
+ "description": "",
431
+ },
432
+ "default": {
433
+ "content": {
434
+ "*/*": {
435
+ "schema": {},
436
+ },
437
+ },
438
+ "description": "",
439
+ },
440
+ },
441
+ "x-fern-streaming": {
442
+ "format": "sse",
443
+ },
444
+ },
445
+ },
446
+ "/streamWithSchema": {
447
+ "get": {
448
+ "description": "This is a stream with schema",
449
+ "responses": {
450
+ "200": {
451
+ "content": {
452
+ "application/json": {
453
+ "schema": {
454
+ "properties": {
455
+ "count": {
456
+ "type": "number",
457
+ },
458
+ },
459
+ "required": [
460
+ "count",
461
+ ],
462
+ "type": "object",
463
+ },
464
+ },
465
+ },
466
+ "description": "",
467
+ },
468
+ "default": {
469
+ "content": {
470
+ "*/*": {
471
+ "schema": {},
472
+ },
473
+ },
474
+ "description": "",
475
+ },
476
+ },
477
+ "x-fern-streaming": {
478
+ "format": "sse",
276
479
  },
277
480
  },
278
481
  },
279
482
  "/two/ids/{id}": {
280
483
  "get": {
281
- "operationId": "getTwoIdsById",
282
484
  "parameters": [
283
485
  {
284
486
  "in": "path",
@@ -289,6 +491,24 @@ test('openapi response', async () => {
289
491
  },
290
492
  },
291
493
  ],
494
+ "responses": {
495
+ "200": {
496
+ "content": {
497
+ "*/*": {
498
+ "schema": {},
499
+ },
500
+ },
501
+ "description": "",
502
+ },
503
+ "default": {
504
+ "content": {
505
+ "*/*": {
506
+ "schema": {},
507
+ },
508
+ },
509
+ "description": "",
510
+ },
511
+ },
292
512
  },
293
513
  },
294
514
  },