@innet/server 2.0.0-alpha.9 → 2.0.0-beta.10
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 +1771 -799
- package/handler/handler.d.ts +26 -18
- package/handler/handler.es6.js +17 -14
- package/handler/handler.js +16 -13
- package/hooks/index.d.ts +26 -20
- package/hooks/index.es6.js +26 -20
- package/hooks/index.js +26 -20
- package/hooks/useAction/useAction.es6.js +1 -1
- package/hooks/useAction/useAction.js +1 -1
- package/hooks/useApi/useApi.d.ts +1 -3
- package/hooks/useClientIp/useClientIp.d.ts +1 -1
- 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/useEndpoint/useEndpoint.d.ts +1 -1
- package/hooks/useEndpoint/useEndpoint.es6.js +3 -1
- package/hooks/useEndpoint/useEndpoint.js +3 -1
- package/hooks/useHeaders/useHeaders.d.ts +0 -1
- package/hooks/useIsServerHttps/index.d.ts +1 -0
- package/hooks/useIsServerHttps/index.es6.js +1 -0
- package/hooks/useIsServerHttps/index.js +10 -0
- package/hooks/useIsServerHttps/useIsServerHttps.d.ts +3 -0
- package/hooks/useIsServerHttps/useIsServerHttps.es6.js +14 -0
- package/hooks/useIsServerHttps/useIsServerHttps.js +19 -0
- package/hooks/useNewSchema/useNewSchema.es6.js +2 -2
- package/hooks/useNewSchema/useNewSchema.js +2 -2
- package/hooks/useObjectSchemaContext/index.d.ts +1 -0
- package/hooks/useObjectSchemaContext/index.es6.js +1 -0
- package/hooks/useObjectSchemaContext/index.js +10 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.d.ts +3 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js +14 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.js +19 -0
- package/hooks/useRequest/index.es6.js +1 -1
- package/hooks/useRequest/index.js +0 -1
- package/hooks/useRequest/useRequest.d.ts +1 -5
- package/hooks/useRequest/useRequest.es6.js +4 -4
- package/hooks/useRequest/useRequest.js +3 -4
- package/hooks/useRequestHandler/index.d.ts +1 -0
- package/hooks/useRequestHandler/index.es6.js +1 -0
- package/hooks/useRequestHandler/index.js +10 -0
- package/hooks/useRequestHandler/useRequestHandler.d.ts +4 -0
- package/hooks/useRequestHandler/useRequestHandler.es6.js +14 -0
- package/hooks/useRequestHandler/useRequestHandler.js +19 -0
- package/hooks/useResponse/index.es6.js +1 -1
- package/hooks/useResponse/index.js +0 -1
- package/hooks/useResponse/useResponse.d.ts +1 -5
- package/hooks/useResponse/useResponse.es6.js +4 -4
- package/hooks/useResponse/useResponse.js +3 -4
- package/hooks/useSchemaType/useSchemaType.d.ts +3 -2
- package/hooks/useSchemaType/useSchemaType.es6.js +16 -9
- package/hooks/useSchemaType/useSchemaType.js +16 -9
- package/hooks/useServer/useServer.d.ts +2 -3
- package/hooks/useServer/useServer.es6.js +3 -1
- package/hooks/useServer/useServer.js +3 -1
- package/hooks/useServerPlugin/index.d.ts +1 -0
- package/hooks/useServerPlugin/index.es6.js +1 -0
- package/hooks/useServerPlugin/index.js +9 -0
- package/hooks/useServerPlugin/useServerPlugin.d.ts +2 -0
- package/hooks/useServerPlugin/useServerPlugin.es6.js +13 -0
- package/hooks/useServerPlugin/useServerPlugin.js +17 -0
- package/hooks/useServerPlugins/index.d.ts +1 -0
- package/hooks/useServerPlugins/index.es6.js +1 -0
- package/hooks/useServerPlugins/index.js +10 -0
- package/hooks/useServerPlugins/useServerPlugins.d.ts +4 -0
- package/hooks/useServerPlugins/useServerPlugins.es6.js +14 -0
- package/hooks/useServerPlugins/useServerPlugins.js +19 -0
- package/hooks/useServerPort/index.d.ts +1 -0
- package/hooks/useServerPort/index.es6.js +1 -0
- package/hooks/useServerPort/index.js +10 -0
- package/hooks/useServerPort/useServerPort.d.ts +3 -0
- package/hooks/useServerPort/useServerPort.es6.js +14 -0
- package/hooks/useServerPort/useServerPort.js +19 -0
- package/index.d.ts +2 -2
- package/index.es6.js +91 -82
- package/index.js +208 -184
- package/package.json +16 -16
- package/plugins/handler/serverFn/serverFn.es6.js +2 -2
- package/plugins/handler/serverFn/serverFn.js +2 -6
- 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.d.ts +11 -8
- package/plugins/main/api/api.es6.js +112 -113
- package/plugins/main/api/api.js +112 -117
- package/plugins/main/body/body.d.ts +1 -0
- package/plugins/main/body/body.es6.js +4 -4
- package/plugins/main/body/body.js +4 -8
- package/plugins/main/contact/contact.d.ts +2 -2
- package/plugins/main/endpoint/endpoint.d.ts +21 -15
- package/plugins/main/endpoint/endpoint.es6.js +12 -10
- package/plugins/main/endpoint/endpoint.js +11 -13
- package/plugins/main/host/host.d.ts +5 -5
- package/plugins/main/host/host.es6.js +4 -2
- package/plugins/main/host/host.js +4 -6
- package/plugins/main/index.d.ts +9 -9
- package/plugins/main/index.es6.js +9 -9
- package/plugins/main/index.js +9 -9
- package/plugins/main/license/license.d.ts +5 -5
- package/plugins/main/param/param.d.ts +12 -11
- package/plugins/main/param/param.es6.js +7 -8
- package/plugins/main/param/param.js +6 -11
- package/plugins/main/preset/index.d.ts +1 -0
- package/plugins/main/preset/index.es6.js +1 -0
- package/plugins/{utils/prod → main/preset}/index.js +2 -2
- package/plugins/main/preset/preset.d.ts +3 -0
- package/plugins/main/preset/preset.es6.js +13 -0
- package/plugins/main/preset/preset.js +17 -0
- package/plugins/main/response/index.es6.js +1 -1
- package/plugins/main/response/index.js +1 -0
- package/plugins/main/response/response.d.ts +6 -1
- package/plugins/main/response/response.es6.js +29 -13
- package/plugins/main/response/response.js +28 -15
- package/plugins/main/return/index.d.ts +1 -0
- package/plugins/main/return/index.es6.js +1 -0
- package/plugins/main/return/index.js +9 -0
- package/plugins/main/return/return.d.ts +4 -0
- package/plugins/main/return/return.es6.js +10 -0
- package/plugins/main/return/return.js +14 -0
- package/plugins/main/server/server.d.ts +6 -6
- package/plugins/main/server/server.es6.js +40 -16
- package/plugins/main/server/server.js +39 -16
- package/plugins/main/tag/index.es6.js +1 -1
- package/plugins/main/tag/index.js +1 -0
- package/plugins/main/tag/tag.d.ts +10 -2
- package/plugins/main/tag/tag.es6.js +25 -6
- package/plugins/main/tag/tag.js +24 -8
- package/plugins/main/variable/variable.d.ts +5 -5
- package/plugins/main/variable/variable.es6.js +4 -3
- package/plugins/main/variable/variable.js +4 -3
- package/plugins/request/cms/cms.d.ts +1 -0
- package/plugins/request/cms/cms.es6.js +4 -5
- package/plugins/request/cms/cms.js +3 -5
- package/plugins/request/cookie/cookie.d.ts +2 -2
- package/plugins/request/cookie/cookie.es6.js +1 -2
- package/plugins/request/cookie/cookie.js +1 -2
- package/plugins/request/error/error.d.ts +41 -40
- package/plugins/request/error/error.es6.js +47 -45
- package/plugins/request/error/error.js +46 -44
- package/plugins/request/file/file.d.ts +1 -0
- package/plugins/request/file/file.es6.js +5 -7
- package/plugins/request/file/file.js +3 -6
- 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/proxy/proxy.d.ts +3 -1
- package/plugins/request/proxy/proxy.es6.js +5 -2
- package/plugins/request/proxy/proxy.js +5 -2
- package/plugins/request/redirect/redirect.d.ts +8 -7
- package/plugins/request/redirect/redirect.es6.js +7 -7
- package/plugins/request/redirect/redirect.js +7 -7
- package/plugins/request/success/success.d.ts +8 -6
- package/plugins/request/success/success.es6.js +21 -11
- package/plugins/request/success/success.js +20 -10
- package/plugins/schema/any/any.d.ts +5 -0
- package/plugins/schema/any/any.es6.js +27 -0
- package/plugins/schema/any/any.js +31 -0
- package/plugins/schema/array/array.d.ts +4 -0
- package/plugins/schema/array/array.es6.js +15 -7
- package/plugins/schema/array/array.js +15 -11
- package/plugins/schema/binary/binary.d.ts +7 -3
- package/plugins/schema/boolean/boolean.d.ts +1 -0
- package/plugins/schema/date/date.d.ts +3 -2
- package/plugins/schema/date/date.es6.js +8 -4
- package/plugins/schema/date/date.js +8 -4
- package/plugins/schema/field/field.d.ts +6 -0
- package/plugins/schema/field/field.es6.js +22 -9
- package/plugins/schema/field/field.js +20 -11
- package/plugins/schema/index.d.ts +8 -7
- package/plugins/schema/index.es6.js +8 -7
- package/plugins/schema/index.js +8 -7
- package/plugins/schema/integer/integer.d.ts +40 -3
- package/plugins/schema/integer/integer.es6.js +29 -9
- package/plugins/schema/integer/integer.js +29 -9
- package/plugins/schema/number/number.d.ts +34 -2
- package/plugins/schema/number/number.es6.js +21 -6
- package/plugins/schema/number/number.js +21 -6
- package/plugins/schema/object/object.d.ts +1 -0
- package/plugins/schema/object/object.es6.js +22 -8
- package/plugins/schema/object/object.js +21 -11
- package/plugins/schema/string/string.d.ts +29 -2
- package/plugins/schema/string/string.es6.js +50 -31
- package/plugins/schema/string/string.js +50 -31
- package/plugins/schema/tuple/tuple.d.ts +1 -0
- package/plugins/schema/tuple/tuple.es6.js +8 -9
- package/plugins/schema/tuple/tuple.js +7 -12
- package/plugins/schema/uuid/uuid.es6.js +5 -3
- package/plugins/schema/uuid/uuid.js +5 -3
- package/plugins/utils/blacklist/blacklist.d.ts +5 -0
- package/plugins/utils/blacklist/blacklist.es6.js +17 -0
- package/plugins/utils/blacklist/blacklist.js +21 -0
- package/plugins/utils/blacklist/index.d.ts +1 -0
- package/plugins/utils/blacklist/index.es6.js +1 -0
- package/plugins/utils/blacklist/index.js +9 -0
- package/plugins/utils/dts/dts.d.ts +2 -1
- package/plugins/utils/dts/dts.es6.js +6 -3
- package/plugins/utils/dts/dts.js +6 -3
- package/plugins/utils/env/env.d.ts +7 -0
- package/plugins/utils/env/env.es6.js +11 -0
- package/plugins/utils/env/env.js +15 -0
- package/plugins/utils/env/index.d.ts +1 -0
- package/plugins/utils/env/index.es6.js +1 -0
- package/plugins/utils/{dev → env}/index.js +2 -2
- package/plugins/utils/index.d.ts +5 -3
- package/plugins/utils/index.es6.js +5 -3
- package/plugins/utils/index.js +5 -3
- package/plugins/utils/protection/protection.d.ts +4 -4
- package/plugins/utils/protection/protection.es6.js +13 -16
- package/plugins/utils/protection/protection.js +13 -16
- package/plugins/utils/swagger/swagger.d.ts +1 -0
- package/plugins/utils/swagger/swagger.es6.js +8 -5
- package/plugins/utils/swagger/swagger.js +8 -5
- 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/plugins/utils/whitelist/index.d.ts +1 -0
- package/plugins/utils/whitelist/index.es6.js +1 -0
- package/plugins/utils/whitelist/index.js +9 -0
- package/plugins/utils/whitelist/whitelist.d.ts +5 -0
- package/plugins/utils/whitelist/whitelist.es6.js +19 -0
- package/plugins/utils/whitelist/whitelist.js +23 -0
- package/types.d.ts +21 -22
- package/utils/FileData/Bin.d.ts +13 -13
- package/utils/FileData/Bin.es6.js +2 -2
- package/utils/FileData/Bin.js +2 -2
- package/utils/action/Action.d.ts +13 -14
- package/utils/action/Action.es6.js +92 -92
- package/utils/action/Action.js +91 -91
- package/utils/dateFormat/dateFormat.d.ts +1 -1
- package/utils/dateFormat/dateFormat.es6.js +1 -1
- package/utils/dateFormat/dateFormat.js +1 -1
- package/utils/decorators/once/once.es6.js +1 -1
- package/utils/decorators/once/once.js +1 -1
- package/utils/generateTypes/generateTypes.d.ts +2 -2
- package/utils/generateTypes/generateTypes.es6.js +85 -25
- package/utils/generateTypes/generateTypes.js +85 -25
- package/utils/getEndpoint/getEndpoint.es6.js +2 -2
- package/utils/getEndpoint/getEndpoint.js +2 -2
- package/utils/getOrAdd/getOrAdd.d.ts +1 -1
- 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/httpOnStart/httpOnStart.d.ts +1 -1
- package/utils/httpOnStart/httpOnStart.es6.js +1 -1
- package/utils/httpOnStart/httpOnStart.js +1 -1
- package/utils/index.d.ts +9 -8
- package/utils/index.es6.js +9 -8
- package/utils/index.js +9 -8
- package/utils/parseBody/parseBody.d.ts +0 -1
- package/utils/parseBody/parseBody.es6.js +13 -16
- package/utils/parseBody/parseBody.js +13 -16
- package/utils/parseFormBody/parseFormBody.d.ts +0 -1
- package/utils/parseFormBody/parseFormBody.es6.js +41 -41
- package/utils/parseFormBody/parseFormBody.js +41 -41
- package/utils/parseSearch/parseSearch.es6.js +4 -1
- package/utils/parseSearch/parseSearch.js +4 -1
- package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
- package/utils/rules/arrayOf/arrayOf.js +1 -1
- package/utils/rules/bin/bin.es6.js +4 -1
- package/utils/rules/bin/bin.js +4 -1
- package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
- package/utils/rules/binaryAccept/binaryAccept.js +5 -2
- package/utils/rules/dateTo/dateTo.d.ts +1 -1
- package/utils/rules/dateTo/dateTo.es6.js +4 -1
- package/utils/rules/dateTo/dateTo.js +4 -1
- package/utils/rules/helpers.d.ts +1 -1
- package/utils/rules/helpers.es6.js +4 -1
- package/utils/rules/helpers.js +4 -1
- package/utils/rules/index.d.ts +17 -18
- package/utils/rules/index.es6.js +17 -18
- package/utils/rules/index.js +18 -19
- package/utils/rules/int/int.es6.js +17 -4
- package/utils/rules/int/int.js +17 -4
- package/utils/rules/max/max.d.ts +1 -1
- package/utils/rules/max/max.es6.js +10 -4
- package/utils/rules/max/max.js +10 -4
- package/utils/rules/maxBin/maxBin.es6.js +5 -2
- package/utils/rules/maxBin/maxBin.js +5 -2
- package/utils/rules/maxDate/maxDate.es6.js +5 -1
- package/utils/rules/maxDate/maxDate.js +5 -1
- package/utils/rules/maxLength/maxLength.es6.js +5 -2
- package/utils/rules/maxLength/maxLength.js +5 -2
- package/utils/rules/min/min.d.ts +1 -1
- package/utils/rules/min/min.es6.js +10 -4
- package/utils/rules/min/min.js +10 -4
- package/utils/rules/minBin/minBin.es6.js +5 -2
- package/utils/rules/minBin/minBin.js +5 -2
- package/utils/rules/minDate/minDate.es6.js +5 -1
- package/utils/rules/minDate/minDate.js +5 -1
- package/utils/rules/minLength/minLength.es6.js +5 -2
- package/utils/rules/minLength/minLength.js +5 -2
- package/utils/rules/num/num.es6.js +4 -1
- package/utils/rules/num/num.js +4 -1
- package/utils/rules/objectOf/objectOf.d.ts +1 -1
- package/utils/rules/objectOf/objectOf.es6.js +16 -3
- package/utils/rules/objectOf/objectOf.js +16 -3
- package/utils/rules/pattern/pattern.d.ts +1 -1
- package/utils/rules/pattern/pattern.es6.js +6 -1
- package/utils/rules/pattern/pattern.js +6 -1
- package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
- package/utils/rules/tupleOf/tupleOf.js +1 -1
- package/utils/rules/values/values.es6.js +5 -2
- package/utils/rules/values/values.js +5 -2
- package/utils/stringifySearch/stringifySearch.es6.js +4 -1
- package/utils/stringifySearch/stringifySearch.js +4 -1
- package/example/app/App/App.d.ts +0 -1
- package/example/app/App/index.d.ts +0 -1
- package/example/index.d.ts +0 -1
- package/example/requests/index.d.ts +0 -1
- package/example/requests/todo/AddTodo/AddTodo.d.ts +0 -1
- package/example/requests/todo/AddTodo/index.d.ts +0 -1
- package/example/requests/todo/DeleteTodo/DeleteTodo.d.ts +0 -1
- package/example/requests/todo/DeleteTodo/index.d.ts +0 -1
- package/example/requests/todo/EditTodo/EditTodo.d.ts +0 -1
- package/example/requests/todo/EditTodo/index.d.ts +0 -1
- package/example/requests/todo/GetTodo/GetTodo.d.ts +0 -1
- package/example/requests/todo/GetTodo/index.d.ts +0 -1
- package/example/requests/todo/GetTodos/GetTodos.d.ts +0 -1
- package/example/requests/todo/GetTodos/index.d.ts +0 -1
- package/example/requests/todo/index.d.ts +0 -5
- package/example/requests/todo/todos.d.ts +0 -1
- package/example/schemas/app/ListQueryParams/ListQueryParams.d.ts +0 -1
- package/example/schemas/app/ListQueryParams/index.d.ts +0 -1
- package/example/schemas/app/ListSchema/ListSchema.d.ts +0 -4
- package/example/schemas/app/ListSchema/index.d.ts +0 -1
- package/example/schemas/app/index.d.ts +0 -2
- package/example/schemas/index.d.ts +0 -2
- package/example/schemas/todo/TodoSchema/TodoSchema.d.ts +0 -4
- package/example/schemas/todo/TodoSchema/index.d.ts +0 -1
- package/example/schemas/todo/index.d.ts +0 -1
- package/example/tags/Todo/Todo.d.ts +0 -1
- package/example/tags/Todo/index.d.ts +0 -1
- package/example/tags/index.d.ts +0 -1
- package/hooks/useRequestPlugin/index.d.ts +0 -1
- package/hooks/useRequestPlugin/index.es6.js +0 -1
- package/hooks/useRequestPlugin/index.js +0 -9
- package/hooks/useRequestPlugin/useRequestPlugin.d.ts +0 -2
- package/hooks/useRequestPlugin/useRequestPlugin.es6.js +0 -13
- package/hooks/useRequestPlugin/useRequestPlugin.js +0 -17
- package/openApi.test.d.ts +0 -1
- package/plugins/main/fallback/fallback.d.ts +0 -4
- package/plugins/main/fallback/fallback.es6.js +0 -19
- package/plugins/main/fallback/fallback.js +0 -23
- package/plugins/main/fallback/index.d.ts +0 -1
- package/plugins/main/fallback/index.es6.js +0 -1
- package/plugins/main/fallback/index.js +0 -9
- package/plugins/main/request/index.d.ts +0 -1
- package/plugins/main/request/index.es6.js +0 -1
- package/plugins/main/request/index.js +0 -9
- package/plugins/main/request/request.d.ts +0 -4
- package/plugins/main/request/request.es6.js +0 -21
- package/plugins/main/request/request.js +0 -25
- package/plugins/utils/dev/dev.d.ts +0 -4
- package/plugins/utils/dev/dev.es6.js +0 -10
- package/plugins/utils/dev/dev.js +0 -18
- package/plugins/utils/dev/index.d.ts +0 -1
- package/plugins/utils/dev/index.es6.js +0 -1
- package/plugins/utils/prod/index.d.ts +0 -1
- package/plugins/utils/prod/index.es6.js +0 -1
- package/plugins/utils/prod/prod.d.ts +0 -4
- package/plugins/utils/prod/prod.es6.js +0 -10
- package/plugins/utils/prod/prod.js +0 -18
- package/utils/decorators/once/once.test.d.ts +0 -1
- package/utils/generateTypes/generateTypes.test.d.ts +0 -1
- package/utils/parseSearch/parseSearch.test.d.ts +0 -1
- package/utils/rules/any/any.d.ts +0 -1
- package/utils/rules/any/any.es6.js +0 -5
- package/utils/rules/any/any.js +0 -9
- /package/{utils/rules → plugins/schema}/any/index.d.ts +0 -0
- /package/{utils/rules → plugins/schema}/any/index.es6.js +0 -0
- /package/{utils/rules → plugins/schema}/any/index.js +0 -0
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type IntegerFormats, type ValuesSchemaProps } from '../../../types';
|
|
3
|
-
export interface IntegerProps extends ValuesSchemaProps<
|
|
3
|
+
export interface IntegerProps extends ValuesSchemaProps<bigint | number> {
|
|
4
|
+
/**
|
|
5
|
+
* The `exclusiveMaximum` keyword is used to restrict the value to be less than the specified number.
|
|
6
|
+
* @example For example, the following value is valid:
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <integer exclusiveMaximum={10} />
|
|
9
|
+
* ```
|
|
10
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
|
|
11
|
+
* */
|
|
12
|
+
exclusiveMaximum?: bigint | boolean | number;
|
|
13
|
+
/**
|
|
14
|
+
* The `exclusiveMinimum` keyword is used to restrict the value to be greater than the specified number.
|
|
15
|
+
* @example For example, the following value is valid:
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <integer exclusiveMinimum={10} />
|
|
18
|
+
* ```
|
|
19
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
|
|
20
|
+
* */
|
|
21
|
+
exclusiveMinimum?: bigint | boolean | number;
|
|
22
|
+
/**
|
|
23
|
+
* An optional format modifier serves as a hint at the contents and format of the string.
|
|
24
|
+
* @example For example, the following value is valid:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <integer format='int64' />
|
|
27
|
+
* ```
|
|
28
|
+
* @see https://swagger.io/docs/specification/data-models/data-types/#numbers
|
|
29
|
+
* */
|
|
4
30
|
format?: IntegerFormats;
|
|
5
|
-
|
|
6
|
-
max?:
|
|
31
|
+
/** Validate the integer number value by maximum. */
|
|
32
|
+
max?: bigint | number;
|
|
33
|
+
/** Validate the integer number value by minimum. */
|
|
34
|
+
min?: bigint | number;
|
|
35
|
+
/**
|
|
36
|
+
* The `multipleOf` keyword is used to restrict the value to be a multiple of the specified number.
|
|
37
|
+
* @example For example, the following value is valid:
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <number multipleOf={2} />
|
|
40
|
+
* ```
|
|
41
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
|
|
42
|
+
* */
|
|
43
|
+
multipleOf?: bigint | number;
|
|
7
44
|
}
|
|
8
45
|
export declare const integer: HandlerPlugin;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { useProps } from '@innet/jsx';
|
|
3
2
|
import '../../../hooks/index.es6.js';
|
|
4
3
|
import '../../../utils/index.es6.js';
|
|
@@ -13,14 +12,35 @@ import { optional } from '../../../utils/rules/optional/optional.es6.js';
|
|
|
13
12
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
14
13
|
|
|
15
14
|
const integer = () => {
|
|
16
|
-
const
|
|
17
|
-
const schema = useSchemaType('integer',
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
const { default: defaultValue, example, examples, exclusiveMaximum, exclusiveMinimum, format = 'int32', max: max$1, min: min$1, multipleOf, values: values$1, ...props } = useProps() || {};
|
|
16
|
+
const schema = useSchemaType('integer', {
|
|
17
|
+
...props,
|
|
18
|
+
const: props.const !== undefined ? Number(props.const) : undefined,
|
|
19
|
+
default: defaultValue !== undefined ? Number(defaultValue) : undefined,
|
|
20
|
+
example: example !== undefined ? Number(example) : undefined,
|
|
21
|
+
examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
|
|
22
|
+
values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number),
|
|
23
|
+
});
|
|
24
|
+
if (schema) {
|
|
25
|
+
if (format) {
|
|
26
|
+
schema.format = format;
|
|
27
|
+
}
|
|
28
|
+
if (min$1 !== undefined) {
|
|
29
|
+
schema.minimum = Number(min$1);
|
|
30
|
+
}
|
|
31
|
+
if (max$1 !== undefined) {
|
|
32
|
+
schema.maximum = Number(max$1);
|
|
33
|
+
}
|
|
34
|
+
if (exclusiveMinimum) {
|
|
35
|
+
schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
|
|
36
|
+
}
|
|
37
|
+
if (exclusiveMaximum) {
|
|
38
|
+
schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
|
|
39
|
+
}
|
|
40
|
+
if (multipleOf !== undefined) {
|
|
41
|
+
schema.multipleOf = Number(multipleOf);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
const rules = [];
|
|
25
45
|
if (defaultValue !== undefined) {
|
|
26
46
|
rules.push(defaultTo(defaultValue));
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var jsx = require('@innet/jsx');
|
|
7
6
|
require('../../../hooks/index.js');
|
|
8
7
|
require('../../../utils/index.js');
|
|
@@ -17,14 +16,35 @@ var optional = require('../../../utils/rules/optional/optional.js');
|
|
|
17
16
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
18
17
|
|
|
19
18
|
const integer = () => {
|
|
20
|
-
const
|
|
21
|
-
const schema = useSchemaType.useSchemaType('integer',
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const { default: defaultValue, example, examples, exclusiveMaximum, exclusiveMinimum, format = 'int32', max: max$1, min: min$1, multipleOf, values: values$1, ...props } = jsx.useProps() || {};
|
|
20
|
+
const schema = useSchemaType.useSchemaType('integer', {
|
|
21
|
+
...props,
|
|
22
|
+
const: props.const !== undefined ? Number(props.const) : undefined,
|
|
23
|
+
default: defaultValue !== undefined ? Number(defaultValue) : undefined,
|
|
24
|
+
example: example !== undefined ? Number(example) : undefined,
|
|
25
|
+
examples: examples === null || examples === void 0 ? void 0 : examples.map(Number),
|
|
26
|
+
values: values$1 === null || values$1 === void 0 ? void 0 : values$1.map(Number),
|
|
27
|
+
});
|
|
28
|
+
if (schema) {
|
|
29
|
+
if (format) {
|
|
30
|
+
schema.format = format;
|
|
31
|
+
}
|
|
32
|
+
if (min$1 !== undefined) {
|
|
33
|
+
schema.minimum = Number(min$1);
|
|
34
|
+
}
|
|
35
|
+
if (max$1 !== undefined) {
|
|
36
|
+
schema.maximum = Number(max$1);
|
|
37
|
+
}
|
|
38
|
+
if (exclusiveMinimum) {
|
|
39
|
+
schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
|
|
40
|
+
}
|
|
41
|
+
if (exclusiveMaximum) {
|
|
42
|
+
schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
|
|
43
|
+
}
|
|
44
|
+
if (multipleOf !== undefined) {
|
|
45
|
+
schema.multipleOf = Number(multipleOf);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
28
48
|
const rules = [];
|
|
29
49
|
if (defaultValue !== undefined) {
|
|
30
50
|
rules.push(defaultTo.defaultTo(defaultValue));
|
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type ValuesSchemaProps } from '../../../types';
|
|
3
3
|
export interface NumberProps extends ValuesSchemaProps<number> {
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The `exclusiveMaximum` keyword is used to restrict the value to be less than the specified number.
|
|
6
|
+
* @example For example, the following value is valid:
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <number exclusiveMaximum={10} />
|
|
9
|
+
* ```
|
|
10
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
|
|
11
|
+
* */
|
|
12
|
+
exclusiveMaximum?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The `exclusiveMinimum` keyword is used to restrict the value to be greater than the specified number.
|
|
15
|
+
* @example For example, the following value is valid:
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <number exclusiveMinimum={10} />
|
|
18
|
+
* ```
|
|
19
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
|
|
20
|
+
* */
|
|
21
|
+
exclusiveMinimum?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* An optional format modifier serves as a hint at the contents and format of the string.
|
|
24
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
|
|
25
|
+
* */
|
|
26
|
+
format?: 'double' | 'float' | (string & {});
|
|
6
27
|
/** Validate the number value by maximum. */
|
|
7
28
|
max?: number;
|
|
29
|
+
/** Validate the number value by minimum. */
|
|
30
|
+
min?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The `multipleOf` keyword is used to restrict the value to be a multiple of the specified number.
|
|
33
|
+
* @example For example, the following value is valid:
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <number multipleOf={2} />
|
|
36
|
+
* ```
|
|
37
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#numbers
|
|
38
|
+
* */
|
|
39
|
+
multipleOf?: number;
|
|
8
40
|
}
|
|
9
41
|
export declare const number: HandlerPlugin;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { useProps } from '@innet/jsx';
|
|
3
2
|
import '../../../hooks/index.es6.js';
|
|
4
3
|
import '../../../hooks/useParentRule/index.es6.js';
|
|
@@ -14,12 +13,28 @@ import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
|
14
13
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
15
14
|
|
|
16
15
|
const number = () => {
|
|
17
|
-
const
|
|
16
|
+
const { exclusiveMaximum, exclusiveMinimum, format, max: max$1, min: min$1, multipleOf, ...props } = useProps() || {};
|
|
18
17
|
const schema = useSchemaType('number', props);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
if (schema) {
|
|
19
|
+
if (format !== undefined) {
|
|
20
|
+
schema.format = format;
|
|
21
|
+
}
|
|
22
|
+
if (min$1 !== undefined) {
|
|
23
|
+
schema.minimum = min$1;
|
|
24
|
+
}
|
|
25
|
+
if (max$1 !== undefined) {
|
|
26
|
+
schema.maximum = max$1;
|
|
27
|
+
}
|
|
28
|
+
if (exclusiveMinimum) {
|
|
29
|
+
schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
|
|
30
|
+
}
|
|
31
|
+
if (exclusiveMaximum) {
|
|
32
|
+
schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
|
|
33
|
+
}
|
|
34
|
+
if (multipleOf !== undefined) {
|
|
35
|
+
schema.multipleOf = Number(multipleOf);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
const rules = [];
|
|
24
39
|
if (props.default !== undefined) {
|
|
25
40
|
rules.push(defaultTo(props.default));
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var jsx = require('@innet/jsx');
|
|
7
6
|
require('../../../hooks/index.js');
|
|
8
7
|
require('../../../hooks/useParentRule/index.js');
|
|
@@ -18,12 +17,28 @@ var useRule = require('../../../hooks/useRule/useRule.js');
|
|
|
18
17
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
19
18
|
|
|
20
19
|
const number = () => {
|
|
21
|
-
const
|
|
20
|
+
const { exclusiveMaximum, exclusiveMinimum, format, max: max$1, min: min$1, multipleOf, ...props } = jsx.useProps() || {};
|
|
22
21
|
const schema = useSchemaType.useSchemaType('number', props);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
if (schema) {
|
|
23
|
+
if (format !== undefined) {
|
|
24
|
+
schema.format = format;
|
|
25
|
+
}
|
|
26
|
+
if (min$1 !== undefined) {
|
|
27
|
+
schema.minimum = min$1;
|
|
28
|
+
}
|
|
29
|
+
if (max$1 !== undefined) {
|
|
30
|
+
schema.maximum = max$1;
|
|
31
|
+
}
|
|
32
|
+
if (exclusiveMinimum) {
|
|
33
|
+
schema.exclusiveMinimum = typeof exclusiveMinimum === 'boolean' ? exclusiveMinimum : Number(exclusiveMinimum);
|
|
34
|
+
}
|
|
35
|
+
if (exclusiveMaximum) {
|
|
36
|
+
schema.exclusiveMaximum = typeof exclusiveMaximum === 'boolean' ? exclusiveMaximum : Number(exclusiveMaximum);
|
|
37
|
+
}
|
|
38
|
+
if (multipleOf !== undefined) {
|
|
39
|
+
schema.multipleOf = Number(multipleOf);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
const rules = [];
|
|
28
43
|
if (props.default !== undefined) {
|
|
29
44
|
rules.push(defaultTo.defaultTo(props.default));
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { useNewHandler, innet } from 'innet';
|
|
2
|
+
import { useProps } from '@innet/jsx';
|
|
3
3
|
import '../../../hooks/index.es6.js';
|
|
4
4
|
import '../../../hooks/useParentRule/index.es6.js';
|
|
5
5
|
import '../../../utils/index.es6.js';
|
|
6
6
|
import { useBlock } from '../../../hooks/useBlock/useBlock.es6.js';
|
|
7
7
|
import { useApi } from '../../../hooks/useApi/useApi.es6.js';
|
|
8
8
|
import { useSchemaType } from '../../../hooks/useSchemaType/useSchemaType.es6.js';
|
|
9
|
+
import { objectSchemaContext } from '../../../hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js';
|
|
9
10
|
import { schemaContext } from '../../../hooks/useSchemaContext/useSchemaContext.es6.js';
|
|
10
11
|
import { parentRuleContext, useParentRule } from '../../../hooks/useParentRule/useParentRule.es6.js';
|
|
11
12
|
import { defaultTo } from '../../../utils/rules/defaultTo/defaultTo.es6.js';
|
|
@@ -13,28 +14,33 @@ import { objectOf } from '../../../utils/rules/objectOf/objectOf.es6.js';
|
|
|
13
14
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
14
15
|
import { useRule, ruleContext } from '../../../hooks/useRule/useRule.es6.js';
|
|
15
16
|
import { objectRuleContext } from '../../../hooks/useObjectRule/useObjectRule.es6.js';
|
|
17
|
+
import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
|
|
18
|
+
import { getSafeSchema } from '../../../utils/getSafeSchema/getSafeSchema.es6.js';
|
|
16
19
|
|
|
17
20
|
const object = () => {
|
|
18
21
|
useBlock('path');
|
|
19
|
-
const children =
|
|
20
|
-
const props = useProps() || {};
|
|
22
|
+
const { children, ...props } = useProps();
|
|
21
23
|
const { refRules } = useApi();
|
|
22
24
|
const schema = useSchemaType('object', props);
|
|
23
25
|
const handler = useNewHandler();
|
|
24
26
|
if (schema) {
|
|
25
|
-
|
|
27
|
+
schema.additionalProperties = {};
|
|
28
|
+
objectSchemaContext.set(handler, schema);
|
|
29
|
+
schemaContext.set(handler, schema.additionalProperties);
|
|
26
30
|
parentRuleContext.reset(handler);
|
|
27
31
|
const rules = [];
|
|
28
32
|
const rulesMap = {};
|
|
29
33
|
if ((props === null || props === void 0 ? void 0 : props.default) !== undefined) {
|
|
30
34
|
rules.push(defaultTo(props.default));
|
|
31
35
|
}
|
|
36
|
+
let childRule = v => v;
|
|
37
|
+
const restRule = (value, data) => childRule(value, data);
|
|
32
38
|
if ((props === null || props === void 0 ? void 0 : props.default) !== undefined) {
|
|
33
|
-
rules.push(objectOf(rulesMap));
|
|
39
|
+
rules.push(objectOf(rulesMap, restRule));
|
|
34
40
|
}
|
|
35
41
|
else {
|
|
36
42
|
const parentRule = useParentRule();
|
|
37
|
-
rules.push(parentRule(objectOf(rulesMap)));
|
|
43
|
+
rules.push(parentRule(objectOf(rulesMap, restRule)));
|
|
38
44
|
}
|
|
39
45
|
const rule = pipe(...rules);
|
|
40
46
|
if (props.ref) {
|
|
@@ -42,9 +48,17 @@ const object = () => {
|
|
|
42
48
|
}
|
|
43
49
|
useRule(rule);
|
|
44
50
|
objectRuleContext.set(handler, rulesMap);
|
|
45
|
-
ruleContext.set(handler,
|
|
51
|
+
ruleContext.set(handler, rule => {
|
|
52
|
+
childRule = rule;
|
|
53
|
+
});
|
|
46
54
|
parentRuleContext.reset(handler);
|
|
47
55
|
innet(children, handler);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const safeSchema = getSafeSchema(schema);
|
|
58
|
+
if (!Object.keys(safeSchema.additionalProperties).length) {
|
|
59
|
+
delete safeSchema.additionalProperties;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
48
62
|
}
|
|
49
63
|
else if (props.ref) {
|
|
50
64
|
useRule(refRules[props.ref]);
|
|
@@ -10,6 +10,7 @@ require('../../../utils/index.js');
|
|
|
10
10
|
var useBlock = require('../../../hooks/useBlock/useBlock.js');
|
|
11
11
|
var useApi = require('../../../hooks/useApi/useApi.js');
|
|
12
12
|
var useSchemaType = require('../../../hooks/useSchemaType/useSchemaType.js');
|
|
13
|
+
var useObjectSchemaContext = require('../../../hooks/useObjectSchemaContext/useObjectSchemaContext.js');
|
|
13
14
|
var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext.js');
|
|
14
15
|
var useParentRule = require('../../../hooks/useParentRule/useParentRule.js');
|
|
15
16
|
var defaultTo = require('../../../utils/rules/defaultTo/defaultTo.js');
|
|
@@ -17,32 +18,33 @@ var objectOf = require('../../../utils/rules/objectOf/objectOf.js');
|
|
|
17
18
|
var pipe = require('../../../utils/rules/pipe/pipe.js');
|
|
18
19
|
var useRule = require('../../../hooks/useRule/useRule.js');
|
|
19
20
|
var useObjectRule = require('../../../hooks/useObjectRule/useObjectRule.js');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
21
|
+
var useEffect = require('../../../hooks/useEffect/useEffect.js');
|
|
22
|
+
var getSafeSchema = require('../../../utils/getSafeSchema/getSafeSchema.js');
|
|
24
23
|
|
|
25
24
|
const object = () => {
|
|
26
25
|
useBlock.useBlock('path');
|
|
27
|
-
const children = jsx.
|
|
28
|
-
const props = jsx.useProps() || {};
|
|
26
|
+
const { children, ...props } = jsx.useProps();
|
|
29
27
|
const { refRules } = useApi.useApi();
|
|
30
28
|
const schema = useSchemaType.useSchemaType('object', props);
|
|
31
29
|
const handler = innet.useNewHandler();
|
|
32
30
|
if (schema) {
|
|
33
|
-
|
|
31
|
+
schema.additionalProperties = {};
|
|
32
|
+
useObjectSchemaContext.objectSchemaContext.set(handler, schema);
|
|
33
|
+
useSchemaContext.schemaContext.set(handler, schema.additionalProperties);
|
|
34
34
|
useParentRule.parentRuleContext.reset(handler);
|
|
35
35
|
const rules = [];
|
|
36
36
|
const rulesMap = {};
|
|
37
37
|
if ((props === null || props === void 0 ? void 0 : props.default) !== undefined) {
|
|
38
38
|
rules.push(defaultTo.defaultTo(props.default));
|
|
39
39
|
}
|
|
40
|
+
let childRule = v => v;
|
|
41
|
+
const restRule = (value, data) => childRule(value, data);
|
|
40
42
|
if ((props === null || props === void 0 ? void 0 : props.default) !== undefined) {
|
|
41
|
-
rules.push(objectOf.objectOf(rulesMap));
|
|
43
|
+
rules.push(objectOf.objectOf(rulesMap, restRule));
|
|
42
44
|
}
|
|
43
45
|
else {
|
|
44
46
|
const parentRule = useParentRule.useParentRule();
|
|
45
|
-
rules.push(parentRule(objectOf.objectOf(rulesMap)));
|
|
47
|
+
rules.push(parentRule(objectOf.objectOf(rulesMap, restRule)));
|
|
46
48
|
}
|
|
47
49
|
const rule = pipe.pipe(...rules);
|
|
48
50
|
if (props.ref) {
|
|
@@ -50,9 +52,17 @@ const object = () => {
|
|
|
50
52
|
}
|
|
51
53
|
useRule.useRule(rule);
|
|
52
54
|
useObjectRule.objectRuleContext.set(handler, rulesMap);
|
|
53
|
-
useRule.ruleContext.set(handler,
|
|
55
|
+
useRule.ruleContext.set(handler, rule => {
|
|
56
|
+
childRule = rule;
|
|
57
|
+
});
|
|
54
58
|
useParentRule.parentRuleContext.reset(handler);
|
|
55
|
-
|
|
59
|
+
innet.innet(children, handler);
|
|
60
|
+
useEffect.useEffect(() => {
|
|
61
|
+
const safeSchema = getSafeSchema.getSafeSchema(schema);
|
|
62
|
+
if (!Object.keys(safeSchema.additionalProperties).length) {
|
|
63
|
+
delete safeSchema.additionalProperties;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
56
66
|
}
|
|
57
67
|
else if (props.ref) {
|
|
58
68
|
useRule.useRule(refRules[props.ref]);
|
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type ValuesSchemaProps } from '../../../types';
|
|
3
3
|
export interface StringProps extends ValuesSchemaProps<string> {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* An optional format modifier serves as a hint at the contents and format of the string.
|
|
6
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
|
|
7
|
+
* */
|
|
8
|
+
format?: 'binary' | 'byte' | 'date' | 'date-time' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'password' | 'uri' | 'uuid' | (string & {});
|
|
9
|
+
/**
|
|
10
|
+
* String length can be restricted using `min` and `max`.
|
|
11
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
|
|
12
|
+
* */
|
|
5
13
|
max?: number;
|
|
6
|
-
|
|
14
|
+
/**
|
|
15
|
+
* String length can be restricted using `min` and `max`.
|
|
16
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
|
|
17
|
+
* */
|
|
18
|
+
min?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The pattern keyword lets you define a regular expression template for the string value.
|
|
21
|
+
* Only the values that match this template will be accepted.
|
|
22
|
+
* The regular expression syntax used is from JavaScript (more specifically, ECMA 262).
|
|
23
|
+
* Regular expressions are case-sensitive, that is, [a-z] and [A-Z] are different expressions.
|
|
24
|
+
* @example For example, the following pattern matches a Social Security Number (SSN) in the 123-45-6789 format:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <string pattern='^\d{3}-\d{2}-\d{4}$' />
|
|
27
|
+
* ```
|
|
28
|
+
* @see https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings
|
|
29
|
+
* */
|
|
30
|
+
pattern?: RegExp | string;
|
|
31
|
+
/**
|
|
32
|
+
* The `patternId` keyword is used to reference a pattern from the OpenAPI specification.
|
|
33
|
+
* */
|
|
7
34
|
patternId?: string;
|
|
8
35
|
}
|
|
9
36
|
export declare const string: HandlerPlugin;
|
|
@@ -1,50 +1,69 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { useProps } from '@innet/jsx';
|
|
3
2
|
import '../../../hooks/index.es6.js';
|
|
4
3
|
import '../../../hooks/useParentRule/index.es6.js';
|
|
5
4
|
import '../../../utils/index.es6.js';
|
|
5
|
+
import { useApi } from '../../../hooks/useApi/useApi.es6.js';
|
|
6
6
|
import { useSchemaType } from '../../../hooks/useSchemaType/useSchemaType.es6.js';
|
|
7
7
|
import { defaultTo } from '../../../utils/rules/defaultTo/defaultTo.es6.js';
|
|
8
8
|
import { values } from '../../../utils/rules/values/values.es6.js';
|
|
9
9
|
import { minLength } from '../../../utils/rules/minLength/minLength.es6.js';
|
|
10
10
|
import { maxLength } from '../../../utils/rules/maxLength/maxLength.es6.js';
|
|
11
11
|
import { pattern } from '../../../utils/rules/pattern/pattern.es6.js';
|
|
12
|
-
import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
13
12
|
import { pipe } from '../../../utils/rules/pipe/pipe.es6.js';
|
|
13
|
+
import { useRule } from '../../../hooks/useRule/useRule.es6.js';
|
|
14
14
|
import { useParentRule } from '../../../hooks/useParentRule/useParentRule.es6.js';
|
|
15
15
|
|
|
16
16
|
const string = () => {
|
|
17
|
-
const
|
|
17
|
+
const { format, max, min, pattern: pattern$1, patternId, ...props } = useProps() || {};
|
|
18
|
+
const { refRules } = useApi();
|
|
18
19
|
const schema = useSchemaType('string', props);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
if (schema) {
|
|
21
|
+
const rules = [];
|
|
22
|
+
if (format !== undefined) {
|
|
23
|
+
schema.format = format;
|
|
24
|
+
}
|
|
25
|
+
if (props.default !== undefined) {
|
|
26
|
+
rules.push(defaultTo(props.default));
|
|
27
|
+
}
|
|
28
|
+
rules.push(String);
|
|
29
|
+
if (props.values) {
|
|
30
|
+
rules.push(values(props.values));
|
|
31
|
+
}
|
|
32
|
+
if (format !== undefined) {
|
|
33
|
+
schema.format = format;
|
|
34
|
+
}
|
|
35
|
+
if (min !== undefined) {
|
|
36
|
+
schema.minLength = min;
|
|
37
|
+
rules.push(minLength(min));
|
|
38
|
+
}
|
|
39
|
+
if (max !== undefined) {
|
|
40
|
+
schema.maxLength = max;
|
|
41
|
+
rules.push(maxLength(max));
|
|
42
|
+
}
|
|
43
|
+
if (pattern$1 !== undefined) {
|
|
44
|
+
schema.pattern = String(pattern$1);
|
|
45
|
+
rules.push(pattern(pattern$1, patternId));
|
|
46
|
+
}
|
|
47
|
+
const rule = pipe(...rules);
|
|
48
|
+
if (props.ref) {
|
|
49
|
+
refRules[props.ref] = rule;
|
|
50
|
+
}
|
|
51
|
+
if (props.default !== undefined) {
|
|
52
|
+
useRule(rule);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const parentRule = useParentRule();
|
|
56
|
+
useRule(parentRule(rule));
|
|
57
|
+
}
|
|
44
58
|
}
|
|
45
|
-
else {
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
else if (props.ref) {
|
|
60
|
+
if (props.default !== undefined) {
|
|
61
|
+
useRule(refRules[props.ref]);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const parentRule = useParentRule();
|
|
65
|
+
useRule(parentRule(refRules[props.ref]));
|
|
66
|
+
}
|
|
48
67
|
}
|
|
49
68
|
};
|
|
50
69
|
|