@innet/server 2.0.0-beta.20 → 2.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hooks/useSchemaType/useSchemaType.d.ts +2 -2
- package/package.json +1 -1
- package/plugins/schema/any/any.d.ts +2 -2
- package/plugins/schema/array/array.d.ts +2 -2
- package/plugins/schema/boolean/boolean.d.ts +2 -2
- package/plugins/schema/date/date.d.ts +2 -3
- package/plugins/schema/date/date.es6.js +2 -1
- package/plugins/schema/date/date.js +2 -1
- package/plugins/schema/integer/integer.d.ts +2 -2
- package/plugins/schema/null/null.d.ts +2 -2
- package/plugins/schema/number/number.d.ts +2 -2
- package/plugins/schema/object/object.d.ts +2 -2
- package/plugins/schema/string/string.d.ts +2 -2
- package/plugins/schema/tuple/tuple.d.ts +2 -2
- package/plugins/schema/uuid/uuid.d.ts +2 -2
- package/types.d.ts +3 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ObjectType, type SchemaObject, type
|
|
1
|
+
import { type ObjectType, type SchemaObject, type SchemaProps } from '../../types';
|
|
2
2
|
export type SchemaType = 'any' | ObjectType;
|
|
3
3
|
type TypeMap<T extends SchemaType> = T extends 'integer' | 'number' ? number : T extends 'string' ? string : T extends 'object' ? object : T extends 'array' ? any[] : T extends 'boolean' ? boolean : T extends 'null' ? null : T extends 'any' ? any : unknown;
|
|
4
|
-
export declare function useSchemaType<T extends SchemaType>(type: T, { example, examples, nullable, ref, value, values, ...options }?:
|
|
4
|
+
export declare function useSchemaType<T extends SchemaType>(type: T, { example, examples, nullable, ref, value, values, ...options }?: SchemaProps<TypeMap<T>> | undefined): SchemaObject | undefined;
|
|
5
5
|
export {};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface AnyProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface AnyProps extends SchemaProps<any> {
|
|
4
4
|
}
|
|
5
5
|
export declare const any: HandlerPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface ArrayProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface ArrayProps extends SchemaProps<any[]> {
|
|
4
4
|
children?: any;
|
|
5
5
|
maxItems?: number;
|
|
6
6
|
minItems?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface BooleanProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface BooleanProps extends SchemaProps<boolean> {
|
|
4
4
|
const?: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare const boolean: HandlerPlugin;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
3
|
import { type DateFormat } from '../../../utils';
|
|
4
|
-
export interface DateProps extends
|
|
5
|
-
const?: string;
|
|
4
|
+
export interface DateProps extends SchemaProps<DateFormat> {
|
|
6
5
|
max?: DateFormat;
|
|
7
6
|
min?: DateFormat;
|
|
8
7
|
}
|
|
@@ -15,7 +15,7 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
15
15
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
16
16
|
|
|
17
17
|
const date = () => {
|
|
18
|
-
const { default: defaultValue, example, examples, max, min, values: values$1, ...props } = useProps() || {};
|
|
18
|
+
const { default: defaultValue, example, examples, max, min, value, values: values$1, ...props } = useProps() || {};
|
|
19
19
|
const normMin = dateFormat(min);
|
|
20
20
|
const normMax = dateFormat(max);
|
|
21
21
|
const normDefault = dateFormat(defaultValue);
|
|
@@ -28,6 +28,7 @@ const date = () => {
|
|
|
28
28
|
...props,
|
|
29
29
|
default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(),
|
|
30
30
|
example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
|
|
31
|
+
value: value instanceof Date ? value.toISOString() : typeof value === 'number' ? new Date(value).toISOString() : value,
|
|
31
32
|
// @ts-expect-error: FIXME
|
|
32
33
|
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
33
34
|
values: stringValues,
|
|
@@ -19,7 +19,7 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
19
19
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
20
20
|
|
|
21
21
|
const date = () => {
|
|
22
|
-
const { default: defaultValue, example, examples, max, min, values: values$1, ...props } = jsx.useProps() || {};
|
|
22
|
+
const { default: defaultValue, example, examples, max, min, value, values: values$1, ...props } = jsx.useProps() || {};
|
|
23
23
|
const normMin = dateFormat.dateFormat(min);
|
|
24
24
|
const normMax = dateFormat.dateFormat(max);
|
|
25
25
|
const normDefault = dateFormat.dateFormat(defaultValue);
|
|
@@ -32,6 +32,7 @@ const date = () => {
|
|
|
32
32
|
...props,
|
|
33
33
|
default: defaultValue === 'now' ? undefined : normDefault === null || normDefault === void 0 ? void 0 : normDefault.toISOString(),
|
|
34
34
|
example: normExample === null || normExample === void 0 ? void 0 : normExample.toISOString(),
|
|
35
|
+
value: value instanceof Date ? value.toISOString() : typeof value === 'number' ? new Date(value).toISOString() : value,
|
|
35
36
|
// @ts-expect-error: FIXME
|
|
36
37
|
examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
|
|
37
38
|
values: stringValues,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type IntegerFormats, type
|
|
3
|
-
export interface IntegerProps extends
|
|
2
|
+
import { type IntegerFormats, type SchemaProps } from '../../../types';
|
|
3
|
+
export interface IntegerProps extends SchemaProps<bigint | number> {
|
|
4
4
|
/**
|
|
5
5
|
* The `exclusiveMaximum` keyword is used to restrict the value to be less than the specified number.
|
|
6
6
|
* @example For example, the following value is valid:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface NullProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface NullProps extends SchemaProps<null> {
|
|
4
4
|
}
|
|
5
5
|
export declare const nullPlugin: HandlerPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface NumberProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface NumberProps extends SchemaProps<number> {
|
|
4
4
|
/**
|
|
5
5
|
* The `exclusiveMaximum` keyword is used to restrict the value to be less than the specified number.
|
|
6
6
|
* @example For example, the following value is valid:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface ObjectProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface ObjectProps extends SchemaProps<object> {
|
|
4
4
|
children?: any;
|
|
5
5
|
}
|
|
6
6
|
export declare const object: HandlerPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface StringProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface StringProps extends SchemaProps<string> {
|
|
4
4
|
/**
|
|
5
5
|
* An optional format modifier serves as a hint at the contents and format of the string.
|
|
6
6
|
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface TupleProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface TupleProps extends SchemaProps<any[]> {
|
|
4
4
|
children?: any;
|
|
5
5
|
}
|
|
6
6
|
export declare const tuple: HandlerPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
|
-
import { type
|
|
3
|
-
export interface UuidProps extends
|
|
2
|
+
import { type SchemaProps } from '../../../types';
|
|
3
|
+
export interface UuidProps extends SchemaProps<string> {
|
|
4
4
|
default?: 'new' | string;
|
|
5
5
|
}
|
|
6
6
|
export declare const uuid: HandlerPlugin;
|
package/types.d.ts
CHANGED
|
@@ -58,7 +58,8 @@ export interface ServerStartParams {
|
|
|
58
58
|
https: boolean;
|
|
59
59
|
port: number;
|
|
60
60
|
}
|
|
61
|
-
export
|
|
61
|
+
export type SchemaValues<T> = (T extends (number | string) ? Record<T, string> : never) | T[];
|
|
62
|
+
export interface SchemaProps<T> {
|
|
62
63
|
default?: T;
|
|
63
64
|
deprecated?: boolean;
|
|
64
65
|
description?: string;
|
|
@@ -68,12 +69,9 @@ export interface BaseSchemaProps<T> {
|
|
|
68
69
|
readOnly?: boolean;
|
|
69
70
|
ref?: string;
|
|
70
71
|
title?: string;
|
|
71
|
-
writeOnly?: boolean;
|
|
72
|
-
}
|
|
73
|
-
export type SchemaValues<T> = (T extends (number | string) ? Record<T, string> : never) | T[];
|
|
74
|
-
export interface ValuesSchemaProps<T> extends BaseSchemaProps<T> {
|
|
75
72
|
value?: T;
|
|
76
73
|
values?: SchemaValues<T>;
|
|
74
|
+
writeOnly?: boolean;
|
|
77
75
|
}
|
|
78
76
|
export type TResponse = Record<ResponseStatus, unknown>;
|
|
79
77
|
export interface TEndpoint {
|