Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@samchon/openapi

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@samchon/openapi - npm Package Compare versions

Comparing version 2.0.0-dev.20241127 to 2.0.0-dev.20241128

lib/structures/ILlamaSchema.mjs

2

lib/converters/ChatGptConverter.d.ts

@@ -7,3 +7,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => IChatGptSchema.IParameters | null;

@@ -10,0 +10,0 @@ const schema: (props: {

@@ -49,3 +49,3 @@ "use strict";

ChatGptConverter.parameters = function (props) {
var e_1, _a, e_2, _b;
var e_1, _a;
var params = LlmConverterV3_1_1.LlmConverterV3_1.parameters({

@@ -62,4 +62,4 @@ config: {

try {
for (var _c = __values(Object.keys(params.$defs)), _d = _c.next(); !_d.done; _d = _c.next()) {
var key = _d.value;
for (var _b = __values(Object.keys(params.$defs)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
params.$defs[key] = transform(params.$defs[key]);

@@ -71,23 +71,10 @@ }

try {
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
try {
for (var _e = __values(Object.keys(params.properties)), _f = _e.next(); !_f.done; _f = _e.next()) {
var key = _f.value;
params.properties[key] = transform(params.properties[key]);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
}
finally { if (e_2) throw e_2.error; }
}
return params;
return transform(params);
};
ChatGptConverter.schema = function (props) {
var e_3, _a;
var e_2, _a;
var oldbie = new Set(Object.keys(props.$defs));

@@ -112,3 +99,3 @@ var schema = LlmConverterV3_1_1.LlmConverterV3_1.schema({

}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {

@@ -118,3 +105,3 @@ try {

}
finally { if (e_3) throw e_3.error; }
finally { if (e_2) throw e_2.error; }
}

@@ -141,3 +128,3 @@ return transform(schema);

];
})) }));
})), additionalProperties: false }));
else if (LlmTypeCheckerV3_1_1.LlmTypeCheckerV3_1.isConstant(input) === false)

@@ -220,3 +207,3 @@ union.push(input);

var separateObject = function (props) {
var e_4, _a;
var e_3, _a;
var _b;

@@ -239,3 +226,3 @@ var llm = __assign(__assign({}, props.schema), { properties: {} });

}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {

@@ -245,3 +232,3 @@ try {

}
finally { if (e_4) throw e_4.error; }
finally { if (e_3) throw e_3.error; }
}

@@ -248,0 +235,0 @@ llm.additionalProperties = false;

@@ -7,3 +7,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => IClaudeSchema.IParameters | null;

