vellum-ai 0.3.4 → 0.3.6

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 (73) hide show
  1. package/Client.d.ts +5 -22
  2. package/Client.js +32 -31
  3. package/api/client/requests/GenerateBodyRequest.d.ts +3 -4
  4. package/api/client/requests/SearchRequestBodyRequest.d.ts +1 -11
  5. package/api/client/requests/SubmitCompletionActualsRequest.d.ts +1 -1
  6. package/api/resources/deployments/client/Client.d.ts +1 -1
  7. package/api/resources/deployments/client/Client.js +10 -4
  8. package/api/resources/deployments/client/requests/DeploymentsListRequest.d.ts +1 -3
  9. package/api/resources/documentIndexes/client/Client.d.ts +1 -3
  10. package/api/resources/documentIndexes/client/Client.js +7 -5
  11. package/api/resources/documentIndexes/client/requests/DocumentIndexCreateRequest.d.ts +0 -2
  12. package/api/resources/documents/client/Client.d.ts +1 -3
  13. package/api/resources/documents/client/Client.js +13 -7
  14. package/api/resources/documents/client/requests/PatchedDocumentUpdateRequest.d.ts +1 -3
  15. package/api/resources/modelVersions/client/Client.d.ts +1 -1
  16. package/api/resources/modelVersions/client/Client.js +4 -2
  17. package/api/resources/registeredPrompts/client/Client.d.ts +11 -6
  18. package/api/resources/registeredPrompts/client/Client.js +14 -7
  19. package/api/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.d.ts +11 -6
  20. package/api/resources/sandboxes/client/Client.d.ts +4 -2
  21. package/api/resources/sandboxes/client/Client.js +10 -4
  22. package/api/resources/sandboxes/client/requests/UpsertSandboxScenarioRequestRequest.d.ts +2 -0
  23. package/api/resources/testSuites/client/Client.d.ts +2 -2
  24. package/api/resources/testSuites/client/Client.js +8 -4
  25. package/api/resources/workflowDeployments/client/Client.js +3 -1
  26. package/api/resources/workflowDeployments/client/requests/WorkflowDeploymentsListRequest.d.ts +1 -3
  27. package/core/fetcher/Fetcher.js +8 -1
  28. package/core/index.d.ts +1 -0
  29. package/core/index.js +1 -0
  30. package/core/runtime/index.d.ts +1 -0
  31. package/core/runtime/index.js +5 -0
  32. package/core/runtime/runtime.d.ts +8 -0
  33. package/core/runtime/runtime.js +82 -0
  34. package/core/streaming-fetcher/Stream.d.ts +4 -0
  35. package/core/streaming-fetcher/Stream.js +63 -5
  36. package/dist/Client.d.ts +5 -22
  37. package/dist/Client.js +32 -31
  38. package/dist/api/client/requests/GenerateBodyRequest.d.ts +3 -4
  39. package/dist/api/client/requests/SearchRequestBodyRequest.d.ts +1 -11
  40. package/dist/api/client/requests/SubmitCompletionActualsRequest.d.ts +1 -1
  41. package/dist/api/resources/deployments/client/Client.d.ts +1 -1
  42. package/dist/api/resources/deployments/client/Client.js +10 -4
  43. package/dist/api/resources/deployments/client/requests/DeploymentsListRequest.d.ts +1 -3
  44. package/dist/api/resources/documentIndexes/client/Client.d.ts +1 -3
  45. package/dist/api/resources/documentIndexes/client/Client.js +7 -5
  46. package/dist/api/resources/documentIndexes/client/requests/DocumentIndexCreateRequest.d.ts +0 -2
  47. package/dist/api/resources/documents/client/Client.d.ts +1 -3
  48. package/dist/api/resources/documents/client/Client.js +13 -7
  49. package/dist/api/resources/documents/client/requests/PatchedDocumentUpdateRequest.d.ts +1 -3
  50. package/dist/api/resources/modelVersions/client/Client.d.ts +1 -1
  51. package/dist/api/resources/modelVersions/client/Client.js +4 -2
  52. package/dist/api/resources/registeredPrompts/client/Client.d.ts +11 -6
  53. package/dist/api/resources/registeredPrompts/client/Client.js +14 -7
  54. package/dist/api/resources/registeredPrompts/client/requests/RegisterPromptRequestRequest.d.ts +11 -6
  55. package/dist/api/resources/sandboxes/client/Client.d.ts +4 -2
  56. package/dist/api/resources/sandboxes/client/Client.js +10 -4
  57. package/dist/api/resources/sandboxes/client/requests/UpsertSandboxScenarioRequestRequest.d.ts +2 -0
  58. package/dist/api/resources/testSuites/client/Client.d.ts +2 -2
  59. package/dist/api/resources/testSuites/client/Client.js +8 -4
  60. package/dist/api/resources/workflowDeployments/client/Client.js +3 -1
  61. package/dist/api/resources/workflowDeployments/client/requests/WorkflowDeploymentsListRequest.d.ts +1 -3
  62. package/dist/core/fetcher/Fetcher.js +8 -1
  63. package/dist/core/index.d.ts +1 -0
  64. package/dist/core/index.js +1 -0
  65. package/dist/core/runtime/index.d.ts +1 -0
  66. package/dist/core/runtime/index.js +5 -0
  67. package/dist/core/runtime/runtime.d.ts +8 -0
  68. package/dist/core/runtime/runtime.js +82 -0
  69. package/dist/core/streaming-fetcher/Stream.d.ts +4 -0
  70. package/dist/core/streaming-fetcher/Stream.js +63 -5
  71. package/jest.config.js +5 -0
  72. package/package.json +6 -2
  73. package/tests/client.test.ts +11 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RUNTIME = void 0;
