@innet/server 2.0.0-beta.2 → 2.0.0-beta.21
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/README.md +1869 -3651
- package/handler/handler.d.ts +5 -2
- package/handler/handler.es6.js +2 -0
- package/handler/handler.js +2 -0
- package/hooks/index.d.ts +25 -23
- package/hooks/index.es6.js +25 -23
- package/hooks/index.js +25 -23
- package/hooks/useAction/useAction.es6.js +1 -1
- package/hooks/useAction/useAction.js +1 -1
- package/hooks/useApi/useApi.d.ts +2 -0
- package/hooks/useData/index.d.ts +1 -0
- package/hooks/useData/index.es6.js +1 -0
- package/hooks/useData/index.js +9 -0
- package/hooks/useData/useData.d.ts +6 -0
- package/hooks/useData/useData.es6.js +29 -0
- package/hooks/useData/useData.js +33 -0
- package/hooks/useEffect/index.d.ts +1 -0
- package/hooks/useEffect/index.es6.js +1 -0
- package/hooks/useEffect/index.js +9 -0
- package/hooks/useEffect/useEffect.d.ts +2 -0
- package/hooks/useEffect/useEffect.es6.js +8 -0
- package/hooks/useEffect/useEffect.js +12 -0
- package/hooks/useSchemaType/useSchemaType.d.ts +2 -2
- package/hooks/useSchemaType/useSchemaType.es6.js +13 -4
- package/hooks/useSchemaType/useSchemaType.js +13 -4
- package/hooks/useSearch/useSearch.es6.js +1 -1
- package/hooks/useSearch/useSearch.js +1 -1
- package/hooks/useServer/useServer.d.ts +2 -0
- package/index.d.ts +2 -2
- package/index.es6.js +90 -86
- package/index.js +204 -193
- package/package.json +5 -4
- package/plugins/handler/serverFn/serverFn.es6.js +1 -1
- package/plugins/handler/serverFn/serverFn.js +1 -5
- package/plugins/index.d.ts +2 -2
- package/plugins/index.es6.js +2 -2
- package/plugins/index.js +2 -2
- package/plugins/main/api/api.es6.js +6 -5
- package/plugins/main/api/api.js +8 -11
- package/plugins/main/body/body.es6.js +4 -4
- package/plugins/main/body/body.js +4 -8
- package/plugins/main/endpoint/endpoint.es6.js +4 -4
- package/plugins/main/endpoint/endpoint.js +4 -8
- package/plugins/main/host/host.es6.js +1 -1
- package/plugins/main/host/host.js +1 -5
- package/plugins/main/index.d.ts +8 -8
- package/plugins/main/index.es6.js +8 -8
- package/plugins/main/index.js +8 -8
- package/plugins/main/param/param.es6.js +1 -1
- package/plugins/main/param/param.js +1 -5
- package/plugins/main/preset/preset.es6.js +1 -1
- package/plugins/main/preset/preset.js +1 -5
- package/plugins/main/response/response.d.ts +2 -1
- package/plugins/main/response/response.es6.js +1 -1
- package/plugins/main/response/response.js +1 -5
- package/plugins/main/server/server.d.ts +4 -0
- package/plugins/main/server/server.es6.js +5 -3
- package/plugins/main/server/server.js +6 -5
- package/plugins/main/tag/index.es6.js +1 -1
- package/plugins/main/tag/index.js +1 -0
- package/plugins/main/tag/tag.d.ts +8 -1
- package/plugins/main/tag/tag.es6.js +20 -3
- package/plugins/main/tag/tag.js +20 -6
- package/plugins/request/cms/cms.es6.js +1 -1
- package/plugins/request/cms/cms.js +2 -3
- package/plugins/request/error/error.es6.js +7 -3
- package/plugins/request/error/error.js +7 -3
- package/plugins/request/file/file.es6.js +2 -2
- package/plugins/request/file/file.js +2 -3
- package/plugins/request/header/header.es6.js +1 -1
- package/plugins/request/header/header.js +1 -1
- package/plugins/request/index.d.ts +5 -5
- package/plugins/request/index.es6.js +5 -5
- package/plugins/request/index.js +5 -5
- package/plugins/request/success/success.es6.js +6 -4
- package/plugins/request/success/success.js +6 -4
- package/plugins/schema/any/any.d.ts +2 -2
- package/plugins/schema/array/array.d.ts +5 -2
- package/plugins/schema/array/array.es6.js +14 -5
- package/plugins/schema/array/array.js +15 -10
- package/plugins/schema/binary/binary.d.ts +4 -0
- package/plugins/schema/boolean/boolean.d.ts +3 -2
- package/plugins/schema/date/date.d.ts +3 -2
- package/plugins/schema/date/date.es6.js +2 -2
- package/plugins/schema/date/date.js +2 -2
- package/plugins/schema/field/field.d.ts +4 -0
- package/plugins/schema/field/field.es6.js +16 -3
- package/plugins/schema/field/field.js +16 -7
- package/plugins/schema/index.d.ts +8 -8
- package/plugins/schema/index.es6.js +8 -8
- package/plugins/schema/index.js +8 -8
- package/plugins/schema/integer/integer.d.ts +39 -2
- package/plugins/schema/integer/integer.es6.js +25 -10
- package/plugins/schema/integer/integer.js +25 -10
- package/plugins/schema/null/null.d.ts +2 -2
- package/plugins/schema/number/number.d.ts +34 -2
- package/plugins/schema/number/number.es6.js +23 -7
- package/plugins/schema/number/number.js +22 -6
- package/plugins/schema/object/object.d.ts +2 -2
- package/plugins/schema/object/object.es6.js +8 -6
- package/plugins/schema/object/object.js +8 -10
- package/plugins/schema/string/string.d.ts +29 -2
- package/plugins/schema/string/string.es6.js +11 -5
- package/plugins/schema/string/string.js +10 -4
- package/plugins/schema/tuple/tuple.d.ts +2 -2
- package/plugins/schema/tuple/tuple.es6.js +4 -4
- package/plugins/schema/tuple/tuple.js +4 -8
- package/plugins/schema/uuid/uuid.d.ts +2 -2
- package/plugins/schema/uuid/uuid.es6.js +2 -2
- package/plugins/schema/uuid/uuid.js +1 -1
- package/plugins/utils/dts/dts.es6.js +5 -2
- package/plugins/utils/dts/dts.js +5 -2
- package/plugins/utils/env/env.es6.js +1 -1
- package/plugins/utils/env/env.js +1 -5
- package/plugins/utils/index.d.ts +3 -2
- package/plugins/utils/index.es6.js +3 -2
- package/plugins/utils/index.js +3 -2
- package/plugins/utils/swagger/swagger.d.ts +1 -0
- package/plugins/utils/swagger/swagger.es6.js +1 -0
- package/plugins/utils/swagger/swagger.js +1 -0
- package/plugins/utils/ui/index.d.ts +1 -0
- package/plugins/utils/ui/index.es6.js +1 -0
- package/plugins/utils/ui/index.js +10 -0
- package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
- package/plugins/utils/ui/rapidoc.html.js +7 -0
- package/plugins/utils/ui/redoc.html.es6.js +3 -0
- package/plugins/utils/ui/redoc.html.js +7 -0
- package/plugins/utils/ui/scalar.html.es6.js +3 -0
- package/plugins/utils/ui/scalar.html.js +7 -0
- package/plugins/utils/ui/swagger.html.es6.js +3 -0
- package/plugins/utils/ui/swagger.html.js +7 -0
- package/plugins/utils/ui/ui.d.ts +13 -0
- package/plugins/utils/ui/ui.es6.js +45 -0
- package/plugins/utils/ui/ui.js +50 -0
- package/types.d.ts +23 -3
- package/utils/generateTypes/generateTypes.es6.js +105 -76
- package/utils/generateTypes/generateTypes.js +105 -76
- package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
- package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
- package/utils/getSafeSchema/getSafeSchema.js +9 -0
- package/utils/getSafeSchema/index.d.ts +1 -0
- package/utils/getSafeSchema/index.es6.js +1 -0
- package/utils/getSafeSchema/index.js +9 -0
- package/utils/index.d.ts +9 -8
- package/utils/index.es6.js +9 -8
- package/utils/index.js +9 -8
- package/utils/rules/index.d.ts +17 -17
- package/utils/rules/index.es6.js +17 -17
- package/utils/rules/index.js +18 -18
- package/utils/rules/values/index.es6.js +1 -1
- package/utils/rules/values/index.js +1 -0
- package/utils/rules/values/values.d.ts +3 -1
- package/utils/rules/values/values.es6.js +4 -1
- 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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 (
|
|
21
|
-
|
|
38
|
+
if (!type) {
|
|
39
|
+
scope += `${operator}any`;
|
|
40
|
+
continue;
|
|
22
41
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
55
|
+
scope += `${operator}string`;
|
|
56
|
+
continue;
|
|
35
57
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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 += '
|
|
108
|
+
result += ' export interface Schemas {\n';
|
|
93
109
|
for (const name in schemas) {
|
|
94
|
-
result += `
|
|
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 += `
|
|
139
|
+
result += ` params: {\n${params.path} }\n`;
|
|
124
140
|
}
|
|
125
141
|
if (params.query) {
|
|
126
|
-
result += `
|
|
142
|
+
result += ` search: {\n${params.query} }\n`;
|
|
127
143
|
}
|
|
128
144
|
if (params.header) {
|
|
129
|
-
result += `
|
|
145
|
+
result += ` headers: {\n${params.header} }\n`;
|
|
130
146
|
}
|
|
131
147
|
if (params.cookie) {
|
|
132
|
-
result += `
|
|
148
|
+
result += ` cookies: {\n${params.cookie} }\n`;
|
|
133
149
|
}
|
|
134
150
|
}
|
|
135
151
|
if (requestBody) {
|
|
136
|
-
result += `
|
|
152
|
+
result += ` body: ${generateSchemaTypes(requestBody.content['multipart/form-data'].schema, 8)}`;
|
|
137
153
|
}
|
|
138
154
|
if (responses) {
|
|
139
|
-
result += '
|
|
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
|
-
|
|
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 @@
|
|
|
1
|
+
export * from './getSafeSchema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSafeSchema } from './getSafeSchema.es6.js';
|
package/utils/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
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 './
|
|
7
|
-
export * from './
|
|
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 './
|
|
12
|
-
export * from './FileData';
|
|
13
|
-
export * from './generateTypes';
|
|
14
|
+
export * from './stringifySearch';
|
package/utils/index.es6.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import './
|
|
2
|
-
import './
|
|
3
|
-
import './
|
|
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 './
|
|
7
|
-
import './
|
|
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 './
|
|
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('./
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
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('./
|
|
9
|
-
require('./
|
|
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('./
|
|
14
|
-
require('./FileData/index.js');
|
|
15
|
-
require('./generateTypes/index.js');
|
|
16
|
+
require('./stringifySearch/index.js');
|
|
16
17
|
|
package/utils/rules/index.d.ts
CHANGED
|
@@ -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 './
|
|
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';
|
package/utils/rules/index.es6.js
CHANGED
|
@@ -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 './
|
|
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';
|
package/utils/rules/index.js
CHANGED
|
@@ -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('./
|
|
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';
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
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;
|