graphor 0.4.1 → 0.4.2

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 (101) hide show
  1. package/CHANGELOG.md +24 -44
  2. package/LICENSE +1 -1
  3. package/README.md +37 -33
  4. package/client.d.mts +16 -15
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +16 -15
  7. package/client.d.ts.map +1 -1
  8. package/client.js +46 -47
  9. package/client.js.map +1 -1
  10. package/client.mjs +44 -45
  11. package/client.mjs.map +1 -1
  12. package/core/api-promise.d.mts +2 -2
  13. package/core/api-promise.d.mts.map +1 -1
  14. package/core/api-promise.d.ts +2 -2
  15. package/core/api-promise.d.ts.map +1 -1
  16. package/core/api-promise.js.map +1 -1
  17. package/core/api-promise.mjs.map +1 -1
  18. package/core/error.d.mts +2 -2
  19. package/core/error.d.mts.map +1 -1
  20. package/core/error.d.ts +2 -2
  21. package/core/error.d.ts.map +1 -1
  22. package/core/error.js +4 -4
  23. package/core/error.js.map +1 -1
  24. package/core/error.mjs +2 -2
  25. package/core/error.mjs.map +1 -1
  26. package/core/resource.d.mts +3 -3
  27. package/core/resource.d.mts.map +1 -1
  28. package/core/resource.d.ts +3 -3
  29. package/core/resource.d.ts.map +1 -1
  30. package/core/resource.js.map +1 -1
  31. package/core/resource.mjs.map +1 -1
  32. package/index.d.mts +3 -3
  33. package/index.d.mts.map +1 -1
  34. package/index.d.ts +3 -3
  35. package/index.d.ts.map +1 -1
  36. package/index.js +4 -4
  37. package/index.js.map +1 -1
  38. package/index.mjs +3 -3
  39. package/index.mjs.map +1 -1
  40. package/internal/parse.d.mts +2 -2
  41. package/internal/parse.d.mts.map +1 -1
  42. package/internal/parse.d.ts +2 -2
  43. package/internal/parse.d.ts.map +1 -1
  44. package/internal/parse.js.map +1 -1
  45. package/internal/parse.mjs.map +1 -1
  46. package/internal/shims.js +1 -1
  47. package/internal/shims.js.map +1 -1
  48. package/internal/shims.mjs +1 -1
  49. package/internal/shims.mjs.map +1 -1
  50. package/internal/uploads.d.mts +4 -4
  51. package/internal/uploads.d.mts.map +1 -1
  52. package/internal/uploads.d.ts +4 -4
  53. package/internal/uploads.d.ts.map +1 -1
  54. package/internal/uploads.js.map +1 -1
  55. package/internal/uploads.mjs.map +1 -1
  56. package/internal/utils/base64.js +2 -2
  57. package/internal/utils/base64.js.map +1 -1
  58. package/internal/utils/base64.mjs +3 -3
  59. package/internal/utils/base64.mjs.map +1 -1
  60. package/internal/utils/log.d.mts +3 -3
  61. package/internal/utils/log.d.mts.map +1 -1
  62. package/internal/utils/log.d.ts +3 -3
  63. package/internal/utils/log.d.ts.map +1 -1
  64. package/internal/utils/log.js.map +1 -1
  65. package/internal/utils/log.mjs.map +1 -1
  66. package/internal/utils/path.js +1 -1
  67. package/internal/utils/path.js.map +1 -1
  68. package/internal/utils/path.mjs +2 -2
  69. package/internal/utils/path.mjs.map +1 -1
  70. package/internal/utils/values.js +5 -5
  71. package/internal/utils/values.js.map +1 -1
  72. package/internal/utils/values.mjs +6 -6
  73. package/internal/utils/values.mjs.map +1 -1
  74. package/package.json +3 -3
  75. package/resources/index.d.mts +1 -1
  76. package/resources/index.d.mts.map +1 -1
  77. package/resources/index.d.ts +1 -1
  78. package/resources/index.d.ts.map +1 -1
  79. package/resources/sources.d.mts +9 -6
  80. package/resources/sources.d.mts.map +1 -1
  81. package/resources/sources.d.ts +9 -6
  82. package/resources/sources.d.ts.map +1 -1
  83. package/src/client.ts +37 -37
  84. package/src/core/api-promise.ts +4 -4
  85. package/src/core/error.ts +2 -2
  86. package/src/core/resource.ts +3 -3
  87. package/src/index.ts +3 -3
  88. package/src/internal/parse.ts +2 -2
  89. package/src/internal/shims.ts +1 -1
  90. package/src/internal/uploads.ts +5 -5
  91. package/src/internal/utils/base64.ts +3 -3
  92. package/src/internal/utils/log.ts +3 -3
  93. package/src/internal/utils/path.ts +2 -2
  94. package/src/internal/utils/values.ts +6 -6
  95. package/src/resources/index.ts +1 -1
  96. package/src/resources/sources.ts +18 -14
  97. package/src/version.ts +1 -1
  98. package/version.d.mts +1 -1
  99. package/version.d.ts +1 -1
  100. package/version.js +1 -1
  101. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -17,7 +17,7 @@ import * as Uploads from './core/uploads';
