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

@samchon/openapi

Package Overview
Dependencies
Maintainers
0
Versions
146
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.20241124 to 2.0.0-dev.20241125

lib/converters/ClaudeConverter.d.ts

10

lib/converters/ChatGptConverter.js

@@ -51,3 +51,6 @@ "use strict";

var params = LlmConverterV3_1_1.LlmConverterV3_1.parameters({
config: props.config,
config: {
reference: props.config.reference,
constraint: false,
},
components: props.components,

@@ -90,3 +93,6 @@ schema: props.schema,

var schema = LlmConverterV3_1_1.LlmConverterV3_1.schema({
config: props.config,
config: {
reference: props.config.reference,
constraint: false,
},
components: props.components,

@@ -93,0 +99,0 @@ $defs: props.$defs,

14

lib/converters/GeminiConverter.js

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

var LlmTypeCheckerV3_1 = require("../utils/LlmTypeCheckerV3");
var OpenApiContraintShifter_1 = require("../utils/OpenApiContraintShifter");
var LlmConverterV3_1 = require("./LlmConverterV3");

@@ -41,12 +40,5 @@ var GeminiConverter;

union = true;
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isObject(v)) {
if (v.additionalProperties !== undefined)
delete v.additionalProperties;
}
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isArray(v))
OpenApiContraintShifter_1.OpenApiContraintShifter.shiftArray(v);
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isString(v))
OpenApiContraintShifter_1.OpenApiContraintShifter.shiftString(v);
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isNumber(v) || LlmTypeCheckerV3_1.LlmTypeCheckerV3.isInteger(v))
OpenApiContraintShifter_1.OpenApiContraintShifter.shiftNumeric(v);
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isObject(v) &&
v.additionalProperties !== undefined)
delete v.additionalProperties;
});

@@ -53,0 +45,0 @@ return union ? null : schema;

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

var ChatGptConverter_1 = require("./ChatGptConverter");
var ClaudeConverter_1 = require("./ClaudeConverter");
var GeminiConverter_1 = require("./GeminiConverter");

@@ -211,6 +212,7 @@ var LlmConverterV3_2 = require("./LlmConverterV3");

var SEPARATORS = {
chatgpt: ChatGptConverter_1.ChatGptConverter.separate,
claude: ClaudeConverter_1.ClaudeConverter.separate,
gemini: GeminiConverter_1.GeminiConverter.separate,
"3.0": LlmConverterV3_2.LlmConverterV3.separate,
"3.1": LlmConverterV3_1_1.LlmConverterV3_1.separate,
chatgpt: ChatGptConverter_1.ChatGptConverter.separate,
gemini: GeminiConverter_1.GeminiConverter.separate,
};

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

var visit = function (input) {
var _a;
var _a, _b;
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(input)) {

@@ -131,3 +131,3 @@ input.oneOf.forEach(visit);

else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(input)) {
var properties = Object.entries(input.properties || {}).reduce(function (acc, _a) {
var properties = Object.entries((_b = input.properties) !== null && _b !== void 0 ? _b : {}).reduce(function (acc, _a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];

@@ -134,0 +134,0 @@ var converted = LlmConverterV3_1.schema({

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

var LlmTypeCheckerV3_1 = require("../utils/LlmTypeCheckerV3");
var OpenApiContraintShifter_1 = require("../utils/OpenApiContraintShifter");
var OpenApiTypeChecker_1 = require("../utils/OpenApiTypeChecker");

@@ -75,2 +76,7 @@ var OpenApiV3Downgrader_1 = require("./OpenApiV3Downgrader");

}
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isInteger(schema) ||
LlmTypeCheckerV3_1.LlmTypeCheckerV3.isNumber(schema))
OpenApiContraintShifter_1.OpenApiContraintShifter.shiftNumeric(schema);
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isString(schema))
OpenApiContraintShifter_1.OpenApiContraintShifter.shiftString(schema);
});

@@ -77,0 +83,0 @@ return downgraded;

import { OpenApi } from "../OpenApi";
import { IChatGptSchema } from "../structures/IChatGptSchema";
import { IClaudeSchema } from "../structures/IClaudeSchema";
import { IGeminiSchema } from "../structures/IGeminiSchema";

@@ -9,7 +10,12 @@ import { ILlmApplication } from "../structures/ILlmApplication";

const parameters: <Model extends ILlmApplication.Model>(model: Model) => {
"3.0": (props: {
chatgpt: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
config: ILlmSchemaV3.IConfig;
}) => ILlmSchemaV3.IParameters | null;
config: IChatGptSchema.IConfig;
}) => IChatGptSchema.IParameters | null;
claude: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
config: IClaudeSchema.IConfig;
}) => IClaudeSchema.IParameters | null;
gemini: (props: {

@@ -20,2 +26,7 @@ components: OpenApi.IComponents;

}) => IGeminiSchema.IObject | null;
"3.0": (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
config: ILlmSchemaV3.IConfig;
}) => ILlmSchemaV3.IParameters | null;
"3.1": (props: {

@@ -25,15 +36,17 @@ components: OpenApi.IComponents;

config: ILlmSchemaV3_1.IConfig;
}) => ILlmSchemaV3_1.IParameters | null;
}) => IClaudeSchema.IParameters | null;
}[Model];
const schema: <Model extends ILlmApplication.Model>(model: Model) => {
chatgpt: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema;
$defs: Record<string, IChatGptSchema>;
config: IChatGptSchema.IConfig;
}) => IChatGptSchema.IParameters | null;
}[Model];
const schema: <Model extends ILlmApplication.Model>(model: Model) => {
"3.0": (props: {
}) => IChatGptSchema | null;
claude: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
config: ILlmSchemaV3.IConfig;
}) => ILlmSchemaV3 | null;
$defs: Record<string, IClaudeSchema>;
config: IClaudeSchema.IConfig;
}) => IClaudeSchema | null;
gemini: (props: {

@@ -44,2 +57,7 @@ components: OpenApi.IComponents;

}) => IGeminiSchema | null;
"3.0": (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
config: ILlmSchemaV3.IConfig;
}) => ILlmSchemaV3 | null;
"3.1": (props: {

@@ -51,9 +69,22 @@ components: OpenApi.IComponents;

}) => ILlmSchemaV3_1 | null;
chatgpt: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
$defs: Record<string, IChatGptSchema>;
config: IChatGptSchema.IConfig;
}) => IChatGptSchema | null;
}[Model];
const defaultConfig: <Model extends ILlmApplication.Model>(model: Model) => {
chatgpt: {
reference: false;
};
claude: {
reference: false;
};
gemini: {
recursive: number;
};
"3.0": {
constraint: false;
recursive: number;
};
"3.1": {
constraint: false;
reference: false;
};
}[Model];
}

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

var ChatGptConverter_1 = require("./ChatGptConverter");
var ClaudeConverter_1 = require("./ClaudeConverter");
var GeminiConverter_1 = require("./GeminiConverter");

