@orq-ai/node 3.1.6 → 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 (165) 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 +2 -2
  5. package/lib/config.js +2 -2
  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 +2 -2
  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 -559
  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 -316
  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/promptsnippets/README.md +0 -534
  54. package/packages/orq-rc/docs/sdks/remoteconfig/README.md +0 -80
  55. package/packages/orq-rc/jsr.json +0 -28
  56. package/packages/orq-rc/package-lock.json +0 -1861
  57. package/packages/orq-rc/package.json +0 -31
  58. package/packages/orq-rc/src/core.ts +0 -13
  59. package/packages/orq-rc/src/funcs/contactsCreate.ts +0 -126
  60. package/packages/orq-rc/src/funcs/deploymentsGetConfig.ts +0 -134
  61. package/packages/orq-rc/src/funcs/deploymentsInvoke.ts +0 -142
  62. package/packages/orq-rc/src/funcs/deploymentsList.ts +0 -141
  63. package/packages/orq-rc/src/funcs/deploymentsMetricsCreate.ts +0 -134
  64. package/packages/orq-rc/src/funcs/deploymentsStream.ts +0 -150
  65. package/packages/orq-rc/src/funcs/feedbackCreate.ts +0 -126
  66. package/packages/orq-rc/src/funcs/filesDelete.ts +0 -130
  67. package/packages/orq-rc/src/funcs/filesGet.ts +0 -129
  68. package/packages/orq-rc/src/funcs/filesList.ts +0 -131
  69. package/packages/orq-rc/src/funcs/filesUpload.ts +0 -149
  70. package/packages/orq-rc/src/funcs/promptSnippetsCreate.ts +0 -128
  71. package/packages/orq-rc/src/funcs/promptSnippetsDelete.ts +0 -131
  72. package/packages/orq-rc/src/funcs/promptSnippetsGet.ts +0 -130
  73. package/packages/orq-rc/src/funcs/promptSnippetsGetByKey.ts +0 -132
  74. package/packages/orq-rc/src/funcs/promptSnippetsList.ts +0 -132
  75. package/packages/orq-rc/src/funcs/promptSnippetsUpdate.ts +0 -139
  76. package/packages/orq-rc/src/funcs/promptsCreate.ts +0 -126
  77. package/packages/orq-rc/src/funcs/promptsDelete.ts +0 -130
  78. package/packages/orq-rc/src/funcs/promptsGetVersion.ts +0 -146
  79. package/packages/orq-rc/src/funcs/promptsList.ts +0 -133
  80. package/packages/orq-rc/src/funcs/promptsListVersions.ts +0 -139
  81. package/packages/orq-rc/src/funcs/promptsRetrieve.ts +0 -132
  82. package/packages/orq-rc/src/funcs/promptsUpdate.ts +0 -138
  83. package/packages/orq-rc/src/funcs/remoteconfigGetConfig.ts +0 -127
  84. package/packages/orq-rc/src/hooks/global.ts +0 -44
  85. package/packages/orq-rc/src/hooks/hooks.ts +0 -132
  86. package/packages/orq-rc/src/hooks/index.ts +0 -6
  87. package/packages/orq-rc/src/hooks/registration.ts +0 -15
  88. package/packages/orq-rc/src/hooks/types.ts +0 -109
  89. package/packages/orq-rc/src/index.ts +0 -7
  90. package/packages/orq-rc/src/lib/base64.ts +0 -37
  91. package/packages/orq-rc/src/lib/config.ts +0 -70
  92. package/packages/orq-rc/src/lib/dlv.ts +0 -53
  93. package/packages/orq-rc/src/lib/encodings.ts +0 -483
  94. package/packages/orq-rc/src/lib/env.ts +0 -73
  95. package/packages/orq-rc/src/lib/event-streams.ts +0 -264
  96. package/packages/orq-rc/src/lib/files.ts +0 -40
  97. package/packages/orq-rc/src/lib/http.ts +0 -323
  98. package/packages/orq-rc/src/lib/is-plain-object.ts +0 -43
  99. package/packages/orq-rc/src/lib/logger.ts +0 -9
  100. package/packages/orq-rc/src/lib/matchers.ts +0 -325
  101. package/packages/orq-rc/src/lib/primitives.ts +0 -136
  102. package/packages/orq-rc/src/lib/retries.ts +0 -218
  103. package/packages/orq-rc/src/lib/schemas.ts +0 -91
  104. package/packages/orq-rc/src/lib/sdks.ts +0 -400
  105. package/packages/orq-rc/src/lib/security.ts +0 -254
  106. package/packages/orq-rc/src/lib/url.ts +0 -33
  107. package/packages/orq-rc/src/models/components/deployments.ts +0 -1666
  108. package/packages/orq-rc/src/models/components/index.ts +0 -6
  109. package/packages/orq-rc/src/models/components/security.ts +0 -71
  110. package/packages/orq-rc/src/models/errors/apierror.ts +0 -27
  111. package/packages/orq-rc/src/models/errors/getpromptversion.ts +0 -71
  112. package/packages/orq-rc/src/models/errors/honoapierror.ts +0 -82
  113. package/packages/orq-rc/src/models/errors/httpclienterrors.ts +0 -62
  114. package/packages/orq-rc/src/models/errors/index.ts +0 -11
  115. package/packages/orq-rc/src/models/errors/sdkvalidationerror.ts +0 -97
  116. package/packages/orq-rc/src/models/errors/updateprompt.ts +0 -71
  117. package/packages/orq-rc/src/models/errors/updatepromptsnippet.ts +0 -71
  118. package/packages/orq-rc/src/models/operations/createcontact.ts +0 -256
  119. package/packages/orq-rc/src/models/operations/createfeedback.ts +0 -286
  120. package/packages/orq-rc/src/models/operations/createprompt.ts +0 -3819
  121. package/packages/orq-rc/src/models/operations/createpromptsnippet.ts +0 -6239
  122. package/packages/orq-rc/src/models/operations/deleteprompt.ts +0 -69
  123. package/packages/orq-rc/src/models/operations/deletepromptsnippet.ts +0 -69
  124. package/packages/orq-rc/src/models/operations/deploymentcreatemetric.ts +0 -1790
  125. package/packages/orq-rc/src/models/operations/deploymentgetconfig.ts +0 -3527
  126. package/packages/orq-rc/src/models/operations/deploymentinvoke.ts +0 -1144
  127. package/packages/orq-rc/src/models/operations/deployments.ts +0 -2148
  128. package/packages/orq-rc/src/models/operations/deploymentstream.ts +0 -3062
  129. package/packages/orq-rc/src/models/operations/filedelete.ts +0 -78
  130. package/packages/orq-rc/src/models/operations/fileget.ts +0 -222
  131. package/packages/orq-rc/src/models/operations/filelist.ts +0 -321
  132. package/packages/orq-rc/src/models/operations/fileupload.ts +0 -322
  133. package/packages/orq-rc/src/models/operations/findonebykeypromptsnippet.ts +0 -4483
  134. package/packages/orq-rc/src/models/operations/findonepromptsnippet.ts +0 -4343
  135. package/packages/orq-rc/src/models/operations/getallprompts.ts +0 -2116
  136. package/packages/orq-rc/src/models/operations/getallpromptsnippets.ts +0 -4472
  137. package/packages/orq-rc/src/models/operations/getoneprompt.ts +0 -1982
  138. package/packages/orq-rc/src/models/operations/getpromptversion.ts +0 -2012
  139. package/packages/orq-rc/src/models/operations/index.ts +0 -29
  140. package/packages/orq-rc/src/models/operations/listpromptversions.ts +0 -2146
  141. package/packages/orq-rc/src/models/operations/remoteconfigsgetconfig.ts +0 -190
  142. package/packages/orq-rc/src/models/operations/updateprompt.ts +0 -3917
  143. package/packages/orq-rc/src/models/operations/updatepromptsnippet.ts +0 -6544
  144. package/packages/orq-rc/src/sdk/contacts.ts +0 -27
  145. package/packages/orq-rc/src/sdk/deployments.ts +0 -89
  146. package/packages/orq-rc/src/sdk/feedback.ts +0 -27
  147. package/packages/orq-rc/src/sdk/files.ts +0 -72
  148. package/packages/orq-rc/src/sdk/index.ts +0 -5
  149. package/packages/orq-rc/src/sdk/metrics.ts +0 -27
  150. package/packages/orq-rc/src/sdk/prompts.ts +0 -126
  151. package/packages/orq-rc/src/sdk/promptsnippets.ts +0 -99
  152. package/packages/orq-rc/src/sdk/remoteconfig.ts +0 -24
  153. package/packages/orq-rc/src/sdk/sdk.ts +0 -49
  154. package/packages/orq-rc/src/types/blobs.ts +0 -31
  155. package/packages/orq-rc/src/types/constdatetime.ts +0 -15
  156. package/packages/orq-rc/src/types/enums.ts +0 -16
  157. package/packages/orq-rc/src/types/fp.ts +0 -50
  158. package/packages/orq-rc/src/types/index.ts +0 -11
  159. package/packages/orq-rc/src/types/operations.ts +0 -105
  160. package/packages/orq-rc/src/types/rfcdate.ts +0 -54
  161. package/packages/orq-rc/src/types/streams.ts +0 -21
  162. package/packages/orq-rc/tsconfig.json +0 -41
  163. package/src/funcs/deploymentsStream.ts +0 -151
  164. package/src/lib/event-streams.ts +0 -264
  165. package/src/models/operations/deploymentstream.ts +0 -3062
