openlayer 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +67 -77
  3. package/_shims/index.d.ts +2 -0
  4. package/_shims/index.js +5 -1
  5. package/_shims/index.mjs +5 -1
  6. package/core.d.ts +17 -3
  7. package/core.d.ts.map +1 -1
  8. package/core.js +32 -18
  9. package/core.js.map +1 -1
  10. package/core.mjs +33 -19
  11. package/core.mjs.map +1 -1
  12. package/index.d.mts +8 -5
  13. package/index.d.ts +8 -5
  14. package/index.d.ts.map +1 -1
  15. package/index.js +6 -2
  16. package/index.js.map +1 -1
  17. package/index.mjs +6 -2
  18. package/index.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/resource.d.ts +1 -1
  21. package/resource.d.ts.map +1 -1
  22. package/resource.js.map +1 -1
  23. package/resource.mjs.map +1 -1
  24. package/resources/commits/test-results.d.ts +24 -6
  25. package/resources/commits/test-results.d.ts.map +1 -1
  26. package/resources/commits.d.ts +2 -0
  27. package/resources/commits.d.ts.map +1 -0
  28. package/resources/commits.js +19 -0
  29. package/resources/commits.js.map +1 -0
  30. package/resources/commits.mjs +3 -0
  31. package/resources/commits.mjs.map +1 -0
  32. package/resources/inference-pipelines/data.d.ts +23 -1
  33. package/resources/inference-pipelines/data.d.ts.map +1 -1
  34. package/resources/inference-pipelines/data.js +20 -0
  35. package/resources/inference-pipelines/data.js.map +1 -1
  36. package/resources/inference-pipelines/data.mjs +20 -0
  37. package/resources/inference-pipelines/data.mjs.map +1 -1
  38. package/resources/inference-pipelines/inference-pipelines.d.ts +95 -0
  39. package/resources/inference-pipelines/inference-pipelines.d.ts.map +1 -1
  40. package/resources/inference-pipelines/inference-pipelines.js +7 -0
  41. package/resources/inference-pipelines/inference-pipelines.js.map +1 -1
  42. package/resources/inference-pipelines/inference-pipelines.mjs +7 -0
  43. package/resources/inference-pipelines/inference-pipelines.mjs.map +1 -1
  44. package/resources/inference-pipelines/rows.d.ts +8 -0
  45. package/resources/inference-pipelines/rows.d.ts.map +1 -1
  46. package/resources/inference-pipelines/rows.js +8 -0
  47. package/resources/inference-pipelines/rows.js.map +1 -1
  48. package/resources/inference-pipelines/rows.mjs +8 -0
  49. package/resources/inference-pipelines/rows.mjs.map +1 -1
  50. package/resources/inference-pipelines/test-results.d.ts +31 -5
  51. package/resources/inference-pipelines/test-results.d.ts.map +1 -1
  52. package/resources/inference-pipelines/test-results.js.map +1 -1
  53. package/resources/inference-pipelines/test-results.mjs.map +1 -1
  54. package/resources/inference-pipelines.d.ts +2 -0
  55. package/resources/inference-pipelines.d.ts.map +1 -0
  56. package/resources/inference-pipelines.js +19 -0
  57. package/resources/inference-pipelines.js.map +1 -0
  58. package/resources/inference-pipelines.mjs +3 -0
  59. package/resources/inference-pipelines.mjs.map +1 -0
  60. package/resources/projects/commits.d.ts +18 -0
  61. package/resources/projects/commits.d.ts.map +1 -1
  62. package/resources/projects/commits.js +11 -0
  63. package/resources/projects/commits.js.map +1 -1
  64. package/resources/projects/commits.mjs +11 -0
  65. package/resources/projects/commits.mjs.map +1 -1
  66. package/resources/projects/index.d.ts +1 -0
  67. package/resources/projects/index.d.ts.map +1 -1
  68. package/resources/projects/index.js +3 -1
  69. package/resources/projects/index.js.map +1 -1
  70. package/resources/projects/index.mjs +1 -0
  71. package/resources/projects/index.mjs.map +1 -1
  72. package/resources/projects/inference-pipelines.d.ts +104 -0
  73. package/resources/projects/inference-pipelines.d.ts.map +1 -1
  74. package/resources/projects/inference-pipelines.js +12 -0
  75. package/resources/projects/inference-pipelines.js.map +1 -1
  76. package/resources/projects/inference-pipelines.mjs +12 -0
  77. package/resources/projects/inference-pipelines.mjs.map +1 -1
  78. package/resources/projects/projects.d.ts +17 -0
  79. package/resources/projects/projects.d.ts.map +1 -1
  80. package/resources/projects/projects.js +12 -0
  81. package/resources/projects/projects.js.map +1 -1
  82. package/resources/projects/projects.mjs +12 -0
  83. package/resources/projects/projects.mjs.map +1 -1
  84. package/resources/projects/tests.d.ts +501 -0
  85. package/resources/projects/tests.d.ts.map +1 -0
  86. package/resources/projects/tests.js +55 -0
  87. package/resources/projects/tests.js.map +1 -0
  88. package/resources/projects/tests.mjs +51 -0
  89. package/resources/projects/tests.mjs.map +1 -0
  90. package/resources/projects.d.ts +2 -0
  91. package/resources/projects.d.ts.map +1 -0
  92. package/resources/projects.js +19 -0
  93. package/resources/projects.js.map +1 -0
  94. package/resources/projects.mjs +3 -0
  95. package/resources/projects.mjs.map +1 -0
  96. package/resources/storage.d.ts +2 -0
  97. package/resources/storage.d.ts.map +1 -0
  98. package/resources/storage.js +19 -0
  99. package/resources/storage.js.map +1 -0
  100. package/resources/storage.mjs +3 -0
  101. package/resources/storage.mjs.map +1 -0
  102. package/resources.d.ts +2 -0
  103. package/resources.d.ts.map +1 -0
  104. package/resources.js +18 -0
  105. package/resources.js.map +1 -0
  106. package/resources.mjs +2 -0
  107. package/resources.mjs.map +1 -0
  108. package/src/_shims/index.d.ts +2 -0
  109. package/src/_shims/index.js +5 -1
  110. package/src/_shims/index.mjs +5 -1
  111. package/src/core.ts +51 -17
  112. package/src/index.ts +15 -5
  113. package/src/resource.ts +1 -1
  114. package/src/resources/commits/test-results.ts +102 -6
  115. package/src/resources/commits.ts +3 -0
  116. package/src/resources/inference-pipelines/data.ts +21 -1
  117. package/src/resources/inference-pipelines/inference-pipelines.ts +95 -0
  118. package/src/resources/inference-pipelines/rows.ts +8 -0
  119. package/src/resources/inference-pipelines/test-results.ts +109 -5
  120. package/src/resources/inference-pipelines.ts +3 -0
  121. package/src/resources/projects/commits.ts +18 -0
  122. package/src/resources/projects/index.ts +9 -0
  123. package/src/resources/projects/inference-pipelines.ts +104 -0
  124. package/src/resources/projects/projects.ts +35 -0
  125. package/src/resources/projects/tests.ts +905 -0
  126. package/src/resources/projects.ts +3 -0
  127. package/src/resources/storage.ts +3 -0
  128. package/src/resources.ts +1 -0
  129. package/src/version.ts +1 -1
  130. package/version.d.ts +1 -1
  131. package/version.js +1 -1
  132. package/version.mjs +1 -1