@@ -15,20 +16,30 @@ var LlmConverterV3_2 = require("./LlmConverterV3");

};
LlmSchemaConverter.defaultConfig = function (model) { return DEFAULT_CONFIGS[model]; };
})(LlmSchemaConverter || (exports.LlmSchemaConverter = LlmSchemaConverter = {}));
var PARAMETERS_CASTERS = {
"3.0": function (props) {
return LlmConverterV3_2.LlmConverterV3.parameters({
chatgpt: function (props) { return ChatGptConverter_1.ChatGptConverter.parameters(props); },
claude: function (props) { return ClaudeConverter_1.ClaudeConverter.parameters(props); },
gemini: function (props) { return GeminiConverter_1.GeminiConverter.parameters(props); },
"3.0": function (props) { return LlmConverterV3_2.LlmConverterV3.parameters(props); },
"3.1": function (props) { return LlmConverterV3_1_1.LlmConverterV3_1.parameters(props); },
};
var SCHEMA_CASTERS = {
chatgpt: function (props) {
return ChatGptConverter_1.ChatGptConverter.schema({
components: props.components,
schema: props.schema,
$defs: props.$defs,
config: props.config,
});
},
gemini: function (props) {
return GeminiConverter_1.GeminiConverter.parameters({
claude: function (props) {
return ClaudeConverter_1.ClaudeConverter.schema({
components: props.components,
schema: props.schema,
$defs: props.$defs,
config: props.config,
});
},
"3.1": function (props) {
return LlmConverterV3_1_1.LlmConverterV3_1.parameters({
gemini: function (props) {
return GeminiConverter_1.GeminiConverter.schema({
components: props.components,

@@ -39,11 +50,2 @@ schema: props.schema,

},
chatgpt: function (props) {
return ChatGptConverter_1.ChatGptConverter.parameters({
components: props.components,
schema: props.schema,
config: props.config,
});
},
};
var SCHEMA_CASTERS = {
"3.0": function (props) {

@@ -56,9 +58,2 @@ return LlmConverterV3_2.LlmConverterV3.schema({

},
gemini: function (props) {
return GeminiConverter_1.GeminiConverter.schema({
components: props.components,
schema: props.schema,
config: props.config,
});
},
"3.1": function (props) {

@@ -72,10 +67,21 @@ return LlmConverterV3_1_1.LlmConverterV3_1.schema({

},
chatgpt: function (props) {
return ChatGptConverter_1.ChatGptConverter.schema({
components: props.components,
schema: props.schema,
$defs: props.$defs,
config: props.config,
});
};
var DEFAULT_CONFIGS = {
chatgpt: {
reference: false,
},
claude: {
reference: false,
},
gemini: {
recursive: 3,
},
"3.0": {
constraint: false,
recursive: 3,
},
"3.1": {
constraint: false,
reference: false,
},
};

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

.flat())), false)),
required: __spreadArray([], __read(new Set(entire.map(function (o) { return o.required; }).flat())), false),
required: __spreadArray([], __read(new Set(entire.map(function (o) { var _a; return (_a = o.required) !== null && _a !== void 0 ? _a : []; }).flat())), false),
},

@@ -168,0 +168,0 @@ }),

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

var _a;
if (input["x-samchon-emend-version"] === "2.0")
if (input["x-samchon-emended"] === true)
return input;

@@ -82,3 +82,3 @@ return __assign(__assign({}, input), { components: convertComponents((_a = input.components) !== null && _a !== void 0 ? _a : {}), paths: input.paths

}))
: undefined, "x-samchon-emend-version": "2.0" });
: undefined, "x-samchon-emended": true });
};

@@ -85,0 +85,0 @@ /* -----------------------------------------------------------

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

}))
: undefined, openapi: "3.1.0", "x-samchon-emend-version": "2.0" }));
: undefined, openapi: "3.1.0", "x-samchon-emended": true }));
};

@@ -69,0 +69,0 @@ /* -----------------------------------------------------------

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

tags: input.tags,
"x-samchon-emend-version": "2.0",
"x-samchon-emended": true,
}); };

@@ -81,0 +81,0 @@ /* -----------------------------------------------------------

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,2 +17,3 @@ exports.HttpLlm = void 0;

var HttpLlmConverter_1 = require("./converters/HttpLlmConverter");
var LlmSchemaConverter_1 = require("./converters/LlmSchemaConverter");
var HttpLlmFunctionFetcher_1 = require("./http/HttpLlmFunctionFetcher");

@@ -62,5 +74,5 @@ var LlmDataMerger_1 = require("./utils/LlmDataMerger");

HttpLlm.application = function (props) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var _a, _b;
// MIGRATE
var migrate = props.document["x-samchon-emend-version"] === "2.0"
var migrate = props.document["x-samchon-emended"] === true
? HttpMigration_1.HttpMigration.application(props.document)

@@ -71,12 +83,3 @@ : props.document;

model: props.model,
options: (props.model === "chatgpt" || props.model === "3.1"
? {
separate: (_b = (_a = props.options) === null || _a === void 0 ? void 0 : _a.separate) !== null && _b !== void 0 ? _b : null,
reference: (_d = (_c = props.options) === null || _c === void 0 ? void 0 : _c.reference) !== null && _d !== void 0 ? _d : false,
constraint: (_f = (_e = props.options) === null || _e === void 0 ? void 0 : _e.constraint) !== null && _f !== void 0 ? _f : false,
}
: {
separate: (_h = (_g = props.options) === null || _g === void 0 ? void 0 : _g.separate) !== null && _h !== void 0 ? _h : null,
recursive: (_k = (_j = props.options) === null || _j === void 0 ? void 0 : _j.recursive) !== null && _k !== void 0 ? _k : 3,
}),
options: __assign(__assign({}, LlmSchemaConverter_1.LlmSchemaConverter.defaultConfig(props.model)), { separate: (_b = (_a = props.options) === null || _a === void 0 ? void 0 : _a.separate) !== null && _b !== void 0 ? _b : null }),
});

@@ -83,0 +86,0 @@ };

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

export * from "./structures/IChatGptSchema";
export * from "./structures/IClaudeSchema";
export * from "./structures/IGeminiSchema";

@@ -23,5 +24,6 @@ export * from "./structures/ILlmSchema";

export * from "./HttpLlm";
export * from "./utils/ChatGptTypeChecker";
export * from "./utils/ClaudeTypeChecker";
export * from "./utils/GeminiTypeChecker";
export * from "./utils/LlmTypeCheckerV3";
export * from "./utils/LlmTypeCheckerV3_1";
export * from "./utils/ChatGptTypeChecker";
export * from "./utils/GeminiTypeChecker";

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

__exportStar(require("./structures/IChatGptSchema"), exports);
__exportStar(require("./structures/IClaudeSchema"), exports);
__exportStar(require("./structures/IGeminiSchema"), exports);

@@ -48,5 +49,6 @@ __exportStar(require("./structures/ILlmSchema"), exports);

__exportStar(require("./HttpLlm"), exports);
__exportStar(require("./utils/ChatGptTypeChecker"), exports);
__exportStar(require("./utils/ClaudeTypeChecker"), exports);
__exportStar(require("./utils/GeminiTypeChecker"), exports);
__exportStar(require("./utils/LlmTypeCheckerV3"), exports);
__exportStar(require("./utils/LlmTypeCheckerV3_1"), exports);
__exportStar(require("./utils/ChatGptTypeChecker"), exports);
__exportStar(require("./utils/GeminiTypeChecker"), exports);

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

*/
"x-samchon-emend-version": "2.0";
"x-samchon-emended": true;
}

@@ -739,3 +739,3 @@ namespace IDocument {

*/
properties: Record<string, Schema>;
properties?: Record<string, Schema>;
/**

@@ -789,3 +789,3 @@ * Additional properties' info.

*/
required: string[];
required?: string[];
}

@@ -792,0 +792,0 @@ /**

@@ -36,26 +36,25 @@ /**

*
* Also, if you've composed the `IChatGptSchema` type with the
* {@link IChatGptSchema.IConfig.constraint} `false` option (default `false`),
* the `IChatGptSchema` would not compose these properties. Instead, these
* properties would be written on {@link IChatGptSchema.__IAttribute.descripotion}
* field like `@format uuid` case.
* Also, ChatGPT has banned below constraint properties. Instead, I'll will
* fill the {@link IChatGptSchema.__IAttribute.description} property with
* the comment text like `"@format uuid"`.
*
* - {@link IChatGptSchema.INumber.minimum}
* - {@link IChatGptSchema.INumber.maximum}
* - {@link IChatGptSchema.INumber.multipleOf}
* - {@link IChatGptSchema.IString.minLength}
* - {@link IChatGptSchema.IString.maxLength}
* - {@link IChatGptSchema.IString.format}
* - {@link IChatGptSchema.IString.pattern}
* - {@link IChatGptSchema.IString.contentMediaType}
* - {@link IChatGptSchema.IArray.minItems}
* - {@link IChatGptSchema.IArray.maxItems}
* - {@link IChatGptSchema.IArray.unique}
* - {@link OpenApi.IJsonSchema.INumber.minimum}
* - {@link OpenApi.IJsonSchema.INumber.maximum}
* - {@link OpenApi.IJsonSchema.INumber.multipleOf}
* - {@link OpenApi.IJsonSchema.IString.minLength}
* - {@link OpenApi.IJsonSchema.IString.maxLength}
* - {@link OpenApi.IJsonSchema.IString.format}
* - {@link OpenApi.IJsonSchema.IString.pattern}
* - {@link OpenApi.IJsonSchema.IString.contentMediaType}
* - {@link OpenApi.IJsonSchema.IString.default}
* - {@link OpenApi.IJsonSchema.IArray.minItems}
* - {@link OpenApi.IJsonSchema.IArray.maxItems}
* - {@link OpenApi.IJsonSchema.IArray.unique}
*
* @reference https://platform.openai.com/docs/guides/function-calling
* @reference https://platform.openai.com/docs/guides/structured-outputs
* @warning Specified not by the official documentation, but by my experiments.
* Therefore, its definitions can be inaccurate or be changed in the
* future. If you find any wrong or outdated definitions, please let me
* know by issue
* @warning Specified not only by the official documentation, but also by my
* experiments. Therefore, its definitions can be inaccurate or be
* changed in the future. If you find any wrong or outdated definitions,
* please let me know by issue.
* @issue https://github.com/samchon/openapi/issues

@@ -90,6 +89,2 @@ * @author Jeongho Nam - https://github.com/samchon

enum?: Array<boolean>;
/**
* The default value.
*/
default?: boolean;
}

@@ -104,45 +99,2 @@ /**

enum?: Array<number>;
/**
* Default value.
*
* @type int64
*/
default?: number;
/**
* Minimum value restriction.
*
* @type int64
*/
minimum?: number;
/**
* Maximum value restriction.
*
* @type int64
*/
maximum?: number;
/**
* Exclusive minimum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMinimum` value as `number`, {@link IChatGptSchema}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link minimum} property.
*/
exclusiveMinimum?: boolean;
/**
* Exclusive maximum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMaximum` value as `number`, {@link IChatGptSchema}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link maximum} property.
*/
exclusiveMaximum?: boolean;
/**
* Multiple of value restriction.
*
* @type uint64
* @exclusiveMinimum 0
*/
multipleOf?: number;
}

