notdiamond 2.0.0-rc4 → 2.0.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 (181) hide show
  1. package/CHANGELOG.md +164 -0
  2. package/LICENSE +1 -1
  3. package/README.md +294 -166
  4. package/client.d.mts +20 -23
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +20 -23
  7. package/client.d.ts.map +1 -1
  8. package/client.js +43 -46
  9. package/client.js.map +1 -1
  10. package/client.mjs +41 -44
  11. package/client.mjs.map +1 -1
  12. package/core/api-promise.d.mts +2 -2
  13. package/core/api-promise.d.ts +2 -2
  14. package/core/error.d.mts +2 -2
  15. package/core/error.d.ts +2 -2
  16. package/core/error.js +4 -4
  17. package/core/error.mjs +2 -2
  18. package/core/resource.d.mts +3 -3
  19. package/core/resource.d.ts +3 -3
  20. package/index.d.mts +3 -3
  21. package/index.d.ts +3 -3
  22. package/index.js +4 -4
  23. package/index.mjs +3 -3
  24. package/internal/parse.d.mts +2 -2
  25. package/internal/parse.d.ts +2 -2
  26. package/internal/shims.js +1 -1
  27. package/internal/shims.mjs +1 -1
  28. package/internal/tslib.js +17 -17
  29. package/internal/uploads.d.mts +4 -4
  30. package/internal/uploads.d.ts +4 -4
  31. package/internal/utils/base64.js +2 -2
  32. package/internal/utils/base64.mjs +3 -3
  33. package/internal/utils/log.d.mts +3 -3
  34. package/internal/utils/log.d.ts +3 -3
  35. package/internal/utils/path.js +1 -1
  36. package/internal/utils/path.mjs +2 -2
  37. package/internal/utils/values.js +5 -5
  38. package/internal/utils/values.mjs +6 -6
  39. package/package.json +3 -3
  40. package/resources/{pzn.d.mts → custom-router.d.mts} +16 -96
  41. package/resources/custom-router.d.mts.map +1 -0
  42. package/resources/{pzn.d.ts → custom-router.d.ts} +16 -96
  43. package/resources/custom-router.d.ts.map +1 -0
  44. package/resources/{pzn.js → custom-router.js} +13 -50
  45. package/resources/custom-router.js.map +1 -0
  46. package/resources/{pzn.mjs → custom-router.mjs} +11 -48
  47. package/resources/custom-router.mjs.map +1 -0
  48. package/resources/index.d.mts +4 -5
  49. package/resources/index.d.mts.map +1 -1
  50. package/resources/index.d.ts +4 -5
  51. package/resources/index.d.ts.map +1 -1
  52. package/resources/index.js +5 -7
  53. package/resources/index.js.map +1 -1
  54. package/resources/index.mjs +2 -3
  55. package/resources/index.mjs.map +1 -1
  56. package/resources/model-router.d.mts +6 -123
  57. package/resources/model-router.d.mts.map +1 -1
  58. package/resources/model-router.d.ts +6 -123
  59. package/resources/model-router.d.ts.map +1 -1
  60. package/resources/model-router.js +3 -32
  61. package/resources/model-router.js.map +1 -1
  62. package/resources/model-router.mjs +3 -32
  63. package/resources/model-router.mjs.map +1 -1
  64. package/resources/preferences.d.mts +4 -23
  65. package/resources/preferences.d.mts.map +1 -1
  66. package/resources/preferences.d.ts +4 -23
  67. package/resources/preferences.d.ts.map +1 -1
  68. package/resources/preferences.js +3 -25
  69. package/resources/preferences.js.map +1 -1
  70. package/resources/preferences.mjs +3 -25
  71. package/resources/preferences.mjs.map +1 -1
  72. package/resources/prompt-adaptation.d.mts +684 -0
  73. package/resources/prompt-adaptation.d.mts.map +1 -0
  74. package/resources/prompt-adaptation.d.ts +684 -0
  75. package/resources/prompt-adaptation.d.ts.map +1 -0
  76. package/resources/prompt-adaptation.js +258 -0
  77. package/resources/prompt-adaptation.js.map +1 -0
  78. package/resources/prompt-adaptation.mjs +254 -0
  79. package/resources/prompt-adaptation.mjs.map +1 -0
  80. package/src/client.ts +49 -56
  81. package/src/core/api-promise.ts +4 -4
  82. package/src/core/error.ts +2 -2
  83. package/src/core/resource.ts +3 -3
  84. package/src/index.ts +3 -3
  85. package/src/internal/parse.ts +2 -2
  86. package/src/internal/shims.ts +1 -1
  87. package/src/internal/uploads.ts +5 -5
  88. package/src/internal/utils/base64.ts +3 -3
  89. package/src/internal/utils/log.ts +3 -3
  90. package/src/internal/utils/path.ts +2 -2
  91. package/src/internal/utils/values.ts +6 -6
  92. package/src/resources/{pzn.ts → custom-router.ts} +17 -122
  93. package/src/resources/index.ts +14 -16
  94. package/src/resources/model-router.ts +5 -139
  95. package/src/resources/preferences.ts +3 -34
  96. package/src/resources/prompt-adaptation.ts +777 -0
  97. package/src/version.ts +1 -1
  98. package/version.d.mts +1 -1
  99. package/version.d.mts.map +1 -1
  100. package/version.d.ts +1 -1
  101. package/version.d.ts.map +1 -1
  102. package/version.js +1 -1
  103. package/version.js.map +1 -1
  104. package/version.mjs +1 -1
  105. package/version.mjs.map +1 -1
  106. package/resources/prompt/adapt.d.mts +0 -352
  107. package/resources/prompt/adapt.d.mts.map +0 -1
  108. package/resources/prompt/adapt.d.ts +0 -352
  109. package/resources/prompt/adapt.d.ts.map +0 -1
  110. package/resources/prompt/adapt.js +0 -154
  111. package/resources/prompt/adapt.js.map +0 -1
  112. package/resources/prompt/adapt.mjs +0 -150
  113. package/resources/prompt/adapt.mjs.map +0 -1
  114. package/resources/prompt/index.d.mts +0 -3
  115. package/resources/prompt/index.d.mts.map +0 -1
  116. package/resources/prompt/index.d.ts +0 -3
  117. package/resources/prompt/index.d.ts.map +0 -1
  118. package/resources/prompt/index.js +0 -9
  119. package/resources/prompt/index.js.map +0 -1
  120. package/resources/prompt/index.mjs +0 -4
  121. package/resources/prompt/index.mjs.map +0 -1
  122. package/resources/prompt/prompt.d.mts +0 -338
  123. package/resources/prompt/prompt.d.mts.map +0 -1
  124. package/resources/prompt/prompt.d.ts +0 -338
  125. package/resources/prompt/prompt.d.ts.map +0 -1
  126. package/resources/prompt/prompt.js +0 -128
  127. package/resources/prompt/prompt.js.map +0 -1
  128. package/resources/prompt/prompt.mjs +0 -123
  129. package/resources/prompt/prompt.mjs.map +0 -1
  130. package/resources/prompt.d.mts +0 -2
  131. package/resources/prompt.d.mts.map +0 -1
  132. package/resources/prompt.d.ts +0 -2
  133. package/resources/prompt.d.ts.map +0 -1
  134. package/resources/prompt.js +0 -6
  135. package/resources/prompt.js.map +0 -1
  136. package/resources/prompt.mjs +0 -3
  137. package/resources/prompt.mjs.map +0 -1
  138. package/resources/pzn.d.mts.map +0 -1
  139. package/resources/pzn.d.ts.map +0 -1
  140. package/resources/pzn.js.map +0 -1
  141. package/resources/pzn.mjs.map +0 -1
  142. package/resources/report/index.d.mts +0 -3
  143. package/resources/report/index.d.mts.map +0 -1
  144. package/resources/report/index.d.ts +0 -3
  145. package/resources/report/index.d.ts.map +0 -1
  146. package/resources/report/index.js +0 -9
  147. package/resources/report/index.js.map +0 -1
  148. package/resources/report/index.mjs +0 -4
  149. package/resources/report/index.mjs.map +0 -1
  150. package/resources/report/metrics.d.mts +0 -87
  151. package/resources/report/metrics.d.mts.map +0 -1
  152. package/resources/report/metrics.d.ts +0 -87
  153. package/resources/report/metrics.d.ts.map +0 -1
  154. package/resources/report/metrics.js +0 -57
  155. package/resources/report/metrics.js.map +0 -1
  156. package/resources/report/metrics.mjs +0 -53
  157. package/resources/report/metrics.mjs.map +0 -1
  158. package/resources/report/report.d.mts +0 -10
  159. package/resources/report/report.d.mts.map +0 -1
  160. package/resources/report/report.d.ts +0 -10
  161. package/resources/report/report.d.ts.map +0 -1
  162. package/resources/report/report.js +0 -17
  163. package/resources/report/report.js.map +0 -1
  164. package/resources/report/report.mjs +0 -12
  165. package/resources/report/report.mjs.map +0 -1
  166. package/resources/report.d.mts +0 -2
  167. package/resources/report.d.mts.map +0 -1
  168. package/resources/report.d.ts +0 -2
  169. package/resources/report.d.ts.map +0 -1
  170. package/resources/report.js +0 -6
  171. package/resources/report.js.map +0 -1
  172. package/resources/report.mjs +0 -3
  173. package/resources/report.mjs.map +0 -1
  174. package/src/resources/prompt/adapt.ts +0 -402
  175. package/src/resources/prompt/index.ts +0 -16
  176. package/src/resources/prompt/prompt.ts +0 -398
  177. package/src/resources/prompt.ts +0 -3
  178. package/src/resources/report/index.ts +0 -4
  179. package/src/resources/report/metrics.ts +0 -99
  180. package/src/resources/report/report.ts +0 -19
  181. package/src/resources/report.ts +0 -3
