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.
- package/CHANGELOG.md +24 -44
- package/LICENSE +1 -1
- package/README.md +37 -33
- package/client.d.mts +16 -15
- package/client.d.mts.map +1 -1
- package/client.d.ts +16 -15
- package/client.d.ts.map +1 -1
- package/client.js +46 -47
- package/client.js.map +1 -1
- package/client.mjs +44 -45
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts +2 -2
- package/core/api-promise.d.ts.map +1 -1
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs.map +1 -1
- package/core/error.d.mts +2 -2
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +2 -2
- package/core/error.d.ts.map +1 -1
- package/core/error.js +4 -4
- package/core/error.js.map +1 -1
- package/core/error.mjs +2 -2
- package/core/error.mjs.map +1 -1
- package/core/resource.d.mts +3 -3
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts +3 -3
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs.map +1 -1
- package/index.d.mts +3 -3
- package/index.d.mts.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/index.mjs +3 -3
- package/index.mjs.map +1 -1
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +2 -2
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/shims.js +1 -1
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/shims.mjs.map +1 -1
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +4 -4
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +6 -6
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +3 -3
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/sources.d.mts +9 -6
- package/resources/sources.d.mts.map +1 -1
- package/resources/sources.d.ts +9 -6
- package/resources/sources.d.ts.map +1 -1
- package/src/client.ts +37 -37
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/resource.ts +3 -3
- package/src/index.ts +3 -3
- package/src/internal/parse.ts +2 -2
- package/src/internal/shims.ts +1 -1
- package/src/internal/uploads.ts +5 -5
- package/src/internal/utils/base64.ts +3 -3
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -2
- package/src/internal/utils/values.ts +6 -6
- package/src/resources/index.ts +1 -1
- package/src/resources/sources.ts +18 -14
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- 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
|
-
|
|
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['
|
|
55
|
+
* Defaults to process.env['GRAPHOR_PRD_API_KEY'].
|
|
56
56
|
*/
|
|
57
|
-
apiKey?: string |
|
|
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['
|
|
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['
|
|
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
|
|
132
|
-
apiKey: string
|
|
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 |
|
|
150
|
-
* @param {string} [opts.baseURL=process.env['
|
|
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('
|
|
160
|
-
apiKey = readEnv('
|
|
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://
|
|
172
|
+
baseURL: baseURL || `https://graphorlm.com/api/public/v1`,
|
|
167
173
|
};
|
|
168
174
|
|
|
169
175
|
this.baseURL = options.baseURL!;
|
|
170
|
-
this.timeout = options.timeout ??
|
|
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('
|
|
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://
|
|
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
|
-
|
|
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.
|
|
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 =
|
|
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
|
|
725
|
+
static GraphorPrd = this;
|
|
726
726
|
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
727
727
|
|
|
728
|
-
static
|
|
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
|
-
|
|
747
|
+
GraphorPrd.Sources = Sources;
|
|
748
748
|
|
|
749
|
-
export declare namespace
|
|
749
|
+
export declare namespace GraphorPrd {
|
|
750
750
|
export type RequestOptions = Opts.RequestOptions;
|
|
751
751
|
|
|
752
752
|
export {
|
|
753
753
|
Sources as Sources,
|
|
754
|
-
type
|
|
754
|
+
type PublicPartitionMethod as PublicPartitionMethod,
|
|
755
755
|
type PublicSource as PublicSource,
|
|
756
756
|
type SourceListResponse as SourceListResponse,
|
|
757
757
|
type SourceDeleteResponse as SourceDeleteResponse,
|
package/src/core/api-promise.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { type
|
|
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:
|
|
14
|
+
#client: GraphorPrd;
|
|
15
15
|
|
|
16
16
|
constructor(
|
|
17
|
-
client:
|
|
17
|
+
client: GraphorPrd,
|
|
18
18
|
private responsePromise: Promise<APIResponseProps>,
|
|
19
19
|
private parseResponse: (
|
|
20
|
-
client:
|
|
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
|
|
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
|
|
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 */
|
package/src/core/resource.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { GraphorPrd } from '../client';
|
|
4
4
|
|
|
5
5
|
export abstract class APIResource {
|
|
6
|
-
protected _client:
|
|
6
|
+
protected _client: GraphorPrd;
|
|
7
7
|
|
|
8
|
-
constructor(client:
|
|
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 {
|
|
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 {
|
|
7
|
+
export { GraphorPrd, type ClientOptions } from './client';
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
GraphorPrdError,
|
|
10
10
|
APIError,
|
|
11
11
|
APIConnectionError,
|
|
12
12
|
APIConnectionTimeoutError,
|
package/src/internal/parse.ts
CHANGED
|
@@ -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
|
|
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:
|
|
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.
|
package/src/internal/shims.ts
CHANGED
|
@@ -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
|
|
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
|
|
package/src/internal/uploads.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RequestOptions } from './request-options';
|
|
2
2
|
import type { FilePropertyBag, Fetch } from './builtin-types';
|
|
3
|
-
import type {
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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 {
|
|
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
|
|
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 {
|
|
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
|
|
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
|
|
50
|
+
throw new GraphorPrdError(`${name} must be an integer`);
|
|
51
51
|
}
|
|
52
52
|
if (n < 0) {
|
|
53
|
-
throw new
|
|
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
|
|
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
|
|
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 => {
|
package/src/resources/index.ts
CHANGED
package/src/resources/sources.ts
CHANGED
|
@@ -106,15 +106,10 @@ export class Sources extends APIResource {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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
|
|
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
|
+
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
|
+
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
|
+
export declare const VERSION = "0.4.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.4.
|
|
1
|
+
export const VERSION = '0.4.2'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|