@@ -157,38 +109,2 @@ /**

enum?: Array<number>;
/**
* Default value.
*/
default?: number;
/**
* Minimum value restriction.
*/
minimum?: number;
/**
* Maximum value restriction.
*/
maximum?: number;
/**
* Exclusive minimum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMinimum` value as `number`, {@link OpenAiComposer}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link minimum} property.
*/
exclusiveMinimum?: boolean;
/**
* Exclusive maximum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMaximum` value as `number`, {@link OpenAiComposer}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link maximum} property.
*/
exclusiveMaximum?: boolean;
/**
* Multiple of value restriction.
*
* @exclusiveMinimum 0
*/
multipleOf?: number;
}

@@ -203,30 +119,2 @@ /**

enum?: Array<string>;
/**
* Default value.
*/
default?: string;
/**
* Format restriction.
*/
format?: "binary" | "byte" | "password" | "regex" | "uuid" | "email" | "hostname" | "idn-email" | "idn-hostname" | "iri" | "iri-reference" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer" | (string & {});
/**
* Pattern restriction.
*/
pattern?: string;
/**
* Content media type restriction.
*/
contentMediaType?: string;
/**
* Minimum length restriction.
*
* @type uint64
*/
minLength?: number;
/**
* Maximum length restriction.
*
* @type uint64
*/
maxLength?: number;
}

@@ -244,24 +132,2 @@ /**

items: IChatGptSchema;
/**
* Unique items restriction.
*
* If this property value is `true`, target array must have unique items.
*/
uniqueItems?: boolean;
/**
* Minimum items restriction.
*
* Restriction of minumum number of items in the array.
*
* @type uint64
*/
minItems?: number;
/**
* Maximum items restriction.
*
* Restriction of maximum number of items in the array.
*
* @type uint64
*/
maxItems?: number;
}

@@ -364,6 +230,2 @@ /**

interface INull extends __ISignificant<"null"> {
/**
* Default value.
*/
default?: null;
}

@@ -418,32 +280,2 @@ /**

/**
* Whether to allow contraint properties or not.
*
* If you configure this property to `false`, the schemas do not containt
* the constraint properties of below. Instead, below properties would be
* written to the {@link IChatGptSchema.__IAttribute.description} property
* as a comment string like `"@format uuid"`.
*
* This is because the ChatGPT function calling understands the constraint
* properties when the function parameter types are simple, however it occurs
* some errors when the parameter types are complex.
*
* Therefore, considering the complexity of your parameter types, determine
* which is better, to allow the constraint properties or not.
*
* - {@link IChatGptSchema.INumber.minimum}
* - {@link IChatGptSchema.INumber.maximum}
* - {@link IChatGptSchema.INumber.multipleOf}
* - {@link IChatGptSchema.IString.minLength}
* - {@link IChatGptSchema.IString.maxLength}
* - {@link IChatGptSchema.IString.format}
* - {@link IChatGptSchema.IString.pattern}
* - {@link IChatGptSchema.IString.contentMediaType}
* - {@link IChatGptSchema.IArray.minItems}
* - {@link IChatGptSchema.IArray.maxItems}
* - {@link IChatGptSchema.IArray.unique}
*
* @default false
*/
constraint: boolean;
/**
* Whether to allow reference type in everywhere.

@@ -450,0 +282,0 @@ *

@@ -45,2 +45,3 @@ /**

* - {@link OpenApi.IJsonSchema.IString.contentMediaType}
* - {@link OpenApi.IJsonSchema.IString.default}
* - {@link OpenApi.IJsonSchema.IArray.minItems}

@@ -53,6 +54,7 @@ * - {@link OpenApi.IJsonSchema.IArray.maxItems}

* @reference https://ai.google.dev/gemini-api/docs/structured-output
* @warning Specified not by the official documentation, but by my experiments.
* Therefore, its definitions can be inaccurate or be changed in the
* future. If you find any wrong or outdated definitions, please let me
* know by issue
* @warning Specified not only by the official documentation, but also by my
* experiments. Therefore, its definitions can be inaccurate or be
* changed in the future. If you find any wrong or outdated definitions,
* please let me know by issue.
* @issue https://github.com/samchon/openapi/issues
* @author Jeongho Nam - https://github.com/samchon

@@ -81,8 +83,2 @@ */

enum?: Array<boolean | null>;
/**
* Default value.
*
* @warning document of Gemini says not supported, but cannot sure
*/
default?: boolean | null;
}

@@ -99,9 +95,2 @@ /**

enum?: Array<number | null>;
/**
* Default value.
*
* @type int64
* @warning document of Gemini says not supported, but cannot sure
*/
default?: number | null;
}

@@ -116,8 +105,2 @@ /**

enum?: Array<number | null>;
/**
* Default value.
*
* @warning document of Gemini says not supported, but cannot sure
*/
default?: number | null;
}

@@ -214,8 +197,2 @@ /**

type: "null";
/**
* Default value.
*
* @warning document of Gemini says not supported, but cannot sure
*/
default?: null;
}

