@innet/server 2.0.0-beta.1 → 2.0.0-beta.3

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 (110) hide show
  1. package/README.md +22 -0
  2. package/handler/handler.d.ts +1 -7
  3. package/handler/handler.es6.js +1 -4
  4. package/handler/handler.js +0 -3
  5. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  6. package/hooks/useNewSchema/useNewSchema.es6.js +1 -1
  7. package/hooks/useNewSchema/useNewSchema.js +1 -1
  8. package/hooks/useRequest/useRequest.d.ts +0 -1
  9. package/hooks/useResponse/useResponse.d.ts +0 -1
  10. package/hooks/useSchemaType/useSchemaType.es6.js +17 -9
  11. package/hooks/useSchemaType/useSchemaType.js +17 -9
  12. package/hooks/useServer/useServer.d.ts +0 -2
  13. package/index.es6.js +0 -1
  14. package/index.js +0 -1
  15. package/package.json +15 -15
  16. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  17. package/plugins/handler/serverFn/serverFn.js +1 -1
  18. package/plugins/main/api/api.es6.js +73 -73
  19. package/plugins/main/api/api.js +73 -73
  20. package/plugins/main/endpoint/endpoint.d.ts +5 -0
  21. package/plugins/main/endpoint/endpoint.es6.js +4 -4
  22. package/plugins/main/endpoint/endpoint.js +4 -4
  23. package/plugins/main/host/host.es6.js +3 -1
  24. package/plugins/main/host/host.js +3 -1
  25. package/plugins/main/param/param.es6.js +2 -3
  26. package/plugins/main/param/param.js +2 -3
  27. package/plugins/main/response/response.es6.js +10 -3
  28. package/plugins/main/response/response.js +10 -3
  29. package/plugins/main/server/server.d.ts +0 -1
  30. package/plugins/main/server/server.es6.js +6 -9
  31. package/plugins/main/server/server.js +6 -9
  32. package/plugins/main/variable/variable.es6.js +3 -4
  33. package/plugins/main/variable/variable.js +3 -4
  34. package/plugins/request/cookie/cookie.d.ts +2 -2
  35. package/plugins/request/cookie/cookie.es6.js +1 -2
  36. package/plugins/request/cookie/cookie.js +1 -2
  37. package/plugins/request/error/error.es6.js +1 -2
  38. package/plugins/request/error/error.js +1 -2
  39. package/plugins/request/file/file.es6.js +1 -2
  40. package/plugins/request/file/file.js +1 -2
  41. package/plugins/request/proxy/proxy.d.ts +0 -1
  42. package/plugins/schema/array/array.es6.js +1 -2
  43. package/plugins/schema/array/array.js +1 -2
  44. package/plugins/schema/date/date.es6.js +8 -4
  45. package/plugins/schema/date/date.js +8 -4
  46. package/plugins/schema/integer/integer.es6.js +8 -3
  47. package/plugins/schema/integer/integer.js +8 -3
  48. package/plugins/schema/number/number.es6.js +1 -2
  49. package/plugins/schema/number/number.js +1 -2
  50. package/plugins/schema/object/object.es6.js +1 -2
  51. package/plugins/schema/object/object.js +1 -2
  52. package/plugins/schema/string/string.es6.js +1 -2
  53. package/plugins/schema/string/string.js +1 -2
  54. package/plugins/schema/tuple/tuple.es6.js +1 -2
  55. package/plugins/schema/tuple/tuple.js +1 -2
  56. package/plugins/schema/uuid/uuid.es6.js +5 -3
  57. package/plugins/schema/uuid/uuid.js +5 -3
  58. package/utils/action/Action.d.ts +4 -5
  59. package/utils/action/Action.es6.js +14 -16
  60. package/utils/action/Action.js +13 -15
  61. package/utils/parseBody/parseBody.d.ts +0 -1
  62. package/utils/parseBody/parseBody.es6.js +13 -16
  63. package/utils/parseBody/parseBody.js +13 -16
  64. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  65. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  66. package/utils/parseFormBody/parseFormBody.js +41 -41
  67. package/utils/parseSearch/parseSearch.es6.js +4 -1
  68. package/utils/parseSearch/parseSearch.js +4 -1
  69. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  70. package/utils/rules/arrayOf/arrayOf.js +1 -1
  71. package/utils/rules/bin/bin.es6.js +4 -1
  72. package/utils/rules/bin/bin.js +4 -1
  73. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  74. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  75. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  76. package/utils/rules/dateTo/dateTo.js +4 -1
  77. package/utils/rules/helpers.es6.js +4 -1
  78. package/utils/rules/helpers.js +4 -1
  79. package/utils/rules/int/int.es6.js +17 -4
  80. package/utils/rules/int/int.js +17 -4
  81. package/utils/rules/max/max.es6.js +9 -3
  82. package/utils/rules/max/max.js +9 -3
  83. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  84. package/utils/rules/maxBin/maxBin.js +5 -2
  85. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  86. package/utils/rules/maxDate/maxDate.js +5 -1
  87. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  88. package/utils/rules/maxLength/maxLength.js +5 -2
  89. package/utils/rules/min/min.es6.js +9 -3
  90. package/utils/rules/min/min.js +9 -3
  91. package/utils/rules/minBin/minBin.es6.js +5 -2
  92. package/utils/rules/minBin/minBin.js +5 -2
  93. package/utils/rules/minDate/minDate.es6.js +5 -1
  94. package/utils/rules/minDate/minDate.js +5 -1
  95. package/utils/rules/minLength/minLength.es6.js +5 -2
  96. package/utils/rules/minLength/minLength.js +5 -2
  97. package/utils/rules/num/num.es6.js +4 -1
  98. package/utils/rules/num/num.js +4 -1
  99. package/utils/rules/objectOf/objectOf.es6.js +6 -3
  100. package/utils/rules/objectOf/objectOf.js +6 -3
  101. package/utils/rules/pattern/pattern.es6.js +6 -2
  102. package/utils/rules/pattern/pattern.js +6 -2
  103. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  104. package/utils/rules/tupleOf/tupleOf.js +1 -1
  105. package/utils/rules/values/values.es6.js +5 -2
  106. package/utils/rules/values/values.js +5 -2
  107. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  108. package/utils/stringifySearch/stringifySearch.js +4 -1
  109. package/_virtual/_rollup-plugin-process-env.es6.js +0 -10
  110. package/_virtual/_rollup-plugin-process-env.js +0 -12
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var innet = require('innet');
7
6
  var jsx = require('@innet/jsx');
