vovk-hello-world 0.0.69 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/chunk.cjs +42 -0
- package/chunk.mjs +33 -0
- package/fetcher.cjs +252 -0
- package/fetcher.mjs +235 -0
- package/fetcher2.cjs +8 -0
- package/fetcher2.mjs +5 -0
- package/index.cjs +542 -7
- package/index.d.cts +140 -47
- package/index.d.mts +143 -50
- package/index.mjs +542 -7
- package/package.json +2 -3
- package/vovk-ajv.cjs +4409 -0
- package/vovk-ajv.mjs +4406 -0
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<!-- Generated by vovk-cli v0.0.1-beta.
|
|
1
|
+
<!-- Generated by vovk-cli v0.0.1-beta.67 at 2026-01-11T19:20:08.894Z -->
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
# vovk-hello-world v0.0.
|
|
4
|
+
# vovk-hello-world v0.0.70 [](https://www.typescriptlang.org/) [](https://vovk.dev)
|
|
5
5
|
|
|
6
|
-
> A
|
|
6
|
+
> A "Hello World!" app built with Next.js, Vovk.ts and Zod. For details, visit https://vovk.dev/hello-world
|
|
7
7
|
|
|
8
8
|
License: **MIT**
|
|
9
9
|
|
package/chunk.cjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(exports, '__commonJSMin', {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return __commonJSMin;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, '__toDynamicImportESM', {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return __toDynamicImportESM;
|
|
41
|
+
}
|
|
42
|
+
});
|
package/chunk.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
__defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { __require as n, __toDynamicImportESM as r, __commonJSMin as t };
|
package/fetcher.cjs
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
const require_chunk = require('./chunk.cjs');
|
|
2
|
+
|
|
3
|
+
//#region node_modules/vovk/mjs/types.js
|
|
4
|
+
var require_types = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VovkSchemaIdEnum = exports.HttpStatus = exports.HttpMethod = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* HTTP methods
|
|
9
|
+
*/
|
|
10
|
+
var HttpMethod;
|
|
11
|
+
(function(HttpMethod) {
|
|
12
|
+
HttpMethod["GET"] = "GET";
|
|
13
|
+
HttpMethod["POST"] = "POST";
|
|
14
|
+
HttpMethod["PUT"] = "PUT";
|
|
15
|
+
HttpMethod["PATCH"] = "PATCH";
|
|
16
|
+
HttpMethod["DELETE"] = "DELETE";
|
|
17
|
+
HttpMethod["HEAD"] = "HEAD";
|
|
18
|
+
HttpMethod["OPTIONS"] = "OPTIONS";
|
|
19
|
+
})(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
|
|
20
|
+
/**
|
|
21
|
+
* HTTP status codes
|
|
22
|
+
*/
|
|
23
|
+
var HttpStatus;
|
|
24
|
+
(function(HttpStatus) {
|
|
25
|
+
HttpStatus[HttpStatus["NULL"] = 0] = "NULL";
|
|
26
|
+
HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
|
|
27
|
+
HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
28
|
+
HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
|
|
29
|
+
HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
30
|
+
HttpStatus[HttpStatus["OK"] = 200] = "OK";
|
|
31
|
+
HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
|
|
32
|
+
HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
|
|
33
|
+
HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
34
|
+
HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
35
|
+
HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
36
|
+
HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
37
|
+
HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
38
|
+
HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
39
|
+
HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
|
|
40
|
+
HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
41
|
+
HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
42
|
+
HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
43
|
+
HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
44
|
+
HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
45
|
+
HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
46
|
+
HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
47
|
+
HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
48
|
+
HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
49
|
+
HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
50
|
+
HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
51
|
+
HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
52
|
+
HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
53
|
+
HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
|
|
54
|
+
HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
|
|
55
|
+
HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
56
|
+
HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
57
|
+
HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
58
|
+
HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
59
|
+
HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
60
|
+
HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
61
|
+
HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
62
|
+
HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
63
|
+
HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
|
|
64
|
+
HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
65
|
+
HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
66
|
+
HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
67
|
+
HttpStatus[HttpStatus["TOO_MANY_TRequestS"] = 429] = "TOO_MANY_TRequestS";
|
|
68
|
+
HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
69
|
+
HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
70
|
+
HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
71
|
+
HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
72
|
+
HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
73
|
+
HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
74
|
+
})(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
|
|
75
|
+
/**
|
|
76
|
+
* IDs of the JSON Schema files that can be generated by Vovk.ts
|
|
77
|
+
*/
|
|
78
|
+
var VovkSchemaIdEnum;
|
|
79
|
+
(function(VovkSchemaIdEnum) {
|
|
80
|
+
VovkSchemaIdEnum["META"] = "https://vovk.dev/api/schema/v3/meta.json";
|
|
81
|
+
VovkSchemaIdEnum["CONFIG"] = "https://vovk.dev/api/schema/v3/config.json";
|
|
82
|
+
VovkSchemaIdEnum["SEGMENT"] = "https://vovk.dev/api/schema/v3/segment.json";
|
|
83
|
+
VovkSchemaIdEnum["SCHEMA"] = "https://vovk.dev/api/schema/v3/schema.json";
|
|
84
|
+
})(VovkSchemaIdEnum || (exports.VovkSchemaIdEnum = VovkSchemaIdEnum = {}));
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region node_modules/vovk/mjs/core/HttpException.js
|
|
89
|
+
var require_HttpException = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
90
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
+
exports.HttpException = void 0;
|
|
92
|
+
/**
|
|
93
|
+
* Represents an HTTP exception with a status code and message.
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* throw new HttpException(HttpStatus.BAD_REQUEST, 'Invalid request data');
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
var HttpException = class extends Error {
|
|
100
|
+
statusCode;
|
|
101
|
+
message;
|
|
102
|
+
cause;
|
|
103
|
+
constructor(statusCode, message, cause) {
|
|
104
|
+
super(message);
|
|
105
|
+
this.statusCode = statusCode;
|
|
106
|
+
this.message = message;
|
|
107
|
+
this.cause = cause;
|
|
108
|
+
}
|
|
109
|
+
toJSON() {
|
|
110
|
+
return {
|
|
111
|
+
isError: true,
|
|
112
|
+
statusCode: this.statusCode,
|
|
113
|
+
message: this.message,
|
|
114
|
+
...this.cause ? { cause: this.cause } : {}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
exports.HttpException = HttpException;
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region node_modules/vovk/mjs/client/fetcher.js
|
|
123
|
+
var require_fetcher = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
124
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
125
|
+
exports.fetcher = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
126
|
+
exports.createFetcher = createFetcher;
|
|
127
|
+
const types_1 = require_types();
|
|
128
|
+
const HttpException_1 = require_HttpException();
|
|
129
|
+
exports.DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
130
|
+
/**
|
|
131
|
+
* Creates a customizable fetcher function for client requests.
|
|
132
|
+
* @see https://vovk.dev/imports
|
|
133
|
+
*/
|
|
134
|
+
function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onError } = {}) {
|
|
135
|
+
const newFetcher = async ({ httpMethod, getURL, validate, defaultHandler, defaultStreamHandler, schema }, inputOptions) => {
|
|
136
|
+
let response = null;
|
|
137
|
+
let respData = null;
|
|
138
|
+
let requestInit = null;
|
|
139
|
+
try {
|
|
140
|
+
const { meta, apiRoot, disableClientValidation, init, interpretAs } = inputOptions;
|
|
141
|
+
let { body, query, params } = inputOptions;
|
|
142
|
+
const endpoint = getURL({
|
|
143
|
+
apiRoot,
|
|
144
|
+
params,
|
|
145
|
+
query
|
|
146
|
+
});
|
|
147
|
+
const unusedParams = Array.from(new URL(endpoint.startsWith("/") ? `http://localhost${endpoint}` : endpoint).pathname.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]);
|
|
148
|
+
if (unusedParams.length) throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, `Unused params: ${unusedParams.join(", ")} in ${endpoint}`, {
|
|
149
|
+
body,
|
|
150
|
+
query,
|
|
151
|
+
params,
|
|
152
|
+
endpoint
|
|
153
|
+
});
|
|
154
|
+
if (!disableClientValidation) try {
|
|
155
|
+
({body, query, params} = await validate(inputOptions, { endpoint }) ?? {
|
|
156
|
+
body,
|
|
157
|
+
query,
|
|
158
|
+
params
|
|
159
|
+
});
|
|
160
|
+
} catch (e) {
|
|
161
|
+
if (e instanceof HttpException_1.HttpException) throw e;
|
|
162
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e.message ?? exports.DEFAULT_ERROR_MESSAGE, {
|
|
163
|
+
body,
|
|
164
|
+
query,
|
|
165
|
+
params,
|
|
166
|
+
endpoint
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
requestInit = {
|
|
170
|
+
method: httpMethod,
|
|
171
|
+
...init,
|
|
172
|
+
headers: {
|
|
173
|
+
accept: "application/jsonl, application/json",
|
|
174
|
+
...body instanceof FormData ? {} : { "content-type": "application/json" },
|
|
175
|
+
...meta ? { "x-meta": JSON.stringify(meta) } : {},
|
|
176
|
+
...init?.headers
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
if (body instanceof FormData) requestInit.body = body;
|
|
180
|
+
else if (body) requestInit.body = JSON.stringify(body);
|
|
181
|
+
const abortController = new AbortController();
|
|
182
|
+
requestInit.signal = abortController.signal;
|
|
183
|
+
requestInit = prepareRequestInit ? await prepareRequestInit(requestInit, inputOptions) : requestInit;
|
|
184
|
+
try {
|
|
185
|
+
response = await fetch(endpoint, requestInit);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, (e?.message ?? exports.DEFAULT_ERROR_MESSAGE) + " " + endpoint, {
|
|
188
|
+
body,
|
|
189
|
+
query,
|
|
190
|
+
params,
|
|
191
|
+
endpoint
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const contentType = interpretAs ?? response.headers.get("content-type");
|
|
195
|
+
if (contentType?.startsWith("application/jsonl")) respData = defaultStreamHandler({
|
|
196
|
+
response,
|
|
197
|
+
abortController
|
|
198
|
+
});
|
|
199
|
+
else if (contentType?.startsWith("application/json")) respData = await defaultHandler({
|
|
200
|
+
response,
|
|
201
|
+
schema
|
|
202
|
+
});
|
|
203
|
+
else respData = response;
|
|
204
|
+
respData = transformResponse ? await transformResponse(respData, inputOptions, {
|
|
205
|
+
response,
|
|
206
|
+
init: requestInit,
|
|
207
|
+
schema
|
|
208
|
+
}) : respData;
|
|
209
|
+
await onSuccess?.(respData, inputOptions, {
|
|
210
|
+
response,
|
|
211
|
+
init: requestInit,
|
|
212
|
+
schema
|
|
213
|
+
});
|
|
214
|
+
return [respData, response];
|
|
215
|
+
} catch (error) {
|
|
216
|
+
await onError?.(error, inputOptions, {
|
|
217
|
+
response,
|
|
218
|
+
init: requestInit,
|
|
219
|
+
respData,
|
|
220
|
+
schema
|
|
221
|
+
});
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
return newFetcher;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Default fetcher implementation for client requests.
|
|
229
|
+
* @see https://vovk.dev/imports
|
|
230
|
+
*/
|
|
231
|
+
exports.fetcher = createFetcher();
|
|
232
|
+
}));
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
Object.defineProperty(exports, 'require_HttpException', {
|
|
236
|
+
enumerable: true,
|
|
237
|
+
get: function () {
|
|
238
|
+
return require_HttpException;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(exports, 'require_fetcher', {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function () {
|
|
244
|
+
return require_fetcher;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
Object.defineProperty(exports, 'require_types', {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get: function () {
|
|
250
|
+
return require_types;
|
|
251
|
+
}
|
|
252
|
+
});
|
package/fetcher.mjs
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./chunk.mjs";
|
|
2
|
+
|
|
3
|
+
//#region node_modules/vovk/mjs/types.js
|
|
4
|
+
var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VovkSchemaIdEnum = exports.HttpStatus = exports.HttpMethod = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* HTTP methods
|
|
9
|
+
*/
|
|
10
|
+
var HttpMethod;
|
|
11
|
+
(function(HttpMethod) {
|
|
12
|
+
HttpMethod["GET"] = "GET";
|
|
13
|
+
HttpMethod["POST"] = "POST";
|
|
14
|
+
HttpMethod["PUT"] = "PUT";
|
|
15
|
+
HttpMethod["PATCH"] = "PATCH";
|
|
16
|
+
HttpMethod["DELETE"] = "DELETE";
|
|
17
|
+
HttpMethod["HEAD"] = "HEAD";
|
|
18
|
+
HttpMethod["OPTIONS"] = "OPTIONS";
|
|
19
|
+
})(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
|
|
20
|
+
/**
|
|
21
|
+
* HTTP status codes
|
|
22
|
+
*/
|
|
23
|
+
var HttpStatus;
|
|
24
|
+
(function(HttpStatus) {
|
|
25
|
+
HttpStatus[HttpStatus["NULL"] = 0] = "NULL";
|
|
26
|
+
HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
|
|
27
|
+
HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
28
|
+
HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
|
|
29
|
+
HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
30
|
+
HttpStatus[HttpStatus["OK"] = 200] = "OK";
|
|
31
|
+
HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
|
|
32
|
+
HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
|
|
33
|
+
HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
34
|
+
HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
35
|
+
HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
36
|
+
HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
37
|
+
HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
38
|
+
HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
39
|
+
HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
|
|
40
|
+
HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
41
|
+
HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
42
|
+
HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
43
|
+
HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
44
|
+
HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
45
|
+
HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
46
|
+
HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
47
|
+
HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
48
|
+
HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
49
|
+
HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
50
|
+
HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
51
|
+
HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
52
|
+
HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
53
|
+
HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
|
|
54
|
+
HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
|
|
55
|
+
HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
56
|
+
HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
57
|
+
HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
58
|
+
HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
59
|
+
HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
60
|
+
HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
61
|
+
HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
62
|
+
HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
63
|
+
HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
|
|
64
|
+
HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
65
|
+
HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
66
|
+
HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
67
|
+
HttpStatus[HttpStatus["TOO_MANY_TRequestS"] = 429] = "TOO_MANY_TRequestS";
|
|
68
|
+
HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
69
|
+
HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
70
|
+
HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
71
|
+
HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
72
|
+
HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
73
|
+
HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
74
|
+
})(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
|
|
75
|
+
/**
|
|
76
|
+
* IDs of the JSON Schema files that can be generated by Vovk.ts
|
|
77
|
+
*/
|
|
78
|
+
var VovkSchemaIdEnum;
|
|
79
|
+
(function(VovkSchemaIdEnum) {
|
|
80
|
+
VovkSchemaIdEnum["META"] = "https://vovk.dev/api/schema/v3/meta.json";
|
|
81
|
+
VovkSchemaIdEnum["CONFIG"] = "https://vovk.dev/api/schema/v3/config.json";
|
|
82
|
+
VovkSchemaIdEnum["SEGMENT"] = "https://vovk.dev/api/schema/v3/segment.json";
|
|
83
|
+
VovkSchemaIdEnum["SCHEMA"] = "https://vovk.dev/api/schema/v3/schema.json";
|
|
84
|
+
})(VovkSchemaIdEnum || (exports.VovkSchemaIdEnum = VovkSchemaIdEnum = {}));
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region node_modules/vovk/mjs/core/HttpException.js
|
|
89
|
+
var require_HttpException = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
90
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
+
exports.HttpException = void 0;
|
|
92
|
+
/**
|
|
93
|
+
* Represents an HTTP exception with a status code and message.
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* throw new HttpException(HttpStatus.BAD_REQUEST, 'Invalid request data');
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
var HttpException = class extends Error {
|
|
100
|
+
statusCode;
|
|
101
|
+
message;
|
|
102
|
+
cause;
|
|
103
|
+
constructor(statusCode, message, cause) {
|
|
104
|
+
super(message);
|
|
105
|
+
this.statusCode = statusCode;
|
|
106
|
+
this.message = message;
|
|
107
|
+
this.cause = cause;
|
|
108
|
+
}
|
|
109
|
+
toJSON() {
|
|
110
|
+
return {
|
|
111
|
+
isError: true,
|
|
112
|
+
statusCode: this.statusCode,
|
|
113
|
+
message: this.message,
|
|
114
|
+
...this.cause ? { cause: this.cause } : {}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
exports.HttpException = HttpException;
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region node_modules/vovk/mjs/client/fetcher.js
|
|
123
|
+
var require_fetcher = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
124
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
125
|
+
exports.fetcher = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
126
|
+
exports.createFetcher = createFetcher;
|
|
127
|
+
const types_1 = require_types();
|
|
128
|
+
const HttpException_1 = require_HttpException();
|
|
129
|
+
exports.DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
130
|
+
/**
|
|
131
|
+
* Creates a customizable fetcher function for client requests.
|
|
132
|
+
* @see https://vovk.dev/imports
|
|
133
|
+
*/
|
|
134
|
+
function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onError } = {}) {
|
|
135
|
+
const newFetcher = async ({ httpMethod, getURL, validate, defaultHandler, defaultStreamHandler, schema }, inputOptions) => {
|
|
136
|
+
let response = null;
|
|
137
|
+
let respData = null;
|
|
138
|
+
let requestInit = null;
|
|
139
|
+
try {
|
|
140
|
+
const { meta, apiRoot, disableClientValidation, init, interpretAs } = inputOptions;
|
|
141
|
+
let { body, query, params } = inputOptions;
|
|
142
|
+
const endpoint = getURL({
|
|
143
|
+
apiRoot,
|
|
144
|
+
params,
|
|
145
|
+
query
|
|
146
|
+
});
|
|
147
|
+
const unusedParams = Array.from(new URL(endpoint.startsWith("/") ? `http://localhost${endpoint}` : endpoint).pathname.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]);
|
|
148
|
+
if (unusedParams.length) throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, `Unused params: ${unusedParams.join(", ")} in ${endpoint}`, {
|
|
149
|
+
body,
|
|
150
|
+
query,
|
|
151
|
+
params,
|
|
152
|
+
endpoint
|
|
153
|
+
});
|
|
154
|
+
if (!disableClientValidation) try {
|
|
155
|
+
({body, query, params} = await validate(inputOptions, { endpoint }) ?? {
|
|
156
|
+
body,
|
|
157
|
+
query,
|
|
158
|
+
params
|
|
159
|
+
});
|
|
160
|
+
} catch (e) {
|
|
161
|
+
if (e instanceof HttpException_1.HttpException) throw e;
|
|
162
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e.message ?? exports.DEFAULT_ERROR_MESSAGE, {
|
|
163
|
+
body,
|
|
164
|
+
query,
|
|
165
|
+
params,
|
|
166
|
+
endpoint
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
requestInit = {
|
|
170
|
+
method: httpMethod,
|
|
171
|
+
...init,
|
|
172
|
+
headers: {
|
|
173
|
+
accept: "application/jsonl, application/json",
|
|
174
|
+
...body instanceof FormData ? {} : { "content-type": "application/json" },
|
|
175
|
+
...meta ? { "x-meta": JSON.stringify(meta) } : {},
|
|
176
|
+
...init?.headers
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
if (body instanceof FormData) requestInit.body = body;
|
|
180
|
+
else if (body) requestInit.body = JSON.stringify(body);
|
|
181
|
+
const abortController = new AbortController();
|
|
182
|
+
requestInit.signal = abortController.signal;
|
|
183
|
+
requestInit = prepareRequestInit ? await prepareRequestInit(requestInit, inputOptions) : requestInit;
|
|
184
|
+
try {
|
|
185
|
+
response = await fetch(endpoint, requestInit);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, (e?.message ?? exports.DEFAULT_ERROR_MESSAGE) + " " + endpoint, {
|
|
188
|
+
body,
|
|
189
|
+
query,
|
|
190
|
+
params,
|
|
191
|
+
endpoint
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const contentType = interpretAs ?? response.headers.get("content-type");
|
|
195
|
+
if (contentType?.startsWith("application/jsonl")) respData = defaultStreamHandler({
|
|
196
|
+
response,
|
|
197
|
+
abortController
|
|
198
|
+
});
|
|
199
|
+
else if (contentType?.startsWith("application/json")) respData = await defaultHandler({
|
|
200
|
+
response,
|
|
201
|
+
schema
|
|
202
|
+
});
|
|
203
|
+
else respData = response;
|
|
204
|
+
respData = transformResponse ? await transformResponse(respData, inputOptions, {
|
|
205
|
+
response,
|
|
206
|
+
init: requestInit,
|
|
207
|
+
schema
|
|
208
|
+
}) : respData;
|
|
209
|
+
await onSuccess?.(respData, inputOptions, {
|
|
210
|
+
response,
|
|
211
|
+
init: requestInit,
|
|
212
|
+
schema
|
|
213
|
+
});
|
|
214
|
+
return [respData, response];
|
|
215
|
+
} catch (error) {
|
|
216
|
+
await onError?.(error, inputOptions, {
|
|
217
|
+
response,
|
|
218
|
+
init: requestInit,
|
|
219
|
+
respData,
|
|
220
|
+
schema
|
|
221
|
+
});
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
return newFetcher;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Default fetcher implementation for client requests.
|
|
229
|
+
* @see https://vovk.dev/imports
|
|
230
|
+
*/
|
|
231
|
+
exports.fetcher = createFetcher();
|
|
232
|
+
}));
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
export { require_HttpException as n, require_types as r, require_fetcher as t };
|
package/fetcher2.cjs
ADDED