@synova-cloud/sdk 1.9.2 → 2.0.1
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.cjs +235 -512
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +190 -386
- package/dist/index.d.ts +190 -386
- package/dist/index.js +231 -491
- package/dist/index.js.map +1 -1
- package/package.json +28 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Schema primitive types
|
|
3
3
|
*/
|
|
4
|
-
type TJsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array';
|
|
4
|
+
type TJsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
5
5
|
/**
|
|
6
6
|
* JSON Schema string formats
|
|
7
7
|
* @see https://json-schema.org/understanding-json-schema/reference/string#built-in-formats
|
|
@@ -38,41 +38,117 @@ interface IJsonSchema {
|
|
|
38
38
|
oneOf?: IJsonSchema[];
|
|
39
39
|
not?: IJsonSchema;
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Interface for schema adapters that convert various schema libraries to JSON Schema
|
|
44
|
+
*/
|
|
45
|
+
interface ISchemaAdapter<TSchema = unknown> {
|
|
46
|
+
/**
|
|
47
|
+
* Check if this adapter can handle the given schema
|
|
48
|
+
*/
|
|
49
|
+
canHandle(schema: unknown): schema is TSchema;
|
|
50
|
+
/**
|
|
51
|
+
* Convert the schema to JSON Schema format
|
|
52
|
+
*/
|
|
53
|
+
toJsonSchema(schema: TSchema): IJsonSchema;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Schema type identifier
|
|
58
|
+
*/
|
|
59
|
+
type TSchemaType = 'zod' | 'yup' | 'joi' | 'json-schema' | 'unknown';
|
|
60
|
+
/**
|
|
61
|
+
* Zod-like schema interface
|
|
62
|
+
*/
|
|
63
|
+
interface IZodLike {
|
|
64
|
+
_def: {
|
|
65
|
+
typeName: string;
|
|
66
|
+
};
|
|
67
|
+
safeParse: unknown;
|
|
68
|
+
}
|
|
41
69
|
/**
|
|
42
|
-
*
|
|
70
|
+
* Yup-like schema interface
|
|
43
71
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
readonly ADDITIONAL_PROPERTIES: "synova:schema:additionalProperties";
|
|
64
|
-
};
|
|
72
|
+
interface IYupLike {
|
|
73
|
+
__isYupSchema__: true;
|
|
74
|
+
}
|
|
65
75
|
/**
|
|
66
|
-
*
|
|
76
|
+
* Joi-like schema interface
|
|
67
77
|
*/
|
|
68
|
-
interface
|
|
69
|
-
|
|
70
|
-
additionalProperties?: boolean;
|
|
78
|
+
interface IJoiLike {
|
|
79
|
+
describe: () => unknown;
|
|
71
80
|
}
|
|
72
81
|
/**
|
|
73
|
-
*
|
|
82
|
+
* Supported schema input types.
|
|
83
|
+
* Provides better type hints while maintaining flexibility.
|
|
84
|
+
*/
|
|
85
|
+
type TSchemaInput = IJsonSchema | IZodLike | IYupLike | IJoiLike | unknown;
|
|
86
|
+
/**
|
|
87
|
+
* Schema resolver that converts various schema libraries to JSON Schema.
|
|
88
|
+
* Supports Zod, Yup, Joi, and raw JSON Schema.
|
|
74
89
|
*/
|
|
75
|
-
|
|
90
|
+
declare class SchemaResolver {
|
|
91
|
+
private static adapters;
|
|
92
|
+
/**
|
|
93
|
+
* Register a custom adapter.
|
|
94
|
+
*
|
|
95
|
+
* @param adapter - The adapter to register
|
|
96
|
+
* @param position - Where to insert: 'first' adds at the beginning,
|
|
97
|
+
* 'last' adds before JsonSchemaAdapter (fallback)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* SchemaResolver.registerAdapter(new MyCustomAdapter(), 'first');
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
static registerAdapter(adapter: ISchemaAdapter, position?: 'first' | 'last'): void;
|
|
105
|
+
/**
|
|
106
|
+
* Reset adapters to default configuration.
|
|
107
|
+
* Removes all custom adapters.
|
|
108
|
+
*/
|
|
109
|
+
static resetAdapters(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Resolve a schema input to JSON Schema format.
|
|
112
|
+
*
|
|
113
|
+
* @param schema - Schema from Zod, Yup, Joi, or raw JSON Schema
|
|
114
|
+
* @returns JSON Schema representation
|
|
115
|
+
* @throws Error if schema type is not supported
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // Zod
|
|
120
|
+
* const zodSchema = z.object({ title: z.string() });
|
|
121
|
+
* const jsonSchema = SchemaResolver.resolve(zodSchema);
|
|
122
|
+
*
|
|
123
|
+
* // Yup
|
|
124
|
+
* const yupSchema = yup.object({ title: yup.string().required() });
|
|
125
|
+
* const jsonSchema = SchemaResolver.resolve(yupSchema);
|
|
126
|
+
*
|
|
127
|
+
* // Joi
|
|
128
|
+
* const joiSchema = Joi.object({ title: Joi.string() });
|
|
129
|
+
* const jsonSchema = SchemaResolver.resolve(joiSchema);
|
|
130
|
+
*
|
|
131
|
+
* // Raw JSON Schema (passthrough)
|
|
132
|
+
* const rawSchema = { type: 'object', properties: { title: { type: 'string' } } };
|
|
133
|
+
* const jsonSchema = SchemaResolver.resolve(rawSchema);
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
static resolve(schema: TSchemaInput): IJsonSchema;
|
|
137
|
+
/**
|
|
138
|
+
* Check if a schema is supported.
|
|
139
|
+
*
|
|
140
|
+
* @param schema - Schema to check
|
|
141
|
+
* @returns true if the schema is supported
|
|
142
|
+
*/
|
|
143
|
+
static isSupported(schema: unknown): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Get the type of a schema.
|
|
146
|
+
*
|
|
147
|
+
* @param schema - Schema to identify
|
|
148
|
+
* @returns Schema type identifier
|
|
149
|
+
*/
|
|
150
|
+
static getSchemaType(schema: unknown): TSchemaType;
|
|
151
|
+
}
|
|
76
152
|
|
|
77
153
|
type TSynovaMessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
78
154
|
type TSynovaResponseType = 'message' | 'tool_calls' | 'image' | 'audio' | 'error';
|
|
@@ -177,8 +253,8 @@ interface ISynovaExecuteOptions {
|
|
|
177
253
|
metadata?: Record<string, string>;
|
|
178
254
|
/** Model parameters (temperature, maxTokens, topP, topK, etc.) */
|
|
179
255
|
parameters?: Record<string, unknown>;
|
|
180
|
-
/**
|
|
181
|
-
responseSchema?:
|
|
256
|
+
/** Schema for structured output (Zod, Yup, Joi, or raw JSON Schema) */
|
|
257
|
+
responseSchema?: TSchemaInput;
|
|
182
258
|
/** Session ID for trace grouping (enables multi-call trace view in observability) */
|
|
183
259
|
sessionId?: string;
|
|
184
260
|
}
|
|
@@ -274,6 +350,14 @@ interface ISynovaExecuteResponse {
|
|
|
274
350
|
/** Span ID (for observability - individual call within trace) */
|
|
275
351
|
spanId?: string;
|
|
276
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Typed execute response - returned when responseSchema is provided.
|
|
355
|
+
* Contains the typed object along with all metadata (usage, spans, etc.)
|
|
356
|
+
*/
|
|
357
|
+
interface ISynovaTypedExecuteResponse<T> extends Omit<ISynovaExecuteResponse, 'object'> {
|
|
358
|
+
/** Typed structured output object */
|
|
359
|
+
object: T;
|
|
360
|
+
}
|
|
277
361
|
interface ISynovaModelCapabilities {
|
|
278
362
|
text_generation?: boolean;
|
|
279
363
|
function_calling?: boolean;
|
|
@@ -473,15 +557,6 @@ declare class HttpClient {
|
|
|
473
557
|
private log;
|
|
474
558
|
}
|
|
475
559
|
|
|
476
|
-
/**
|
|
477
|
-
* Execute options with optional responseClass for typed responses
|
|
478
|
-
*/
|
|
479
|
-
interface ISynovaExecuteTypedOptions<T> extends Omit<ISynovaExecuteOptions, 'responseSchema'> {
|
|
480
|
-
/** Class to use for response typing and schema generation */
|
|
481
|
-
responseClass: TClassConstructor<T>;
|
|
482
|
-
/** Enable class-validator validation (default: true) */
|
|
483
|
-
validate?: boolean;
|
|
484
|
-
}
|
|
485
560
|
declare class PromptsResource {
|
|
486
561
|
private readonly http;
|
|
487
562
|
constructor(http: HttpClient);
|
|
@@ -490,26 +565,38 @@ declare class PromptsResource {
|
|
|
490
565
|
*/
|
|
491
566
|
get(promptId: string, options?: ISynovaGetPromptOptions): Promise<ISynovaPrompt>;
|
|
492
567
|
/**
|
|
493
|
-
* Execute a prompt with typed response
|
|
568
|
+
* Execute a prompt with typed response using responseSchema
|
|
494
569
|
*
|
|
495
570
|
* @example
|
|
496
571
|
* ```ts
|
|
497
|
-
* // With
|
|
498
|
-
* const
|
|
572
|
+
* // With Zod schema - returns full response with typed object
|
|
573
|
+
* const schema = z.object({ title: z.string() });
|
|
574
|
+
* const result = await client.prompts.execute<z.infer<typeof schema>>('prm_abc123', {
|
|
499
575
|
* provider: 'openai',
|
|
500
576
|
* model: 'gpt-4o',
|
|
501
|
-
*
|
|
577
|
+
* responseSchema: schema,
|
|
502
578
|
* });
|
|
503
|
-
* console.log(
|
|
579
|
+
* console.log(result.object.title); // Typed as string
|
|
580
|
+
* console.log(result.executionUsage); // Token usage available
|
|
581
|
+
*
|
|
582
|
+
* // With raw JSON Schema
|
|
583
|
+
* const result = await client.prompts.execute<{ title: string }>('prm_abc123', {
|
|
584
|
+
* provider: 'openai',
|
|
585
|
+
* model: 'gpt-4o',
|
|
586
|
+
* responseSchema: { type: 'object', properties: { title: { type: 'string' } } },
|
|
587
|
+
* });
|
|
588
|
+
* console.log(result.object.title); // Typed
|
|
504
589
|
* ```
|
|
505
590
|
*/
|
|
506
|
-
execute<T>(promptId: string, options:
|
|
591
|
+
execute<T>(promptId: string, options: ISynovaExecuteOptions & {
|
|
592
|
+
responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
|
|
593
|
+
}): Promise<ISynovaTypedExecuteResponse<T>>;
|
|
507
594
|
/**
|
|
508
595
|
* Execute a prompt
|
|
509
596
|
*
|
|
510
597
|
* @example
|
|
511
598
|
* ```ts
|
|
512
|
-
* // Without
|
|
599
|
+
* // Without responseSchema - returns ISynovaExecuteResponse
|
|
513
600
|
* const result = await client.prompts.execute('prm_abc123', {
|
|
514
601
|
* provider: 'openai',
|
|
515
602
|
* model: 'gpt-4o',
|
|
@@ -523,7 +610,9 @@ declare class PromptsResource {
|
|
|
523
610
|
/**
|
|
524
611
|
* Execute a prompt by tag with typed response
|
|
525
612
|
*/
|
|
526
|
-
executeByTag<T>(promptId: string, tag: string, options:
|
|
613
|
+
executeByTag<T>(promptId: string, tag: string, options: ISynovaExecuteOptions & {
|
|
614
|
+
responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
|
|
615
|
+
}): Promise<ISynovaTypedExecuteResponse<T>>;
|
|
527
616
|
/**
|
|
528
617
|
* Execute a prompt by tag
|
|
529
618
|
*/
|
|
@@ -531,24 +620,13 @@ declare class PromptsResource {
|
|
|
531
620
|
/**
|
|
532
621
|
* Execute a prompt by version with typed response
|
|
533
622
|
*/
|
|
534
|
-
executeByVersion<T>(promptId: string, version: string, options:
|
|
623
|
+
executeByVersion<T>(promptId: string, version: string, options: ISynovaExecuteOptions & {
|
|
624
|
+
responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
|
|
625
|
+
}): Promise<ISynovaTypedExecuteResponse<T>>;
|
|
535
626
|
/**
|
|
536
627
|
* Execute a prompt by version
|
|
537
628
|
*/
|
|
538
629
|
executeByVersion(promptId: string, version: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
539
|
-
/**
|
|
540
|
-
* Execute raw request without typed response
|
|
541
|
-
* @throws {ExecutionSynovaError} If LLM returns an error
|
|
542
|
-
*/
|
|
543
|
-
private executeRaw;
|
|
544
|
-
/**
|
|
545
|
-
* Execute with typed response class
|
|
546
|
-
*/
|
|
547
|
-
private executeTyped;
|
|
548
|
-
/**
|
|
549
|
-
* Validate object using class-validator
|
|
550
|
-
*/
|
|
551
|
-
private validateObject;
|
|
552
630
|
}
|
|
553
631
|
|
|
554
632
|
declare class ModelsResource {
|
|
@@ -889,349 +967,75 @@ declare class ExecutionSynovaError extends SynovaError {
|
|
|
889
967
|
readonly details?: ISynovaExecutionError['details'];
|
|
890
968
|
constructor(error: ISynovaExecutionError);
|
|
891
969
|
}
|
|
892
|
-
/**
|
|
893
|
-
* Validation violation details
|
|
894
|
-
*/
|
|
895
|
-
interface IValidationViolation {
|
|
896
|
-
property: string;
|
|
897
|
-
constraints: Record<string, string>;
|
|
898
|
-
value?: unknown;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Error thrown when LLM response fails class-validator validation
|
|
902
|
-
*/
|
|
903
|
-
declare class ValidationSynovaError extends SynovaError {
|
|
904
|
-
readonly violations: IValidationViolation[];
|
|
905
|
-
constructor(violations: IValidationViolation[]);
|
|
906
|
-
}
|
|
907
970
|
|
|
908
971
|
/**
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
* @example
|
|
912
|
-
* ```typescript
|
|
913
|
-
* import { ClassSchema, Description, Example, SchemaMin, SchemaMax } from '@synova-cloud/sdk';
|
|
914
|
-
*
|
|
915
|
-
* class User {
|
|
916
|
-
* @Description('User ID')
|
|
917
|
-
* @Example('usr_123')
|
|
918
|
-
* id: string;
|
|
919
|
-
*
|
|
920
|
-
* @Description('User age')
|
|
921
|
-
* @SchemaMin(0)
|
|
922
|
-
* @SchemaMax(150)
|
|
923
|
-
* age: number;
|
|
924
|
-
* }
|
|
925
|
-
*
|
|
926
|
-
* const schema = ClassSchema.generate(User);
|
|
927
|
-
* ```
|
|
972
|
+
* Passthrough adapter for raw JSON Schema objects.
|
|
973
|
+
* Transforms `nullable: true` to `type: ["...", "null"]` recursively.
|
|
928
974
|
*/
|
|
929
|
-
declare class
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
static generate<T>(targetClass: TClassConstructor<T>, options?: IGenerateSchemaOptions): IJsonSchema;
|
|
975
|
+
declare class JsonSchemaAdapter implements ISchemaAdapter<IJsonSchema> {
|
|
976
|
+
private static readonly VALID_JSON_SCHEMA_TYPES;
|
|
977
|
+
canHandle(schema: unknown): schema is IJsonSchema;
|
|
978
|
+
toJsonSchema(schema: IJsonSchema): IJsonSchema;
|
|
934
979
|
/**
|
|
935
|
-
*
|
|
980
|
+
* Recursively transform `nullable: true` to `type: ["...", "null"]`
|
|
936
981
|
*/
|
|
937
|
-
private
|
|
938
|
-
/**
|
|
939
|
-
* Get property names from class-validator metadata
|
|
940
|
-
*/
|
|
941
|
-
private static getClassValidatorProperties;
|
|
942
|
-
/**
|
|
943
|
-
* Get property names from our decorator metadata
|
|
944
|
-
*/
|
|
945
|
-
private static getDecoratorProperties;
|
|
946
|
-
/**
|
|
947
|
-
* Get JSON Schema for a single property
|
|
948
|
-
*/
|
|
949
|
-
private static getPropertySchema;
|
|
950
|
-
/**
|
|
951
|
-
* Get base schema from TypeScript type
|
|
952
|
-
*/
|
|
953
|
-
private static getBaseTypeSchema;
|
|
954
|
-
/**
|
|
955
|
-
* Get schema for array items
|
|
956
|
-
*/
|
|
957
|
-
private static getArrayItemSchema;
|
|
958
|
-
/**
|
|
959
|
-
* Apply class-validator constraints to schema
|
|
960
|
-
*/
|
|
961
|
-
private static applyClassValidatorConstraints;
|
|
962
|
-
/**
|
|
963
|
-
* Apply a single class-validator constraint
|
|
964
|
-
*/
|
|
965
|
-
private static applyValidationConstraint;
|
|
966
|
-
/**
|
|
967
|
-
* Apply our decorator metadata to schema.
|
|
968
|
-
* Our decorators take precedence over class-validator if both are used.
|
|
969
|
-
*/
|
|
970
|
-
private static applyDecoratorMetadata;
|
|
971
|
-
/**
|
|
972
|
-
* Get required properties (properties without @IsOptional)
|
|
973
|
-
*/
|
|
974
|
-
private static getRequiredProperties;
|
|
982
|
+
private transformNullable;
|
|
975
983
|
}
|
|
976
984
|
|
|
977
985
|
/**
|
|
978
|
-
*
|
|
979
|
-
* Helps LLMs understand the expected content.
|
|
980
|
-
*
|
|
981
|
-
* @example
|
|
982
|
-
* ```typescript
|
|
983
|
-
* class Article {
|
|
984
|
-
* @Description('SEO-optimized article title, 50-60 characters')
|
|
985
|
-
* title: string;
|
|
986
|
-
* }
|
|
987
|
-
* ```
|
|
986
|
+
* Zod schema type definition
|
|
988
987
|
*/
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
* @Example('How to Optimize SQL Queries', '10 Tips for Better Code')
|
|
998
|
-
* title: string;
|
|
999
|
-
* }
|
|
1000
|
-
* ```
|
|
1001
|
-
*/
|
|
1002
|
-
declare function Example(...examples: unknown[]): PropertyDecorator;
|
|
1003
|
-
/**
|
|
1004
|
-
* Sets the default value for the property.
|
|
1005
|
-
*
|
|
1006
|
-
* @example
|
|
1007
|
-
* ```typescript
|
|
1008
|
-
* class Settings {
|
|
1009
|
-
* @Default('en')
|
|
1010
|
-
* language: string;
|
|
1011
|
-
* }
|
|
1012
|
-
* ```
|
|
1013
|
-
*/
|
|
1014
|
-
declare function Default(value: unknown): PropertyDecorator;
|
|
1015
|
-
/**
|
|
1016
|
-
* Sets the type of array items.
|
|
1017
|
-
* Required since TypeScript loses array item types at runtime.
|
|
1018
|
-
*
|
|
1019
|
-
* @example
|
|
1020
|
-
* ```typescript
|
|
1021
|
-
* class Article {
|
|
1022
|
-
* @ArrayItems(String)
|
|
1023
|
-
* keywords: string[];
|
|
1024
|
-
*
|
|
1025
|
-
* @ArrayItems(Comment)
|
|
1026
|
-
* comments: Comment[];
|
|
1027
|
-
* }
|
|
1028
|
-
* ```
|
|
1029
|
-
*/
|
|
1030
|
-
declare function ArrayItems(itemType: TClassConstructor | StringConstructor | NumberConstructor | BooleanConstructor): PropertyDecorator;
|
|
1031
|
-
/**
|
|
1032
|
-
* Sets semantic format for string (email, uri, uuid, date-time, etc.).
|
|
1033
|
-
*
|
|
1034
|
-
* @example
|
|
1035
|
-
* ```typescript
|
|
1036
|
-
* class User {
|
|
1037
|
-
* @Format('email')
|
|
1038
|
-
* email: string;
|
|
1039
|
-
*
|
|
1040
|
-
* @Format('date-time')
|
|
1041
|
-
* createdAt: string;
|
|
1042
|
-
* }
|
|
1043
|
-
* ```
|
|
1044
|
-
*/
|
|
1045
|
-
declare function Format(format: TJsonSchemaFormat): PropertyDecorator;
|
|
1046
|
-
/**
|
|
1047
|
-
* Marks the property as nullable (can be null).
|
|
1048
|
-
*
|
|
1049
|
-
* @example
|
|
1050
|
-
* ```typescript
|
|
1051
|
-
* class User {
|
|
1052
|
-
* @Nullable()
|
|
1053
|
-
* middleName: string | null;
|
|
1054
|
-
* }
|
|
1055
|
-
* ```
|
|
1056
|
-
*/
|
|
1057
|
-
declare function Nullable(): PropertyDecorator;
|
|
1058
|
-
/**
|
|
1059
|
-
* Sets minimum string length.
|
|
1060
|
-
*
|
|
1061
|
-
* @example
|
|
1062
|
-
* ```typescript
|
|
1063
|
-
* class User {
|
|
1064
|
-
* @SchemaMinLength(3)
|
|
1065
|
-
* username: string;
|
|
1066
|
-
* }
|
|
1067
|
-
* ```
|
|
1068
|
-
*/
|
|
1069
|
-
declare function SchemaMinLength(length: number): PropertyDecorator;
|
|
1070
|
-
/**
|
|
1071
|
-
* Sets maximum string length.
|
|
1072
|
-
*
|
|
1073
|
-
* @example
|
|
1074
|
-
* ```typescript
|
|
1075
|
-
* class User {
|
|
1076
|
-
* @SchemaMaxLength(100)
|
|
1077
|
-
* bio: string;
|
|
1078
|
-
* }
|
|
1079
|
-
* ```
|
|
1080
|
-
*/
|
|
1081
|
-
declare function SchemaMaxLength(length: number): PropertyDecorator;
|
|
1082
|
-
/**
|
|
1083
|
-
* Sets regex pattern for string validation.
|
|
1084
|
-
*
|
|
1085
|
-
* @example
|
|
1086
|
-
* ```typescript
|
|
1087
|
-
* class User {
|
|
1088
|
-
* @SchemaPattern('^[a-z0-9_]+$')
|
|
1089
|
-
* username: string;
|
|
1090
|
-
* }
|
|
1091
|
-
* ```
|
|
1092
|
-
*/
|
|
1093
|
-
declare function SchemaPattern(pattern: string): PropertyDecorator;
|
|
1094
|
-
/**
|
|
1095
|
-
* Sets minimum value (inclusive).
|
|
1096
|
-
*
|
|
1097
|
-
* @example
|
|
1098
|
-
* ```typescript
|
|
1099
|
-
* class Product {
|
|
1100
|
-
* @SchemaMin(0)
|
|
1101
|
-
* price: number;
|
|
1102
|
-
* }
|
|
1103
|
-
* ```
|
|
1104
|
-
*/
|
|
1105
|
-
declare function SchemaMin(value: number): PropertyDecorator;
|
|
1106
|
-
/**
|
|
1107
|
-
* Sets maximum value (inclusive).
|
|
1108
|
-
*
|
|
1109
|
-
* @example
|
|
1110
|
-
* ```typescript
|
|
1111
|
-
* class Rating {
|
|
1112
|
-
* @SchemaMax(5)
|
|
1113
|
-
* score: number;
|
|
1114
|
-
* }
|
|
1115
|
-
* ```
|
|
1116
|
-
*/
|
|
1117
|
-
declare function SchemaMax(value: number): PropertyDecorator;
|
|
1118
|
-
/**
|
|
1119
|
-
* Sets minimum value (exclusive).
|
|
1120
|
-
*
|
|
1121
|
-
* @example
|
|
1122
|
-
* ```typescript
|
|
1123
|
-
* class Discount {
|
|
1124
|
-
* @ExclusiveMin(0) // must be > 0
|
|
1125
|
-
* percentage: number;
|
|
1126
|
-
* }
|
|
1127
|
-
* ```
|
|
1128
|
-
*/
|
|
1129
|
-
declare function ExclusiveMin(value: number): PropertyDecorator;
|
|
1130
|
-
/**
|
|
1131
|
-
* Sets maximum value (exclusive).
|
|
1132
|
-
*
|
|
1133
|
-
* @example
|
|
1134
|
-
* ```typescript
|
|
1135
|
-
* class Probability {
|
|
1136
|
-
* @ExclusiveMax(1) // must be < 1
|
|
1137
|
-
* value: number;
|
|
1138
|
-
* }
|
|
1139
|
-
* ```
|
|
1140
|
-
*/
|
|
1141
|
-
declare function ExclusiveMax(value: number): PropertyDecorator;
|
|
988
|
+
interface IZodSchema {
|
|
989
|
+
_def: {
|
|
990
|
+
typeName: string;
|
|
991
|
+
};
|
|
992
|
+
safeParse: (data: unknown) => {
|
|
993
|
+
success: boolean;
|
|
994
|
+
};
|
|
995
|
+
}
|
|
1142
996
|
/**
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
* @example
|
|
1146
|
-
* ```typescript
|
|
1147
|
-
* class Currency {
|
|
1148
|
-
* @MultipleOf(0.01)
|
|
1149
|
-
* amount: number;
|
|
1150
|
-
* }
|
|
1151
|
-
* ```
|
|
997
|
+
* Adapter for Zod schemas.
|
|
998
|
+
* Uses zod-to-json-schema for conversion.
|
|
1152
999
|
*/
|
|
1153
|
-
declare
|
|
1000
|
+
declare class ZodAdapter implements ISchemaAdapter<IZodSchema> {
|
|
1001
|
+
canHandle(schema: unknown): schema is IZodSchema;
|
|
1002
|
+
toJsonSchema(schema: IZodSchema): IJsonSchema;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1154
1005
|
/**
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
* @example
|
|
1158
|
-
* ```typescript
|
|
1159
|
-
* class Order {
|
|
1160
|
-
* @SchemaMinItems(1)
|
|
1161
|
-
* items: OrderItem[];
|
|
1162
|
-
* }
|
|
1163
|
-
* ```
|
|
1006
|
+
* Yup schema type definition
|
|
1164
1007
|
*/
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
*
|
|
1169
|
-
* @example
|
|
1170
|
-
* ```typescript
|
|
1171
|
-
* class Article {
|
|
1172
|
-
* @SchemaMaxItems(10)
|
|
1173
|
-
* tags: string[];
|
|
1174
|
-
* }
|
|
1175
|
-
* ```
|
|
1176
|
-
*/
|
|
1177
|
-
declare function SchemaMaxItems(count: number): PropertyDecorator;
|
|
1008
|
+
interface IYupSchema {
|
|
1009
|
+
__isYupSchema__: boolean;
|
|
1010
|
+
}
|
|
1178
1011
|
/**
|
|
1179
|
-
*
|
|
1012
|
+
* Adapter for Yup schemas.
|
|
1013
|
+
* Uses @sodaru/yup-to-json-schema for conversion.
|
|
1180
1014
|
*
|
|
1181
|
-
* @
|
|
1182
|
-
* ```typescript
|
|
1183
|
-
* class User {
|
|
1184
|
-
* @SchemaUniqueItems()
|
|
1185
|
-
* roles: string[];
|
|
1186
|
-
* }
|
|
1187
|
-
* ```
|
|
1015
|
+
* @see https://github.com/jquense/yup/blob/master/src/schema.ts
|
|
1188
1016
|
*/
|
|
1189
|
-
declare
|
|
1017
|
+
declare class YupAdapter implements ISchemaAdapter<IYupSchema> {
|
|
1018
|
+
canHandle(schema: unknown): schema is IYupSchema;
|
|
1019
|
+
toJsonSchema(schema: IYupSchema): IJsonSchema;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1190
1022
|
/**
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
* @example
|
|
1194
|
-
* ```typescript
|
|
1195
|
-
* class User {
|
|
1196
|
-
* @SchemaEnum(['admin', 'user', 'guest'])
|
|
1197
|
-
* role: string;
|
|
1198
|
-
* }
|
|
1199
|
-
* ```
|
|
1200
|
-
*
|
|
1201
|
-
* With TypeScript enum:
|
|
1202
|
-
* ```typescript
|
|
1203
|
-
* enum Status { Active = 'active', Inactive = 'inactive' }
|
|
1204
|
-
*
|
|
1205
|
-
* class User {
|
|
1206
|
-
* @SchemaEnum(Object.values(Status))
|
|
1207
|
-
* status: Status;
|
|
1208
|
-
* }
|
|
1209
|
-
* ```
|
|
1023
|
+
* Joi schema type definition
|
|
1210
1024
|
*/
|
|
1211
|
-
|
|
1025
|
+
interface IJoiSchema {
|
|
1026
|
+
describe: () => {
|
|
1027
|
+
type: string;
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1212
1030
|
/**
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
* For arrays, applies to array items instead of the array itself.
|
|
1217
|
-
*
|
|
1218
|
-
* @param value - `true` for any value type, or a schema to constrain value types
|
|
1031
|
+
* Adapter for Joi schemas.
|
|
1032
|
+
* Uses joi-to-json for conversion.
|
|
1219
1033
|
*
|
|
1220
|
-
* @
|
|
1221
|
-
* ```typescript
|
|
1222
|
-
* class Response {
|
|
1223
|
-
* @AdditionalProperties(true) // any value type
|
|
1224
|
-
* metadata: Record<string, unknown>;
|
|
1225
|
-
*
|
|
1226
|
-
* @AdditionalProperties({ type: 'string' }) // only string values
|
|
1227
|
-
* labels: Record<string, string>;
|
|
1228
|
-
*
|
|
1229
|
-
* @ArrayItems(Object)
|
|
1230
|
-
* @AdditionalProperties(true) // applies to each array item
|
|
1231
|
-
* pipeline: Record<string, unknown>[];
|
|
1232
|
-
* }
|
|
1233
|
-
* ```
|
|
1034
|
+
* @see https://joi.dev/api/#isschemaschema-options
|
|
1234
1035
|
*/
|
|
1235
|
-
declare
|
|
1036
|
+
declare class JoiAdapter implements ISchemaAdapter<IJoiSchema> {
|
|
1037
|
+
canHandle(schema: unknown): schema is IJoiSchema;
|
|
1038
|
+
toJsonSchema(schema: IJoiSchema): IJsonSchema;
|
|
1039
|
+
}
|
|
1236
1040
|
|
|
1237
|
-
export {
|
|
1041
|
+
export { ApiSynovaError, AuthSynovaError, ExecutionSynovaError, type IJsonSchema, type ISchemaAdapter, type ISynovaConfig, type ISynovaCreateSpanOptions, type ISynovaEndSpanOptions, type ISynovaExecuteOptions, type ISynovaExecuteResponse, 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 ISynovaSpan, type ISynovaSpanData, type ISynovaToolCall, type ISynovaToolResult, type ISynovaTypedExecuteResponse, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type ISynovaWrapOptions, type ISynovaWrapToolOptions, JoiAdapter, JsonSchemaAdapter, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, SchemaResolver, ServerSynovaError, SynovaCloudSdk, SynovaError, type TJsonSchemaFormat, type TJsonSchemaType, type TSchemaInput, type TSchemaType, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaSpanLevel, type TSynovaSpanStatus, type TSynovaSpanType, type TSynovaUsageType, TimeoutSynovaError, YupAdapter, ZodAdapter };
|