notdiamond 2.0.0 → 2.1.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.
- package/CHANGELOG.md +14 -0
- package/README.md +17 -17
- package/client.d.mts +4 -4
- package/client.d.ts +4 -4
- package/client.js +32 -32
- package/client.mjs +30 -30
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.ts +2 -2
- package/core/error.d.mts +2 -2
- package/core/error.d.ts +2 -2
- package/core/error.js +4 -4
- package/core/error.mjs +2 -2
- package/core/resource.d.mts +3 -3
- package/core/resource.d.ts +3 -3
- package/index.d.mts +3 -3
- package/index.d.ts +3 -3
- package/index.js +4 -4
- package/index.mjs +3 -3
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.ts +2 -2
- package/internal/shims.js +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.ts +4 -4
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.mjs +6 -6
- package/package.json +1 -1
- package/resources/prompt-adaptation.d.mts +9 -6
- package/resources/prompt-adaptation.d.mts.map +1 -1
- package/resources/prompt-adaptation.d.ts +9 -6
- package/resources/prompt-adaptation.d.ts.map +1 -1
- package/src/client.ts +12 -12
- 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/prompt-adaptation.ts +7 -4
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0 (2025-12-16)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v2.0.0...v2.1.0](https://github.com/Not-Diamond/not-diamond-typescript/compare/v2.0.0...v2.1.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([cd722d2](https://github.com/Not-Diamond/not-diamond-typescript/commit/cd722d21da6b084a46e14605f8a698e33eb8b09e))
|
|
10
|
+
* **api:** api update ([70574af](https://github.com/Not-Diamond/not-diamond-typescript/commit/70574afebdb651cdf004f4a7c223b20d6141dcf3))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Chores
|
|
14
|
+
|
|
15
|
+
* **api:** changed default client name to NotDiamond ([6a57ccd](https://github.com/Not-Diamond/not-diamond-typescript/commit/6a57ccd9b266ba6da66e78601bca315fda58da08))
|
|
16
|
+
|
|
3
17
|
## 2.0.0 (2025-12-08)
|
|
4
18
|
|
|
5
19
|
Full Changelog: [v2.0.0-rc21...v2.0.0](https://github.com/Not-Diamond/not-diamond-typescript/compare/v2.0.0-rc21...v2.0.0)
|
package/README.md
CHANGED
|
@@ -312,7 +312,7 @@ Requests time out after 1 minute by default. You can configure this with a `time
|
|
|
312
312
|
<!-- prettier-ignore -->
|
|
313
313
|
```ts
|
|
314
314
|
// Configure the default for all requests:
|
|
315
|
-
const client = new
|
|
315
|
+
const client = new NotDiamond({
|
|
316
316
|
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
|
|
317
317
|
});
|
|
318
318
|
|
|
@@ -338,7 +338,7 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
|
|
|
338
338
|
|
|
339
339
|
<!-- prettier-ignore -->
|
|
340
340
|
```ts
|
|
341
|
-
const client = new
|
|
341
|
+
const client = new NotDiamond();
|
|
342
342
|
|
|
343
343
|
const response = await client.prompt.adapt
|
|
344
344
|
.create({
|
|
@@ -409,9 +409,9 @@ The log level can be configured in two ways:
|
|
|
409
409
|
2. Using the `logLevel` client option (overrides the environment variable if set)
|
|
410
410
|
|
|
411
411
|
```ts
|
|
412
|
-
import
|
|
412
|
+
import NotDiamond from 'notdiamond';
|
|
413
413
|
|
|
414
|
-
const client = new
|
|
414
|
+
const client = new NotDiamond({
|
|
415
415
|
logLevel: 'debug', // Show all log messages
|
|
416
416
|
});
|
|
417
417
|
```
|
|
@@ -437,13 +437,13 @@ When providing a custom logger, the `logLevel` option still controls which messa
|
|
|
437
437
|
below the configured level will not be sent to your logger.
|
|
438
438
|
|
|
439
439
|
```ts
|
|
440
|
-
import
|
|
440
|
+
import NotDiamond from 'notdiamond';
|
|
441
441
|
import pino from 'pino';
|
|
442
442
|
|
|
443
443
|
const logger = pino();
|
|
444
444
|
|
|
445
|
-
const client = new
|
|
446
|
-
logger: logger.child({ name: '
|
|
445
|
+
const client = new NotDiamond({
|
|
446
|
+
logger: logger.child({ name: 'NotDiamond' }),
|
|
447
447
|
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
448
448
|
});
|
|
449
449
|
```
|
|
@@ -510,10 +510,10 @@ globalThis.fetch = fetch;
|
|
|
510
510
|
Or pass it to the client:
|
|
511
511
|
|
|
512
512
|
```ts
|
|
513
|
-
import
|
|
513
|
+
import NotDiamond from 'notdiamond';
|
|
514
514
|
import fetch from 'my-fetch';
|
|
515
515
|
|
|
516
|
-
const client = new
|
|
516
|
+
const client = new NotDiamond({ fetch });
|
|
517
517
|
```
|
|
518
518
|
|
|
519
519
|
### Fetch options
|
|
@@ -521,9 +521,9 @@ const client = new Notdiamond({ fetch });
|
|
|
521
521
|
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
|
|
522
522
|
|
|
523
523
|
```ts
|
|
524
|
-
import
|
|
524
|
+
import NotDiamond from 'notdiamond';
|
|
525
525
|
|
|
526
|
-
const client = new
|
|
526
|
+
const client = new NotDiamond({
|
|
527
527
|
fetchOptions: {
|
|
528
528
|
// `RequestInit` options
|
|
529
529
|
},
|
|
@@ -538,11 +538,11 @@ options to requests:
|
|
|
538
538
|
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
|
|
539
539
|
|
|
540
540
|
```ts
|
|
541
|
-
import
|
|
541
|
+
import NotDiamond from 'notdiamond';
|
|
542
542
|
import * as undici from 'undici';
|
|
543
543
|
|
|
544
544
|
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
|
545
|
-
const client = new
|
|
545
|
+
const client = new NotDiamond({
|
|
546
546
|
fetchOptions: {
|
|
547
547
|
dispatcher: proxyAgent,
|
|
548
548
|
},
|
|
@@ -552,9 +552,9 @@ const client = new Notdiamond({
|
|
|
552
552
|
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
|
|
553
553
|
|
|
554
554
|
```ts
|
|
555
|
-
import
|
|
555
|
+
import NotDiamond from 'notdiamond';
|
|
556
556
|
|
|
557
|
-
const client = new
|
|
557
|
+
const client = new NotDiamond({
|
|
558
558
|
fetchOptions: {
|
|
559
559
|
proxy: 'http://localhost:8888',
|
|
560
560
|
},
|
|
@@ -564,10 +564,10 @@ const client = new Notdiamond({
|
|
|
564
564
|
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
|
|
565
565
|
|
|
566
566
|
```ts
|
|
567
|
-
import
|
|
567
|
+
import NotDiamond from 'npm:notdiamond';
|
|
568
568
|
|
|
569
569
|
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
|
|
570
|
-
const client = new
|
|
570
|
+
const client = new NotDiamond({
|
|
571
571
|
fetchOptions: {
|
|
572
572
|
client: httpClient,
|
|
573
573
|
},
|
package/client.d.mts
CHANGED
|
@@ -84,7 +84,7 @@ export interface ClientOptions {
|
|
|
84
84
|
/**
|
|
85
85
|
* API Client for interfacing with the Notdiamond API.
|
|
86
86
|
*/
|
|
87
|
-
export declare class
|
|
87
|
+
export declare class NotDiamond {
|
|
88
88
|
#private;
|
|
89
89
|
apiKey: string;
|
|
90
90
|
baseURL: string;
|
|
@@ -156,9 +156,9 @@ export declare class Notdiamond {
|
|
|
156
156
|
}>;
|
|
157
157
|
private buildHeaders;
|
|
158
158
|
private buildBody;
|
|
159
|
-
static
|
|
159
|
+
static NotDiamond: typeof NotDiamond;
|
|
160
160
|
static DEFAULT_TIMEOUT: number;
|
|
161
|
-
static
|
|
161
|
+
static NotDiamondError: typeof Errors.NotDiamondError;
|
|
162
162
|
static APIError: typeof Errors.APIError;
|
|
163
163
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
164
164
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -178,7 +178,7 @@ export declare class Notdiamond {
|
|
|
178
178
|
customRouter: API.CustomRouter;
|
|
179
179
|
models: API.Models;
|
|
180
180
|
}
|
|
181
|
-
export declare namespace
|
|
181
|
+
export declare namespace NotDiamond {
|
|
182
182
|
export type RequestOptions = Opts.RequestOptions;
|
|
183
183
|
export { ModelRouter as ModelRouter, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
184
184
|
export { Preferences as Preferences, type PreferenceCreateResponse as PreferenceCreateResponse, type PreferenceUpdateResponse as PreferenceUpdateResponse, type PreferenceDeleteResponse as PreferenceDeleteResponse, type PreferenceCreateParams as PreferenceCreateParams, type PreferenceUpdateParams as PreferenceUpdateParams, };
|
package/client.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export interface ClientOptions {
|
|
|
84
84
|
/**
|
|
85
85
|
* API Client for interfacing with the Notdiamond API.
|
|
86
86
|
*/
|
|
87
|
-
export declare class
|
|
87
|
+
export declare class NotDiamond {
|
|
88
88
|
#private;
|
|
89
89
|
apiKey: string;
|
|
90
90
|
baseURL: string;
|
|
@@ -156,9 +156,9 @@ export declare class Notdiamond {
|
|
|
156
156
|
}>;
|
|
157
157
|
private buildHeaders;
|
|
158
158
|
private buildBody;
|
|
159
|
-
static
|
|
159
|
+
static NotDiamond: typeof NotDiamond;
|
|
160
160
|
static DEFAULT_TIMEOUT: number;
|
|
161
|
-
static
|
|
161
|
+
static NotDiamondError: typeof Errors.NotDiamondError;
|
|
162
162
|
static APIError: typeof Errors.APIError;
|
|
163
163
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
164
164
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -178,7 +178,7 @@ export declare class Notdiamond {
|
|
|
178
178
|
customRouter: API.CustomRouter;
|
|
179
179
|
models: API.Models;
|
|
180
180
|
}
|
|
181
|
-
export declare namespace
|
|
181
|
+
export declare namespace NotDiamond {
|
|
182
182
|
export type RequestOptions = Opts.RequestOptions;
|
|
183
183
|
export { ModelRouter as ModelRouter, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
184
184
|
export { Preferences as Preferences, type PreferenceCreateResponse as PreferenceCreateResponse, type PreferenceUpdateResponse as PreferenceUpdateResponse, type PreferenceDeleteResponse as PreferenceDeleteResponse, type PreferenceCreateParams as PreferenceCreateParams, type PreferenceUpdateParams as PreferenceUpdateParams, };
|
package/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
var
|
|
3
|
+
var _NotDiamond_instances, _a, _NotDiamond_encoder, _NotDiamond_baseURLOverridden;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
5
|
+
exports.NotDiamond = void 0;
|
|
6
6
|
const tslib_1 = require("./internal/tslib.js");
|
|
7
7
|
const uuid_1 = require("./internal/utils/uuid.js");
|
|
8
8
|
const values_1 = require("./internal/utils/values.js");
|
|
@@ -29,7 +29,7 @@ const values_2 = require("./internal/utils/values.js");
|
|
|
29
29
|
/**
|
|
30
30
|
* API Client for interfacing with the Notdiamond API.
|
|
31
31
|
*/
|
|
32
|
-
class
|
|
32
|
+
class NotDiamond {
|
|
33
33
|
/**
|
|
34
34
|
* API Client for interfacing with the Notdiamond API.
|
|
35
35
|
*
|
|
@@ -43,15 +43,15 @@ class Notdiamond {
|
|
|
43
43
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
44
44
|
*/
|
|
45
45
|
constructor({ baseURL = (0, env_1.readEnv)('NOTDIAMOND_BASE_URL'), apiKey = (0, env_1.readEnv)('NOT_DIAMOND_API_KEY'), ...opts } = {}) {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
_NotDiamond_instances.add(this);
|
|
47
|
+
_NotDiamond_encoder.set(this, void 0);
|
|
48
48
|
this.modelRouter = new API.ModelRouter(this);
|
|
49
49
|
this.preferences = new API.Preferences(this);
|
|
50
50
|
this.promptAdaptation = new API.PromptAdaptation(this);
|
|
51
51
|
this.customRouter = new API.CustomRouter(this);
|
|
52
52
|
this.models = new API.Models(this);
|
|
53
53
|
if (apiKey === undefined) {
|
|
54
|
-
throw new Errors.
|
|
54
|
+
throw new Errors.NotDiamondError("The NOT_DIAMOND_API_KEY environment variable is missing or empty; either provide it, or instantiate the NotDiamond client with an apiKey option, like new NotDiamond({ apiKey: 'My API Key' }).");
|
|
55
55
|
}
|
|
56
56
|
const options = {
|
|
57
57
|
apiKey,
|
|
@@ -71,7 +71,7 @@ class Notdiamond {
|
|
|
71
71
|
this.fetchOptions = options.fetchOptions;
|
|
72
72
|
this.maxRetries = options.maxRetries ?? 2;
|
|
73
73
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
74
|
-
tslib_1.__classPrivateFieldSet(this,
|
|
74
|
+
tslib_1.__classPrivateFieldSet(this, _NotDiamond_encoder, Opts.FallbackEncoder, "f");
|
|
75
75
|
this._options = options;
|
|
76
76
|
this.apiKey = apiKey;
|
|
77
77
|
}
|
|
@@ -115,7 +115,7 @@ class Notdiamond {
|
|
|
115
115
|
return Errors.APIError.generate(status, error, message, headers);
|
|
116
116
|
}
|
|
117
117
|
buildURL(path, query, defaultBaseURL) {
|
|
118
|
-
const baseURL = (!tslib_1.__classPrivateFieldGet(this,
|
|
118
|
+
const baseURL = (!tslib_1.__classPrivateFieldGet(this, _NotDiamond_instances, "m", _NotDiamond_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
119
119
|
const url = (0, values_1.isAbsoluteURL)(path) ?
|
|
120
120
|
new URL(path)
|
|
121
121
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
@@ -428,33 +428,33 @@ class Notdiamond {
|
|
|
428
428
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
|
|
429
429
|
}
|
|
430
430
|
else {
|
|
431
|
-
return tslib_1.__classPrivateFieldGet(this,
|
|
431
|
+
return tslib_1.__classPrivateFieldGet(this, _NotDiamond_encoder, "f").call(this, { body, headers });
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
exports.
|
|
436
|
-
_a =
|
|
435
|
+
exports.NotDiamond = NotDiamond;
|
|
436
|
+
_a = NotDiamond, _NotDiamond_encoder = new WeakMap(), _NotDiamond_instances = new WeakSet(), _NotDiamond_baseURLOverridden = function _NotDiamond_baseURLOverridden() {
|
|
437
437
|
return this.baseURL !== 'https://api.notdiamond.ai';
|
|
438
438
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
439
|
+
NotDiamond.NotDiamond = _a;
|
|
440
|
+
NotDiamond.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
441
|
+
NotDiamond.NotDiamondError = Errors.NotDiamondError;
|
|
442
|
+
NotDiamond.APIError = Errors.APIError;
|
|
443
|
+
NotDiamond.APIConnectionError = Errors.APIConnectionError;
|
|
444
|
+
NotDiamond.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
445
|
+
NotDiamond.APIUserAbortError = Errors.APIUserAbortError;
|
|
446
|
+
NotDiamond.NotFoundError = Errors.NotFoundError;
|
|
447
|
+
NotDiamond.ConflictError = Errors.ConflictError;
|
|
448
|
+
NotDiamond.RateLimitError = Errors.RateLimitError;
|
|
449
|
+
NotDiamond.BadRequestError = Errors.BadRequestError;
|
|
450
|
+
NotDiamond.AuthenticationError = Errors.AuthenticationError;
|
|
451
|
+
NotDiamond.InternalServerError = Errors.InternalServerError;
|
|
452
|
+
NotDiamond.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
453
|
+
NotDiamond.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
454
|
+
NotDiamond.toFile = Uploads.toFile;
|
|
455
|
+
NotDiamond.ModelRouter = model_router_1.ModelRouter;
|
|
456
|
+
NotDiamond.Preferences = preferences_1.Preferences;
|
|
457
|
+
NotDiamond.PromptAdaptation = prompt_adaptation_1.PromptAdaptation;
|
|
458
|
+
NotDiamond.CustomRouter = custom_router_1.CustomRouter;
|
|
459
|
+
NotDiamond.Models = models_1.Models;
|
|
460
460
|
//# sourceMappingURL=client.js.map
|
package/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
var
|
|
2
|
+
var _NotDiamond_instances, _a, _NotDiamond_encoder, _NotDiamond_baseURLOverridden;
|
|
3
3
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "./internal/tslib.mjs";
|
|
4
4
|
import { uuid4 } from "./internal/utils/uuid.mjs";
|
|
5
5
|
import { validatePositiveInteger, isAbsoluteURL, safeJSON } from "./internal/utils/values.mjs";
|
|
@@ -26,7 +26,7 @@ import { isEmptyObj } from "./internal/utils/values.mjs";
|
|
|
26
26
|
/**
|
|
27
27
|
* API Client for interfacing with the Notdiamond API.
|
|
28
28
|
*/
|
|
29
|
-
export class
|
|
29
|
+
export class NotDiamond {
|
|
30
30
|
/**
|
|
31
31
|
* API Client for interfacing with the Notdiamond API.
|
|
32
32
|
*
|
|
@@ -40,15 +40,15 @@ export class Notdiamond {
|
|
|
40
40
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
41
41
|
*/
|
|
42
42
|
constructor({ baseURL = readEnv('NOTDIAMOND_BASE_URL'), apiKey = readEnv('NOT_DIAMOND_API_KEY'), ...opts } = {}) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
_NotDiamond_instances.add(this);
|
|
44
|
+
_NotDiamond_encoder.set(this, void 0);
|
|
45
45
|
this.modelRouter = new API.ModelRouter(this);
|
|
46
46
|
this.preferences = new API.Preferences(this);
|
|
47
47
|
this.promptAdaptation = new API.PromptAdaptation(this);
|
|
48
48
|
this.customRouter = new API.CustomRouter(this);
|
|
49
49
|
this.models = new API.Models(this);
|
|
50
50
|
if (apiKey === undefined) {
|
|
51
|
-
throw new Errors.
|
|
51
|
+
throw new Errors.NotDiamondError("The NOT_DIAMOND_API_KEY environment variable is missing or empty; either provide it, or instantiate the NotDiamond client with an apiKey option, like new NotDiamond({ apiKey: 'My API Key' }).");
|
|
52
52
|
}
|
|
53
53
|
const options = {
|
|
54
54
|
apiKey,
|
|
@@ -68,7 +68,7 @@ export class Notdiamond {
|
|
|
68
68
|
this.fetchOptions = options.fetchOptions;
|
|
69
69
|
this.maxRetries = options.maxRetries ?? 2;
|
|
70
70
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
71
|
-
__classPrivateFieldSet(this,
|
|
71
|
+
__classPrivateFieldSet(this, _NotDiamond_encoder, Opts.FallbackEncoder, "f");
|
|
72
72
|
this._options = options;
|
|
73
73
|
this.apiKey = apiKey;
|
|
74
74
|
}
|
|
@@ -112,7 +112,7 @@ export class Notdiamond {
|
|
|
112
112
|
return Errors.APIError.generate(status, error, message, headers);
|
|
113
113
|
}
|
|
114
114
|
buildURL(path, query, defaultBaseURL) {
|
|
115
|
-
const baseURL = (!__classPrivateFieldGet(this,
|
|
115
|
+
const baseURL = (!__classPrivateFieldGet(this, _NotDiamond_instances, "m", _NotDiamond_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
116
116
|
const url = isAbsoluteURL(path) ?
|
|
117
117
|
new URL(path)
|
|
118
118
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
@@ -425,32 +425,32 @@ export class Notdiamond {
|
|
|
425
425
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
|
|
426
426
|
}
|
|
427
427
|
else {
|
|
428
|
-
return __classPrivateFieldGet(this,
|
|
428
|
+
return __classPrivateFieldGet(this, _NotDiamond_encoder, "f").call(this, { body, headers });
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
_a =
|
|
432
|
+
_a = NotDiamond, _NotDiamond_encoder = new WeakMap(), _NotDiamond_instances = new WeakSet(), _NotDiamond_baseURLOverridden = function _NotDiamond_baseURLOverridden() {
|
|
433
433
|
return this.baseURL !== 'https://api.notdiamond.ai';
|
|
434
434
|
};
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
435
|
+
NotDiamond.NotDiamond = _a;
|
|
436
|
+
NotDiamond.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
437
|
+
NotDiamond.NotDiamondError = Errors.NotDiamondError;
|
|
438
|
+
NotDiamond.APIError = Errors.APIError;
|
|
439
|
+
NotDiamond.APIConnectionError = Errors.APIConnectionError;
|
|
440
|
+
NotDiamond.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
441
|
+
NotDiamond.APIUserAbortError = Errors.APIUserAbortError;
|
|
442
|
+
NotDiamond.NotFoundError = Errors.NotFoundError;
|
|
443
|
+
NotDiamond.ConflictError = Errors.ConflictError;
|
|
444
|
+
NotDiamond.RateLimitError = Errors.RateLimitError;
|
|
445
|
+
NotDiamond.BadRequestError = Errors.BadRequestError;
|
|
446
|
+
NotDiamond.AuthenticationError = Errors.AuthenticationError;
|
|
447
|
+
NotDiamond.InternalServerError = Errors.InternalServerError;
|
|
448
|
+
NotDiamond.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
449
|
+
NotDiamond.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
450
|
+
NotDiamond.toFile = Uploads.toFile;
|
|
451
|
+
NotDiamond.ModelRouter = ModelRouter;
|
|
452
|
+
NotDiamond.Preferences = Preferences;
|
|
453
|
+
NotDiamond.PromptAdaptation = PromptAdaptation;
|
|
454
|
+
NotDiamond.CustomRouter = CustomRouter;
|
|
455
|
+
NotDiamond.Models = Models;
|
|
456
456
|
//# sourceMappingURL=client.mjs.map
|
package/core/api-promise.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type NotDiamond } from "../client.mjs";
|
|
2
2
|
import { type PromiseOrValue } from "../internal/types.mjs";
|
|
3
3
|
import { APIResponseProps } from "../internal/parse.mjs";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export declare class APIPromise<T> extends Promise<T> {
|
|
|
10
10
|
private responsePromise;
|
|
11
11
|
private parseResponse;
|
|
12
12
|
private parsedPromise;
|
|
13
|
-
constructor(client:
|
|
13
|
+
constructor(client: NotDiamond, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: NotDiamond, props: APIResponseProps) => PromiseOrValue<T>);
|
|
14
14
|
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
|
|
15
15
|
/**
|
|
16
16
|
* Gets the raw `Response` instance instead of parsing the response
|
package/core/api-promise.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type NotDiamond } from "../client.js";
|
|
2
2
|
import { type PromiseOrValue } from "../internal/types.js";
|
|
3
3
|
import { APIResponseProps } from "../internal/parse.js";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export declare class APIPromise<T> extends Promise<T> {
|
|
|
10
10
|
private responsePromise;
|
|
11
11
|
private parseResponse;
|
|
12
12
|
private parsedPromise;
|
|
13
|
-
constructor(client:
|
|
13
|
+
constructor(client: NotDiamond, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: NotDiamond, props: APIResponseProps) => PromiseOrValue<T>);
|
|
14
14
|
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
|
|
15
15
|
/**
|
|
16
16
|
* Gets the raw `Response` instance instead of parsing the response
|
package/core/error.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class NotDiamondError extends Error {
|
|
2
2
|
}
|
|
3
|
-
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends
|
|
3
|
+
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends NotDiamondError {
|
|
4
4
|
/** HTTP status for the response that caused the error */
|
|
5
5
|
readonly status: TStatus;
|
|
6
6
|
/** HTTP headers for the response that caused the error */
|
package/core/error.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class NotDiamondError extends Error {
|
|
2
2
|
}
|
|
3
|
-
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends
|
|
3
|
+
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends NotDiamondError {
|
|
4
4
|
/** HTTP status for the response that caused the error */
|
|
5
5
|
readonly status: TStatus;
|
|
6
6
|
/** HTTP headers for the response that caused the error */
|
package/core/error.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.BadRequestError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIUserAbortError = exports.APIError = exports.
|
|
4
|
+
exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.BadRequestError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIUserAbortError = exports.APIError = exports.NotDiamondError = void 0;
|
|
5
5
|
const errors_1 = require("../internal/errors.js");
|
|
6
|
-
class
|
|
6
|
+
class NotDiamondError extends Error {
|
|
7
7
|
}
|
|
8
|
-
exports.
|
|
9
|
-
class APIError extends
|
|
8
|
+
exports.NotDiamondError = NotDiamondError;
|
|
9
|
+
class APIError extends NotDiamondError {
|
|
10
10
|
constructor(status, error, message, headers) {
|
|
11
11
|
super(`${APIError.makeMessage(status, error, message)}`);
|
|
12
12
|
this.status = status;
|
package/core/error.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { castToError } from "../internal/errors.mjs";
|
|
3
|
-
export class
|
|
3
|
+
export class NotDiamondError extends Error {
|
|
4
4
|
}
|
|
5
|
-
export class APIError extends
|
|
5
|
+
export class APIError extends NotDiamondError {
|
|
6
6
|
constructor(status, error, message, headers) {
|
|
7
7
|
super(`${APIError.makeMessage(status, error, message)}`);
|
|
8
8
|
this.status = status;
|
package/core/resource.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NotDiamond } from "../client.mjs";
|
|
2
2
|
export declare abstract class APIResource {
|
|
3
|
-
protected _client:
|
|
4
|
-
constructor(client:
|
|
3
|
+
protected _client: NotDiamond;
|
|
4
|
+
constructor(client: NotDiamond);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=resource.d.mts.map
|
package/core/resource.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NotDiamond } from "../client.js";
|
|
2
2
|
export declare abstract class APIResource {
|
|
3
|
-
protected _client:
|
|
4
|
-
constructor(client:
|
|
3
|
+
protected _client: NotDiamond;
|
|
4
|
+
constructor(client: NotDiamond);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=resource.d.ts.map
|
package/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { NotDiamond as default } from "./client.mjs";
|
|
2
2
|
export { type Uploadable, toFile } from "./core/uploads.mjs";
|
|
3
3
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { NotDiamond, type ClientOptions } from "./client.mjs";
|
|
5
|
+
export { NotDiamondError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
|
6
6
|
//# sourceMappingURL=index.d.mts.map
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { NotDiamond as default } from "./client.js";
|
|
2
2
|
export { type Uploadable, toFile } from "./core/uploads.js";
|
|
3
3
|
export { APIPromise } from "./core/api-promise.js";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { NotDiamond, type ClientOptions } from "./client.js";
|
|
5
|
+
export { NotDiamondError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -4,17 +4,17 @@ exports = module.exports = function (...args) {
|
|
|
4
4
|
return new exports.default(...args)
|
|
5
5
|
}
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.
|
|
7
|
+
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.NotDiamondError = exports.NotDiamond = exports.APIPromise = exports.toFile = exports.default = void 0;
|
|
8
8
|
var client_1 = require("./client.js");
|
|
9
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.
|
|
9
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.NotDiamond; } });
|
|
10
10
|
var uploads_1 = require("./core/uploads.js");
|
|
11
11
|
Object.defineProperty(exports, "toFile", { enumerable: true, get: function () { return uploads_1.toFile; } });
|
|
12
12
|
var api_promise_1 = require("./core/api-promise.js");
|
|
13
13
|
Object.defineProperty(exports, "APIPromise", { enumerable: true, get: function () { return api_promise_1.APIPromise; } });
|
|
14
14
|
var client_2 = require("./client.js");
|
|
15
|
-
Object.defineProperty(exports, "
|
|
15
|
+
Object.defineProperty(exports, "NotDiamond", { enumerable: true, get: function () { return client_2.NotDiamond; } });
|
|
16
16
|
var error_1 = require("./core/error.js");
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "NotDiamondError", { enumerable: true, get: function () { return error_1.NotDiamondError; } });
|
|
18
18
|
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return error_1.APIError; } });
|
|
19
19
|
Object.defineProperty(exports, "APIConnectionError", { enumerable: true, get: function () { return error_1.APIConnectionError; } });
|
|
20
20
|
Object.defineProperty(exports, "APIConnectionTimeoutError", { enumerable: true, get: function () { return error_1.APIConnectionTimeoutError; } });
|
package/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
export {
|
|
2
|
+
export { NotDiamond as default } from "./client.mjs";
|
|
3
3
|
export { toFile } from "./core/uploads.mjs";
|
|
4
4
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { NotDiamond } from "./client.mjs";
|
|
6
|
+
export { NotDiamondError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
|
7
7
|
//# sourceMappingURL=index.mjs.map
|
package/internal/parse.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FinalRequestOptions } from "./request-options.mjs";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NotDiamond } from "../client.mjs";
|
|
3
3
|
export type APIResponseProps = {
|
|
4
4
|
response: Response;
|
|
5
5
|
options: FinalRequestOptions;
|
|
@@ -8,5 +8,5 @@ export type APIResponseProps = {
|
|
|
8
8
|
retryOfRequestLogID: string | undefined;
|
|
9
9
|
startTime: number;
|
|
10
10
|
};
|
|
11
|
-
export declare function defaultParseResponse<T>(client:
|
|
11
|
+
export declare function defaultParseResponse<T>(client: NotDiamond, props: APIResponseProps): Promise<T>;
|
|
12
12
|
//# sourceMappingURL=parse.d.mts.map
|
package/internal/parse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FinalRequestOptions } from "./request-options.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NotDiamond } from "../client.js";
|
|
3
3
|
export type APIResponseProps = {
|
|
4
4
|
response: Response;
|
|
5
5
|
options: FinalRequestOptions;
|
|
@@ -8,5 +8,5 @@ export type APIResponseProps = {
|
|
|
8
8
|
retryOfRequestLogID: string | undefined;
|
|
9
9
|
startTime: number;
|
|
10
10
|
};
|
|
11
|
-
export declare function defaultParseResponse<T>(client:
|
|
11
|
+
export declare function defaultParseResponse<T>(client: NotDiamond, props: APIResponseProps): Promise<T>;
|
|
12
12
|
//# sourceMappingURL=parse.d.ts.map
|
package/internal/shims.js
CHANGED
|
@@ -10,7 +10,7 @@ function getDefaultFetch() {
|
|
|
10
10
|
if (typeof fetch !== 'undefined') {
|
|
11
11
|
return fetch;
|
|
12
12
|
}
|
|
13
|
-
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new
|
|
13
|
+
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new NotDiamond({ fetch })` or polyfill the global, `globalThis.fetch = fetch`');
|
|
14
14
|
}
|
|
15
15
|
function makeReadableStream(...args) {
|
|
16
16
|
const ReadableStream = globalThis.ReadableStream;
|
package/internal/shims.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export function getDefaultFetch() {
|
|
|
3
3
|
if (typeof fetch !== 'undefined') {
|
|
4
4
|
return fetch;
|
|
5
5
|
}
|
|
6
|
-
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new
|
|
6
|
+
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new NotDiamond({ fetch })` or polyfill the global, `globalThis.fetch = fetch`');
|
|
7
7
|
}
|
|
8
8
|
export function makeReadableStream(...args) {
|
|
9
9
|
const ReadableStream = globalThis.ReadableStream;
|