@@ -222,0 +199,0 @@ /**

import { IChatGptSchema } from "./IChatGptSchema";
import { IClaudeSchema } from "./IClaudeSchema";
import { IGeminiSchema } from "./IGeminiSchema";

@@ -46,20 +47,23 @@ import { ILlmFunction } from "./ILlmFunction";

export declare namespace ILlmApplication {
type Model = "3.0" | "3.1" | "chatgpt" | "gemini";
type Model = "chatgpt" | "claude" | "gemini" | "3.0" | "3.1";
type ModelParameters = {
chatgpt: IChatGptSchema.IParameters;
claude: IClaudeSchema.IParameters;
gemini: IGeminiSchema.IParameters;
"3.0": ILlmSchemaV3.IParameters;
"3.1": ILlmSchemaV3_1.IParameters;
chatgpt: IChatGptSchema.IParameters;
gemini: IGeminiSchema.IParameters;
};
type ModelSchema = {
chatgpt: IChatGptSchema;
claude: IClaudeSchema;
gemini: IGeminiSchema;
"3.0": ILlmSchemaV3;
"3.1": ILlmSchemaV3_1;
chatgpt: IChatGptSchema;
gemini: IGeminiSchema;
};
type ModelConfig = {
chatgpt: IChatGptSchema.IConfig;
claude: IClaudeSchema.IConfig;
gemini: IGeminiSchema.IConfig;
"3.0": ILlmSchemaV3.IConfig;
"3.1": ILlmSchemaV3_1.IConfig;
chatgpt: IChatGptSchema.IConfig;
gemini: IGeminiSchema.IConfig;
};

@@ -66,0 +70,0 @@ /**

import { IChatGptSchema } from "./IChatGptSchema";
import { IClaudeSchema } from "./IClaudeSchema";
import { IGeminiSchema } from "./IGeminiSchema";

@@ -27,3 +28,3 @@ import { ILlmSchemaV3 } from "./ILlmSchemaV3";

*/
export interface ILlmFunction<Parameters extends ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters | IChatGptSchema.IParameters | IGeminiSchema.IParameters> {
export interface ILlmFunction<Parameters extends IChatGptSchema.IParameters | IClaudeSchema.IParameters | IGeminiSchema.IParameters | ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters> {
/**

@@ -87,3 +88,3 @@ * Representative name of the function.

*/
interface ISeparated<Parameters extends ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters | IChatGptSchema.IParameters | IGeminiSchema.IParameters> {
interface ISeparated<Parameters extends IChatGptSchema.IParameters | IClaudeSchema.IParameters | IGeminiSchema.IParameters | ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters> {
/**

@@ -90,0 +91,0 @@ * Parameters that would be composed by the LLM.

import { IChatGptSchema } from "./IChatGptSchema";
import { IClaudeSchema } from "./IClaudeSchema";
import { IGeminiSchema } from "./IGeminiSchema";

@@ -15,6 +16,6 @@ import { ILlmSchemaV3 } from "./ILlmSchemaV3";

*/
export type ILlmSchema = IChatGptSchema | IGeminiSchema | ILlmSchemaV3 | ILlmSchemaV3_1;
export type ILlmSchema = IChatGptSchema | IClaudeSchema | IGeminiSchema | ILlmSchemaV3 | ILlmSchemaV3_1;
export declare namespace ILlmSchema {
type IParameters = IChatGptSchema.IParameters | IGeminiSchema.IParameters | ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters;
type IConfig = IChatGptSchema.IConfig | IGeminiSchema.IConfig | ILlmSchemaV3.IConfig | ILlmSchemaV3_1.IConfig;
type IParameters = IChatGptSchema.IParameters | IClaudeSchema.IParameters | IGeminiSchema.IParameters | ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters;
type IConfig = IChatGptSchema.IConfig | IClaudeSchema.IConfig | IGeminiSchema.IConfig | ILlmSchemaV3.IConfig | ILlmSchemaV3_1.IConfig;
}

@@ -15,3 +15,2 @@ /**

* - Resolve nullable property: {@link OpenApiV3_1.IJsonSchema.__ISignificant.nullable}
* - Tuple type is banned: {@link OpenApiV3_1.IJsonSchema.ITuple.prefixItems}
* - Constant type is banned: {@link OpenApiV3_1.IJsonSchema.IConstant}

@@ -27,8 +26,9 @@ * - Merge {@link OpenApiV3_1.IJsonSchema.IAnyOf} to {@link ILlmSchemaV3_1.IOneOf}

* - Do not support {@link OpenApi.IJsonSchema.ITuple} type
* - {@link ILlmSchemaV3_1.additionalProperties} is fixed to `false`
* - {@link ILlmSchemaV3_1.properties} and {@link ILlmSchemaV3_1.required} are always defined
*
* For reference, if you've composed the `ILlmSchemaV3_1` type with the
* {@link ILlmSchemaV3_1.IConfig.reference} `false` option (default is `false`),
* only the recursived named types would be archived into the
* {@link ILlmSchemaV3_1.IParameters.$defs}, and the others would be ecaped from the
* {@link ILlmSchemaV3_1.IReference} type.
* {@link ILlmSchemaV3_1.IConfig.reference} `false` option (default is `false`), only the
* recursived named types would be archived into the {@link ILlmSchemaV3_1.IParameters.$defs},
* and the others would be ecaped from the {@link ILlmSchemaV3_1.IReference} type.
*

@@ -57,3 +57,3 @@ * Also, if you've composed the `ILlmSchemaV3_1` type with the

*/
export type ILlmSchemaV3_1 = ILlmSchemaV3_1.IBoolean | ILlmSchemaV3_1.IInteger | ILlmSchemaV3_1.INumber | ILlmSchemaV3_1.IString | ILlmSchemaV3_1.IArray | ILlmSchemaV3_1.IObject | ILlmSchemaV3_1.IOneOf | ILlmSchemaV3_1.IReference | ILlmSchemaV3_1.INull | ILlmSchemaV3_1.IUnknown;
export type ILlmSchemaV3_1 = ILlmSchemaV3_1.IConstant | ILlmSchemaV3_1.IBoolean | ILlmSchemaV3_1.IInteger | ILlmSchemaV3_1.INumber | ILlmSchemaV3_1.IString | ILlmSchemaV3_1.IArray | ILlmSchemaV3_1.IObject | ILlmSchemaV3_1.IReference | ILlmSchemaV3_1.IOneOf | ILlmSchemaV3_1.INull | ILlmSchemaV3_1.IUnknown;
export declare namespace ILlmSchemaV3_1 {

@@ -445,2 +445,3 @@ /**

* - {@link ILlmSchemaV3_1.IString.contentMediaType}
* - {@link ILlmSchemaV3_1.IString.default}
* - {@link ILlmSchemaV3_1.IArray.minItems}

@@ -447,0 +448,0 @@ * - {@link ILlmSchemaV3_1.IArray.maxItems}

@@ -402,2 +402,3 @@ /**

* - {@link ILlmSchemaV3.IString.contentMediaType}
* - {@link ILlmSchemaV3.IString.default}
* - {@link ILlmSchemaV3.IArray.minItems}

@@ -404,0 +405,0 @@ * - {@link ILlmSchemaV3.IArray.maxItems}

@@ -193,8 +193,16 @@ "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;
// 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({

@@ -253,18 +261,18 @@ $defs: p.$defs,

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)),
// 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; });

@@ -278,18 +286,18 @@ };

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)),
// 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; });

@@ -303,19 +311,11 @@ };

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),
// 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; });
};
var coverFormat = function (x, y) {
return 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");
};
var flatSchema = function ($defs, schema) {

@@ -322,0 +322,0 @@ schema = escapeReference($defs, schema);

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

var escapeSchema = function (props) {
var _a, _b;
var _a, _b, _c, _d;
if (OpenApiTypeCheckerBase.isReference(props.schema)) {

@@ -297,4 +297,5 @@ // REFERENCE

else if (properties_1.some(function (_a) {
var _b = __read(_a, 2), k = _b[0], v = _b[1];
return v === undefined && object_1.required.includes(k) === true;
var _b;
var _c = __read(_a, 2), k = _c[0], v = _c[1];
return v === undefined && ((_b = object_1.required) === null || _b === void 0 ? void 0 : _b.includes(k)) === true;
}) === true)

@@ -305,3 +306,3 @@ return undefined;

return v !== undefined;
})), additionalProperties: additionalProperties !== null && additionalProperties !== void 0 ? additionalProperties : false, required: object_1.required.filter(function (k) {
})), additionalProperties: additionalProperties !== null && additionalProperties !== void 0 ? additionalProperties : false, required: (_d = (_c = object_1.required) === null || _c === void 0 ? void 0 : _c.filter(function (k) {
return properties_1.some(function (_a) {

@@ -311,3 +312,3 @@ var _b = __read(_a, 2), key = _b[0], value = _b[1];

});
}) });
})) !== null && _d !== void 0 ? _d : [] });
}

@@ -504,9 +505,9 @@ else if (OpenApiTypeCheckerBase.isTuple(props.schema)) {

return Object.entries((_a = p.y.properties) !== null && _a !== void 0 ? _a : {}).every(function (_a) {
var _b;
var _c = __read(_a, 2), key = _c[0], b = _c[1];
var _b, _c, _d, _e;
var _f = __read(_a, 2), key = _f[0], b = _f[1];
var a = (_b = p.x.properties) === null || _b === void 0 ? void 0 : _b[key];
if (a === undefined)
return false;
else if (p.x.required.includes(key) === true &&
p.y.required.includes(key) === false)
else if (((_c = p.x.required) === null || _c === void 0 ? void 0 : _c.includes(key)) === true &&
((_e = (_d = p.y.required) === null || _d === void 0 ? void 0 : _d.includes(key)) !== null && _e !== void 0 ? _e : false) === false)
return false;

@@ -513,0 +514,0 @@ return coverStation({

@@ -18,7 +18,7 @@ import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1";

}) => boolean;
const escape: (props: {
const covers: (props: {
$defs?: Record<string, ILlmSchemaV3_1>;
schema: ILlmSchemaV3_1;
recursive: false | number;
}) => ILlmSchemaV3_1 | null;
x: ILlmSchemaV3_1;
y: ILlmSchemaV3_1;
}) => boolean;
const visit: (props: {

@@ -29,7 +29,2 @@ closure: (schema: ILlmSchemaV3_1) => void;

}) => void;
const covers: (props: {
$defs?: Record<string, ILlmSchemaV3_1>;
x: ILlmSchemaV3_1;
y: ILlmSchemaV3_1;
}) => boolean;
}

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

----------------------------------------------------------- */
LlmTypeCheckerV3_1.escape = function (props) {
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.escape({
LlmTypeCheckerV3_1.covers = function (props) {
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.covers({
prefix: "#/$defs/",

@@ -56,4 +56,4 @@ components: {

},
schema: props.schema,
recursive: props.recursive,
x: props.x,
y: props.y,
});

@@ -64,19 +64,9 @@ };

prefix: "#/$defs/",
closure: props.closure,
components: {
schemas: props.$defs,
},
closure: props.closure,
schema: props.schema,
});
};
LlmTypeCheckerV3_1.covers = function (props) {
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.covers({
prefix: "#/$defs/",
components: {
schemas: props.$defs,
},
x: props.x,
y: props.y,
});
};
})(LlmTypeCheckerV3_1 || (exports.LlmTypeCheckerV3_1 = LlmTypeCheckerV3_1 = {}));
import { OpenApi } from "../OpenApi";
export declare namespace OpenApiContraintShifter {
const shiftArray: <Schema extends Pick<OpenApi.IJsonSchema.IArray, "description" | "minItems" | "maxItems" | "uniqueItems">>(v: Schema) => Omit<Schema, "minItems" | "maxItems" | "uniqueItems">;
const shiftNumeric: <Schema extends Pick<OpenApi.IJsonSchema.INumber | OpenApi.IJsonSchema.IInteger, "description" | "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf">>(v: Schema) => Omit<Schema, "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf">;
const shiftString: <Schema extends Pick<OpenApi.IJsonSchema.IString, "description" | "minLength" | "maxLength" | "format" | "pattern" | "contentMediaType">>(v: Schema) => Omit<Schema, "minLength" | "maxLength" | "format" | "pattern" | "contentMediaType">;
const shiftNumeric: <Schema extends Pick<OpenApi.IJsonSchema.INumber | OpenApi.IJsonSchema.IInteger, "description" | "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf" | "default">>(v: Schema) => Omit<Schema, "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf" | "default">;
const shiftString: <Schema extends Pick<OpenApi.IJsonSchema.IString, "description" | "minLength" | "maxLength" | "format" | "pattern" | "contentMediaType" | "default">>(v: Schema) => Omit<Schema, "minLength" | "maxLength" | "format" | "pattern" | "contentMediaType" | "default">;
}

@@ -74,2 +74,6 @@ "use strict";

}
if (v.default !== undefined) {
tags.push("@default ".concat(v.default));
delete v.default;
}
v.description = writeTagWithDescription({

@@ -103,2 +107,6 @@ description: v.description,

}
if (v.default !== undefined) {
tags.push("@default ".concat(v.default));
delete v.default;
}
v.description = writeTagWithDescription({

@@ -105,0 +113,0 @@ description: v.description,

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

@@ -35,2 +35,3 @@ "main": "./lib/index.js",

"devDependencies": {
"@anthropic-ai/sdk": "^0.32.1",
"@google/generative-ai": "^0.21.0",

@@ -37,0 +38,0 @@ "@nestia/core": "4.0.0-dev.20241116",

@@ -46,3 +46,3 @@ > ## Next version is coming.

- ✔️[`IChatGptSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IChatGptSchema.ts): OpenAI ChatGPT
- ✍️`IClaudeSchema`: Anthropic Claude
- ✔️[`IClaudeSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IClaudeSchema.ts): Anthropic Claude (same with [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts))
- ✔️[`IGeminiSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IGeminiSchema.ts): Google Gemini

@@ -247,2 +247,3 @@ - ✍️`ILlamaSchema`: Meta (Facebook) Llama

- [`ChatGptTypeChecker`](https://github.com/samchon/openapi/blob/master/src/utils/ChatGptTypeChecker.ts)
- [`ClaudeTypeChecker`](https://github.com/samchon/openapi/blob/master/src/utils/ClaudeTypeChecker.ts)
- [`GeminiTypeChecker`](https://github.com/samchon/openapi/blob/master/src/utils/GeminiTypeChecker.ts)

@@ -249,0 +250,0 @@ - [`LlmTypeCheckerV3`](https://github.com/samchon/openapi/blob/master/src/utils/LlmTypeCheckerV3.ts)

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

LlmConverterV3_1.parameters({
config: props.config,
config: {
reference: props.config.reference,
constraint: false,
},
components: props.components,

@@ -38,3 +41,6 @@ schema: props.schema,

const schema: ILlmSchemaV3_1 | null = LlmConverterV3_1.schema({
config: props.config,
config: {
reference: props.config.reference,
constraint: false,
},
components: props.components,

@@ -41,0 +47,0 @@ $defs: props.$defs,

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

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

@@ -47,11 +46,7 @@

if (LlmTypeCheckerV3.isOneOf(v)) union = true;
else if (LlmTypeCheckerV3.isObject(v)) {
if (v.additionalProperties !== undefined)
delete (v as Partial<ILlmSchemaV3.IObject>).additionalProperties;
} else if (LlmTypeCheckerV3.isArray(v))
OpenApiContraintShifter.shiftArray(v);
else if (LlmTypeCheckerV3.isString(v))
OpenApiContraintShifter.shiftString(v);
else if (LlmTypeCheckerV3.isNumber(v) || LlmTypeCheckerV3.isInteger(v))
OpenApiContraintShifter.shiftNumeric(v);
else if (
LlmTypeCheckerV3.isObject(v) &&
v.additionalProperties !== undefined
)
delete (v as Partial<ILlmSchemaV3.IObject>).additionalProperties;
});

@@ -58,0 +53,0 @@ return union ? null : schema;

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

import { ChatGptConverter } from "./ChatGptConverter";
import { ClaudeConverter } from "./ClaudeConverter";
import { GeminiConverter } from "./GeminiConverter";

@@ -238,6 +239,7 @@ import { LlmConverterV3 } from "./LlmConverterV3";

const SEPARATORS = {
chatgpt: ChatGptConverter.separate,
claude: ClaudeConverter.separate,
gemini: GeminiConverter.separate,
"3.0": LlmConverterV3.separate,
"3.1": LlmConverterV3_1.separate,
chatgpt: ChatGptConverter.separate,
gemini: GeminiConverter.separate,
};

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

const properties: Record<string, ILlmSchemaV3_1 | null> =
Object.entries(input.properties || {}).reduce(
Object.entries(input.properties ?? {}).reduce(
(acc, [key, value]) => {

@@ -114,0 +114,0 @@ const converted: ILlmSchemaV3_1 | null = schema({

import { OpenApi } from "../OpenApi";
import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3";
import { LlmTypeCheckerV3 } from "../utils/LlmTypeCheckerV3";
import { OpenApiContraintShifter } from "../utils/OpenApiContraintShifter";
import { OpenApiTypeChecker } from "../utils/OpenApiTypeChecker";

@@ -42,3 +43,13 @@ import { OpenApiV3Downgrader } from "./OpenApiV3Downgrader";

schema.additionalProperties = false;
}
} else if (
LlmTypeCheckerV3.isInteger(schema) ||
LlmTypeCheckerV3.isNumber(schema)
)
OpenApiContraintShifter.shiftNumeric(
schema as OpenApi.IJsonSchema.IInteger | OpenApi.IJsonSchema.INumber,
);
else if (LlmTypeCheckerV3.isString(schema))
OpenApiContraintShifter.shiftString(
schema as OpenApi.IJsonSchema.IString,
);
});

@@ -45,0 +56,0 @@ return downgraded;

import { OpenApi } from "../OpenApi";
import { IChatGptSchema } from "../structures/IChatGptSchema";
import { IClaudeSchema } from "../structures/IClaudeSchema";
import { IGeminiSchema } from "../structures/IGeminiSchema";

@@ -8,2 +9,3 @@ import { ILlmApplication } from "../structures/ILlmApplication";

import { ChatGptConverter } from "./ChatGptConverter";
import { ClaudeConverter } from "./ClaudeConverter";
import { GeminiConverter } from "./GeminiConverter";

@@ -20,15 +22,19 @@ import { LlmConverterV3 } from "./LlmConverterV3";

SCHEMA_CASTERS[model];
export const defaultConfig = <Model extends ILlmApplication.Model>(
model: Model,
) => DEFAULT_CONFIGS[model];
}
const PARAMETERS_CASTERS = {
"3.0": (props: {
chatgpt: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
config: ILlmSchemaV3.IConfig;
}) =>
LlmConverterV3.parameters({
components: props.components,
schema: props.schema,
config: props.config,
}),
config: IChatGptSchema.IConfig;
}) => ChatGptConverter.parameters(props),
claude: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
config: IClaudeSchema.IConfig;
}) => ClaudeConverter.parameters(props),
gemini: (props: {

@@ -38,8 +44,8 @@ components: OpenApi.IComponents;

config: IGeminiSchema.IConfig;
}) =>
GeminiConverter.parameters({
components: props.components,
schema: props.schema,
config: props.config,
}),
}) => GeminiConverter.parameters(props),
"3.0": (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
config: ILlmSchemaV3.IConfig;
}) => LlmConverterV3.parameters(props),
"3.1": (props: {

@@ -49,29 +55,28 @@ components: OpenApi.IComponents;

config: ILlmSchemaV3_1.IConfig;
}) =>
LlmConverterV3_1.parameters({
components: props.components,
schema: props.schema,
config: props.config,
}),
}) => LlmConverterV3_1.parameters(props),
};
const SCHEMA_CASTERS = {
chatgpt: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema.IObject;
schema: OpenApi.IJsonSchema;
$defs: Record<string, IChatGptSchema>;
config: IChatGptSchema.IConfig;
}) =>
ChatGptConverter.parameters({
ChatGptConverter.schema({
components: props.components,
schema: props.schema,
$defs: props.$defs,
config: props.config,
}),
};
const SCHEMA_CASTERS = {
"3.0": (props: {
claude: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
config: ILlmSchemaV3.IConfig;
$defs: Record<string, IClaudeSchema>;
config: IClaudeSchema.IConfig;
}) =>
LlmConverterV3.schema({
ClaudeConverter.schema({
components: props.components,
schema: props.schema,
$defs: props.$defs,
config: props.config,

@@ -89,2 +94,12 @@ }),

}),
"3.0": (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
config: ILlmSchemaV3.IConfig;
}) =>
LlmConverterV3.schema({
components: props.components,
schema: props.schema,
config: props.config,
}),
"3.1": (props: {

@@ -102,14 +117,22 @@ components: OpenApi.IComponents;

}),
chatgpt: (props: {
components: OpenApi.IComponents;
schema: OpenApi.IJsonSchema;
$defs: Record<string, IChatGptSchema>;
config: IChatGptSchema.IConfig;
}) =>
ChatGptConverter.schema({
components: props.components,
schema: props.schema,
$defs: props.$defs,
config: props.config,
}),
};
const DEFAULT_CONFIGS = {
chatgpt: {
reference: false,
} satisfies IChatGptSchema.IConfig,
claude: {
reference: false,
} satisfies IClaudeSchema.IConfig,
gemini: {
recursive: 3,
} satisfies IGeminiSchema.IConfig,
"3.0": {
constraint: false,
recursive: 3,
} satisfies ILlmSchemaV3.IConfig,
"3.1": {
constraint: false,
reference: false,
} satisfies ILlmSchemaV3_1.IConfig,
};

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

]),
required: [...new Set(entire.map((o) => o.required).flat())],
required: [
...new Set(entire.map((o) => o.required ?? []).flat()),
],
},

@@ -181,0 +183,0 @@ }),

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

export const convert = (input: OpenApiV3_1.IDocument): OpenApi.IDocument => {
if ((input as OpenApi.IDocument)["x-samchon-emend-version"] === "2.0")
if ((input as OpenApi.IDocument)["x-samchon-emended"] === true)
return input as OpenApi.IDocument;

@@ -32,3 +32,3 @@ return {

: undefined,
"x-samchon-emend-version": "2.0",
"x-samchon-emended": true,
};

@@ -35,0 +35,0 @@ };

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

openapi: "3.1.0",
"x-samchon-emend-version": "2.0",
"x-samchon-emended": true,
});

@@ -22,0 +22,0 @@

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

tags: input.tags,
"x-samchon-emend-version": "2.0",
"x-samchon-emended": true,
});

@@ -31,0 +31,0 @@

import { HttpMigration } from "./HttpMigration";
import { OpenApi } from "./OpenApi";
import { HttpLlmConverter } from "./converters/HttpLlmConverter";
import { LlmSchemaConverter } from "./converters/LlmSchemaConverter";
import { HttpLlmFunctionFetcher } from "./http/HttpLlmFunctionFetcher";

@@ -90,3 +91,3 @@ import { IChatGptSchema } from "./structures/IChatGptSchema";

const migrate: IHttpMigrateApplication =
(props.document as OpenApi.IDocument)["x-samchon-emend-version"] === "2.0"
(props.document as OpenApi.IDocument)["x-samchon-emended"] === true
? HttpMigration.application(props.document as OpenApi.IDocument)

@@ -97,24 +98,6 @@ : (props.document as IHttpMigrateApplication);

model: props.model,
options: (props.model === "chatgpt" || props.model === "3.1"
? ({
separate:
(props.options
?.separate as IHttpLlmApplication.IOptions<any>["separate"]) ??
null,
reference:
(props.options as IHttpLlmApplication.IOptions<any> | undefined)
?.reference ?? false,
constraint:
(props.options as IHttpLlmApplication.IOptions<any> | undefined)
?.constraint ?? false,
} satisfies IHttpLlmApplication.IOptions<any>)
: ({
separate:
(props.options
?.separate as IHttpLlmApplication.IOptions<any>["separate"]) ??
null,
recursive:
(props.options as IHttpLlmApplication.IOptions<any> | undefined)
?.recursive ?? 3,
} satisfies IHttpLlmApplication.IOptions<any>)) as IHttpLlmApplication.IOptions<any>,
options: {
...LlmSchemaConverter.defaultConfig(props.model),
separate: props.options?.separate ?? null,
},
});

@@ -121,0 +104,0 @@ };

@@ -32,2 +32,3 @@ //----

export * from "./structures/IChatGptSchema";
export * from "./structures/IClaudeSchema";
export * from "./structures/IGeminiSchema";

@@ -39,5 +40,6 @@ export * from "./structures/ILlmSchema";

export * from "./HttpLlm";
export * from "./utils/ChatGptTypeChecker";
export * from "./utils/ClaudeTypeChecker";
export * from "./utils/GeminiTypeChecker";
export * from "./utils/LlmTypeCheckerV3";
export * from "./utils/LlmTypeCheckerV3_1";
export * from "./utils/ChatGptTypeChecker";
export * from "./utils/GeminiTypeChecker";

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

*/
"x-samchon-emend-version": "2.0";
"x-samchon-emended": true;
}

@@ -949,3 +949,3 @@ export namespace IDocument {

*/
properties: Record<string, Schema>;
properties?: Record<string, Schema>;

@@ -1001,3 +1001,3 @@ /**

*/
required: string[];
required?: string[];
}

@@ -1004,0 +1004,0 @@

@@ -36,26 +36,25 @@ /**

*
* Also, if you've composed the `IChatGptSchema` type with the
* {@link IChatGptSchema.IConfig.constraint} `false` option (default `false`),
* the `IChatGptSchema` would not compose these properties. Instead, these
* properties would be written on {@link IChatGptSchema.__IAttribute.descripotion}
* field like `@format uuid` case.
* Also, ChatGPT has banned below constraint properties. Instead, I'll will
* fill the {@link IChatGptSchema.__IAttribute.description} property with
* the comment text like `"@format uuid"`.
*
* - {@link IChatGptSchema.INumber.minimum}
* - {@link IChatGptSchema.INumber.maximum}
* - {@link IChatGptSchema.INumber.multipleOf}
* - {@link IChatGptSchema.IString.minLength}
* - {@link IChatGptSchema.IString.maxLength}
* - {@link IChatGptSchema.IString.format}
* - {@link IChatGptSchema.IString.pattern}
* - {@link IChatGptSchema.IString.contentMediaType}
* - {@link IChatGptSchema.IArray.minItems}
* - {@link IChatGptSchema.IArray.maxItems}
* - {@link IChatGptSchema.IArray.unique}
* - {@link OpenApi.IJsonSchema.INumber.minimum}
* - {@link OpenApi.IJsonSchema.INumber.maximum}
* - {@link OpenApi.IJsonSchema.INumber.multipleOf}
* - {@link OpenApi.IJsonSchema.IString.minLength}
* - {@link OpenApi.IJsonSchema.IString.maxLength}
* - {@link OpenApi.IJsonSchema.IString.format}
* - {@link OpenApi.IJsonSchema.IString.pattern}
* - {@link OpenApi.IJsonSchema.IString.contentMediaType}
* - {@link OpenApi.IJsonSchema.IString.default}
* - {@link OpenApi.IJsonSchema.IArray.minItems}
* - {@link OpenApi.IJsonSchema.IArray.maxItems}
* - {@link OpenApi.IJsonSchema.IArray.unique}
*
* @reference https://platform.openai.com/docs/guides/function-calling
* @reference https://platform.openai.com/docs/guides/structured-outputs
* @warning Specified not by the official documentation, but by my experiments.
* Therefore, its definitions can be inaccurate or be changed in the
* future. If you find any wrong or outdated definitions, please let me
* know by issue
* @warning Specified not only by the official documentation, but also by my
* experiments. Therefore, its definitions can be inaccurate or be
* changed in the future. If you find any wrong or outdated definitions,
* please let me know by issue.
* @issue https://github.com/samchon/openapi/issues

@@ -101,7 +100,2 @@ * @author Jeongho Nam - https://github.com/samchon

enum?: Array<boolean>;
/**
* The default value.
*/
default?: boolean;
}

@@ -117,51 +111,2 @@

enum?: Array<number>;
/**
* Default value.
*
* @type int64
*/
default?: number;
/**
* Minimum value restriction.
*
* @type int64
*/
minimum?: number;
/**
* Maximum value restriction.
*
* @type int64
*/
maximum?: number;
/**
* Exclusive minimum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMinimum` value as `number`, {@link IChatGptSchema}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link minimum} property.
*/
exclusiveMinimum?: boolean;
/**
* Exclusive maximum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMaximum` value as `number`, {@link IChatGptSchema}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link maximum} property.
*/
exclusiveMaximum?: boolean;
/**
* Multiple of value restriction.
*
* @type uint64
* @exclusiveMinimum 0
*/
multipleOf?: number;
}

@@ -177,44 +122,2 @@

enum?: Array<number>;
/**
* Default value.
*/
default?: number;
/**
* Minimum value restriction.
*/
minimum?: number;
/**
* Maximum value restriction.
*/
maximum?: number;
/**
* Exclusive minimum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMinimum` value as `number`, {@link OpenAiComposer}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link minimum} property.
*/
exclusiveMinimum?: boolean;
/**
* Exclusive maximum value restriction.
*
* For reference, even though your Swagger (or OpenAPI) document has
* defined the `exclusiveMaximum` value as `number`, {@link OpenAiComposer}
* forcibly converts it to `boolean` type, and assign the numeric value to
* the {@link maximum} property.
*/
exclusiveMaximum?: boolean;
/**
* Multiple of value restriction.
*
* @exclusiveMinimum 0
*/
multipleOf?: number;
}

@@ -230,60 +133,2 @@

enum?: Array<string>;
/**
* Default value.
*/
default?: string;
/**
* Format restriction.
*/
format?:
| "binary"
| "byte"
| "password"
| "regex"
| "uuid"
| "email"
| "hostname"
| "idn-email"
| "idn-hostname"
| "iri"
| "iri-reference"
| "ipv4"
| "ipv6"
| "uri"
| "uri-reference"
| "uri-template"
| "url"
| "date-time"
| "date"
| "time"
| "duration"
| "json-pointer"
| "relative-json-pointer"
| (string & {});
/**
* Pattern restriction.
*/
pattern?: string;
/**
* Content media type restriction.
*/
contentMediaType?: string;
/**
* Minimum length restriction.
*
* @type uint64
*/
minLength?: number;
/**
* Maximum length restriction.
*
* @type uint64
*/
maxLength?: number;
}

@@ -302,27 +147,2 @@

items: IChatGptSchema;
/**
* Unique items restriction.
*
* If this property value is `true`, target array must have unique items.
*/
uniqueItems?: boolean;
/**
* Minimum items restriction.
*
* Restriction of minumum number of items in the array.
*
* @type uint64
*/
minItems?: number;
/**
* Maximum items restriction.
*
* Restriction of maximum number of items in the array.
*
* @type uint64
*/
maxItems?: number;
}

@@ -430,8 +250,3 @@

*/
export interface INull extends __ISignificant<"null"> {
/**
* Default value.
*/
default?: null;
}
export interface INull extends __ISignificant<"null"> {}

@@ -493,33 +308,2 @@ /**

/**
* Whether to allow contraint properties or not.
*
* If you configure this property to `false`, the schemas do not containt
* the constraint properties of below. Instead, below properties would be
* written to the {@link IChatGptSchema.__IAttribute.description} property
* as a comment string like `"@format uuid"`.
*
* This is because the ChatGPT function calling understands the constraint
* properties when the function parameter types are simple, however it occurs
* some errors when the parameter types are complex.
*
* Therefore, considering the complexity of your parameter types, determine
* which is better, to allow the constraint properties or not.
*
* - {@link IChatGptSchema.INumber.minimum}
* - {@link IChatGptSchema.INumber.maximum}
* - {@link IChatGptSchema.INumber.multipleOf}
* - {@link IChatGptSchema.IString.minLength}
* - {@link IChatGptSchema.IString.maxLength}
* - {@link IChatGptSchema.IString.format}
* - {@link IChatGptSchema.IString.pattern}
* - {@link IChatGptSchema.IString.contentMediaType}
* - {@link IChatGptSchema.IArray.minItems}
* - {@link IChatGptSchema.IArray.maxItems}
* - {@link IChatGptSchema.IArray.unique}
*
* @default false
*/
constraint: boolean;
/**
* Whether to allow reference type in everywhere.

@@ -526,0 +310,0 @@ *

@@ -45,2 +45,3 @@ /**

* - {@link OpenApi.IJsonSchema.IString.contentMediaType}
* - {@link OpenApi.IJsonSchema.IString.default}
* - {@link OpenApi.IJsonSchema.IArray.minItems}

@@ -53,6 +54,7 @@ * - {@link OpenApi.IJsonSchema.IArray.maxItems}

* @reference https://ai.google.dev/gemini-api/docs/structured-output
* @warning Specified not by the official documentation, but by my experiments.
* Therefore, its definitions can be inaccurate or be changed in the
* future. If you find any wrong or outdated definitions, please let me
* know by issue
* @warning Specified not only by the official documentation, but also by my
* experiments. Therefore, its definitions can be inaccurate or be
* changed in the future. If you find any wrong or outdated definitions,
* please let me know by issue.
* @issue https://github.com/samchon/openapi/issues
* @author Jeongho Nam - https://github.com/samchon

@@ -90,9 +92,2 @@ */

enum?: Array<boolean | null>;
/**
* Default value.
*
* @warning document of Gemini says not supported, but cannot sure
*/
default?: boolean | null;
}

@@ -110,10 +105,2 @@

enum?: Array<number | null>;
/**
* Default value.
*
* @type int64
* @warning document of Gemini says not supported, but cannot sure
*/
default?: number | null;
}

