@orq-ai/node 3.2.8 → 3.3.0-rc.1

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 (215) hide show
  1. package/bin/mcp-server.js +32 -35
  2. package/bin/mcp-server.js.map +20 -20
  3. package/jsr.json +1 -1
  4. package/lib/config.d.ts +2 -2
  5. package/lib/config.js +2 -2
  6. package/lib/config.js.map +1 -1
  7. package/mcp-server/mcp-server.js +1 -1
  8. package/mcp-server/mcp-server.js.map +1 -1
  9. package/mcp-server/server.js +1 -1
  10. package/mcp-server/server.js.map +1 -1
  11. package/models/operations/bulkcreatedatapoints.js +2 -2
  12. package/models/operations/createcontact.js +2 -2
  13. package/models/operations/createdataset.js +2 -2
  14. package/models/operations/createdatasetitem.js +2 -2
  15. package/models/operations/fileget.js +2 -2
  16. package/models/operations/filelist.js +2 -2
  17. package/models/operations/fileupload.js +2 -2
  18. package/models/operations/listdatasetdatapoints.js +2 -2
  19. package/models/operations/listdatasets.js +2 -2
  20. package/models/operations/retrievedatapoint.js +2 -2
  21. package/models/operations/retrievedataset.js +2 -2
  22. package/models/operations/updatedatapoint.js +2 -2
  23. package/models/operations/updatedataset.js +2 -2
  24. package/package.json +3 -2
  25. package/src/lib/config.ts +2 -2
  26. package/src/mcp-server/mcp-server.ts +1 -1
  27. package/src/mcp-server/server.ts +1 -1
  28. package/src/models/operations/bulkcreatedatapoints.ts +2 -2
  29. package/src/models/operations/createcontact.ts +2 -2
  30. package/src/models/operations/createdataset.ts +2 -2
  31. package/src/models/operations/createdatasetitem.ts +2 -2
  32. package/src/models/operations/fileget.ts +2 -2
  33. package/src/models/operations/filelist.ts +2 -2
  34. package/src/models/operations/fileupload.ts +2 -2
  35. package/src/models/operations/listdatasetdatapoints.ts +2 -2
  36. package/src/models/operations/listdatasets.ts +2 -2
  37. package/src/models/operations/retrievedatapoint.ts +2 -2
  38. package/src/models/operations/retrievedataset.ts +2 -2
  39. package/src/models/operations/updatedatapoint.ts +2 -2
  40. package/src/models/operations/updatedataset.ts +2 -2
  41. package/packages/orq-rc/FUNCTIONS.md +0 -106
  42. package/packages/orq-rc/README.md +0 -660
  43. package/packages/orq-rc/RUNTIMES.md +0 -48
  44. package/packages/orq-rc/docs/sdks/contacts/README.md +0 -84
  45. package/packages/orq-rc/docs/sdks/datasets/README.md +0 -934
  46. package/packages/orq-rc/docs/sdks/deployments/README.md +0 -316
  47. package/packages/orq-rc/docs/sdks/feedback/README.md +0 -92
  48. package/packages/orq-rc/docs/sdks/files/README.md +0 -305
  49. package/packages/orq-rc/docs/sdks/metrics/README.md +0 -86
  50. package/packages/orq-rc/docs/sdks/orq/README.md +0 -10
  51. package/packages/orq-rc/docs/sdks/prompts/README.md +0 -608
  52. package/packages/orq-rc/docs/sdks/remoteconfigs/README.md +0 -80
  53. package/packages/orq-rc/jsr.json +0 -28
  54. package/packages/orq-rc/package-lock.json +0 -3217
  55. package/packages/orq-rc/package.json +0 -45
  56. package/packages/orq-rc/src/core.ts +0 -13
  57. package/packages/orq-rc/src/funcs/contactsCreate.ts +0 -154
  58. package/packages/orq-rc/src/funcs/datasetsClear.ts +0 -161
  59. package/packages/orq-rc/src/funcs/datasetsCreate.ts +0 -159
  60. package/packages/orq-rc/src/funcs/datasetsCreateDatapoint.ts +0 -161
  61. package/packages/orq-rc/src/funcs/datasetsCreateDatapoints.ts +0 -165
  62. package/packages/orq-rc/src/funcs/datasetsDelete.ts +0 -161
  63. package/packages/orq-rc/src/funcs/datasetsDeleteDatapoint.ts +0 -176
  64. package/packages/orq-rc/src/funcs/datasetsList.ts +0 -162
  65. package/packages/orq-rc/src/funcs/datasetsListDatapoints.ts +0 -169
  66. package/packages/orq-rc/src/funcs/datasetsRetrieve.ts +0 -169
  67. package/packages/orq-rc/src/funcs/datasetsRetrieveDatapoint.ts +0 -175
  68. package/packages/orq-rc/src/funcs/datasetsUpdate.ts +0 -170
  69. package/packages/orq-rc/src/funcs/datasetsUpdateDatapoint.ts +0 -173
  70. package/packages/orq-rc/src/funcs/deploymentsGetConfig.ts +0 -162
  71. package/packages/orq-rc/src/funcs/deploymentsInvoke.ts +0 -170
  72. package/packages/orq-rc/src/funcs/deploymentsList.ts +0 -171
  73. package/packages/orq-rc/src/funcs/deploymentsMetricsCreate.ts +0 -162
  74. package/packages/orq-rc/src/funcs/deploymentsStream.ts +0 -178
  75. package/packages/orq-rc/src/funcs/feedbackCreate.ts +0 -154
  76. package/packages/orq-rc/src/funcs/filesCreate.ts +0 -177
  77. package/packages/orq-rc/src/funcs/filesDelete.ts +0 -158
  78. package/packages/orq-rc/src/funcs/filesGet.ts +0 -160
  79. package/packages/orq-rc/src/funcs/filesList.ts +0 -162
  80. package/packages/orq-rc/src/funcs/promptsCreate.ts +0 -154
  81. package/packages/orq-rc/src/funcs/promptsDelete.ts +0 -158
  82. package/packages/orq-rc/src/funcs/promptsGetVersion.ts +0 -175
  83. package/packages/orq-rc/src/funcs/promptsList.ts +0 -162
  84. package/packages/orq-rc/src/funcs/promptsListVersions.ts +0 -168
  85. package/packages/orq-rc/src/funcs/promptsRetrieve.ts +0 -160
  86. package/packages/orq-rc/src/funcs/promptsUpdate.ts +0 -167
  87. package/packages/orq-rc/src/funcs/remoteconfigsRetrieve.ts +0 -155
  88. package/packages/orq-rc/src/hooks/global.ts +0 -44
  89. package/packages/orq-rc/src/hooks/hooks.ts +0 -132
  90. package/packages/orq-rc/src/hooks/index.ts +0 -6
  91. package/packages/orq-rc/src/hooks/registration.ts +0 -15
  92. package/packages/orq-rc/src/hooks/types.ts +0 -110
  93. package/packages/orq-rc/src/index.ts +0 -7
  94. package/packages/orq-rc/src/lib/base64.ts +0 -37
  95. package/packages/orq-rc/src/lib/config.ts +0 -70
  96. package/packages/orq-rc/src/lib/dlv.ts +0 -53
  97. package/packages/orq-rc/src/lib/encodings.ts +0 -483
  98. package/packages/orq-rc/src/lib/env.ts +0 -73
  99. package/packages/orq-rc/src/lib/event-streams.ts +0 -264
  100. package/packages/orq-rc/src/lib/files.ts +0 -40
  101. package/packages/orq-rc/src/lib/http.ts +0 -323
  102. package/packages/orq-rc/src/lib/is-plain-object.ts +0 -43
  103. package/packages/orq-rc/src/lib/logger.ts +0 -9
  104. package/packages/orq-rc/src/lib/matchers.ts +0 -325
  105. package/packages/orq-rc/src/lib/primitives.ts +0 -150
  106. package/packages/orq-rc/src/lib/retries.ts +0 -218
  107. package/packages/orq-rc/src/lib/schemas.ts +0 -91
  108. package/packages/orq-rc/src/lib/sdks.ts +0 -395
  109. package/packages/orq-rc/src/lib/security.ts +0 -261
  110. package/packages/orq-rc/src/lib/url.ts +0 -33
  111. package/packages/orq-rc/src/mcp-server/cli/start/command.ts +0 -125
  112. package/packages/orq-rc/src/mcp-server/cli/start/impl.ts +0 -140
  113. package/packages/orq-rc/src/mcp-server/cli.ts +0 -13
  114. package/packages/orq-rc/src/mcp-server/console-logger.ts +0 -71
  115. package/packages/orq-rc/src/mcp-server/extensions.ts +0 -17
  116. package/packages/orq-rc/src/mcp-server/mcp-server.ts +0 -26
  117. package/packages/orq-rc/src/mcp-server/prompts.ts +0 -110
  118. package/packages/orq-rc/src/mcp-server/resources.ts +0 -158
  119. package/packages/orq-rc/src/mcp-server/scopes.ts +0 -7
  120. package/packages/orq-rc/src/mcp-server/server.ts +0 -125
  121. package/packages/orq-rc/src/mcp-server/shared.ts +0 -75
  122. package/packages/orq-rc/src/mcp-server/tools/contactsCreate.ts +0 -37
  123. package/packages/orq-rc/src/mcp-server/tools/datasetsClear.ts +0 -35
  124. package/packages/orq-rc/src/mcp-server/tools/datasetsCreate.ts +0 -37
  125. package/packages/orq-rc/src/mcp-server/tools/datasetsCreateDatapoint.ts +0 -37
  126. package/packages/orq-rc/src/mcp-server/tools/datasetsCreateDatapoints.ts +0 -37
  127. package/packages/orq-rc/src/mcp-server/tools/datasetsDelete.ts +0 -35
  128. package/packages/orq-rc/src/mcp-server/tools/datasetsDeleteDatapoint.ts +0 -35
  129. package/packages/orq-rc/src/mcp-server/tools/datasetsList.ts +0 -37
  130. package/packages/orq-rc/src/mcp-server/tools/datasetsListDatapoints.ts +0 -37
  131. package/packages/orq-rc/src/mcp-server/tools/datasetsRetrieve.ts +0 -37
  132. package/packages/orq-rc/src/mcp-server/tools/datasetsRetrieveDatapoint.ts +0 -37
  133. package/packages/orq-rc/src/mcp-server/tools/datasetsUpdate.ts +0 -37
  134. package/packages/orq-rc/src/mcp-server/tools/datasetsUpdateDatapoint.ts +0 -35
  135. package/packages/orq-rc/src/mcp-server/tools/deploymentsGetConfig.ts +0 -37
  136. package/packages/orq-rc/src/mcp-server/tools/deploymentsInvoke.ts +0 -37
  137. package/packages/orq-rc/src/mcp-server/tools/deploymentsList.ts +0 -37
  138. package/packages/orq-rc/src/mcp-server/tools/deploymentsMetricsCreate.ts +0 -37
  139. package/packages/orq-rc/src/mcp-server/tools/deploymentsStream.ts +0 -37
  140. package/packages/orq-rc/src/mcp-server/tools/feedbackCreate.ts +0 -37
  141. package/packages/orq-rc/src/mcp-server/tools/filesCreate.ts +0 -37
  142. package/packages/orq-rc/src/mcp-server/tools/filesDelete.ts +0 -33
  143. package/packages/orq-rc/src/mcp-server/tools/filesGet.ts +0 -37
  144. package/packages/orq-rc/src/mcp-server/tools/filesList.ts +0 -37
  145. package/packages/orq-rc/src/mcp-server/tools/promptsCreate.ts +0 -35
  146. package/packages/orq-rc/src/mcp-server/tools/promptsDelete.ts +0 -33
  147. package/packages/orq-rc/src/mcp-server/tools/promptsGetVersion.ts +0 -37
  148. package/packages/orq-rc/src/mcp-server/tools/promptsList.ts +0 -37
  149. package/packages/orq-rc/src/mcp-server/tools/promptsListVersions.ts +0 -37
  150. package/packages/orq-rc/src/mcp-server/tools/promptsRetrieve.ts +0 -37
  151. package/packages/orq-rc/src/mcp-server/tools/promptsUpdate.ts +0 -35
  152. package/packages/orq-rc/src/mcp-server/tools/remoteconfigsRetrieve.ts +0 -36
  153. package/packages/orq-rc/src/mcp-server/tools.ts +0 -126
  154. package/packages/orq-rc/src/models/components/deployments.ts +0 -4164
  155. package/packages/orq-rc/src/models/components/index.ts +0 -6
  156. package/packages/orq-rc/src/models/components/security.ts +0 -71
  157. package/packages/orq-rc/src/models/errors/apierror.ts +0 -27
  158. package/packages/orq-rc/src/models/errors/getpromptversion.ts +0 -71
  159. package/packages/orq-rc/src/models/errors/honoapierror.ts +0 -82
  160. package/packages/orq-rc/src/models/errors/httpclienterrors.ts +0 -62
  161. package/packages/orq-rc/src/models/errors/index.ts +0 -10
  162. package/packages/orq-rc/src/models/errors/sdkvalidationerror.ts +0 -97
  163. package/packages/orq-rc/src/models/errors/updateprompt.ts +0 -71
  164. package/packages/orq-rc/src/models/operations/bulkcreatedatapoints.ts +0 -1816
  165. package/packages/orq-rc/src/models/operations/cleardataset.ts +0 -75
  166. package/packages/orq-rc/src/models/operations/createcontact.ts +0 -256
  167. package/packages/orq-rc/src/models/operations/createdataset.ts +0 -296
  168. package/packages/orq-rc/src/models/operations/createdatasetitem.ts +0 -1740
  169. package/packages/orq-rc/src/models/operations/createfeedback.ts +0 -286
  170. package/packages/orq-rc/src/models/operations/createprompt.ts +0 -3735
  171. package/packages/orq-rc/src/models/operations/deletedatapoint.ts +0 -81
  172. package/packages/orq-rc/src/models/operations/deletedataset.ts +0 -75
  173. package/packages/orq-rc/src/models/operations/deleteprompt.ts +0 -69
  174. package/packages/orq-rc/src/models/operations/deploymentcreatemetric.ts +0 -4936
  175. package/packages/orq-rc/src/models/operations/deploymentgetconfig.ts +0 -6090
  176. package/packages/orq-rc/src/models/operations/deploymentinvoke.ts +0 -1199
  177. package/packages/orq-rc/src/models/operations/deployments.ts +0 -2194
  178. package/packages/orq-rc/src/models/operations/deploymentstream.ts +0 -5960
  179. package/packages/orq-rc/src/models/operations/filedelete.ts +0 -78
  180. package/packages/orq-rc/src/models/operations/fileget.ts +0 -223
  181. package/packages/orq-rc/src/models/operations/filelist.ts +0 -377
  182. package/packages/orq-rc/src/models/operations/fileupload.ts +0 -324
  183. package/packages/orq-rc/src/models/operations/getallprompts.ts +0 -2165
  184. package/packages/orq-rc/src/models/operations/getoneprompt.ts +0 -1989
  185. package/packages/orq-rc/src/models/operations/getpromptversion.ts +0 -1987
  186. package/packages/orq-rc/src/models/operations/index.ts +0 -35
  187. package/packages/orq-rc/src/models/operations/listdatasetdatapoints.ts +0 -1115
  188. package/packages/orq-rc/src/models/operations/listdatasets.ts +0 -448
  189. package/packages/orq-rc/src/models/operations/listpromptversions.ts +0 -2163
  190. package/packages/orq-rc/src/models/operations/remoteconfigsgetconfig.ts +0 -190
  191. package/packages/orq-rc/src/models/operations/retrievedatapoint.ts +0 -924
  192. package/packages/orq-rc/src/models/operations/retrievedataset.ts +0 -288
  193. package/packages/orq-rc/src/models/operations/updatedatapoint.ts +0 -1729
  194. package/packages/orq-rc/src/models/operations/updatedataset.ts +0 -374
  195. package/packages/orq-rc/src/models/operations/updateprompt.ts +0 -3914
  196. package/packages/orq-rc/src/sdk/contacts.ts +0 -27
  197. package/packages/orq-rc/src/sdk/datasets.ts +0 -222
  198. package/packages/orq-rc/src/sdk/deployments.ts +0 -89
  199. package/packages/orq-rc/src/sdk/feedback.ts +0 -27
  200. package/packages/orq-rc/src/sdk/files.ts +0 -78
  201. package/packages/orq-rc/src/sdk/index.ts +0 -5
  202. package/packages/orq-rc/src/sdk/metrics.ts +0 -27
  203. package/packages/orq-rc/src/sdk/prompts.ts +0 -126
  204. package/packages/orq-rc/src/sdk/remoteconfigs.ts +0 -24
  205. package/packages/orq-rc/src/sdk/sdk.ts +0 -49
  206. package/packages/orq-rc/src/types/async.ts +0 -68
  207. package/packages/orq-rc/src/types/blobs.ts +0 -31
  208. package/packages/orq-rc/src/types/constdatetime.ts +0 -15
  209. package/packages/orq-rc/src/types/enums.ts +0 -16
  210. package/packages/orq-rc/src/types/fp.ts +0 -50
  211. package/packages/orq-rc/src/types/index.ts +0 -11
  212. package/packages/orq-rc/src/types/operations.ts +0 -105
  213. package/packages/orq-rc/src/types/rfcdate.ts +0 -54
  214. package/packages/orq-rc/src/types/streams.ts +0 -21
  215. package/packages/orq-rc/tsconfig.json +0 -41
