@innet/server 2.0.0-beta.22 → 2.0.0-beta.24

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.
Files changed (42) hide show
  1. package/hooks/useData/useData.d.ts +1 -1
  2. package/hooks/useData/useData.es6.js +7 -2
  3. package/hooks/useData/useData.js +7 -2
  4. package/hooks/useSchemaType/useSchemaType.d.ts +2 -3
  5. package/index.es6.js +1 -1
  6. package/index.js +1 -1
  7. package/package.json +1 -1
  8. package/plugins/schema/any/any.d.ts +1 -2
  9. package/plugins/schema/array/array.d.ts +3 -3
  10. package/plugins/schema/boolean/boolean.d.ts +1 -3
  11. package/plugins/schema/date/date.d.ts +3 -3
  12. package/plugins/schema/date/date.es6.js +4 -3
  13. package/plugins/schema/date/date.js +4 -3
  14. package/plugins/schema/integer/integer.d.ts +2 -2
  15. package/plugins/schema/integer/integer.es6.js +2 -2
  16. package/plugins/schema/integer/integer.js +2 -2
  17. package/plugins/schema/null/null.d.ts +1 -2
  18. package/plugins/schema/number/number.d.ts +2 -2
  19. package/plugins/schema/number/number.es6.js +1 -1
  20. package/plugins/schema/number/number.js +1 -1
  21. package/plugins/schema/object/object.d.ts +3 -3
  22. package/plugins/schema/string/string.d.ts +2 -2
  23. package/plugins/schema/tuple/tuple.d.ts +3 -3
  24. package/plugins/schema/uuid/uuid.d.ts +1 -3
  25. package/plugins/schema/uuid/uuid.es6.js +6 -3
  26. package/plugins/schema/uuid/uuid.js +6 -3
  27. package/{types.d.ts → types/appTypes.d.ts} +11 -7
  28. package/types/index.d.ts +2 -0
  29. package/types/index.es6.js +2 -0
  30. package/types/index.js +5 -0
  31. package/types/isoDate.d.ts +29 -0
  32. package/types/isoDate.es6.js +1 -0
  33. package/types/isoDate.js +3 -0
  34. package/utils/dateFormat/dateFormat.d.ts +1 -1
  35. package/utils/dateFormat/dateFormat.es6.js +1 -1
  36. package/utils/dateFormat/dateFormat.js +1 -1
  37. package/utils/rules/dateTo/dateTo.d.ts +3 -1
  38. package/utils/rules/values/values.d.ts +2 -2
  39. package/utils/rules/values/values.es6.js +3 -2
  40. package/utils/rules/values/values.js +3 -2
  41. /package/{types.es6.js → types/appTypes.es6.js} +0 -0
  42. /package/{types.js → types/appTypes.js} +0 -0
@@ -2,5 +2,5 @@ import { type ApiEndpoints, type TEndpoint } from '../../types';
2
2
  type KeysWithField<F extends string> = {
3
3
  [K in keyof ApiEndpoints]: F extends keyof ApiEndpoints[K] ? K : never;
4
4
  }[keyof ApiEndpoints];
5
- export declare function useData<F extends Exclude<keyof TEndpoint, 'response'>, K extends KeysWithField<F> = KeysWithField<F>>(from: F, path?: K): ApiEndpoints[K][F];
5
+ export declare function useData<F extends Exclude<keyof TEndpoint, 'response'>, K extends KeysWithField<F> = KeysWithField<F>, T extends boolean = false>(from: F, path?: K, withThrow?: T): T extends true ? ApiEndpoints[K][F] : ApiEndpoints[K][F] | undefined;
6
6
  export {};
@@ -8,12 +8,17 @@ import { useThrow } from '../useThrow/useThrow.es6.js';
8
8
  import { useAction } from '../useAction/useAction.es6.js';
9
9
  import { paramsContext } from '../useParams/useParams.es6.js';
10
10
 