@@ -0,0 +1,51 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../../resource.mjs";
3
+ import { isRequestOptions } from "../../core.mjs";
4
+ export class Tests extends APIResource {
5
+ /**
6
+ * Create a test.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const test = await client.projects.tests.create(
11
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
12
+ * {
13
+ * description:
14
+ * 'This test checks for duplicate rows in the dataset.',
15
+ * name: 'No duplicate rows',
16
+ * subtype: 'duplicateRowCount',
17
+ * thresholds: [{}],
18
+ * type: 'integrity',
19
+ * },
20
+ * );
21
+ * ```
22
+ */
23
+ create(projectId, body, options) {
24
+ return this._client.post(`/projects/${projectId}/tests`, { body, ...options });
25
+ }
26
+ /**
27
+ * Update tests.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const test = await client.projects.tests.update(
32
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
33
+ * {
34
+ * payloads: [
35
+ * { id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
36
+ * ],
37
+ * },
38
+ * );
39
+ * ```
40
+ */
41
+ update(projectId, body, options) {
42
+ return this._client.put(`/projects/${projectId}/tests`, { body, ...options });
43
+ }
44
+ list(projectId, query = {}, options) {
45
+ if (isRequestOptions(query)) {
46
+ return this.list(projectId, {}, query);
47
+ }
48
+ return this._client.get(`/projects/${projectId}/tests`, { query, ...options });
49
+ }
50
+ }
51
+ //# sourceMappingURL=tests.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tests.mjs","sourceRoot":"","sources":["../../src/resources/projects/tests.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;AAG3B,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CACJ,SAAiB,EACjB,IAAsB,EACtB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,SAAS,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CACJ,SAAiB,EACjB,IAAsB,EACtB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,SAAS,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;IAkBD,IAAI,CACF,SAAiB,EACjB,QAA8C,EAAE,EAChD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,SAAS,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjF,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from "./projects/index.js";
2
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../src/resources/projects.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./projects/index.js"), exports);
19
+ //# sourceMappingURL=projects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.js","sourceRoot":"","sources":["../src/resources/projects.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;AAEtF,sDAAiC"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export * from "./projects/index.mjs";
3
+ //# sourceMappingURL=projects.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.mjs","sourceRoot":"","sources":["../src/resources/projects.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
@@ -0,0 +1,2 @@
1
+ export * from "./storage/index.js";
2
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/resources/storage.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./storage/index.js"), exports);
19
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/resources/storage.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;AAEtF,qDAAgC"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export * from "./storage/index.mjs";
3
+ //# sourceMappingURL=storage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.mjs","sourceRoot":"","sources":["../src/resources/storage.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
package/resources.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./resources/index.js";
2
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
package/resources.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./resources/index.js"), exports);
18
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAkC"}
package/resources.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./resources/index.mjs";
2
+ //# sourceMappingURL=resources.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.mjs","sourceRoot":"","sources":["src/resources.ts"],"names":[],"mappings":""}
@@ -79,3 +79,5 @@ export function fileFromPath(path: string, options?: FileFromPathOptions): Promi
79
79
  export function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File>;