@@ -1,483 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- import { bytesToBase64 } from "./base64.js";
6
- import { isPlainObject } from "./is-plain-object.js";
7
-
8
- export class EncodingError extends Error {
9
- constructor(message: string) {
10
- super(message);
11
- this.name = "EncodingError";
12
- }
13
- }
14
-
15
- export function encodeMatrix(
16
- key: string,
17
- value: unknown,
18
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
19
- ): string | undefined {
20
- let out = "";
21
- const pairs: [string, unknown][] = options?.explode
22
- ? explode(key, value)
23
- : [[key, value]];
24
-
25
- if (pairs.every(([_, v]) => v == null)) {
26
- return;
27
- }
28
-
29
- const encodeString = (v: string) => {
30
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
31
- };
32
- const encodeValue = (v: unknown) => encodeString(serializeValue(v));
33
-
34
- pairs.forEach(([pk, pv]) => {
35
- let tmp = "";
36
- let encValue: string | null | undefined = null;
37
-
38
- if (pv == null) {
39
- return;
40
- } else if (Array.isArray(pv)) {
41
- encValue = mapDefined(pv, (v) => `${encodeValue(v)}`)?.join(",");
42
- } else if (isPlainObject(pv)) {
43
- const mapped = mapDefinedEntries(Object.entries(pv), ([k, v]) => {
44
- return `,${encodeString(k)},${encodeValue(v)}`;
45
- });
46
- encValue = mapped?.join("").slice(1);
47
- } else {
48
- encValue = `${encodeValue(pv)}`;
49
- }
50
-
51
- if (encValue == null) {
52
- return;
53
- }
54
-
55
- const keyPrefix = encodeString(pk);
56
- tmp = `${keyPrefix}=${encValue}`;
57
- // trim trailing '=' if value was empty
58
- if (tmp === `${keyPrefix}=`) {
59
- tmp = tmp.slice(0, -1);
60
- }
61
-
62
- // If we end up with the nothing then skip forward
63
- if (!tmp) {
64
- return;
65
- }
66
-
67
- out += `;${tmp}`;
68
- });
69
-
70
- return out;
71
- }
72
-
73
- export function encodeLabel(
74
- key: string,
75
- value: unknown,
76
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
77
- ): string | undefined {
78
- let out = "";
79
- const pairs: [string, unknown][] = options?.explode
80
- ? explode(key, value)
81
- : [[key, value]];
82
-
83
- if (pairs.every(([_, v]) => v == null)) {
84
- return;
85
- }
86
-
87
- const encodeString = (v: string) => {
88
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
89
- };
90
- const encodeValue = (v: unknown) => encodeString(serializeValue(v));
91
-
92
- pairs.forEach(([pk, pv]) => {
93
- let encValue: string | null | undefined = "";
94
-
95
- if (pv == null) {
96
- return;
97
- } else if (Array.isArray(pv)) {
98
- encValue = mapDefined(pv, (v) => `${encodeValue(v)}`)?.join(".");
99
- } else if (isPlainObject(pv)) {
100
- const mapped = mapDefinedEntries(Object.entries(pv), ([k, v]) => {
101
- return `.${encodeString(k)}.${encodeValue(v)}`;
102
- });
103
- encValue = mapped?.join("").slice(1);
104
- } else {
105
- const k =
106
- options?.explode && isPlainObject(value) ? `${encodeString(pk)}=` : "";
107
- encValue = `${k}${encodeValue(pv)}`;
108
- }
109
-
110
- out += encValue == null ? "" : `.${encValue}`;
111
- });
112
-
113
- return out;
114
- }
115
-
116
- type FormEncoder = (
117
- key: string,
118
- value: unknown,
119
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
120
- ) => string | undefined;
121
-
122
- function formEncoder(sep: string): FormEncoder {
123
- return (
124
- key: string,
125
- value: unknown,
126
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
127
- ) => {
128
- let out = "";
129
- const pairs: [string, unknown][] = options?.explode
130
- ? explode(key, value)
131
- : [[key, value]];
132
-
133
- if (pairs.every(([_, v]) => v == null)) {
134
- return;
135
- }
136
-
137
- const encodeString = (v: string) => {
138
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
139
- };
140
-
141
- const encodeValue = (v: unknown) => encodeString(serializeValue(v));
142
-
143
- const encodedSep = encodeString(sep);
144
-
145
- pairs.forEach(([pk, pv]) => {
146
- let tmp = "";
147
- let encValue: string | null | undefined = null;
148
-
149
- if (pv == null) {
150
- return;
151
- } else if (Array.isArray(pv)) {
152
- encValue = mapDefined(pv, (v) => `${encodeValue(v)}`)?.join(encodedSep);
153
- } else if (isPlainObject(pv)) {
154
- encValue = mapDefinedEntries(Object.entries(pv), ([k, v]) => {
155
- return `${encodeString(k)}${encodedSep}${encodeValue(v)}`;
156
- })?.join(encodedSep);
157
- } else {
158
- encValue = `${encodeValue(pv)}`;
159
- }
160
-
161
- if (encValue == null) {
162
- return;
163
- }
164
-
165
- tmp = `${encodeString(pk)}=${encValue}`;
166
-
167
- // If we end up with the nothing then skip forward
168
- if (!tmp || tmp === "=") {
169
- return;
170
- }
171
-
172
- out += `&${tmp}`;
173
- });
174
-
175
- return out.slice(1);
176
- };
177
- }
178
-
179
- export const encodeForm = formEncoder(",");
180
- export const encodeSpaceDelimited = formEncoder(" ");
181
- export const encodePipeDelimited = formEncoder("|");
182
-
183
- export function encodeBodyForm(
184
- key: string,
185
- value: unknown,
186
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
187
- ): string {
188
- let out = "";
189
- const pairs: [string, unknown][] = options?.explode
190
- ? explode(key, value)
191
- : [[key, value]];
192
-
193
- const encodeString = (v: string) => {
194
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
195
- };
196
-
197
- const encodeValue = (v: unknown) => encodeString(serializeValue(v));
198
-
199
- pairs.forEach(([pk, pv]) => {
200
- let tmp = "";
201
- let encValue = "";
202
-
203
- if (pv == null) {
204
- return;
205
- } else if (Array.isArray(pv)) {
206
- encValue = JSON.stringify(pv, jsonReplacer);
207
- } else if (isPlainObject(pv)) {
208
- encValue = JSON.stringify(pv, jsonReplacer);
209
- } else {
210
- encValue = `${encodeValue(pv)}`;
211
- }
212
-
213
- tmp = `${encodeString(pk)}=${encValue}`;
214
-
215
- // If we end up with the nothing then skip forward
216
- if (!tmp || tmp === "=") {
217
- return;
218
- }
219
-
220
- out += `&${tmp}`;
221
- });
222
-
223
- return out.slice(1);
224
- }
225
-
226
- export function encodeDeepObject(
227
- key: string,
228
- value: unknown,
229
- options?: { charEncoding?: "percent" | "none" },
230
- ): string | undefined {
231
- if (value == null) {
232
- return;
233
- }
234
-
235
- if (!isPlainObject(value)) {
236
- throw new EncodingError(
237
- `Value of parameter '${key}' which uses deepObject encoding must be an object or null`,
238
- );
239
- }
240
-
241
- return encodeDeepObjectObject(key, value, options);
242
- }
243
-
244
- export function encodeDeepObjectObject(
245
- key: string,
246
- value: unknown,
247
- options?: { charEncoding?: "percent" | "none" },
248
- ): string | undefined {
249
- if (value == null) {
250
- return;
251
- }
252
-
253
- let out = "";
254
-
255
- const encodeString = (v: string) => {
256
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
257
- };
258
-
259
- if (!isPlainObject(value)) {
260
- throw new EncodingError(`Expected parameter '${key}' to be an object.`);
261
- }
262
-
263
- Object.entries(value).forEach(([ck, cv]) => {
264
- if (cv == null) {
265
- return;
266
- }
267
-
268
- const pk = `${key}[${ck}]`;
269
-
270
- if (isPlainObject(cv)) {
271
- const objOut = encodeDeepObjectObject(pk, cv, options);
272
-
273
- out += objOut == null ? "" : `&${objOut}`;
274
-
275
- return;
276
- }
277
-
278
- const pairs: unknown[] = Array.isArray(cv) ? cv : [cv];
279
- const encoded = mapDefined(pairs, (v) => {
280
- return `${encodeString(pk)}=${encodeString(serializeValue(v))}`;
281
- })?.join("&");
282
-
283
- out += encoded == null ? "" : `&${encoded}`;
284
- });
285
-
286
- return out.slice(1);
287
- }
288
-
289
- export function encodeJSON(
290
- key: string,
291
- value: unknown,
292
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
293
- ): string | undefined {
294
- if (typeof value === "undefined") {
295
- return;
296
- }
297
-
298
- const encodeString = (v: string) => {
299
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
300
- };
301
-
302
- const encVal = encodeString(JSON.stringify(value, jsonReplacer));
303
-
304
- return options?.explode ? encVal : `${encodeString(key)}=${encVal}`;
305
- }
306
-
307
- export const encodeSimple = (
308
- key: string,
309
- value: unknown,
310
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
311
- ): string | undefined => {
312
- let out = "";
313
- const pairs: [string, unknown][] = options?.explode
314
- ? explode(key, value)
315
- : [[key, value]];
316
-
317
- if (pairs.every(([_, v]) => v == null)) {
318
- return;
319
- }
320
-
321
- const encodeString = (v: string) => {
322
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
323
- };
324
- const encodeValue = (v: unknown) => encodeString(serializeValue(v));
325
-
326
- pairs.forEach(([pk, pv]) => {
327
- let tmp: string | null | undefined = "";
328
-
329
- if (pv == null) {
330
- return;
331
- } else if (Array.isArray(pv)) {
332
- tmp = mapDefined(pv, (v) => `${encodeValue(v)}`)?.join(",");
333
- } else if (isPlainObject(pv)) {
334
- const mapped = mapDefinedEntries(Object.entries(pv), ([k, v]) => {
335
- return `,${encodeString(k)},${encodeValue(v)}`;
336
- });
337
- tmp = mapped?.join("").slice(1);
338
- } else {
339
- const k = options?.explode && isPlainObject(value) ? `${pk}=` : "";
340
- tmp = `${k}${encodeValue(pv)}`;
341
- }
342
-
343
- out += tmp ? `,${tmp}` : "";
344
- });
345
-
346
- return out.slice(1);
347
- };
348
-
349
- function explode(key: string, value: unknown): [string, unknown][] {
350
- if (Array.isArray(value)) {
351
- return value.map((v) => [key, v]);
352
- } else if (isPlainObject(value)) {
353
- const o = value ?? {};
354
- return Object.entries(o).map(([k, v]) => [k, v]);
355
- } else {
356
- return [[key, value]];
357
- }
358
- }
359
-
360
- function serializeValue(value: unknown): string {
361
- if (value == null) {
362
- return "";
363
- } else if (value instanceof Date) {
364
- return value.toISOString();
365
- } else if (value instanceof Uint8Array) {
366
- return bytesToBase64(value);
367
- } else if (typeof value === "object") {
368
- return JSON.stringify(value, jsonReplacer);
369
- }
370
-
371
- return `${value}`;
372
- }
373
-
374
- function jsonReplacer(_: string, value: unknown): unknown {
375
- if (value instanceof Uint8Array) {
376
- return bytesToBase64(value);
377
- } else {
378
- return value;
379
- }
380
- }
381
-
382
- function mapDefined<T, R>(inp: T[], mapper: (v: T) => R): R[] | null {
383
- const res = inp.reduce<R[]>((acc, v) => {
384
- if (v == null) {
385
- return acc;
386
- }
387
-
388
- const m = mapper(v);
389
- if (m == null) {
390
- return acc;
391
- }
392
-
393
- acc.push(m);
394
-
395
- return acc;
396
- }, []);
397
-
398
- return res.length ? res : null;
399
- }
400
-
401
- function mapDefinedEntries<K, V, R>(
402
- inp: Iterable<[K, V]>,
403
- mapper: (v: [K, V]) => R,
404
- ): R[] | null {
405
- const acc: R[] = [];
406
- for (const [k, v] of inp) {
407
- if (v == null) {
408
- continue;
409
- }
410
-
411
- const m = mapper([k, v]);
412
- if (m == null) {
413
- continue;
414
- }
415
-
416
- acc.push(m);
417
- }
418
-
419
- return acc.length ? acc : null;
420
- }
421
-
422
- export function queryJoin(...args: (string | undefined)[]): string {
423
- return args.filter(Boolean).join("&");
424
- }
425
-
426
- type QueryEncoderOptions = {
427
- explode?: boolean;
428
- charEncoding?: "percent" | "none";
429
- };
430
-
431
- type QueryEncoder = (
432
- key: string,
433
- value: unknown,
434
- options?: QueryEncoderOptions,
435
- ) => string | undefined;
436
-
437
- type BulkQueryEncoder = (
438
- values: Record<string, unknown>,
439
- options?: QueryEncoderOptions,
440
- ) => string;
441
-
442
- export function queryEncoder(f: QueryEncoder): BulkQueryEncoder {
443
- const bulkEncode = function (
444
- values: Record<string, unknown>,
445
- options?: QueryEncoderOptions,
446
- ): string {
447
- const opts: QueryEncoderOptions = {
448
- ...options,
449
- explode: options?.explode ?? true,
450
- charEncoding: options?.charEncoding ?? "percent",
451
- };
452
-
453
- const encoded = Object.entries(values).map(([key, value]) => {
454
- return f(key, value, opts);
455
- });
456
- return queryJoin(...encoded);
457
- };
458
-
459
- return bulkEncode;
460
- }
461
-
462
- export const encodeJSONQuery = queryEncoder(encodeJSON);
463
- export const encodeFormQuery = queryEncoder(encodeForm);
464
- export const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited);
465
- export const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited);
466
- export const encodeDeepObjectQuery = queryEncoder(encodeDeepObject);
467
-
468
- export function appendForm(
469
- fd: FormData,
470
- key: string,
471
- value: unknown,
472
- fileName?: string,
473
- ): void {
474
- if (value == null) {
475
- return;
476
- } else if (value instanceof Blob && fileName) {
477
- fd.append(key, value, fileName);
478
- } else if (value instanceof Blob) {
479
- fd.append(key, value);
480
- } else {
481
- fd.append(key, String(value));
482
- }
483
- }
@@ -1,73 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- import { dlv } from "./dlv.js";
6
-
7
- import * as z from "zod";
8
- import { SDKOptions } from "./config.js";
9
-
10
- export interface Env {
11
- ORQ_API_KEY?: string | undefined;
12
-
13
- /**
14
- * Sets the contactId parameter for all supported operations
15
- */
16
- ORQ_CONTACT_ID?: string | undefined;
17
-
18
- /**
19
- * Sets the environment parameter for all supported operations
20
- */
21
- ORQ_ENVIRONMENT?: string | undefined;
22
-
23
- ORQ_DEBUG?: boolean | undefined;
24
- }
25
-
26
- export const envSchema: z.ZodType<Env, z.ZodTypeDef, unknown> = z.object({
27
- ORQ_API_KEY: z.string().optional(),
28
-
29
- ORQ_CONTACT_ID: z.string().optional(),
30
- ORQ_ENVIRONMENT: z.string().optional(),
31
-
32
- ORQ_DEBUG: z.coerce.boolean().optional(),
33
- });
34
-
35
- let envMemo: Env | undefined = undefined;
36
- /**
37
- * Reads and validates environment variables.
38
- */
39
- export function env(): Env {
40
- if (envMemo) {
41
- return envMemo;
42
- }
43
-
44
- envMemo = envSchema.parse(
45
- dlv(globalThis, "process.env") ?? dlv(globalThis, "Deno.env") ?? {},
46
- );
47
- return envMemo;
48
- }
49
-
50
- /**
51
- * Clears the cached env object. Useful for testing with a fresh environment.
52
- */
53
- export function resetEnv() {
54
- envMemo = undefined;
55
- }
56
-
57
- /**
58
- * Populates global parameters with environment variables.
59
- */
60
- export function fillGlobals(options: SDKOptions): SDKOptions {
61
- const clone = { ...options };
62
-
63
- const envVars = env();
64
-
65
- if (typeof envVars.ORQ_CONTACT_ID !== "undefined") {
66
- clone.contactId ??= envVars.ORQ_CONTACT_ID;
67
- }
68
- if (typeof envVars.ORQ_ENVIRONMENT !== "undefined") {
69
- clone.environment ??= envVars.ORQ_ENVIRONMENT;
70
- }
71
-
72
- return clone;
73
- }