11
- function useData(from, path) {
11
+ function useData(from, path, withThrow) {
12
12
  if (path) {
13
13
  const endpoint = useEndpoint();
14
14
  const endpointKey = `${endpoint.props.method.toUpperCase()}:${endpoint.props.path}`;
15
15
  if (endpointKey !== path) {
16
- useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
16
+ if (withThrow) {
17
+ useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
18
+ }
19
+ else {
20
+ return undefined;
21
+ }
17
22
  }
18
23
  }
19
24
  const action = useAction();
@@ -12,12 +12,17 @@ var useThrow = require('../useThrow/useThrow.js');
12
12
  var useAction = require('../useAction/useAction.js');
13
13
  var useParams = require('../useParams/useParams.js');
14
14
 
15
- function useData(from, path) {
15
+ function useData(from, path, withThrow) {
16
16
  if (path) {
17
17
  const endpoint = useEndpoint.useEndpoint();
18
18
  const endpointKey = `${endpoint.props.method.toUpperCase()}:${endpoint.props.path}`;
19
19
  if (endpointKey !== path) {
20
- useThrow.useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
20
+ if (withThrow) {
21
+ useThrow.useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
22
+ }
23
+ else {
24
+ return undefined;
25
+ }
21
26
  }
22
27
  }
23
28
  const action = useAction.useAction();
@@ -1,5 +1,4 @@
1
1
  import { type ObjectType, type SchemaObject, type SchemaProps } from '../../types';
2
2
  export type SchemaType = 'any' | ObjectType;
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 }?: SchemaProps<TypeMap<T>> | undefined): SchemaObject | undefined;
5
- export {};
3
+ export type SchemaTypeMap<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 }?: SchemaProps<SchemaTypeMap<T>> | undefined): SchemaObject | undefined;
package/index.es6.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import './handler/index.es6.js';
2
2
  import './hooks/index.es6.js';
3
3
  import './plugins/index.es6.js';
4
- import './types.es6.js';
4
+ import './types/index.es6.js';
5
5
  import './utils/index.es6.js';
6
6
  export { JSXPlugins, arrayPlugins, handler as default, fnPlugins, handler, objectPlugins, promisePlugins } from './handler/handler.es6.js';
7
7
  export { actionContext, useAction } from './hooks/useAction/useAction.es6.js';
package/index.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  require('./handler/index.js');
6
6
  require('./hooks/index.js');
7
7
  require('./plugins/index.js');
8
- require('./types.js');
8
+ require('./types/index.js');
9
9
  require('./utils/index.js');
10
10
  var handler = require('./handler/handler.js');