80
80
 
81
81
  export function isFsReadStream(value: any): value is FsReadStream;
82
+
83
+ export const init: () => void;
@@ -3,7 +3,9 @@
3
3
  */
4
4
  const shims = require('./registry');
5
5
  const auto = require('openlayer/_shims/auto/runtime');
6
- if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
6
+ exports.init = () => {
7
+ if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
8
+ };
7
9
  for (const property of Object.keys(shims)) {
8
10
  Object.defineProperty(exports, property, {
9
11
  get() {
@@ -11,3 +13,5 @@ for (const property of Object.keys(shims)) {
11
13
  },
12
14
  });
13
15
  }
16
+
17
+ exports.init();
@@ -3,5 +3,9 @@
3
3
  */
4
4
  import * as shims from './registry.mjs';
5
5
  import * as auto from "./auto/runtime";
6
- if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
6
+ export const init = () => {
7
+ if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
8
+ };
7
9
  export * from './registry.mjs';
10
+
11
+ init();
package/src/core.ts CHANGED
@@ -16,7 +16,12 @@ import {
16
16
  type RequestInit,
17
17
  type Response,
18
18
  type HeadersInit,
19
+ init,
19
20
  } from './_shims/index';
21
+
22
+ // try running side effects outside of _shims/index to workaround https://github.com/vercel/next.js/issues/76881
23
+ init();
24
+
20
25
  export { type Response };
21
26
  import { BlobLike, isBlobLike, isMultipartBody } from './uploads';
22
27
  export {
@@ -28,6 +33,20 @@ export {
28
33
 
29
34
  export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
30
35
 
36
+ /**
37
+ * An alias to the builtin `Array` type so we can
38
+ * easily alias it in import statements if there are name clashes.
39
+ */
40
+ type _Array<T> = Array<T>;
41
+
42
+ /**
43
+ * An alias to the builtin `Record` type so we can
44
+ * easily alias it in import statements if there are name clashes.
45
+ */
46
+ type _Record<K extends keyof any, T> = Record<K, T>;
47
+
48
+ export type { _Array as Array, _Record as Record };
49
+
31
50
  type PromiseOrValue<T> = T | Promise<T>;
32
51
 
33
52
  type APIResponseProps = {
@@ -48,8 +67,8 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
48
67
  }
49
68
 
50
69
  const contentType = response.headers.get('content-type');
51
- const isJSON =
52
- contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json');
70
+ const mediaType = contentType?.split(';')[0]?.trim();
71
+ const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
53
72
  if (isJSON) {
54
73
  const json = await response.json();
55
74
 
@@ -151,6 +170,7 @@ export class APIPromise<T> extends Promise<T> {
151
170
 
152
171
  export abstract class APIClient {
153
172
  baseURL: string;
173
+ #baseURLOverridden: boolean;
154
174
  maxRetries: number;
155
175
  timeout: number;
156
176
  httpAgent: Agent | undefined;
@@ -160,18 +180,21 @@ export abstract class APIClient {
160
180
 
161
181
  constructor({
162
182
  baseURL,
183
+ baseURLOverridden,
163
184
  maxRetries = 2,
164
185
  timeout = 60000, // 1 minute
165
186
  httpAgent,
166
187
  fetch: overriddenFetch,
167
188
  }: {
168
189
  baseURL: string;
190
+ baseURLOverridden: boolean;
169
191
  maxRetries?: number | undefined;
170
192
  timeout: number | undefined;
171
193
  httpAgent: Agent | undefined;
172
194
  fetch: Fetch | undefined;
173
195
  }) {
174
196
  this.baseURL = baseURL;
197
+ this.#baseURLOverridden = baseURLOverridden;
175
198
  this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
176
199
  this.timeout = validatePositiveInteger('timeout', timeout);
177
200
  this.httpAgent = httpAgent;
@@ -194,7 +217,7 @@ export abstract class APIClient {
194
217
  protected defaultHeaders(opts: FinalRequestOptions): Headers {
195
218
  return {
196
219
  Accept: 'application/json',
197
- 'Content-Type': 'application/json',
220
+ ...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }),
198
221
  'User-Agent': this.getUserAgent(),
199
222
  ...getPlatformHeaders(),
200
223
  ...this.authHeaders(opts),
@@ -277,10 +300,11 @@ export abstract class APIClient {
277
300
  }
278
301
 
279
302
  buildRequest<Req>(
280
- options: FinalRequestOptions<Req>,
303
+ inputOptions: FinalRequestOptions<Req>,
281
304
  { retryCount = 0 }: { retryCount?: number } = {},
282
305
  ): { req: RequestInit; url: string; timeout: number } {
283
- const { method, path, query, headers: headers = {} } = options;
306
+ const options = { ...inputOptions };
307
+ const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
284
308
 
285
309
  const body =
286
310
  ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
@@ -290,11 +314,11 @@ export abstract class APIClient {
290
314
  : null;
291
315
  const contentLength = this.calculateContentLength(body);
292
316
 
293
- const url = this.buildURL(path!, query);
317
+ const url = this.buildURL(path!, query, defaultBaseURL);
294
318
  if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
295
- const timeout = options.timeout ?? this.timeout;
319
+ options.timeout = options.timeout ?? this.timeout;
296
320
  const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
297
- const minAgentTimeout = timeout + 1000;
321
+ const minAgentTimeout = options.timeout + 1000;
298
322
  if (
299
323
  typeof (httpAgent as any)?.options?.timeout === 'number' &&
300
324
  minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
@@ -307,8 +331,8 @@ export abstract class APIClient {
307
331
  }
308
332
 
309
333
  if (this.idempotencyHeader && method !== 'get') {
310
- if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
311
- headers[this.idempotencyHeader] = options.idempotencyKey;
334
+ if (!inputOptions.idempotencyKey) inputOptions.idempotencyKey = this.defaultIdempotencyKey();
335
+ headers[this.idempotencyHeader] = inputOptions.idempotencyKey;
312
336
  }
313
337
 
314
338
  const reqHeaders = this.buildHeaders({ options, headers, contentLength, retryCount });
@@ -323,7 +347,7 @@ export abstract class APIClient {
323
347
  signal: options.signal ?? null,
324
348
  };
325
349
 
326
- return { req, url, timeout };
350
+ return { req, url, timeout: options.timeout };
327
351
  }
328
352
 
329
353
  private buildHeaders({
@@ -351,15 +375,22 @@ export abstract class APIClient {
351
375
  delete reqHeaders['content-type'];
352
376
  }
353
377
 
354
- // Don't set the retry count header if it was already set or removed through default headers or by the
355
- // caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
356
- // account for the removal case.
378
+ // Don't set theses headers if they were already set or removed through default headers or by the caller.
379
+ // We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to account
380
+ // for the removal case.
357
381
  if (
358
382
  getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
359
383
  getHeader(headers, 'x-stainless-retry-count') === undefined
360
384
  ) {
361
385
  reqHeaders['x-stainless-retry-count'] = String(retryCount);
362
386
  }
387
+ if (
388
+ getHeader(defaultHeaders, 'x-stainless-timeout') === undefined &&
389
+ getHeader(headers, 'x-stainless-timeout') === undefined &&
390
+ options.timeout
391
+ ) {
392
+ reqHeaders['x-stainless-timeout'] = String(Math.trunc(options.timeout / 1000));
393
+ }
363
394
 
364
395
  this.validateHeaders(reqHeaders, headers);
365
396
 
@@ -387,7 +418,7 @@ export abstract class APIClient {
387
418
  !headers ? {}
388
419
  : Symbol.iterator in headers ?
389
420
  Object.fromEntries(Array.from(headers as Iterable<string[]>).map((header) => [...header]))
390
- : { ...headers }
421
+ : { ...(headers as any as Record<string, string>) }
391
422
  );
392
423
  }
393
424
 
@@ -476,11 +507,12 @@ export abstract class APIClient {
476
507
  return new PagePromise<PageClass, Item>(this, request, Page);
477
508
  }
478
509
 
479
- buildURL<Req>(path: string, query: Req | null | undefined): string {
510
+ buildURL<Req>(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string {
511
+ const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL;
480
512
  const url =
481
513
  isAbsoluteURL(path) ?
482
514
  new URL(path)
483
- : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
515
+ : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
484
516
 
485
517
  const defaultQuery = this.defaultQuery();
486
518
  if (!isEmptyObj(defaultQuery)) {
@@ -765,6 +797,7 @@ export type RequestOptions<
765
797
  query?: Req | undefined;
766
798
  body?: Req | null | undefined;
767
799
  headers?: Headers | undefined;
800
+ defaultBaseURL?: string | undefined;
768
801
 
769
802
  maxRetries?: number;
770
803
  stream?: boolean | undefined;
@@ -786,6 +819,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
786
819
  query: true,
787
820
  body: true,
788
821
  headers: true,
822
+ defaultBaseURL: true,
789
823
 
790
824
  maxRetries: true,
791
825
  stream: true,
package/src/index.ts CHANGED
@@ -42,8 +42,10 @@ export interface ClientOptions {
42
42
  *
43
43
  * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
44
44
  * much longer than this timeout before the promise succeeds or fails.
45
+ *
46
+ * @unit milliseconds
45
47
  */
46
- timeout?: number;
48
+ timeout?: number | undefined;
47
49
 
48
50
  /**
49
51
  * An HTTP agent used to manage HTTP(S) connections.
@@ -51,7 +53,7 @@ export interface ClientOptions {
51
53
  * If not provided, an agent will be constructed by default in the Node.js environment,
52
54
  * otherwise no agent is used.
53
55
  */
54
- httpAgent?: Agent;
56
+ httpAgent?: Agent | undefined;
55
57
 
56
58
  /**
57
59
  * Specify a custom `fetch` function implementation.
@@ -67,7 +69,7 @@ export interface ClientOptions {
67
69
  *
68
70
  * @default 2
69
71
  */
70
- maxRetries?: number;
72
+ maxRetries?: number | undefined;
71
73
 
72
74
  /**
73
75
  * Default headers to include with every request to the API.
@@ -75,7 +77,7 @@ export interface ClientOptions {
75
77
  * These can be removed in individual requests by explicitly setting the
76
78
  * header to `undefined` or `null` in request options.
77
79
  */
78
- defaultHeaders?: Core.Headers;
80
+ defaultHeaders?: Core.Headers | undefined;
79
81
 
80
82
  /**
81
83
  * Default query parameters to include with every request to the API.
@@ -83,7 +85,7 @@ export interface ClientOptions {
83
85
  * These can be removed in individual requests by explicitly setting the
84
86
  * param to `undefined` in request options.
85
87
  */
86
- defaultQuery?: Core.DefaultQuery;
88
+ defaultQuery?: Core.DefaultQuery | undefined;
87
89
  }
88
90
 
89
91
  /**
@@ -119,6 +121,7 @@ export class Openlayer extends Core.APIClient {
119
121
 
120
122
  super({
121
123
  baseURL: options.baseURL!,
124
+ baseURLOverridden: baseURL ? baseURL !== 'https://api.openlayer.com/v1' : false,
122
125
  timeout: options.timeout ?? 60000 /* 1 minute */,
123
126
  httpAgent: options.httpAgent,
124
127
  maxRetries: options.maxRetries,
@@ -135,6 +138,13 @@ export class Openlayer extends Core.APIClient {
135
138
  inferencePipelines: API.InferencePipelines = new API.InferencePipelines(this);
136
139
  storage: API.Storage = new API.Storage(this);
137
140
 
141
+ /**
142
+ * Check whether the base URL is set to its default.
143
+ */
144
+ #baseURLOverridden(): boolean {
145
+ return this.baseURL !== 'https://api.openlayer.com/v1';
146
+ }
147
+
138
148
  protected override defaultQuery(): Core.DefaultQuery | undefined {
139
149
  return this._options.defaultQuery;
140
150
  }
package/src/resource.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { Openlayer } from './index';
4
4
 
5
- export class APIResource {
5
+ export abstract class APIResource {
6
6
  protected _client: Openlayer;
7
7
 
8
8
  constructor(client: Openlayer) {
@@ -140,7 +140,48 @@ export namespace TestResultListResponse {
140
140
  /**
141
141
  * The test subtype.
142
142
  */
143
- subtype: string;
143
+ subtype:
144
+ | 'anomalousColumnCount'
145
+ | 'characterLength'
146
+ | 'classImbalanceRatio'
147
+ | 'expectColumnAToBeInColumnB'
148
+ | 'columnAverage'
149
+ | 'columnDrift'
150
+ | 'columnStatistic'
151
+ | 'columnValuesMatch'
152
+ | 'conflictingLabelRowCount'
153
+ | 'containsPii'
154
+ | 'containsValidUrl'
155
+ | 'correlatedFeatureCount'
156
+ | 'customMetricThreshold'
157
+ | 'duplicateRowCount'
158
+ | 'emptyFeature'
159
+ | 'emptyFeatureCount'
160
+ | 'driftedFeatureCount'
161
+ | 'featureMissingValues'
162
+ | 'featureValueValidation'
163
+ | 'greatExpectations'
164
+ | 'groupByColumnStatsCheck'
165
+ | 'illFormedRowCount'
166
+ | 'isCode'
167
+ | 'isJson'
168
+ | 'llmRubricThresholdV2'
169
+ | 'labelDrift'
170
+ | 'metricThreshold'
171
+ | 'newCategoryCount'
172
+ | 'newLabelCount'
173
+ | 'nullRowCount'
174
+ | 'rowCount'
175
+ | 'ppScoreValueValidation'
176
+ | 'quasiConstantFeature'
177
+ | 'quasiConstantFeatureCount'
178
+ | 'sqlQuery'
179
+ | 'dtypeValidation'
180
+ | 'sentenceLength'
181
+ | 'sizeRatio'
182
+ | 'specialCharactersRatio'
183
+ | 'stringValidation'
184
+ | 'trainValLeakageRowCount';
144
185
 
145
186
  /**
146
187
  * Whether the test is suggested or user-created.
@@ -152,7 +193,7 @@ export namespace TestResultListResponse {
152
193
  /**
153
194
  * The test type.
154
195
  */
155
- type: string;
196
+ type: 'integrity' | 'consistency' | 'performance';
156
197
 
157
198
  /**
158
199
  * Whether the test is archived.
@@ -201,9 +242,48 @@ export namespace TestResultListResponse {
201
242
  /**
202
243
  * The insight name to be evaluated.
203
244
  */
204
- insightName?: string;
245
+ insightName?:
246
+ | 'characterLength'
247
+ | 'classImbalance'
248
+ | 'expectColumnAToBeInColumnB'
249
+ | 'columnAverage'
250
+ | 'columnDrift'
251
+ | 'columnValuesMatch'
252
+ | 'confidenceDistribution'
253
+ | 'conflictingLabelRowCount'
254
+ | 'containsPii'
255
+ | 'containsValidUrl'
256
+ | 'correlatedFeatures'
257
+ | 'customMetric'
258
+ | 'duplicateRowCount'
259
+ | 'emptyFeatures'
260
+ | 'featureDrift'
261
+ | 'featureProfile'
262
+ | 'greatExpectations'
263
+ | 'groupByColumnStatsCheck'
264
+ | 'illFormedRowCount'
265
+ | 'isCode'
266
+ | 'isJson'
267
+ | 'llmRubricV2'
268
+ | 'labelDrift'
269
+ | 'metrics'
270
+ | 'newCategories'
271
+ | 'newLabels'
272
+ | 'nullRowCount'
273
+ | 'ppScore'
274
+ | 'quasiConstantFeatures'
275
+ | 'sentenceLength'
276
+ | 'sizeRatio'
277
+ | 'specialCharacters'
278
+ | 'stringValidation'
279
+ | 'trainValLeakageRowCount';
205
280
 
206
- insightParameters?: Array<unknown>;
281
+ /**
282
+ * The insight parameters. Required only for some test subtypes. For example, for
283
+ * tests that require a column name, the insight parameters will be [{'name':
284
+ * 'column_name', 'value': 'Age'}]
285
+ */
286
+ insightParameters?: Array<Threshold.InsightParameter> | null;
207
287
 
208
288
  /**
209
289
  * The measurement to be evaluated.
@@ -213,20 +293,36 @@ export namespace TestResultListResponse {
213
293
  /**
214
294
  * The operator to be used for the evaluation.
215
295
  */
216
- operator?: string;
296
+ operator?: 'is' | '>' | '>=' | '<' | '<=' | '!=';
297
+
298
+ /**
299
+ * Whether to use automatic anomaly detection or manual thresholds
300
+ */
301
+ thresholdMode?: 'automatic' | 'manual';
217
302
 
218
303
  /**
219
304
  * The value to be compared.
220
305
  */
221
306
  value?: number | boolean | string | Array<string>;
222
307
  }
308
+
309
+ export namespace Threshold {
310
+ export interface InsightParameter {
311
+ /**
312
+ * The name of the insight filter.
313
+ */
314
+ name: string;
315
+
316
+ value: unknown;
317
+ }
318
+ }
223
319
  }
224
320
  }
225
321
  }
226
322
 
227
323
  export interface TestResultListParams {
228
324
  /**
229
- * Include archived goals.
325
+ * Filter for archived tests.
230
326
  */
231
327
  includeArchived?: boolean;
232
328
 
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './commits/index';