@innet/server 2.0.0-alpha.23 → 2.0.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/handler/handler.d.ts +5 -5
  2. package/handler/handler.es6.js +3 -3
  3. package/handler/handler.js +3 -3
  4. package/hooks/index.d.ts +1 -0
  5. package/hooks/index.es6.js +1 -0
  6. package/hooks/index.js +1 -0
  7. package/hooks/useClientIp/useClientIp.d.ts +1 -1
  8. package/hooks/useEndpoint/useEndpoint.d.ts +1 -1
  9. package/hooks/useSchemaType/useSchemaType.d.ts +3 -3
  10. package/hooks/useSchemaType/useSchemaType.es6.js +5 -5
  11. package/hooks/useSchemaType/useSchemaType.js +5 -5
  12. package/hooks/useServer/useServer.d.ts +1 -1
  13. package/hooks/useServerPort/index.d.ts +1 -0
  14. package/hooks/useServerPort/index.es6.js +1 -0
  15. package/hooks/useServerPort/index.js +10 -0
  16. package/hooks/useServerPort/useServerPort.d.ts +3 -0
  17. package/hooks/useServerPort/useServerPort.es6.js +14 -0
  18. package/hooks/useServerPort/useServerPort.js +19 -0
  19. package/index.es6.js +1 -0
  20. package/index.js +3 -0
  21. package/package.json +1 -1
  22. package/plugins/main/api/api.d.ts +10 -10
  23. package/plugins/main/api/api.es6.js +7 -7
  24. package/plugins/main/api/api.js +7 -7
  25. package/plugins/main/contact/contact.d.ts +2 -2
  26. package/plugins/main/endpoint/endpoint.d.ts +15 -15
  27. package/plugins/main/endpoint/endpoint.es6.js +3 -3
  28. package/plugins/main/endpoint/endpoint.js +3 -3
  29. package/plugins/main/host/host.d.ts +5 -5
  30. package/plugins/main/license/license.d.ts +5 -5
  31. package/plugins/main/param/param.d.ts +11 -11
  32. package/plugins/main/param/param.es6.js +3 -3
  33. package/plugins/main/param/param.js +3 -3
  34. package/plugins/main/response/response.d.ts +1 -1
  35. package/plugins/main/response/response.es6.js +2 -2
  36. package/plugins/main/response/response.js +2 -2
  37. package/plugins/main/server/server.d.ts +4 -4
  38. package/plugins/main/server/server.es6.js +9 -7
  39. package/plugins/main/server/server.js +9 -7
  40. package/plugins/main/tag/tag.d.ts +2 -2
  41. package/plugins/main/tag/tag.es6.js +1 -1
  42. package/plugins/main/tag/tag.js +1 -1
  43. package/plugins/main/variable/variable.d.ts +5 -5
  44. package/plugins/main/variable/variable.es6.js +3 -1
  45. package/plugins/main/variable/variable.js +3 -1
  46. package/plugins/request/cms/cms.es6.js +2 -2
  47. package/plugins/request/cms/cms.js +2 -2
  48. package/plugins/request/error/error.d.ts +40 -40
  49. package/plugins/request/error/error.es6.js +42 -42
  50. package/plugins/request/error/error.js +42 -42
  51. package/plugins/request/file/file.es6.js +2 -3
  52. package/plugins/request/file/file.js +2 -3
  53. package/plugins/request/header/header.es6.js +1 -1
  54. package/plugins/request/header/header.js +1 -1
  55. package/plugins/request/proxy/proxy.d.ts +2 -2
  56. package/plugins/request/proxy/proxy.es6.js +2 -2
  57. package/plugins/request/proxy/proxy.js +2 -2
  58. package/plugins/request/redirect/redirect.d.ts +7 -7
  59. package/plugins/request/redirect/redirect.es6.js +7 -7
  60. package/plugins/request/redirect/redirect.js +7 -7
  61. package/plugins/request/success/success.d.ts +6 -6
  62. package/plugins/request/success/success.es6.js +8 -8
  63. package/plugins/request/success/success.js +8 -8
  64. package/plugins/schema/binary/binary.d.ts +3 -3
  65. package/plugins/schema/date/date.d.ts +1 -1
  66. package/plugins/schema/date/date.es6.js +3 -3
  67. package/plugins/schema/date/date.js +3 -3
  68. package/plugins/schema/field/field.es6.js +1 -1
  69. package/plugins/schema/field/field.js +1 -1
  70. package/plugins/schema/integer/integer.d.ts +3 -3
  71. package/plugins/schema/integer/integer.es6.js +1 -1
  72. package/plugins/schema/integer/integer.js +1 -1
  73. package/plugins/schema/number/number.d.ts +2 -2
  74. package/plugins/schema/number/number.es6.js +1 -1
  75. package/plugins/schema/number/number.js +1 -1
  76. package/plugins/schema/string/string.d.ts +2 -2
  77. package/plugins/schema/string/string.es6.js +1 -1
  78. package/plugins/schema/string/string.js +1 -1
  79. package/plugins/utils/dts/dts.d.ts +1 -1
  80. package/plugins/utils/dts/dts.es6.js +1 -1
  81. package/plugins/utils/dts/dts.js +1 -1
  82. package/plugins/utils/env/env.d.ts +1 -1
  83. package/plugins/utils/env/env.es6.js +1 -1
  84. package/plugins/utils/env/env.js +1 -1
  85. package/plugins/utils/protection/protection.d.ts +3 -3
  86. package/plugins/utils/protection/protection.es6.js +3 -3
  87. package/plugins/utils/protection/protection.js +3 -3
  88. package/plugins/utils/swagger/swagger.es6.js +1 -1
  89. package/plugins/utils/swagger/swagger.js +1 -1
  90. package/types.d.ts +13 -13
  91. package/utils/FileData/Bin.d.ts +13 -13
  92. package/utils/FileData/Bin.es6.js +2 -2
  93. package/utils/FileData/Bin.js +2 -2
  94. package/utils/action/Action.d.ts +12 -12
  95. package/utils/action/Action.es6.js +80 -80
  96. package/utils/action/Action.js +79 -79
  97. package/utils/dateFormat/dateFormat.d.ts +1 -1
  98. package/utils/dateFormat/dateFormat.es6.js +1 -1
  99. package/utils/dateFormat/dateFormat.js +1 -1
  100. package/utils/generateTypes/generateTypes.es6.js +3 -3
  101. package/utils/generateTypes/generateTypes.js +3 -3
  102. package/utils/getOrAdd/getOrAdd.d.ts +1 -1
  103. package/utils/httpOnStart/httpOnStart.d.ts +1 -1
  104. package/utils/httpOnStart/httpOnStart.es6.js +1 -1
  105. package/utils/httpOnStart/httpOnStart.js +1 -1
  106. package/utils/rules/binaryAccept/binaryAccept.es6.js +2 -2
  107. package/utils/rules/binaryAccept/binaryAccept.js +2 -2
  108. package/utils/rules/dateTo/dateTo.d.ts +1 -1
  109. package/utils/rules/helpers.d.ts +1 -1
  110. package/utils/rules/int/int.es6.js +2 -2
  111. package/utils/rules/int/int.js +2 -2
  112. package/utils/rules/max/max.d.ts +1 -1
  113. package/utils/rules/max/max.es6.js +3 -3
  114. package/utils/rules/max/max.js +3 -3
  115. package/utils/rules/maxBin/maxBin.es6.js +2 -2
  116. package/utils/rules/maxBin/maxBin.js +2 -2
  117. package/utils/rules/maxDate/maxDate.es6.js +1 -1
  118. package/utils/rules/maxDate/maxDate.js +1 -1
  119. package/utils/rules/maxLength/maxLength.es6.js +2 -2
  120. package/utils/rules/maxLength/maxLength.js +2 -2
  121. package/utils/rules/min/min.d.ts +1 -1
  122. package/utils/rules/min/min.es6.js +3 -3
  123. package/utils/rules/min/min.js +3 -3
  124. package/utils/rules/minBin/minBin.es6.js +2 -2
  125. package/utils/rules/minBin/minBin.js +2 -2
  126. package/utils/rules/minDate/minDate.es6.js +1 -1
  127. package/utils/rules/minDate/minDate.js +1 -1
  128. package/utils/rules/minLength/minLength.es6.js +2 -2
  129. package/utils/rules/minLength/minLength.js +2 -2
  130. package/utils/rules/pattern/pattern.d.ts +1 -1
  131. package/utils/rules/pattern/pattern.es6.js +2 -1
  132. package/utils/rules/pattern/pattern.js +2 -1
