vovk 3.0.0-draft.33 → 3.0.0-draft.331

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 (196) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -96
  3. package/bin/index.mjs +8 -0
  4. package/{HttpException.d.ts → cjs/HttpException.d.ts} +2 -2
  5. package/{HttpException.js → cjs/HttpException.js} +3 -3
  6. package/cjs/JSONLinesResponse.d.ts +19 -0
  7. package/cjs/JSONLinesResponse.js +93 -0
  8. package/{VovkApp.d.ts → cjs/VovkApp.d.ts} +10 -9
  9. package/cjs/VovkApp.js +202 -0
  10. package/cjs/client/createRPC.d.ts +3 -0
  11. package/cjs/client/createRPC.js +90 -0
  12. package/cjs/client/defaultHandler.d.ts +6 -0
  13. package/cjs/client/defaultHandler.js +29 -0
  14. package/cjs/client/defaultStreamHandler.d.ts +9 -0
  15. package/{client → cjs/client}/defaultStreamHandler.js +25 -13
  16. package/cjs/client/fetcher.d.ts +14 -0
  17. package/cjs/client/fetcher.js +93 -0
  18. package/cjs/client/index.d.ts +4 -0
  19. package/cjs/client/index.js +10 -0
  20. package/cjs/client/progressive.d.ts +9 -0
  21. package/cjs/client/progressive.js +45 -0
  22. package/cjs/client/types.d.ts +123 -0
  23. package/{createVovkApp.d.ts → cjs/createVovkApp.d.ts} +12 -11
  24. package/cjs/createVovkApp.js +133 -0
  25. package/cjs/index.d.ts +65 -0
  26. package/cjs/index.js +38 -0
  27. package/cjs/openapi/error.d.ts +2 -0
  28. package/cjs/openapi/error.js +100 -0
  29. package/cjs/openapi/generateFnName.d.ts +23 -0
  30. package/cjs/openapi/generateFnName.js +81 -0
  31. package/cjs/openapi/index.d.ts +12 -0
  32. package/cjs/openapi/index.js +21 -0
  33. package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  34. package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
  35. package/cjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
  36. package/cjs/openapi/openAPIToVovkSchema/index.js +192 -0
  37. package/cjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
  38. package/cjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
  39. package/cjs/openapi/vovkSchemaToOpenAPI.d.ts +9 -0
  40. package/cjs/openapi/vovkSchemaToOpenAPI.js +233 -0
  41. package/cjs/types.d.ts +400 -0
  42. package/cjs/types.js +74 -0
  43. package/cjs/utils/camelCase.d.ts +6 -0
  44. package/cjs/utils/camelCase.js +37 -0
  45. package/cjs/utils/createCodeExamples.d.ts +19 -0
  46. package/cjs/utils/createCodeExamples.js +110 -0
  47. package/cjs/utils/createDecorator.d.ts +6 -0
  48. package/{createDecorator.js → cjs/utils/createDecorator.js} +26 -16
  49. package/cjs/utils/createLLMTools.d.ts +44 -0
  50. package/cjs/utils/createLLMTools.js +118 -0
  51. package/cjs/utils/createStandardValidation.d.ts +81 -0
  52. package/cjs/utils/createStandardValidation.js +33 -0
  53. package/cjs/utils/generateStaticAPI.d.ts +4 -0
  54. package/cjs/utils/generateStaticAPI.js +30 -0
  55. package/cjs/utils/getJSONSchemaExample.d.ts +8 -0
  56. package/cjs/utils/getJSONSchemaExample.js +234 -0
  57. package/cjs/utils/getJSONSchemaSample.d.ts +2 -0
  58. package/cjs/utils/getJSONSchemaSample.js +167 -0
  59. package/cjs/utils/getSchema.d.ts +21 -0
  60. package/cjs/utils/getSchema.js +38 -0
  61. package/cjs/utils/multitenant.d.ts +24 -0
  62. package/cjs/utils/multitenant.js +170 -0
  63. package/cjs/utils/parseQuery.d.ts +25 -0
  64. package/cjs/utils/parseQuery.js +156 -0
  65. package/{utils → cjs/utils}/reqForm.d.ts +1 -2
  66. package/cjs/utils/reqForm.js +33 -0
  67. package/{utils → cjs/utils}/reqMeta.d.ts +1 -2
  68. package/cjs/utils/reqQuery.d.ts +2 -0
  69. package/cjs/utils/reqQuery.js +10 -0
  70. package/cjs/utils/serializeQuery.d.ts +13 -0
  71. package/cjs/utils/serializeQuery.js +65 -0
  72. package/cjs/utils/setHandlerSchema.d.ts +4 -0
  73. package/cjs/utils/setHandlerSchema.js +15 -0
  74. package/cjs/utils/upperFirst.d.ts +1 -0
  75. package/cjs/utils/upperFirst.js +6 -0
  76. package/cjs/utils/withValidationLibrary.d.ts +76 -0
  77. package/cjs/utils/withValidationLibrary.js +123 -0
  78. package/mjs/HttpException.d.ts +7 -0
  79. package/mjs/HttpException.js +15 -0
  80. package/mjs/JSONLinesResponse.d.ts +19 -0
  81. package/mjs/JSONLinesResponse.js +93 -0
  82. package/mjs/VovkApp.d.ts +29 -0
  83. package/mjs/VovkApp.js +202 -0
  84. package/mjs/client/createRPC.d.ts +3 -0
  85. package/mjs/client/createRPC.js +90 -0
  86. package/mjs/client/defaultHandler.d.ts +6 -0
  87. package/mjs/client/defaultHandler.js +29 -0
  88. package/mjs/client/defaultStreamHandler.d.ts +9 -0
  89. package/mjs/client/defaultStreamHandler.js +94 -0
  90. package/mjs/client/fetcher.d.ts +14 -0
  91. package/mjs/client/fetcher.js +93 -0
  92. package/mjs/client/index.d.ts +4 -0
  93. package/mjs/client/index.js +10 -0
  94. package/mjs/client/progressive.d.ts +9 -0
  95. package/mjs/client/progressive.js +45 -0
  96. package/mjs/client/types.d.ts +123 -0
  97. package/mjs/createVovkApp.d.ts +63 -0
  98. package/mjs/createVovkApp.js +133 -0
  99. package/mjs/index.d.ts +65 -0
  100. package/mjs/index.js +38 -0
  101. package/mjs/openapi/error.d.ts +2 -0
  102. package/mjs/openapi/error.js +100 -0
  103. package/mjs/openapi/generateFnName.d.ts +23 -0
  104. package/mjs/openapi/generateFnName.js +81 -0
  105. package/mjs/openapi/index.d.ts +12 -0
  106. package/mjs/openapi/index.js +21 -0
  107. package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  108. package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
  109. package/mjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
  110. package/mjs/openapi/openAPIToVovkSchema/index.js +192 -0
  111. package/mjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
  112. package/mjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
  113. package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +9 -0
  114. package/mjs/openapi/vovkSchemaToOpenAPI.js +233 -0
  115. package/mjs/types.d.ts +400 -0
  116. package/mjs/types.js +74 -0
  117. package/mjs/utils/camelCase.d.ts +6 -0
  118. package/mjs/utils/camelCase.js +37 -0
  119. package/mjs/utils/createCodeExamples.d.ts +19 -0
  120. package/mjs/utils/createCodeExamples.js +110 -0
  121. package/mjs/utils/createDecorator.d.ts +6 -0
  122. package/mjs/utils/createDecorator.js +48 -0
  123. package/mjs/utils/createLLMTools.d.ts +44 -0
  124. package/mjs/utils/createLLMTools.js +118 -0
  125. package/mjs/utils/createStandardValidation.d.ts +81 -0
  126. package/mjs/utils/createStandardValidation.js +33 -0
  127. package/mjs/utils/generateStaticAPI.d.ts +4 -0
  128. package/mjs/utils/generateStaticAPI.js +30 -0
  129. package/mjs/utils/getJSONSchemaExample.d.ts +8 -0
  130. package/mjs/utils/getJSONSchemaExample.js +234 -0
  131. package/mjs/utils/getJSONSchemaSample.d.ts +2 -0
  132. package/mjs/utils/getJSONSchemaSample.js +167 -0
  133. package/mjs/utils/getSchema.d.ts +21 -0
  134. package/mjs/utils/getSchema.js +38 -0
  135. package/mjs/utils/multitenant.d.ts +24 -0
  136. package/mjs/utils/multitenant.js +170 -0
  137. package/mjs/utils/parseQuery.d.ts +25 -0
  138. package/mjs/utils/parseQuery.js +156 -0
  139. package/mjs/utils/reqForm.d.ts +2 -0
  140. package/mjs/utils/reqForm.js +33 -0
  141. package/mjs/utils/reqMeta.d.ts +2 -0
  142. package/mjs/utils/reqMeta.js +13 -0
  143. package/mjs/utils/reqQuery.d.ts +2 -0
  144. package/mjs/utils/reqQuery.js +10 -0
  145. package/mjs/utils/serializeQuery.d.ts +13 -0
  146. package/mjs/utils/serializeQuery.js +65 -0
  147. package/mjs/utils/setHandlerSchema.d.ts +4 -0
  148. package/mjs/utils/setHandlerSchema.js +15 -0
  149. package/mjs/utils/shim.d.ts +1 -0
  150. package/mjs/utils/shim.js +18 -0
  151. package/mjs/utils/upperFirst.d.ts +1 -0
  152. package/mjs/utils/upperFirst.js +6 -0
  153. package/mjs/utils/withValidationLibrary.d.ts +76 -0
  154. package/mjs/utils/withValidationLibrary.js +123 -0
  155. package/package.json +29 -6
  156. package/.npmignore +0 -2
  157. package/StreamJSONResponse.d.ts +0 -17
  158. package/StreamJSONResponse.js +0 -54
  159. package/VovkApp.js +0 -185
  160. package/client/clientizeController.d.ts +0 -4
  161. package/client/clientizeController.js +0 -92
  162. package/client/defaultFetcher.d.ts +0 -4
  163. package/client/defaultFetcher.js +0 -49
  164. package/client/defaultHandler.d.ts +0 -2
  165. package/client/defaultHandler.js +0 -22
  166. package/client/defaultStreamHandler.d.ts +0 -4
  167. package/client/index.d.ts +0 -4
  168. package/client/index.js +0 -5
  169. package/client/types.d.ts +0 -100
  170. package/createDecorator.d.ts +0 -4
  171. package/createVovkApp.js +0 -118
  172. package/index.d.ts +0 -60
  173. package/index.js +0 -20
  174. package/types.d.ts +0 -157
  175. package/types.js +0 -65
  176. package/utils/generateStaticAPI.d.ts +0 -4
  177. package/utils/generateStaticAPI.js +0 -18
  178. package/utils/getSchema.d.ts +0 -8
  179. package/utils/getSchema.js +0 -38
  180. package/utils/reqForm.js +0 -13
  181. package/utils/reqQuery.d.ts +0 -3
  182. package/utils/reqQuery.js +0 -25
  183. package/utils/setClientValidatorsForHandler.d.ts +0 -5
  184. package/utils/setClientValidatorsForHandler.js +0 -25
  185. package/worker/index.d.ts +0 -3
  186. package/worker/index.js +0 -7
  187. package/worker/promisifyWorker.d.ts +0 -2
  188. package/worker/promisifyWorker.js +0 -141
  189. package/worker/types.d.ts +0 -31
  190. package/worker/worker.d.ts +0 -1
  191. package/worker/worker.js +0 -43
  192. /package/{client → cjs/client}/types.js +0 -0
  193. /package/{utils → cjs/utils}/reqMeta.js +0 -0
  194. /package/{utils → cjs/utils}/shim.d.ts +0 -0
  195. /package/{utils → cjs/utils}/shim.js +0 -0
  196. /package/{worker → mjs/client}/types.js +0 -0
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._defaultStreamHandler = exports.DEFAULT_ERROR_MESSAGE = void 0;
3
+ exports.defaultStreamHandler = exports.DEFAULT_ERROR_MESSAGE = void 0;
4
4
  const types_1 = require("../types");
