@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.
@@ -1,5 +1,5 @@
1
- import { type ObjectType, type SchemaObject, type ValuesSchemaProps } from '../../types';
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 }?: ValuesSchemaProps<TypeMap<T>> | undefined): SchemaObject | undefined;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-beta.20",
3
+ "version": "2.0.0-beta.22",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",
@@ -1,5 +1,5 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
- import { type BaseSchemaProps } from '../../../types';
3
- export interface AnyProps extends BaseSchemaProps<any> {
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 BaseSchemaProps } from '../../../types';
3
- export interface ArrayProps extends BaseSchemaProps<any[]> {
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 BaseSchemaProps } from '../../../types';
3
- export interface BooleanProps extends BaseSchemaProps<boolean> {
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 ValuesSchemaProps } from '../../../types';
2
+ import { type SchemaProps } from '../../../types';
3
3
  import { type DateFormat } from '../../../utils';
4
- export interface DateProps extends Omit<ValuesSchemaProps<DateFormat>, 'value'> {
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 ValuesSchemaProps } from '../../../types';
3
- export interface IntegerProps extends ValuesSchemaProps<bigint | number> {
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 BaseSchemaProps } from '../../../types';
3
- export interface NullProps extends BaseSchemaProps<null> {
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 ValuesSchemaProps } from '../../../types';
3
- export interface NumberProps extends ValuesSchemaProps<number> {
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 BaseSchemaProps } from '../../../types';
3
- export interface ObjectProps extends BaseSchemaProps<object> {
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 ValuesSchemaProps } from '../../../types';
3
- export interface StringProps extends ValuesSchemaProps<string> {
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 BaseSchemaProps } from '../../../types';
3
- export interface TupleProps extends BaseSchemaProps<any[]> {
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 ValuesSchemaProps } from '../../../types';
3
- export interface UuidProps extends ValuesSchemaProps<string> {
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 interface BaseSchemaProps<T> {
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 {