@@ -35,12 +35,12 @@ export declare const JSXPlugins: {
35
35
  redirect: import("innet").HandlerPlugin;
36
36
  response: import("innet").HandlerPlugin;
37
37
  return: import("innet").HandlerPlugin;
38
+ server: import("innet").HandlerPlugin;
38
39
  slot: typeof slot;
39
40
  slots: typeof slots;
40
- server: import("innet").HandlerPlugin;
41
- swagger: import("innet").HandlerPlugin;
42
41
  string: import("innet").HandlerPlugin;
43
42
  success: import("innet").HandlerPlugin;
43
+ swagger: import("innet").HandlerPlugin;
44
44
  tag: import("innet").HandlerPlugin;
45
45
  tuple: import("innet").HandlerPlugin;
46
46
  uuid: import("innet").HandlerPlugin;
@@ -84,14 +84,14 @@ declare global {
84
84
  protection: ProtectionProps;
85
85
  proxy: ProxyProps;
86
86
  redirect: RedirectProps;
87
- return: ReturnProps;
88
87
  response: ResponseProps;
88
+ return: ReturnProps;
89
+ server: ServerProps;
89
90
  slot: SlotProps;
90
91
  slots: SlotsProps;
91
- server: ServerProps;
92
- swagger: SwaggerProps;
93
92
  string: StringProps;
94
93
  success: SuccessProps;
94
+ swagger: SwaggerProps;
95
95
  tag: TagProps;
96
96
  tuple: TupleProps;
97
97
  uuid: UuidProps;
@@ -34,9 +34,9 @@ import { redirect } from '../plugins/request/redirect/redirect.es6.js';
34
34
  import { response } from '../plugins/main/response/response.es6.js';
35
35
  import { returnPlugin } from '../plugins/main/return/return.es6.js';
36
36
  import { server } from '../plugins/main/server/server.es6.js';
37
- import { swagger } from '../plugins/utils/swagger/swagger.es6.js';
38
37
  import { string } from '../plugins/schema/string/string.es6.js';
39
38
  import { success } from '../plugins/request/success/success.es6.js';
39
+ import { swagger } from '../plugins/utils/swagger/swagger.es6.js';
40
40
  import { tag } from '../plugins/main/tag/tag.es6.js';
41
41
  import { tuple } from '../plugins/schema/tuple/tuple.es6.js';
42
42
  import { uuid } from '../plugins/schema/uuid/uuid.es6.js';
@@ -80,12 +80,12 @@ const JSXPlugins = {
80
80
  redirect,
81
81
  response,
82
82
  return: returnPlugin,
83
+ server,
83
84
  slot,
84
85
  slots,
85
- server,
86
- swagger,
87
86
  string,
88
87
  success,
88
+ swagger,
89
89
  tag,
90
90
  tuple,
91
91
  uuid,
@@ -38,9 +38,9 @@ var redirect = require('../plugins/request/redirect/redirect.js');
38
38
  var response = require('../plugins/main/response/response.js');
39
39
  var _return = require('../plugins/main/return/return.js');
40
40
  var server = require('../plugins/main/server/server.js');
41
- var swagger = require('../plugins/utils/swagger/swagger.js');
42
41
  var string = require('../plugins/schema/string/string.js');
43
42
  var success = require('../plugins/request/success/success.js');
43
+ var swagger = require('../plugins/utils/swagger/swagger.js');
44
44
  var tag = require('../plugins/main/tag/tag.js');
45
45
  var tuple = require('../plugins/schema/tuple/tuple.js');
46
46
  var uuid = require('../plugins/schema/uuid/uuid.js');
@@ -84,12 +84,12 @@ const JSXPlugins = {
84
84
  redirect: redirect.redirect,
85
85
  response: response.response,
86
86
  return: _return.returnPlugin,
87
+ server: server.server,
87
88
  slot: jsx.slot,
88
89
  slots: jsx.slots,
89
- server: server.server,
90
- swagger: swagger.swagger,
91
90
  string: string.string,
92
91
  success: success.success,
92
+ swagger: swagger.swagger,
93
93
  tag: tag.tag,
94
94
  tuple: tuple.tuple,
95
95
  uuid: uuid.uuid,
package/hooks/index.d.ts CHANGED
@@ -27,3 +27,4 @@ export * from './useServerPlugin';
27
27
  export * from './useClientIp';
28
28
  export * from './useServerPlugins';
29
29
  export * from './useObjectSchemaContext';
30
+ export * from './useServerPort';
@@ -27,3 +27,4 @@ import './useServerPlugin/index.es6.js';
27
27
  import './useClientIp/index.es6.js';
28
28
  import './useServerPlugins/index.es6.js';
29
29
  import './useObjectSchemaContext/index.es6.js';
30
+ import './useServerPort/index.es6.js';
package/hooks/index.js CHANGED
@@ -29,4 +29,5 @@ require('./useServerPlugin/index.js');
29
29
  require('./useClientIp/index.js');
30
30
  require('./useServerPlugins/index.js');
31
31
  require('./useObjectSchemaContext/index.js');
32
+ require('./useServerPort/index.js');
32
33
 
@@ -1 +1 @@
1
- export declare function useClientIp(): string | null;
1
+ export declare function useClientIp(): null | string;
@@ -2,9 +2,9 @@ import { Context } from '@innet/jsx';
2
2
  import { type EndpointProps } from '../../plugins';
3
3
  import type { Endpoint, OperationObject } from '../../types';
4
4
  export interface EndpointContext {
5
+ endpoint: Endpoint;
5
6
  operation: OperationObject;
6
7
  props: EndpointProps;
7
- endpoint: Endpoint;
8
8
  }
9
9
  export declare const endpointContext: Context<EndpointContext, EndpointContext | undefined>;
10
10
  export declare function useEndpoint(): EndpointContext;
@@ -1,5 +1,5 @@
1
1
  import { type ObjectType, type SchemaObject, type ValuesSchemaProps } from '../../types';
2
- export type SchemaType = ObjectType | 'any';
3
- type TypeMap<T extends SchemaType> = T extends 'number' | 'integer' ? number : T extends 'string' ? string : T extends 'object' ? object : T extends 'array' ? any[] : T extends 'boolean' ? boolean : T extends 'null' ? null : T extends 'any' ? any : unknown;
4
- export declare function useSchemaType<T extends SchemaType>(type: T, { values, ref, example, examples, ...options }?: undefined | ValuesSchemaProps<TypeMap<T>>): SchemaObject | undefined;
2
+ export type SchemaType = 'any' | ObjectType;
3
+ type TypeMap<T extends SchemaType> = T extends 'integer' | 'number' ? number : T extends 'string' ? string : T extends 'object' ? object : T extends 'array' ? any[] : T extends 'boolean' ? boolean : T extends 'null' ? null : T extends 'any' ? any : unknown;
4
+ export declare function useSchemaType<T extends SchemaType>(type: T, { example, examples, ref, values, ...options }?: ValuesSchemaProps<TypeMap<T>> | undefined): SchemaObject | undefined;
5
5
  export {};
@@ -6,7 +6,7 @@ import { useNewSchema } from '../useNewSchema/useNewSchema.es6.js';
6
6
 
7
7
  function useSchemaType(type, _a = {}) {
8
8
  var _b;
9
- var { values, ref, example, examples } = _a, options = __rest(_a, ["values", "ref", "example", "examples"]);
9
+ var { example, examples, ref, values } = _a, options = __rest(_a, ["example", "examples", "ref", "values"]);
10
10
  if (ref) {
11
11
  const { docs } = useApi();
12
12
  if (!docs.components) {
@@ -21,11 +21,11 @@ function useSchemaType(type, _a = {}) {
21
21
  if ((_b = docs.components.schemas) === null || _b === void 0 ? void 0 : _b[ref]) {
22
22
  return;
23
23
  }
24
- return (docs.components.schemas[ref] = Object.assign(Object.assign({}, options), { example,
25
- examples, type: type === 'any' ? undefined : type, enum: values }));
24
+ return (docs.components.schemas[ref] = Object.assign(Object.assign({}, options), { enum: values, example,
25
+ examples, type: type === 'any' ? undefined : type }));
26
26
  }
27
- return useNewSchema(Object.assign(Object.assign({}, options), { example,
28
- examples, enum: values, type: type === 'any' ? undefined : type }));
27
+ return useNewSchema(Object.assign(Object.assign({}, options), { enum: values, example,
28
+ examples, type: type === 'any' ? undefined : type }));
29
29
  }
30
30
 
31
31
  export { useSchemaType };
@@ -10,7 +10,7 @@ var useNewSchema = require('../useNewSchema/useNewSchema.js');
10
10
 
11
11
  function useSchemaType(type, _a = {}) {
12
12
  var _b;
13
- var { values, ref, example, examples } = _a, options = tslib.__rest(_a, ["values", "ref", "example", "examples"]);
13
+ var { example, examples, ref, values } = _a, options = tslib.__rest(_a, ["example", "examples", "ref", "values"]);
14
14
  if (ref) {
15
15
  const { docs } = useApi.useApi();
16
16
  if (!docs.components) {
@@ -25,11 +25,11 @@ function useSchemaType(type, _a = {}) {
25
25
  if ((_b = docs.components.schemas) === null || _b === void 0 ? void 0 : _b[ref]) {
26
26
  return;
27
27
  }
28
- return (docs.components.schemas[ref] = Object.assign(Object.assign({}, options), { example,
29
- examples, type: type === 'any' ? undefined : type, enum: values }));
28
+ return (docs.components.schemas[ref] = Object.assign(Object.assign({}, options), { enum: values, example,
29
+ examples, type: type === 'any' ? undefined : type }));
30
30
  }
31
- return useNewSchema.useNewSchema(Object.assign(Object.assign({}, options), { example,
32
- examples, enum: values, type: type === 'any' ? undefined : type }));
31
+ return useNewSchema.useNewSchema(Object.assign(Object.assign({}, options), { enum: values, example,
32
+ examples, type: type === 'any' ? undefined : type }));
33
33
  }
34
34
 
35
35
  exports.useSchemaType = useSchemaType;
@@ -5,8 +5,8 @@ import { type Server as HttpServer } from 'http';
5
5
  import { type Server as HttpsServer } from 'https';
6
6
  export type ServerPlugin = () => any;
7
7
  export interface ServerContext {
8
- server: HttpServer | HttpsServer;
9
8
  port: number;
9
+ server: HttpServer | HttpsServer;
10
10
  }
11
11
  export declare const serverContext: Context<ServerContext, ServerContext | undefined>;
12
12
  export declare function useServer(): ServerContext;
@@ -0,0 +1 @@
1
+ export * from './useServerPort';
@@ -0,0 +1 @@
1
+ export { serverPortContext, useServerPort } from './useServerPort.es6.js';
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var useServerPort = require('./useServerPort.js');
6
+
7
+
8
+
9
+ exports.serverPortContext = useServerPort.serverPortContext;
10
+ exports.useServerPort = useServerPort.useServerPort;
@@ -0,0 +1,3 @@
1
+ import { Context } from '@innet/jsx';
2
+ export declare const serverPortContext: Context<number, number | undefined>;
3
+ export declare function useServerPort(): number;
@@ -0,0 +1,14 @@
1
+ import { Context, useContext } from '@innet/jsx';
2
+ import '../useThrow/index.es6.js';
3
+ import { useThrow } from '../useThrow/useThrow.es6.js';
4
+
5
+ const serverPortContext = new Context();
6
+ function useServerPort() {
7
+ const port = useContext(serverPortContext);
8
+ if (!port) {
9
+ useThrow('{type} MUST BE in <server>');
10
+ }
11
+ return port;
12
+ }
13
+
14
+ export { serverPortContext, useServerPort };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsx = require('@innet/jsx');
6
+ require('../useThrow/index.js');
7
+ var useThrow = require('../useThrow/useThrow.js');
8
+
9
+ const serverPortContext = new jsx.Context();
10
+ function useServerPort() {
11
+ const port = jsx.useContext(serverPortContext);
12
+ if (!port) {
13
+ useThrow.useThrow('{type} MUST BE in <server>');
14
+ }
15
+ return port;
16
+ }
17
+
18
+ exports.serverPortContext = serverPortContext;
19
+ exports.useServerPort = useServerPort;
package/index.es6.js CHANGED
@@ -113,3 +113,4 @@ export { useServerPlugin } from './hooks/useServerPlugin/useServerPlugin.es6.js'
113
113
  export { useClientIp } from './hooks/useClientIp/useClientIp.es6.js';
114
114
  export { serverPlugins, useServerPlugins } from './hooks/useServerPlugins/useServerPlugins.es6.js';
115
115
  export { objectSchemaContext, useObjectSchemaContext } from './hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js';
116
+ export { serverPortContext, useServerPort } from './hooks/useServerPort/useServerPort.es6.js';
package/index.js CHANGED
@@ -117,6 +117,7 @@ var useServerPlugin = require('./hooks/useServerPlugin/useServerPlugin.js');
117
117
  var useClientIp = require('./hooks/useClientIp/useClientIp.js');
118
118
  var useServerPlugins = require('./hooks/useServerPlugins/useServerPlugins.js');
119
119
  var useObjectSchemaContext = require('./hooks/useObjectSchemaContext/useObjectSchemaContext.js');
120
+ var useServerPort = require('./hooks/useServerPort/useServerPort.js');
120
121
 
121
122
 
122
123
 
@@ -259,3 +260,5 @@ exports.serverPlugins = useServerPlugins.serverPlugins;
259
260
  exports.useServerPlugins = useServerPlugins.useServerPlugins;
260
261
  exports.objectSchemaContext = useObjectSchemaContext.objectSchemaContext;
261
262
  exports.useObjectSchemaContext = useObjectSchemaContext.useObjectSchemaContext;
263
+ exports.serverPortContext = useServerPort.serverPortContext;
264
+ exports.useServerPort = useServerPort.useServerPort;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-alpha.23",
3
+ "version": "2.0.0-alpha.25",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",
@@ -1,5 +1,15 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  export interface ApiProps {
3
+ /** A description of the API. [CommonMark syntax](https://spec.commonmark.or.org) MAY be used for rich text representation. */
4
+ description?: string;
5
+ exclude?: RegExp;
6
+ include?: RegExp;
7
+ /** URL path prefix scopes the API. */
8
+ prefix?: string;
9
+ /** A short summary of the API. */
10
+ summary?: string;
11
+ /** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
12
+ termsOfService?: string;
3
13
  /** The title of the API. */
4
14
  title?: string;
5
15
  /**
@@ -10,15 +20,5 @@ export interface ApiProps {
10
20
  * @default: 0.0.0
11
21
  * */
12
22
  version?: string;
13
- /** A short summary of the API. */
14
- summary?: string;
15
- /** A description of the API. [CommonMark syntax](https://spec.commonmark.or.org) MAY be used for rich text representation. */
16
- description?: string;
17
- /** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
18
- termsOfService?: string;
19
- /** URL path prefix scopes the API. */
20
- prefix?: string;
21
- include?: RegExp;
22
- exclude?: RegExp;
23
23
  }
24
24
  export declare const api: HandlerPlugin;
@@ -13,13 +13,13 @@ import { paramsContext } from '../../../hooks/useParams/useParams.es6.js';
13
13
 
14
14
  const api = () => {
15
15
  const handler = useNewHandler();
16
- const { props = {}, children } = useApp();
17
- const { prefix = '', title = '', include, exclude, version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = __rest(props, ["prefix", "title", "include", "exclude", "version"]);
18
- const info = Object.assign(Object.assign({}, rest), { version, title });
16
+ const { children, props = {}, } = useApp();
17
+ const { exclude, include, 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 });
19
19
  const endpoints = {};
20
20
  const docs = {
21
- openapi: '3.1.0',
22
21
  info,
22
+ openapi: '3.1.0',
23
23
  paths: {},
24
24
  };
25
25
  const plugins = new Set();
@@ -45,7 +45,7 @@ const api = () => {
45
45
  const actionHandler = useNewHandler();
46
46
  const path = action.parsedUrl.path;
47
47
  const url = path.endsWith('/') ? path.slice(0, -1) : path;
48
- const { req, res } = action;
48
+ const { req, res, } = action;
49
49
  if (url === (prefix || '')) {
50
50
  res.setHeader('Content-Type', 'application/json');
51
51
  res.write(JSONString(docs));
@@ -87,8 +87,8 @@ const api = () => {
87
87
  if (e instanceof RulesError) {
88
88
  res.statusCode = 400;
89
89
  res.write(JSONString({
90
- error: 'requestValidation',
91
90
  data: Object.assign(Object.assign({}, e.data), { in: key }),
91
+ error: 'requestValidation',
92
92
  }));
93
93
  res.end();
94
94
  }
@@ -96,8 +96,8 @@ const api = () => {
96
96
  console.error(e);
97
97
  res.statusCode = 500;
98
98
  res.write(JSONString({
99
- error: 'unknown',
100
99
  data: { in: key },
100
+ error: 'unknown',
101
101
  }));
102
102
  res.end();
103
103
  }
@@ -21,13 +21,13 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
21
21
 
22
22
  const api = () => {
23
23
  const handler = innet.useNewHandler();
24
- const { props = {}, children } = innet.useApp();
25
- const { prefix = '', title = '', include, exclude, version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = tslib.__rest(props, ["prefix", "title", "include", "exclude", "version"]);
26
- const info = Object.assign(Object.assign({}, rest), { version, title });
24
+ const { children, props = {}, } = innet.useApp();
25
+ const { exclude, include, 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 });
27
27
  const endpoints = {};
28
28
  const docs = {
29
- openapi: '3.1.0',
30
29
  info,
30
+ openapi: '3.1.0',
31
31
  paths: {},
32
32
  };
33
33
  const plugins = new Set();
@@ -53,7 +53,7 @@ const api = () => {
53
53
  const actionHandler = innet.useNewHandler();
54
54
  const path = action.parsedUrl.path;
55
55
  const url = path.endsWith('/') ? path.slice(0, -1) : path;
56
- const { req, res } = action;
56
+ const { req, res, } = action;
57
57
  if (url === (prefix || '')) {
58
58
  res.setHeader('Content-Type', 'application/json');
59
59
  res.write(JSONString.JSONString(docs));
@@ -95,8 +95,8 @@ const api = () => {
95
95
  if (e instanceof helpers.RulesError) {
96
96
  res.statusCode = 400;
97
97
  res.write(JSONString.JSONString({
98
- error: 'requestValidation',
99
98
  data: Object.assign(Object.assign({}, e.data), { in: key }),
99
+ error: 'requestValidation',
100
100
  }));
101
101
  res.end();
102
102
  }
@@ -104,8 +104,8 @@ const api = () => {
104
104
  console.error(e);
105
105
  res.statusCode = 500;
106
106
  res.write(JSONString.JSONString({
107
- error: 'unknown',
108
107
  data: { in: key },
108
+ error: 'unknown',
109
109
  }));
110
110
  res.end();
111
111
  }
@@ -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;
@@ -11,9 +11,9 @@ import { serverPlugins } from '../../../hooks/useServerPlugins/useServerPlugins.
11
11
  const endpoint = () => {
12
12
  const handler = useNewHandler();
13
13
  const tag = useTag();
14
- const { docs, endpoints } = useApi();
14
+ const { docs, endpoints, } = useApi();
15
15
  const props = useProps();
16
- const { path, summary, description, deprecated, method, private: privateMode } = props;
16
+ const { deprecated, description, method, path, private: privateMode, summary, } = props;
17
17
  const children = useChildren();
18
18
  const { paths } = docs;
19
19
  if (!paths)
@@ -48,7 +48,7 @@ const endpoint = () => {
48
48
  // @ts-expect-error: it's always an object
49
49
  const endpoint = getEndpoint(path, endpoints[method]);
50
50
  // @ts-expect-error: it's always an object
51
- endpointContext.set(handler, { operation, props, endpoint });
51
+ endpointContext.set(handler, { endpoint, operation, props });
52
52
  // @ts-expect-error: it's always an object
53
53
  serverPlugins.set(handler, endpoint.plugins);
54
54
  innet(children, handler);
@@ -19,9 +19,9 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
19
19
  const endpoint = () => {
20
20
  const handler = innet.useNewHandler();
21
21
  const tag = useTag.useTag();
22
- const { docs, endpoints } = useApi.useApi();
22
+ const { docs, endpoints, } = useApi.useApi();
23
23
  const props = jsx.useProps();
24
- const { path, summary, description, deprecated, method, private: privateMode } = props;
24
+ const { deprecated, description, method, path, private: privateMode, summary, } = props;
25
25
  const children = jsx.useChildren();
26
26
  const { paths } = docs;
27
27
  if (!paths)
@@ -56,7 +56,7 @@ const endpoint = () => {
56
56
  // @ts-expect-error: it's always an object
57
57
  const endpoint = getEndpoint.getEndpoint(path, endpoints[method]);
58
58
  // @ts-expect-error: it's always an object
59
- useEndpoint.endpointContext.set(handler, { operation, props, endpoint });
59
+ useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
60
60
  // @ts-expect-error: it's always an object
61
61
  useServerPlugins.serverPlugins.set(handler, endpoint.plugins);
62
62
  innet__default["default"](children, handler);
@@ -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;
@@ -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, endpoint } = useEndpoint();
23
+ const { endpoint, operation, } = useEndpoint();
24
24
  if (!operation.parameters) {
25
25
  operation.parameters = [];
26
26
  }
@@ -21,14 +21,14 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
21
21
  var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
22
22
 
23
23
  const inMap = {
24
- query: 'search',
25
- path: 'path',
26
24
  cookie: 'cookie',
27
25
  header: 'header',
26
+ path: 'path',
27
+ query: 'search',
28
28
  };
29
29
  const param = () => {
30
30
  var _a;
31
- const { operation, endpoint } = useEndpoint.useEndpoint();
31
+ const { endpoint, operation, } = useEndpoint.useEndpoint();
32
32
  if (!operation.parameters) {
33
33
  operation.parameters = [];
34
34
  }