17
17
  import * as API from './resources/index';
18
18
  import { APIPromise } from './core/api-promise';
19
19
  import {
20
- PartitionMethod,
20
+ PublicPartitionMethod,
21
21
  PublicSource,
22
22
  SourceAskParams,
23
23
  SourceAskResponse,
@@ -52,14 +52,14 @@ import { isEmptyObj } from './internal/utils/values';
52
52
 
53
53
  export interface ClientOptions {
54
54
  /**
55
- * Defaults to process.env['GRAPHOR_API_KEY'].
55
+ * Defaults to process.env['GRAPHOR_PRD_API_KEY'].
56
56
  */
57
- apiKey?: string | null | undefined;
57
+ apiKey?: string | undefined;
58
58
 
59
59
  /**
60
60
  * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
61
61
  *
62
- * Defaults to process.env['GRAPHOR_BASE_URL'].
62
+ * Defaults to process.env['GRAPHOR_PRD_BASE_URL'].
63
63
  */
64
64
  baseURL?: string | null | undefined;
65
65
 
@@ -113,7 +113,7 @@ export interface ClientOptions {
113
113
  /**
114
114
  * Set the log level.
115
115
  *
116
- * Defaults to process.env['GRAPHOR_LOG'] or 'warn' if it isn't set.
116
+ * Defaults to process.env['GRAPHOR_PRD_LOG'] or 'warn' if it isn't set.
117
117
  */
118
118
  logLevel?: LogLevel | undefined;
119
119
 
@@ -126,10 +126,10 @@ export interface ClientOptions {
126
126
  }
127
127
 
128
128
  /**
129
- * API Client for interfacing with the Graphor API.
129
+ * API Client for interfacing with the Graphor Prd API.
130
130
  */
131
- export class Graphor {
132
- apiKey: string | null;
131
+ export class GraphorPrd {
132
+ apiKey: string;
133
133
 
134
134
  baseURL: string;
135
135
  maxRetries: number;
@@ -144,10 +144,10 @@ export class Graphor {
144
144
  private _options: ClientOptions;
145
145
 
146
146
  /**
147
- * API Client for interfacing with the Graphor API.
147
+ * API Client for interfacing with the Graphor Prd API.
148
148
  *
149
- * @param {string | null | undefined} [opts.apiKey=process.env['GRAPHOR_API_KEY'] ?? null]
150
- * @param {string} [opts.baseURL=process.env['GRAPHOR_BASE_URL'] ?? https://api.graphorlm.com/api/public/v1] - Override the default base URL for the API.
149
+ * @param {string | undefined} [opts.apiKey=process.env['GRAPHOR_PRD_API_KEY'] ?? undefined]
150
+ * @param {string} [opts.baseURL=process.env['GRAPHOR_PRD_BASE_URL'] ?? https://graphorlm.com/api/public/v1] - Override the default base URL for the API.
151
151
  * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
152
152
  * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
153
153
  * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -156,25 +156,31 @@ export class Graphor {
156
156
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
157
157
  */
158
158
  constructor({
159
- baseURL = readEnv('GRAPHOR_BASE_URL'),
160
- apiKey = readEnv('GRAPHOR_API_KEY') ?? null,
159
+ baseURL = readEnv('GRAPHOR_PRD_BASE_URL'),
160
+ apiKey = readEnv('GRAPHOR_PRD_API_KEY'),
161
161
  ...opts
162
162
  }: ClientOptions = {}) {
163
+ if (apiKey === undefined) {
164
+ throw new Errors.GraphorPrdError(
165
+ "The GRAPHOR_PRD_API_KEY environment variable is missing or empty; either provide it, or instantiate the GraphorPrd client with an apiKey option, like new GraphorPrd({ apiKey: 'My API Key' }).",
166
+ );
167
+ }
168
+
163
169
  const options: ClientOptions = {
164
170
  apiKey,
165
171
  ...opts,
166
- baseURL: baseURL || `https://api.graphorlm.com/api/public/v1`,
172
+ baseURL: baseURL || `https://graphorlm.com/api/public/v1`,
167
173
  };
168
174
 
169
175
  this.baseURL = options.baseURL!;
170
- this.timeout = options.timeout ?? Graphor.DEFAULT_TIMEOUT /* 1 minute */;
176
+ this.timeout = options.timeout ?? GraphorPrd.DEFAULT_TIMEOUT /* 1 minute */;
171
177
  this.logger = options.logger ?? console;
172
178
  const defaultLogLevel = 'warn';
173
179
  // Set default logLevel early so that we can log a warning in parseLogLevel.
174
180
  this.logLevel = defaultLogLevel;
175
181
  this.logLevel =
176
182
  parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ??
177
- parseLogLevel(readEnv('GRAPHOR_LOG'), "process.env['GRAPHOR_LOG']", this) ??
183
+ parseLogLevel(readEnv('GRAPHOR_PRD_LOG'), "process.env['GRAPHOR_PRD_LOG']", this) ??
178
184
  defaultLogLevel;
179
185
  this.fetchOptions = options.fetchOptions;
180
186
  this.maxRetries = options.maxRetries ?? 2;
@@ -209,7 +215,7 @@ export class Graphor {
209
215
  * Check whether the base URL is set to its default.
210
216
  */
211
217
  #baseURLOverridden(): boolean {
212
- return this.baseURL !== 'https://api.graphorlm.com/api/public/v1';
218
+ return this.baseURL !== 'https://graphorlm.com/api/public/v1';
213
219
  }
214
220
 
215
221
  protected defaultQuery(): Record<string, string | undefined> | undefined {
@@ -217,22 +223,10 @@ export class Graphor {
217
223
  }
218
224
 
219
225
  protected validateHeaders({ values, nulls }: NullableHeaders) {
220
- if (this.apiKey && values.get('authorization')) {
221
- return;
222
- }
223
- if (nulls.has('authorization')) {
224
- return;
225
- }
226
-
227
- throw new Error(
228
- 'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted',
229
- );
226
+ return;
230
227
  }
231
228
 
232
229
  protected async authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
233
- if (this.apiKey == null) {
234
- return undefined;
235
- }
236
230
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
237
231
  }
238
232
 
@@ -249,7 +243,7 @@ export class Graphor {
249
243
  if (value === null) {
250
244
  return `${encodeURIComponent(key)}=`;
251
245
  }
252
- throw new Errors.GraphorError(
246
+ throw new Errors.GraphorPrdError(
253
247
  `Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
254
248
  );
255
249
  })
@@ -515,7 +509,7 @@ export class Graphor {
515
509
  controller: AbortController,
516
510
  ): Promise<Response> {
517
511
  const { signal, method, ...options } = init || {};
518
- const abort = controller.abort.bind(controller);
512
+ const abort = this._makeAbort(controller);
519
513
  if (signal) signal.addEventListener('abort', abort, { once: true });
520
514
 
521
515
  const timeout = setTimeout(abort, ms);
@@ -685,6 +679,12 @@ export class Graphor {
685
679
  return headers.values;
686
680
  }
687
681
 
682
+ private _makeAbort(controller: AbortController) {
683
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
684
+ // would capture all request options, and cause a memory leak.
685
+ return () => controller.abort();
686
+ }
687
+
688
688
  private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
689
689
  bodyHeaders: HeadersLike;
690
690
  body: BodyInit | undefined;
@@ -722,10 +722,10 @@ export class Graphor {
722
722
  }
723
723
  }
724
724
 
725
- static Graphor = this;
725
+ static GraphorPrd = this;
726
726
  static DEFAULT_TIMEOUT = 60000; // 1 minute
727
727
 
728
- static GraphorError = Errors.GraphorError;
728
+ static GraphorPrdError = Errors.GraphorPrdError;
729
729
  static APIError = Errors.APIError;
730
730
  static APIConnectionError = Errors.APIConnectionError;
731
731
  static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
@@ -744,14 +744,14 @@ export class Graphor {
744
744
  sources: API.Sources = new API.Sources(this);
745
745
  }
746
746
 
747
- Graphor.Sources = Sources;
747
+ GraphorPrd.Sources = Sources;
748
748
 
749
- export declare namespace Graphor {
749
+ export declare namespace GraphorPrd {
750
750
  export type RequestOptions = Opts.RequestOptions;
751
751
 
752
752
  export {
753
753
  Sources as Sources,
754
- type PartitionMethod as PartitionMethod,
754
+ type PublicPartitionMethod as PublicPartitionMethod,
755
755
  type PublicSource as PublicSource,
756
756
  type SourceListResponse as SourceListResponse,
757
757
  type SourceDeleteResponse as SourceDeleteResponse,
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { type Graphor } from '../client';
3
+ import { type GraphorPrd } from '../client';
4
4
 
5
5
  import { type PromiseOrValue } from '../internal/types';
6
6
  import { APIResponseProps, defaultParseResponse } from '../internal/parse';
@@ -11,13 +11,13 @@ import { APIResponseProps, defaultParseResponse } from '../internal/parse';
11
11
  */
12
12
  export class APIPromise<T> extends Promise<T> {
13
13
  private parsedPromise: Promise<T> | undefined;
14
- #client: Graphor;
14
+ #client: GraphorPrd;
15
15
 
16
16
  constructor(
17
- client: Graphor,
17
+ client: GraphorPrd,
18
18
  private responsePromise: Promise<APIResponseProps>,
19
19
  private parseResponse: (
20
- client: Graphor,
20
+ client: GraphorPrd,
21
21
  props: APIResponseProps,
22
22
  ) => PromiseOrValue<T> = defaultParseResponse,
23
23
  ) {
package/src/core/error.ts CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  import { castToError } from '../internal/errors';
4
4
 
5
- export class GraphorError extends Error {}
5
+ export class GraphorPrdError extends Error {}
6
6
 
7
7
  export class APIError<
8
8
  TStatus extends number | undefined = number | undefined,
9
9
  THeaders extends Headers | undefined = Headers | undefined,
10
10
  TError extends Object | undefined = Object | undefined,
11
- > extends GraphorError {
11
+ > extends GraphorPrdError {
12
12
  /** HTTP status for the response that caused the error */
13
13
  readonly status: TStatus;
14
14
  /** HTTP headers for the response that caused the error */
@@ -1,11 +1,11 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import type { Graphor } from '../client';
3
+ import type { GraphorPrd } from '../client';
4
4
 
5
5
  export abstract class APIResource {
6
- protected _client: Graphor;
6
+ protected _client: GraphorPrd;
7
7
 
8
- constructor(client: Graphor) {
8
+ constructor(client: GraphorPrd) {
9
9
  this._client = client;
10
10
  }
11
11
  }
package/src/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { Graphor as default } from './client';
3
+ export { GraphorPrd as default } from './client';
4
4
 
5
5
  export { type Uploadable, toFile } from './core/uploads';
6
6
  export { APIPromise } from './core/api-promise';
7
- export { Graphor, type ClientOptions } from './client';
7
+ export { GraphorPrd, type ClientOptions } from './client';
8
8
  export {
9
- GraphorError,
9
+ GraphorPrdError,
10
10
  APIError,
11
11
  APIConnectionError,
12
12
  APIConnectionTimeoutError,
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import type { FinalRequestOptions } from './request-options';
4
- import { type Graphor } from '../client';
4
+ import { type GraphorPrd } from '../client';
5
5
  import { formatRequestDetails, loggerFor } from './utils/log';
6
6
 
7
7
  export type APIResponseProps = {
@@ -13,7 +13,7 @@ export type APIResponseProps = {
13
13
  startTime: number;
14
14
  };
15
15
 
16
- export async function defaultParseResponse<T>(client: Graphor, props: APIResponseProps): Promise<T> {
16
+ export async function defaultParseResponse<T>(client: GraphorPrd, props: APIResponseProps): Promise<T> {
17
17
  const { response, requestLogID, retryOfRequestLogID, startTime } = props;
18
18
  const body = await (async () => {
19
19
  // fetch refuses to read the body when the status code is 204.
@@ -16,7 +16,7 @@ export function getDefaultFetch(): Fetch {
16
16
  }
17
17
 
18
18
  throw new Error(
19
- '`fetch` is not defined as a global; Either pass `fetch` to the client, `new Graphor({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
19
+ '`fetch` is not defined as a global; Either pass `fetch` to the client, `new GraphorPrd({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
20
20
  );
21
21
  }
22
22
 
@@ -1,6 +1,6 @@
1
1
  import { type RequestOptions } from './request-options';
2
2
  import type { FilePropertyBag, Fetch } from './builtin-types';
3
- import type { Graphor } from '../client';
3
+ import type { GraphorPrd } from '../client';
4
4
  import { ReadableStreamFrom } from './shims';
5
5
 
6
6
  export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
@@ -74,7 +74,7 @@ export const isAsyncIterable = (value: any): value is AsyncIterable<any> =>
74
74
  */
75
75
  export const maybeMultipartFormRequestOptions = async (
76
76
  opts: RequestOptions,
77
- fetch: Graphor | Fetch,
77
+ fetch: GraphorPrd | Fetch,
78
78
  ): Promise<RequestOptions> => {
79
79
  if (!hasUploadableValue(opts.body)) return opts;
80
80
 
@@ -85,7 +85,7 @@ type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & { body: unknow
85
85
 
86
86
  export const multipartFormRequestOptions = async (
87
87
  opts: MultipartFormRequestOptions,
88
- fetch: Graphor | Fetch,
88
+ fetch: GraphorPrd | Fetch,
89
89
  ): Promise<RequestOptions> => {
90
90
  return { ...opts, body: await createForm(opts.body, fetch) };
91
91
  };
@@ -98,7 +98,7 @@ const supportsFormDataMap = /* @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>
98
98
  * This function detects if the fetch function provided supports the global FormData object to avoid
99
99
  * confusing error messages later on.
100
100
  */
101
- function supportsFormData(fetchObject: Graphor | Fetch): Promise<boolean> {
101
+ function supportsFormData(fetchObject: GraphorPrd | Fetch): Promise<boolean> {
102
102
  const fetch: Fetch = typeof fetchObject === 'function' ? fetchObject : (fetchObject as any).fetch;
103
103
  const cached = supportsFormDataMap.get(fetch);
104
104
  if (cached) return cached;
@@ -124,7 +124,7 @@ function supportsFormData(fetchObject: Graphor | Fetch): Promise<boolean> {
124
124
 
125
125
  export const createForm = async <T = Record<string, unknown>>(
126
126
  body: T | undefined,
127
- fetch: Graphor | Fetch,
127
+ fetch: GraphorPrd | Fetch,
128
128
  ): Promise<FormData> => {
129
129
  if (!(await supportsFormData(fetch))) {
130
130
  throw new TypeError(
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { GraphorError } from '../../core/error';
3
+ import { GraphorPrdError } from '../../core/error';
4
4
  import { encodeUTF8 } from './bytes';
5
5
 
6
6
  export const toBase64 = (data: string | Uint8Array | null | undefined): string => {
@@ -18,7 +18,7 @@ export const toBase64 = (data: string | Uint8Array | null | undefined): string =
18
18
  return btoa(String.fromCharCode.apply(null, data as any));
19
19
  }
20
20
 
21
- throw new GraphorError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
21
+ throw new GraphorPrdError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
22
22
  };
23
23
 
24
24
  export const fromBase64 = (str: string): Uint8Array => {
@@ -36,5 +36,5 @@ export const fromBase64 = (str: string): Uint8Array => {
36
36
  return buf;
37
37
  }
38
38
 
39
- throw new GraphorError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
39
+ throw new GraphorPrdError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
40
40
  };
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { hasOwn } from './values';
4
- import { type Graphor } from '../../client';
4
+ import { type GraphorPrd } from '../../client';
5
5
  import { RequestOptions } from '../request-options';
6
6
 
7
7
  type LogFn = (message: string, ...rest: unknown[]) => void;
@@ -24,7 +24,7 @@ const levelNumbers = {
24
24
  export const parseLogLevel = (
25
25
  maybeLevel: string | undefined,
26
26
  sourceName: string,
27
- client: Graphor,
27
+ client: GraphorPrd,
28
28
  ): LogLevel | undefined => {
29
29
  if (!maybeLevel) {
30
30
  return undefined;
@@ -60,7 +60,7 @@ const noopLogger = {
60
60
 
61
61
  let cachedLoggers = /* @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
62
62
 
63
- export function loggerFor(client: Graphor): Logger {
63
+ export function loggerFor(client: GraphorPrd): Logger {
64
64
  const logger = client.logger;
65
65
  const logLevel = client.logLevel ?? 'off';
66
66
  if (!logger) {
@@ -1,4 +1,4 @@
1
- import { GraphorError } from '../../core/error';
1
+ import { GraphorPrdError } from '../../core/error';
2
2
 
3
3
  /**
4
4
  * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
@@ -72,7 +72,7 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
72
72
  return acc + spaces + arrows;
73
73
  }, '');
74
74
 
75
- throw new GraphorError(
75
+ throw new GraphorPrdError(
76
76
  `Path parameters result in path with invalid segments:\n${invalidSegments
77
77
  .map((e) => e.error)
78
78
  .join('\n')}\n${path}\n${underline}`,
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { GraphorError } from '../../core/error';
3
+ import { GraphorPrdError } from '../../core/error';
4
4
 
5
5
  // https://url.spec.whatwg.org/#url-scheme-string
6
6
  const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
@@ -39,7 +39,7 @@ export function isObj(obj: unknown): obj is Record<string, unknown> {
39
39
 
40
40
  export const ensurePresent = <T>(value: T | null | undefined): T => {
41
41
  if (value == null) {
42
- throw new GraphorError(`Expected a value to be given but received ${value} instead.`);
42
+ throw new GraphorPrdError(`Expected a value to be given but received ${value} instead.`);
43
43
  }
44
44
 
45
45
  return value;
@@ -47,10 +47,10 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
47
47
 
48
48
  export const validatePositiveInteger = (name: string, n: unknown): number => {
49
49
  if (typeof n !== 'number' || !Number.isInteger(n)) {
50
- throw new GraphorError(`${name} must be an integer`);
50
+ throw new GraphorPrdError(`${name} must be an integer`);
51
51
  }
52
52
  if (n < 0) {
53
- throw new GraphorError(`${name} must be a positive integer`);
53
+ throw new GraphorPrdError(`${name} must be a positive integer`);
54
54
  }
55
55
  return n;
56
56
  };
@@ -59,14 +59,14 @@ export const coerceInteger = (value: unknown): number => {
59
59
  if (typeof value === 'number') return Math.round(value);
60
60
  if (typeof value === 'string') return parseInt(value, 10);
61
61
 
62
- throw new GraphorError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
62
+ throw new GraphorPrdError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
63
63
  };
64
64
 
65
65
  export const coerceFloat = (value: unknown): number => {
66
66
  if (typeof value === 'number') return value;
67
67
  if (typeof value === 'string') return parseFloat(value);
68
68
 
69
- throw new GraphorError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
69
+ throw new GraphorPrdError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
70
70
  };
71
71
 
72
72
  export const coerceBoolean = (value: unknown): boolean => {
@@ -2,7 +2,7 @@
2
2
 
3
3
  export {
4
4
  Sources,
5
- type PartitionMethod,
5
+ type PublicPartitionMethod,
6
6
  type PublicSource,
7
7
  type SourceListResponse,
8
8
  type SourceDeleteResponse,
@@ -106,15 +106,10 @@ export class Sources extends APIResource {
106
106
  }
107
107
  }
108
108
 
109
- export type PartitionMethod =
110
- | 'basic'
111
- | 'hi_res'
112
- | 'hi_res_ft'
113
- | 'mai'
114
- | 'graphorlm'
115
- | 'ocr'
116
- | 'advanced'
117
- | 'yolox';
109
+ /**
110
+ * Partition methods available for public API endpoints.
111
+ */
112
+ export type PublicPartitionMethod = 'basic' | 'hi_res' | 'hi_res_ft' | 'mai' | 'graphorlm';
118
113
 
119
114
  export interface PublicSource {
120
115
  file_name: string;
@@ -138,7 +133,16 @@ export interface PublicSource {
138
133
  */
139
134
  file_id?: string | null;
140
135
 
141
- partition_method?: PartitionMethod | null;
136
+ partition_method?:
137
+ | 'basic'
138
+ | 'hi_res'
139
+ | 'hi_res_ft'
140
+ | 'mai'
141
+ | 'graphorlm'
142
+ | 'ocr'
143
+ | 'advanced'
144
+ | 'yolox'
145
+ | null;
142
146
  }
143
147
 
144
148
  export type SourceListResponse = Array<PublicSource>;
@@ -471,7 +475,7 @@ export interface SourceParseParams {
471
475
  /**
472
476
  * The method used to partition the file
473
477
  */
474
- partition_method?: 'basic' | 'hi_res' | 'hi_res_ft' | 'mai' | 'graphorlm';
478
+ partition_method?: PublicPartitionMethod;
475
479
  }
476
480
 
477
481
  export interface SourceRetrieveChunksParams {
@@ -499,7 +503,7 @@ export interface SourceUploadParams {
499
503
  /**
500
504
  * Partition methods available for public API endpoints.
501
505
  */
502
- partition_method?: 'basic' | 'hi_res' | 'hi_res_ft' | 'mai' | 'graphorlm' | null;
506
+ partition_method?: PublicPartitionMethod | null;
503
507
  }
504
508
 
505
509
  export interface SourceUploadGitHubParams {
@@ -523,7 +527,7 @@ export interface SourceUploadURLParams {
523
527
  /**
524
528
  * Partition methods available for public API endpoints.
525
529
  */
526
- partition_method?: 'basic' | 'hi_res' | 'hi_res_ft' | 'mai' | 'graphorlm' | null;
530
+ partition_method?: PublicPartitionMethod | null;
527
531
  }
528
532
 
529
533
  export interface SourceUploadYoutubeParams {
@@ -535,7 +539,7 @@ export interface SourceUploadYoutubeParams {
535
539
 
536
540
  export declare namespace Sources {
537
541
  export {
538
- type PartitionMethod as PartitionMethod,
542
+ type PublicPartitionMethod as PublicPartitionMethod,
539
543
  type PublicSource as PublicSource,
540
544
  type SourceListResponse as SourceListResponse,
541
545
  type SourceDeleteResponse as SourceDeleteResponse,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.4.1'; // x-release-please-version
1
+ export const VERSION = '0.4.2'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.4.1";
1
+ export declare const VERSION = "0.4.2";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.4.1";
1
+ export declare const VERSION = "0.4.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.4.1'; // x-release-please-version
4
+ exports.VERSION = '0.4.2'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.4.1'; // x-release-please-version
1
+ export const VERSION = '0.4.2'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map