@@ -1,264 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- export type ServerEvent<T> = {
6
- data?: T | undefined;
7
- event?: string | undefined;
8
- retry?: number | undefined;
9
- id?: string | undefined;
10
- };
11
- const LF = 0x0a;
12
- const CR = 0x0d;
13
- const NEWLINE_CHARS = new Set([LF, CR]);
14
- const MESSAGE_BOUNDARIES = [
15
- new Uint8Array([CR, LF, CR, LF]),
16
- new Uint8Array([CR, CR]),
17
- new Uint8Array([LF, LF]),
18
- ];
19
-
20
- export class EventStream<Event extends ServerEvent<unknown>> {
21
- private readonly stream: ReadableStream<Uint8Array>;
22
- private readonly decoder: (rawEvent: ServerEvent<string>) => Event;
23
-
24
- constructor(init: {
25
- stream: ReadableStream<Uint8Array>;
26
- decoder: (rawEvent: ServerEvent<string>) => Event;
27
- }) {
28
- this.stream = init.stream;
29
- this.decoder = init.decoder;
30
- }
31
-
32
- async *[Symbol.asyncIterator](): AsyncGenerator<Event, void, unknown> {
33
- const reader = this.stream.getReader();
34
- let buffer = new Uint8Array([]);
35
- let position = 0;
36
-
37
- try {
38
- while (true) {
39
- const { done, value } = await reader.read();
40
- if (done) {
41
- break;
42
- }
43
-
44
- const newBuffer = new Uint8Array(buffer.length + value.length);
45
- newBuffer.set(buffer);
46
- newBuffer.set(value, buffer.length);
47
- buffer = newBuffer;
48
-
49
- for (let i = position; i < buffer.length; i++) {
50
- const boundary = findBoundary(buffer, i);
51
- if (boundary == null) {
52
- continue;
53
- }
54
-
55
- const chunk = buffer.slice(position, i);
56
- position = i + boundary.length;
57
- const event = parseEvent(chunk, this.decoder);
58
- if (event != null) {
59
- yield event;
60
- }
61
- }
62
-
63
- if (position > 0) {
64
- buffer = buffer.slice(position);
65
- position = 0;
66
- }
67
- }
68
-
69
- if (buffer.length > 0) {
70
- const event = parseEvent(buffer, this.decoder);
71
- if (event != null) {
72
- yield event;
73
- }
74
- }
75
- } catch (e: unknown) {
76
- if (e instanceof Error && e.name === "AbortError") {
77
- return;
78
- }
79
-
80
- throw e;
81
- } finally {
82
- reader.releaseLock();
83
- }
84
- }
85
- }
86
-
87
- function findBoundary(buffer: Uint8Array, start: number): Uint8Array | null {
88
- const char1 = buffer[start];
89
- const char2 = buffer[start + 1];
90
-
91
- // Don't bother checking if the first two characters are not new line
92
- // characters.
93
- if (
94
- char1 == null
95
- || char2 == null
96
- || !NEWLINE_CHARS.has(char1)
97
- || !NEWLINE_CHARS.has(char2)
98
- ) {
99
- return null;
100
- }
101
-
102
- for (const s of MESSAGE_BOUNDARIES) {
103
- const seq = peekSequence(start, buffer, s);
104
- if (seq != null) {
105
- return seq;
106
- }
107
- }
108
-
109
- return null;
110
- }
111
-
112
- function peekSequence(
113
- position: number,
114
- buffer: Uint8Array,
115
- sequence: Uint8Array,
116
- ): Uint8Array | null {
117
- if (sequence.length > buffer.length - position) {
118
- return null;
119
- }
120
-
121
- for (let i = 0; i < sequence.length; i++) {
122
- if (buffer[position + i] !== sequence[i]) {
123
- return null;
124
- }
125
- }
126
-
127
- return sequence;
128
- }
129
-
130
- function parseEvent<Event extends ServerEvent<unknown>>(
131
- chunk: Uint8Array,
132
- decoder: (rawEvent: ServerEvent<string>) => Event,
133
- ) {
134
- if (!chunk.length) {
135
- return null;
136
- }
137
-
138
- const td = new TextDecoder();
139
- const raw = td.decode(chunk);
140
- const lines = raw.split(/\r?\n|\r/g);
141
- let publish = false;
142
- const rawEvent: ServerEvent<string> = {};
143
-
144
- for (const line of lines) {
145
- if (!line) {
146
- continue;
147
- }
148
-
149
- const delim = line.indexOf(":");
150
- // Lines starting with a colon are ignored.
151
- if (delim === 0) {
152
- continue;
153
- }
154
-
155
- const field = delim > 0 ? line.substring(0, delim) : "";
156
- let value = delim > 0 ? line.substring(delim + 1) : "";
157
- if (value.charAt(0) === " ") {
158
- value = value.substring(1);
159
- }
160
-
161
- switch (field) {
162
- case "event": {
163
- publish = true;
164
- rawEvent.event = value;
165
- break;
166
- }
167
- case "data": {
168
- publish = true;
169
- rawEvent.data ??= "";
170
- rawEvent.data += value + "\n";
171
- break;
172
- }
173
- case "id": {
174
- publish = true;
175
- rawEvent.id = value;
176
- break;
177
- }
178
- case "retry": {
179
- const r = parseInt(value, 10);
180
- if (!Number.isNaN(r)) {
181
- publish = true;
182
- rawEvent.retry = r;
183
- }
184
- break;
185
- }
186
- }
187
- }
188
-
189
- if (!publish) {
190
- return null;
191
- }
192
-
193
- if (rawEvent.data != null) {
194
- rawEvent.data = rawEvent.data.slice(0, -1);
195
- }
196
-
197
- return decoder(rawEvent);
198
- }
199
-
200
- export function discardSentinel(
201
- stream: ReadableStream<Uint8Array>,
202
- sentinel: string,
203
- ): ReadableStream<Uint8Array> {
204
- return new ReadableStream<Uint8Array>({
205
- async start(controller) {
206
- let buffer = new Uint8Array([]);
207
- let position = 0;
208
- let done = false;
209
- let discard = false;
210
- const rdr = stream.getReader();
211
- try {
212
- while (!done) {
213
- const result = await rdr.read();
214
- const value = result.value;
215
- done = done || result.done;
216
- // We keep consuming from the source to its completion so it can
217
- // flush all its contents and release resources.
218
- if (discard) {
219
- continue;
220
- }
221
- if (typeof value === "undefined") {
222
- continue;
223
- }
224
-
225
- const newBuffer = new Uint8Array(buffer.length + value.length);
226
- newBuffer.set(buffer);
227
- newBuffer.set(value, buffer.length);
228
- buffer = newBuffer;
229
-
230
- for (let i = position; i < buffer.length; i++) {
231
- const boundary = findBoundary(buffer, i);
232
- if (boundary == null) {
233
- continue;
234
- }
235
-
236
- const start = position;
237
- const chunk = buffer.slice(start, i);
238
- position = i + boundary.length;
239
- const event = parseEvent(chunk, id);
240
- if (event?.data === sentinel) {
241
- controller.enqueue(buffer.slice(0, start));
242
- discard = true;
243
- } else {
244
- controller.enqueue(buffer.slice(0, position));
245
- buffer = buffer.slice(position);
246
- position = 0;
247
- }
248
- }
249
- }
250
- } catch (e) {
251
- controller.error(e);
252
- } finally {
253
- // If the source stream terminates, flush its contents and terminate.
254
- // If the sentinel event was found, flush everything up to its start.
255
- controller.close();
256
- rdr.releaseLock();
257
- }
258
- },
259
- });
260
- }
261
-
262
- function id<T>(v: T): T {
263
- return v;
264
- }
@@ -1,40 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- /**
6
- * Consumes a stream and returns a concatenated array buffer. Useful in
7
- * situations where we need to read the whole file because it forms part of a
8
- * larger payload containing other fields, and we can't modify the underlying
9
- * request structure.
10
- */
11
- export async function readableStreamToArrayBuffer(
12
- readable: ReadableStream<Uint8Array>,
13
- ): Promise<ArrayBuffer> {
14
- const reader = readable.getReader();
15
- const chunks: Uint8Array[] = [];
16
-
17
- let totalLength = 0;
18
- let done = false;
19
-
20
- while (!done) {
21
- const { value, done: doneReading } = await reader.read();
22
-
23
- if (doneReading) {
24
- done = true;
25
- } else {
26
- chunks.push(value);
27
- totalLength += value.length;
28
- }
29
- }
30
-
31
- const concatenatedChunks = new Uint8Array(totalLength);
32
- let offset = 0;
33
-
34
- for (const chunk of chunks) {
35
- concatenatedChunks.set(chunk, offset);
36
- offset += chunk.length;
37
- }
38
-
39
- return concatenatedChunks.buffer as ArrayBuffer;
40
- }
@@ -1,323 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- export type Fetcher = (
6
- input: RequestInfo | URL,
7
- init?: RequestInit,
8
- ) => Promise<Response>;
9
-
10
- export type Awaitable<T> = T | Promise<T>;
11
-
12
- const DEFAULT_FETCHER: Fetcher = (input, init) => {
13
- // If input is a Request and init is undefined, Bun will discard the method,
14
- // headers, body and other options that were set on the request object.
15
- // Node.js and browers would ignore an undefined init value. This check is
16
- // therefore needed for interop with Bun.
17
- if (init == null) {
18
- return fetch(input);
19
- } else {
20
- return fetch(input, init);
21
- }
22
- };
23
-
24
- export type RequestInput = {
25
- /**
26
- * The URL the request will use.
27
- */
28
- url: URL;
29
- /**
30
- * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request).
31
- */
32
- options?: RequestInit | undefined;
33
- };
34
-
35
- export interface HTTPClientOptions {
36
- fetcher?: Fetcher;
37
- }
38
-
39
- export type BeforeRequestHook = (req: Request) => Awaitable<Request | void>;
40
- export type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>;
41
- export type ResponseHook = (res: Response, req: Request) => Awaitable<void>;
42
-
43
- export class HTTPClient {
44
- private fetcher: Fetcher;
45
- private requestHooks: BeforeRequestHook[] = [];
46
- private requestErrorHooks: RequestErrorHook[] = [];
47
- private responseHooks: ResponseHook[] = [];
48
-
49
- constructor(private options: HTTPClientOptions = {}) {
50
- this.fetcher = options.fetcher || DEFAULT_FETCHER;
51
- }
52
-
53
- async request(request: Request): Promise<Response> {
54
- let req = request;
55
- for (const hook of this.requestHooks) {
56
- const nextRequest = await hook(req);
57
- if (nextRequest) {
58
- req = nextRequest;
59
- }
60
- }
61
-
62
- try {
63
- const res = await this.fetcher(req);
64
-
65
- for (const hook of this.responseHooks) {
66
- await hook(res, req);
67
- }
68
-
69
- return res;
70
- } catch (err) {
71
- for (const hook of this.requestErrorHooks) {
72
- await hook(err, req);
73
- }
74
-
75
- throw err;
76
- }
77
- }
78
-
79
- /**
80
- * Registers a hook that is called before a request is made. The hook function
81
- * can mutate the request or return a new request. This may be useful to add
82
- * additional information to request such as request IDs and tracing headers.
83
- */
84
- addHook(hook: "beforeRequest", fn: BeforeRequestHook): this;
85
- /**
86
- * Registers a hook that is called when a request cannot be made due to a
87
- * network error.
88
- */
89
- addHook(hook: "requestError", fn: RequestErrorHook): this;
90
- /**
91
- * Registers a hook that is called when a response has been received from the
92
- * server.
93
- */
94
- addHook(hook: "response", fn: ResponseHook): this;
95
- addHook(
96
- ...args:
97
- | [hook: "beforeRequest", fn: BeforeRequestHook]
98
- | [hook: "requestError", fn: RequestErrorHook]
99
- | [hook: "response", fn: ResponseHook]
100
- ) {
101
- if (args[0] === "beforeRequest") {
102
- this.requestHooks.push(args[1]);
103
- } else if (args[0] === "requestError") {
104
- this.requestErrorHooks.push(args[1]);
105
- } else if (args[0] === "response") {
106
- this.responseHooks.push(args[1]);
107
- } else {
108
- throw new Error(`Invalid hook type: ${args[0]}`);
109
- }
110
- return this;
111
- }
112
-
113
- /** Removes a hook that was previously registered with `addHook`. */
114
- removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this;
115
- /** Removes a hook that was previously registered with `addHook`. */
116
- removeHook(hook: "requestError", fn: RequestErrorHook): this;
117
- /** Removes a hook that was previously registered with `addHook`. */
118
- removeHook(hook: "response", fn: ResponseHook): this;
119
- removeHook(
120
- ...args:
121
- | [hook: "beforeRequest", fn: BeforeRequestHook]
122
- | [hook: "requestError", fn: RequestErrorHook]
123
- | [hook: "response", fn: ResponseHook]
124
- ): this {
125
- let target: unknown[];
126
- if (args[0] === "beforeRequest") {
127
- target = this.requestHooks;
128
- } else if (args[0] === "requestError") {
129
- target = this.requestErrorHooks;
130
- } else if (args[0] === "response") {
131
- target = this.responseHooks;
132
- } else {
133
- throw new Error(`Invalid hook type: ${args[0]}`);
134
- }
135
-
136
- const index = target.findIndex((v) => v === args[1]);
137
- if (index >= 0) {
138
- target.splice(index, 1);
139
- }
140
-
141
- return this;
142
- }
143
-
144
- clone(): HTTPClient {
145
- const child = new HTTPClient(this.options);
146
- child.requestHooks = this.requestHooks.slice();
147
- child.requestErrorHooks = this.requestErrorHooks.slice();
148
- child.responseHooks = this.responseHooks.slice();
149
-
150
- return child;
151
- }
152
- }
153
-
154
- export type StatusCodePredicate = number | string | (number | string)[];
155
-
156
- // A semicolon surrounded by optional whitespace characters is used to separate
157
- // segments in a media type string.
158
- const mediaParamSeparator = /\s*;\s*/g;
159
-
160
- export function matchContentType(response: Response, pattern: string): boolean {
161
- // `*` is a special case which means anything is acceptable.
162
- if (pattern === "*") {
163
- return true;
164
- }
165
-
166
- let contentType =
167
- response.headers.get("content-type")?.trim() || "application/octet-stream";
168
- contentType = contentType.toLowerCase();
169
-
170
- const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator);
171
- const [wantType = "", ...wantParams] = wantParts;
172
-
173
- if (wantType.split("/").length !== 2) {
174
- return false;
175
- }
176
-
177
- const gotParts = contentType.split(mediaParamSeparator);
178
- const [gotType = "", ...gotParams] = gotParts;
179
-
180
- const [type = "", subtype = ""] = gotType.split("/");
181
- if (!type || !subtype) {
182
- return false;
183
- }
184
-
185
- if (
186
- wantType !== "*/*" &&
187
- gotType !== wantType &&
188
- `${type}/*` !== wantType &&
189
- `*/${subtype}` !== wantType
190
- ) {
191
- return false;
192
- }
193
-
194
- if (gotParams.length < wantParams.length) {
195
- return false;
196
- }
197
-
198
- const params = new Set(gotParams);
199
- for (const wantParam of wantParams) {
200
- if (!params.has(wantParam)) {
201
- return false;
202
- }
203
- }
204
-
205
- return true;
206
- }
207
-
208
- const codeRangeRE = new RegExp("^[0-9]xx$", "i");
209
-
210
- export function matchStatusCode(
211
- response: Response,
212
- codes: StatusCodePredicate,
213
- ): boolean {
214
- const actual = `${response.status}`;
215
- const expectedCodes = Array.isArray(codes) ? codes : [codes];
216
- if (!expectedCodes.length) {
217
- return false;
218
- }
219
-
220
- return expectedCodes.some((ec) => {
221
- const code = `${ec}`;
222
-
223
- if (code === "default") {
224
- return true;
225
- }
226
-
227
- if (!codeRangeRE.test(`${code}`)) {
228
- return code === actual;
229
- }
230
-
231
- const expectFamily = code.charAt(0);
232
- if (!expectFamily) {
233
- throw new Error("Invalid status code range");
234
- }
235
-
236
- const actualFamily = actual.charAt(0);
237
- if (!actualFamily) {
238
- throw new Error(`Invalid response status code: ${actual}`);
239
- }
240
-
241
- return actualFamily === expectFamily;
242
- });
243
- }
244
-
245
- export function matchResponse(
246
- response: Response,
247
- code: StatusCodePredicate,
248
- contentTypePattern: string,
249
- ): boolean {
250
- return (
251
- matchStatusCode(response, code) &&
252
- matchContentType(response, contentTypePattern)
253
- );
254
- }
255
-
256
- /**
257
- * Uses various heurisitics to determine if an error is a connection error.
258
- */
259
- export function isConnectionError(err: unknown): boolean {
260
- if (typeof err !== "object" || err == null) {
261
- return false;
262
- }
263
-
264
- // Covers fetch in Deno as well
265
- const isBrowserErr =
266
- err instanceof TypeError &&
267
- err.message.toLowerCase().startsWith("failed to fetch");
268
-
269
- const isNodeErr =
270
- err instanceof TypeError &&
271
- err.message.toLowerCase().startsWith("fetch failed");
272
-
273
- const isBunErr = "name" in err && err.name === "ConnectionError";
274
-
275
- const isGenericErr =
276
- "code" in err &&
277
- typeof err.code === "string" &&
278
- err.code.toLowerCase() === "econnreset";
279
-
280
- return isBrowserErr || isNodeErr || isGenericErr || isBunErr;
281
- }
282
-
283
- /**
284
- * Uses various heurisitics to determine if an error is a timeout error.
285
- */
286
- export function isTimeoutError(err: unknown): boolean {
287
- if (typeof err !== "object" || err == null) {
288
- return false;
289
- }
290
-
291
- // Fetch in browser, Node.js, Bun, Deno
292
- const isNative = "name" in err && err.name === "TimeoutError";
293
- const isLegacyNative = "code" in err && err.code === 23;
294
-
295
- // Node.js HTTP client and Axios
296
- const isGenericErr =
297
- "code" in err &&
298
- typeof err.code === "string" &&
299
- err.code.toLowerCase() === "econnaborted";
300
-
301
- return isNative || isLegacyNative || isGenericErr;
302
- }
303
-
304
- /**
305
- * Uses various heurisitics to determine if an error is a abort error.
306
- */
307
- export function isAbortError(err: unknown): boolean {
308
- if (typeof err !== "object" || err == null) {
309
- return false;
310
- }
311
-
312
- // Fetch in browser, Node.js, Bun, Deno
313
- const isNative = "name" in err && err.name === "AbortError";
314
- const isLegacyNative = "code" in err && err.code === 20;
315
-
316
- // Node.js HTTP client and Axios
317
- const isGenericErr =
318
- "code" in err &&
319
- typeof err.code === "string" &&
320
- err.code.toLowerCase() === "econnaborted";
321
-
322
- return isNative || isLegacyNative || isGenericErr;
323
- }
@@ -1,43 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- /*
6
- MIT License
7
-
8
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy of
11
- this software and associated documentation files (the "Software"), to deal in
12
- the Software without restriction, including without limitation the rights to
13
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
- the Software, and to permit persons to whom the Software is furnished to do so,
15
- subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
- // Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
29
-
30
- export function isPlainObject(value: unknown): value is object {
31
- if (typeof value !== "object" || value === null) {
32
- return false;
33
- }
34
-
35
- const prototype = Object.getPrototypeOf(value);
36
- return (
37
- (prototype === null ||
38
- prototype === Object.prototype ||
39
- Object.getPrototypeOf(prototype) === null) &&
40
- !(Symbol.toStringTag in value) &&
41
- !(Symbol.iterator in value)
42
- );
43
- }
@@ -1,9 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- export interface Logger {
6
- group(label?: string): void;
7
- groupEnd(): void;
8
- log(message: any, ...args: any[]): void;
9
- }