@@ -129,9 +116,2 @@

enum?: Array<number | null>;
/**
* Default value.
*
* @warning document of Gemini says not supported, but cannot sure
*/
default?: number | null;
}

@@ -234,9 +214,2 @@

type: "null";
/**
* Default value.
*
* @warning document of Gemini says not supported, but cannot sure
*/
default?: null;
}

@@ -243,0 +216,0 @@

import { IChatGptSchema } from "./IChatGptSchema";
import { IClaudeSchema } from "./IClaudeSchema";
import { IGeminiSchema } from "./IGeminiSchema";

@@ -58,20 +59,23 @@ import { ILlmFunction } from "./ILlmFunction";

export namespace ILlmApplication {
export type Model = "3.0" | "3.1" | "chatgpt" | "gemini";
export type Model = "chatgpt" | "claude" | "gemini" | "3.0" | "3.1";
export type ModelParameters = {
chatgpt: IChatGptSchema.IParameters;
claude: IClaudeSchema.IParameters;
gemini: IGeminiSchema.IParameters;
"3.0": ILlmSchemaV3.IParameters;
"3.1": ILlmSchemaV3_1.IParameters;
chatgpt: IChatGptSchema.IParameters;
gemini: IGeminiSchema.IParameters;
};
export type ModelSchema = {
chatgpt: IChatGptSchema;
claude: IClaudeSchema;
gemini: IGeminiSchema;
"3.0": ILlmSchemaV3;
"3.1": ILlmSchemaV3_1;
chatgpt: IChatGptSchema;
gemini: IGeminiSchema;
};
export type ModelConfig = {
chatgpt: IChatGptSchema.IConfig;
claude: IClaudeSchema.IConfig;
gemini: IGeminiSchema.IConfig;
"3.0": ILlmSchemaV3.IConfig;
"3.1": ILlmSchemaV3_1.IConfig;
chatgpt: IChatGptSchema.IConfig;
gemini: IGeminiSchema.IConfig;
};

@@ -78,0 +82,0 @@

import { IChatGptSchema } from "./IChatGptSchema";
import { IClaudeSchema } from "./IClaudeSchema";
import { IGeminiSchema } from "./IGeminiSchema";

@@ -30,6 +31,7 @@ import { ILlmSchemaV3 } from "./ILlmSchemaV3";

Parameters extends
| IChatGptSchema.IParameters
| IClaudeSchema.IParameters
| IGeminiSchema.IParameters
| ILlmSchemaV3.IParameters
| ILlmSchemaV3_1.IParameters
| IChatGptSchema.IParameters
| IGeminiSchema.IParameters,
| ILlmSchemaV3_1.IParameters,
> {

@@ -103,6 +105,7 @@ /**

Parameters extends
| IChatGptSchema.IParameters
| IClaudeSchema.IParameters
| IGeminiSchema.IParameters
| ILlmSchemaV3.IParameters
| ILlmSchemaV3_1.IParameters
| IChatGptSchema.IParameters
| IGeminiSchema.IParameters,
| ILlmSchemaV3_1.IParameters,
> {

@@ -109,0 +112,0 @@ /**

import { IChatGptSchema } from "./IChatGptSchema";
import { IClaudeSchema } from "./IClaudeSchema";
import { IGeminiSchema } from "./IGeminiSchema";

@@ -18,2 +19,3 @@ import { ILlmSchemaV3 } from "./ILlmSchemaV3";

| IChatGptSchema
| IClaudeSchema
| IGeminiSchema

@@ -26,2 +28,3 @@ | ILlmSchemaV3

| IChatGptSchema.IParameters
| IClaudeSchema.IParameters
| IGeminiSchema.IParameters

@@ -33,2 +36,3 @@ | ILlmSchemaV3.IParameters

| IChatGptSchema.IConfig
| IClaudeSchema.IConfig
| IGeminiSchema.IConfig

@@ -35,0 +39,0 @@ | ILlmSchemaV3.IConfig

@@ -15,3 +15,2 @@ /**

* - Resolve nullable property: {@link OpenApiV3_1.IJsonSchema.__ISignificant.nullable}
* - Tuple type is banned: {@link OpenApiV3_1.IJsonSchema.ITuple.prefixItems}
* - Constant type is banned: {@link OpenApiV3_1.IJsonSchema.IConstant}

@@ -27,8 +26,9 @@ * - Merge {@link OpenApiV3_1.IJsonSchema.IAnyOf} to {@link ILlmSchemaV3_1.IOneOf}

* - Do not support {@link OpenApi.IJsonSchema.ITuple} type
* - {@link ILlmSchemaV3_1.additionalProperties} is fixed to `false`
* - {@link ILlmSchemaV3_1.properties} and {@link ILlmSchemaV3_1.required} are always defined
*
* For reference, if you've composed the `ILlmSchemaV3_1` type with the
* {@link ILlmSchemaV3_1.IConfig.reference} `false` option (default is `false`),
* only the recursived named types would be archived into the
* {@link ILlmSchemaV3_1.IParameters.$defs}, and the others would be ecaped from the
* {@link ILlmSchemaV3_1.IReference} type.
* {@link ILlmSchemaV3_1.IConfig.reference} `false` option (default is `false`), only the
* recursived named types would be archived into the {@link ILlmSchemaV3_1.IParameters.$defs},
* and the others would be ecaped from the {@link ILlmSchemaV3_1.IReference} type.
*

@@ -58,2 +58,3 @@ * Also, if you've composed the `ILlmSchemaV3_1` type with the

export type ILlmSchemaV3_1 =
| ILlmSchemaV3_1.IConstant
| ILlmSchemaV3_1.IBoolean

@@ -65,4 +66,4 @@ | ILlmSchemaV3_1.IInteger

| ILlmSchemaV3_1.IObject
| ILlmSchemaV3_1.IReference
| ILlmSchemaV3_1.IOneOf
| ILlmSchemaV3_1.IReference
| ILlmSchemaV3_1.INull

@@ -520,2 +521,3 @@ | ILlmSchemaV3_1.IUnknown;

* - {@link ILlmSchemaV3_1.IString.contentMediaType}
* - {@link ILlmSchemaV3_1.IString.default}
* - {@link ILlmSchemaV3_1.IArray.minItems}

@@ -522,0 +524,0 @@ * - {@link ILlmSchemaV3_1.IArray.maxItems}

@@ -480,2 +480,3 @@ /**

* - {@link ILlmSchemaV3.IString.contentMediaType}
* - {@link ILlmSchemaV3.IString.default}
* - {@link ILlmSchemaV3.IArray.minItems}

@@ -482,0 +483,0 @@ * - {@link ILlmSchemaV3.IArray.maxItems}

@@ -193,16 +193,16 @@ import { IChatGptSchema } from "../structures/IChatGptSchema";

}): 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;
// 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({

@@ -272,18 +272,18 @@ $defs: p.$defs,

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)),
// 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);

@@ -300,18 +300,18 @@ };

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)),
// 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);

@@ -328,23 +328,12 @@ };

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),
// 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);
};
const coverFormat = (
x: Required<IChatGptSchema.IString>["format"],
y: Required<IChatGptSchema.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");
const flatSchema = (

@@ -351,0 +340,0 @@ $defs: Record<string, IChatGptSchema> | undefined,

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

properties.some(
([k, v]) => v === undefined && object.required.includes(k) === true,
([k, v]) => v === undefined && object.required?.includes(k) === true,
) === true

@@ -304,5 +304,6 @@ )

additionalProperties: additionalProperties ?? false,
required: object.required.filter((k) =>
properties.some(([key, value]) => key === k && value !== undefined),
),
required:
object.required?.filter((k) =>
properties.some(([key, value]) => key === k && value !== undefined),
) ?? [],
};

@@ -560,4 +561,4 @@ } else if (isTuple(props.schema)) {

else if (
p.x.required.includes(key) === true &&
p.y.required.includes(key) === false
p.x.required?.includes(key) === true &&
(p.y.required?.includes(key) ?? false) === false
)

@@ -564,0 +565,0 @@ return false;

@@ -1,2 +0,1 @@

import { OpenApi } from "../OpenApi";
import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1";

@@ -76,8 +75,8 @@ import { OpenApiTypeCheckerBase } from "./internal/OpenApiTypeCheckerBase";

----------------------------------------------------------- */
export const escape = (props: {
export const covers = (props: {
$defs?: Record<string, ILlmSchemaV3_1>;
schema: ILlmSchemaV3_1;
recursive: false | number;
}): ILlmSchemaV3_1 | null =>
OpenApiTypeCheckerBase.escape({
x: ILlmSchemaV3_1;
y: ILlmSchemaV3_1;
}): boolean =>
OpenApiTypeCheckerBase.covers({
prefix: "#/$defs/",

@@ -87,5 +86,5 @@ components: {

},
schema: props.schema,
recursive: props.recursive,
}) as ILlmSchemaV3_1 | null;
x: props.x,
y: props.y,
});

@@ -99,22 +98,8 @@ export const visit = (props: {

prefix: "#/$defs/",
closure: props.closure as (schema: OpenApi.IJsonSchema) => void,
components: {
schemas: props.$defs,
},
closure: props.closure as any,
schema: props.schema,
});
export const covers = (props: {
$defs?: Record<string, ILlmSchemaV3_1>;
x: ILlmSchemaV3_1;
y: ILlmSchemaV3_1;
}): boolean =>
OpenApiTypeCheckerBase.covers({
prefix: "#/$defs/",
components: {
schemas: props.$defs,
},
x: props.x,
y: props.y,
});
}

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

| "multipleOf"
| "default"
>,

@@ -52,2 +53,3 @@ >(

| "multipleOf"
| "default"
> => {

@@ -75,2 +77,6 @@ const tags: string[] = [];

}
if (v.default !== undefined) {
tags.push(`@default ${v.default}`);
delete v.default;
}
v.description = writeTagWithDescription({

@@ -92,2 +98,3 @@ description: v.description,

| "contentMediaType"
| "default"
>,

@@ -98,3 +105,8 @@ >(

Schema,
"minLength" | "maxLength" | "format" | "pattern" | "contentMediaType"
| "minLength"
| "maxLength"
| "format"
| "pattern"
| "contentMediaType"
| "default"
> => {

@@ -122,2 +134,6 @@ const tags: string[] = [];

}
if (v.default !== undefined) {
tags.push(`@default ${v.default}`);
delete v.default;
}
v.description = writeTagWithDescription({

@@ -124,0 +140,0 @@ description: v.description,

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