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
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.20241122-3 to 2.0.0-dev.20241123-2

46

lib/converters/ChatGptConverter.js

@@ -143,16 +143,5 @@ "use strict";

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

@@ -306,27 +295,7 @@ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(input)) {

}
if (typeof props.schema.additionalProperties === "object" &&
props.schema.additionalProperties !== null) {
var _g = __read(ChatGptConverter.separate({
$defs: props.$defs,
predicate: props.predicate,
schema: props.schema.additionalProperties,
}), 2), x = _g[0], y = _g[1];
if (x !== null)
llm.additionalProperties = x;
if (y !== null)
human.additionalProperties = y;
}
else {
llm.additionalProperties = false;
human.additionalProperties = false;
}
llm.additionalProperties = false;
human.additionalProperties = false;
return [
Object.keys(llm.properties).length === 0 &&
llm.additionalProperties === false
? null
: shrinkRequired(llm),
Object.keys(human.properties).length === 0 &&
human.additionalProperties === false
? null
: shrinkRequired(human),
Object.keys(llm.properties).length === 0 ? null : shrinkRequired(llm),
Object.keys(human.properties).length === 0 ? null : shrinkRequired(human),
];

@@ -372,6 +341,5 @@ };

var shrinkRequired = function (s) {
if (s.required !== undefined)
s.required = s.required.filter(function (key) { var _a; return ((_a = s.properties) === null || _a === void 0 ? void 0 : _a[key]) !== undefined; });
s.required = s.required.filter(function (key) { var _a; return ((_a = s.properties) === null || _a === void 0 ? void 0 : _a[key]) !== undefined; });
return s;
};
})(ChatGptConverter || (exports.ChatGptConverter = ChatGptConverter = {}));

2

lib/converters/GeminiConverter.js

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

else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isObject(v)) {
if (v.properties !== undefined)
if (v.additionalProperties !== undefined)
delete v.additionalProperties;

@@ -37,0 +37,0 @@ }

@@ -59,9 +59,17 @@ "use strict";

var downgraded = OpenApiV3Downgrader_1.OpenApiV3Downgrader.downgradeSchema({
original: {},
original: {
schemas: {},
},
downgraded: {},
})(resolved);
LlmTypeCheckerV3_1.LlmTypeCheckerV3.visit(downgraded, function (schema) {
var _a, _b;
if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isOneOf(schema) &&
schema.discriminator !== undefined)
delete schema.discriminator;
else if (LlmTypeCheckerV3_1.LlmTypeCheckerV3.isObject(schema)) {
(_a = schema.properties) !== null && _a !== void 0 ? _a : (schema.properties = {});
(_b = schema.required) !== null && _b !== void 0 ? _b : (schema.required = []);
schema.additionalProperties = false;
}
});

@@ -134,6 +142,5 @@ return downgraded;

var shrinkRequired = function (s) {
if (s.required !== undefined)
s.required = s.required.filter(function (key) { var _a; return ((_a = s.properties) === null || _a === void 0 ? void 0 : _a[key]) !== undefined; });
s.required = s.required.filter(function (key) { return s.properties[key] !== undefined; });
return s;
};
})(LlmConverterV3 || (exports.LlmConverterV3 = LlmConverterV3 = {}));

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

})), false), __read((dto ? Object.entries((_c = dto.properties) !== null && _c !== void 0 ? _c : {}) : [])), false)),
required: __spreadArray(__spreadArray([], __read(primitives.filter(function (p) { return p.required; }).map(function (p) { return p.name; })), false), __read((dto ? ((_d = dto.required) !== null && _d !== void 0 ? _d : []) : [])), false),
required: __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(primitives.filter(function (p) { return p.required; }).map(function (p) { return p.name; })), false), __read(((_d = dto === null || dto === void 0 ? void 0 : dto.required) !== null && _d !== void 0 ? _d : [])), false))), false),
},

@@ -166,3 +166,3 @@ ], false);

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

@@ -169,0 +169,0 @@ }),

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

var _a;
if (input["x-samchon-emended"] === true)
if (input["x-samchon-emend-version"] === "2.0")
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-emended": true });
: undefined, "x-samchon-emend-version": "2.0" });
};

@@ -264,5 +264,6 @@ /* -----------------------------------------------------------

----------------------------------------------------------- */
var convertComponents = function (input) { return ({
schemas: input.schemas
? Object.fromEntries(Object.entries(input.schemas)
var convertComponents = function (input) {
var _a;
return ({
schemas: Object.fromEntries(Object.entries((_a = input.schemas) !== null && _a !== void 0 ? _a : {})
.filter(function (_a) {

@@ -275,6 +276,6 @@ var _b = __read(_a, 2), _ = _b[0], v = _b[1];

return [key, convertSchema(input)(value)];
}))
: undefined,
securitySchemes: input.securitySchemes,
}); };
})),
securitySchemes: input.securitySchemes,
});
};
var convertSchema = function (components) {

@@ -293,3 +294,3 @@ return function (input) {

var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
// NULLABLE PROPERTY

@@ -358,4 +359,4 @@ if (schema.nullable ===

try {
for (var _q = __values(schema.type), _r = _q.next(); !_r.done; _r = _q.next()) {
var type = _r.value;
for (var _r = __values(schema.type), _s = _r.next(); !_s.done; _s = _r.next()) {
var type = _s.value;
_loop_1(type);

@@ -367,3 +368,3 @@ }

try {
if (_r && !_r.done && (_a = _q.return)) _a.call(_q);
if (_s && !_s.done && (_a = _r.return)) _a.call(_r);
}

@@ -385,4 +386,4 @@ finally { if (e_1) throw e_1.error; }

try {
for (var _s = __values(schema.enum.filter(function (e) { return e !== null; })), _t = _s.next(); !_t.done; _t = _s.next()) {
var value = _t.value;
for (var _t = __values(schema.enum.filter(function (e) { return e !== null; })), _u = _t.next(); !_u.done; _u = _t.next()) {
var value = _u.value;
union.push(__assign({ const: value }, __assign(__assign({}, schema), { type: undefined, enum: undefined, default: undefined })));

@@ -394,3 +395,3 @@ }

try {
if (_t && !_t.done && (_b = _s.return)) _b.call(_s);
if (_u && !_u.done && (_b = _t.return)) _b.call(_t);
}

@@ -406,4 +407,4 @@ finally { if (e_2) throw e_2.error; }

try {
for (var _u = __values(schema.enum.filter(function (e) { return e !== null; })), _v = _u.next(); !_v.done; _v = _u.next()) {
var value = _v.value;
for (var _v = __values(schema.enum.filter(function (e) { return e !== null; })), _w = _v.next(); !_w.done; _w = _v.next()) {
var value = _w.value;
union.push(__assign({ const: value }, __assign(__assign({}, schema), { type: undefined, enum: undefined, default: undefined, minimum: undefined, maximum: undefined, exclusiveMinimum: undefined, exclusiveMaximum: undefined, multipleOf: undefined })));

@@ -415,3 +416,3 @@ }

try {
if (_v && !_v.done && (_c = _u.return)) _c.call(_u);
if (_w && !_w.done && (_c = _v.return)) _c.call(_v);
}

@@ -442,4 +443,4 @@ finally { if (e_3) throw e_3.error; }

try {
for (var _w = __values(schema.enum.filter(function (e) { return e !== null; })), _x = _w.next(); !_x.done; _x = _w.next()) {
var value = _x.value;
for (var _x = __values(schema.enum.filter(function (e) { return e !== null; })), _y = _x.next(); !_y.done; _y = _x.next()) {
var value = _y.value;
union.push(__assign({ const: value }, __assign(__assign({}, schema), { type: undefined, enum: undefined, default: undefined })));

@@ -451,3 +452,3 @@ }

try {
if (_x && !_x.done && (_d = _w.return)) _d.call(_w);
if (_y && !_y.done && (_d = _x.return)) _d.call(_x);
}

@@ -512,2 +513,3 @@ finally { if (e_4) throw e_4.error; }

: undefined,
required: (_q = schema.required) !== null && _q !== void 0 ? _q : [],
}));

@@ -551,2 +553,3 @@ else if (TypeChecker.isRecursiveReference(schema))

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

@@ -553,0 +556,0 @@ };

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

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

@@ -239,5 +239,6 @@ /* -----------------------------------------------------------

----------------------------------------------------------- */
OpenApiV3Converter.convertComponents = function (input) { return ({
schemas: input.schemas
? Object.fromEntries(Object.entries(input.schemas)
OpenApiV3Converter.convertComponents = function (input) {
var _a;
return ({
schemas: Object.fromEntries(Object.entries((_a = input.schemas) !== null && _a !== void 0 ? _a : {})
.filter(function (_a) {

@@ -250,6 +251,6 @@ var _b = __read(_a, 2), _ = _b[0], v = _b[1];

return [key, OpenApiV3Converter.convertSchema(input)(value)];
}))
: undefined,
securitySchemes: input.securitySchemes,
}); };
})),
securitySchemes: input.securitySchemes,
});
};
OpenApiV3Converter.convertSchema = function (components) {

@@ -268,3 +269,3 @@ return function (input) {

var visit = function (schema) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
// NULLABLE PROPERTY

@@ -325,2 +326,3 @@ if (schema.nullable ===

: undefined,
required: (_e = schema.required) !== null && _e !== void 0 ? _e : [],
}));

@@ -384,2 +386,3 @@ else if (TypeChecker.isReference(schema))

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

@@ -386,0 +389,0 @@ };

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

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

@@ -204,5 +204,6 @@ /* -----------------------------------------------------------

----------------------------------------------------------- */
var convertComponents = function (input) { return ({
schemas: input.definitions
? Object.fromEntries(Object.entries(input.definitions)
var convertComponents = function (input) {
var _a;
return ({
schemas: Object.fromEntries(Object.entries((_a = input.definitions) !== null && _a !== void 0 ? _a : {})
.filter(function (_a) {

@@ -215,20 +216,20 @@ var _b = __read(_a, 2), _ = _b[0], v = _b[1];

return [key, SwaggerV2Converter.convertSchema(value)];
}))
: undefined,
securitySchemes: input.securityDefinitions
? Object.fromEntries(Object.entries(input.securityDefinitions)
.filter(function (_a) {
var _b = __read(_a, 2), _ = _b[0], v = _b[1];
return v !== undefined;
})
.map(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
return [key, convertSecurityScheme(value)];
})
.filter(function (_a) {
var _b = __read(_a, 2), _ = _b[0], v = _b[1];
return v !== undefined;
}))
: undefined,
}); };
})),
securitySchemes: input.securityDefinitions
? Object.fromEntries(Object.entries(input.securityDefinitions)
.filter(function (_a) {
var _b = __read(_a, 2), _ = _b[0], v = _b[1];
return v !== undefined;
})
.map(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
return [key, convertSecurityScheme(value)];
})
.filter(function (_a) {
var _b = __read(_a, 2), _ = _b[0], v = _b[1];
return v !== undefined;
}))
: undefined,
});
};
var convertSecurityScheme = function (input) {

@@ -307,3 +308,3 @@ if (input.type === "apiKey")

var visit = function (schema) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
// NULLABLE PROPERTY

@@ -364,3 +365,3 @@ if (schema["x-nullable"] ===

? Object.fromEntries(schema.examples.map(function (v, i) { return [i.toString(), v]; }))
: undefined }));
: undefined, required: (_e = schema.required) !== null && _e !== void 0 ? _e : [] }));
else if (TypeChecker.isReference(schema))

@@ -367,0 +368,0 @@ union.push(__assign(__assign({}, schema), { $ref: schema.$ref.replace("#/definitions/", "#/components/schemas/"), examples: schema.examples

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

// MIGRATE
var migrate = props.document["x-samchon-emended"] === true
var migrate = props.document["x-samchon-emend-version"] === "2.0"
? HttpMigration_1.HttpMigration.application(props.document)

@@ -66,0 +66,0 @@ : props.document;

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

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

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

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

@@ -791,0 +791,0 @@ /**

@@ -68,3 +68,3 @@ /**

*/
interface IParameters extends Omit<IObject, "additionalProperties"> {
interface IParameters extends IObject {
/**

@@ -74,6 +74,2 @@ * Collection of the named types.

$defs?: Record<string, IChatGptSchema>;
/**
* Do not allow additional properties in the parameters.
*/
additionalProperties: false;
}

@@ -282,11 +278,6 @@ /**

*
* 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>`
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
*/
additionalProperties?: boolean | IChatGptSchema;
additionalProperties: false;
/**

@@ -325,3 +316,3 @@ * List of key values of the required properties.

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

@@ -328,0 +319,0 @@ /**

@@ -180,3 +180,3 @@ /**

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

@@ -183,0 +183,0 @@ /**

@@ -302,3 +302,3 @@ export type ILlmSchemaV3_1 = ILlmSchemaV3_1.IBoolean | ILlmSchemaV3_1.IInteger | ILlmSchemaV3_1.INumber | ILlmSchemaV3_1.IString | ILlmSchemaV3_1.IArray | ILlmSchemaV3_1.ITuple | ILlmSchemaV3_1.IObject | ILlmSchemaV3_1.IOneOf | ILlmSchemaV3_1.INull | ILlmSchemaV3_1.IUnknown;

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

@@ -305,0 +305,0 @@ /**

@@ -262,3 +262,3 @@ /**

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

@@ -270,11 +270,6 @@ * Additional properties' info.

*
* 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>`
* - `ILlmSchemaV3`: `Record<string, T>`
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
*/
additionalProperties?: boolean | Schema;
additionalProperties: false;
}

@@ -281,0 +276,0 @@ /**

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

var e_1, _a;
var _b, _c;
var _b;
props.closure(schema);

@@ -89,6 +89,6 @@ if (ChatGptTypeChecker.isReference(schema)) {

schema.anyOf.forEach(next);
else if (ChatGptTypeChecker.isObject(schema)) {
else if (ChatGptTypeChecker.isObject(schema))
try {
for (var _d = __values(Object.values((_c = schema.properties) !== null && _c !== void 0 ? _c : {})), _e = _d.next(); !_e.done; _e = _d.next()) {
var value = _e.value;
for (var _c = __values(Object.values(schema.properties)), _d = _c.next(); !_d.done; _d = _c.next()) {
var value = _d.value;
next(value);

@@ -100,10 +100,6 @@ }

try {
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_1) throw e_1.error; }
}
if (typeof schema.additionalProperties === "object" &&
schema.additionalProperties !== null)
next(schema.additionalProperties);
}
else if (ChatGptTypeChecker.isArray(schema))

@@ -110,0 +106,0 @@ next(schema.items);

@@ -59,10 +59,9 @@ "use strict";

var e_1, _a;
var _b;
callback(schema);
if (LlmTypeCheckerV3.isOneOf(schema))
schema.oneOf.forEach(function (s) { return LlmTypeCheckerV3.visit(s, callback); });
else if (LlmTypeCheckerV3.isObject(schema)) {
else if (LlmTypeCheckerV3.isObject(schema))
try {
for (var _c = __values(Object.entries((_b = schema.properties) !== null && _b !== void 0 ? _b : {})), _d = _c.next(); !_d.done; _d = _c.next()) {
var _e = __read(_d.value, 2), _ = _e[0], s = _e[1];
for (var _b = __values(Object.entries(schema.properties)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), _ = _d[0], s = _d[1];
LlmTypeCheckerV3.visit(s, callback);

@@ -74,10 +73,6 @@ }

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; }
}
if (typeof schema.additionalProperties === "object" &&
schema.additionalProperties !== null)
LlmTypeCheckerV3.visit(schema.additionalProperties, callback);
}
else if (LlmTypeCheckerV3.isArray(schema))

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

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

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

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

else if (properties_1.some(function (_a) {
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;
var _b = __read(_a, 2), k = _b[0], v = _b[1];
return v === undefined && object_1.required.includes(k) === true;
}) === true)

@@ -284,3 +283,3 @@ return undefined;

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

@@ -464,9 +463,9 @@ var _b = __read(_a, 2), key = _b[0], value = _b[1];

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

@@ -473,0 +472,0 @@ return coverStation({

{
"name": "@samchon/openapi",
"version": "2.0.0-dev.20241122-3",
"version": "2.0.0-dev.20241123-2",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",

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

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

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

@@ -329,26 +317,7 @@ });

}
if (
typeof props.schema.additionalProperties === "object" &&
props.schema.additionalProperties !== null
) {
const [x, y] = separate({
$defs: props.$defs,
predicate: props.predicate,
schema: props.schema.additionalProperties,
});
if (x !== null) llm.additionalProperties = x;
if (y !== null) human.additionalProperties = y;
} else {
llm.additionalProperties = false;
human.additionalProperties = false;
}
llm.additionalProperties = false;
human.additionalProperties = false;
return [
Object.keys(llm.properties).length === 0 &&
llm.additionalProperties === false
? null
: shrinkRequired(llm),
Object.keys(human.properties).length === 0 &&
human.additionalProperties === false
? null
: shrinkRequired(human),
Object.keys(llm.properties).length === 0 ? null : shrinkRequired(llm),
Object.keys(human.properties).length === 0 ? null : shrinkRequired(human),
];

@@ -417,8 +386,5 @@ };

): IChatGptSchema.IObject => {
if (s.required !== undefined)
s.required = s.required.filter(
(key) => s.properties?.[key] !== undefined,
);
s.required = s.required.filter((key) => s.properties?.[key] !== undefined);
return s;
};
}

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

else if (LlmTypeCheckerV3.isObject(v)) {
if (v.properties !== undefined) delete v.additionalProperties;
if (v.additionalProperties !== undefined)
delete (v as Partial<ILlmSchemaV3.IObject>).additionalProperties;
} else if (LlmTypeCheckerV3.isArray(v))

@@ -56,3 +57,8 @@ OpenApiContraintShifter.shiftArray(v);

}): [IGeminiSchema | null, IGeminiSchema | null] =>
LlmConverterV3.separate(props);
LlmConverterV3.separate(
props as {
predicate: (schema: ILlmSchemaV3) => boolean;
schema: ILlmSchemaV3;
},
);
}

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

const downgraded: ILlmSchemaV3 = OpenApiV3Downgrader.downgradeSchema({
original: {},
original: {
schemas: {},
},
downgraded: {},

@@ -37,2 +39,7 @@ })(resolved) as ILlmSchemaV3;

delete (schema as any).discriminator;
else if (LlmTypeCheckerV3.isObject(schema)) {
schema.properties ??= {};
schema.required ??= [];
schema.additionalProperties = false;
}
});

@@ -121,8 +128,5 @@ return downgraded;

const shrinkRequired = (s: ILlmSchemaV3.IObject): ILlmSchemaV3.IObject => {
if (s.required !== undefined)
s.required = s.required.filter(
(key) => s.properties?.[key] !== undefined,
);
s.required = s.required.filter((key) => s.properties[key] !== undefined);
return s;
};
}

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

required: [
...primitives.filter((p) => p.required).map((p) => p.name!),
...(dto ? (dto.required ?? []) : []),
...new Set([
...primitives.filter((p) => p.required).map((p) => p.name!),
...(dto?.required ?? []),
]),
],

@@ -177,5 +179,3 @@ },

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

@@ -182,0 +182,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-emended"] === true)
if ((input as OpenApi.IDocument)["x-samchon-emend-version"] === "2.0")
return input as OpenApi.IDocument;

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

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

@@ -264,9 +264,7 @@ };

): OpenApi.IComponents => ({
schemas: input.schemas
? Object.fromEntries(
Object.entries(input.schemas)
.filter(([_, v]) => v !== undefined)
.map(([key, value]) => [key, convertSchema(input)(value)] as const),
)
: undefined,
schemas: Object.fromEntries(
Object.entries(input.schemas ?? {})
.filter(([_, v]) => v !== undefined)
.map(([key, value]) => [key, convertSchema(input)(value)] as const),
),
securitySchemes: input.securitySchemes,

@@ -545,2 +543,3 @@ });

: undefined,
required: schema.required ?? [],
},

@@ -606,2 +605,3 @@ });

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

@@ -608,0 +608,0 @@ };

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

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

@@ -236,9 +236,7 @@

): OpenApi.IComponents => ({
schemas: input.schemas
? Object.fromEntries(
Object.entries(input.schemas)
.filter(([_, v]) => v !== undefined)
.map(([key, value]) => [key, convertSchema(input)(value)]),
)
: undefined,
schemas: Object.fromEntries(
Object.entries(input.schemas ?? {})
.filter(([_, v]) => v !== undefined)
.map(([key, value]) => [key, convertSchema(input)(value)]),
),
securitySchemes: input.securitySchemes,

@@ -341,2 +339,3 @@ });

: undefined,
required: schema.required ?? [],
},

@@ -410,2 +409,3 @@ });

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

@@ -412,0 +412,0 @@ };

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

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

@@ -179,9 +179,7 @@

): OpenApi.IComponents => ({
schemas: input.definitions
? Object.fromEntries(
Object.entries(input.definitions)
.filter(([_, v]) => v !== undefined)
.map(([key, value]) => [key, convertSchema(value)]),
)
: undefined,
schemas: Object.fromEntries(
Object.entries(input.definitions ?? {})
.filter(([_, v]) => v !== undefined)
.map(([key, value]) => [key, convertSchema(value)]),
),
securitySchemes: input.securityDefinitions

@@ -359,2 +357,3 @@ ? Object.fromEntries(

: undefined,
required: schema.required ?? [],
});

@@ -361,0 +360,0 @@ else if (TypeChecker.isReference(schema))

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

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

@@ -93,0 +93,0 @@ : (props.document as IHttpMigrateApplication);

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

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

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

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

@@ -1003,0 +1003,0 @@

@@ -78,3 +78,3 @@ /**

*/
export interface IParameters extends Omit<IObject, "additionalProperties"> {
export interface IParameters extends IObject {
/**

@@ -84,7 +84,2 @@ * Collection of the named types.

$defs?: Record<string, IChatGptSchema>;
/**
* Do not allow additional properties in the parameters.
*/
additionalProperties: false;
}

@@ -346,11 +341,6 @@

*
* 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>`
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
*/
additionalProperties?: boolean | IChatGptSchema;
additionalProperties: false;

@@ -390,3 +380,3 @@ /**

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

@@ -393,0 +383,0 @@

@@ -198,3 +198,3 @@ /**

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

@@ -201,0 +201,0 @@

@@ -368,3 +368,3 @@ export type ILlmSchemaV3_1 =

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

@@ -371,0 +371,0 @@

@@ -326,3 +326,3 @@ /**

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

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

*
* 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>`
* - `ILlmSchemaV3`: `Record<string, T>`
* By the way, as LLM function calling does not support such dynamic key
* typed properties, the `additionalProperties` becomes always `false`.
*/
additionalProperties?: boolean | Schema;
additionalProperties: false;
}

@@ -346,0 +341,0 @@

@@ -71,10 +71,5 @@ import { IChatGptSchema } from "../structures/IChatGptSchema";

} else if (ChatGptTypeChecker.isAnyOf(schema)) schema.anyOf.forEach(next);
else if (ChatGptTypeChecker.isObject(schema)) {
for (const value of Object.values(schema.properties ?? {})) next(value);
if (
typeof schema.additionalProperties === "object" &&
schema.additionalProperties !== null
)
next(schema.additionalProperties);
} else if (ChatGptTypeChecker.isArray(schema)) next(schema.items);
else if (ChatGptTypeChecker.isObject(schema))
for (const value of Object.values(schema.properties)) next(value);
else if (ChatGptTypeChecker.isArray(schema)) next(schema.items);
};

@@ -81,0 +76,0 @@ next(props.schema);

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

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

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

@@ -264,3 +264,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

@@ -277,3 +277,3 @@ )

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

@@ -510,4 +510,4 @@ ),

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

@@ -514,0 +514,0 @@ return false;

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