@codetunezstudios/token-kit 0.1.0-beta.2 → 0.1.0-beta.3
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/dist/index.d.mts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +14 -2
- package/dist/index.mjs +13 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -86,10 +86,28 @@ declare class TokenKitAPIError extends Error implements TokenKitError {
|
|
|
86
86
|
details?: unknown;
|
|
87
87
|
constructor(message: string, code: string, statusCode?: number, details?: unknown);
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Named deployment environments.
|
|
91
|
+
* Maps to the canonical API Gateway URLs for each environment.
|
|
92
|
+
* Use `baseUrl` to override for self-hosted or custom deployments.
|
|
93
|
+
*/
|
|
94
|
+
type TokenKitEnvironment = 'production' | 'staging' | 'development';
|
|
95
|
+
/** Canonical base URLs per environment — exported for reference */
|
|
96
|
+
declare const ENVIRONMENT_URLS: Record<TokenKitEnvironment, string>;
|
|
89
97
|
interface TokenKitConfig {
|
|
90
98
|
/** Developer API key */
|
|
91
99
|
apiKey: string;
|
|
92
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Named environment shorthand. Resolves to the canonical API URL.
|
|
102
|
+
* Ignored when `baseUrl` is also provided (baseUrl takes precedence).
|
|
103
|
+
* Defaults to `'production'` when neither is set.
|
|
104
|
+
*/
|
|
105
|
+
environment?: TokenKitEnvironment;
|
|
106
|
+
/**
|
|
107
|
+
* Explicit API Gateway base URL.
|
|
108
|
+
* Use this for self-hosted deployments or local development.
|
|
109
|
+
* Takes precedence over `environment`.
|
|
110
|
+
*/
|
|
93
111
|
baseUrl?: string;
|
|
94
112
|
/** Request timeout in milliseconds (default: 60000) */
|
|
95
113
|
timeout?: number;
|
|
@@ -122,7 +140,11 @@ declare class TokenKit {
|
|
|
122
140
|
*
|
|
123
141
|
* @param config - Configuration options
|
|
124
142
|
* @param config.apiKey - Your developer API key
|
|
125
|
-
* @param config.
|
|
143
|
+
* @param config.environment - Target environment: 'production' | 'staging' | 'development'
|
|
144
|
+
* Resolves to the canonical API URL for that environment.
|
|
145
|
+
* Defaults to 'production'. Ignored when `baseUrl` is also set.
|
|
146
|
+
* @param config.baseUrl - Explicit API base URL — overrides `environment`.
|
|
147
|
+
* Use for self-hosted deployments or local tunnels.
|
|
126
148
|
* @param config.timeout - Request timeout in ms (optional, defaults to 60000)
|
|
127
149
|
*/
|
|
128
150
|
constructor(config: TokenKitConfig);
|
|
@@ -229,4 +251,4 @@ declare class TokenKit {
|
|
|
229
251
|
static assistant(content: string): Message;
|
|
230
252
|
}
|
|
231
253
|
|
|
232
|
-
export { type ChatOptions, type ChatResponse, type Message, type MessageRole, type ModelInfo, type ModelsResponse, TokenKit, TokenKitAPIError, type TokenKitConfig, type TokenValidationResponse, TokenKit as default };
|
|
254
|
+
export { type ChatOptions, type ChatResponse, ENVIRONMENT_URLS, type Message, type MessageRole, type ModelInfo, type ModelsResponse, TokenKit, TokenKitAPIError, type TokenKitConfig, type TokenKitEnvironment, type TokenValidationResponse, TokenKit as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -86,10 +86,28 @@ declare class TokenKitAPIError extends Error implements TokenKitError {
|
|
|
86
86
|
details?: unknown;
|
|
87
87
|
constructor(message: string, code: string, statusCode?: number, details?: unknown);
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Named deployment environments.
|
|
91
|
+
* Maps to the canonical API Gateway URLs for each environment.
|
|
92
|
+
* Use `baseUrl` to override for self-hosted or custom deployments.
|
|
93
|
+
*/
|
|
94
|
+
type TokenKitEnvironment = 'production' | 'staging' | 'development';
|
|
95
|
+
/** Canonical base URLs per environment — exported for reference */
|
|
96
|
+
declare const ENVIRONMENT_URLS: Record<TokenKitEnvironment, string>;
|
|
89
97
|
interface TokenKitConfig {
|
|
90
98
|
/** Developer API key */
|
|
91
99
|
apiKey: string;
|
|
92
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Named environment shorthand. Resolves to the canonical API URL.
|
|
102
|
+
* Ignored when `baseUrl` is also provided (baseUrl takes precedence).
|
|
103
|
+
* Defaults to `'production'` when neither is set.
|
|
104
|
+
*/
|
|
105
|
+
environment?: TokenKitEnvironment;
|
|
106
|
+
/**
|
|
107
|
+
* Explicit API Gateway base URL.
|
|
108
|
+
* Use this for self-hosted deployments or local development.
|
|
109
|
+
* Takes precedence over `environment`.
|
|
110
|
+
*/
|
|
93
111
|
baseUrl?: string;
|
|
94
112
|
/** Request timeout in milliseconds (default: 60000) */
|
|
95
113
|
timeout?: number;
|
|
@@ -122,7 +140,11 @@ declare class TokenKit {
|
|
|
122
140
|
*
|
|
123
141
|
* @param config - Configuration options
|
|
124
142
|
* @param config.apiKey - Your developer API key
|
|
125
|
-
* @param config.
|
|
143
|
+
* @param config.environment - Target environment: 'production' | 'staging' | 'development'
|
|
144
|
+
* Resolves to the canonical API URL for that environment.
|
|
145
|
+
* Defaults to 'production'. Ignored when `baseUrl` is also set.
|
|
146
|
+
* @param config.baseUrl - Explicit API base URL — overrides `environment`.
|
|
147
|
+
* Use for self-hosted deployments or local tunnels.
|
|
126
148
|
* @param config.timeout - Request timeout in ms (optional, defaults to 60000)
|
|
127
149
|
*/
|
|
128
150
|
constructor(config: TokenKitConfig);
|
|
@@ -229,4 +251,4 @@ declare class TokenKit {
|
|
|
229
251
|
static assistant(content: string): Message;
|
|
230
252
|
}
|
|
231
253
|
|
|
232
|
-
export { type ChatOptions, type ChatResponse, type Message, type MessageRole, type ModelInfo, type ModelsResponse, TokenKit, TokenKitAPIError, type TokenKitConfig, type TokenValidationResponse, TokenKit as default };
|
|
254
|
+
export { type ChatOptions, type ChatResponse, ENVIRONMENT_URLS, type Message, type MessageRole, type ModelInfo, type ModelsResponse, TokenKit, TokenKitAPIError, type TokenKitConfig, type TokenKitEnvironment, type TokenValidationResponse, TokenKit as default };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
ENVIRONMENT_URLS: () => ENVIRONMENT_URLS,
|
|
33
34
|
TokenKit: () => TokenKit,
|
|
34
35
|
TokenKitAPIError: () => TokenKitAPIError,
|
|
35
36
|
default: () => index_default
|
|
@@ -50,6 +51,11 @@ var TokenKitAPIError = class extends Error {
|
|
|
50
51
|
Error.captureStackTrace?.(this, this.constructor);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
54
|
+
var ENVIRONMENT_URLS = {
|
|
55
|
+
production: "https://api.token-kit.com/v1",
|
|
56
|
+
staging: "https://api-staging.token-kit.com/v1",
|
|
57
|
+
development: "https://api-dev.token-kit.com/v1"
|
|
58
|
+
};
|
|
53
59
|
|
|
54
60
|
// src/client.ts
|
|
55
61
|
var TokenKitClient = class {
|
|
@@ -58,8 +64,9 @@ var TokenKitClient = class {
|
|
|
58
64
|
throw new Error("API key is required");
|
|
59
65
|
}
|
|
60
66
|
this.apiKey = config.apiKey;
|
|
67
|
+
const baseURL = config.baseUrl ?? ENVIRONMENT_URLS[config.environment ?? "production"];
|
|
61
68
|
this.client = import_axios.default.create({
|
|
62
|
-
baseURL
|
|
69
|
+
baseURL,
|
|
63
70
|
timeout: config.timeout || 6e4,
|
|
64
71
|
headers: {
|
|
65
72
|
"Content-Type": "application/json",
|
|
@@ -203,7 +210,11 @@ var TokenKit = class {
|
|
|
203
210
|
*
|
|
204
211
|
* @param config - Configuration options
|
|
205
212
|
* @param config.apiKey - Your developer API key
|
|
206
|
-
* @param config.
|
|
213
|
+
* @param config.environment - Target environment: 'production' | 'staging' | 'development'
|
|
214
|
+
* Resolves to the canonical API URL for that environment.
|
|
215
|
+
* Defaults to 'production'. Ignored when `baseUrl` is also set.
|
|
216
|
+
* @param config.baseUrl - Explicit API base URL — overrides `environment`.
|
|
217
|
+
* Use for self-hosted deployments or local tunnels.
|
|
207
218
|
* @param config.timeout - Request timeout in ms (optional, defaults to 60000)
|
|
208
219
|
*/
|
|
209
220
|
constructor(config) {
|
|
@@ -354,6 +365,7 @@ var TokenKit = class {
|
|
|
354
365
|
var index_default = TokenKit;
|
|
355
366
|
// Annotate the CommonJS export names for ESM import in node:
|
|
356
367
|
0 && (module.exports = {
|
|
368
|
+
ENVIRONMENT_URLS,
|
|
357
369
|
TokenKit,
|
|
358
370
|
TokenKitAPIError
|
|
359
371
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,11 @@ var TokenKitAPIError = class extends Error {
|
|
|
12
12
|
Error.captureStackTrace?.(this, this.constructor);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
var ENVIRONMENT_URLS = {
|
|
16
|
+
production: "https://api.token-kit.com/v1",
|
|
17
|
+
staging: "https://api-staging.token-kit.com/v1",
|
|
18
|
+
development: "https://api-dev.token-kit.com/v1"
|
|
19
|
+
};
|
|
15
20
|
|
|
16
21
|
// src/client.ts
|
|
17
22
|
var TokenKitClient = class {
|
|
@@ -20,8 +25,9 @@ var TokenKitClient = class {
|
|
|
20
25
|
throw new Error("API key is required");
|
|
21
26
|
}
|
|
22
27
|
this.apiKey = config.apiKey;
|
|
28
|
+
const baseURL = config.baseUrl ?? ENVIRONMENT_URLS[config.environment ?? "production"];
|
|
23
29
|
this.client = axios.create({
|
|
24
|
-
baseURL
|
|
30
|
+
baseURL,
|
|
25
31
|
timeout: config.timeout || 6e4,
|
|
26
32
|
headers: {
|
|
27
33
|
"Content-Type": "application/json",
|
|
@@ -165,7 +171,11 @@ var TokenKit = class {
|
|
|
165
171
|
*
|
|
166
172
|
* @param config - Configuration options
|
|
167
173
|
* @param config.apiKey - Your developer API key
|
|
168
|
-
* @param config.
|
|
174
|
+
* @param config.environment - Target environment: 'production' | 'staging' | 'development'
|
|
175
|
+
* Resolves to the canonical API URL for that environment.
|
|
176
|
+
* Defaults to 'production'. Ignored when `baseUrl` is also set.
|
|
177
|
+
* @param config.baseUrl - Explicit API base URL — overrides `environment`.
|
|
178
|
+
* Use for self-hosted deployments or local tunnels.
|
|
169
179
|
* @param config.timeout - Request timeout in ms (optional, defaults to 60000)
|
|
170
180
|
*/
|
|
171
181
|
constructor(config) {
|
|
@@ -315,6 +325,7 @@ var TokenKit = class {
|
|
|
315
325
|
};
|
|
316
326
|
var index_default = TokenKit;
|
|
317
327
|
export {
|
|
328
|
+
ENVIRONMENT_URLS,
|
|
318
329
|
TokenKit,
|
|
319
330
|
TokenKitAPIError,
|
|
320
331
|
index_default as default
|
package/package.json
CHANGED