@@ -10,0 +10,0 @@ const schema: (props: {

@@ -5,2 +5,3 @@ "use strict";

var LlmTypeCheckerV3_1 = require("../utils/LlmTypeCheckerV3");
var OpenApiTypeChecker_1 = require("../utils/OpenApiTypeChecker");
var LlmConverterV3_1 = require("./LlmConverterV3");

@@ -10,3 +11,10 @@ var GeminiConverter;

GeminiConverter.parameters = function (props) {
return GeminiConverter.schema(props);
var entity = OpenApiTypeChecker_1.OpenApiTypeChecker.unreference(props);
if (entity === null || OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(entity) === false)
return null;
return GeminiConverter.schema({
config: props.config,
components: props.components,
schema: entity,
});
};

@@ -13,0 +21,0 @@ GeminiConverter.schema = function (props) {

@@ -7,3 +7,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => ILlamaSchema.IParameters | null;

@@ -10,0 +10,0 @@ const schema: (props: {

@@ -7,3 +7,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => ILlmSchemaV3_1.IParameters | null;

@@ -10,0 +10,0 @@ const schema: (props: {

@@ -50,6 +50,9 @@ "use strict";

var $defs = {};
var entity = OpenApiTypeChecker_1.OpenApiTypeChecker.unreference(props);
if (entity === null || OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(entity) === false)
return null;
var res = LlmConverterV3_1.schema({
config: props.config,
components: props.components,
schema: props.schema,
schema: entity,
$defs: $defs,

@@ -146,5 +149,14 @@ });

return union.push(null);
if (!!input.additionalProperties === null)
var additionalProperties = typeof input.additionalProperties === "object" &&
input.additionalProperties !== null
? LlmConverterV3_1.schema({
config: props.config,
components: props.components,
$defs: props.$defs,
schema: input.additionalProperties,
})
: input.additionalProperties;
if (additionalProperties === null)
return union.push(null);
return union.push(__assign(__assign({}, input), { properties: properties, additionalProperties: false, required: Object.keys(properties) }));
return union.push(__assign(__assign({}, input), { properties: properties, additionalProperties: additionalProperties, required: Object.keys(properties) }));
}

@@ -151,0 +163,0 @@ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(input)) {

@@ -7,3 +7,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => ILlmSchemaV3.IParameters | null;

@@ -10,0 +10,0 @@ const schema: (props: {

@@ -49,3 +49,10 @@ "use strict";

LlmConverterV3.parameters = function (props) {
return LlmConverterV3.schema(props);
var entity = OpenApiTypeChecker_1.OpenApiTypeChecker.unreference(props);
if (entity === null || OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(entity) === false)
return null;
return LlmConverterV3.schema({
config: props.config,
components: props.components,
schema: entity,
});
};

@@ -52,0 +59,0 @@ LlmConverterV3.schema = function (props) {

@@ -14,3 +14,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => IChatGptSchema.IParameters | null;

@@ -20,3 +20,3 @@ claude: (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => IClaudeSchema.IParameters | null;

@@ -26,3 +26,3 @@ gemini: (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => IGeminiSchema.IObject | null;

@@ -32,3 +32,3 @@ llama: (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => IClaudeSchema.IParameters | null;

@@ -38,3 +38,3 @@ "3.0": (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => ILlmSchemaV3.IObject | null;

@@ -44,3 +44,3 @@ "3.1": (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => IClaudeSchema.IParameters | null;

@@ -47,0 +47,0 @@ }[Model];

@@ -19,2 +19,3 @@ export * from "./OpenApi";

export * from "./structures/IGeminiSchema";
export * from "./structures/ILlamaSchema";
export * from "./structures/ILlmSchema";

@@ -27,3 +28,4 @@ export * from "./structures/ILlmSchemaV3";

export * from "./utils/GeminiTypeChecker";
export * from "./utils/LlamaTypeChecker";
export * from "./utils/LlmTypeCheckerV3";
export * from "./utils/LlmTypeCheckerV3_1";

@@ -44,2 +44,3 @@ "use strict";

__exportStar(require("./structures/IGeminiSchema"), exports);
__exportStar(require("./structures/ILlamaSchema"), exports);
__exportStar(require("./structures/ILlmSchema"), exports);

@@ -52,3 +53,4 @@ __exportStar(require("./structures/ILlmSchemaV3"), exports);

__exportStar(require("./utils/GeminiTypeChecker"), exports);
__exportStar(require("./utils/LlamaTypeChecker"), exports);
__exportStar(require("./utils/LlmTypeCheckerV3"), exports);
__exportStar(require("./utils/LlmTypeCheckerV3_1"), exports);

@@ -149,4 +149,5 @@ /**

*
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
* By the way, as ChatGPT function calling does not support such
* dynamic key typed properties, the `additionalProperties` becomes
* always `false`.
*/

@@ -153,0 +154,0 @@ additionalProperties: false;

@@ -272,6 +272,11 @@ /**

*
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
* If the value is `true`, it means that the additional properties are not
* restricted. They can be any type. Otherwise, if the value is
* {@link IOpenAiSchema} type, it means that the additional properties must
* follow the type schema info.
*
* - `true`: `Record<string, any>`
* - `IOpenAiSchema`: `Record<string, T>`
*/
additionalProperties: false;
additionalProperties?: boolean | ILlmSchemaV3_1;
/**

@@ -278,0 +283,0 @@ * List of key values of the required properties.

@@ -293,6 +293,11 @@ /**

*
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
* If the value is `true`, it means that the additional properties are not
* restricted. They can be any type. Otherwise, if the value is
* {@link ILlmSchemaV3} type, it means that the additional properties must
* follow the type schema info.
*
* - `true`: `Record<string, any>`
* - `IOpenAiSchema`: `Record<string, T>`
*/
additionalProperties: false;
additionalProperties?: boolean | ILlmSchemaV3;
}

@@ -299,0 +304,0 @@ /**

@@ -193,16 +193,2 @@ "use strict";

var coverArray = function (p) {
// if (
// !(
// p.x.minItems === undefined ||
// (p.y.minItems !== undefined && p.x.minItems <= p.y.minItems)
// )
// )
// return false;
// else if (
// !(
// p.x.maxItems === undefined ||
// (p.y.maxItems !== undefined && p.x.maxItems >= p.y.maxItems)
// )
// )
// return false;
return coverStation({

@@ -217,17 +203,2 @@ $defs: p.$defs,

var _a;
if (!p.x.additionalProperties && !!p.y.additionalProperties)
return false;
else if (!!p.x.additionalProperties &&
!!p.y.additionalProperties &&
((typeof p.x.additionalProperties === "object" &&
p.y.additionalProperties === true) ||
(typeof p.x.additionalProperties === "object" &&
typeof p.y.additionalProperties === "object" &&
!coverStation({
$defs: p.$defs,
visited: p.visited,
x: p.x.additionalProperties,
y: p.y.additionalProperties,
}))))
return false;
return Object.entries((_a = p.y.properties) !== null && _a !== void 0 ? _a : {}).every(function (_a) {

@@ -260,21 +231,3 @@ var _b, _c, _d, _e, _f;

return !!((_b = y.enum) === null || _b === void 0 ? void 0 : _b.length) && y.enum.every(function (v) { return x.enum.includes(v); });
return [
x.type === y.type,
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every(function (v) { return v; });
return x.type === y.type;
};

@@ -285,21 +238,3 @@ var coverNumber = function (x, y) {

return !!((_b = y.enum) === null || _b === void 0 ? void 0 : _b.length) && y.enum.every(function (v) { return x.enum.includes(v); });
return [
x.type === y.type || (x.type === "number" && y.type === "integer"),
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every(function (v) { return v; });
return x.type === y.type || (x.type === "number" && y.type === "integer");
};

@@ -310,12 +245,3 @@ var coverString = function (x, y) {

return !!((_b = y.enum) === null || _b === void 0 ? void 0 : _b.length) && y.enum.every(function (v) { return x.enum.includes(v); });
return [
x.type === y.type,
// x.format === undefined ||
// (y.format !== undefined && coverFormat(x.format, y.format)),
// x.pattern === undefined || x.pattern === y.pattern,
// x.minLength === undefined ||
// (y.minLength !== undefined && x.minLength <= y.minLength),
// x.maxLength === undefined ||
// (y.maxLength !== undefined && x.maxLength >= y.maxLength),
].every(function (v) { return v; });
return x.type === y.type;
};

@@ -322,0 +248,0 @@ var flatSchema = function ($defs, schema) {

@@ -35,7 +35,6 @@ "use strict";

closure(schema);
if (GeminiTypeChecker.isObject(schema)) {
if (GeminiTypeChecker.isObject(schema))
Object.values((_a = schema.properties) !== null && _a !== void 0 ? _a : {}).forEach(function (child) {
return GeminiTypeChecker.visit(child, closure);
});
}
else if (GeminiTypeChecker.isArray(schema))

@@ -87,21 +86,3 @@ GeminiTypeChecker.visit(schema.items, closure);

return y.enum !== undefined && x.enum.every(function (v) { return y.enum.includes(v); });
return [
x.type === y.type,
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every(function (v) { return v; });
return x.type === y.type;
};

@@ -114,21 +95,3 @@ /**

return y.enum !== undefined && x.enum.every(function (v) { return y.enum.includes(v); });
return [
x.type === y.type,
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every(function (v) { return v; });
return x.type === y.type;
};

@@ -141,46 +104,8 @@ /**

return y.enum !== undefined && x.enum.every(function (v) { return y.enum.includes(v); });
return [
x.type === y.type,
// x.format === undefined ||
// (y.format !== undefined && coverFormat(x.format, y.format)),
// x.pattern === undefined || x.pattern === y.pattern,
// x.minLength === undefined ||
// (y.minLength !== undefined && x.minLength <= y.minLength),
// x.maxLength === undefined ||
// (y.maxLength !== undefined && x.maxLength >= y.maxLength),
].every(function (v) { return v; });
return x.type === y.type;
};
// /**
// * @internal
// */
// const coverFormat = (
// x: Required<IGeminiSchema.IString>["format"],
// y: Required<IGeminiSchema.IString>["format"],
// ): boolean =>
// x === y ||
// (x === "idn-email" && y === "email") ||
// (x === "idn-hostname" && y === "hostname") ||
// (["uri", "iri"].includes(x) && y === "url") ||
// (x === "iri" && y === "uri") ||
// (x === "iri-reference" && y === "uri-reference");
/**
* @internal
*/
var coverArray = function (x, y) {
// if (
// !(
// x.minItems === undefined ||
// (y.minItems !== undefined && x.minItems <= y.minItems)
// )
// )
// return false;
// else if (
// !(
// x.maxItems === undefined ||
// (y.maxItems !== undefined && x.maxItems >= y.maxItems)
// )
// )
// return false;
return GeminiTypeChecker.covers(x.items, y.items);
};
var coverArray = function (x, y) { return GeminiTypeChecker.covers(x.items, y.items); };
/**

@@ -187,0 +112,0 @@ * @internal

@@ -124,2 +124,10 @@ "use strict";

----------------------------------------------------------- */
OpenApiTypeCheckerBase.unreference = function (props) {
var _a;
if (OpenApiTypeCheckerBase.isReference(props.schema) === false)
return props.schema;
var key = props.schema.$ref.split(props.prefix).pop();
var found = (_a = props.components.schemas) === null || _a === void 0 ? void 0 : _a[key];
return found ? OpenApiTypeCheckerBase.unreference(__assign(__assign({}, props), { schema: found })) : null;
};
OpenApiTypeCheckerBase.escape = function (props) {

@@ -126,0 +134,0 @@ return escapeSchema({

@@ -62,3 +62,3 @@ "use strict";

schema.oneOf.forEach(function (s) { return LlmTypeCheckerV3.visit(s, callback); });
else if (LlmTypeCheckerV3.isObject(schema))
else if (LlmTypeCheckerV3.isObject(schema)) {
try {

@@ -77,2 +77,6 @@ for (var _b = __values(Object.entries(schema.properties)), _c = _b.next(); !_c.done; _c = _b.next()) {

}
if (typeof schema.additionalProperties === "object" &&
schema.additionalProperties !== null)
LlmTypeCheckerV3.visit(schema.additionalProperties, callback);
}
else if (LlmTypeCheckerV3.isArray(schema))

@@ -79,0 +83,0 @@ LlmTypeCheckerV3.visit(schema.items, callback);

@@ -24,2 +24,6 @@ import { OpenApi } from "../OpenApi";

}) => OpenApi.IJsonSchema | null;
const unreference: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
}) => OpenApi.IJsonSchema | null;
const visit: (props: {

@@ -26,0 +30,0 @@ closure: (schema: OpenApi.IJsonSchema) => void;

@@ -64,2 +64,9 @@ "use strict";

};
OpenApiTypeChecker.unreference = function (props) {
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.unreference({
prefix: "#/components/schemas/",
components: props.components,
schema: props.schema,
});
};
OpenApiTypeChecker.visit = function (props) {

@@ -66,0 +73,0 @@ return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.visit({

{
"name": "@samchon/openapi",
"version": "2.0.0-dev.20241127",
"version": "2.0.0-dev.20241128",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -42,4 +42,4 @@ > ## Next version is coming.

- [`HttpLlm.application()`](https://github.com/samchon/openapi/blob/master/src/HttpLlm.ts)
- [`IHttpLlmApplication<Model, Schema>`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmApplication.ts)
- [`IHttpLlmFunction<Schema>`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmFunction.ts)
- [`IHttpLlmApplication<Model>`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmApplication.ts)
- [`IHttpLlmFunction<Model>`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmFunction.ts)
- Supported schemas

@@ -99,3 +99,3 @@ - [`IChatGptSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IChatGptSchema.ts): OpenAI ChatGPT

// Let's imagine that LLM has selected a function to call
const func: IHttpLlmFunction<IChatGptSchema.IParameters> | undefined =
const func: IHttpLlmFunction<"chatgpt"> | undefined =
application.functions.find(

@@ -102,0 +102,0 @@ // (f) => f.name === "llm_selected_fuction_name"

@@ -13,3 +13,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}): IChatGptSchema.IParameters | null => {

@@ -28,5 +28,3 @@ const params: ILlmSchemaV3_1.IParameters | null =

params.$defs[key] = transform(params.$defs[key]);
for (const key of Object.keys(params.properties))
params.properties[key] = transform(params.properties[key]);
return params;
return transform(params) as IChatGptSchema.IParameters;
};

@@ -86,2 +84,3 @@

),
additionalProperties: false,
});

@@ -88,0 +87,0 @@ else if (LlmTypeCheckerV3_1.isConstant(input) === false)

@@ -9,3 +9,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}): IClaudeSchema.IParameters | null =>

@@ -12,0 +12,0 @@ LlmConverterV3_1.parameters({

@@ -5,2 +5,3 @@ import { OpenApi } from "../OpenApi";

import { LlmTypeCheckerV3 } from "../utils/LlmTypeCheckerV3";
import { OpenApiTypeChecker } from "../utils/OpenApiTypeChecker";
import { LlmConverterV3 } from "./LlmConverterV3";

@@ -13,4 +14,13 @@

schema: OpenApi.IJsonSchema;
}): IGeminiSchema.IParameters | null =>
schema(props) as IGeminiSchema.IParameters | null;
}): IGeminiSchema.IParameters | null => {
const entity: OpenApi.IJsonSchema | null =
OpenApiTypeChecker.unreference(props);
if (entity === null || OpenApiTypeChecker.isObject(entity) === false)
return null;
return schema({
config: props.config,
components: props.components,
schema: entity,
}) as IGeminiSchema.IParameters | null;
};

@@ -17,0 +27,0 @@ export const schema = (props: {

@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi";

@@ -9,3 +9,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}): ILlamaSchema.IParameters | null =>

@@ -12,0 +12,0 @@ LlmConverterV3_1.parameters({

@@ -12,9 +12,13 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}): ILlmSchemaV3_1.IParameters | null => {
const $defs: Record<string, ILlmSchemaV3_1> = {};
const entity: OpenApi.IJsonSchema | null =
OpenApiTypeChecker.unreference(props);
if (entity === null || OpenApiTypeChecker.isObject(entity) === false)
return null;
const res: ILlmSchemaV3_1.IParameters | null = schema({
config: props.config,
components: props.components,
schema: props.schema,
schema: entity,
$defs,

@@ -128,7 +132,21 @@ }) as ILlmSchemaV3_1.IParameters | null;

return union.push(null);
if (!!input.additionalProperties === null) return union.push(null);
const additionalProperties:
| ILlmSchemaV3_1
| boolean
| null
| undefined =
typeof input.additionalProperties === "object" &&
input.additionalProperties !== null
? schema({
config: props.config,
components: props.components,
$defs: props.$defs,
schema: input.additionalProperties,
})
: input.additionalProperties;
if (additionalProperties === null) return union.push(null);
return union.push({
...input,
properties: properties as Record<string, ILlmSchemaV3_1>,
additionalProperties: false,
additionalProperties,
required: Object.keys(properties),

@@ -135,0 +153,0 @@ });

@@ -12,5 +12,14 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
}): ILlmSchemaV3.IParameters | null =>
schema(props) as ILlmSchemaV3.IParameters | null;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}): ILlmSchemaV3.IParameters | null => {
const entity: OpenApi.IJsonSchema | null =
OpenApiTypeChecker.unreference(props);
if (entity === null || OpenApiTypeChecker.isObject(entity) === false)
return null;
return schema({
config: props.config,
components: props.components,
schema: entity,
}) as ILlmSchemaV3.IParameters | null;
};

@@ -17,0 +26,0 @@ export const schema = (props: {

@@ -31,3 +31,3 @@ import { OpenApi } from "../OpenApi";

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => ChatGptConverter.parameters(props),

@@ -37,3 +37,3 @@ claude: (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => ClaudeConverter.parameters(props),

@@ -43,3 +43,3 @@ gemini: (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => GeminiConverter.parameters(props),

@@ -49,3 +49,3 @@ llama: (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => LlamaConverter.parameters(props),

@@ -55,3 +55,3 @@ "3.0": (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => LlmConverterV3.parameters(props),

@@ -61,3 +61,3 @@ "3.1": (props: {

components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
}) => LlmConverterV3_1.parameters(props),

@@ -64,0 +64,0 @@ };

@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi";

@@ -0,0 +0,0 @@ import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute";

@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi";

@@ -0,0 +0,0 @@ import type { HttpLlm } from "../HttpLlm";

@@ -0,0 +0,0 @@ import { HttpMigration } from "./HttpMigration";

@@ -0,0 +0,0 @@ import { OpenApi } from "./OpenApi";

@@ -34,2 +34,3 @@ //----

export * from "./structures/IGeminiSchema";
export * from "./structures/ILlamaSchema";
export * from "./structures/ILlmSchema";

@@ -43,3 +44,4 @@ export * from "./structures/ILlmSchemaV3";

export * from "./utils/GeminiTypeChecker";
export * from "./utils/LlamaTypeChecker";
export * from "./utils/LlmTypeCheckerV3";
export * from "./utils/LlmTypeCheckerV3_1";

@@ -0,0 +0,0 @@ import { OpenApiV3 } from "./OpenApiV3";

@@ -166,4 +166,5 @@ /**

*
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
* By the way, as ChatGPT function calling does not support such
* dynamic key typed properties, the `additionalProperties` becomes
* always `false`.
*/

@@ -170,0 +171,0 @@ additionalProperties: false;

@@ -0,0 +0,0 @@ /// <reference lib="dom" />

@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi";

@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi";

@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi";

@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi";

@@ -0,0 +0,0 @@ import { IGeminiSchema } from "./IGeminiSchema";

@@ -0,0 +0,0 @@ import { IChatGptSchema } from "./IChatGptSchema";

@@ -0,0 +0,0 @@ import { IChatGptSchema } from "./IChatGptSchema";

@@ -333,6 +333,11 @@ /**

*
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
* If the value is `true`, it means that the additional properties are not
* restricted. They can be any type. Otherwise, if the value is
* {@link IOpenAiSchema} type, it means that the additional properties must
* follow the type schema info.
*
* - `true`: `Record<string, any>`
* - `IOpenAiSchema`: `Record<string, T>`
*/
additionalProperties: false;
additionalProperties?: boolean | ILlmSchemaV3_1;

@@ -339,0 +344,0 @@ /**

@@ -356,6 +356,11 @@ /**

*
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
* If the value is `true`, it means that the additional properties are not
* restricted. They can be any type. Otherwise, if the value is
* {@link ILlmSchemaV3} type, it means that the additional properties must
* follow the type schema info.
*
* - `true`: `Record<string, any>`
* - `IOpenAiSchema`: `Record<string, T>`
*/
additionalProperties: false;
additionalProperties?: boolean | ILlmSchemaV3;
}

@@ -362,0 +367,0 @@

@@ -192,18 +192,4 @@ import { IChatGptSchema } from "../structures/IChatGptSchema";

y: IChatGptSchema.IArray;
}): boolean => {
// if (
// !(
// p.x.minItems === undefined ||
// (p.y.minItems !== undefined && p.x.minItems <= p.y.minItems)
// )
// )
// return false;
// else if (
// !(
// p.x.maxItems === undefined ||
// (p.y.maxItems !== undefined && p.x.maxItems >= p.y.maxItems)
// )
// )
// return false;
return coverStation({
}): boolean =>
coverStation({
$defs: p.$defs,

@@ -214,3 +200,2 @@ visited: p.visited,

});
};

@@ -222,20 +207,4 @@ const coverObject = (p: {

y: IChatGptSchema.IObject;
}): boolean => {
if (!p.x.additionalProperties && !!p.y.additionalProperties) return false;
else if (
!!p.x.additionalProperties &&
!!p.y.additionalProperties &&
((typeof p.x.additionalProperties === "object" &&
p.y.additionalProperties === true) ||
(typeof p.x.additionalProperties === "object" &&
typeof p.y.additionalProperties === "object" &&
!coverStation({
$defs: p.$defs,
visited: p.visited,
x: p.x.additionalProperties,
y: p.y.additionalProperties,
})))
)
return false;
return Object.entries(p.y.properties ?? {}).every(([key, b]) => {
}): boolean =>
Object.entries(p.y.properties ?? {}).every(([key, b]) => {
const a: IChatGptSchema | undefined = p.x.properties?.[key];

@@ -255,3 +224,2 @@ if (a === undefined) return false;

});
};

@@ -273,21 +241,3 @@ const coverBoolean = (

return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
return [
x.type === y.type,
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every((v) => v);
return x.type === y.type;
};

@@ -301,21 +251,3 @@

return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
return [
x.type === y.type || (x.type === "number" && y.type === "integer"),
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every((v) => v);
return x.type === y.type || (x.type === "number" && y.type === "integer");
};

@@ -329,12 +261,3 @@

return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
return [
x.type === y.type,
// x.format === undefined ||
// (y.format !== undefined && coverFormat(x.format, y.format)),
// x.pattern === undefined || x.pattern === y.pattern,
// x.minLength === undefined ||
// (y.minLength !== undefined && x.minLength <= y.minLength),
// x.maxLength === undefined ||
// (y.maxLength !== undefined && x.maxLength >= y.maxLength),
].every((v) => v);
return x.type === y.type;
};

@@ -341,0 +264,0 @@

@@ -19,7 +19,7 @@ import { IGeminiSchema } from "../structures/IGeminiSchema";

closure(schema);
if (isObject(schema)) {
if (isObject(schema))
Object.values(schema.properties ?? {}).forEach((child) =>
visit(child, closure),
);
} else if (isArray(schema)) visit(schema.items, closure);
else if (isArray(schema)) visit(schema.items, closure);
};

@@ -66,21 +66,3 @@

return y.enum !== undefined && x.enum.every((v) => y.enum!.includes(v));
return [
x.type === y.type,
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every((v) => v);
return x.type === y.type;
};

@@ -97,21 +79,3 @@

return y.enum !== undefined && x.enum.every((v) => y.enum!.includes(v));
return [
x.type === y.type,
// x.minimum === undefined ||
// (y.minimum !== undefined && x.minimum <= y.minimum),
// x.maximum === undefined ||
// (y.maximum !== undefined && x.maximum >= y.maximum),
// x.exclusiveMinimum !== true ||
// x.minimum === undefined ||
// (y.minimum !== undefined &&
// (y.exclusiveMinimum === true || x.minimum < y.minimum)),
// x.exclusiveMaximum !== true ||
// x.maximum === undefined ||
// (y.maximum !== undefined &&
// (y.exclusiveMaximum === true || x.maximum > y.maximum)),
// x.multipleOf === undefined ||
// (y.multipleOf !== undefined &&
// y.multipleOf / x.multipleOf ===
// Math.floor(y.multipleOf / x.multipleOf)),
].every((v) => v);
return x.type === y.type;
};

@@ -128,28 +92,5 @@

return y.enum !== undefined && x.enum.every((v) => y.enum!.includes(v));
return [
x.type === y.type,
// x.format === undefined ||
// (y.format !== undefined && coverFormat(x.format, y.format)),
// x.pattern === undefined || x.pattern === y.pattern,
// x.minLength === undefined ||
// (y.minLength !== undefined && x.minLength <= y.minLength),
// x.maxLength === undefined ||
// (y.maxLength !== undefined && x.maxLength >= y.maxLength),
].every((v) => v);
return x.type === y.type;
};
// /**
// * @internal
// */
// const coverFormat = (
// x: Required<IGeminiSchema.IString>["format"],
// y: Required<IGeminiSchema.IString>["format"],
// ): boolean =>
// x === y ||
// (x === "idn-email" && y === "email") ||
// (x === "idn-hostname" && y === "hostname") ||
// (["uri", "iri"].includes(x) && y === "url") ||
// (x === "iri" && y === "uri") ||
// (x === "iri-reference" && y === "uri-reference");
/**

@@ -161,19 +102,3 @@ * @internal

y: IGeminiSchema.IArray,
): boolean => {
// if (
// !(
// x.minItems === undefined ||
// (y.minItems !== undefined && x.minItems <= y.minItems)
// )
// )
// return false;
// else if (
// !(
// x.maxItems === undefined ||
// (y.maxItems !== undefined && x.maxItems >= y.maxItems)
// )
// )
// return false;
return covers(x.items, y.items);
};
): boolean => covers(x.items, y.items);

@@ -186,4 +111,4 @@ /**

y: IGeminiSchema.IObject,
): boolean => {
return Object.entries(y.properties ?? {}).every(([key, b]) => {
): boolean =>
Object.entries(y.properties ?? {}).every(([key, b]) => {
const a: IGeminiSchema | undefined = x.properties?.[key];

@@ -198,3 +123,2 @@ if (a === undefined) return false;

});
};

@@ -201,0 +125,0 @@ /* -----------------------------------------------------------

@@ -102,2 +102,14 @@ import { OpenApi } from "../../OpenApi";

----------------------------------------------------------- */
export const unreference = (props: {
prefix: string;
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
}): OpenApi.IJsonSchema | null => {
if (isReference(props.schema) === false) return props.schema;
const key: string = props.schema.$ref.split(props.prefix).pop()!;
const found: OpenApi.IJsonSchema | undefined =
props.components.schemas?.[key];
return found ? unreference({ ...props, schema: found }) : null;
};
export const escape = (props: {

@@ -104,0 +116,0 @@ prefix: string;

@@ -0,0 +0,0 @@ import { ILlmFunction } from "../structures/ILlmFunction";

@@ -34,6 +34,11 @@ import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3";

if (isOneOf(schema)) schema.oneOf.forEach((s) => visit(s, callback));
else if (isObject(schema))
else if (isObject(schema)) {
for (const [_, s] of Object.entries(schema.properties))
visit(s, callback);
else if (isArray(schema)) visit(schema.items, callback);
if (
typeof schema.additionalProperties === "object" &&
schema.additionalProperties !== null
)
visit(schema.additionalProperties, callback);
} else if (isArray(schema)) visit(schema.items, callback);
};

@@ -40,0 +45,0 @@

@@ -93,2 +93,12 @@ import { OpenApi } from "../OpenApi";

export const unreference = (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
}): OpenApi.IJsonSchema | null =>
OpenApiTypeCheckerBase.unreference({
prefix: "#/components/schemas/",
components: props.components,
schema: props.schema,
});
export const visit = (props: {

@@ -95,0 +105,0 @@ closure: (schema: OpenApi.IJsonSchema) => void;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc