Skip to content

Commit f61d0c7

Browse files
authored
exclusiveMinimum/exclusiveMaximum as number type (#1562)
* ExclusiveMinimum/Maximum type as `number` * Ready * Upgrade again
1 parent ec86821 commit f61d0c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+587
-1082
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "typia",
4-
"version": "8.2.0",
4+
"version": "9.0.0-dev.20250405-2",
55
"description": "Superfast runtime validators with only one line",
66
"main": "lib/index.js",
77
"typings": "lib/index.d.ts",
@@ -41,15 +41,15 @@
4141
},
4242
"homepage": "https://typia.io",
4343
"dependencies": {
44-
"@samchon/openapi": "^3.3.0",
44+
"@samchon/openapi": "^4.0.0-dev.20250405-3",
4545
"commander": "^10.0.0",
4646
"comment-json": "^4.2.3",
4747
"inquirer": "^8.2.5",
4848
"package-manager-detector": "^0.2.0",
4949
"randexp": "^0.5.3"
5050
},
5151
"peerDependencies": {
52-
"@samchon/openapi": ">=3.3.0 <4.0.0",
52+
"@samchon/openapi": ">=4.0.0 <5.0.0",
5353
"typescript": ">=4.8.0 <5.9.0"
5454
},
5555
"devDependencies": {

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internal/_randomInteger.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
import { OpenApi } from "@samchon/openapi";
22

3-
export const _randomInteger = (props: OpenApi.IJsonSchema.IInteger) => {
3+
export const _randomInteger = (schema: OpenApi.IJsonSchema.IInteger) => {
44
let minimum: number =
5-
props.minimum ??
6-
(props.multipleOf ?? 1) *
7-
(props.maximum === undefined ? 0 : props.maximum - 100);
8-
if (props.minimum !== undefined && props.exclusiveMinimum === true) minimum++;
5+
schema.minimum ??
6+
schema.exclusiveMinimum ??
7+
(schema.multipleOf ?? 1) *
8+
(schema.maximum === undefined && schema.exclusiveMaximum === undefined
9+
? 0
10+
: (schema.maximum ?? schema.exclusiveMaximum!) - 100);
11+
if (schema.exclusiveMinimum !== undefined) minimum++;
912
let maximum: number =
10-
props.maximum ??
11-
(props.multipleOf ?? 1) *
12-
(props.minimum === undefined ? 100 : props.minimum + 100);
13-
if (props.maximum !== undefined && props.exclusiveMaximum === true) maximum--;
13+
schema.maximum ??
14+
schema.exclusiveMaximum ??
15+
(schema.multipleOf ?? 1) *
16+
(schema.minimum === undefined && schema.exclusiveMinimum === undefined
17+
? 100
18+
: (schema.minimum ?? schema.exclusiveMinimum!) + 100);
19+
if (schema.exclusiveMaximum !== undefined) maximum--;
1420
if (minimum > maximum)
1521
throw new Error("Minimum value is greater than maximum value.");
16-
return props.multipleOf === undefined
22+
return schema.multipleOf === undefined
1723
? scalar({
1824
minimum,
1925
maximum,
2026
})
2127
: multiple({
2228
minimum,
2329
maximum,
24-
multipleOf: props.multipleOf,
30+
multipleOf: schema.multipleOf,
2531
});
2632
};
2733

src/internal/_randomNumber.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,33 @@ import { OpenApi } from "@samchon/openapi";
33
export const _randomNumber = (schema: OpenApi.IJsonSchema.INumber): number => {
44
const minimum: number =
55
schema.minimum ??
6+
schema.exclusiveMinimum ??
67
(schema.multipleOf ?? 1) *
7-
(schema.maximum === undefined ? 0 : schema.maximum - 100);
8+
(schema.maximum === undefined && schema.exclusiveMaximum === undefined
9+
? 0
10+
: (schema.maximum ?? schema.exclusiveMaximum!) - 100);
811
const maximum: number =
912
schema.maximum ??
13+
schema.exclusiveMaximum ??
1014
(schema.multipleOf ?? 1) *
11-
(schema.minimum === undefined ? 100 : schema.minimum + 100);
15+
(schema.minimum === undefined && schema.exclusiveMinimum === undefined
16+
? 100
17+
: (schema.minimum ?? schema.exclusiveMinimum!) + 100);
1218
if (minimum > maximum)
1319
throw new Error("Minimum value is greater than maximum value.");
1420
return schema.multipleOf === undefined
1521
? scalar({
1622
minimum,
1723
maximum,
18-
exclusiveMinimum: schema.exclusiveMinimum,
19-
exclusiveMaximum: schema.exclusiveMaximum,
24+
exclusiveMinimum: schema.exclusiveMinimum !== undefined,
25+
exclusiveMaximum: schema.exclusiveMaximum !== undefined,
2026
})
2127
: multiple({
2228
minimum,
2329
maximum,
2430
multipleOf: schema.multipleOf,
25-
exclusiveMinimum: schema.exclusiveMinimum,
26-
exclusiveMaximum: schema.exclusiveMaximum,
31+
exclusiveMinimum: schema.exclusiveMinimum !== undefined,
32+
exclusiveMaximum: schema.exclusiveMaximum !== undefined,
2733
});
2834
};
2935

src/json.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -63,62 +63,6 @@ export function schemas(): never {
6363
halt("schemas");
6464
}
6565

66-
/**
67-
* > You must configure the generic argument `Types`.
68-
*
69-
* JSON Schemas generator.
70-
*
71-
* Creates a JSON schema list which contains both main JSON schemas
72-
* and components. Note that, all of the named types are stored in the
73-
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
74-
*
75-
* Also, you can specify the OpenAPI version by configuring the second generic
76-
* argument `Version`. For reference, the default version is `"3.1"`, and key
77-
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
78-
*
79-
* @template Types Tuple of target types
80-
* @template Version Version of OpenAPI specification. Default is 3.1
81-
* @return JSON schema list
82-
*
83-
* @deprecated Use {@link schemas} function instead please.
84-
* This function would be changed to return {@linkk ILlmApplication} like
85-
* structure in the future version (maybe next v8 major update).
86-
* @author Jeongho Nam - https://github.com/samchon
87-
*/
88-
export function application(): never;
89-
90-
/**
91-
* JSON Schemas generator.
92-
*
93-
* Creates a JSON schema list which contains both main JSON schemas
94-
* and components. Note that, all of the named types are stored in the
95-
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
96-
*
97-
* Also, you can specify the OpenAPI version by configuring the second generic
98-
* argument `Version`. For reference, the default version is `"3.1"`, and key
99-
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
100-
*
101-
* @template Types Tuple of target types
102-
* @template Version Version of OpenAPI specification. Default is 3.1
103-
* @return JSON schema list
104-
*
105-
* @deprecated Use {@link schemas} function instead please.
106-
* This function would be changed to return {@linkk ILlmApplication} like
107-
* structure in the future version (maybe next v8 major update).
108-
* @author Jeongho Nam - https://github.com/samchon
109-
*/
110-
export function application<
111-
Types extends unknown[],
112-
Version extends "3.0" | "3.1" = "3.1",
113-
>(): IJsonSchemaCollection<Version, Types>;
114-
115-
/**
116-
* @internal
117-
*/
118-
export function application(): never {
119-
halt("application");
120-
}
121-
12266
// /**
12367
// * > You must configure the generic argument `App`.
12468
// *

src/llm.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -123,60 +123,6 @@ export function application(): never {
123123
halt("application");
124124
}
125125

126-
/**
127-
* > You must configure the generic argument `App`.
128-
*
129-
* Use {@link application} instead.
130-
*
131-
* Since the version `[email protected]`, {@link application} function has
132-
* started supporting the {@link ILlmFunction.validate} function which
133-
* has been designed for the validation feedback strategy of the LLM
134-
* function calling.
135-
*
136-
* This `applicationOfValidate` function would be eliminated in the
137-
* next major version `[email protected]`. So please use {@link application}
138-
* function instead.
139-
*
140-
* @deprecated
141-
*/
142-
export function applicationOfValidate(
143-
options?: Partial<Pick<ILlmApplication.IOptions<any>, "separate">>,
144-
): never;
145-
146-
/**
147-
* Use {@link application} instead.
148-
*
149-
* Since the version `[email protected]`, {@link application} function has
150-
* started supporting the {@link ILlmFunction.validate} function which
151-
* has been designed for the validation feedback strategy of the LLM
152-
* function calling.
153-
*
154-
* This `applicationOfValidate` function would be eliminated in the
155-
* next major version `[email protected]`. So please use {@link application}
156-
* function instead.
157-
*
158-
* @template App Target class or interface type collecting the functions to call
159-
* @template Model LLM schema model
160-
* @template Config Configuration of LLM schema composition
161-
* @param options Options for the LLM application construction
162-
* @returns Application of LLM function calling schemas
163-
* @deprecated
164-
*/
165-
export function applicationOfValidate<
166-
App extends Record<string, any>,
167-
Model extends ILlmSchema.Model,
168-
Config extends Partial<ILlmSchema.ModelConfig[Model]> = {},
169-
>(
170-
options?: Partial<Pick<ILlmApplication.IOptions<Model>, "separate">>,
171-
): ILlmApplication<Model, App>;
172-
173-
/**
174-
* @internal
175-
*/
176-
export function applicationOfValidate(): never {
177-
halt("applicationOfValidate");
178-
}
179-
180126
/**
181127
* > You must configure the generic argument `Parameters`.
182128
*

src/module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export * as tags from "./tags";
1717
export * from "./schemas/metadata/IJsDocTagInfo";
1818
export * from "./schemas/json/IJsonApplication";
1919
export * from "./schemas/json/IJsonSchemaCollection";
20-
export * from "./schemas/llm/ILlmApplicationOfValidate";
21-
export * from "./schemas/llm/ILlmFunctionOfValidate";
2220
export * from "./AssertionGuard";
2321
export * from "./IRandomGenerator";
2422
export * from "./IValidation";

src/schemas/llm/ILlmApplicationOfValidate.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/schemas/llm/ILlmFunctionOfValidate.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/tags/ExclusiveMaximum.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ export type ExclusiveMaximum<Value extends number | bigint> = TagBase<{
88
exclusive: ["exclusiveMaximum", "maximum"];
99
schema: Value extends bigint
1010
? {
11-
exclusiveMaximum: true;
12-
maximum: Numeric<Value>;
11+
exclusiveMaximum: Numeric<Value>;
1312
}
1413
: {
15-
exclusiveMaximum: true;
16-
maximum: Value;
14+
exclusiveMaximum: Value;
1715
};
1816
}>;
1917

0 commit comments

Comments
 (0)