@innet/server 2.0.0-alpha.3 → 2.0.0-alpha.30
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 +1375 -541
- package/handler/handler.d.ts +19 -13
- package/handler/handler.es6.js +17 -11
- package/handler/handler.js +17 -11
- package/hooks/index.d.ts +6 -0
- package/hooks/index.es6.js +6 -0
- package/hooks/index.js +6 -0
- 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/index.d.ts +1 -0
- package/hooks/useClientIp/index.es6.js +1 -0
- package/hooks/useClientIp/index.js +9 -0
- package/hooks/useClientIp/useClientIp.d.ts +1 -0
- package/hooks/useClientIp/useClientIp.es6.js +9 -0
- package/hooks/useClientIp/useClientIp.js +13 -0
- package/hooks/useComponentName/useComponentName.d.ts +1 -1
- 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/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/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 -4
- package/hooks/useRequest/useRequest.es6.js +4 -4
- package/hooks/useRequest/useRequest.js +3 -4
- package/hooks/useResponse/index.es6.js +1 -1
- package/hooks/useResponse/index.js +0 -1
- package/hooks/useResponse/useResponse.d.ts +1 -4
- 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 +5 -6
- package/hooks/useSchemaType/useSchemaType.js +5 -6
- package/hooks/useServer/useServer.d.ts +2 -1
- 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.es6.js +17 -8
- package/index.js +34 -12
- package/package.json +2 -2
- package/plugins/main/api/api.d.ts +10 -8
- package/plugins/main/api/api.es6.js +53 -55
- package/plugins/main/api/api.js +53 -55
- package/plugins/main/contact/contact.d.ts +2 -2
- package/plugins/main/endpoint/endpoint.d.ts +15 -15
- package/plugins/main/endpoint/endpoint.es6.js +7 -4
- package/plugins/main/endpoint/endpoint.js +7 -4
- package/plugins/main/host/host.d.ts +5 -5
- package/plugins/main/index.d.ts +2 -2
- package/plugins/main/index.es6.js +2 -2
- package/plugins/main/index.js +2 -2
- package/plugins/main/license/license.d.ts +5 -5
- package/plugins/main/param/param.d.ts +11 -11
- package/plugins/main/param/param.es6.js +3 -3
- package/plugins/main/param/param.js +3 -3
- 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/{utils/dev/dev.js → main/preset/preset.js} +9 -6
- 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 -2
- package/plugins/main/response/response.es6.js +18 -10
- package/plugins/main/response/response.js +18 -9
- 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 +5 -5
- package/plugins/main/server/server.es6.js +36 -10
- package/plugins/main/server/server.js +36 -10
- package/plugins/main/tag/tag.d.ts +2 -2
- package/plugins/main/tag/tag.es6.js +5 -2
- package/plugins/main/tag/tag.js +5 -2
- package/plugins/main/variable/variable.d.ts +5 -5
- package/plugins/main/variable/variable.es6.js +3 -1
- package/plugins/main/variable/variable.js +3 -1
- package/plugins/request/cms/cms.es6.js +2 -2
- package/plugins/request/cms/cms.js +2 -2
- package/plugins/request/cookie/cookie.es6.js +3 -19
- package/plugins/request/cookie/cookie.js +3 -23
- package/plugins/request/error/error.d.ts +40 -40
- package/plugins/request/error/error.es6.js +45 -42
- package/plugins/request/error/error.js +45 -42
- package/plugins/request/file/file.es6.js +2 -3
- 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/proxy/proxy.d.ts +4 -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 +7 -6
- package/plugins/request/success/success.es6.js +21 -10
- package/plugins/request/success/success.js +21 -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/binary/binary.d.ts +3 -3
- package/plugins/schema/boolean/boolean.es6.js +2 -4
- package/plugins/schema/boolean/boolean.js +1 -3
- package/plugins/schema/date/date.d.ts +1 -1
- package/plugins/schema/date/date.es6.js +3 -3
- package/plugins/schema/date/date.js +3 -3
- package/plugins/schema/field/field.d.ts +1 -0
- package/plugins/schema/field/field.es6.js +7 -6
- package/plugins/schema/field/field.js +6 -5
- package/plugins/schema/index.d.ts +1 -0
- package/plugins/schema/index.es6.js +1 -0
- package/plugins/schema/index.js +1 -0
- package/plugins/schema/integer/integer.d.ts +3 -3
- package/plugins/schema/integer/integer.es6.js +1 -1
- package/plugins/schema/integer/integer.js +1 -1
- package/plugins/schema/number/number.d.ts +2 -2
- package/plugins/schema/number/number.es6.js +1 -1
- package/plugins/schema/number/number.js +1 -1
- package/plugins/schema/object/object.es6.js +17 -4
- package/plugins/schema/object/object.js +17 -4
- package/plugins/schema/string/string.d.ts +2 -2
- package/plugins/schema/string/string.es6.js +44 -30
- package/plugins/schema/string/string.js +44 -30
- package/plugins/utils/blacklist/blacklist.d.ts +4 -0
- package/plugins/utils/blacklist/blacklist.es6.js +18 -0
- package/plugins/utils/blacklist/blacklist.js +22 -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 +3 -3
- package/plugins/utils/dts/dts.es6.js +6 -25
- package/plugins/utils/dts/dts.js +5 -29
- package/plugins/utils/env/env.d.ts +6 -0
- package/plugins/utils/env/env.es6.js +11 -0
- package/plugins/utils/{prod/prod.js → env/env.js} +4 -3
- 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 +4 -2
- package/plugins/utils/index.es6.js +4 -2
- package/plugins/utils/index.js +4 -2
- package/plugins/utils/protection/index.d.ts +1 -0
- package/plugins/utils/protection/index.es6.js +1 -0
- package/plugins/utils/protection/index.js +9 -0
- package/plugins/utils/protection/protection.d.ts +8 -0
- package/plugins/utils/protection/protection.es6.js +36 -0
- package/plugins/utils/protection/protection.js +40 -0
- package/plugins/utils/swagger/swagger.es6.js +10 -12
- package/plugins/utils/swagger/swagger.js +10 -12
- 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 +4 -0
- package/plugins/utils/whitelist/whitelist.es6.js +20 -0
- package/plugins/utils/whitelist/whitelist.js +24 -0
- package/types.d.ts +15 -23
- 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 +17 -14
- package/utils/action/Action.es6.js +102 -78
- package/utils/action/Action.js +102 -78
- 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/generateTypes/generateTypes.d.ts +3 -0
- package/utils/generateTypes/generateTypes.es6.js +157 -0
- package/utils/generateTypes/generateTypes.js +162 -0
- package/utils/generateTypes/index.d.ts +1 -0
- package/utils/generateTypes/index.es6.js +1 -0
- package/utils/generateTypes/index.js +10 -0
- 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/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 +1 -0
- package/utils/index.es6.js +1 -0
- package/utils/index.js +1 -0
- package/utils/rules/binaryAccept/binaryAccept.es6.js +2 -2
- package/utils/rules/binaryAccept/binaryAccept.js +2 -2
- package/utils/rules/dateTo/dateTo.d.ts +1 -1
- package/utils/rules/helpers.d.ts +1 -1
- package/utils/rules/index.d.ts +0 -1
- package/utils/rules/index.es6.js +0 -1
- package/utils/rules/index.js +0 -1
- package/utils/rules/int/int.es6.js +2 -2
- package/utils/rules/int/int.js +2 -2
- package/utils/rules/max/max.d.ts +1 -1
- package/utils/rules/max/max.es6.js +3 -3
- package/utils/rules/max/max.js +3 -3
- package/utils/rules/maxBin/maxBin.es6.js +2 -2
- package/utils/rules/maxBin/maxBin.js +2 -2
- package/utils/rules/maxDate/maxDate.es6.js +1 -1
- package/utils/rules/maxDate/maxDate.js +1 -1
- package/utils/rules/maxLength/maxLength.es6.js +2 -2
- package/utils/rules/maxLength/maxLength.js +2 -2
- package/utils/rules/min/min.d.ts +1 -1
- package/utils/rules/min/min.es6.js +3 -3
- package/utils/rules/min/min.js +3 -3
- package/utils/rules/minBin/minBin.es6.js +2 -2
- package/utils/rules/minBin/minBin.js +2 -2
- package/utils/rules/minDate/minDate.es6.js +1 -1
- package/utils/rules/minDate/minDate.js +1 -1
- package/utils/rules/minLength/minLength.es6.js +2 -2
- package/utils/rules/minLength/minLength.js +2 -2
- package/utils/rules/objectOf/objectOf.d.ts +1 -1
- package/utils/rules/objectOf/objectOf.es6.js +15 -2
- package/utils/rules/objectOf/objectOf.js +15 -2
- package/utils/rules/pattern/pattern.d.ts +1 -1
- package/utils/rules/pattern/pattern.es6.js +2 -1
- package/utils/rules/pattern/pattern.js +2 -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/partners/EditPartner/EditPartner.d.ts +0 -1
- package/example/requests/partners/EditPartner/index.d.ts +0 -1
- package/example/requests/partners/GetPartner/GetPartner.d.ts +0 -1
- package/example/requests/partners/GetPartner/index.d.ts +0 -1
- package/example/requests/partners/GetPartners/GetPartners.d.ts +0 -1
- package/example/requests/partners/GetPartners/index.d.ts +0 -1
- package/example/requests/partners/index.d.ts +0 -3
- package/example/schemas/address/AddressSchema/AddressSchema.d.ts +0 -1
- package/example/schemas/address/AddressSchema/index.d.ts +0 -1
- package/example/schemas/address/index.d.ts +0 -1
- package/example/schemas/app/ListSchema/ListSchema.d.ts +0 -1
- package/example/schemas/app/ListSchema/index.d.ts +0 -1
- package/example/schemas/app/index.d.ts +0 -1
- package/example/schemas/index.d.ts +0 -4
- package/example/schemas/location/LocationSchema/LocationSchema.d.ts +0 -1
- package/example/schemas/location/LocationSchema/index.d.ts +0 -1
- package/example/schemas/location/index.d.ts +0 -1
- package/example/schemas/partner/EditPartnerSchema/EditPartnerSchema.d.ts +0 -1
- package/example/schemas/partner/EditPartnerSchema/index.d.ts +0 -1
- package/example/schemas/partner/PartnerSchema/PartnerSchema.d.ts +0 -1
- package/example/schemas/partner/PartnerSchema/index.d.ts +0 -1
- package/example/schemas/partner/index.d.ts +0 -2
- package/example/tags/Partner/Partner.d.ts +0 -1
- package/example/tags/Partner/index.d.ts +0 -1
- package/example/tags/index.d.ts +0 -1
- 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/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/utils/decorators/once/once.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,52 +1,58 @@
|
|
|
1
1
|
import { __rest, __awaiter } from 'tslib';
|
|
2
2
|
import innet, { useNewHandler, useApp } from 'innet';
|
|
3
|
-
import { onDestroy } from 'watch-state';
|
|
4
3
|
import '../../../hooks/index.es6.js';
|
|
5
4
|
import '../../../utils/index.es6.js';
|
|
6
5
|
import '../../../utils/rules/index.es6.js';
|
|
7
|
-
import {
|
|
6
|
+
import { serverPlugins } from '../../../hooks/useServerPlugins/useServerPlugins.es6.js';
|
|
8
7
|
import { apiContext } from '../../../hooks/useApi/useApi.es6.js';
|
|
9
|
-
import {
|
|
8
|
+
import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
|
|
9
|
+
import { useAction, actionContext } from '../../../hooks/useAction/useAction.es6.js';
|
|
10
10
|
import { JSONString } from '../../../utils/JSONString/JSONString.es6.js';
|
|
11
11
|
import { RulesError } from '../../../utils/rules/helpers.es6.js';
|
|
12
|
-
import { responseContext } from '../../../hooks/useResponse/useResponse.es6.js';
|
|
13
|
-
import { requestContext } from '../../../hooks/useRequest/useRequest.es6.js';
|
|
14
12
|
import { paramsContext } from '../../../hooks/useParams/useParams.es6.js';
|
|
15
|
-
import { actionContext } from '../../../hooks/useAction/useAction.es6.js';
|
|
16
13
|
|
|
17
14
|
const api = () => {
|
|
18
|
-
var _a;
|
|
19
15
|
const handler = useNewHandler();
|
|
20
|
-
const { props = {},
|
|
21
|
-
const {
|
|
22
|
-
const
|
|
23
|
-
const info = Object.assign(Object.assign({}, rest), { version: (_a = rest.version) !== null && _a !== void 0 ? _a : '0.0.0', title });
|
|
16
|
+
const { children, props = {}, } = useApp();
|
|
17
|
+
const { exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = __rest(props, ["exclude", "include", "prefix", "title", "version"]);
|
|
18
|
+
const info = Object.assign(Object.assign({}, rest), { title, version });
|
|
24
19
|
const endpoints = {};
|
|
25
20
|
const docs = {
|
|
26
|
-
openapi: '3.1.0',
|
|
27
21
|
info,
|
|
22
|
+
openapi: '3.1.0',
|
|
28
23
|
paths: {},
|
|
29
24
|
};
|
|
30
|
-
const
|
|
31
|
-
const context = { docs, endpoints, prefix,
|
|
25
|
+
const plugins = new Set();
|
|
26
|
+
const context = { docs, endpoints, prefix, refRules: {} };
|
|
27
|
+
const condition = (action) => {
|
|
28
|
+
const path = action.parsedUrl.path;
|
|
29
|
+
const url = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
30
|
+
if (!url.startsWith(prefix) || (exclude === null || exclude === void 0 ? void 0 : exclude.test(url))) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (include && !include.test(url)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
serverPlugins.set(handler, plugins);
|
|
32
39
|
apiContext.set(handler, context);
|
|
33
|
-
|
|
34
|
-
var _b, _c, _d, _e, _f
|
|
35
|
-
|
|
40
|
+
useServerPlugin(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f;
|
|
42
|
+
const action = useAction();
|
|
43
|
+
if (!condition(action))
|
|
36
44
|
return;
|
|
37
|
-
const
|
|
45
|
+
const actionHandler = useNewHandler();
|
|
38
46
|
const path = action.parsedUrl.path;
|
|
39
47
|
const url = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
48
|
+
const { req, res, } = action;
|
|
40
49
|
if (url === (prefix || '')) {
|
|
41
50
|
res.setHeader('Content-Type', 'application/json');
|
|
42
51
|
res.write(JSONString(docs));
|
|
43
52
|
res.end();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (!url.startsWith(prefix)) {
|
|
47
|
-
return;
|
|
53
|
+
return null;
|
|
48
54
|
}
|
|
49
|
-
const method = ((
|
|
55
|
+
const method = ((_b = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'get');
|
|
50
56
|
const rawSplitPath = url.slice(prefix.length).split('/').slice(1);
|
|
51
57
|
const splitPath = rawSplitPath.at(-1) ? rawSplitPath : rawSplitPath.slice(0, -1);
|
|
52
58
|
const endpoint = endpoints[method];
|
|
@@ -81,8 +87,8 @@ const api = () => {
|
|
|
81
87
|
if (e instanceof RulesError) {
|
|
82
88
|
res.statusCode = 400;
|
|
83
89
|
res.write(JSONString({
|
|
84
|
-
error: 'requestValidation',
|
|
85
90
|
data: Object.assign(Object.assign({}, e.data), { in: key }),
|
|
91
|
+
error: 'requestValidation',
|
|
86
92
|
}));
|
|
87
93
|
res.end();
|
|
88
94
|
}
|
|
@@ -90,8 +96,8 @@ const api = () => {
|
|
|
90
96
|
console.error(e);
|
|
91
97
|
res.statusCode = 500;
|
|
92
98
|
res.write(JSONString({
|
|
93
|
-
error: 'unknown',
|
|
94
99
|
data: { in: key },
|
|
100
|
+
error: 'unknown',
|
|
95
101
|
}));
|
|
96
102
|
res.end();
|
|
97
103
|
}
|
|
@@ -120,32 +126,34 @@ const api = () => {
|
|
|
120
126
|
if (checkActionRules(bodyRules, 'body'))
|
|
121
127
|
return true;
|
|
122
128
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
paramsContext.set(actionHandler, params);
|
|
130
|
+
for (const plugin of runEndpoint.plugins) {
|
|
131
|
+
const result = yield plugin();
|
|
132
|
+
if (result === undefined)
|
|
133
|
+
continue;
|
|
134
|
+
innet(result, actionHandler);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
129
137
|
return true;
|
|
130
138
|
});
|
|
131
139
|
}
|
|
132
|
-
if ((
|
|
133
|
-
if (!(yield run((
|
|
140
|
+
if ((_d = (_c = currentEndpoint.static) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.plugins) {
|
|
141
|
+
if (!(yield run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params)))
|
|
134
142
|
continue;
|
|
135
|
-
return;
|
|
143
|
+
return null;
|
|
136
144
|
}
|
|
137
145
|
if (currentEndpoint.dynamic) {
|
|
138
146
|
for (const dynamicEndpoint of currentEndpoint.dynamic) {
|
|
139
|
-
if (dynamicEndpoint.
|
|
147
|
+
if (dynamicEndpoint.plugins) {
|
|
140
148
|
if (!(yield run(dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key }))))
|
|
141
149
|
continue;
|
|
142
|
-
return;
|
|
150
|
+
return null;
|
|
143
151
|
}
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
154
|
break;
|
|
147
155
|
}
|
|
148
|
-
if ((
|
|
156
|
+
if ((_f = currentEndpoint.static) === null || _f === void 0 ? void 0 : _f[key]) {
|
|
149
157
|
endpointQueue.push([deep + 1, currentEndpoint.static[key], params]);
|
|
150
158
|
}
|
|
151
159
|
if (currentEndpoint.dynamic) {
|
|
@@ -154,26 +162,16 @@ const api = () => {
|
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
|
-
for (const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const newHandler = Object.create(context.fallback.handler);
|
|
163
|
-
responseContext.set(newHandler, res);
|
|
164
|
-
requestContext.set(newHandler, req);
|
|
165
|
+
for (const plugin of plugins) {
|
|
166
|
+
const result = yield plugin();
|
|
167
|
+
if (result === undefined)
|
|
168
|
+
continue;
|
|
169
|
+
const newHandler = Object.create(handler);
|
|
165
170
|
actionContext.set(newHandler, action);
|
|
166
|
-
innet(
|
|
167
|
-
|
|
168
|
-
else {
|
|
169
|
-
res.statusCode = 404;
|
|
170
|
-
res.end();
|
|
171
|
+
innet(result, newHandler);
|
|
172
|
+
return null;
|
|
171
173
|
}
|
|
172
|
-
});
|
|
173
|
-
server.on('request', listener);
|
|
174
|
-
onDestroy(() => {
|
|
175
|
-
server.off('request', listener);
|
|
176
|
-
});
|
|
174
|
+
}));
|
|
177
175
|
innet(children, handler);
|
|
178
176
|
};
|
|
179
177
|
|
package/plugins/main/api/api.js
CHANGED
|
@@ -4,57 +4,63 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var innet = require('innet');
|
|
7
|
-
var watchState = require('watch-state');
|
|
8
7
|
require('../../../hooks/index.js');
|
|
9
8
|
require('../../../utils/index.js');
|
|
10
9
|
require('../../../utils/rules/index.js');
|
|
11
|
-
var
|
|
10
|
+
var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
|
|
12
11
|
var useApi = require('../../../hooks/useApi/useApi.js');
|
|
13
|
-
var
|
|
12
|
+
var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
|
|
13
|
+
var useAction = require('../../../hooks/useAction/useAction.js');
|
|
14
14
|
var JSONString = require('../../../utils/JSONString/JSONString.js');
|
|
15
15
|
var helpers = require('../../../utils/rules/helpers.js');
|
|
16
|
-
var useResponse = require('../../../hooks/useResponse/useResponse.js');
|
|
17
|
-
var useRequest = require('../../../hooks/useRequest/useRequest.js');
|
|
18
16
|
var useParams = require('../../../hooks/useParams/useParams.js');
|
|
19
|
-
var useAction = require('../../../hooks/useAction/useAction.js');
|
|
20
17
|
|
|
21
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
19
|
|
|
23
20
|
var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
24
21
|
|
|
25
22
|
const api = () => {
|
|
26
|
-
var _a;
|
|
27
23
|
const handler = innet.useNewHandler();
|
|
28
|
-
const { props = {},
|
|
29
|
-
const {
|
|
30
|
-
const
|
|
31
|
-
const info = Object.assign(Object.assign({}, rest), { version: (_a = rest.version) !== null && _a !== void 0 ? _a : '0.0.0', title });
|
|
24
|
+
const { children, props = {}, } = innet.useApp();
|
|
25
|
+
const { exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = tslib.__rest(props, ["exclude", "include", "prefix", "title", "version"]);
|
|
26
|
+
const info = Object.assign(Object.assign({}, rest), { title, version });
|
|
32
27
|
const endpoints = {};
|
|
33
28
|
const docs = {
|
|
34
|
-
openapi: '3.1.0',
|
|
35
29
|
info,
|
|
30
|
+
openapi: '3.1.0',
|
|
36
31
|
paths: {},
|
|
37
32
|
};
|
|
38
|
-
const
|
|
39
|
-
const context = { docs, endpoints, prefix,
|
|
33
|
+
const plugins = new Set();
|
|
34
|
+
const context = { docs, endpoints, prefix, refRules: {} };
|
|
35
|
+
const condition = (action) => {
|
|
36
|
+
const path = action.parsedUrl.path;
|
|
37
|
+
const url = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
38
|
+
if (!url.startsWith(prefix) || (exclude === null || exclude === void 0 ? void 0 : exclude.test(url))) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (include && !include.test(url)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
useServerPlugins.serverPlugins.set(handler, plugins);
|
|
40
47
|
useApi.apiContext.set(handler, context);
|
|
41
|
-
|
|
42
|
-
var _b, _c, _d, _e, _f
|
|
43
|
-
|
|
48
|
+
useServerPlugin.useServerPlugin(() => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
50
|
+
const action = useAction.useAction();
|
|
51
|
+
if (!condition(action))
|
|
44
52
|
return;
|
|
45
|
-
const
|
|
53
|
+
const actionHandler = innet.useNewHandler();
|
|
46
54
|
const path = action.parsedUrl.path;
|
|
47
55
|
const url = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
56
|
+
const { req, res, } = action;
|
|
48
57
|
if (url === (prefix || '')) {
|
|
49
58
|
res.setHeader('Content-Type', 'application/json');
|
|
50
59
|
res.write(JSONString.JSONString(docs));
|
|
51
60
|
res.end();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (!url.startsWith(prefix)) {
|
|
55
|
-
return;
|
|
61
|
+
return null;
|
|
56
62
|
}
|
|
57
|
-
const method = ((
|
|
63
|
+
const method = ((_b = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'get');
|
|
58
64
|
const rawSplitPath = url.slice(prefix.length).split('/').slice(1);
|
|
59
65
|
const splitPath = rawSplitPath.at(-1) ? rawSplitPath : rawSplitPath.slice(0, -1);
|
|
60
66
|
const endpoint = endpoints[method];
|
|
@@ -89,8 +95,8 @@ const api = () => {
|
|
|
89
95
|
if (e instanceof helpers.RulesError) {
|
|
90
96
|
res.statusCode = 400;
|
|
91
97
|
res.write(JSONString.JSONString({
|
|
92
|
-
error: 'requestValidation',
|
|
93
98
|
data: Object.assign(Object.assign({}, e.data), { in: key }),
|
|
99
|
+
error: 'requestValidation',
|
|
94
100
|
}));
|
|
95
101
|
res.end();
|
|
96
102
|
}
|
|
@@ -98,8 +104,8 @@ const api = () => {
|
|
|
98
104
|
console.error(e);
|
|
99
105
|
res.statusCode = 500;
|
|
100
106
|
res.write(JSONString.JSONString({
|
|
101
|
-
error: 'unknown',
|
|
102
107
|
data: { in: key },
|
|
108
|
+
error: 'unknown',
|
|
103
109
|
}));
|
|
104
110
|
res.end();
|
|
105
111
|
}
|
|
@@ -128,32 +134,34 @@ const api = () => {
|
|
|
128
134
|
if (checkActionRules(bodyRules, 'body'))
|
|
129
135
|
return true;
|
|
130
136
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
useParams.paramsContext.set(actionHandler, params);
|
|
138
|
+
for (const plugin of runEndpoint.plugins) {
|
|
139
|
+
const result = yield plugin();
|
|
140
|
+
if (result === undefined)
|
|
141
|
+
continue;
|
|
142
|
+
innet__default["default"](result, actionHandler);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
137
145
|
return true;
|
|
138
146
|
});
|
|
139
147
|
}
|
|
140
|
-
if ((
|
|
141
|
-
if (!(yield run((
|
|
148
|
+
if ((_d = (_c = currentEndpoint.static) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.plugins) {
|
|
149
|
+
if (!(yield run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params)))
|
|
142
150
|
continue;
|
|
143
|
-
return;
|
|
151
|
+
return null;
|
|
144
152
|
}
|
|
145
153
|
if (currentEndpoint.dynamic) {
|
|
146
154
|
for (const dynamicEndpoint of currentEndpoint.dynamic) {
|
|
147
|
-
if (dynamicEndpoint.
|
|
155
|
+
if (dynamicEndpoint.plugins) {
|
|
148
156
|
if (!(yield run(dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key }))))
|
|
149
157
|
continue;
|
|
150
|
-
return;
|
|
158
|
+
return null;
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
162
|
break;
|
|
155
163
|
}
|
|
156
|
-
if ((
|
|
164
|
+
if ((_f = currentEndpoint.static) === null || _f === void 0 ? void 0 : _f[key]) {
|
|
157
165
|
endpointQueue.push([deep + 1, currentEndpoint.static[key], params]);
|
|
158
166
|
}
|
|
159
167
|
if (currentEndpoint.dynamic) {
|
|
@@ -162,26 +170,16 @@ const api = () => {
|
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
}
|
|
165
|
-
for (const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const newHandler = Object.create(context.fallback.handler);
|
|
171
|
-
useResponse.responseContext.set(newHandler, res);
|
|
172
|
-
useRequest.requestContext.set(newHandler, req);
|
|
173
|
+
for (const plugin of plugins) {
|
|
174
|
+
const result = yield plugin();
|
|
175
|
+
if (result === undefined)
|
|
176
|
+
continue;
|
|
177
|
+
const newHandler = Object.create(handler);
|
|
173
178
|
useAction.actionContext.set(newHandler, action);
|
|
174
|
-
innet__default["default"](
|
|
175
|
-
|
|
176
|
-
else {
|
|
177
|
-
res.statusCode = 404;
|
|
178
|
-
res.end();
|
|
179
|
+
innet__default["default"](result, newHandler);
|
|
180
|
+
return null;
|
|
179
181
|
}
|
|
180
|
-
});
|
|
181
|
-
server.on('request', listener);
|
|
182
|
-
watchState.onDestroy(() => {
|
|
183
|
-
server.off('request', listener);
|
|
184
|
-
});
|
|
182
|
+
}));
|
|
185
183
|
innet__default["default"](children, handler);
|
|
186
184
|
};
|
|
187
185
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface ContactProps {
|
|
3
|
+
/** The email address of the contact person/organization. This MUST be in the form of an email address. */
|
|
4
|
+
email?: string;
|
|
3
5
|
/** The identifying name of the contact person/organization. */
|
|
4
6
|
name?: string;
|
|
5
7
|
/** The URL pointing to the contact information. This MUST be in the form of a URL. */
|
|
6
8
|
url?: string;
|
|
7
|
-
/** The email address of the contact person/organization. This MUST be in the form of an email address. */
|
|
8
|
-
email?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare const contact: HandlerPlugin;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type EndpointsMethods } from '../../../types';
|
|
3
3
|
export interface EndpointProps {
|
|
4
|
+
/**
|
|
5
|
+
* Declares this operation to be deprecated.
|
|
6
|
+
* Consumers SHOULD refrain from usage of the declared operation.
|
|
7
|
+
* Default value is false.
|
|
8
|
+
* */
|
|
9
|
+
deprecated?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* An optional, string description, intended to apply to all operations in this path.
|
|
12
|
+
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
13
|
+
* */
|
|
14
|
+
description?: string;
|
|
4
15
|
/**
|
|
5
16
|
* A method of the endpoint.
|
|
6
17
|
* */
|
|
@@ -13,25 +24,14 @@ export interface EndpointProps {
|
|
|
13
24
|
* Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.
|
|
14
25
|
* */
|
|
15
26
|
path: string;
|
|
16
|
-
/**
|
|
17
|
-
* An optional, string summary, intended to apply to all operations in this path.
|
|
18
|
-
* */
|
|
19
|
-
summary?: string;
|
|
20
|
-
/**
|
|
21
|
-
* An optional, string description, intended to apply to all operations in this path.
|
|
22
|
-
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
23
|
-
* */
|
|
24
|
-
description?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Declares this operation to be deprecated.
|
|
27
|
-
* Consumers SHOULD refrain from usage of the declared operation.
|
|
28
|
-
* Default value is false.
|
|
29
|
-
* */
|
|
30
|
-
deprecated?: boolean;
|
|
31
27
|
/**
|
|
32
28
|
* Declares this operation to make an endpoint private.
|
|
33
29
|
* That means the endpoint should not be described and will not be shown in the Open API documentation.
|
|
34
30
|
* */
|
|
35
31
|
private?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* An optional, string summary, intended to apply to all operations in this path.
|
|
34
|
+
* */
|
|
35
|
+
summary?: string;
|
|
36
36
|
}
|
|
37
37
|
export declare const endpoint: HandlerPlugin;
|
|
@@ -6,13 +6,14 @@ import { useTag } from '../../../hooks/useTag/useTag.es6.js';
|
|
|
6
6
|
import { useApi } from '../../../hooks/useApi/useApi.es6.js';
|
|
7
7
|
import { getEndpoint } from '../../../utils/getEndpoint/getEndpoint.es6.js';
|
|
8
8
|
import { endpointContext } from '../../../hooks/useEndpoint/useEndpoint.es6.js';
|
|
9
|
+
import { serverPlugins } from '../../../hooks/useServerPlugins/useServerPlugins.es6.js';
|
|
9
10
|
|
|
10
11
|
const endpoint = () => {
|
|
11
12
|
const handler = useNewHandler();
|
|
12
13
|
const tag = useTag();
|
|
13
|
-
const { docs, endpoints } = useApi();
|
|
14
|
+
const { docs, endpoints, } = useApi();
|
|
14
15
|
const props = useProps();
|
|
15
|
-
const {
|
|
16
|
+
const { deprecated, description, method, path, private: privateMode, summary, } = props;
|
|
16
17
|
const children = useChildren();
|
|
17
18
|
const { paths } = docs;
|
|
18
19
|
if (!paths)
|
|
@@ -42,12 +43,14 @@ const endpoint = () => {
|
|
|
42
43
|
paths[path][method] = operation;
|
|
43
44
|
}
|
|
44
45
|
if (!endpoints[method]) {
|
|
45
|
-
endpoints[method] = { key: '' };
|
|
46
|
+
endpoints[method] = { key: '', plugins: new Set() };
|
|
46
47
|
}
|
|
47
48
|
// @ts-expect-error: it's always an object
|
|
48
49
|
const endpoint = getEndpoint(path, endpoints[method]);
|
|
49
50
|
// @ts-expect-error: it's always an object
|
|
50
|
-
endpointContext.set(handler, { operation, props
|
|
51
|
+
endpointContext.set(handler, { endpoint, operation, props });
|
|
52
|
+
// @ts-expect-error: it's always an object
|
|
53
|
+
serverPlugins.set(handler, endpoint.plugins);
|
|
51
54
|
innet(children, handler);
|
|
52
55
|
};
|
|
53
56
|
|
|
@@ -10,6 +10,7 @@ var useTag = require('../../../hooks/useTag/useTag.js');
|
|
|
10
10
|
var useApi = require('../../../hooks/useApi/useApi.js');
|
|
11
11
|
var getEndpoint = require('../../../utils/getEndpoint/getEndpoint.js');
|
|
12
12
|
var useEndpoint = require('../../../hooks/useEndpoint/useEndpoint.js');
|
|
13
|
+
var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
16
|
|
|
@@ -18,9 +19,9 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
|
|
|
18
19
|
const endpoint = () => {
|
|
19
20
|
const handler = innet.useNewHandler();
|
|
20
21
|
const tag = useTag.useTag();
|
|
21
|
-
const { docs, endpoints } = useApi.useApi();
|
|
22
|
+
const { docs, endpoints, } = useApi.useApi();
|
|
22
23
|
const props = jsx.useProps();
|
|
23
|
-
const {
|
|
24
|
+
const { deprecated, description, method, path, private: privateMode, summary, } = props;
|
|
24
25
|
const children = jsx.useChildren();
|
|
25
26
|
const { paths } = docs;
|
|
26
27
|
if (!paths)
|
|
@@ -50,12 +51,14 @@ const endpoint = () => {
|
|
|
50
51
|
paths[path][method] = operation;
|
|
51
52
|
}
|
|
52
53
|
if (!endpoints[method]) {
|
|
53
|
-
endpoints[method] = { key: '' };
|
|
54
|
+
endpoints[method] = { key: '', plugins: new Set() };
|
|
54
55
|
}
|
|
55
56
|
// @ts-expect-error: it's always an object
|
|
56
57
|
const endpoint = getEndpoint.getEndpoint(path, endpoints[method]);
|
|
57
58
|
// @ts-expect-error: it's always an object
|
|
58
|
-
useEndpoint.endpointContext.set(handler, { operation, props
|
|
59
|
+
useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
|
|
60
|
+
// @ts-expect-error: it's always an object
|
|
61
|
+
useServerPlugins.serverPlugins.set(handler, endpoint.plugins);
|
|
59
62
|
innet__default["default"](children, handler);
|
|
60
63
|
};
|
|
61
64
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface HostProps {
|
|
3
|
+
/**
|
|
4
|
+
* An optional string describing the host designated by the URL.
|
|
5
|
+
* [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
|
|
6
|
+
* */
|
|
7
|
+
description?: string;
|
|
3
8
|
/**
|
|
4
9
|
* A URL to the target host.
|
|
5
10
|
* This URL supports Server Variables and MAY be relative,
|
|
@@ -7,10 +12,5 @@ export interface HostProps {
|
|
|
7
12
|
* Variable substitutions will be made when a variable is named in {brackets}.
|
|
8
13
|
* */
|
|
9
14
|
url: string;
|
|
10
|
-
/**
|
|
11
|
-
* An optional string describing the host designated by the URL.
|
|
12
|
-
* [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
|
|
13
|
-
* */
|
|
14
|
-
description?: string;
|
|
15
15
|
}
|
|
16
16
|
export declare const host: HandlerPlugin;
|
package/plugins/main/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export * from './variable';
|
|
|
7
7
|
export * from './tag';
|
|
8
8
|
export * from './endpoint';
|
|
9
9
|
export * from './response';
|
|
10
|
-
export * from './
|
|
10
|
+
export * from './return';
|
|
11
11
|
export * from './param';
|
|
12
12
|
export * from './body';
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './preset';
|
|
@@ -7,7 +7,7 @@ import './variable/index.es6.js';
|
|
|
7
7
|
import './tag/index.es6.js';
|
|
8
8
|
import './endpoint/index.es6.js';
|
|
9
9
|
import './response/index.es6.js';
|
|
10
|
-
import './
|
|
10
|
+
import './return/index.es6.js';
|
|
11
11
|
import './param/index.es6.js';
|
|
12
12
|
import './body/index.es6.js';
|
|
13
|
-
import './
|
|
13
|
+
import './preset/index.es6.js';
|
package/plugins/main/index.js
CHANGED
|
@@ -9,8 +9,8 @@ require('./variable/index.js');
|
|
|
9
9
|
require('./tag/index.js');
|
|
10
10
|
require('./endpoint/index.js');
|
|
11
11
|
require('./response/index.js');
|
|
12
|
-
require('./
|
|
12
|
+
require('./return/index.js');
|
|
13
13
|
require('./param/index.js');
|
|
14
14
|
require('./body/index.js');
|
|
15
|
-
require('./
|
|
15
|
+
require('./preset/index.js');
|
|
16
16
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
export interface LicenseProps {
|
|
3
|
-
/**
|
|
4
|
-
* The license name used for the API.
|
|
5
|
-
* @example: Apache 2.0
|
|
6
|
-
* */
|
|
7
|
-
name: string;
|
|
8
3
|
/**
|
|
9
4
|
* An [SPDX](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60) license expression for the API.
|
|
10
5
|
* The `identifier` field is mutually exclusive of the `url` field.
|
|
11
6
|
* @example: Apache-2.0
|
|
12
7
|
* */
|
|
13
8
|
identifier?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The license name used for the API.
|
|
11
|
+
* @example: Apache 2.0
|
|
12
|
+
* */
|
|
13
|
+
name: string;
|
|
14
14
|
/**
|
|
15
15
|
* A URL to the license used for the API.
|
|
16
16
|
* This MUST be in the form of a URL.
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { type HandlerPlugin } from 'innet';
|
|
2
2
|
import { type InParam } from '../../../types';
|
|
3
3
|
export interface ParamProps {
|
|
4
|
+
/**
|
|
5
|
+
* Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
|
|
6
|
+
* Default value is `false`.
|
|
7
|
+
* */
|
|
8
|
+
deprecated?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A brief description of the parameter.
|
|
11
|
+
* This could contain examples of use.
|
|
12
|
+
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
13
|
+
* */
|
|
14
|
+
description?: string;
|
|
4
15
|
/**
|
|
5
16
|
* The location of the parameter.
|
|
6
17
|
* Possible values are "query", "header", "path" or "cookie".
|
|
@@ -14,22 +25,11 @@ export interface ParamProps {
|
|
|
14
25
|
* - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
|
|
15
26
|
* */
|
|
16
27
|
name: string;
|
|
17
|
-
/**
|
|
18
|
-
* A brief description of the parameter.
|
|
19
|
-
* This could contain examples of use.
|
|
20
|
-
* [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
|
|
21
|
-
* */
|
|
22
|
-
description?: string;
|
|
23
28
|
/**
|
|
24
29
|
* Determines whether this parameter is mandatory.
|
|
25
30
|
* If the parameter location is "path", this property is `true` and its value MUST be `true`.
|
|
26
31
|
* Otherwise, the property MAY be included and its default value is `false`.
|
|
27
32
|
* */
|
|
28
33
|
required?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
|
|
31
|
-
* Default value is `false`.
|
|
32
|
-
* */
|
|
33
|
-
deprecated?: boolean;
|
|
34
34
|
}
|
|
35
35
|
export declare const param: HandlerPlugin;
|
|
@@ -13,14 +13,14 @@ import { required } from '../../../utils/rules/required/required.es6.js';
|
|
|
13
13
|
import { oneOf } from '../../../utils/rules/oneOf/oneOf.es6.js';
|
|
14
14
|
|
|
15
15
|
const inMap = {
|
|
16
|
-
query: 'search',
|
|
17
|
-
path: 'path',
|
|
18
16
|
cookie: 'cookie',
|
|
19
17
|
header: 'header',
|
|
18
|
+
path: 'path',
|
|
19
|
+
query: 'search',
|
|
20
20
|
};
|
|
21
21
|
const param = () => {
|
|
22
22
|
var _a;
|
|
23
|
-
const { operation,
|
|
23
|
+
const { endpoint, operation, } = useEndpoint();
|
|
24
24
|
if (!operation.parameters) {
|
|
25
25
|
operation.parameters = [];
|
|
26
26
|
}
|