@orq-ai/node 3.1.7 → 3.2.0-rc.3

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 (147) hide show
  1. package/README.md +0 -38
  2. package/docs/sdks/deployments/README.md +0 -81
  3. package/jsr.json +1 -2
  4. package/lib/config.d.ts +3 -3
  5. package/lib/config.js +3 -3
  6. package/lib/config.js.map +1 -1
  7. package/lib/matchers.d.ts.map +1 -1
  8. package/lib/matchers.js +1 -4
  9. package/lib/matchers.js.map +1 -1
  10. package/models/operations/createcontact.js +2 -2
  11. package/models/operations/fileget.js +2 -2
  12. package/models/operations/filelist.js +2 -2
  13. package/models/operations/fileupload.js +2 -2
  14. package/models/operations/index.d.ts +0 -1
  15. package/models/operations/index.d.ts.map +1 -1
  16. package/models/operations/index.js +0 -1
  17. package/models/operations/index.js.map +1 -1
  18. package/package.json +3 -2
  19. package/sdk/deployments.d.ts +0 -8
  20. package/sdk/deployments.d.ts.map +1 -1
  21. package/sdk/deployments.js +0 -10
  22. package/sdk/deployments.js.map +1 -1
  23. package/src/lib/config.ts +3 -3
  24. package/src/lib/matchers.ts +1 -4
  25. package/src/models/operations/createcontact.ts +2 -2
  26. package/src/models/operations/fileget.ts +2 -2
  27. package/src/models/operations/filelist.ts +2 -2
  28. package/src/models/operations/fileupload.ts +2 -2
  29. package/src/models/operations/index.ts +0 -1
  30. package/src/sdk/deployments.ts +0 -19
  31. package/funcs/deploymentsStream.d.ts +0 -16
  32. package/funcs/deploymentsStream.d.ts.map +0 -1
  33. package/funcs/deploymentsStream.js +0 -126
  34. package/funcs/deploymentsStream.js.map +0 -1
  35. package/lib/event-streams.d.ts +0 -17
  36. package/lib/event-streams.d.ts.map +0 -1
  37. package/lib/event-streams.js +0 -220
  38. package/lib/event-streams.js.map +0 -1
  39. package/models/operations/deploymentstream.d.ts +0 -1622
  40. package/models/operations/deploymentstream.d.ts.map +0 -1
  41. package/models/operations/deploymentstream.js +0 -1571
  42. package/models/operations/deploymentstream.js.map +0 -1
  43. package/packages/orq-rc/FUNCTIONS.md +0 -106
  44. package/packages/orq-rc/README.md +0 -506
  45. package/packages/orq-rc/RUNTIMES.md +0 -48
  46. package/packages/orq-rc/docs/sdks/contacts/README.md +0 -84
  47. package/packages/orq-rc/docs/sdks/deployments/README.md +0 -235
  48. package/packages/orq-rc/docs/sdks/feedback/README.md +0 -92
  49. package/packages/orq-rc/docs/sdks/files/README.md +0 -305
  50. package/packages/orq-rc/docs/sdks/metrics/README.md +0 -86
  51. package/packages/orq-rc/docs/sdks/orq/README.md +0 -10
  52. package/packages/orq-rc/docs/sdks/prompts/README.md +0 -608
  53. package/packages/orq-rc/docs/sdks/remoteconfigs/README.md +0 -80
  54. package/packages/orq-rc/jsr.json +0 -27
  55. package/packages/orq-rc/package-lock.json +0 -1861
  56. package/packages/orq-rc/package.json +0 -31
  57. package/packages/orq-rc/src/core.ts +0 -13
  58. package/packages/orq-rc/src/funcs/contactsCreate.ts +0 -127
  59. package/packages/orq-rc/src/funcs/deploymentsGetConfig.ts +0 -135
  60. package/packages/orq-rc/src/funcs/deploymentsInvoke.ts +0 -143
  61. package/packages/orq-rc/src/funcs/deploymentsList.ts +0 -142
  62. package/packages/orq-rc/src/funcs/deploymentsMetricsCreate.ts +0 -135
  63. package/packages/orq-rc/src/funcs/feedbackCreate.ts +0 -127
  64. package/packages/orq-rc/src/funcs/filesCreate.ts +0 -150
  65. package/packages/orq-rc/src/funcs/filesDelete.ts +0 -131
  66. package/packages/orq-rc/src/funcs/filesGet.ts +0 -133
  67. package/packages/orq-rc/src/funcs/filesList.ts +0 -134
  68. package/packages/orq-rc/src/funcs/promptsCreate.ts +0 -127
  69. package/packages/orq-rc/src/funcs/promptsDelete.ts +0 -131
  70. package/packages/orq-rc/src/funcs/promptsGetVersion.ts +0 -147
  71. package/packages/orq-rc/src/funcs/promptsList.ts +0 -134
  72. package/packages/orq-rc/src/funcs/promptsListVersions.ts +0 -140
  73. package/packages/orq-rc/src/funcs/promptsRetrieve.ts +0 -133
  74. package/packages/orq-rc/src/funcs/promptsUpdate.ts +0 -139
  75. package/packages/orq-rc/src/funcs/remoteconfigsRetrieve.ts +0 -128
  76. package/packages/orq-rc/src/hooks/global.ts +0 -44
  77. package/packages/orq-rc/src/hooks/hooks.ts +0 -132
  78. package/packages/orq-rc/src/hooks/index.ts +0 -6
  79. package/packages/orq-rc/src/hooks/registration.ts +0 -15
  80. package/packages/orq-rc/src/hooks/types.ts +0 -110
  81. package/packages/orq-rc/src/index.ts +0 -7
  82. package/packages/orq-rc/src/lib/base64.ts +0 -37
  83. package/packages/orq-rc/src/lib/config.ts +0 -70
  84. package/packages/orq-rc/src/lib/dlv.ts +0 -53
  85. package/packages/orq-rc/src/lib/encodings.ts +0 -483
  86. package/packages/orq-rc/src/lib/env.ts +0 -73
  87. package/packages/orq-rc/src/lib/files.ts +0 -40
  88. package/packages/orq-rc/src/lib/http.ts +0 -323
  89. package/packages/orq-rc/src/lib/is-plain-object.ts +0 -43
  90. package/packages/orq-rc/src/lib/logger.ts +0 -9
  91. package/packages/orq-rc/src/lib/matchers.ts +0 -322
  92. package/packages/orq-rc/src/lib/primitives.ts +0 -136
  93. package/packages/orq-rc/src/lib/retries.ts +0 -218
  94. package/packages/orq-rc/src/lib/schemas.ts +0 -91
  95. package/packages/orq-rc/src/lib/sdks.ts +0 -400
  96. package/packages/orq-rc/src/lib/security.ts +0 -253
  97. package/packages/orq-rc/src/lib/url.ts +0 -33
  98. package/packages/orq-rc/src/models/components/deployments.ts +0 -1666
  99. package/packages/orq-rc/src/models/components/index.ts +0 -6
  100. package/packages/orq-rc/src/models/components/security.ts +0 -71
  101. package/packages/orq-rc/src/models/errors/apierror.ts +0 -27
  102. package/packages/orq-rc/src/models/errors/getpromptversion.ts +0 -71
  103. package/packages/orq-rc/src/models/errors/honoapierror.ts +0 -82
  104. package/packages/orq-rc/src/models/errors/httpclienterrors.ts +0 -62
  105. package/packages/orq-rc/src/models/errors/index.ts +0 -10
  106. package/packages/orq-rc/src/models/errors/sdkvalidationerror.ts +0 -97
  107. package/packages/orq-rc/src/models/errors/updateprompt.ts +0 -71
  108. package/packages/orq-rc/src/models/operations/createcontact.ts +0 -256
  109. package/packages/orq-rc/src/models/operations/createfeedback.ts +0 -286
  110. package/packages/orq-rc/src/models/operations/createprompt.ts +0 -3717
  111. package/packages/orq-rc/src/models/operations/deleteprompt.ts +0 -69
  112. package/packages/orq-rc/src/models/operations/deploymentcreatemetric.ts +0 -1790
  113. package/packages/orq-rc/src/models/operations/deploymentgetconfig.ts +0 -3527
  114. package/packages/orq-rc/src/models/operations/deploymentinvoke.ts +0 -1144
  115. package/packages/orq-rc/src/models/operations/deployments.ts +0 -2148
  116. package/packages/orq-rc/src/models/operations/filedelete.ts +0 -78
  117. package/packages/orq-rc/src/models/operations/fileget.ts +0 -222
  118. package/packages/orq-rc/src/models/operations/filelist.ts +0 -336
  119. package/packages/orq-rc/src/models/operations/fileupload.ts +0 -322
  120. package/packages/orq-rc/src/models/operations/getallprompts.ts +0 -2116
  121. package/packages/orq-rc/src/models/operations/getoneprompt.ts +0 -1982
  122. package/packages/orq-rc/src/models/operations/getpromptversion.ts +0 -2012
  123. package/packages/orq-rc/src/models/operations/index.ts +0 -22
  124. package/packages/orq-rc/src/models/operations/listpromptversions.ts +0 -2146
  125. package/packages/orq-rc/src/models/operations/remoteconfigsgetconfig.ts +0 -190
  126. package/packages/orq-rc/src/models/operations/updateprompt.ts +0 -3900
  127. package/packages/orq-rc/src/sdk/contacts.ts +0 -27
  128. package/packages/orq-rc/src/sdk/deployments.ts +0 -70
  129. package/packages/orq-rc/src/sdk/feedback.ts +0 -27
  130. package/packages/orq-rc/src/sdk/files.ts +0 -78
  131. package/packages/orq-rc/src/sdk/index.ts +0 -5
  132. package/packages/orq-rc/src/sdk/metrics.ts +0 -27
  133. package/packages/orq-rc/src/sdk/prompts.ts +0 -126
  134. package/packages/orq-rc/src/sdk/remoteconfigs.ts +0 -24
  135. package/packages/orq-rc/src/sdk/sdk.ts +0 -43
  136. package/packages/orq-rc/src/types/blobs.ts +0 -31
  137. package/packages/orq-rc/src/types/constdatetime.ts +0 -15
  138. package/packages/orq-rc/src/types/enums.ts +0 -16
  139. package/packages/orq-rc/src/types/fp.ts +0 -50
  140. package/packages/orq-rc/src/types/index.ts +0 -11
  141. package/packages/orq-rc/src/types/operations.ts +0 -105
  142. package/packages/orq-rc/src/types/rfcdate.ts +0 -54
  143. package/packages/orq-rc/src/types/streams.ts +0 -21
  144. package/packages/orq-rc/tsconfig.json +0 -41
  145. package/src/funcs/deploymentsStream.ts +0 -151
  146. package/src/lib/event-streams.ts +0 -264
  147. package/src/models/operations/deploymentstream.ts +0 -3062
