@tstdl/base 0.92.22 → 0.92.23

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/ai/ai.service.js CHANGED
@@ -262,6 +262,10 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
262
262
  }
263
263
  async convertFunctions(functions) {
264
264
  const mapped = mapAsync(objectEntries(functions), async ([name, declaration]) => {
265
+ const enabled = await resolveValueOrAsyncProvider(declaration.enabled);
266
+ if (enabled == false) {
267
+ return undefined;
268
+ }
265
269
  const parametersSchema = await resolveValueOrAsyncProvider(declaration.parameters);
266
270
  return {
267
271
  name,
@@ -269,7 +273,8 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
269
273
  parameters: convertToOpenApiSchema(parametersSchema)
270
274
  };
271
275
  });
272
- return toArrayAsync(mapped);
276
+ const functionsArray = await toArrayAsync(mapped);
277
+ return functionsArray.filter(isDefined);
273
278
  }
274
279
  convertGoogleContent(content) {
275
280
  return {
package/ai/types.d.ts CHANGED
@@ -10,6 +10,7 @@ export type SchemaFunctionDeclarations = Record<string, SchemaFunctionDeclaratio
10
10
  export type SchemaFunctionDeclarationWithoutHandler<T extends Record = Record> = {
11
11
  description: string;
12
12
  parameters: ValueOrAsyncProvider<ObjectSchema<T>>;
13
+ enabled?: ValueOrAsyncProvider<boolean>;
13
14
  };
14
15
  export type SchemaFunctionDeclarationWithHandler<T extends Record = Record, R = unknown> = SchemaFunctionDeclarationWithoutHandler<T> & {
15
16
  handler: (parameters: T) => R | Promise<R>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.22",
3
+ "version": "0.92.23",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -75,7 +75,7 @@ function convertToOpenApiSchemaBase(schema) {
75
75
  if (schema instanceof EnumerationSchema) {
76
76
  const hasString = schema.allowedValues.some(isString);
77
77
  const hasNumber = schema.allowedValues.some(isNumber);
78
- if (hasString && hasNumber) {
78
+ if (!hasString && !hasNumber) {
79
79
  throw new NotSupportedError('Enum must be either string or number but not both.');
80
80
  }
81
81
  return {