@innet/server 2.0.0-beta.2 → 2.0.0-beta.20

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 (149) hide show
  1. package/README.md +1869 -3651
  2. package/handler/handler.d.ts +5 -2
  3. package/handler/handler.es6.js +2 -0
  4. package/handler/handler.js +2 -0
  5. package/hooks/index.d.ts +25 -23
  6. package/hooks/index.es6.js +25 -23
  7. package/hooks/index.js +25 -23
  8. package/hooks/useAction/useAction.es6.js +1 -1
  9. package/hooks/useAction/useAction.js +1 -1
  10. package/hooks/useApi/useApi.d.ts +2 -0
  11. package/hooks/useData/index.d.ts +1 -0
  12. package/hooks/useData/index.es6.js +1 -0
  13. package/hooks/useData/index.js +9 -0
  14. package/hooks/useData/useData.d.ts +6 -0
  15. package/hooks/useData/useData.es6.js +29 -0
  16. package/hooks/useData/useData.js +33 -0
  17. package/hooks/useEffect/index.d.ts +1 -0
  18. package/hooks/useEffect/index.es6.js +1 -0
  19. package/hooks/useEffect/index.js +9 -0
  20. package/hooks/useEffect/useEffect.d.ts +2 -0
  21. package/hooks/useEffect/useEffect.es6.js +8 -0
  22. package/hooks/useEffect/useEffect.js +12 -0
  23. package/hooks/useSchemaType/useSchemaType.d.ts +1 -1
  24. package/hooks/useSchemaType/useSchemaType.es6.js +13 -4
  25. package/hooks/useSchemaType/useSchemaType.js +13 -4
  26. package/hooks/useSearch/useSearch.es6.js +1 -1
  27. package/hooks/useSearch/useSearch.js +1 -1
  28. package/hooks/useServer/useServer.d.ts +2 -0
  29. package/index.d.ts +2 -2
  30. package/index.es6.js +90 -86
  31. package/index.js +204 -193
  32. package/package.json +5 -4
  33. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  34. package/plugins/handler/serverFn/serverFn.js +1 -5
  35. package/plugins/index.d.ts +2 -2
  36. package/plugins/index.es6.js +2 -2
  37. package/plugins/index.js +2 -2
  38. package/plugins/main/api/api.es6.js +6 -5
  39. package/plugins/main/api/api.js +8 -11
  40. package/plugins/main/body/body.es6.js +4 -4
  41. package/plugins/main/body/body.js +4 -8
  42. package/plugins/main/endpoint/endpoint.es6.js +4 -4
  43. package/plugins/main/endpoint/endpoint.js +4 -8
  44. package/plugins/main/host/host.es6.js +1 -1
  45. package/plugins/main/host/host.js +1 -5
  46. package/plugins/main/index.d.ts +8 -8
  47. package/plugins/main/index.es6.js +8 -8
  48. package/plugins/main/index.js +8 -8
  49. package/plugins/main/param/param.es6.js +1 -1
  50. package/plugins/main/param/param.js +1 -5
  51. package/plugins/main/preset/preset.es6.js +1 -1
  52. package/plugins/main/preset/preset.js +1 -5
  53. package/plugins/main/response/response.d.ts +2 -1
  54. package/plugins/main/response/response.es6.js +1 -1
  55. package/plugins/main/response/response.js +1 -5
  56. package/plugins/main/server/server.d.ts +4 -0
  57. package/plugins/main/server/server.es6.js +5 -3
  58. package/plugins/main/server/server.js +6 -5
  59. package/plugins/main/tag/index.es6.js +1 -1
  60. package/plugins/main/tag/index.js +1 -0
  61. package/plugins/main/tag/tag.d.ts +8 -1
  62. package/plugins/main/tag/tag.es6.js +20 -3
  63. package/plugins/main/tag/tag.js +20 -6
  64. package/plugins/request/cms/cms.es6.js +1 -1
  65. package/plugins/request/cms/cms.js +2 -3
  66. package/plugins/request/error/error.es6.js +7 -3
  67. package/plugins/request/error/error.js +7 -3
  68. package/plugins/request/file/file.es6.js +2 -2
  69. package/plugins/request/file/file.js +2 -3
  70. package/plugins/request/header/header.es6.js +1 -1
  71. package/plugins/request/header/header.js +1 -1
  72. package/plugins/request/index.d.ts +5 -5
  73. package/plugins/request/index.es6.js +5 -5
  74. package/plugins/request/index.js +5 -5
  75. package/plugins/request/success/success.es6.js +6 -4
  76. package/plugins/request/success/success.js +6 -4
  77. package/plugins/schema/array/array.d.ts +3 -0
  78. package/plugins/schema/array/array.es6.js +14 -5
  79. package/plugins/schema/array/array.js +15 -10
  80. package/plugins/schema/binary/binary.d.ts +4 -0
  81. package/plugins/schema/boolean/boolean.d.ts +1 -0
  82. package/plugins/schema/date/date.d.ts +2 -1
  83. package/plugins/schema/date/date.es6.js +2 -2
  84. package/plugins/schema/date/date.js +2 -2
  85. package/plugins/schema/field/field.d.ts +4 -0
  86. package/plugins/schema/field/field.es6.js +16 -3
  87. package/plugins/schema/field/field.js +16 -7
  88. package/plugins/schema/index.d.ts +8 -8
  89. package/plugins/schema/index.es6.js +8 -8
  90. package/plugins/schema/index.js +8 -8
  91. package/plugins/schema/integer/integer.d.ts +37 -0
  92. package/plugins/schema/integer/integer.es6.js +25 -10
  93. package/plugins/schema/integer/integer.js +25 -10
  94. package/plugins/schema/number/number.d.ts +32 -0
  95. package/plugins/schema/number/number.es6.js +23 -7
  96. package/plugins/schema/number/number.js +22 -6
  97. package/plugins/schema/object/object.es6.js +8 -6
  98. package/plugins/schema/object/object.js +8 -10
  99. package/plugins/schema/string/string.d.ts +27 -0
  100. package/plugins/schema/string/string.es6.js +11 -5
  101. package/plugins/schema/string/string.js +10 -4
  102. package/plugins/schema/tuple/tuple.es6.js +4 -4
  103. package/plugins/schema/tuple/tuple.js +4 -8
  104. package/plugins/schema/uuid/uuid.es6.js +2 -2
  105. package/plugins/schema/uuid/uuid.js +1 -1
  106. package/plugins/utils/dts/dts.es6.js +5 -2
  107. package/plugins/utils/dts/dts.js +5 -2
  108. package/plugins/utils/env/env.es6.js +1 -1
  109. package/plugins/utils/env/env.js +1 -5
  110. package/plugins/utils/index.d.ts +3 -2
  111. package/plugins/utils/index.es6.js +3 -2
  112. package/plugins/utils/index.js +3 -2
  113. package/plugins/utils/swagger/swagger.d.ts +1 -0
  114. package/plugins/utils/swagger/swagger.es6.js +1 -0
  115. package/plugins/utils/swagger/swagger.js +1 -0
  116. package/plugins/utils/ui/index.d.ts +1 -0
  117. package/plugins/utils/ui/index.es6.js +1 -0
  118. package/plugins/utils/ui/index.js +10 -0
  119. package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
  120. package/plugins/utils/ui/rapidoc.html.js +7 -0
  121. package/plugins/utils/ui/redoc.html.es6.js +3 -0
  122. package/plugins/utils/ui/redoc.html.js +7 -0
  123. package/plugins/utils/ui/scalar.html.es6.js +3 -0
  124. package/plugins/utils/ui/scalar.html.js +7 -0
  125. package/plugins/utils/ui/swagger.html.es6.js +3 -0
  126. package/plugins/utils/ui/swagger.html.js +7 -0
  127. package/plugins/utils/ui/ui.d.ts +13 -0
  128. package/plugins/utils/ui/ui.es6.js +45 -0
  129. package/plugins/utils/ui/ui.js +50 -0
  130. package/types.d.ts +23 -1
  131. package/utils/generateTypes/generateTypes.es6.js +105 -76
  132. package/utils/generateTypes/generateTypes.js +105 -76
  133. package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
  134. package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
  135. package/utils/getSafeSchema/getSafeSchema.js +9 -0
  136. package/utils/getSafeSchema/index.d.ts +1 -0
  137. package/utils/getSafeSchema/index.es6.js +1 -0
  138. package/utils/getSafeSchema/index.js +9 -0
  139. package/utils/index.d.ts +9 -8
  140. package/utils/index.es6.js +9 -8
  141. package/utils/index.js +9 -8
  142. package/utils/rules/index.d.ts +17 -17
  143. package/utils/rules/index.es6.js +17 -17
  144. package/utils/rules/index.js +18 -18
  145. package/utils/rules/values/index.es6.js +1 -1
  146. package/utils/rules/values/index.js +1 -0
  147. package/utils/rules/values/values.d.ts +3 -1
  148. package/utils/rules/values/values.es6.js +4 -1
  149. package/utils/rules/values/values.js +4 -0