@@ -1,506 +0,0 @@
1
- # @orq-ai/node
2
-
3
- Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@orq-ai/node* API.
4
-
5
- <div align="left">
6
- <a href="https://www.speakeasy.com/?utm_source=@orq-ai/node&utm_campaign=typescript"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
7
- <a href="https://opensource.org/licenses/MIT">
8
- <img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
9
- </a>
10
- </div>
11
-
12
- <!-- Start Summary [summary] -->
13
- ## Summary
14
-
15
- [Dev] orq.ai API: orq.ai API documentation
16
-
17
- For more information about the API: [orq.ai Documentation](https://docs.orq.ai)
18
- <!-- End Summary [summary] -->
19
-
20
- <!-- Start Table of Contents [toc] -->
21
- ## Table of Contents
22
- <!-- $toc-max-depth=2 -->
23
- * [@orq-ai/node](#orq-ainode)
24
- * [SDK Installation](#sdk-installation)
25
- * [Requirements](#requirements)
26
- * [SDK Example Usage](#sdk-example-usage)
27
- * [Authentication](#authentication)
28
- * [Available Resources and Operations](#available-resources-and-operations)
29
- * [Standalone functions](#standalone-functions)
30
- * [File uploads](#file-uploads)
31
- * [Retries](#retries)
32
- * [Error Handling](#error-handling)
33
- * [Server Selection](#server-selection)
34
- * [Custom HTTP Client](#custom-http-client)
35
- * [Debugging](#debugging)
36
- * [Development](#development)
37
- * [Maturity](#maturity)
38
- * [Contributions](#contributions)
39
-
40
- <!-- End Table of Contents [toc] -->
41
-
42
- <!-- Start SDK Installation [installation] -->
43
- ## SDK Installation
44
-
45
- The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
46
-
47
- ### NPM
48
-
49
- ```bash
50
- npm add @orq-ai/node
51
- ```
52
-
53
- ### PNPM
54
-
55
- ```bash
56
- pnpm add @orq-ai/node
57
- ```
58
-
59
- ### Bun
60
-
61
- ```bash
62
- bun add @orq-ai/node
63
- ```
64
-
65
- ### Yarn
66
-
67
- ```bash
68
- yarn add @orq-ai/node zod
69
-
70
- # Note that Yarn does not install peer dependencies automatically. You will need
71
- # to install zod as shown above.
72
- ```
73
- <!-- End SDK Installation [installation] -->
74
-
75
- <!-- Start Requirements [requirements] -->
76
- ## Requirements
77
-
78
- For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
79
- <!-- End Requirements [requirements] -->
80
-
81
- <!-- Start SDK Example Usage [usage] -->
82
- ## SDK Example Usage
83
-
84
- ### Example
85
-
86
- ```typescript
87
- import { Orq } from "@orq-ai/node";
88
-
89
- const orq = new Orq({
90
- apiKey: process.env["ORQ_API_KEY"] ?? "",
91
- });
92
-
93
- async function run() {
94
- const result = await orq.contacts.create({
95
- externalId: "<id>",
96
- });
97
-
98
- // Handle the result
99
- console.log(result);
100
- }
101
-
102
- run();
103
-
104
- ```
105
- <!-- End SDK Example Usage [usage] -->
106
-
107
- <!-- Start Authentication [security] -->
108
- ## Authentication
109
-
110
- ### Per-Client Security Schemes
111
-
112
- This SDK supports the following security scheme globally:
113
-
114
- | Name | Type | Scheme | Environment Variable |
115
- | -------- | ---- | ----------- | -------------------- |
116
- | `apiKey` | http | HTTP Bearer | `ORQ_API_KEY` |
117
-
118
- To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:
119
- ```typescript
120
- import { Orq } from "@orq-ai/node";
121
-
122
- const orq = new Orq({
123
- apiKey: process.env["ORQ_API_KEY"] ?? "",
124
- });
125
-
126
- async function run() {
127
- const result = await orq.contacts.create({
128
- externalId: "<id>",
129
- });
130
-
131
- // Handle the result
132
- console.log(result);
133
- }
134
-
135
- run();
136
-
137
- ```
138
- <!-- End Authentication [security] -->
139
-
140
- <!-- Start Available Resources and Operations [operations] -->
141
- ## Available Resources and Operations
142
-
143
- <details open>
144
- <summary>Available methods</summary>
145
-
146
- ### [contacts](docs/sdks/contacts/README.md)
147
-
148
- * [create](docs/sdks/contacts/README.md#create) - Update user information
149
-
150
- ### [deployments](docs/sdks/deployments/README.md)
151
-
152
- * [list](docs/sdks/deployments/README.md#list) - List all deployments
153
- * [getConfig](docs/sdks/deployments/README.md#getconfig) - Get config
154
- * [invoke](docs/sdks/deployments/README.md#invoke) - Invoke
155
-
156
- #### [deployments.metrics](docs/sdks/metrics/README.md)
157
-
158
- * [create](docs/sdks/metrics/README.md#create) - Add metrics
159
-
160
- ### [feedback](docs/sdks/feedback/README.md)
161
-
162
- * [create](docs/sdks/feedback/README.md#create) - Submit feedback
163
-
164
- ### [files](docs/sdks/files/README.md)
165
-
166
- * [create](docs/sdks/files/README.md#create) - Create file
167
- * [list](docs/sdks/files/README.md#list) - List all files
168
- * [get](docs/sdks/files/README.md#get) - Retrieve a file
169
- * [delete](docs/sdks/files/README.md#delete) - Delete file
170
-
171
-
172
- ### [prompts](docs/sdks/prompts/README.md)
173
-
174
- * [list](docs/sdks/prompts/README.md#list) - List all prompts
175
- * [create](docs/sdks/prompts/README.md#create) - Create a prompt
176
- * [retrieve](docs/sdks/prompts/README.md#retrieve) - Retrieve a prompt
177
- * [update](docs/sdks/prompts/README.md#update) - Update a prompt
178
- * [delete](docs/sdks/prompts/README.md#delete) - Delete a prompt
179
- * [listVersions](docs/sdks/prompts/README.md#listversions) - List all prompt versions
180
- * [getVersion](docs/sdks/prompts/README.md#getversion) - Retrieve a prompt version
181
-
182
- ### [remoteconfigs](docs/sdks/remoteconfigs/README.md)
183
-
184
- * [retrieve](docs/sdks/remoteconfigs/README.md#retrieve) - Retrieve a remote config
185
-
186
- </details>
187
- <!-- End Available Resources and Operations [operations] -->
188
-
189
- <!-- Start Standalone functions [standalone-funcs] -->
190
- ## Standalone functions
191
-
192
- All the methods listed above are available as standalone functions. These
193
- functions are ideal for use in applications running in the browser, serverless
194
- runtimes or other environments where application bundle size is a primary
195
- concern. When using a bundler to build your application, all unused
196
- functionality will be either excluded from the final bundle or tree-shaken away.
197
-
198
- To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
199
-
200
- <details>
201
-
202
- <summary>Available standalone functions</summary>
203
-
204
- - [`contactsCreate`](docs/sdks/contacts/README.md#create) - Update user information
205
- - [`deploymentsGetConfig`](docs/sdks/deployments/README.md#getconfig) - Get config
206
- - [`deploymentsInvoke`](docs/sdks/deployments/README.md#invoke) - Invoke
207
- - [`deploymentsList`](docs/sdks/deployments/README.md#list) - List all deployments
208
- - [`deploymentsMetricsCreate`](docs/sdks/metrics/README.md#create) - Add metrics
209
- - [`feedbackCreate`](docs/sdks/feedback/README.md#create) - Submit feedback
210
- - [`filesCreate`](docs/sdks/files/README.md#create) - Create file
211
- - [`filesDelete`](docs/sdks/files/README.md#delete) - Delete file
212
- - [`filesGet`](docs/sdks/files/README.md#get) - Retrieve a file
213
- - [`filesList`](docs/sdks/files/README.md#list) - List all files
214
- - [`promptsCreate`](docs/sdks/prompts/README.md#create) - Create a prompt
215
- - [`promptsDelete`](docs/sdks/prompts/README.md#delete) - Delete a prompt
216
- - [`promptsGetVersion`](docs/sdks/prompts/README.md#getversion) - Retrieve a prompt version
217
- - [`promptsList`](docs/sdks/prompts/README.md#list) - List all prompts
218
- - [`promptsListVersions`](docs/sdks/prompts/README.md#listversions) - List all prompt versions
219
- - [`promptsRetrieve`](docs/sdks/prompts/README.md#retrieve) - Retrieve a prompt
220
- - [`promptsUpdate`](docs/sdks/prompts/README.md#update) - Update a prompt
221
- - [`remoteconfigsRetrieve`](docs/sdks/remoteconfigs/README.md#retrieve) - Retrieve a remote config
222
-
223
- </details>
224
- <!-- End Standalone functions [standalone-funcs] -->
225
-
226
- <!-- Start File uploads [file-upload] -->
227
- ## File uploads
228
-
229
- Certain SDK methods accept files as part of a multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
230
-
231
- > [!TIP]
232
- >
233
- > Depending on your JavaScript runtime, there are convenient utilities that return a handle to a file without reading the entire contents into memory:
234
- >
235
- > - **Node.js v20+:** Since v20, Node.js comes with a native `openAsBlob` function in [`node:fs`](https://nodejs.org/docs/latest-v20.x/api/fs.html#fsopenasblobpath-options).
236
- > - **Bun:** The native [`Bun.file`](https://bun.sh/docs/api/file-io#reading-files-bun-file) function produces a file handle that can be used for streaming file uploads.
237
- > - **Browsers:** All supported browsers return an instance to a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) when reading the value from an `<input type="file">` element.
238
- > - **Node.js v18:** A file stream can be created using the `fileFrom` helper from [`fetch-blob/from.js`](https://www.npmjs.com/package/fetch-blob).
239
-
240
- ```typescript
241
- import { Orq } from "@orq-ai/node";
242
-
243
- const orq = new Orq({
244
- apiKey: process.env["ORQ_API_KEY"] ?? "",
245
- });
246
-
247
- async function run() {
248
- const result = await orq.files.create();
249
-
250
- // Handle the result
251
- console.log(result);
252
- }
253
-
254
- run();
255
-
256
- ```
257
- <!-- End File uploads [file-upload] -->
258
-
259
- <!-- Start Retries [retries] -->
260
- ## Retries
261
-
262
- Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
263
-
264
- To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
265
- ```typescript
266
- import { Orq } from "@orq-ai/node";
267
-
268
- const orq = new Orq({
269
- apiKey: process.env["ORQ_API_KEY"] ?? "",
270
- });
271
-
272
- async function run() {
273
- const result = await orq.contacts.create({
274
- externalId: "<id>",
275
- }, {
276
- retries: {
277
- strategy: "backoff",
278
- backoff: {
279
- initialInterval: 1,
280
- maxInterval: 50,
281
- exponent: 1.1,
282
- maxElapsedTime: 100,
283
- },
284
- retryConnectionErrors: false,
285
- },
286
- });
287
-
288
- // Handle the result
289
- console.log(result);
290
- }
291
-
292
- run();
293
-
294
- ```
295
-
296
- If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
297
- ```typescript
298
- import { Orq } from "@orq-ai/node";
299
-
300
- const orq = new Orq({
301
- retryConfig: {
302
- strategy: "backoff",
303
- backoff: {
304
- initialInterval: 1,
305
- maxInterval: 50,
306
- exponent: 1.1,
307
- maxElapsedTime: 100,
308
- },
309
- retryConnectionErrors: false,
310
- },
311
- apiKey: process.env["ORQ_API_KEY"] ?? "",
312
- });
313
-
314
- async function run() {
315
- const result = await orq.contacts.create({
316
- externalId: "<id>",
317
- });
318
-
319
- // Handle the result
320
- console.log(result);
321
- }
322
-
323
- run();
324
-
325
- ```
326
- <!-- End Retries [retries] -->
327
-
328
- <!-- Start Error Handling [errors] -->
329
- ## Error Handling
330
-
331
- Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `list` method may throw the following errors:
332
-
333
- | Error Type | Status Code | Content Type |
334
- | ------------------- | ----------- | ---------------- |
335
- | errors.HonoApiError | 500 | application/json |
336
- | errors.APIError | 4XX, 5XX | \*/\* |
337
-
338
- If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
339
-
340
- ```typescript
341
- import { Orq } from "@orq-ai/node";
342
- import { HonoApiError, SDKValidationError } from "@orq-ai/node/models/errors";
343
-
344
- const orq = new Orq({
345
- apiKey: process.env["ORQ_API_KEY"] ?? "",
346
- });
347
-
348
- async function run() {
349
- let result;
350
- try {
351
- result = await orq.deployments.list({});
352
-
353
- // Handle the result
354
- console.log(result);
355
- } catch (err) {
356
- switch (true) {
357
- // The server response does not match the expected SDK schema
358
- case (err instanceof SDKValidationError): {
359
- // Pretty-print will provide a human-readable multi-line error message
360
- console.error(err.pretty());
361
- // Raw value may also be inspected
362
- console.error(err.rawValue);
363
- return;
364
- }
365
- case (err instanceof HonoApiError): {
366
- // Handle err.data$: HonoApiErrorData
367
- console.error(err);
368
- return;
369
- }
370
- default: {
371
- // Other errors such as network errors, see HTTPClientErrors for more details
372
- throw err;
373
- }
374
- }
375
- }
376
- }
377
-
378
- run();
379
-
380
- ```
381
-
382
- Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
383
-
384
- In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
385
-
386
- | HTTP Client Error | Description |
387
- | ---------------------------------------------------- | ---------------------------------------------------- |
388
- | RequestAbortedError | HTTP request was aborted by the client |
389
- | RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
390
- | ConnectionError | HTTP client was unable to make a request to a server |
391
- | InvalidRequestError | Any input used to create a request is invalid |
392
- | UnexpectedClientError | Unrecognised or unexpected error |
393
- <!-- End Error Handling [errors] -->
394
-
395
- <!-- Start Server Selection [server] -->
396
- ## Server Selection
397
-
398
- ### Override Server URL Per-Client
399
-
400
- The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:
401
- ```typescript
402
- import { Orq } from "@orq-ai/node";
403
-
404
- const orq = new Orq({
405
- serverURL: "https://my.orq.ai",
406
- apiKey: process.env["ORQ_API_KEY"] ?? "",
407
- });
408
-
409
- async function run() {
410
- const result = await orq.contacts.create({
411
- externalId: "<id>",
412
- });
413
-
414
- // Handle the result
415
- console.log(result);
416
- }
417
-
418
- run();
419
-
420
- ```
421
- <!-- End Server Selection [server] -->
422
-
423
- <!-- Start Custom HTTP Client [http-client] -->
424
- ## Custom HTTP Client
425
-
426
- The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
427
- [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
428
- client is a thin wrapper around `fetch` and provides the ability to attach hooks
429
- around the request lifecycle that can be used to modify the request or handle
430
- errors and response.
431
-
432
- The `HTTPClient` constructor takes an optional `fetcher` argument that can be
433
- used to integrate a third-party HTTP client or when writing tests to mock out
434
- the HTTP client and feed in fixtures.
435
-
436
- The following example shows how to use the `"beforeRequest"` hook to to add a
437
- custom header and a timeout to requests and how to use the `"requestError"` hook
438
- to log errors:
439
-
440
- ```typescript
441
- import { Orq } from "@orq-ai/node";
442
- import { HTTPClient } from "@orq-ai/node/lib/http";
443
-
444
- const httpClient = new HTTPClient({
445
- // fetcher takes a function that has the same signature as native `fetch`.
446
- fetcher: (request) => {
447
- return fetch(request);
448
- }
449
- });
450
-
451
- httpClient.addHook("beforeRequest", (request) => {
452
- const nextRequest = new Request(request, {
453
- signal: request.signal || AbortSignal.timeout(5000)
454
- });
455
-
456
- nextRequest.headers.set("x-custom-header", "custom value");
457
-
458
- return nextRequest;
459
- });
460
-
461
- httpClient.addHook("requestError", (error, request) => {
462
- console.group("Request Error");
463
- console.log("Reason:", `${error}`);
464
- console.log("Endpoint:", `${request.method} ${request.url}`);
465
- console.groupEnd();
466
- });
467
-
468
- const sdk = new Orq({ httpClient });
469
- ```
470
- <!-- End Custom HTTP Client [http-client] -->
471
-
472
- <!-- Start Debugging [debug] -->
473
- ## Debugging
474
-
475
- You can setup your SDK to emit debug logs for SDK requests and responses.
476
-
477
- You can pass a logger that matches `console`'s interface as an SDK option.
478
-
479
- > [!WARNING]
480
- > Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
481
-
482
- ```typescript
483
- import { Orq } from "@orq-ai/node";
484
-
485
- const sdk = new Orq({ debugLogger: console });
486
- ```
487
-
488
- You can also enable a default debug logger by setting an environment variable `ORQ_DEBUG` to true.
489
- <!-- End Debugging [debug] -->
490
-
491
- <!-- Placeholder for Future Speakeasy SDK Sections -->
492
-
493
- # Development
494
-
495
- ## Maturity
496
-
497
- This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
498
- to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
499
- looking for the latest version.
500
-
501
- ## Contributions
502
-
503
- While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
504
- We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
505
-
506
- ### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=@orq-ai/node&utm_campaign=typescript)
@@ -1,48 +0,0 @@
1
- # Supported JavaScript runtimes
2
-
3
- This SDK is intended to be used in JavaScript runtimes that support ECMAScript 2020 or newer. The SDK uses the following features:
4
-
5
- * [Web Fetch API][web-fetch]
6
- * [Web Streams API][web-streams] and in particular `ReadableStream`
7
- * [Async iterables][async-iter] using `Symbol.asyncIterator`
8
-
9
- [web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
10
- [web-streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
11
- [async-iter]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
12
-
13
- Runtime environments that are explicitly supported are:
14
-
15
- - Evergreen browsers which include: Chrome, Safari, Edge, Firefox
16
- - Node.js active and maintenance LTS releases
17
- - Currently, this is v18 and v20
18
- - Bun v1 and above
19
- - Deno v1.39
20
- - Note that Deno does not currently have native support for streaming file uploads backed by the filesystem ([issue link][deno-file-streaming])
21
-
22
- [deno-file-streaming]: https://github.com/denoland/deno/issues/11018
23
-
24
- ## Recommended TypeScript compiler options
25
-
26
- The following `tsconfig.json` options are recommended for projects using this
27
- SDK in order to get static type support for features like async iterables,
28
- streams and `fetch`-related APIs ([`for await...of`][for-await-of],
29
- [`AbortSignal`][abort-signal], [`Request`][request], [`Response`][response] and
30
- so on):
31
-
32
- [for-await-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
33
- [abort-signal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
34
- [request]: https://developer.mozilla.org/en-US/docs/Web/API/Request
35
- [response]: https://developer.mozilla.org/en-US/docs/Web/API/Response
36
-
37
- ```jsonc
38
- {
39
- "compilerOptions": {
40
- "target": "es2020", // or higher
41
- "lib": ["es2020", "dom", "dom.iterable"],
42
- }
43
- }
44
- ```
45
-
46
- While `target` can be set to older ECMAScript versions, it may result in extra,
47
- unnecessary compatibility code being generated if you are not targeting old
48
- runtimes.
@@ -1,84 +0,0 @@
1
- # Contacts
2
- (*contacts*)
3
-
4
- ## Overview
5
-
6
- ### Available Operations
7
-
8
- * [create](#create) - Update user information
9
-
10
- ## create
11
-
12
- Update or add user information to workspace
13
-
14
- ### Example Usage
15
-
16
- ```typescript
17
- import { Orq } from "@orq-ai/node";
18
-
19
- const orq = new Orq({
20
- apiKey: process.env["ORQ_API_KEY"] ?? "",
21
- });
22
-
23
- async function run() {
24
- const result = await orq.contacts.create({
25
- externalId: "<id>",
26
- });
27
-
28
- // Handle the result
29
- console.log(result);
30
- }
31
-
32
- run();
33
- ```
34
-
35
- ### Standalone function
36
-
37
- The standalone function version of this method:
38
-
39
- ```typescript
40
- import { OrqCore } from "@orq-ai/node/core.js";
41
- import { contactsCreate } from "@orq-ai/node/funcs/contactsCreate.js";
42
-
43
- // Use `OrqCore` for best tree-shaking performance.
44
- // You can create one instance of it to use across an application.
45
- const orq = new OrqCore({
46
- apiKey: process.env["ORQ_API_KEY"] ?? "",
47
- });
48
-
49
- async function run() {
50
- const res = await contactsCreate(orq, {
51
- externalId: "<id>",
52
- });
53
-
54
- if (!res.ok) {
55
- throw res.error;
56
- }
57
-
58
- const { value: result } = res;
59
-
60
- // Handle the result
61
- console.log(result);
62
- }
63
-
64
- run();
65
- ```
66
-
67
- ### Parameters
68
-
69
- | Parameter | Type | Required | Description |
70
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
71
- | `request` | [operations.CreateContactRequestBody](../../models/operations/createcontactrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
72
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
73
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
74
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
75
-
76
- ### Response
77
-
78
- **Promise\<[operations.CreateContactResponseBody](../../models/operations/createcontactresponsebody.md)\>**
79
-
80
- ### Errors
81
-
82
- | Error Type | Status Code | Content Type |
83
- | --------------- | --------------- | --------------- |
84
- | errors.APIError | 4XX, 5XX | \*/\* |