package/src/client.ts CHANGED
@@ -17,10 +17,13 @@ import * as Errors from './core/error';
17
17
  import * as Uploads from './core/uploads';
18
18
  import * as API from './resources/index';
19
19
  import { APIPromise } from './core/api-promise';
20
+ import {
21
+ CustomRouter,
22
+ CustomRouterTrainCustomRouterParams,
23
+ CustomRouterTrainCustomRouterResponse,
24
+ } from './resources/custom-router';
20
25
  import {
21
26
  ModelRouter,
22
- ModelRouterOpenHandsSelectParams,
23
- ModelRouterOpenHandsSelectResponse,
24
27
  ModelRouterSelectModelParams,
25
28
  ModelRouterSelectModelResponse,
26
29
  } from './resources/model-router';
@@ -29,26 +32,21 @@ import {
29
32
  PreferenceCreateParams,
30
33
  PreferenceCreateResponse,
31
34
  PreferenceDeleteResponse,
32
- PreferenceRetrieveParams,
33
- PreferenceRetrieveResponse,
34
35
  PreferenceUpdateParams,
35
36
  PreferenceUpdateResponse,
36
37
  Preferences,
37
38
  } from './resources/preferences';
38
39
  import {
39
- Pzn,
40
- PznSubmitSurveyResponseParams,
41
- PznSubmitSurveyResponseResponse,
42
- PznTrainCustomRouterParams,
43
- PznTrainCustomRouterResponse,
44
- } from './resources/pzn';
45
- import {
40
+ GoldenRecord,
46
41
  JobStatus,
47
- Prompt,
48
- PromptGetAdaptResultsResponse,
49
- PromptGetAdaptStatusResponse,
50
- } from './resources/prompt/prompt';
51
- import { Report } from './resources/report/report';
42
+ PromptAdaptation,
43
+ PromptAdaptationAdaptParams,
44
+ PromptAdaptationAdaptResponse,
45
+ PromptAdaptationGetAdaptResultsResponse,
46
+ PromptAdaptationGetAdaptStatusResponse,
47
+ PromptAdaptationGetCostResponse,
48
+ RequestProvider,
49
+ } from './resources/prompt-adaptation';
52
50
  import { type Fetch } from './internal/builtin-types';