5
+ /**
6
+ * A constant that indicates whether the environment the code is running is a Web Browser.
7
+ */
8
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
9
+ /**
10
+ * A constant that indicates whether the environment the code is running is a Web Worker.
11
+ */
12
+ const isWebWorker = typeof self === "object" &&
13
+ // @ts-ignore
14
+ typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
15
+ (((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
16
+ ((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
17
+ ((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
18
+ /**
19
+ * A constant that indicates whether the environment the code is running is Deno.
20
+ */
21
+ const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
22
+ /**
23
+ * A constant that indicates whether the environment the code is running is Bun.sh.
24
+ */
25
+ const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
26
+ /**
27
+ * A constant that indicates whether the environment the code is running is Node.JS.
28
+ */
29
+ const isNode = typeof process !== "undefined" &&
30
+ Boolean(process.version) &&
31
+ Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) &&
32
+ // Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
33
+ !isDeno &&
34
+ !isBun;
35
+ /**
36
+ * A constant that indicates whether the environment the code is running is in React-Native.
37
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
38
+ */
39
+ const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
40
+ /**
41
+ * A constant that indicates which environment and version the SDK is running in.
42
+ */
43
+ exports.RUNTIME = evaluateRuntime();
44
+ function evaluateRuntime() {
45
+ if (isBrowser) {
46
+ return {
47
+ type: "browser",
48
+ version: window.navigator.userAgent,
49
+ };
50
+ }
51
+ if (isWebWorker) {
52
+ return {
53
+ type: "web-worker",
54
+ };
55
+ }
56
+ if (isDeno) {
57
+ return {
58
+ type: "deno",
59
+ version: Deno.version.deno,
60
+ };
61
+ }
62
+ if (isBun) {
63
+ return {
64
+ type: "bun",
65
+ version: Bun.version,
66
+ };
67
+ }
68
+ if (isNode) {
69
+ return {
70
+ type: "node",
71
+ version: process.versions.node,
72
+ };
73
+ }
74
+ if (isReactNative) {
75
+ return {
76
+ type: "react-native",
77
+ };
78
+ }
79
+ return {
80
+ type: "unknown",
81
+ };
82
+ }
@@ -13,3 +13,7 @@ export declare class Stream<T> implements AsyncIterable<T> {
13
13
  private iterMessages;
14
14
  [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
15
15
  }
16
+ /**
17
+ * Browser polyfill for ReadableStream
18
+ */
19
+ export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __asyncValues = (this && this.__asyncValues) || function (o) {
3
12
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
4
13
  var m = o[Symbol.asyncIterator], i;
@@ -19,7 +28,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
19
28
  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
20
29
  };
21
30
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.Stream = void 0;
31
+ exports.readableStreamAsyncIterable = exports.Stream = void 0;
23
32
  class Stream {
24
33
  constructor({ stream, parse, terminator, }) {
25
34
  this.stream = stream;
@@ -29,11 +38,21 @@ class Stream {
29
38
  iterMessages() {
30
39
  return __asyncGenerator(this, arguments, function* iterMessages_1() {
31
40
  var e_1, _a;
41
+ const decoder = new TextDecoder("utf8");
42
+ const stream = readableStreamAsyncIterable(this.stream);
32
43
  let previous = "";
33
44
  try {
34
- for (var _b = __asyncValues(this.stream), _c; _c = yield __await(_b.next()), !_c.done;) {
35
- const chunk = _c.value;
36
- const bufferChunk = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
45
+ for (var stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), !stream_1_1.done;) {
46
+ const chunk = stream_1_1.value;
47
+ let bufferChunk = "";
48
+ // Buffer is present in Node.js environment
49
+ if (typeof Buffer !== "undefined") {
50
+ bufferChunk += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
51
+ }
52
+ // TextDecoder is present in Browser environment
53
+ else if (typeof TextDecoder !== "undefined") {
54
+ bufferChunk += decoder.decode(chunk);
55
+ }
37
56
  previous += bufferChunk;
38
57
  let terminatorIndex;
39
58
  while ((terminatorIndex = previous.indexOf(this.terminator)) >= 0) {
@@ -47,7 +66,7 @@ class Stream {
47
66
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
48
67
  finally {
49
68
  try {
50
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
69
+ if (stream_1_1 && !stream_1_1.done && (_a = stream_1.return)) yield __await(_a.call(stream_1));
51
70
  }
52
71
  finally { if (e_1) throw e_1.error; }
53
72
  }
@@ -73,3 +92,42 @@ class Stream {
73
92
  }
74
93
  }
75
94
  exports.Stream = Stream;
95
+ /**
96
+ * Browser polyfill for ReadableStream
97
+ */
98
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
+ function readableStreamAsyncIterable(stream) {
100
+ if (stream[Symbol.asyncIterator]) {
101
+ return stream;
102
+ }
103
+ const reader = stream.getReader();
104
+ return {
105
+ next() {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ try {
108
+ const result = yield reader.read();
109
+ if (result === null || result === void 0 ? void 0 : result.done) {
110
+ reader.releaseLock();
111
+ } // release lock when stream becomes closed
112
+ return result;
113
+ }
114
+ catch (e) {
115
+ reader.releaseLock(); // release lock when stream becomes errored
116
+ throw e;
117
+ }
118
+ });
119
+ },
120
+ return() {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const cancelPromise = reader.cancel();
123
+ reader.releaseLock();
124
+ yield cancelPromise;
125
+ return { done: true, value: undefined };
126
+ });
127
+ },
128
+ [Symbol.asyncIterator]() {
129
+ return this;
130
+ },
131
+ };
132
+ }
133
+ exports.readableStreamAsyncIterable = readableStreamAsyncIterable;
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: "ts-jest",
4
+ testEnvironment: "node",
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vellum-ai",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "private": false,
5
5
  "repository": "https://github.com/vellum-ai/vellum-client-node",
6
6
  "license": "MIT",
@@ -9,7 +9,8 @@
9
9
  "scripts": {
10
10
  "format": "prettier --write 'src/**/*.ts'",
11
11
  "build": "tsc",
12
- "prepack": "cp -rv dist/. ."
12
+ "prepack": "cp -rv dist/. .",
13
+ "test": "jest"
13
14
  },
14
15
  "dependencies": {
15
16
  "url-join": "4.0.1",
@@ -21,6 +22,9 @@
21
22
  "@types/url-join": "4.0.1",
22
23
  "@types/qs": "6.9.8",
23
24
  "@types/node-fetch": "2.6.9",
25
+ "jest": "^29.7.0",
26
+ "@types/jest": "^29.5.5",
27
+ "ts-jest": "^29.1.1",
24
28
  "@types/node": "17.0.33",
25
29
  "prettier": "2.7.1",
26
30
  "typescript": "4.6.4"
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This is a test file for the SDK.
3
+ *
4
+ * Add any tests here and make sure to mark this file
5
+ * in `.fernignore`.
6
+ */
7
+ describe("test", () => {
8
+ it("default", () => {
9
+ expect(true).toBe(true);
10
+ });
11
+ });