5
5
  const HttpException_1 = require("../HttpException");
6
6
  require("../utils/shim");
7
7
  exports.DEFAULT_ERROR_MESSAGE = 'Unknown error at defaultStreamHandler';
8
- const _defaultStreamHandler = async (response) => {
8
+ const defaultStreamHandler = async ({ response, controller, }) => {
9
9
  if (!response.ok) {
10
10
  let result;
11
11
  try {
@@ -15,20 +15,23 @@ const _defaultStreamHandler = async (response) => {
15
15
  // ignore parsing errors
16
16
  }
17
17
  // handle server errors
18
- throw new HttpException_1._HttpException(response.status, result.message ?? exports.DEFAULT_ERROR_MESSAGE);
18
+ throw new HttpException_1.HttpException(response.status, result.message ?? exports.DEFAULT_ERROR_MESSAGE);
19
19
  }
20
20
  if (!response.body)
21
- throw new HttpException_1._HttpException(types_1._HttpStatus.NULL, 'Stream body is falsy. Check your controller code.');
21
+ throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, 'Stream body is falsy. Check your controller code.');
22
22
  const reader = response.body.getReader();
23
23
  // if streaming is too rapid, we need to make sure that the loop is stopped
24
24
  let canceled = false;
25
+ const subscribers = new Set();
25
26
  async function* asyncIterator() {
26
27
  let prepend = '';
27
28
  while (true) {
28
29
  let value;
29
- let done = false;
30
30
  try {
31
+ let done;
31
32
  ({ value, done } = await reader.read());
33
+ if (done)
34
+ break;
32
35
  }
33
36
  catch (error) {
34
37
  await reader.cancel();
@@ -36,9 +39,6 @@ const _defaultStreamHandler = async (response) => {
36
39
  err.cause = error;
37
40
  throw err;
38
41
  }
39
- if (done) {
40
- return;
41
- }
42
42
  // typeof value === 'number' is a workaround for React Native
43
43
  const string = typeof value === 'number' ? String.fromCharCode(value) : new TextDecoder().decode(value);
44
44
  prepend += string;
@@ -53,6 +53,10 @@ const _defaultStreamHandler = async (response) => {
53
53
  break;
54
54
  }
55
55
  if (data) {
56
+ subscribers.forEach((cb) => {
57
+ if (!canceled)
58
+ cb(data);
59
+ });
56
60
  if ('isError' in data && 'reason' in data) {
57
61
  const upcomingError = data.reason;
58
62
  await reader.cancel();
@@ -71,12 +75,20 @@ const _defaultStreamHandler = async (response) => {
71
75
  return {
72
76
  status: response.status,
73
77
  [Symbol.asyncIterator]: asyncIterator,
74
- [Symbol.dispose]: () => reader.cancel(),
75
- [Symbol.asyncDispose]: () => reader.cancel(),
76
- cancel: () => {
78
+ [Symbol.dispose]: () => controller.abort(),
79
+ [Symbol.asyncDispose]: () => controller.abort(),
80
+ onIterate: (cb) => {
81
+ if (canceled)
82
+ return () => { };
83
+ subscribers.add(cb);
84
+ return () => {
85
+ subscribers.delete(cb);
86
+ };
87
+ },
88
+ abort: () => {
77
89
  canceled = true;
78
- return reader.cancel();
90
+ return controller.abort();
79
91
  },
80
92
  };
81
93
  };
82
- exports._defaultStreamHandler = _defaultStreamHandler;
94
+ exports.defaultStreamHandler = defaultStreamHandler;
@@ -0,0 +1,14 @@
1
+ import type { VovkDefaultFetcherOptions, VovkClientFetcher } from './types';
2
+ import { KnownAny } from '../types';
3
+ export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
4
+ export declare function createFetcher<T>({ prepareRequestInit, transformResponse, }?: {
5
+ prepareRequestInit?: (init: RequestInit, options: VovkDefaultFetcherOptions<T>) => RequestInit | Promise<RequestInit> | void | Promise<void>;
6
+ transformResponse?: (respData: KnownAny, response: Response, options: VovkDefaultFetcherOptions<T>, init: RequestInit) => unknown;
7
+ }): VovkClientFetcher<VovkDefaultFetcherOptions<T>>;
8
+ export declare const fetcher: VovkClientFetcher<{
9
+ apiRoot?: string;
10
+ disableClientValidation?: boolean;
11
+ validateOnClient?: import("./types").VovkValidateOnClient;
12
+ interpretAs?: string;
13
+ init?: RequestInit;
14
+ }>;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetcher = exports.DEFAULT_ERROR_MESSAGE = void 0;
4
+ exports.createFetcher = createFetcher;
5
+ const types_1 = require("../types");
6
+ const HttpException_1 = require("../HttpException");
7
+ exports.DEFAULT_ERROR_MESSAGE = 'Unknown error at default fetcher';
8
+ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
9
+ // fetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
10
+ // For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
11
+ const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler, schema }, options) => {
12
+ const { params, query, body, meta, apiRoot, disableClientValidation, init, interpretAs } = options;
13
+ const endpoint = getEndpoint({ apiRoot, params, query });
14
+ const unusedParams = Array.from(new URL(endpoint.startsWith('/') ? `http://localhost${endpoint}` : endpoint).pathname.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]);
15
+ if (unusedParams.length) {
16
+ throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, `Unused params: ${unusedParams.join(', ')} in ${endpoint}`, {
17
+ body,
18
+ query,
19
+ params,
20
+ endpoint,
21
+ });
22
+ }
23
+ if (!disableClientValidation) {
24
+ try {
25
+ await validate({ body, query, params, endpoint });
26
+ }
27
+ catch (e) {
28
+ // if HttpException is thrown, rethrow it
29
+ if (e instanceof HttpException_1.HttpException)
30
+ throw e;
31
+ // otherwise, throw HttpException with status 0
32
+ throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e.message ?? exports.DEFAULT_ERROR_MESSAGE, {
33
+ body,
34
+ query,
35
+ params,
36
+ endpoint,
37
+ });
38
+ }
39
+ }
40
+ let requestInit = {
41
+ method: httpMethod,
42
+ ...init,
43
+ headers: {
44
+ accept: 'application/jsonl, application/json',
45
+ ...(body instanceof FormData ? {} : { 'content-type': 'application/json' }),
46
+ ...(meta ? { 'x-meta': JSON.stringify(meta) } : {}),
47
+ ...init?.headers,
48
+ },
49
+ };
50
+ if (body instanceof FormData) {
51
+ requestInit.body = body;
52
+ }
53
+ else if (body) {
54
+ requestInit.body = JSON.stringify(body);
55
+ }
56
+ requestInit = prepareRequestInit
57
+ ? ((await prepareRequestInit(requestInit, options)) ?? requestInit)
58
+ : requestInit;
59
+ let response;
60
+ const controller = new AbortController();
61
+ requestInit.signal = controller.signal;
62
+ try {
63
+ response = await fetch(endpoint, requestInit);
64
+ }
65
+ catch (e) {
66
+ // handle network errors
67
+ throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, (e?.message ?? exports.DEFAULT_ERROR_MESSAGE) + ' ' + endpoint, {
68
+ body,
69
+ query,
70
+ params,
71
+ endpoint,
72
+ });
73
+ }
74
+ const contentType = interpretAs ?? response.headers.get('content-type');
75
+ let resp;
76
+ if (contentType?.startsWith('application/jsonl')) {
77
+ resp = defaultStreamHandler({ response, controller, schema });
78
+ }
79
+ else if (contentType?.startsWith('application/json')) {
80
+ resp = defaultHandler({ response, schema });
81
+ }
82
+ else {
83
+ resp = response;
84
+ }
85
+ resp = await resp;
86
+ resp = transformResponse
87
+ ? await transformResponse(resp, response, options, requestInit)
88
+ : resp;
89
+ return [resp, response];
90
+ };
91
+ return newFetcher;
92
+ }
93
+ exports.fetcher = createFetcher();
@@ -0,0 +1,4 @@
1
+ export { createRPC } from './createRPC';
2
+ export { fetcher, createFetcher } from './fetcher';
3
+ export { progressive } from './progressive';
4
+ export type { VovkClient, VovkClientFetcher, VovkDefaultFetcherOptions, VovkValidateOnClient, VovkStreamAsyncIterable, } from './types';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.progressive = exports.createFetcher = exports.fetcher = exports.createRPC = void 0;
4
+ var createRPC_1 = require("./createRPC");
5
+ Object.defineProperty(exports, "createRPC", { enumerable: true, get: function () { return createRPC_1.createRPC; } });
6
+ var fetcher_1 = require("./fetcher");
7
+ Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return fetcher_1.fetcher; } });
8
+ Object.defineProperty(exports, "createFetcher", { enumerable: true, get: function () { return fetcher_1.createFetcher; } });
9
+ var progressive_1 = require("./progressive");
10
+ Object.defineProperty(exports, "progressive", { enumerable: true, get: function () { return progressive_1.progressive; } });
@@ -0,0 +1,9 @@
1
+ import type { VovkStreamAsyncIterable } from './types';
2
+ import type { KnownAny, VovkYieldType } from '../types';
3
+ type UnionToIntersection<U> = (U extends KnownAny ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
4
+ type PromisifyProperties<T> = {
5
+ [K in keyof T]: Promise<T[K]>;
6
+ };
7
+ type TransformUnionToPromises<T> = PromisifyProperties<UnionToIntersection<T>>;
8
+ export declare function progressive<T extends (...args: KnownAny[]) => Promise<VovkStreamAsyncIterable<KnownAny>>>(fn: T, ...args: undefined extends Parameters<T>[0] ? [arg?: Parameters<T>[0]] : [arg: Parameters<T>[0]]): TransformUnionToPromises<VovkYieldType<T>>;
9
+ export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.progressive = progressive;
4
+ function progressive(fn, ...args) {
5
+ const [arg] = args;
6
+ const reg = {};
7
+ void fn(arg)
8
+ .then(async (result) => {
9
+ for await (const item of result) {
10
+ for (const [key, value] of Object.entries(item)) {
11
+ if (key in reg) {
12
+ if (!reg[key].isSettled) {
13
+ reg[key].isSettled = true;
14
+ reg[key].resolve(value);
15
+ }
16
+ }
17
+ else {
18
+ const { promise, resolve, reject } = Promise.withResolvers();
19
+ reg[key] = { resolve, reject, promise, isSettled: true };
20
+ reg[key].resolve(value);
21
+ }
22
+ }
23
+ }
24
+ return result;
25
+ })
26
+ .catch((error) => {
27
+ Object.keys(reg).forEach((key) => {
28
+ if (reg[key].isSettled)
29
+ return;
30
+ reg[key].isSettled = true;
31
+ reg[key].reject(error);
32
+ });
33
+ return error;
34
+ });
35
+ return new Proxy({}, {
36
+ get(_target, prop) {
37
+ if (prop in reg) {
38
+ return reg[prop].promise;
39
+ }
40
+ const { promise, resolve, reject } = Promise.withResolvers();
41
+ reg[prop] = { resolve, reject, promise, isSettled: false };
42
+ return promise;
43
+ },
44
+ });
45
+ }
@@ -0,0 +1,123 @@
1
+ import type { KnownAny, HttpMethod, ControllerStaticMethod, VovkHandlerSchema, VovkControllerSchema, VovkSegmentSchema, VovkSchema, VovkRequest } from '../types';
2
+ import type { JSONLinesResponse } from '../JSONLinesResponse';
3
+ import type { NextResponse } from 'next/server';
4
+ import type { defaultStreamHandler } from './defaultStreamHandler';
5
+ import type { defaultHandler } from './defaultHandler';
6
+ type OmitNullable<T> = {
7
+ [K in keyof T as T[K] extends null | undefined ? never : K]: T[K];
8
+ };
9
+ type Empty = {};
10
+ export type StaticMethodInput<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => KnownAny) & {
11
+ __types?: {
12
+ isForm: boolean;
13
+ };
14
+ }> = OmitNullable<(Parameters<T>[0] extends VovkRequest<infer BODY, infer QUERY, infer PARAMS> ? (BODY extends Record<KnownAny, KnownAny> ? {
15
+ body: T['__types'] extends {
16
+ isForm: true;
17
+ } ? FormData : BODY;
18
+ } : Empty) & (QUERY extends Record<KnownAny, KnownAny> ? {
19
+ query: QUERY;
20
+ } : Empty) & (PARAMS extends Record<KnownAny, KnownAny> ? {
21
+ params: PARAMS;
22
+ } : Empty) & {
23
+ meta?: {
24
+ [key: string]: KnownAny;
25
+ };
26
+ } : Empty) & (Parameters<T>[1] extends Record<KnownAny, KnownAny> ? {
27
+ params: Parameters<T>[1];
28
+ } : Empty)>;
29
+ type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
30
+ export type VovkStreamAsyncIterable<T> = {
31
+ status: number;
32
+ [Symbol.dispose](): Promise<void> | void;
33
+ [Symbol.asyncDispose](): Promise<void> | void;
34
+ [Symbol.asyncIterator](): AsyncIterator<T>;
35
+ onIterate: (cb: (data: T) => void) => () => void;
36
+ abort: () => Promise<void> | void;
37
+ };
38
+ type StaticMethodReturn<T extends ControllerStaticMethod> = ReturnType<T> extends NextResponse<infer U> | Promise<NextResponse<infer U>> ? U : ReturnType<T> extends Response | Promise<Response> ? Awaited<ReturnType<T>> : ReturnType<T>;
39
+ type StaticMethodReturnPromise<T extends ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
40
+ type StaticMethodOptions<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<STREAM> | Promise<JSONLinesResponse<STREAM>>, OPTS extends Record<string, KnownAny>, STREAM, R, F extends VovkDefaultFetcherOptions<KnownAny>> = Partial<OPTS & {
41
+ transform: (staticMethodReturn: Awaited<StaticMethodReturn<T>>, resp: Response) => R;
42
+ fetcher: VovkClientFetcher<F>;
43
+ }>;
44
+ type ClientMethodReturn<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<STREAM> | Promise<JSONLinesResponse<STREAM>>, STREAM, R> = ReturnType<T> extends Promise<JSONLinesResponse<infer U>> | JSONLinesResponse<infer U> | Iterator<infer U> | AsyncIterator<infer U> ? Promise<VovkStreamAsyncIterable<U>> : R extends object ? Promise<Awaited<R>> : StaticMethodReturnPromise<T>;
45
+ type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<STREAM> | Promise<JSONLinesResponse<STREAM>>) & {
46
+ __types?: {
47
+ body: KnownAny;
48
+ query: KnownAny;
49
+ params: KnownAny;
50
+ output: KnownAny;
51
+ iteration: KnownAny;
52
+ isForm: boolean;
53
+ };
54
+ }, OPTS extends Record<string, KnownAny>, STREAM extends KnownAny = unknown> = (IsEmptyObject<StaticMethodInput<T>> extends true ? <R, F extends VovkDefaultFetcherOptions<KnownAny> = VovkDefaultFetcherOptions<OPTS>>(options?: Prettify<StaticMethodOptions<T, OPTS, STREAM, R, F>>) => ClientMethodReturn<T, STREAM, R> : <R, F extends VovkDefaultFetcherOptions<KnownAny> = VovkDefaultFetcherOptions<OPTS>>(options: Prettify<StaticMethodInput<T> & StaticMethodOptions<T, OPTS, STREAM, R, F>>) => ClientMethodReturn<T, STREAM, R>) & {
55
+ isRPC: true;
56
+ schema: VovkHandlerSchema;
57
+ controllerSchema: VovkControllerSchema;
58
+ segmentSchema: VovkSegmentSchema;
59
+ fullSchema: VovkSchema;
60
+ __types: T['__types'];
61
+ };
62
+ type OmitNever<T> = {
63
+ [K in keyof T as T[K] extends never ? never : K]: T[K];
64
+ };
65
+ type VovkClientWithNever<T, OPTS extends {
66
+ [key: string]: KnownAny;
67
+ }> = {
68
+ [K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], OPTS> : never;
69
+ };
70
+ export type VovkClient<T, OPTS extends {
71
+ [key: string]: KnownAny;
72
+ }> = OmitNever<VovkClientWithNever<T, OPTS>>;
73
+ export type VovkClientFetcher<OPTS> = (options: {
74
+ name: string;
75
+ httpMethod: HttpMethod;
76
+ getEndpoint: (data: {
77
+ apiRoot: string | undefined;
78
+ params: {
79
+ [key: string]: string;
80
+ };
81
+ query: {
82
+ [key: string]: string;
83
+ };
84
+ }) => string;
85
+ validate: (input: {
86
+ body?: unknown;
87
+ query?: unknown;
88
+ params?: unknown;
89
+ endpoint: string;
90
+ }) => void | Promise<void>;
91
+ defaultStreamHandler: typeof defaultStreamHandler;
92
+ defaultHandler: typeof defaultHandler;
93
+ schema: VovkHandlerSchema;
94
+ }, input: {
95
+ body: unknown;
96
+ query: {
97
+ [key: string]: string;
98
+ };
99
+ params: {
100
+ [key: string]: string;
101
+ };
102
+ meta?: {
103
+ [key: string]: KnownAny;
104
+ };
105
+ } & OPTS) => Promise<[KnownAny, Response]>;
106
+ export type VovkDefaultFetcherOptions<T> = T & {
107
+ apiRoot?: string;
108
+ disableClientValidation?: boolean;
109
+ validateOnClient?: VovkValidateOnClient;
110
+ interpretAs?: string;
111
+ init?: RequestInit;
112
+ };
113
+ export type VovkValidateOnClient = (input: {
114
+ body?: unknown;
115
+ query?: unknown;
116
+ params?: unknown;
117
+ endpoint: string;
118
+ }, validation: Omit<Exclude<VovkHandlerSchema['validation'], undefined>, 'output' | 'iteration'>, fullSchema: VovkSchema) => void | Promise<void>;
119
+ type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : T extends Partial<T> ? Partial<T> extends T ? true : false : false : false;
120
+ type Prettify<T> = {
121
+ [K in keyof T]: T[K];
122
+ } & {};
123
+ export {};
@@ -1,5 +1,6 @@
1
- import { type _KnownAny as KnownAny, type _DecoratorOptions as DecoratorOptions, type _VovkRequest as VovkRequest, type _StaticClass as StaticClass } from './types';
2
- export declare function _createVovkApp(): {
1
+ import type { NextRequest } from 'next/server';
2
+ import { type KnownAny, type DecoratorOptions, type VovkRequest, type StaticClass } from './types';
3
+ export declare function createVovkApp(): {
3
4
  get: {
4
5
  (givenPath?: string | undefined, options?: DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
5
6
  auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
@@ -29,33 +30,33 @@ export declare function _createVovkApp(): {
29
30
  auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
30
31
  };
31
32
  prefix: (givenPath?: string) => (givenTarget: KnownAny) => any;
32
- initVovk: (options: {
33
+ initSegment: (options: {
33
34
  segmentName?: string;
34
35
  controllers: Record<string, StaticClass>;
35
- workers?: Record<string, StaticClass>;
36
36
  exposeValidation?: boolean;
37
37
  emitSchema?: boolean;
38
+ forceApiRoot?: string;
38
39
  onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
39
40
  }) => {
40
- GET: (req: VovkRequest, data: {
41
+ GET: (req: NextRequest, data: {
41
42
  params: Promise<Record<string, string[]>>;
42
43
  }) => Promise<Response>;
43
- POST: (req: VovkRequest, data: {
44
+ POST: (req: NextRequest, data: {
44
45
  params: Promise<Record<string, string[]>>;
45
46
  }) => Promise<Response>;
46
- PUT: (req: VovkRequest, data: {
47
+ PUT: (req: NextRequest, data: {
47
48
  params: Promise<Record<string, string[]>>;
48
49
  }) => Promise<Response>;
49
- PATCH: (req: VovkRequest, data: {
50
+ PATCH: (req: NextRequest, data: {
50
51
  params: Promise<Record<string, string[]>>;
51
52
  }) => Promise<Response>;
52
- DELETE: (req: VovkRequest, data: {
53
+ DELETE: (req: NextRequest, data: {
53
54
  params: Promise<Record<string, string[]>>;
54
55
  }) => Promise<Response>;
55
- HEAD: (req: VovkRequest, data: {
56
+ HEAD: (req: NextRequest, data: {
56
57
  params: Promise<Record<string, string[]>>;
57
58
  }) => Promise<Response>;
58
- OPTIONS: (req: VovkRequest, data: {
59
+ OPTIONS: (req: NextRequest, data: {
59
60
  params: Promise<Record<string, string[]>>;
60
61
  }) => Promise<Response>;
61
62
  };
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createVovkApp = createVovkApp;
7
+ const VovkApp_1 = require("./VovkApp");
8
+ const types_1 = require("./types");
9
+ const getSchema_1 = __importDefault(require("./utils/getSchema"));
10
+ const trimPath = (path) => path.trim().replace(/^\/|\/$/g, '');
11
+ const isClass = (func) => typeof func === 'function' && /class/.test(func.toString());
12
+ const toKebabCase = (str) => str
13
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2') // Add hyphen between lowercase/digit and uppercase
14
+ .replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2') // Add hyphen between uppercase letters if the second one is followed by a lowercase
15
+ .toLowerCase()
16
+ .replace(/^-/, ''); // Remove leading hyphen
17
+ const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovkApp, }) => {
18
+ if (typeof window !== 'undefined') {
19
+ throw new Error('HTTP decorators can be used on server-side only. You have probably imported a controller on the client-side.');
20
+ }
21
+ if (!isClass(controller)) {
22
+ let decoratorName = httpMethod.toLowerCase();
23
+ if (decoratorName === 'delete')
24
+ decoratorName = 'del';
25
+ throw new Error(`Decorator must be used on a static class method. Check the controller method named "${propertyKey}" used with @${decoratorName}().`);
26
+ }
27
+ const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
28
+ vovkApp.routes[httpMethod].set(controller, methods);
29
+ const originalMethod = controller[propertyKey];
30
+ originalMethod._controller = controller;
31
+ originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
32
+ const schema = originalMethod._sourceMethod._getSchema?.(controller);
33
+ originalMethod.schema = schema;
34
+ originalMethod.fn = originalMethod._sourceMethod?.fn;
35
+ originalMethod.models = originalMethod._sourceMethod?.models;
36
+ originalMethod._sourceMethod.wrapper = originalMethod;
37
+ controller._handlers = {
38
+ ...controller._handlers,
39
+ [propertyKey]: {
40
+ ...schema,
41
+ ...(controller._handlers ?? {})[propertyKey],
42
+ path,
43
+ httpMethod,
44
+ },
45
+ };
46
+ methods[path] = originalMethod;
47
+ methods[path]._options = options;
48
+ controller._handlersMetadata = {
49
+ ...controller._handlersMetadata,
50
+ [propertyKey]: {
51
+ ...(controller._handlersMetadata ?? {})[propertyKey],
52
+ staticParams: options?.staticParams,
53
+ },
54
+ };
55
+ };
56
+ function createVovkApp() {
57
+ const vovkApp = new VovkApp_1.VovkApp();
58
+ const createHTTPDecorator = (httpMethod) => {
59
+ function decoratorCreator(givenPath = '', options) {
60
+ const path = trimPath(givenPath);
61
+ function decorator(givenTarget, propertyKey) {
62
+ const controller = givenTarget;
63
+ assignSchema({ controller, propertyKey, path, options, httpMethod, vovkApp });
64
+ }
65
+ return decorator;
66
+ }
67
+ const auto = (options) => {
68
+ function decorator(givenTarget, propertyKey) {
69
+ const controller = givenTarget;
70
+ const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
71
+ vovkApp.routes[httpMethod].set(controller, methods);
72
+ controller._handlers = {
73
+ ...controller._handlers,
74
+ [propertyKey]: {
75
+ ...(controller._handlers ?? {})[propertyKey],
76
+ httpMethod,
77
+ },
78
+ };
79
+ const properties = Object.keys(controller._handlers[propertyKey]?.validation?.params?.properties ?? {});
80
+ const kebab = toKebabCase(propertyKey); // 🥙
81
+ const path = properties.length ? `${kebab}/${properties.map((prop) => `:${prop}`).join('/')}` : kebab;
82
+ assignSchema({ controller, propertyKey, path, options, httpMethod, vovkApp });
83
+ }
84
+ return decorator;
85
+ };
86
+ const enhancedDecoratorCreator = decoratorCreator;
87
+ enhancedDecoratorCreator.auto = auto;
88
+ return enhancedDecoratorCreator;
89
+ };
90
+ const prefix = (givenPath = '') => {
91
+ const path = trimPath(givenPath);
92
+ return (givenTarget) => {
93
+ const controller = givenTarget;
94
+ controller._prefix = path;
95
+ return givenTarget;
96
+ };
97
+ };
98
+ const initSegment = (options) => {
99
+ options.segmentName = trimPath(options.segmentName ?? '');
100
+ for (const [rpcModuleName, controller] of Object.entries(options.controllers ?? {})) {
101
+ controller._rpcModuleName = rpcModuleName;
102
+ controller._onError = options?.onError;
103
+ }
104
+ async function GET_DEV(req, data) {
105
+ const params = await data.params;
106
+ if (params[Object.keys(params)[0]]?.[0] === '_schema_') {
107
+ const schema = await (0, getSchema_1.default)(options);
108
+ return vovkApp.respond(200, { schema });
109
+ }
110
+ return vovkApp.GET(req, data);
111
+ }
112
+ return {
113
+ GET: process.env.NODE_ENV === 'development' ? GET_DEV : vovkApp.GET,
114
+ POST: vovkApp.POST,
115
+ PUT: vovkApp.PUT,
116
+ PATCH: vovkApp.PATCH,
117
+ DELETE: vovkApp.DELETE,
118
+ HEAD: vovkApp.HEAD,
119
+ OPTIONS: vovkApp.OPTIONS,
120
+ };
121
+ };
122
+ return {
123
+ get: createHTTPDecorator(types_1.HttpMethod.GET),
124
+ post: createHTTPDecorator(types_1.HttpMethod.POST),
125
+ put: createHTTPDecorator(types_1.HttpMethod.PUT),
126
+ patch: createHTTPDecorator(types_1.HttpMethod.PATCH),
127
+ del: createHTTPDecorator(types_1.HttpMethod.DELETE),
128
+ head: createHTTPDecorator(types_1.HttpMethod.HEAD),
129
+ options: createHTTPDecorator(types_1.HttpMethod.OPTIONS),
130
+ prefix,
131
+ initSegment,
132
+ };
133
+ }
package/cjs/index.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { createVovkApp } from './createVovkApp';
2
+ import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod } from './types';
3
+ import { type VovkClient, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC, fetcher, createFetcher, progressive } from './client/index';
4
+ import { openapi, openAPIToVovkSchema, vovkSchemaToOpenAPI } from './openapi/index';
5
+ import { HttpException } from './HttpException';
6
+ import { createDecorator } from './utils/createDecorator';
7
+ import { JSONLinesResponse } from './JSONLinesResponse';
8
+ import { generateStaticAPI } from './utils/generateStaticAPI';
9
+ import { withValidationLibrary } from './utils/withValidationLibrary';
10
+ import { createStandardValidation } from './utils/createStandardValidation';
11
+ import { multitenant } from './utils/multitenant';
12
+ import { createLLMTools } from './utils/createLLMTools';
13
+ import { createCodeExamples } from './utils/createCodeExamples';
14
+ export { type KnownAny, type VovkClient, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeExamples, progressive, openapi, openAPIToVovkSchema, vovkSchemaToOpenAPI, };
15
+ export declare const get: {
16
+ (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
17
+ auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
18
+ }, post: {
19
+ (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
20
+ auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
21
+ }, put: {
22
+ (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
23
+ auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
24
+ }, patch: {
25
+ (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
26
+ auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
27
+ }, del: {
28
+ (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
29
+ auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
30
+ }, head: {
31
+ (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
32
+ auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
33
+ }, options: {
34
+ (givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
35
+ auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
36
+ }, prefix: (givenPath?: string) => (givenTarget: KnownAny) => any, initSegment: (options: {
37
+ segmentName?: string;
38
+ controllers: Record<string, import("./types").StaticClass>;
39
+ exposeValidation?: boolean;
40
+ emitSchema?: boolean;
41
+ forceApiRoot?: string;
42
+ onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
43
+ }) => {
44
+ GET: (req: import("next/server").NextRequest, data: {
45
+ params: Promise<Record<string, string[]>>;
46
+ }) => Promise<Response>;
47
+ POST: (req: import("next/server").NextRequest, data: {
48
+ params: Promise<Record<string, string[]>>;
49
+ }) => Promise<Response>;
50
+ PUT: (req: import("next/server").NextRequest, data: {
51
+ params: Promise<Record<string, string[]>>;
52
+ }) => Promise<Response>;
53
+ PATCH: (req: import("next/server").NextRequest, data: {
54
+ params: Promise<Record<string, string[]>>;
55
+ }) => Promise<Response>;
56
+ DELETE: (req: import("next/server").NextRequest, data: {
57
+ params: Promise<Record<string, string[]>>;
58
+ }) => Promise<Response>;
59
+ HEAD: (req: import("next/server").NextRequest, data: {
60
+ params: Promise<Record<string, string[]>>;
61
+ }) => Promise<Response>;
62
+ OPTIONS: (req: import("next/server").NextRequest, data: {
63
+ params: Promise<Record<string, string[]>>;
64
+ }) => Promise<Response>;
65
+ };