53
51
  import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
54
52
  import { FinalRequestOptions, RequestOptions } from './internal/request-options';
@@ -71,7 +69,7 @@ export interface ClientOptions {
71
69
  /**
72
70
  * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
73
71
  *
74
- * Defaults to process.env['NOT_DIAMOND_BASE_URL'].
72
+ * Defaults to process.env['NOTDIAMOND_BASE_URL'].
75
73
  */
76
74
  baseURL?: string | null | undefined;
77
75
 
@@ -125,7 +123,7 @@ export interface ClientOptions {
125
123
  /**
126
124
  * Set the log level.
127
125
  *
128
- * Defaults to process.env['NOT_DIAMOND_LOG'] or 'warn' if it isn't set.
126
+ * Defaults to process.env['NOTDIAMOND_LOG'] or 'warn' if it isn't set.
129
127
  */
130
128
  logLevel?: LogLevel | undefined;
131
129
 
@@ -138,15 +136,15 @@ export interface ClientOptions {
138
136
  }
139
137
 
140
138
  /**
141
- * API Client for interfacing with the Not Diamond API.
139
+ * API Client for interfacing with the Notdiamond API.
142
140
  */
143
- export class NotDiamond {
141
+ export class Notdiamond {
144
142
  apiKey: string;
145
143
 
146
144
  baseURL: string;
147
145
  maxRetries: number;
148
146
  timeout: number;
149
- logger: Logger | undefined;
147
+ logger: Logger;
150
148
  logLevel: LogLevel | undefined;
151
149
  fetchOptions: MergedRequestInit | undefined;
152
150
 
@@ -156,10 +154,10 @@ export class NotDiamond {
156
154
  private _options: ClientOptions;
157
155
 
158
156
  /**
159
- * API Client for interfacing with the Not Diamond API.
157
+ * API Client for interfacing with the Notdiamond API.
160
158
  *
161
159
  * @param {string | undefined} [opts.apiKey=process.env['NOT_DIAMOND_API_KEY'] ?? undefined]
162
- * @param {string} [opts.baseURL=process.env['NOT_DIAMOND_BASE_URL'] ?? /] - Override the default base URL for the API.
160
+ * @param {string} [opts.baseURL=process.env['NOTDIAMOND_BASE_URL'] ?? https://api.notdiamond.ai] - Override the default base URL for the API.
163
161
  * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
164
162
  * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
165
163
  * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -168,31 +166,31 @@ export class NotDiamond {
168
166
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
169
167
  */
170
168
  constructor({
171
- baseURL = readEnv('NOT_DIAMOND_BASE_URL'),
169
+ baseURL = readEnv('NOTDIAMOND_BASE_URL'),
172
170
  apiKey = readEnv('NOT_DIAMOND_API_KEY'),
173
171
  ...opts
174
172
  }: ClientOptions = {}) {
175
173
  if (apiKey === undefined) {
176
- throw new Errors.NotDiamondError(
177
- "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' }).",
174
+ throw new Errors.NotdiamondError(
175
+ "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' }).",
178
176
  );
179
177
  }
180
178
 
181
179
  const options: ClientOptions = {
182
180
  apiKey,
183
181
  ...opts,
184
- baseURL: baseURL || `/`,
182
+ baseURL: baseURL || `https://api.notdiamond.ai`,
185
183
  };
186
184
 
187
185
  this.baseURL = options.baseURL!;
188
- this.timeout = options.timeout ?? NotDiamond.DEFAULT_TIMEOUT /* 1 minute */;
186
+ this.timeout = options.timeout ?? Notdiamond.DEFAULT_TIMEOUT /* 1 minute */;
189
187
  this.logger = options.logger ?? console;
190
188
  const defaultLogLevel = 'warn';
191
189
  // Set default logLevel early so that we can log a warning in parseLogLevel.
192
190
  this.logLevel = defaultLogLevel;
193
191
  this.logLevel =
194
192
  parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ??
195
- parseLogLevel(readEnv('NOT_DIAMOND_LOG'), "process.env['NOT_DIAMOND_LOG']", this) ??
193
+ parseLogLevel(readEnv('NOTDIAMOND_LOG'), "process.env['NOTDIAMOND_LOG']", this) ??
196
194
  defaultLogLevel;
197
195
  this.fetchOptions = options.fetchOptions;
198
196
  this.maxRetries = options.maxRetries ?? 2;
@@ -227,7 +225,7 @@ export class NotDiamond {
227
225
  * Check whether the base URL is set to its default.
228
226
  */
229
227
  #baseURLOverridden(): boolean {
230
- return this.baseURL !== '/';
228
+ return this.baseURL !== 'https://api.notdiamond.ai';
231
229
  }
232
230
 
233
231
  protected defaultQuery(): Record<string, string | undefined> | undefined {
@@ -711,10 +709,10 @@ export class NotDiamond {
711
709
  }
712
710
  }
713
711
 
714
- static NotDiamond = this;
712
+ static Notdiamond = this;
715
713
  static DEFAULT_TIMEOUT = 60000; // 1 minute
716
714
 
717
- static NotDiamondError = Errors.NotDiamondError;
715
+ static NotdiamondError = Errors.NotdiamondError;
718
716
  static APIError = Errors.APIError;
719
717
  static APIConnectionError = Errors.APIConnectionError;
720
718
  static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
@@ -731,57 +729,52 @@ export class NotDiamond {
731
729
  static toFile = Uploads.toFile;
732
730
 
733
731
  modelRouter: API.ModelRouter = new API.ModelRouter(this);
734
- report: API.Report = new API.Report(this);
735
732
  preferences: API.Preferences = new API.Preferences(this);
736
- prompt: API.Prompt = new API.Prompt(this);
737
- pzn: API.Pzn = new API.Pzn(this);
733
+ promptAdaptation: API.PromptAdaptation = new API.PromptAdaptation(this);
734
+ customRouter: API.CustomRouter = new API.CustomRouter(this);
738
735
  models: API.Models = new API.Models(this);
739
736
  }
740
737
 
741
- NotDiamond.ModelRouter = ModelRouter;
742
- NotDiamond.Report = Report;
743
- NotDiamond.Preferences = Preferences;
744
- NotDiamond.Prompt = Prompt;
745
- NotDiamond.Pzn = Pzn;
746
- NotDiamond.Models = Models;
738
+ Notdiamond.ModelRouter = ModelRouter;
739
+ Notdiamond.Preferences = Preferences;
740
+ Notdiamond.PromptAdaptation = PromptAdaptation;
741
+ Notdiamond.CustomRouter = CustomRouter;
742
+ Notdiamond.Models = Models;
747
743
 
748
- export declare namespace NotDiamond {
744
+ export declare namespace Notdiamond {
749
745
  export type RequestOptions = Opts.RequestOptions;
750
746
 
751
747
  export {
752
748
  ModelRouter as ModelRouter,
753
- type ModelRouterOpenHandsSelectResponse as ModelRouterOpenHandsSelectResponse,
754
749
  type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse,
755
- type ModelRouterOpenHandsSelectParams as ModelRouterOpenHandsSelectParams,
756
750
  type ModelRouterSelectModelParams as ModelRouterSelectModelParams,
757
751
  };
758
752
 
759
- export { Report as Report };
760
-
761
753
  export {
762
754
  Preferences as Preferences,
763
755
  type PreferenceCreateResponse as PreferenceCreateResponse,
764
- type PreferenceRetrieveResponse as PreferenceRetrieveResponse,
765
756
  type PreferenceUpdateResponse as PreferenceUpdateResponse,
766
757
  type PreferenceDeleteResponse as PreferenceDeleteResponse,
767
758
  type PreferenceCreateParams as PreferenceCreateParams,
768
- type PreferenceRetrieveParams as PreferenceRetrieveParams,
769
759
  type PreferenceUpdateParams as PreferenceUpdateParams,
770
760
  };
771
761
 
772
762
  export {
773
- Prompt as Prompt,
763
+ PromptAdaptation as PromptAdaptation,
764
+ type GoldenRecord as GoldenRecord,
774
765
  type JobStatus as JobStatus,
775
- type PromptGetAdaptResultsResponse as PromptGetAdaptResultsResponse,
776
- type PromptGetAdaptStatusResponse as PromptGetAdaptStatusResponse,
766
+ type RequestProvider as RequestProvider,
767
+ type PromptAdaptationAdaptResponse as PromptAdaptationAdaptResponse,
768
+ type PromptAdaptationGetAdaptResultsResponse as PromptAdaptationGetAdaptResultsResponse,
769
+ type PromptAdaptationGetAdaptStatusResponse as PromptAdaptationGetAdaptStatusResponse,
770
+ type PromptAdaptationGetCostResponse as PromptAdaptationGetCostResponse,
771
+ type PromptAdaptationAdaptParams as PromptAdaptationAdaptParams,
777
772
  };
778
773
 
779
774
  export {
780
- Pzn as Pzn,
781
- type PznSubmitSurveyResponseResponse as PznSubmitSurveyResponseResponse,
782
- type PznTrainCustomRouterResponse as PznTrainCustomRouterResponse,
783
- type PznSubmitSurveyResponseParams as PznSubmitSurveyResponseParams,
784
- type PznTrainCustomRouterParams as PznTrainCustomRouterParams,
775
+ CustomRouter as CustomRouter,
776
+ type CustomRouterTrainCustomRouterResponse as CustomRouterTrainCustomRouterResponse,
777
+ type CustomRouterTrainCustomRouterParams as CustomRouterTrainCustomRouterParams,
785
778
  };
786
779
 
787
780
  export {
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { type NotDiamond } from '../client';
3
+ import { type Notdiamond } 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: NotDiamond;
14
+ #client: Notdiamond;
15
15
 
16
16
  constructor(
17
- client: NotDiamond,
17
+ client: Notdiamond,
18
18
  private responsePromise: Promise<APIResponseProps>,
19
19
  private parseResponse: (
20
- client: NotDiamond,
20
+ client: Notdiamond,
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 NotDiamondError extends Error {}
5
+ export class NotdiamondError 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 NotDiamondError {
11
+ > extends NotdiamondError {
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 { NotDiamond } from '../client';
3
+ import type { Notdiamond } from '../client';
4
4
 
5
5
  export abstract class APIResource {
6
- protected _client: NotDiamond;
6
+ protected _client: Notdiamond;
7
7
 
8
- constructor(client: NotDiamond) {
8
+ constructor(client: Notdiamond) {
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 { NotDiamond as default } from './client';
3
+ export { Notdiamond 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 { NotDiamond, type ClientOptions } from './client';
7
+ export { Notdiamond, type ClientOptions } from './client';
8
8
  export {
9
- NotDiamondError,
9
+ NotdiamondError,
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 NotDiamond } from '../client';
4
+ import { type Notdiamond } 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: NotDiamond, props: APIResponseProps): Promise<T> {
16
+ export async function defaultParseResponse<T>(client: Notdiamond, 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 NotDiamond({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
19
+ '`fetch` is not defined as a global; Either pass `fetch` to the client, `new Notdiamond({ 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 { NotDiamond } from '../client';
3
+ import type { Notdiamond } 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: NotDiamond | Fetch,
77
+ fetch: Notdiamond | 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: NotDiamond | Fetch,
88
+ fetch: Notdiamond | 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: NotDiamond | Fetch): Promise<boolean> {
101
+ function supportsFormData(fetchObject: Notdiamond | 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: NotDiamond | Fetch): Promise<boolean> {
124
124
 
125
125
  export const createForm = async <T = Record<string, unknown>>(
126
126
  body: T | undefined,
127
- fetch: NotDiamond | Fetch,
127
+ fetch: Notdiamond | 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 { NotDiamondError } from '../../core/error';
3
+ import { NotdiamondError } 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 NotDiamondError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
21
+ throw new NotdiamondError('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 NotDiamondError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
39
+ throw new NotdiamondError('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 NotDiamond } from '../../client';
4
+ import { type Notdiamond } 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: NotDiamond,
27
+ client: Notdiamond,
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: NotDiamond): Logger {
63
+ export function loggerFor(client: Notdiamond): Logger {
64
64
  const logger = client.logger;
65
65
  const logLevel = client.logLevel ?? 'off';
66
66
  if (!logger) {
@@ -1,4 +1,4 @@
1
- import { NotDiamondError } from '../../core/error';
1
+ import { NotdiamondError } 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 NotDiamondError(
75
+ throw new NotdiamondError(
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 { NotDiamondError } from '../../core/error';
3
+ import { NotdiamondError } 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 NotDiamondError(`Expected a value to be given but received ${value} instead.`);
42
+ throw new NotdiamondError(`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 NotDiamondError(`${name} must be an integer`);
50
+ throw new NotdiamondError(`${name} must be an integer`);
51
51
  }
52
52
  if (n < 0) {
53
- throw new NotDiamondError(`${name} must be a positive integer`);
53
+ throw new NotdiamondError(`${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 NotDiamondError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
62
+ throw new NotdiamondError(`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 NotDiamondError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
69
+ throw new NotdiamondError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
70
70
  };
71
71
 
72
72
  export const coerceBoolean = (value: unknown): boolean => {