@synova-cloud/sdk 1.5.0 → 1.7.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/README.md +154 -99
- package/dist/index.cjs +560 -226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +468 -225
- package/dist/index.d.ts +468 -225
- package/dist/index.js +539 -227
- package/dist/index.js.map +1 -1
- package/package.json +16 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema primitive types
|
|
3
|
+
*/
|
|
4
|
+
type TJsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array';
|
|
5
|
+
/**
|
|
6
|
+
* JSON Schema string formats
|
|
7
|
+
* @see https://json-schema.org/understanding-json-schema/reference/string#built-in-formats
|
|
8
|
+
*/
|
|
9
|
+
type TJsonSchemaFormat = 'date-time' | 'date' | 'time' | 'duration' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'iri-reference' | 'uuid' | 'json-pointer' | 'relative-json-pointer' | 'regex';
|
|
10
|
+
/**
|
|
11
|
+
* JSON Schema definition
|
|
12
|
+
* @see https://json-schema.org/specification
|
|
13
|
+
*/
|
|
14
|
+
interface IJsonSchema {
|
|
15
|
+
type?: TJsonSchemaType | TJsonSchemaType[];
|
|
10
16
|
description?: string;
|
|
11
|
-
|
|
17
|
+
examples?: unknown[];
|
|
18
|
+
default?: unknown;
|
|
12
19
|
enum?: (string | number | boolean | null)[];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
minLength?: number;
|
|
21
|
+
maxLength?: number;
|
|
22
|
+
pattern?: string;
|
|
23
|
+
format?: TJsonSchemaFormat;
|
|
24
|
+
minimum?: number;
|
|
25
|
+
maximum?: number;
|
|
26
|
+
exclusiveMinimum?: number;
|
|
27
|
+
exclusiveMaximum?: number;
|
|
28
|
+
multipleOf?: number;
|
|
29
|
+
items?: IJsonSchema;
|
|
30
|
+
minItems?: number;
|
|
31
|
+
maxItems?: number;
|
|
32
|
+
uniqueItems?: boolean;
|
|
33
|
+
properties?: Record<string, IJsonSchema>;
|
|
18
34
|
required?: string[];
|
|
19
|
-
|
|
35
|
+
additionalProperties?: boolean | IJsonSchema;
|
|
36
|
+
allOf?: IJsonSchema[];
|
|
37
|
+
anyOf?: IJsonSchema[];
|
|
38
|
+
oneOf?: IJsonSchema[];
|
|
39
|
+
not?: IJsonSchema;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Metadata keys used by schema decorators
|
|
43
|
+
*/
|
|
44
|
+
declare const SCHEMA_METADATA_KEYS: {
|
|
45
|
+
readonly DESCRIPTION: "synova:schema:description";
|
|
46
|
+
readonly EXAMPLES: "synova:schema:examples";
|
|
47
|
+
readonly DEFAULT: "synova:schema:default";
|
|
48
|
+
readonly FORMAT: "synova:schema:format";
|
|
49
|
+
readonly ARRAY_ITEM_TYPE: "synova:schema:arrayItemType";
|
|
50
|
+
readonly NULLABLE: "synova:schema:nullable";
|
|
51
|
+
readonly ENUM: "synova:schema:enum";
|
|
52
|
+
readonly MIN_LENGTH: "synova:schema:minLength";
|
|
53
|
+
readonly MAX_LENGTH: "synova:schema:maxLength";
|
|
54
|
+
readonly PATTERN: "synova:schema:pattern";
|
|
55
|
+
readonly MINIMUM: "synova:schema:minimum";
|
|
56
|
+
readonly MAXIMUM: "synova:schema:maximum";
|
|
57
|
+
readonly EXCLUSIVE_MINIMUM: "synova:schema:exclusiveMinimum";
|
|
58
|
+
readonly EXCLUSIVE_MAXIMUM: "synova:schema:exclusiveMaximum";
|
|
59
|
+
readonly MULTIPLE_OF: "synova:schema:multipleOf";
|
|
60
|
+
readonly MIN_ITEMS: "synova:schema:minItems";
|
|
61
|
+
readonly MAX_ITEMS: "synova:schema:maxItems";
|
|
62
|
+
readonly UNIQUE_ITEMS: "synova:schema:uniqueItems";
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Options for schema generation
|
|
66
|
+
*/
|
|
67
|
+
interface IGenerateSchemaOptions {
|
|
68
|
+
/** Allow additional properties on objects (default: false) */
|
|
20
69
|
additionalProperties?: boolean;
|
|
21
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Constructor type for classes
|
|
73
|
+
*/
|
|
74
|
+
type TClassConstructor<T = unknown> = new (...args: any[]) => T;
|
|
75
|
+
|
|
76
|
+
type TSynovaMessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
77
|
+
type TSynovaResponseType = 'message' | 'tool_calls' | 'image' | 'audio' | 'error';
|
|
78
|
+
type TSynovaModelType = 'text' | 'image';
|
|
79
|
+
type TSynovaUsageType = 'tokens' | 'images' | 'time';
|
|
22
80
|
interface ISynovaLogger {
|
|
23
81
|
debug: (message: string, ...args: unknown[]) => void;
|
|
24
82
|
info: (message: string, ...args: unknown[]) => void;
|
|
@@ -102,8 +160,10 @@ interface ISynovaExecuteOptions {
|
|
|
102
160
|
provider: string;
|
|
103
161
|
/** LLM model to use (e.g., 'gpt-4o', 'claude-sonnet-4-20250514') */
|
|
104
162
|
model: string;
|
|
105
|
-
/**
|
|
106
|
-
|
|
163
|
+
/** Raw API key for the LLM provider */
|
|
164
|
+
apiKey?: string;
|
|
165
|
+
/** Azure OpenAI endpoint URL (required for azure_openai provider) */
|
|
166
|
+
azureEndpoint?: string;
|
|
107
167
|
/** Variables to substitute in prompt template */
|
|
108
168
|
variables?: Record<string, unknown>;
|
|
109
169
|
/** Previous messages for multi-turn conversation */
|
|
@@ -117,7 +177,7 @@ interface ISynovaExecuteOptions {
|
|
|
117
177
|
/** Model parameters (temperature, maxTokens, topP, topK, etc.) */
|
|
118
178
|
parameters?: Record<string, unknown>;
|
|
119
179
|
/** JSON Schema for structured output */
|
|
120
|
-
responseSchema?:
|
|
180
|
+
responseSchema?: IJsonSchema;
|
|
121
181
|
}
|
|
122
182
|
interface ISynovaExecutionUsage {
|
|
123
183
|
/** Usage type: 'tokens' for LLM, 'images' for image generation, 'time' for time-based billing */
|
|
@@ -144,10 +204,8 @@ interface ISynovaProviderResponse {
|
|
|
144
204
|
interface ISynovaExecutionErrorDetails {
|
|
145
205
|
/** Model used for the execution */
|
|
146
206
|
model?: string;
|
|
147
|
-
/** API key
|
|
148
|
-
|
|
149
|
-
/** API key label (human-readable name) */
|
|
150
|
-
apiKeyLabel?: string;
|
|
207
|
+
/** Last 5 characters of the API key used (for debugging) */
|
|
208
|
+
apiKeyHint?: string;
|
|
151
209
|
/** Prompt ID (if execution was via prompt) */
|
|
152
210
|
promptId?: string;
|
|
153
211
|
/** Prompt version (if execution was via prompt) */
|
|
@@ -276,49 +334,6 @@ interface ISynovaUploadOptions {
|
|
|
276
334
|
/** Project ID to associate files with */
|
|
277
335
|
projectId: string;
|
|
278
336
|
}
|
|
279
|
-
type TSynovaLlmProvider = 'openai' | 'anthropic' | 'google' | 'azure_openai' | 'deepseek' | 'replicate' | 'xai' | 'openrouter';
|
|
280
|
-
interface ISynovaAzureConfig {
|
|
281
|
-
/** Azure OpenAI endpoint URL */
|
|
282
|
-
endpoint: string;
|
|
283
|
-
}
|
|
284
|
-
interface ISynovaLlmProviderKey {
|
|
285
|
-
/** Key ID */
|
|
286
|
-
id: string;
|
|
287
|
-
/** LLM provider */
|
|
288
|
-
provider: TSynovaLlmProvider;
|
|
289
|
-
/** Masked API key (last 4 characters visible) */
|
|
290
|
-
maskedKey: string;
|
|
291
|
-
/** Whether this is the default key for the provider */
|
|
292
|
-
isDefault: boolean;
|
|
293
|
-
/** Default model for this provider */
|
|
294
|
-
defaultModel?: string;
|
|
295
|
-
/** Azure OpenAI configuration */
|
|
296
|
-
azure?: ISynovaAzureConfig;
|
|
297
|
-
/** Optional label to identify this key */
|
|
298
|
-
label?: string;
|
|
299
|
-
/** Creation date (ISO 8601) */
|
|
300
|
-
createdAt: string;
|
|
301
|
-
/** Last update date (ISO 8601) */
|
|
302
|
-
updatedAt: string;
|
|
303
|
-
}
|
|
304
|
-
interface ISynovaLlmProviderKeyListResponse {
|
|
305
|
-
items: ISynovaLlmProviderKey[];
|
|
306
|
-
total: number;
|
|
307
|
-
}
|
|
308
|
-
interface ISynovaCreateLlmProviderKeyOptions {
|
|
309
|
-
/** LLM provider */
|
|
310
|
-
provider: TSynovaLlmProvider;
|
|
311
|
-
/** API key for the LLM provider */
|
|
312
|
-
apiKey: string;
|
|
313
|
-
/** Whether this is the default key for the provider */
|
|
314
|
-
isDefault?: boolean;
|
|
315
|
-
/** Default model for this provider */
|
|
316
|
-
defaultModel?: string;
|
|
317
|
-
/** Azure OpenAI configuration (required for azure_openai provider) */
|
|
318
|
-
azure?: ISynovaAzureConfig;
|
|
319
|
-
/** Optional label to identify this key */
|
|
320
|
-
label?: string;
|
|
321
|
-
}
|
|
322
337
|
interface IApiErrorResponse {
|
|
323
338
|
code: string;
|
|
324
339
|
httpCode: number;
|
|
@@ -370,97 +385,82 @@ declare class HttpClient {
|
|
|
370
385
|
private log;
|
|
371
386
|
}
|
|
372
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Execute options with optional responseClass for typed responses
|
|
390
|
+
*/
|
|
391
|
+
interface ISynovaExecuteTypedOptions<T> extends Omit<ISynovaExecuteOptions, 'responseSchema'> {
|
|
392
|
+
/** Class to use for response typing and schema generation */
|
|
393
|
+
responseClass: TClassConstructor<T>;
|
|
394
|
+
/** Enable class-validator validation (default: true) */
|
|
395
|
+
validate?: boolean;
|
|
396
|
+
}
|
|
373
397
|
declare class PromptsResource {
|
|
374
398
|
private readonly http;
|
|
375
399
|
constructor(http: HttpClient);
|
|
376
400
|
/**
|
|
377
401
|
* Get a prompt by ID (returns version with 'latest' tag)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
*
|
|
402
|
+
*/
|
|
403
|
+
get(promptId: string, options?: ISynovaGetPromptOptions): Promise<ISynovaPrompt>;
|
|
404
|
+
/**
|
|
405
|
+
* Execute a prompt with typed response
|
|
382
406
|
*
|
|
383
407
|
* @example
|
|
384
408
|
* ```ts
|
|
385
|
-
* //
|
|
386
|
-
* const
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* //
|
|
392
|
-
* const v2 = await client.prompts.get('prm_abc123', { version: '2.0.0' });
|
|
409
|
+
* // With responseClass - returns typed object
|
|
410
|
+
* const topic = await client.prompts.execute('prm_abc123', {
|
|
411
|
+
* provider: 'openai',
|
|
412
|
+
* model: 'gpt-4o',
|
|
413
|
+
* responseClass: TopicDto,
|
|
414
|
+
* });
|
|
415
|
+
* console.log(topic.title); // Typed as string
|
|
393
416
|
* ```
|
|
394
417
|
*/
|
|
395
|
-
|
|
418
|
+
execute<T>(promptId: string, options: ISynovaExecuteTypedOptions<T>): Promise<T>;
|
|
396
419
|
/**
|
|
397
|
-
* Execute a prompt
|
|
398
|
-
*
|
|
399
|
-
* @param promptId - The prompt ID
|
|
400
|
-
* @param options - Execution options including provider, model and variables
|
|
401
|
-
* @returns The execution response
|
|
420
|
+
* Execute a prompt
|
|
402
421
|
*
|
|
403
422
|
* @example
|
|
404
423
|
* ```ts
|
|
424
|
+
* // Without responseClass - returns ISynovaExecuteResponse
|
|
405
425
|
* const result = await client.prompts.execute('prm_abc123', {
|
|
406
426
|
* provider: 'openai',
|
|
407
427
|
* model: 'gpt-4o',
|
|
408
|
-
* variables: { topic: 'TypeScript' },
|
|
409
428
|
* });
|
|
410
|
-
*
|
|
411
429
|
* if (result.type === 'message') {
|
|
412
430
|
* console.log(result.content);
|
|
413
431
|
* }
|
|
414
|
-
*
|
|
415
|
-
* // Image generation
|
|
416
|
-
* const imageResult = await client.prompts.execute('prm_image123', {
|
|
417
|
-
* provider: 'google',
|
|
418
|
-
* model: 'gemini-2.0-flash-exp',
|
|
419
|
-
* variables: { style: 'modern' },
|
|
420
|
-
* });
|
|
421
|
-
*
|
|
422
|
-
* if (imageResult.type === 'image') {
|
|
423
|
-
* console.log('Generated images:', imageResult.files);
|
|
424
|
-
* }
|
|
425
432
|
* ```
|
|
426
433
|
*/
|
|
427
434
|
execute(promptId: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
435
|
+
/**
|
|
436
|
+
* Execute a prompt by tag with typed response
|
|
437
|
+
*/
|
|
438
|
+
executeByTag<T>(promptId: string, tag: string, options: ISynovaExecuteTypedOptions<T>): Promise<T>;
|
|
428
439
|
/**
|
|
429
440
|
* Execute a prompt by tag
|
|
430
|
-
*
|
|
431
|
-
* @param promptId - The prompt ID
|
|
432
|
-
* @param tag - The tag (e.g., 'latest', 'production', 'staging')
|
|
433
|
-
* @param options - Execution options
|
|
434
|
-
* @returns The execution response
|
|
435
|
-
*
|
|
436
|
-
* @example
|
|
437
|
-
* ```ts
|
|
438
|
-
* const result = await client.prompts.executeByTag('prm_abc123', 'production', {
|
|
439
|
-
* provider: 'openai',
|
|
440
|
-
* model: 'gpt-4o',
|
|
441
|
-
* variables: { topic: 'TypeScript' },
|
|
442
|
-
* });
|
|
443
|
-
* ```
|
|
444
441
|
*/
|
|
445
442
|
executeByTag(promptId: string, tag: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
443
|
+
/**
|
|
444
|
+
* Execute a prompt by version with typed response
|
|
445
|
+
*/
|
|
446
|
+
executeByVersion<T>(promptId: string, version: string, options: ISynovaExecuteTypedOptions<T>): Promise<T>;
|
|
446
447
|
/**
|
|
447
448
|
* Execute a prompt by version
|
|
448
|
-
*
|
|
449
|
-
* @param promptId - The prompt ID
|
|
450
|
-
* @param version - The semantic version (e.g., '1.0.0', '2.1.0')
|
|
451
|
-
* @param options - Execution options
|
|
452
|
-
* @returns The execution response
|
|
453
|
-
*
|
|
454
|
-
* @example
|
|
455
|
-
* ```ts
|
|
456
|
-
* const result = await client.prompts.executeByVersion('prm_abc123', '1.2.0', {
|
|
457
|
-
* provider: 'openai',
|
|
458
|
-
* model: 'gpt-4o',
|
|
459
|
-
* variables: { topic: 'TypeScript' },
|
|
460
|
-
* });
|
|
461
|
-
* ```
|
|
462
449
|
*/
|
|
463
450
|
executeByVersion(promptId: string, version: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
451
|
+
/**
|
|
452
|
+
* Execute raw request without typed response
|
|
453
|
+
* @throws {ExecutionSynovaError} If LLM returns an error
|
|
454
|
+
*/
|
|
455
|
+
private executeRaw;
|
|
456
|
+
/**
|
|
457
|
+
* Execute with typed response class
|
|
458
|
+
*/
|
|
459
|
+
private executeTyped;
|
|
460
|
+
/**
|
|
461
|
+
* Validate object using class-validator
|
|
462
|
+
*/
|
|
463
|
+
private validateObject;
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
declare class ModelsResource {
|
|
@@ -556,95 +556,6 @@ declare class FilesResource {
|
|
|
556
556
|
upload(files: (File | Blob)[], options: ISynovaUploadOptions): Promise<ISynovaUploadResponse>;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
declare class LlmProviderKeysResource {
|
|
560
|
-
private readonly http;
|
|
561
|
-
constructor(http: HttpClient);
|
|
562
|
-
/**
|
|
563
|
-
* List all LLM provider keys
|
|
564
|
-
*
|
|
565
|
-
* @returns List of LLM provider keys
|
|
566
|
-
*
|
|
567
|
-
* @example
|
|
568
|
-
* ```ts
|
|
569
|
-
* const { items, total } = await client.llmProviderKeys.list();
|
|
570
|
-
* console.log(`Found ${total} keys`);
|
|
571
|
-
* for (const key of items) {
|
|
572
|
-
* console.log(`${key.provider}: ${key.maskedKey} (default: ${key.isDefault})`);
|
|
573
|
-
* }
|
|
574
|
-
* ```
|
|
575
|
-
*/
|
|
576
|
-
list(): Promise<ISynovaLlmProviderKeyListResponse>;
|
|
577
|
-
/**
|
|
578
|
-
* Get an LLM provider key by ID
|
|
579
|
-
*
|
|
580
|
-
* @param id - Key ID (e.g., 'lpk_abc123')
|
|
581
|
-
* @returns LLM provider key details
|
|
582
|
-
*
|
|
583
|
-
* @example
|
|
584
|
-
* ```ts
|
|
585
|
-
* const key = await client.llmProviderKeys.get('lpk_abc123');
|
|
586
|
-
* console.log(`Provider: ${key.provider}, Default: ${key.isDefault}`);
|
|
587
|
-
* ```
|
|
588
|
-
*/
|
|
589
|
-
get(id: string): Promise<ISynovaLlmProviderKey>;
|
|
590
|
-
/**
|
|
591
|
-
* Create a new LLM provider key
|
|
592
|
-
*
|
|
593
|
-
* The first key created for a provider will automatically be set as the default.
|
|
594
|
-
*
|
|
595
|
-
* @param options - Key creation options
|
|
596
|
-
* @returns Created LLM provider key
|
|
597
|
-
*
|
|
598
|
-
* @example
|
|
599
|
-
* ```ts
|
|
600
|
-
* // Create OpenAI key
|
|
601
|
-
* const key = await client.llmProviderKeys.create({
|
|
602
|
-
* provider: 'openai',
|
|
603
|
-
* apiKey: 'sk-...',
|
|
604
|
-
* label: 'Production Key',
|
|
605
|
-
* defaultModel: 'gpt-4o',
|
|
606
|
-
* });
|
|
607
|
-
*
|
|
608
|
-
* // Create Azure OpenAI key
|
|
609
|
-
* const azureKey = await client.llmProviderKeys.create({
|
|
610
|
-
* provider: 'azure_openai',
|
|
611
|
-
* apiKey: 'your-azure-key',
|
|
612
|
-
* azure: {
|
|
613
|
-
* endpoint: 'https://my-resource.openai.azure.com',
|
|
614
|
-
* },
|
|
615
|
-
* label: 'Azure Production',
|
|
616
|
-
* });
|
|
617
|
-
* ```
|
|
618
|
-
*/
|
|
619
|
-
create(options: ISynovaCreateLlmProviderKeyOptions): Promise<ISynovaLlmProviderKey>;
|
|
620
|
-
/**
|
|
621
|
-
* Set an LLM provider key as the default for its provider
|
|
622
|
-
*
|
|
623
|
-
* The previous default key for this provider will be unset.
|
|
624
|
-
*
|
|
625
|
-
* @param id - Key ID to set as default
|
|
626
|
-
* @returns Updated LLM provider key
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```ts
|
|
630
|
-
* const key = await client.llmProviderKeys.setDefault('lpk_abc123');
|
|
631
|
-
* console.log(`${key.id} is now the default for ${key.provider}`);
|
|
632
|
-
* ```
|
|
633
|
-
*/
|
|
634
|
-
setDefault(id: string): Promise<ISynovaLlmProviderKey>;
|
|
635
|
-
/**
|
|
636
|
-
* Delete an LLM provider key
|
|
637
|
-
*
|
|
638
|
-
* @param id - Key ID to delete
|
|
639
|
-
*
|
|
640
|
-
* @example
|
|
641
|
-
* ```ts
|
|
642
|
-
* await client.llmProviderKeys.delete('lpk_abc123');
|
|
643
|
-
* ```
|
|
644
|
-
*/
|
|
645
|
-
delete(id: string): Promise<void>;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
559
|
/**
|
|
649
560
|
* Synova Cloud SDK client
|
|
650
561
|
*
|
|
@@ -657,10 +568,20 @@ declare class LlmProviderKeysResource {
|
|
|
657
568
|
* // Get a prompt
|
|
658
569
|
* const prompt = await client.prompts.get('prm_abc123');
|
|
659
570
|
*
|
|
660
|
-
* // Execute a prompt
|
|
571
|
+
* // Execute a prompt with direct API key
|
|
661
572
|
* const result = await client.prompts.execute('prm_abc123', {
|
|
662
573
|
* provider: 'openai',
|
|
663
574
|
* model: 'gpt-4o',
|
|
575
|
+
* apiKey: 'sk-...',
|
|
576
|
+
* variables: { topic: 'TypeScript' },
|
|
577
|
+
* });
|
|
578
|
+
*
|
|
579
|
+
* // Execute with Azure OpenAI
|
|
580
|
+
* const azureResult = await client.prompts.execute('prm_abc123', {
|
|
581
|
+
* provider: 'azure_openai',
|
|
582
|
+
* model: 'gpt-4o',
|
|
583
|
+
* apiKey: 'your-azure-key',
|
|
584
|
+
* azureEndpoint: 'https://my-resource.openai.azure.com',
|
|
664
585
|
* variables: { topic: 'TypeScript' },
|
|
665
586
|
* });
|
|
666
587
|
*
|
|
@@ -670,14 +591,6 @@ declare class LlmProviderKeysResource {
|
|
|
670
591
|
* // Get models for a specific provider
|
|
671
592
|
* const openaiModels = await client.models.getByProvider('openai');
|
|
672
593
|
*
|
|
673
|
-
* // Manage LLM provider keys
|
|
674
|
-
* const { items } = await client.llmProviderKeys.list();
|
|
675
|
-
* const newKey = await client.llmProviderKeys.create({
|
|
676
|
-
* provider: 'openai',
|
|
677
|
-
* apiKey: 'sk-...',
|
|
678
|
-
* label: 'Production',
|
|
679
|
-
* });
|
|
680
|
-
*
|
|
681
594
|
* // With custom retry config
|
|
682
595
|
* const clientWithRetry = new SynovaCloudSdk('your-api-key', {
|
|
683
596
|
* retry: {
|
|
@@ -692,7 +605,6 @@ declare class SynovaCloudSdk {
|
|
|
692
605
|
readonly prompts: PromptsResource;
|
|
693
606
|
readonly models: ModelsResource;
|
|
694
607
|
readonly files: FilesResource;
|
|
695
|
-
readonly llmProviderKeys: LlmProviderKeysResource;
|
|
696
608
|
private readonly http;
|
|
697
609
|
/**
|
|
698
610
|
* Create a new Synova Cloud SDK client
|
|
@@ -763,5 +675,336 @@ declare class NetworkSynovaError extends SynovaError {
|
|
|
763
675
|
readonly cause?: Error;
|
|
764
676
|
constructor(message: string, cause?: Error);
|
|
765
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* Error thrown when LLM execution fails (returned in response with type='error')
|
|
680
|
+
*/
|
|
681
|
+
declare class ExecutionSynovaError extends SynovaError {
|
|
682
|
+
readonly code: string;
|
|
683
|
+
readonly provider?: string;
|
|
684
|
+
readonly retryable: boolean;
|
|
685
|
+
readonly retryAfterMs?: number;
|
|
686
|
+
readonly details?: ISynovaExecutionError['details'];
|
|
687
|
+
constructor(error: ISynovaExecutionError);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Validation violation details
|
|
691
|
+
*/
|
|
692
|
+
interface IValidationViolation {
|
|
693
|
+
property: string;
|
|
694
|
+
constraints: Record<string, string>;
|
|
695
|
+
value?: unknown;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Error thrown when LLM response fails class-validator validation
|
|
699
|
+
*/
|
|
700
|
+
declare class ValidationSynovaError extends SynovaError {
|
|
701
|
+
readonly violations: IValidationViolation[];
|
|
702
|
+
constructor(violations: IValidationViolation[]);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Generates JSON Schema from TypeScript classes decorated with schema decorators.
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```typescript
|
|
710
|
+
* import { ClassSchema, Description, Example, SchemaMin, SchemaMax } from '@synova-cloud/sdk';
|
|
711
|
+
*
|
|
712
|
+
* class User {
|
|
713
|
+
* @Description('User ID')
|
|
714
|
+
* @Example('usr_123')
|
|
715
|
+
* id: string;
|
|
716
|
+
*
|
|
717
|
+
* @Description('User age')
|
|
718
|
+
* @SchemaMin(0)
|
|
719
|
+
* @SchemaMax(150)
|
|
720
|
+
* age: number;
|
|
721
|
+
* }
|
|
722
|
+
*
|
|
723
|
+
* const schema = ClassSchema.generate(User);
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
declare class ClassSchema {
|
|
727
|
+
/**
|
|
728
|
+
* Generate JSON Schema from a class
|
|
729
|
+
*/
|
|
730
|
+
static generate<T>(targetClass: TClassConstructor<T>, options?: IGenerateSchemaOptions): IJsonSchema;
|
|
731
|
+
/**
|
|
732
|
+
* Get all properties with their schemas
|
|
733
|
+
*/
|
|
734
|
+
private static getProperties;
|
|
735
|
+
/**
|
|
736
|
+
* Get property names from class-validator metadata
|
|
737
|
+
*/
|
|
738
|
+
private static getClassValidatorProperties;
|
|
739
|
+
/**
|
|
740
|
+
* Get property names from our decorator metadata
|
|
741
|
+
*/
|
|
742
|
+
private static getDecoratorProperties;
|
|
743
|
+
/**
|
|
744
|
+
* Get JSON Schema for a single property
|
|
745
|
+
*/
|
|
746
|
+
private static getPropertySchema;
|
|
747
|
+
/**
|
|
748
|
+
* Get base schema from TypeScript type
|
|
749
|
+
*/
|
|
750
|
+
private static getBaseTypeSchema;
|
|
751
|
+
/**
|
|
752
|
+
* Get schema for array items
|
|
753
|
+
*/
|
|
754
|
+
private static getArrayItemSchema;
|
|
755
|
+
/**
|
|
756
|
+
* Apply class-validator constraints to schema
|
|
757
|
+
*/
|
|
758
|
+
private static applyClassValidatorConstraints;
|
|
759
|
+
/**
|
|
760
|
+
* Apply a single class-validator constraint
|
|
761
|
+
*/
|
|
762
|
+
private static applyValidationConstraint;
|
|
763
|
+
/**
|
|
764
|
+
* Apply our decorator metadata to schema.
|
|
765
|
+
* Our decorators take precedence over class-validator if both are used.
|
|
766
|
+
*/
|
|
767
|
+
private static applyDecoratorMetadata;
|
|
768
|
+
/**
|
|
769
|
+
* Get required properties (properties without @IsOptional)
|
|
770
|
+
*/
|
|
771
|
+
private static getRequiredProperties;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Adds a description to the property schema.
|
|
776
|
+
* Helps LLMs understand the expected content.
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* ```typescript
|
|
780
|
+
* class Article {
|
|
781
|
+
* @Description('SEO-optimized article title, 50-60 characters')
|
|
782
|
+
* title: string;
|
|
783
|
+
* }
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
declare function Description(description: string): PropertyDecorator;
|
|
787
|
+
/**
|
|
788
|
+
* Adds example values to the property schema.
|
|
789
|
+
* Helps LLMs understand the expected format.
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* ```typescript
|
|
793
|
+
* class Article {
|
|
794
|
+
* @Example('How to Optimize SQL Queries', '10 Tips for Better Code')
|
|
795
|
+
* title: string;
|
|
796
|
+
* }
|
|
797
|
+
* ```
|
|
798
|
+
*/
|
|
799
|
+
declare function Example(...examples: unknown[]): PropertyDecorator;
|
|
800
|
+
/**
|
|
801
|
+
* Sets the default value for the property.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* ```typescript
|
|
805
|
+
* class Settings {
|
|
806
|
+
* @Default('en')
|
|
807
|
+
* language: string;
|
|
808
|
+
* }
|
|
809
|
+
* ```
|
|
810
|
+
*/
|
|
811
|
+
declare function Default(value: unknown): PropertyDecorator;
|
|
812
|
+
/**
|
|
813
|
+
* Sets the type of array items.
|
|
814
|
+
* Required since TypeScript loses array item types at runtime.
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* ```typescript
|
|
818
|
+
* class Article {
|
|
819
|
+
* @ArrayItems(String)
|
|
820
|
+
* keywords: string[];
|
|
821
|
+
*
|
|
822
|
+
* @ArrayItems(Comment)
|
|
823
|
+
* comments: Comment[];
|
|
824
|
+
* }
|
|
825
|
+
* ```
|
|
826
|
+
*/
|
|
827
|
+
declare function ArrayItems(itemType: TClassConstructor | StringConstructor | NumberConstructor | BooleanConstructor): PropertyDecorator;
|
|
828
|
+
/**
|
|
829
|
+
* Sets semantic format for string (email, uri, uuid, date-time, etc.).
|
|
830
|
+
*
|
|
831
|
+
* @example
|
|
832
|
+
* ```typescript
|
|
833
|
+
* class User {
|
|
834
|
+
* @Format('email')
|
|
835
|
+
* email: string;
|
|
836
|
+
*
|
|
837
|
+
* @Format('date-time')
|
|
838
|
+
* createdAt: string;
|
|
839
|
+
* }
|
|
840
|
+
* ```
|
|
841
|
+
*/
|
|
842
|
+
declare function Format(format: TJsonSchemaFormat): PropertyDecorator;
|
|
843
|
+
/**
|
|
844
|
+
* Marks the property as nullable (can be null).
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* ```typescript
|
|
848
|
+
* class User {
|
|
849
|
+
* @Nullable()
|
|
850
|
+
* middleName: string | null;
|
|
851
|
+
* }
|
|
852
|
+
* ```
|
|
853
|
+
*/
|
|
854
|
+
declare function Nullable(): PropertyDecorator;
|
|
855
|
+
/**
|
|
856
|
+
* Sets minimum string length.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```typescript
|
|
860
|
+
* class User {
|
|
861
|
+
* @SchemaMinLength(3)
|
|
862
|
+
* username: string;
|
|
863
|
+
* }
|
|
864
|
+
* ```
|
|
865
|
+
*/
|
|
866
|
+
declare function SchemaMinLength(length: number): PropertyDecorator;
|
|
867
|
+
/**
|
|
868
|
+
* Sets maximum string length.
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* ```typescript
|
|
872
|
+
* class User {
|
|
873
|
+
* @SchemaMaxLength(100)
|
|
874
|
+
* bio: string;
|
|
875
|
+
* }
|
|
876
|
+
* ```
|
|
877
|
+
*/
|
|
878
|
+
declare function SchemaMaxLength(length: number): PropertyDecorator;
|
|
879
|
+
/**
|
|
880
|
+
* Sets regex pattern for string validation.
|
|
881
|
+
*
|
|
882
|
+
* @example
|
|
883
|
+
* ```typescript
|
|
884
|
+
* class User {
|
|
885
|
+
* @SchemaPattern('^[a-z0-9_]+$')
|
|
886
|
+
* username: string;
|
|
887
|
+
* }
|
|
888
|
+
* ```
|
|
889
|
+
*/
|
|
890
|
+
declare function SchemaPattern(pattern: string): PropertyDecorator;
|
|
891
|
+
/**
|
|
892
|
+
* Sets minimum value (inclusive).
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* ```typescript
|
|
896
|
+
* class Product {
|
|
897
|
+
* @SchemaMin(0)
|
|
898
|
+
* price: number;
|
|
899
|
+
* }
|
|
900
|
+
* ```
|
|
901
|
+
*/
|
|
902
|
+
declare function SchemaMin(value: number): PropertyDecorator;
|
|
903
|
+
/**
|
|
904
|
+
* Sets maximum value (inclusive).
|
|
905
|
+
*
|
|
906
|
+
* @example
|
|
907
|
+
* ```typescript
|
|
908
|
+
* class Rating {
|
|
909
|
+
* @SchemaMax(5)
|
|
910
|
+
* score: number;
|
|
911
|
+
* }
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
declare function SchemaMax(value: number): PropertyDecorator;
|
|
915
|
+
/**
|
|
916
|
+
* Sets minimum value (exclusive).
|
|
917
|
+
*
|
|
918
|
+
* @example
|
|
919
|
+
* ```typescript
|
|
920
|
+
* class Discount {
|
|
921
|
+
* @ExclusiveMin(0) // must be > 0
|
|
922
|
+
* percentage: number;
|
|
923
|
+
* }
|
|
924
|
+
* ```
|
|
925
|
+
*/
|
|
926
|
+
declare function ExclusiveMin(value: number): PropertyDecorator;
|
|
927
|
+
/**
|
|
928
|
+
* Sets maximum value (exclusive).
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
* ```typescript
|
|
932
|
+
* class Probability {
|
|
933
|
+
* @ExclusiveMax(1) // must be < 1
|
|
934
|
+
* value: number;
|
|
935
|
+
* }
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
declare function ExclusiveMax(value: number): PropertyDecorator;
|
|
939
|
+
/**
|
|
940
|
+
* Value must be a multiple of this number.
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```typescript
|
|
944
|
+
* class Currency {
|
|
945
|
+
* @MultipleOf(0.01)
|
|
946
|
+
* amount: number;
|
|
947
|
+
* }
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
declare function MultipleOf(value: number): PropertyDecorator;
|
|
951
|
+
/**
|
|
952
|
+
* Sets minimum array length.
|
|
953
|
+
*
|
|
954
|
+
* @example
|
|
955
|
+
* ```typescript
|
|
956
|
+
* class Order {
|
|
957
|
+
* @SchemaMinItems(1)
|
|
958
|
+
* items: OrderItem[];
|
|
959
|
+
* }
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
declare function SchemaMinItems(count: number): PropertyDecorator;
|
|
963
|
+
/**
|
|
964
|
+
* Sets maximum array length.
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* ```typescript
|
|
968
|
+
* class Article {
|
|
969
|
+
* @SchemaMaxItems(10)
|
|
970
|
+
* tags: string[];
|
|
971
|
+
* }
|
|
972
|
+
* ```
|
|
973
|
+
*/
|
|
974
|
+
declare function SchemaMaxItems(count: number): PropertyDecorator;
|
|
975
|
+
/**
|
|
976
|
+
* Requires all array items to be unique.
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```typescript
|
|
980
|
+
* class User {
|
|
981
|
+
* @SchemaUniqueItems()
|
|
982
|
+
* roles: string[];
|
|
983
|
+
* }
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
declare function SchemaUniqueItems(): PropertyDecorator;
|
|
987
|
+
/**
|
|
988
|
+
* Sets allowed enum values.
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* ```typescript
|
|
992
|
+
* class User {
|
|
993
|
+
* @SchemaEnum(['admin', 'user', 'guest'])
|
|
994
|
+
* role: string;
|
|
995
|
+
* }
|
|
996
|
+
* ```
|
|
997
|
+
*
|
|
998
|
+
* With TypeScript enum:
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* enum Status { Active = 'active', Inactive = 'inactive' }
|
|
1001
|
+
*
|
|
1002
|
+
* class User {
|
|
1003
|
+
* @SchemaEnum(Object.values(Status))
|
|
1004
|
+
* status: Status;
|
|
1005
|
+
* }
|
|
1006
|
+
* ```
|
|
1007
|
+
*/
|
|
1008
|
+
declare function SchemaEnum(values: (string | number | boolean | null)[]): PropertyDecorator;
|
|
766
1009
|
|
|
767
|
-
export { ApiSynovaError, AuthSynovaError, type
|
|
1010
|
+
export { ApiSynovaError, ArrayItems, AuthSynovaError, ClassSchema, Default, Description, Example, ExclusiveMax, ExclusiveMin, ExecutionSynovaError, Format, type IGenerateSchemaOptions, type IJsonSchema, type ISynovaConfig, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecuteTypedOptions, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaToolCall, type ISynovaToolResult, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type IValidationViolation, MultipleOf, NetworkSynovaError, NotFoundSynovaError, Nullable, RateLimitSynovaError, SCHEMA_METADATA_KEYS, SchemaEnum, SchemaMax, SchemaMaxItems, SchemaMaxLength, SchemaMin, SchemaMinItems, SchemaMinLength, SchemaPattern, SchemaUniqueItems, ServerSynovaError, SynovaCloudSdk, SynovaError, type TClassConstructor, type TJsonSchemaFormat, type TJsonSchemaType, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaUsageType, TimeoutSynovaError, ValidationSynovaError };
|