8
7
  require('../../../hooks/index.js');
@@ -23,8 +22,8 @@ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
23
22
  const api = () => {
24
23
  const handler = innet.useNewHandler();
25
24
  const props = jsx.useProps();
26
- const { children, exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = tslib.__rest(props, ["children", "exclude", "include", "prefix", "title", "version"]);
27
- const info = Object.assign(Object.assign({}, rest), { title, version });
25
+ const { children, exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0', ...rest } = props;
26
+ const info = { ...rest, title, version };
28
27
  const endpoints = {};
29
28
  const docs = {
30
29
  info,
@@ -46,7 +45,7 @@ const api = () => {
46
45
  };
47
46
  useServerPlugins.serverPlugins.set(handler, plugins);
48
47
  useApi.apiContext.set(handler, context);
49
- useServerPlugin.useServerPlugin(() => tslib.__awaiter(void 0, void 0, void 0, function* () {
48
+ useServerPlugin.useServerPlugin(async () => {
50
49
  var _a, _b, _c, _d, _e, _f;
51
50
  const action = useAction.useAction();
52
51
  if (!condition(action))
@@ -70,91 +69,92 @@ const api = () => {
70
69
  const [deep, currentEndpoint, params] = endpointQueue.shift();
71
70
  const key = splitPath[deep];
72
71
  if (deep + 1 === splitPath.length) {
73
- function run(runEndpoint, params) {
72
+ async function run(runEndpoint, params) {
74
73
  var _a, _b, _c, _d, _e;
75
- return tslib.__awaiter(this, void 0, void 0, function* () {
76
- const pathRules = (_a = runEndpoint.rules) === null || _a === void 0 ? void 0 : _a.path;
77
- const headerRules = (_b = runEndpoint.rules) === null || _b === void 0 ? void 0 : _b.header;
78
- const cookieRules = (_c = runEndpoint.rules) === null || _c === void 0 ? void 0 : _c.cookie;
79
- const searchRules = (_d = runEndpoint.rules) === null || _d === void 0 ? void 0 : _d.search;
80
- const bodyRules = (_e = runEndpoint.rules) === null || _e === void 0 ? void 0 : _e.body;
81
- if (pathRules) {
82
- try {
83
- Object.assign(params, pathRules(params, { in: 'path' }));
84
- }
85
- catch (_f) {
86
- return false;
87
- }
74
+ const pathRules = (_a = runEndpoint.rules) === null || _a === void 0 ? void 0 : _a.path;
75
+ const headerRules = (_b = runEndpoint.rules) === null || _b === void 0 ? void 0 : _b.header;
76
+ const cookieRules = (_c = runEndpoint.rules) === null || _c === void 0 ? void 0 : _c.cookie;
77
+ const searchRules = (_d = runEndpoint.rules) === null || _d === void 0 ? void 0 : _d.search;
78
+ const bodyRules = (_e = runEndpoint.rules) === null || _e === void 0 ? void 0 : _e.body;
79
+ if (pathRules) {
80
+ try {
81
+ Object.assign(params, pathRules(params, { in: 'path' }));
88
82
  }
89
- function checkActionRules(rules, key = 'search') {
90
- if (rules) {
91
- try {
92
- action[key] = rules(action[key]);
93
- }
94
- catch (e) {
95
- res.setHeader('Content-Type', 'application/json');
96
- if (e instanceof helpers.RulesError) {
97
- res.statusCode = 400;
98
- res.write(JSONString.JSONString({
99
- data: Object.assign(Object.assign({}, e.data), { in: key }),
100
- error: 'requestValidation',
101
- }));
102
- res.end();
103
- }
104
- else {
105
- console.error(e);
106
- res.statusCode = 500;
107
- res.write(JSONString.JSONString({
108
- data: { in: key },
109
- error: 'unknown',
110
- }));
111
- res.end();
112
- }
113
- return true;
114
- }
115
- }
83
+ catch (_f) {
116
84
  return false;
117
85
  }
118
- if (checkActionRules(headerRules, 'headers'))
119
- return true;
120
- if (checkActionRules(cookieRules, 'cookies'))
121
- return true;
122
- if (checkActionRules(searchRules, 'search'))
123
- return true;
124
- if (bodyRules) {
125
- yield action.parseBody();
126
- if (!action.body) {
127
- res.statusCode = 400;
86
+ }
87
+ function checkActionRules(rules, key = 'search') {
88
+ if (rules) {
89
+ try {
90
+ action[key] = rules(action[key]);
91
+ }
92
+ catch (e) {
128
93
  res.setHeader('Content-Type', 'application/json');
129
- res.write(JSONString.JSONString({
130
- error: 'requestBodyContentType',
131
- }));
132
- res.end();
94
+ if (e instanceof helpers.RulesError) {
95
+ res.statusCode = 400;
96
+ res.write(JSONString.JSONString({
97
+ data: {
98
+ ...e.data,
99
+ in: key,
100
+ },
101
+ error: 'requestValidation',
102
+ }));
103
+ res.end();
104
+ }
105
+ else {
106
+ console.error(e);
107
+ res.statusCode = 500;
108
+ res.write(JSONString.JSONString({
109
+ data: { in: key },
110
+ error: 'unknown',
111
+ }));
112
+ res.end();
113
+ }
133
114
  return true;
134
115
  }
135
- if (checkActionRules(bodyRules, 'body'))
136
- return true;
137
116
  }
138
- useParams.paramsContext.set(actionHandler, params);
139
- for (const plugin of runEndpoint.plugins) {
140
- const result = yield plugin();
141
- if (result === undefined)
142
- continue;
143
- innet__default["default"](result, actionHandler);
117
+ return false;
118
+ }
119
+ if (checkActionRules(headerRules, 'headers'))
120
+ return true;
121
+ if (checkActionRules(cookieRules, 'cookies'))
122
+ return true;
123
+ if (checkActionRules(searchRules, 'search'))
124
+ return true;
125
+ if (bodyRules) {
126
+ await action.parseBody();
127
+ if (!action.body) {
128
+ res.statusCode = 400;
129
+ res.setHeader('Content-Type', 'application/json');
130
+ res.write(JSONString.JSONString({
131
+ error: 'requestBodyContentType',
132
+ }));
133
+ res.end();
144
134
  return true;
145
135
  }
136
+ if (checkActionRules(bodyRules, 'body'))
137
+ return true;
138
+ }
139
+ useParams.paramsContext.set(actionHandler, params);
140
+ for (const plugin of runEndpoint.plugins) {
141
+ const result = await plugin();
142
+ if (result === undefined)
143
+ continue;
144
+ innet__default["default"](result, actionHandler);
146
145
  return true;
147
- });
146
+ }
147
+ return true;
148
148
  }
149
149
  if ((_d = (_c = currentEndpoint.static) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.plugins) {
150
- if (!(yield run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params)))
150
+ if (!await run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params))
151
151
  continue;
152
152
  return null;
153
153
  }
154
154
  if (currentEndpoint.dynamic) {
155
155
  for (const dynamicEndpoint of currentEndpoint.dynamic) {
156
156
  if (dynamicEndpoint.plugins) {
157
- if (!(yield run(dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key }))))
157
+ if (!await run(dynamicEndpoint, { ...params, [dynamicEndpoint.key.slice(1, -1)]: key }))
158
158
  continue;
159
159
  return null;
160
160
  }
@@ -167,12 +167,12 @@ const api = () => {
167
167
  }
168
168
  if (currentEndpoint.dynamic) {
169
169
  for (const dynamicEndpoint of currentEndpoint.dynamic) {
170
- endpointQueue.push([deep + 1, dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key })]);
170
+ endpointQueue.push([deep + 1, dynamicEndpoint, { ...params, [dynamicEndpoint.key.slice(1, -1)]: key }]);
171
171
  }
172
172
  }
173
173
  }
174
174
  for (const plugin of plugins) {
175
- const result = yield plugin();
175
+ const result = await plugin();
176
176
  if (result === undefined)
177
177
  continue;
178
178
  const newHandler = Object.create(handler);
@@ -180,7 +180,7 @@ const api = () => {
180
180
  innet__default["default"](result, newHandler);
181
181
  return null;
182
182
  }
183
- }));
183
+ });
184
184
  innet__default["default"](children, handler);
185
185
  };
186
186
 
@@ -17,6 +17,11 @@ export interface EndpointProps {
17
17
  * A method of the endpoint.
18
18
  * */
19
19
  method: EndpointsMethods;
20
+ /**
21
+ * `operationId` is an optional unique string used to identify an operation.
22
+ * If provided, these IDs must be unique among all operations described in your API.
23
+ * */
24
+ operationId?: string;
20
25
  /**
21
26
  * A relative path to an individual endpoint.
22
27
  * The property MUST begin with a forward slash (/).
@@ -13,14 +13,13 @@ const endpoint = () => {
13
13
  const tag = useTag();
14
14
  const props = useProps();
15
15
  const { docs, endpoints, } = useApi();
16
- const { children, deprecated, description, method, path, private: privateMode, summary, } = props;
16
+ const { children, deprecated, description, method, operationId, path, private: privateMode, summary, } = props;
17
17
  const { paths } = docs;
18
18
  if (!paths)
19
19
  throw Error('cannot find paths in docs');
20
20
  if (!paths[path]) {
21
21
  paths[path] = {};
22
22
  }
23
- // @ts-expect-error: it's always an object
24
23
  if (paths[path][method]) {
25
24
  throw Error(`You cannot use the same endpoints ${method}:${path}`);
26
25
  }
@@ -28,6 +27,9 @@ const endpoint = () => {
28
27
  if (summary) {
29
28
  operation.summary = summary;
30
29
  }
30
+ if (operationId) {
31
+ operation.operationId = operationId;
32
+ }
31
33
  if (description) {
32
34
  operation.description = description;
33
35
  }
@@ -38,13 +40,11 @@ const endpoint = () => {
38
40
  operation.tags = [tag.name];
39
41
  }
40
42
  if (!privateMode) {
41
- // @ts-expect-error: it's always an object
42
43
  paths[path][method] = operation;
43
44
  }
44
45
  if (!endpoints[method]) {
45
46
  endpoints[method] = { key: '', plugins: new Set() };
46
47
  }
47
- // @ts-expect-error: it's always an object
48
48
  const endpoint = getEndpoint(path, endpoints[method]);
49
49
  // @ts-expect-error: it's always an object
50
50
  endpointContext.set(handler, { endpoint, operation, props });
@@ -21,14 +21,13 @@ const endpoint = () => {
21
21
  const tag = useTag.useTag();
22
22
  const props = jsx.useProps();
23
23
  const { docs, endpoints, } = useApi.useApi();
24
- const { children, deprecated, description, method, path, private: privateMode, summary, } = props;
24
+ const { children, deprecated, description, method, operationId, path, private: privateMode, summary, } = props;
25
25
  const { paths } = docs;
26
26
  if (!paths)
27
27
  throw Error('cannot find paths in docs');
28
28
  if (!paths[path]) {
29
29
  paths[path] = {};
30
30
  }
31
- // @ts-expect-error: it's always an object
32
31
  if (paths[path][method]) {
33
32
  throw Error(`You cannot use the same endpoints ${method}:${path}`);
34
33
  }
@@ -36,6 +35,9 @@ const endpoint = () => {
36
35
  if (summary) {
37
36
  operation.summary = summary;
38
37
  }
38
+ if (operationId) {
39
+ operation.operationId = operationId;
40
+ }
39
41
  if (description) {
40
42
  operation.description = description;
41
43
  }
@@ -46,13 +48,11 @@ const endpoint = () => {
46
48
  operation.tags = [tag.name];
47
49
  }
48
50
  if (!privateMode) {
49
- // @ts-expect-error: it's always an object
50
51
  paths[path][method] = operation;
51
52
  }
52
53
  if (!endpoints[method]) {
53
54
  endpoints[method] = { key: '', plugins: new Set() };
54
55
  }
55
- // @ts-expect-error: it's always an object
56
56
  const endpoint = getEndpoint.getEndpoint(path, endpoints[method]);
57
57
  // @ts-expect-error: it's always an object
58
58
  useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
@@ -16,7 +16,9 @@ const host = () => {
16
16
  target.servers = [];
17
17
  }
18
18
  const { servers } = operation || docs;
19
- const server = Object.assign({}, props);
19
+ const server = {
20
+ ...props,
21
+ };
20
22
  // @ts-expect-error: FIXME
21
23
  servers.push(server);
22
24
  handler[hostContext.key] = { server };
@@ -24,7 +24,9 @@ const host = () => {
24
24
  target.servers = [];
25
25
  }
26
26
  const { servers } = operation || docs;
27
- const server = Object.assign({}, props);
27
+ const server = {
28
+ ...props,
29
+ };
28
30
  // @ts-expect-error: FIXME
29
31
  servers.push(server);
30
32
  handler[useHost.hostContext.key] = { server };
@@ -1,4 +1,3 @@
1
- import { __rest } from 'tslib';
2
1
  import innet, { useNewHandler } from 'innet';
3
2
  import { useProps } from '@innet/jsx';
4
3
  import '../../../hooks/index.es6.js';
@@ -25,8 +24,8 @@ const param = () => {
25
24
  if (!operation.parameters) {
26
25
  operation.parameters = [];
27
26
  }
28
- const _b = useProps(), { children } = _b, props = __rest(_b, ["children"]);
29
- const params = Object.assign({}, props);
27
+ const { children, ...props } = useProps();
28
+ const params = { ...props };
30
29
  if (props.in === 'path') {
31
30
  params.required = (_a = params.required) !== null && _a !== void 0 ? _a : true;
32
31
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var innet = require('innet');
7
6
  var jsx = require('@innet/jsx');
8
7
  require('../../../hooks/index.js');
@@ -33,8 +32,8 @@ const param = () => {
33
32
  if (!operation.parameters) {
34
33
  operation.parameters = [];
35
34
  }
36
- const _b = jsx.useProps(), { children } = _b, props = tslib.__rest(_b, ["children"]);
37
- const params = Object.assign({}, props);
35
+ const { children, ...props } = jsx.useProps();
36
+ const params = { ...props };
38
37
  if (props.in === 'path') {
39
38
  params.required = (_a = params.required) !== null && _a !== void 0 ? _a : true;
40
39
  }
@@ -12,7 +12,11 @@ import { schemaContext } from '../../../hooks/useSchemaContext/useSchemaContext.
12
12
  import { getOrAdd } from '../../../utils/getOrAdd/getOrAdd.es6.js';
13
13
  import { ruleContext } from '../../../hooks/useRule/useRule.es6.js';
14
14
 
15
- const statuses = Object.assign(Object.assign(Object.assign({}, errorStatuses), redirectStatuses), successStatuses);
15
+ const statuses = {
16
+ ...errorStatuses,
17
+ ...redirectStatuses,
18
+ ...successStatuses,
19
+ };
16
20
  const response = () => {
17
21
  var _a;
18
22
  let { children, description = '', status = 'default', type = 'application/json', } = useProps() || {};
@@ -37,9 +41,12 @@ const response = () => {
37
41
  description,
38
42
  };
39
43
  if (schema) {
40
- response.content = Object.assign(Object.assign({}, defaultResponse === null || defaultResponse === void 0 ? void 0 : defaultResponse.content), { [type]: {
44
+ response.content = {
45
+ ...defaultResponse === null || defaultResponse === void 0 ? void 0 : defaultResponse.content,
46
+ [type]: {
41
47
  schema,
42
- } });
48
+ },
49
+ };
43
50
  }
44
51
  operation.responses[status] = response;
45
52
  schemaContext.set(handler, schema);
@@ -20,7 +20,11 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
20
20
 
21
21
  var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
22
22
 
23
- const statuses = Object.assign(Object.assign(Object.assign({}, error.errorStatuses), redirect.redirectStatuses), success.successStatuses);
23
+ const statuses = {
24
+ ...error.errorStatuses,
25
+ ...redirect.redirectStatuses,
26
+ ...success.successStatuses,
27
+ };
24
28
  const response = () => {
25
29
  var _a;
26
30
  let { children, description = '', status = 'default', type = 'application/json', } = jsx.useProps() || {};
@@ -45,9 +49,12 @@ const response = () => {
45
49
  description,
46
50
  };
47
51
  if (schema) {
48
- response.content = Object.assign(Object.assign({}, defaultResponse === null || defaultResponse === void 0 ? void 0 : defaultResponse.content), { [type]: {
52
+ response.content = {
53
+ ...defaultResponse === null || defaultResponse === void 0 ? void 0 : defaultResponse.content,
54
+ [type]: {
49
55
  schema,
50
- } });
56
+ },
57
+ };
51
58
  }
52
59
  operation.responses[status] = response;
53
60
  useSchemaContext.schemaContext.set(handler, schema);
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { type HandlerPlugin } from 'innet';
3
2
  import { type IncomingMessage, type ServerResponse } from 'http';
4
3
  import { type ServerStartParams, type SSL } from '../../../types';
@@ -1,4 +1,3 @@
1
- import { __awaiter } from 'tslib';
2
1
  import innet, { useNewHandler } from 'innet';
3
2
  import { useProps } from '@innet/jsx';
4
3
  import fs from 'node:fs';
@@ -56,15 +55,13 @@ const server = () => {
56
55
  const requestHandler = Object.create(handler);
57
56
  actionContext.set(requestHandler, action);
58
57
  requestHandlerContext.set(requestHandler, requestHandler);
59
- function server() {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- for (const plugin of plugins) {
62
- const result = yield plugin();
63
- if (result !== undefined) {
64
- return result;
65
- }
58
+ async function server() {
59
+ for (const plugin of plugins) {
60
+ const result = await plugin();
61
+ if (result !== undefined) {
62
+ return result;
66
63
  }
67
- });
64
+ }
68
65
  }
69
66
  innet({ props, type: server }, requestHandler);
70
67
  });
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var innet = require('innet');
7
6
  var jsx = require('@innet/jsx');
8
7
  var fs = require('node:fs');
@@ -67,15 +66,13 @@ const server = () => {
67
66
  const requestHandler = Object.create(handler);
68
67
  useAction.actionContext.set(requestHandler, action);
69
68
  useRequestHandler.requestHandlerContext.set(requestHandler, requestHandler);
70
- function server() {
71
- return tslib.__awaiter(this, void 0, void 0, function* () {
72
- for (const plugin of plugins) {
73
- const result = yield plugin();
74
- if (result !== undefined) {
75
- return result;
76
- }
69
+ async function server() {
70
+ for (const plugin of plugins) {
71
+ const result = await plugin();
72
+ if (result !== undefined) {
73
+ return result;
77
74
  }
78
- });
75
+ }
79
76
  }
80
77
  innet__default["default"]({ props, type: server }, requestHandler);
81
78
  });
@@ -1,18 +1,17 @@
1
- import { __rest } from 'tslib';
2
1
  import { useProps } from '@innet/jsx';
3
2
  import '../../../hooks/index.es6.js';
4
3
  import { useHost } from '../../../hooks/useHost/useHost.es6.js';
5
4
 
6
5
  const variable = () => {
7
6
  const { server } = useHost();
8
- const _a = useProps(), { key, values,
7
+ const { key, values,
9
8
  // predefine
10
- value = values === null || values === void 0 ? void 0 : values[0] } = _a, rest = __rest(_a, ["key", "values", "value"]);
9
+ value = values === null || values === void 0 ? void 0 : values[0], ...rest } = useProps();
11
10
  if (!server.variables) {
12
11
  server.variables = {};
13
12
  }
14
13
  // @ts-expect-error: FIXME
15
- server.variables[key] = Object.assign(Object.assign({}, rest), { default: value, enum: values });
14
+ server.variables[key] = { ...rest, default: value, enum: values };
16
15
  };
17
16
 
18
17
  export { variable };
@@ -2,21 +2,20 @@
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
  var useHost = require('../../../hooks/useHost/useHost.js');
9
8
 
10
9
  const variable = () => {
11
10
  const { server } = useHost.useHost();
12
- const _a = jsx.useProps(), { key, values,
11
+ const { key, values,
13
12
  // predefine
14
- value = values === null || values === void 0 ? void 0 : values[0] } = _a, rest = tslib.__rest(_a, ["key", "values", "value"]);
13
+ value = values === null || values === void 0 ? void 0 : values[0], ...rest } = jsx.useProps();
15
14
  if (!server.variables) {
16
15
  server.variables = {};
17
16
  }
18
17
  // @ts-expect-error: FIXME
19
- server.variables[key] = Object.assign(Object.assign({}, rest), { default: value, enum: values });
18
+ server.variables[key] = { ...rest, default: value, enum: values };
20
19
  };
21
20
 
22
21
  exports.variable = variable;
@@ -1,6 +1,6 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
- import { type CookieSerializeOptions } from 'cookie';
3
- export interface CookieProps extends CookieSerializeOptions {
2
+ import { type Cookies } from 'cookie';
3
+ export interface CookieProps extends Cookies {
4
4
  key: string;
5
5
  value?: string;
6
6
  }
@@ -1,11 +1,10 @@
1
- import { __rest } from 'tslib';
2
1
  import { useProps } from '@innet/jsx';
3
2
  import '../../../hooks/index.es6.js';
4
3
  import { useAction } from '../../../hooks/useAction/useAction.es6.js';
5
4
 
6
5
  const cookie = () => {
7
6
  const action = useAction();
8
- const _a = useProps(), { key, value } = _a, opt = __rest(_a, ["key", "value"]);
7
+ const { key, value, ...opt } = useProps();
9
8
  action.setCookie(key, value, opt);
10
9
  };
11
10
 
@@ -2,14 +2,13 @@
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
  var useAction = require('../../../hooks/useAction/useAction.js');
9
8
 
10
9
  const cookie = () => {
11
10
  const action = useAction.useAction();
12
- const _a = jsx.useProps(), { key, value } = _a, opt = tslib.__rest(_a, ["key", "value"]);
11
+ const { key, value, ...opt } = jsx.useProps();
13
12
  action.setCookie(key, value, opt);
14
13
  };
15
14
 
@@ -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';
@@ -59,7 +58,7 @@ const errorStatuses = {
59
58
  webServerIsDown: 521,
60
59
  };
61
60
  const error = () => {
62
- const _a = useProps(), { children } = _a, props = __rest(_a, ["children"]);
61
+ const { children, ...props } = useProps();
63
62
  const res = useResponse();
64
63
  if (!res) {
65
64
  throw Error('<error> MUST be in <request>');
@@ -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');
@@ -63,7 +62,7 @@ const errorStatuses = {
63
62
  webServerIsDown: 521,
64
63
  };
65
64
  const error = () => {
66
- const _a = jsx.useProps(), { children } = _a, props = tslib.__rest(_a, ["children"]);
65
+ const { children, ...props } = jsx.useProps();
67
66
  const res = useResponse.useResponse();
68
67
  if (!res) {
69
68
  throw Error('<error> MUST be in <request>');
@@ -1,4 +1,3 @@
1
- import { __rest } from 'tslib';
2
1
  import innet, { useHandler } from 'innet';
3
2
  import { useProps } from '@innet/jsx';
4
3
  import fs from 'node:fs';
@@ -9,7 +8,7 @@ import { useThrow } from '../../../hooks/useThrow/useThrow.es6.js';
9
8
 
10
9
  function file() {
11
10
  const handler = useHandler();
12
- const _a = useProps(), { children } = _a, props = __rest(_a, ["children"]);
11
+ const { children, ...props } = useProps();
13
12
  const res = useResponse();
14
13
  if (!res) {
15
14
  useThrow('<{type}> MUST be in <request> or <fallback>');
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var innet = require('innet');
7
6
  var jsx = require('@innet/jsx');
8
7
  var fs = require('node:fs');
@@ -19,7 +18,7 @@ var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
19
18
 
20
19
  function file() {
21
20
  const handler = innet.useHandler();
22
- const _a = jsx.useProps(), { children } = _a, props = tslib.__rest(_a, ["children"]);
21
+ const { children, ...props } = jsx.useProps();
23
22
  const res = useResponse.useResponse();
24
23
  if (!res) {
25
24
  useThrow.useThrow('<{type}> MUST be in <request> or <fallback>');
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { type HandlerPlugin } from 'innet';
3
2
  import { type IncomingMessage } from 'http';
4
3
  export interface ProxyProps {