11
11
  var useAction = require('./hooks/useAction/useAction.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-beta.22",
3
+ "version": "2.0.0-beta.24",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",
@@ -1,5 +1,4 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface AnyProps extends SchemaProps<any> {
4
- }
3
+ export type AnyProps = SchemaProps<any>;
5
4
  export declare const any: HandlerPlugin;
@@ -1,9 +1,9 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface ArrayProps extends SchemaProps<any[]> {
4
- children?: any;
3
+ export type ArrayProps = SchemaProps<any[]> & {
4
+ children?: JSX.Element;
5
5
  maxItems?: number;
6
6
  minItems?: number;
7
7
  uniqueItems?: boolean;
8
- }
8
+ };
9
9
  export declare const array: HandlerPlugin;
@@ -1,6 +1,4 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface BooleanProps extends SchemaProps<boolean> {
4
- const?: boolean;
5
- }
3
+ export type BooleanProps = SchemaProps<boolean>;
6
4
  export declare const boolean: HandlerPlugin;
@@ -1,8 +1,8 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- import { type DateFormat } from '../../../utils';
4
- export interface DateProps extends SchemaProps<DateFormat> {
3
+ import { type DateFormat, type DefaultDateFormat } from '../../../utils';
4
+ export type DateProps = SchemaProps<DateFormat, DefaultDateFormat> & {
5
5
  max?: DateFormat;
6
6
  min?: DateFormat;
7
- }
7
+ };
8
8
  export declare const date: HandlerPlugin;
@@ -20,11 +20,11 @@ const date = () => {
20
20
  const normMax = dateFormat(max);
21
21
  const normDefault = dateFormat(defaultValue);
22
22
  const normExample = dateFormat(example);
23
- const normValues = values$1 && getArrayValues(values$1, dateFormat);
23
+ const normValues = values$1 && getArrayValues(values$1).map(dateFormat);
24
24
  // @ts-expect-error: FIXME
25
25
  const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
26
26
  const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat);
27
- const schema = useSchemaType('string', {
27
+ const params = {
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(),
@@ -32,7 +32,8 @@ const date = () => {
32
32
  // @ts-expect-error: FIXME
33
33
  examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
34
34
  values: stringValues,
35
- });
35
+ };
36
+ const schema = useSchemaType('string', params);
36
37
  const rules = [];
37
38
  if (defaultValue !== undefined) {
38
39
  rules.push(defaultTo(defaultValue === 'now' ? () => new Date(Date.now()) : normDefault));
@@ -24,11 +24,11 @@ const date = () => {
24
24
  const normMax = dateFormat.dateFormat(max);
25
25
  const normDefault = dateFormat.dateFormat(defaultValue);
26
26
  const normExample = dateFormat.dateFormat(example);
27
- const normValues = values$1 && values.getArrayValues(values$1, dateFormat.dateFormat);
27
+ const normValues = values$1 && values.getArrayValues(values$1).map(dateFormat.dateFormat);
28
28
  // @ts-expect-error: FIXME
29
29
  const stringValues = normValues === null || normValues === void 0 ? void 0 : normValues.map(value => value.toISOString());
30
30
  const normExamples = examples === null || examples === void 0 ? void 0 : examples.map(dateFormat.dateFormat);
31
- const schema = useSchemaType.useSchemaType('string', {
31
+ const params = {
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(),
@@ -36,7 +36,8 @@ const date = () => {
36
36
  // @ts-expect-error: FIXME
37
37
  examples: normExamples === null || normExamples === void 0 ? void 0 : normExamples.map(example => example.toISOString()),
38
38
  values: stringValues,
39
- });
39
+ };
40
+ const schema = useSchemaType.useSchemaType('string', params);
40
41
  const rules = [];
41
42
  if (defaultValue !== undefined) {
42
43
  rules.push(defaultTo.defaultTo(defaultValue === 'now' ? () => new Date(Date.now()) : normDefault));
@@ -1,6 +1,6 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type IntegerFormats, type SchemaProps } from '../../../types';
3
- export interface IntegerProps extends SchemaProps<bigint | number> {
3
+ export type IntegerProps = 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:
@@ -41,5 +41,5 @@ export interface IntegerProps extends SchemaProps<bigint | number> {
41
41
  * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
42
42
  * */
43
43
  multipleOf?: bigint | number;
44
- }
44
+ };
45
45
  export declare const integer: HandlerPlugin;
@@ -19,7 +19,7 @@ const integer = () => {
19
19
  example: example !== undefined ? Number(example) : undefined,
20
20
  examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
21
21
  value: props.value !== undefined ? Number(props.value) : undefined,
22
- values: values$1 && getArrayValues(values$1, Number),
22
+ values: values$1 && getArrayValues(values$1).map(Number),
23
23
  });
24
24
  if (schema) {
25
25
  if (format) {
@@ -47,7 +47,7 @@ const integer = () => {
47
47
  }
48
48
  rules.push(int(format));
49
49
  if (values$1) {
50
- rules.push(values(getArrayValues(values$1, int(format))));
50
+ rules.push(values(getArrayValues(values$1).filter((v) => v !== null).map(v => int(format)(v))));
51
51
  }
52
52
  if (min$1 !== undefined) {
53
53
  rules.push(min(min$1));
@@ -23,7 +23,7 @@ const integer = () => {
23
23
  example: example !== undefined ? Number(example) : undefined,
24
24
  examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
25
25
  value: props.value !== undefined ? Number(props.value) : undefined,
26
- values: values$1 && values.getArrayValues(values$1, Number),
26
+ values: values$1 && values.getArrayValues(values$1).map(Number),
27
27
  });
28
28
  if (schema) {
29
29
  if (format) {
@@ -51,7 +51,7 @@ const integer = () => {
51
51
  }
52
52
  rules.push(int.int(format));
53
53
  if (values$1) {
54
- rules.push(values.values(values.getArrayValues(values$1, int.int(format))));
54
+ rules.push(values.values(values.getArrayValues(values$1).filter((v) => v !== null).map(v => int.int(format)(v))));
55
55
  }
56
56
  if (min$1 !== undefined) {
57
57
  rules.push(min.min(min$1));
@@ -1,5 +1,4 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface NullProps extends SchemaProps<null> {
4
- }
3
+ export type NullProps = SchemaProps<null>;
5
4
  export declare const nullPlugin: HandlerPlugin;
@@ -1,6 +1,6 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface NumberProps extends SchemaProps<number> {
3
+ export type NumberProps = 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:
@@ -37,5 +37,5 @@ export interface NumberProps extends SchemaProps<number> {
37
37
  * @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
38
38
  * */
39
39
  multipleOf?: number;
40
- }
40
+ };
41
41
  export declare const number: HandlerPlugin;
@@ -41,7 +41,7 @@ const number = () => {
41
41
  }
42
42
  rules.push(num);
43
43
  if (props.values) {
44
- rules.push(values(getArrayValues(props.values, Number)));
44
+ rules.push(values(getArrayValues(props.values).map(Number)));
45
45
  }
46
46
  if (min$1 !== undefined) {
47
47
  rules.push(min(min$1));
@@ -45,7 +45,7 @@ const number = () => {
45
45
  }
46
46
  rules.push(num.num);
47
47
  if (props.values) {
48
- rules.push(values.values(values.getArrayValues(props.values, Number)));
48
+ rules.push(values.values(values.getArrayValues(props.values).map(Number)));
49
49
  }
50
50
  if (min$1 !== undefined) {
51
51
  rules.push(min.min(min$1));
@@ -1,6 +1,6 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface ObjectProps extends SchemaProps<object> {
4
- children?: any;
5
- }
3
+ export type ObjectProps = SchemaProps<object> & {
4
+ children?: JSX.Element;
5
+ };
6
6
  export declare const object: HandlerPlugin;
@@ -1,6 +1,6 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface StringProps extends SchemaProps<string> {
3
+ export type StringProps = 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
@@ -32,5 +32,5 @@ export interface StringProps extends SchemaProps<string> {
32
32
  * The `patternId` keyword is used to reference a pattern from the OpenAPI specification.
33
33
  * */
34
34
  patternId?: string;
35
- }
35
+ };
36
36
  export declare const string: HandlerPlugin;
@@ -1,6 +1,6 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface TupleProps extends SchemaProps<any[]> {
4
- children?: any;
5
- }
3
+ export type TupleProps = SchemaProps<any[]> & {
4
+ children?: JSX.Element;
5
+ };
6
6
  export declare const tuple: HandlerPlugin;
@@ -1,6 +1,4 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type SchemaProps } from '../../../types';
3
- export interface UuidProps extends SchemaProps<string> {
4
- default?: 'new' | string;
5
- }
3
+ export type UuidProps = SchemaProps<string, 'new' | string>;
6
4
  export declare const uuid: HandlerPlugin;
@@ -12,10 +12,13 @@ import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
12
12
 
13
13
  const uuid = () => {
14
14
  const { default: defaultValue, ...props } = useProps();
15
- const schema = useSchemaType('string', {
15
+ const params = {
16
16
  ...props,
17
- default: defaultValue === 'new' ? undefined : defaultValue,
18
- });
17
+ };
18
+ if (defaultValue !== 'new') {
19
+ params.default = defaultValue;
20
+ }
21
+ const schema = useSchemaType('string', params);
19
22
  // @ts-expect-error: FIXME
20
23
  schema.format = 'uuid';
21
24
  if (defaultValue === 'new') {
@@ -16,10 +16,13 @@ var pipe = require('../../../utils/rules/pipe/pipe.js');
16
16
 
17
17
  const uuid = () => {
18
18
  const { default: defaultValue, ...props } = jsx.useProps();
19
- const schema = useSchemaType.useSchemaType('string', {
19
+ const params = {
20
20
  ...props,
21
- default: defaultValue === 'new' ? undefined : defaultValue,
22
- });
21
+ };
22
+ if (defaultValue !== 'new') {
23
+ params.default = defaultValue;
24
+ }
25
+ const schema = useSchemaType.useSchemaType('string', params);
23
26
  // @ts-expect-error: FIXME
24
27
  schema.format = 'uuid';
25
28
  if (defaultValue === 'new') {
@@ -1,8 +1,8 @@
1
1
  import type { OpenAPIV3_1 as API } from 'openapi-types';
2
- import type { ApiErrorValue } from './constants';
3
- import { type ServerPlugin } from './hooks';
4
- import { type ResponseStatus } from './plugins';
5
- import { type Rule, type RulesErrors } from './utils/rules';
2
+ import type { ApiErrorValue } from '../constants';
3
+ import { type ServerPlugin } from '../hooks';
4
+ import { type ResponseStatus } from '../plugins';
5
+ import { type Rule, type RulesErrors } from '../utils/rules';
6
6
  export type TagObject = API.TagObject;
7
7
  export type Document = API.Document;
8
8
  export type ServerObject = API.ServerObject;
@@ -59,13 +59,13 @@ export interface ServerStartParams {
59
59
  port: number;
60
60
  }
61
61
  export type SchemaValues<T> = (T extends (number | string) ? Record<T, string> : never) | T[];
62
- export interface SchemaProps<T> {
63
- default?: T;
62
+ export interface BaseSchemaProps<T, D = T> {
63
+ default?: D;
64
64
  deprecated?: boolean;
65
65
  description?: string;
66
66
  example?: T;
67
67
  examples?: T[];
68
- nullable?: boolean;
68
+ nullable?: false;
69
69
  readOnly?: boolean;
70
70
  ref?: string;
71
71
  title?: string;
@@ -73,6 +73,10 @@ export interface SchemaProps<T> {
73
73
  values?: SchemaValues<T>;
74
74
  writeOnly?: boolean;
75
75
  }
76
+ export interface NullableSchemaProps<T, D = T> extends Omit<BaseSchemaProps<T | null, D | null>, 'nullable'> {
77
+ nullable: true;
78
+ }
79
+ export type SchemaProps<T, D = T> = BaseSchemaProps<T, D> | NullableSchemaProps<T, D>;
76
80
  export type TResponse = Record<ResponseStatus, unknown>;
77
81
  export interface TEndpoint {
78
82
  body?: unknown;
@@ -0,0 +1,2 @@
1
+ export * from './appTypes';
2
+ export * from './isoDate';
@@ -0,0 +1,2 @@
1
+ import './appTypes.es6.js';
2
+ import './isoDate.es6.js';
package/types/index.js ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ require('./appTypes.js');
4
+ require('./isoDate.js');
5
+
@@ -0,0 +1,29 @@
1
+ export type ISODateOnly = `${number}-${number}-${number}`;
2
+ export type ISOBasicDate = `${number}`;
3
+ export type ISOWeekDate = `${number}-W${number}`;
4
+ export type ISOWeekDayDate = `${number}-W${number}-${number}`;
5
+ export type ISOOrdinalDate = `${number}-${number}`;
6
+ export type ISOTimeHM = `${number}:${number}`;
7
+ export type ISOTimeOnly = `${ISOTimeHM}:${number}`;
8
+ export type ISOTimeUTC = `${ISOTimeOnly}Z`;
9
+ export type ISOTimeHMUTC = `${ISOTimeHM}Z`;
10
+ export type ISOTimeWithOffset = `${ISOTimeOnly}${'+' | '-'}${ISOTimeHM}`;
11
+ export type ISOTimeHMWithOffset = `${ISOTimeHM}${'+' | '-'}${ISOTimeHM}`;
12
+ export type ISOLocalDateTime = `${ISODateOnly}T${ISOTimeOnly}`;
13
+ export type ISOLocalDateTimeMillis = `${ISODateOnly}T${ISOTimeOnly}.${number}`;
14
+ export type ISODateTimeUTC = `${ISODateOnly}T${ISOTimeUTC}`;
15
+ export type ISODateTimeUTCFractional = `${ISOLocalDateTimeMillis}Z`;
16
+ export type ISODateTimeWithOffset = `${ISODateOnly}T${ISOTimeOnly}${'+' | '-'}${ISOTimeHM}`;
17
+ export type ISODateTimeWithOffsetCompact = `${ISODateOnly}T${ISOTimeOnly}${'+' | '-'}${number}`;
18
+ export type ISODateTimeWithOffsetHourOnly = `${ISODateOnly}T${ISOTimeOnly}${'+' | '-'}${number}`;
19
+ export type ISODateTimeWithOffsetMillis = `${ISOLocalDateTimeMillis}${'+' | '-'}${ISOTimeHM}`;
20
+ export type ISOBasicDateTime = `${number}T${number}`;
21
+ export type ISOBasicDateTimeUTC = `${number}T${number}Z`;
22
+ export type ISOTruncatedDate = `--${number}-${number}`;
23
+ export type ISOTruncatedDateTime = `--${number}-${number}T${ISOTimeOnly}`;
24
+ export type ISOTruncatedTime = `T${ISOTimeOnly}`;
25
+ export type ISOTruncatedTimeHM = `T${ISOTimeHM}`;
26
+ export type ISODate = ISOBasicDate | ISODateOnly | ISOOrdinalDate | ISOTruncatedDate | ISOWeekDate | ISOWeekDayDate;
27
+ export type ISOTime = ISOTimeHM | ISOTimeHMUTC | ISOTimeHMWithOffset | ISOTimeOnly | ISOTimeUTC | ISOTimeWithOffset | ISOTruncatedTime | ISOTruncatedTimeHM;
28
+ export type ISODateTime = ISOBasicDateTime | ISOBasicDateTimeUTC | ISODateTimeUTC | ISODateTimeUTCFractional | ISODateTimeWithOffset | ISODateTimeWithOffsetCompact | ISODateTimeWithOffsetHourOnly | ISODateTimeWithOffsetMillis | ISOLocalDateTime | ISOLocalDateTimeMillis | ISOTruncatedDateTime;
29
+ export type ISOString = ISODate | ISODateTime | ISOTime;
@@ -0,0 +1 @@
1
+ // ==================== DATE ONLY ====================
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ // ==================== DATE ONLY ====================
@@ -1,2 +1,2 @@
1
1
  export type DateFormat = 'now' | Date | number | string;
2
- export declare function dateFormat(date?: DateFormat): Date | undefined;
2
+ export declare function dateFormat(date?: DateFormat | null): Date | undefined;
@@ -1,5 +1,5 @@
1
1
  function dateFormat(date) {
2
- if (date === undefined)
2
+ if (date === undefined || date === null)
3
3
  return;
4
4
  if (date === 'now')
5
5
  return new Date();
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function dateFormat(date) {
6
- if (date === undefined)
6
+ if (date === undefined || date === null)
7
7
  return;
8
8
  if (date === 'now')
9
9
  return new Date();
@@ -1,2 +1,4 @@
1
- export type DateFormat = 'now' | Date | number | string;
1
+ import { type ISOString } from '../../../types';
2
+ export type DateFormat = Date | ISOString | number;
3
+ export type DefaultDateFormat = 'now' | DateFormat;
2
4
  export declare function dateTo(value: any, data?: object): Date;
@@ -1,3 +1,3 @@
1
- import { type SchemaValues } from '../../../types';
2
- export declare function getArrayValues<T, F extends (value: T | string) => any = () => T>(values: SchemaValues<T>, format?: F): ReturnType<F>[];
1
+ import type { SchemaValues } from '../../../types';
2
+ export declare function getArrayValues<T extends Record<number | string, unknown> | unknown[]>(values: T): T extends SchemaValues<infer V> ? V[] : never;
3
3
  export declare function values<T>(values: T[]): (value: any, data?: object) => any;
@@ -1,7 +1,8 @@
1
1
  import { RulesError } from '../helpers.es6.js';
2
2
 
3
- function getArrayValues(values, format = (value => value)) {
4
- return Array.isArray(values) ? values.map(format) : Object.keys(values).map(format);
3
+ function getArrayValues(values) {
4
+ // @ts-expect-error TODO: Fix types
5
+ return Array.isArray(values) ? values : Object.keys(values);
5
6
  }
6
7
  function values(values) {
7
8
  return (value, data) => {
@@ -4,8 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var helpers = require('../helpers.js');
6
6
 
7
- function getArrayValues(values, format = (value => value)) {
8
- return Array.isArray(values) ? values.map(format) : Object.keys(values).map(format);
7
+ function getArrayValues(values) {
8
+ // @ts-expect-error TODO: Fix types
9
+ return Array.isArray(values) ? values : Object.keys(values);
9
10
  }
10
11
  function values(values) {
11
12
  return (value, data) => {
File without changes
File without changes