@@ -2,6 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function getElement(docs, target) {
6
+ var _a, _b, _c;
7
+ if (!target)
8
+ return target;
9
+ if ('$ref' in target) {
10
+ return (_c = (_b = (_a = docs.components) === null || _a === void 0 ? void 0 : _a.schemas) === null || _b === void 0 ? void 0 : _b[String(target.$ref).replace('#/components/schemas/', '')]) !== null && _c !== void 0 ? _c : target;
11
+ }
12
+ return target;
13
+ }
5
14
  function hasDefault(target) {
6
15
  return Boolean(target && ('default' in target || 'x-default' in target));
7
16
  }
@@ -10,88 +19,95 @@ function generateSchemaTypes(schema, spaces = 2, lastChar = '\n') {
10
19
  if ('$ref' in schema) {
11
20
  return `Schemas.${schema.$ref.slice(21)}${lastChar}`;
12
21
  }
13
- if (schema.type === 'integer') {
14
- return `${schema.format === 'int64' ? 'bigint' : 'number'}${lastChar}`;
15
- }
16
- if (schema.type === 'string') {
17
- if (schema.format === 'date-time') {
18
- return `Date${lastChar}`;
22
+ const types = Array.isArray(schema.type) ? schema.type : [schema.type];
23
+ let scope = '';
24
+ for (let i = 0; i < types.length; i++) {
25
+ const type = types[i];
26
+ const operator = i ? ' | ' : '';
27
+ if (schema.oneOf) {
28
+ let result = '';
29
+ for (const item of schema.oneOf) {
30
+ if (result) {
31
+ result += ' | ';
32
+ }
33
+ result += generateSchemaTypes(item, spaces + 2, '');
34
+ }
35
+ scope += `${operator}${result}`;
36
+ continue;
19
37
  }
20
- if (schema.format === 'binary') {
21
- return `Bin${lastChar}`;
38
+ if (!type) {
39
+ scope += `${operator}any`;
40
+ continue;
22
41
  }
23
- return `string${lastChar}`;
24
- }
25
- if (['boolean', 'null', 'number'].includes(schema.type)) {
26
- return `${schema.type}${lastChar}`;
27
- }
28
- if (schema.oneOf) {
29
- let result = '';
30
- for (const item of schema.oneOf) {
31
- if (result) {
32
- result += ' | ';
42
+ if (type === 'integer') {
43
+ scope += `${operator}${schema.format === 'int64' ? 'bigint' : 'number'}`;
44
+ continue;
45
+ }
46
+ if (type === 'string') {
47
+ if (schema.format === 'date-time') {
48
+ scope += `${operator}Date`;
49
+ continue;
50
+ }
51
+ if (schema.format === 'binary') {
52
+ scope += `${operator}Bin`;
53
+ continue;
33
54
  }
34
- result += generateSchemaTypes(item, spaces + 2, '');
55
+ scope += `${operator}string`;
56
+ continue;
35
57
  }
36
- return result + lastChar;
37
- }
38
- if (schema.type === 'array') {
39
- if (!schema.items)
40
- return `any[]${lastChar}`;
41
- return `Array<${generateSchemaTypes(schema.items, spaces + 2, '')}>${lastChar}`;
42
- }
43
- if (!schema.type) {
44
- return `any${lastChar}`;
45
- }
46
- if (schema.type !== 'object') {
47
- console.error('unknown type', schema);
48
- return `any${lastChar}`;
49
- }
50
- let result = '{\n';
51
- const required = schema.required || [];
52
- const hasProps = Boolean(schema.properties && Object.keys(schema.properties).length);
53
- const hasRestProps = Boolean(typeof schema.additionalProperties === 'object' &&
54
- Object.keys(schema.additionalProperties).length);
55
- if (hasProps) {
56
- for (const key in schema.properties) {
57
- const prop = schema.properties[key];
58
- const splitter = required.includes(key) || hasDefault(prop)
59
- ? ':'
60
- : '?:';
61
- if ('deprecated' in prop && prop.deprecated) {
62
- result += `${space}/** @deprecated */\n`;
58
+ if (['boolean', 'null', 'number'].includes(type)) {
59
+ scope += `${operator}${type}`;
60
+ continue;
61
+ }
62
+ if (type === 'array') {
63
+ if (schema.type !== 'array' || !schema.items) {
64
+ scope += `${operator}any[]`;
65
+ continue;
63
66
  }
64
- result += `${space}${key}${splitter} ${generateSchemaTypes(prop, spaces + 2)}`;
67
+ scope += `${operator}Array<${generateSchemaTypes(schema.items, spaces + 2, '')}>`;
68
+ continue;
65
69
  }
70
+ if (type !== 'object') {
71
+ console.error('Error: Unknown Type', schema);
72
+ scope += `${operator}any`;
73
+ continue;
74
+ }
75
+ let result = '{\n';
76
+ const required = schema.required || [];
77
+ const hasProps = Boolean(schema.properties && Object.keys(schema.properties).length);
78
+ const hasRestProps = Boolean(typeof schema.additionalProperties === 'object' &&
79
+ Object.keys(schema.additionalProperties).length);
80
+ if (hasProps) {
81
+ for (const key in schema.properties) {
82
+ const prop = schema.properties[key];
83
+ const splitter = required.includes(key) || hasDefault(prop)
84
+ ? ':'
85
+ : '?:';
86
+ if ('deprecated' in prop && prop.deprecated) {
87
+ result += `${space}/** @deprecated */\n`;
88
+ }
89
+ result += `${space}${key}${splitter} ${generateSchemaTypes(prop, spaces + 2)}`;
90
+ }
91
+ }
92
+ if (hasRestProps) {
93
+ const value = hasProps
94
+ ? 'any\n'
95
+ : generateSchemaTypes(schema.additionalProperties, spaces + 2);
96
+ result += `${space}[key: string]: ${value}`;
97
+ }
98
+ scope += `${operator}${result}${space.slice(0, -2)}}`;
66
99
  }
67
- if (hasRestProps) {
68
- const value = hasProps
69
- ? 'any\n'
70
- : generateSchemaTypes(schema.additionalProperties, spaces + 2);
71
- result += `${space}[key: string]: ${value}`;
72
- }
73
- return `${result}${space.slice(0, -2)}}${lastChar}`;
100
+ return `${scope}${lastChar}`;
74
101
  }
75
102
  function generateTypes(docs, namespace = 'Api') {
76
103
  var _a;
77
- let result = `declare namespace ${namespace} {
78
- export interface Bin {
79
- filename: string
80
- fieldName: string
81
- originalFilename: string
82
- path: string
83
- type: string
84
- disposition: string
85
- size: number
86
- extension?: string
87
- }
88
- `;
104
+ let result = '';
89
105
  const schemas = (_a = docs.components) === null || _a === void 0 ? void 0 : _a.schemas;
90
106
  const paths = docs.paths;
91
107
  if (schemas) {
92
- result += ' namespace Schemas {\n';
108
+ result += ' export interface Schemas {\n';
93
109
  for (const name in schemas) {
94
- result += ` export type ${name} = ${generateSchemaTypes(schemas[name], 6)}`;
110
+ result += ` ${name}: ${generateSchemaTypes(schemas[name], 6)}`;
95
111
  }
96
112
  result += ' }\n';
97
113
  }
@@ -116,27 +132,27 @@ function generateTypes(docs, namespace = 'Api') {
116
132
  query: '',
117
133
  };
118
134
  for (const param of parameters) {
119
- const splitter = param.in === 'path' || hasDefault(param.schema) || param.required ? ':' : '?:';
135
+ const splitter = param.in === 'path' || hasDefault(getElement(docs, param.schema)) || param.required ? ':' : '?:';
120
136
  params[param.in] += ` ${param.name}${splitter} ${generateSchemaTypes(param.schema)}`;
121
137
  }
122
138
  if (params.path) {
123
- result += ` Params: {\n${params.path} }\n`;
139
+ result += ` params: {\n${params.path} }\n`;
124
140
  }
125
141
  if (params.query) {
126
- result += ` Search: {\n${params.query} }\n`;
142
+ result += ` search: {\n${params.query} }\n`;
127
143
  }
128
144
  if (params.header) {
129
- result += ` Headers: {\n${params.header} }\n`;
145
+ result += ` headers: {\n${params.header} }\n`;
130
146
  }
131
147
  if (params.cookie) {
132
- result += ` Cookies: {\n${params.cookie} }\n`;
148
+ result += ` cookies: {\n${params.cookie} }\n`;
133
149
  }
134
150
  }
135
151
  if (requestBody) {
136
- result += ` Body: ${generateSchemaTypes(requestBody.content['multipart/form-data'].schema, 8)}`;
152
+ result += ` body: ${generateSchemaTypes(requestBody.content['multipart/form-data'].schema, 8)}`;
137
153
  }
138
154
  if (responses) {
139
- result += ' Response: {\n';
155
+ result += ' response: {\n';
140
156
  for (const key in responses) {
141
157
  let multiple = false;
142
158
  const response = responses[key];
@@ -160,7 +176,20 @@ function generateTypes(docs, namespace = 'Api') {
160
176
  result += ' }\n';
161
177
  }
162
178
  }
163
- return result + ' }\n}';
179
+ const body = result + ' }';
180
+ return `import '@innet/server'
181
+ ${body.includes('Bin') ? 'import { Bin } from \'@innet/server\'\n' : ''}
182
+ declare global {
183
+ namespace ${namespace} {
184
+ ${body}
185
+ }
186
+ }
187
+
188
+ declare module '@innet/server' {
189
+ interface ApiEndpoints extends ${namespace}.Endpoints {}
190
+ interface ApiSchemas extends ${namespace}.Schemas {}
191
+ }
192
+ `;
164
193
  }
165
194
 
166
195
  exports.generateSchemaTypes = generateSchemaTypes;
@@ -0,0 +1,2 @@
1
+ import { type SchemaObject } from '../../types';
2
+ export declare function getSafeSchema(schema: SchemaObject): SchemaObject;
@@ -0,0 +1,5 @@
1
+ function getSafeSchema(schema) {
2
+ return 'oneOf' in schema ? schema.oneOf[0] : schema;
3
+ }
4
+
5
+ export { getSafeSchema };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function getSafeSchema(schema) {
6
+ return 'oneOf' in schema ? schema.oneOf[0] : schema;
7
+ }
8
+
9
+ exports.getSafeSchema = getSafeSchema;
@@ -0,0 +1 @@
1
+ export * from './getSafeSchema';
@@ -0,0 +1 @@
1
+ export { getSafeSchema } from './getSafeSchema.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getSafeSchema = require('./getSafeSchema.js');
6
+
7
+
8
+
9
+ exports.getSafeSchema = getSafeSchema.getSafeSchema;
package/utils/index.d.ts CHANGED
@@ -1,13 +1,14 @@
1
- export * from './parseSearch';
2
- export * from './stringifySearch';
3
- export * from './httpOnStart';
1
+ export * from './FileData';
2
+ export * from './JSONString';
3
+ export * from './action';
4
+ export * from './decorators';
5
+ export * from './generateTypes';
4
6
  export * from './getEndpoint';
5
7
  export * from './getOrAdd';
6
- export * from './decorators';
7
- export * from './action';
8
+ export * from './getSafeSchema';
9
+ export * from './httpOnStart';
8
10
  export * from './parseBody';
9
11
  export * from './parseFormBody';
12
+ export * from './parseSearch';
10
13
  export * from './rules';
11
- export * from './JSONString';
12
- export * from './FileData';
13
- export * from './generateTypes';
14
+ export * from './stringifySearch';
@@ -1,13 +1,14 @@
1
- import './parseSearch/index.es6.js';
2
- import './stringifySearch/index.es6.js';
3
- import './httpOnStart/index.es6.js';
1
+ import './FileData/index.es6.js';
2
+ import './JSONString/index.es6.js';
3
+ import './action/index.es6.js';
4
+ import './decorators/index.es6.js';
5
+ import './generateTypes/index.es6.js';
4
6
  import './getEndpoint/index.es6.js';
5
7
  import './getOrAdd/index.es6.js';
6
- import './decorators/index.es6.js';
7
- import './action/index.es6.js';
8
+ import './getSafeSchema/index.es6.js';
9
+ import './httpOnStart/index.es6.js';
8
10
  import './parseBody/index.es6.js';
9
11
  import './parseFormBody/index.es6.js';
12
+ import './parseSearch/index.es6.js';
10
13
  import './rules/index.es6.js';
11
- import './JSONString/index.es6.js';
12
- import './FileData/index.es6.js';
13
- import './generateTypes/index.es6.js';
14
+ import './stringifySearch/index.es6.js';
package/utils/index.js CHANGED
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- require('./parseSearch/index.js');
4
- require('./stringifySearch/index.js');
5
- require('./httpOnStart/index.js');
3
+ require('./FileData/index.js');
4
+ require('./JSONString/index.js');
5
+ require('./action/index.js');
6
+ require('./decorators/index.js');
7
+ require('./generateTypes/index.js');
6
8
  require('./getEndpoint/index.js');
7
9
  require('./getOrAdd/index.js');
8
- require('./decorators/index.js');
9
- require('./action/index.js');
10
+ require('./getSafeSchema/index.js');
11
+ require('./httpOnStart/index.js');
10
12
  require('./parseBody/index.js');
11
13
  require('./parseFormBody/index.js');
14
+ require('./parseSearch/index.js');
12
15
  require('./rules/index.js');
13
- require('./JSONString/index.js');
14
- require('./FileData/index.js');
15
- require('./generateTypes/index.js');
16
+ require('./stringifySearch/index.js');
16
17
 
@@ -1,28 +1,28 @@
1
- export * from './helpers';
2
- export * from './constants';
3
- export * from './types';
4
- export * from './num';
5
1
  export * from './arrayOf';
6
- export * from './oneOf';
2
+ export * from './bin';
3
+ export * from './binaryAccept';
4
+ export * from './constants';
7
5
  export * from './dateTo';
6
+ export * from './defaultTo';
7
+ export * from './helpers';
8
8
  export * from './int';
9
+ export * from './max';
10
+ export * from './maxBin';
11
+ export * from './maxDate';
12
+ export * from './maxLength';
13
+ export * from './min';
14
+ export * from './minBin';
15
+ export * from './minDate';
16
+ export * from './minLength';
9
17
  export * from './nullable';
18
+ export * from './num';
10
19
  export * from './objectOf';
20
+ export * from './oneOf';
11
21
  export * from './optional';
12
22
  export * from './pattern';
23
+ export * from './pipe';
13
24
  export * from './required';
14
25
  export * from './tupleOf';
26
+ export * from './types';
15
27
  export * from './uuidTo';
16
28
  export * from './values';
17
- export * from './pipe';
18
- export * from './maxDate';
19
- export * from './minDate';
20
- export * from './maxLength';
21
- export * from './minLength';
22
- export * from './max';
23
- export * from './min';
24
- export * from './defaultTo';
25
- export * from './bin';
26
- export * from './minBin';
27
- export * from './maxBin';
28
- export * from './binaryAccept';
@@ -1,28 +1,28 @@
1
- export { RulesError, addKey } from './helpers.es6.js';
2
- export { rulesErrors } from './constants.es6.js';
3
- import './types.es6.js';
4
- import './num/index.es6.js';
5
1
  import './arrayOf/index.es6.js';
6
- import './oneOf/index.es6.js';
2
+ import './bin/index.es6.js';
3
+ import './binaryAccept/index.es6.js';
4
+ export { rulesErrors } from './constants.es6.js';
7
5
  import './dateTo/index.es6.js';
6
+ import './defaultTo/index.es6.js';
7
+ export { RulesError, addKey } from './helpers.es6.js';
8
8
  import './int/index.es6.js';
9
+ import './max/index.es6.js';
10
+ import './maxBin/index.es6.js';
11
+ import './maxDate/index.es6.js';
12
+ import './maxLength/index.es6.js';
13
+ import './min/index.es6.js';
14
+ import './minBin/index.es6.js';
15
+ import './minDate/index.es6.js';
16
+ import './minLength/index.es6.js';
9
17
  import './nullable/index.es6.js';
18
+ import './num/index.es6.js';
10
19
  import './objectOf/index.es6.js';
20
+ import './oneOf/index.es6.js';
11
21
  import './optional/index.es6.js';
12
22
  import './pattern/index.es6.js';
23
+ import './pipe/index.es6.js';
13
24
  import './required/index.es6.js';
14
25
  import './tupleOf/index.es6.js';
26
+ import './types.es6.js';
15
27
  import './uuidTo/index.es6.js';
16
28
  import './values/index.es6.js';
17
- import './pipe/index.es6.js';
18
- import './maxDate/index.es6.js';
19
- import './minDate/index.es6.js';
20
- import './maxLength/index.es6.js';
21
- import './minLength/index.es6.js';
22
- import './max/index.es6.js';
23
- import './min/index.es6.js';
24
- import './defaultTo/index.es6.js';
25
- import './bin/index.es6.js';
26
- import './minBin/index.es6.js';
27
- import './maxBin/index.es6.js';
28
- import './binaryAccept/index.es6.js';
@@ -2,37 +2,37 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var helpers = require('./helpers.js');
6
- var constants = require('./constants.js');
7
- require('./types.js');
8
- require('./num/index.js');
9
5
  require('./arrayOf/index.js');
10
- require('./oneOf/index.js');
6
+ require('./bin/index.js');
7
+ require('./binaryAccept/index.js');
8
+ var constants = require('./constants.js');
11
9
  require('./dateTo/index.js');
10
+ require('./defaultTo/index.js');
11
+ var helpers = require('./helpers.js');
12
12
  require('./int/index.js');
13
+ require('./max/index.js');
14
+ require('./maxBin/index.js');
15
+ require('./maxDate/index.js');
16
+ require('./maxLength/index.js');
17
+ require('./min/index.js');
18
+ require('./minBin/index.js');
19
+ require('./minDate/index.js');
20
+ require('./minLength/index.js');
13
21
  require('./nullable/index.js');
22
+ require('./num/index.js');
14
23
  require('./objectOf/index.js');
24
+ require('./oneOf/index.js');
15
25
  require('./optional/index.js');
16
26
  require('./pattern/index.js');
27
+ require('./pipe/index.js');
17
28
  require('./required/index.js');
18
29
  require('./tupleOf/index.js');
30
+ require('./types.js');
19
31
  require('./uuidTo/index.js');
20
32
  require('./values/index.js');
21
- require('./pipe/index.js');
22
- require('./maxDate/index.js');
23
- require('./minDate/index.js');
24
- require('./maxLength/index.js');
25
- require('./minLength/index.js');
26
- require('./max/index.js');
27
- require('./min/index.js');
28
- require('./defaultTo/index.js');
29
- require('./bin/index.js');
30
- require('./minBin/index.js');
31
- require('./maxBin/index.js');
32
- require('./binaryAccept/index.js');
33
33
 
34
34
 
35
35
 
36
+ exports.rulesErrors = constants.rulesErrors;
36
37
  exports.RulesError = helpers.RulesError;
37
38
  exports.addKey = helpers.addKey;
38
- exports.rulesErrors = constants.rulesErrors;
@@ -1 +1 @@
1
- export { values } from './values.es6.js';
1
+ export { getArrayValues, values } from './values.es6.js';
@@ -6,4 +6,5 @@ var values = require('./values.js');
6
6
 
7
7
 
8
8
 
9
+ exports.getArrayValues = values.getArrayValues;
9
10
  exports.values = values.values;
@@ -1 +1,3 @@
1
- export declare function values(values: any[]): (value: any, data?: object) => any;
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>[];
3
+ export declare function values<T>(values: T[]): (value: any, data?: object) => any;
@@ -1,5 +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);
5
+ }
3
6
  function values(values) {
4
7
  return (value, data) => {
5
8
  if (!values.includes(value)) {
@@ -13,4 +16,4 @@ function values(values) {
13
16
  };
14
17
  }
15
18
 
16
- export { values };
19
+ export { getArrayValues, values };
@@ -4,6 +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);
9
+ }
7
10
  function values(values) {
8
11
  return (value, data) => {
9
12
  if (!values.includes(value)) {
@@ -17,4 +20,5 @@ function values(values) {
17
20
  };
18
21
  }
19
22
 
23
+ exports.getArrayValues = getArrayValues;
20
24
  exports.values = values;