@readme/api-core 7.0.0-beta.1 → 7.0.0-beta.11
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/dist/{chunk-ASE5F2OQ.js → chunk-FAGCCMC3.js} +208 -47
- package/dist/chunk-FAGCCMC3.js.map +1 -0
- package/dist/{chunk-HGLVXDVZ.cjs → chunk-MUWYYSMG.cjs} +222 -61
- package/dist/chunk-MUWYYSMG.cjs.map +1 -0
- package/dist/chunk-NVFSP2R3.cjs.map +1 -1
- package/dist/errors/fetchError.cjs +2 -1
- package/dist/errors/fetchError.cjs.map +1 -1
- package/dist/index.cjs +17 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -21
- package/dist/index.d.ts +22 -21
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/index.cjs +2 -2
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.d.cts +11 -14
- package/dist/lib/index.d.ts +11 -14
- package/dist/lib/index.js +1 -1
- package/dist/types.cjs +6 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +22 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +16 -12
- package/src/index.ts +18 -30
- package/src/lib/getJSONSchemaDefaults.ts +2 -2
- package/src/lib/index.ts +1 -3
- package/src/lib/parseResponse.ts +2 -1
- package/src/lib/prepareAuth.ts +8 -15
- package/src/lib/prepareParams.ts +14 -13
- package/src/lib/prepareServer.ts +3 -3
- package/src/types.ts +25 -0
- package/tsup.config.ts +7 -4
- package/dist/chunk-ASE5F2OQ.js.map +0 -1
- package/dist/chunk-HGLVXDVZ.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/lib/getJSONSchemaDefaults.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/lib/getJSONSchemaDefaults.ts
|
|
2
2
|
var _jsonschematraverse = require('json-schema-traverse'); var _jsonschematraverse2 = _interopRequireDefault(_jsonschematraverse);
|
|
3
3
|
function getJSONSchemaDefaults(jsonSchemas) {
|
|
4
4
|
return jsonSchemas.map(({ type: payloadType, schema: jsonSchema }) => {
|
|
@@ -45,7 +45,7 @@ var _utils = require('oas/utils');
|
|
|
45
45
|
async function parseResponse(response) {
|
|
46
46
|
const contentType = response.headers.get("Content-Type");
|
|
47
47
|
const isJSON = contentType && (_utils.matchesMimeType.json(contentType) || _utils.matchesMimeType.wildcard(contentType));
|
|
48
|
-
const responseBody = await response.text();
|
|
48
|
+
const responseBody = await response.clone().text();
|
|
49
49
|
let data = responseBody;
|
|
50
50
|
if (isJSON) {
|
|
51
51
|
try {
|
|
@@ -93,8 +93,8 @@ function prepareAuth(authKey, operation) {
|
|
|
93
93
|
}
|
|
94
94
|
const scheme2 = schemes2.shift();
|
|
95
95
|
preparedAuth[scheme2._key] = {
|
|
96
|
-
user: authKey[0],
|
|
97
|
-
pass: authKey.length === 2 ? authKey[1] : ""
|
|
96
|
+
user: String(authKey[0]),
|
|
97
|
+
pass: authKey.length === 2 ? String(authKey[1]) : ""
|
|
98
98
|
};
|
|
99
99
|
return preparedAuth;
|
|
100
100
|
}
|
|
@@ -105,8 +105,8 @@ function prepareAuth(authKey, operation) {
|
|
|
105
105
|
case "http":
|
|
106
106
|
if (scheme.scheme === "basic") {
|
|
107
107
|
preparedAuth[scheme._key] = {
|
|
108
|
-
user: authKey[0],
|
|
109
|
-
pass: authKey.length === 2 ? authKey[1] : ""
|
|
108
|
+
user: String(authKey[0]),
|
|
109
|
+
pass: authKey.length === 2 ? String(authKey[1]) : ""
|
|
110
110
|
};
|
|
111
111
|
} else if (scheme.scheme === "bearer") {
|
|
112
112
|
preparedAuth[scheme._key] = authKey[0];
|
|
@@ -129,37 +129,202 @@ function prepareAuth(authKey, operation) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// src/lib/prepareParams.ts
|
|
132
|
-
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
133
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
134
132
|
var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
|
|
135
133
|
var _caseless = require('caseless'); var _caseless2 = _interopRequireDefault(_caseless);
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
|
|
135
|
+
// node_modules/get-stream/source/index.js
|
|
136
|
+
var _events = require('events');
|
|
137
|
+
var _promises = require('stream/promises');
|
|
138
|
+
|
|
139
|
+
// node_modules/is-stream/index.js
|
|
140
|
+
function isStream(stream2, { checkOpen = true } = {}) {
|
|
141
|
+
return stream2 !== null && typeof stream2 === "object" && (stream2.writable || stream2.readable || !checkOpen || stream2.writable === void 0 && stream2.readable === void 0) && typeof stream2.pipe === "function";
|
|
142
|
+
}
|
|
143
|
+
function isReadableStream(stream2, { checkOpen = true } = {}) {
|
|
144
|
+
return isStream(stream2, { checkOpen }) && (stream2.readable || !checkOpen) && typeof stream2.read === "function" && typeof stream2.readable === "boolean" && typeof stream2.readableObjectMode === "boolean" && typeof stream2.destroy === "function" && typeof stream2.destroyed === "boolean";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ../../node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.js
|
|
148
|
+
var a = Object.getPrototypeOf(
|
|
149
|
+
Object.getPrototypeOf(
|
|
150
|
+
/* istanbul ignore next */
|
|
151
|
+
async function* () {
|
|
152
|
+
}
|
|
153
|
+
).prototype
|
|
154
|
+
);
|
|
155
|
+
var c = class {
|
|
156
|
+
#t;
|
|
157
|
+
#n;
|
|
158
|
+
#r = false;
|
|
159
|
+
#e = void 0;
|
|
160
|
+
constructor(e, t) {
|
|
161
|
+
this.#t = e, this.#n = t;
|
|
162
|
+
}
|
|
163
|
+
next() {
|
|
164
|
+
const e = () => this.#s();
|
|
165
|
+
return this.#e = this.#e ? this.#e.then(e, e) : e(), this.#e;
|
|
166
|
+
}
|
|
167
|
+
return(e) {
|
|
168
|
+
const t = () => this.#i(e);
|
|
169
|
+
return this.#e ? this.#e.then(t, t) : t();
|
|
170
|
+
}
|
|
171
|
+
async #s() {
|
|
172
|
+
if (this.#r)
|
|
173
|
+
return {
|
|
174
|
+
done: true,
|
|
175
|
+
value: void 0
|
|
176
|
+
};
|
|
177
|
+
let e;
|
|
178
|
+
try {
|
|
179
|
+
e = await this.#t.read();
|
|
180
|
+
} catch (t) {
|
|
181
|
+
throw this.#e = void 0, this.#r = true, this.#t.releaseLock(), t;
|
|
182
|
+
}
|
|
183
|
+
return e.done && (this.#e = void 0, this.#r = true, this.#t.releaseLock()), e;
|
|
184
|
+
}
|
|
185
|
+
async #i(e) {
|
|
186
|
+
if (this.#r)
|
|
187
|
+
return {
|
|
188
|
+
done: true,
|
|
189
|
+
value: e
|
|
190
|
+
};
|
|
191
|
+
if (this.#r = true, !this.#n) {
|
|
192
|
+
const t = this.#t.cancel(e);
|
|
193
|
+
return this.#t.releaseLock(), await t, {
|
|
194
|
+
done: true,
|
|
195
|
+
value: e
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return this.#t.releaseLock(), {
|
|
199
|
+
done: true,
|
|
200
|
+
value: e
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var n = Symbol();
|
|
205
|
+
function i() {
|
|
206
|
+
return this[n].next();
|
|
207
|
+
}
|
|
208
|
+
Object.defineProperty(i, "name", { value: "next" });
|
|
209
|
+
function o(r) {
|
|
210
|
+
return this[n].return(r);
|
|
211
|
+
}
|
|
212
|
+
Object.defineProperty(o, "name", { value: "return" });
|
|
213
|
+
var u = Object.create(a, {
|
|
214
|
+
next: {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
configurable: true,
|
|
217
|
+
writable: true,
|
|
218
|
+
value: i
|
|
219
|
+
},
|
|
220
|
+
return: {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
configurable: true,
|
|
223
|
+
writable: true,
|
|
224
|
+
value: o
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
function h({ preventCancel: r = false } = {}) {
|
|
228
|
+
const e = this.getReader(), t = new c(
|
|
229
|
+
e,
|
|
230
|
+
r
|
|
231
|
+
), s = Object.create(u);
|
|
232
|
+
return s[n] = t, s;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// node_modules/get-stream/source/stream.js
|
|
236
|
+
var getAsyncIterable = (stream2) => {
|
|
237
|
+
if (isReadableStream(stream2, { checkOpen: false }) && nodeImports.on !== void 0) {
|
|
238
|
+
return getStreamIterable(stream2);
|
|
239
|
+
}
|
|
240
|
+
if (typeof _optionalChain([stream2, 'optionalAccess', _6 => _6[Symbol.asyncIterator]]) === "function") {
|
|
241
|
+
return stream2;
|
|
242
|
+
}
|
|
243
|
+
if (toString.call(stream2) === "[object ReadableStream]") {
|
|
244
|
+
return h.call(stream2);
|
|
245
|
+
}
|
|
246
|
+
throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.");
|
|
247
|
+
};
|
|
248
|
+
var { toString } = Object.prototype;
|
|
249
|
+
var getStreamIterable = async function* (stream2) {
|
|
250
|
+
const controller = new AbortController();
|
|
251
|
+
const state = {};
|
|
252
|
+
handleStreamEnd(stream2, controller, state);
|
|
253
|
+
try {
|
|
254
|
+
for await (const [chunk] of nodeImports.on(stream2, "data", { signal: controller.signal })) {
|
|
255
|
+
yield chunk;
|
|
256
|
+
}
|
|
257
|
+
} catch (error) {
|
|
258
|
+
if (state.error !== void 0) {
|
|
259
|
+
throw state.error;
|
|
260
|
+
} else if (!controller.signal.aborted) {
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
} finally {
|
|
264
|
+
stream2.destroy();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var handleStreamEnd = async (stream2, controller, state) => {
|
|
268
|
+
try {
|
|
269
|
+
await nodeImports.finished(stream2, {
|
|
270
|
+
cleanup: true,
|
|
271
|
+
readable: true,
|
|
272
|
+
writable: false,
|
|
273
|
+
error: false
|
|
274
|
+
});
|
|
275
|
+
} catch (error) {
|
|
276
|
+
state.error = error;
|
|
277
|
+
} finally {
|
|
278
|
+
controller.abort();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var nodeImports = {};
|
|
138
282
|
|
|
139
283
|
// node_modules/get-stream/source/contents.js
|
|
140
284
|
var getStreamContents = async (stream2, { init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize }, { maxBuffer = Number.POSITIVE_INFINITY } = {}) => {
|
|
141
|
-
|
|
142
|
-
throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");
|
|
143
|
-
}
|
|
285
|
+
const asyncIterable = getAsyncIterable(stream2);
|
|
144
286
|
const state = init();
|
|
145
287
|
state.length = 0;
|
|
146
288
|
try {
|
|
147
|
-
for await (const chunk of
|
|
289
|
+
for await (const chunk of asyncIterable) {
|
|
148
290
|
const chunkType = getChunkType(chunk);
|
|
149
291
|
const convertedChunk = convertChunk[chunkType](chunk, state);
|
|
150
|
-
appendChunk({
|
|
292
|
+
appendChunk({
|
|
293
|
+
convertedChunk,
|
|
294
|
+
state,
|
|
295
|
+
getSize,
|
|
296
|
+
truncateChunk,
|
|
297
|
+
addChunk,
|
|
298
|
+
maxBuffer
|
|
299
|
+
});
|
|
151
300
|
}
|
|
152
|
-
appendFinalChunk({
|
|
301
|
+
appendFinalChunk({
|
|
302
|
+
state,
|
|
303
|
+
convertChunk,
|
|
304
|
+
getSize,
|
|
305
|
+
truncateChunk,
|
|
306
|
+
addChunk,
|
|
307
|
+
getFinalChunk,
|
|
308
|
+
maxBuffer
|
|
309
|
+
});
|
|
153
310
|
return finalize(state);
|
|
154
311
|
} catch (error) {
|
|
155
|
-
|
|
156
|
-
|
|
312
|
+
const normalizedError = typeof error === "object" && error !== null ? error : new Error(error);
|
|
313
|
+
normalizedError.bufferedData = finalize(state);
|
|
314
|
+
throw normalizedError;
|
|
157
315
|
}
|
|
158
316
|
};
|
|
159
317
|
var appendFinalChunk = ({ state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer }) => {
|
|
160
318
|
const convertedChunk = getFinalChunk(state);
|
|
161
319
|
if (convertedChunk !== void 0) {
|
|
162
|
-
appendChunk({
|
|
320
|
+
appendChunk({
|
|
321
|
+
convertedChunk,
|
|
322
|
+
state,
|
|
323
|
+
getSize,
|
|
324
|
+
truncateChunk,
|
|
325
|
+
addChunk,
|
|
326
|
+
maxBuffer
|
|
327
|
+
});
|
|
163
328
|
}
|
|
164
329
|
};
|
|
165
330
|
var appendChunk = ({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer }) => {
|
|
@@ -179,7 +344,6 @@ var addNewChunk = (convertedChunk, state, addChunk, newLength) => {
|
|
|
179
344
|
state.contents = addChunk(convertedChunk, state, newLength);
|
|
180
345
|
state.length = newLength;
|
|
181
346
|
};
|
|
182
|
-
var isAsyncIterable = (stream2) => typeof stream2 === "object" && stream2 !== null && typeof stream2[Symbol.asyncIterator] === "function";
|
|
183
347
|
var getChunkType = (chunk) => {
|
|
184
348
|
const typeOfChunk = typeof chunk;
|
|
185
349
|
if (typeOfChunk === "string") {
|
|
@@ -188,7 +352,7 @@ var getChunkType = (chunk) => {
|
|
|
188
352
|
if (typeOfChunk !== "object" || chunk === null) {
|
|
189
353
|
return "others";
|
|
190
354
|
}
|
|
191
|
-
if (_optionalChain([globalThis, 'access',
|
|
355
|
+
if (_optionalChain([globalThis, 'access', _7 => _7.Buffer, 'optionalAccess', _8 => _8.isBuffer, 'call', _9 => _9(chunk)])) {
|
|
192
356
|
return "buffer";
|
|
193
357
|
}
|
|
194
358
|
const prototypeName = objectToString.call(chunk);
|
|
@@ -216,7 +380,7 @@ var noop = () => void 0;
|
|
|
216
380
|
var throwObjectStream = (chunk) => {
|
|
217
381
|
throw new Error(`Streams in object mode are not supported: ${String(chunk)}`);
|
|
218
382
|
};
|
|
219
|
-
var
|
|
383
|
+
var getLengthProperty = (convertedChunk) => convertedChunk.length;
|
|
220
384
|
|
|
221
385
|
// node_modules/get-stream/source/array-buffer.js
|
|
222
386
|
async function getStreamAsArrayBuffer(stream2, options) {
|
|
@@ -264,7 +428,7 @@ var arrayBufferMethods = {
|
|
|
264
428
|
typedArray: useUint8ArrayWithOffset,
|
|
265
429
|
others: throwObjectStream
|
|
266
430
|
},
|
|
267
|
-
getSize:
|
|
431
|
+
getSize: getLengthProperty,
|
|
268
432
|
truncateChunk: truncateArrayBufferChunk,
|
|
269
433
|
addChunk: addArrayBufferChunk,
|
|
270
434
|
getFinalChunk: noop,
|
|
@@ -287,6 +451,9 @@ async function getStreamAsBuffer(stream2, options) {
|
|
|
287
451
|
}
|
|
288
452
|
var arrayBufferToNodeBuffer = (arrayBuffer) => globalThis.Buffer.from(arrayBuffer);
|
|
289
453
|
|
|
454
|
+
// node_modules/get-stream/source/index.js
|
|
455
|
+
Object.assign(nodeImports, { on: _events.on, finished: _promises.finished });
|
|
456
|
+
|
|
290
457
|
// src/lib/prepareParams.ts
|
|
291
458
|
var _lodashmerge = require('lodash.merge'); var _lodashmerge2 = _interopRequireDefault(_lodashmerge);
|
|
292
459
|
var _removeundefinedobjects = require('remove-undefined-objects'); var _removeundefinedobjects2 = _interopRequireDefault(_removeundefinedobjects);
|
|
@@ -323,22 +490,26 @@ function merge(src, target) {
|
|
|
323
490
|
}
|
|
324
491
|
return _lodashmerge2.default.call(void 0, src, target);
|
|
325
492
|
}
|
|
326
|
-
function processFile(paramName, file) {
|
|
493
|
+
async function processFile(paramName, file) {
|
|
494
|
+
const fs = await Promise.resolve().then(() => _interopRequireWildcard(require("fs")));
|
|
495
|
+
const path = await Promise.resolve().then(() => _interopRequireWildcard(require("path")));
|
|
496
|
+
const { default: DatauriParser } = await Promise.resolve().then(() => _interopRequireWildcard(require("datauri/parser.js")));
|
|
497
|
+
const { default: datauri } = await Promise.resolve().then(() => _interopRequireWildcard(require("datauri/sync.js")));
|
|
327
498
|
if (typeof file === "string") {
|
|
328
|
-
const resolvedFile =
|
|
499
|
+
const resolvedFile = path.resolve(file);
|
|
329
500
|
return new Promise((resolve, reject) => {
|
|
330
|
-
|
|
501
|
+
fs.stat(resolvedFile, async (err) => {
|
|
331
502
|
if (err) {
|
|
332
503
|
if (err.code === "ENOENT") {
|
|
333
504
|
return resolve(void 0);
|
|
334
505
|
}
|
|
335
506
|
return reject(err);
|
|
336
507
|
}
|
|
337
|
-
const fileMetadata = await
|
|
338
|
-
const payloadFilename = encodeURIComponent(
|
|
508
|
+
const fileMetadata = await datauri(resolvedFile);
|
|
509
|
+
const payloadFilename = encodeURIComponent(path.basename(resolvedFile));
|
|
339
510
|
return resolve({
|
|
340
511
|
paramName,
|
|
341
|
-
base64: _optionalChain([fileMetadata, 'optionalAccess',
|
|
512
|
+
base64: _optionalChain([fileMetadata, 'optionalAccess', _10 => _10.content, 'optionalAccess', _11 => _11.replace, 'call', _12 => _12(";base64", `;name=${payloadFilename};base64`)]),
|
|
342
513
|
filename: payloadFilename,
|
|
343
514
|
buffer: fileMetadata.buffer
|
|
344
515
|
});
|
|
@@ -347,12 +518,12 @@ function processFile(paramName, file) {
|
|
|
347
518
|
} else if (file instanceof _stream2.default.Readable) {
|
|
348
519
|
return getStreamAsBuffer(file).then((buffer) => {
|
|
349
520
|
const filePath = file.path;
|
|
350
|
-
const parser = new (
|
|
521
|
+
const parser = new DatauriParser();
|
|
351
522
|
const base64 = parser.format(filePath, buffer).content;
|
|
352
|
-
const payloadFilename = encodeURIComponent(
|
|
523
|
+
const payloadFilename = encodeURIComponent(path.basename(filePath));
|
|
353
524
|
return {
|
|
354
525
|
paramName,
|
|
355
|
-
base64: _optionalChain([base64, 'optionalAccess',
|
|
526
|
+
base64: _optionalChain([base64, 'optionalAccess', _13 => _13.replace, 'call', _14 => _14(";base64", `;name=${payloadFilename};base64`)]),
|
|
356
527
|
filename: payloadFilename,
|
|
357
528
|
buffer
|
|
358
529
|
};
|
|
@@ -426,19 +597,17 @@ async function prepareParams(operation, body, metadata) {
|
|
|
426
597
|
if (!operation.hasRequestBody()) {
|
|
427
598
|
delete params.body;
|
|
428
599
|
} else {
|
|
429
|
-
if (!("body" in params))
|
|
430
|
-
params.body = {};
|
|
600
|
+
if (!("body" in params)) params.body = {};
|
|
431
601
|
const payloadJsonSchema = jsonSchema.find((js) => js.type === "body");
|
|
432
602
|
if (payloadJsonSchema) {
|
|
433
|
-
if (!params.files)
|
|
434
|
-
params.files = {};
|
|
603
|
+
if (!params.files) params.files = {};
|
|
435
604
|
const conversions = [];
|
|
436
|
-
if (_optionalChain([payloadJsonSchema, 'access',
|
|
437
|
-
Object.entries(_optionalChain([payloadJsonSchema, 'access',
|
|
605
|
+
if (_optionalChain([payloadJsonSchema, 'access', _15 => _15.schema, 'optionalAccess', _16 => _16.properties])) {
|
|
606
|
+
Object.entries(_optionalChain([payloadJsonSchema, 'access', _17 => _17.schema, 'optionalAccess', _18 => _18.properties])).filter(([, schema]) => _optionalChain([schema, 'optionalAccess', _19 => _19.format]) === "binary").filter(([prop]) => Object.keys(params.body).includes(prop)).forEach(([prop]) => {
|
|
438
607
|
conversions.push(processFile(prop, params.body[prop]));
|
|
439
608
|
});
|
|
440
|
-
} else if (_optionalChain([payloadJsonSchema, 'access',
|
|
441
|
-
if (_optionalChain([payloadJsonSchema, 'access',
|
|
609
|
+
} else if (_optionalChain([payloadJsonSchema, 'access', _20 => _20.schema, 'optionalAccess', _21 => _21.type]) === "string") {
|
|
610
|
+
if (_optionalChain([payloadJsonSchema, 'access', _22 => _22.schema, 'optionalAccess', _23 => _23.format]) === "binary") {
|
|
442
611
|
conversions.push(processFile(void 0, params.body));
|
|
443
612
|
}
|
|
444
613
|
}
|
|
@@ -452,7 +621,7 @@ async function prepareParams(operation, body, metadata) {
|
|
|
452
621
|
} else {
|
|
453
622
|
params.body = fileMetadata.base64;
|
|
454
623
|
}
|
|
455
|
-
if (fileMetadata.buffer && _optionalChain([params, 'optionalAccess',
|
|
624
|
+
if (fileMetadata.buffer && _optionalChain([params, 'optionalAccess', _24 => _24.files])) {
|
|
456
625
|
params.files[fileMetadata.filename] = fileMetadata.buffer;
|
|
457
626
|
}
|
|
458
627
|
});
|
|
@@ -464,14 +633,10 @@ async function prepareParams(operation, body, metadata) {
|
|
|
464
633
|
delete params.body;
|
|
465
634
|
}
|
|
466
635
|
if (typeof metadata !== "undefined") {
|
|
467
|
-
if (!("cookie" in params))
|
|
468
|
-
|
|
469
|
-
if (!("
|
|
470
|
-
|
|
471
|
-
if (!("path" in params))
|
|
472
|
-
params.path = {};
|
|
473
|
-
if (!("query" in params))
|
|
474
|
-
params.query = {};
|
|
636
|
+
if (!("cookie" in params)) params.cookie = {};
|
|
637
|
+
if (!("header" in params)) params.header = {};
|
|
638
|
+
if (!("path" in params)) params.path = {};
|
|
639
|
+
if (!("query" in params)) params.query = {};
|
|
475
640
|
Object.entries(digestedParameters).forEach(([paramName, param]) => {
|
|
476
641
|
let value;
|
|
477
642
|
let metadataHeaderParam;
|
|
@@ -490,23 +655,19 @@ async function prepareParams(operation, body, metadata) {
|
|
|
490
655
|
switch (param.in) {
|
|
491
656
|
case "path":
|
|
492
657
|
params.path[paramName] = value;
|
|
493
|
-
if (_optionalChain([metadata, 'optionalAccess',
|
|
494
|
-
delete metadata[paramName];
|
|
658
|
+
if (_optionalChain([metadata, 'optionalAccess', _25 => _25[paramName]])) delete metadata[paramName];
|
|
495
659
|
break;
|
|
496
660
|
case "query":
|
|
497
661
|
params.query[paramName] = value;
|
|
498
|
-
if (_optionalChain([metadata, 'optionalAccess',
|
|
499
|
-
delete metadata[paramName];
|
|
662
|
+
if (_optionalChain([metadata, 'optionalAccess', _26 => _26[paramName]])) delete metadata[paramName];
|
|
500
663
|
break;
|
|
501
664
|
case "header":
|
|
502
665
|
params.header[paramName.toLowerCase()] = value;
|
|
503
|
-
if (metadataHeaderParam && _optionalChain([metadata, 'optionalAccess',
|
|
504
|
-
delete metadata[metadataHeaderParam];
|
|
666
|
+
if (metadataHeaderParam && _optionalChain([metadata, 'optionalAccess', _27 => _27[metadataHeaderParam]])) delete metadata[metadataHeaderParam];
|
|
505
667
|
break;
|
|
506
668
|
case "cookie":
|
|
507
669
|
params.cookie[paramName] = value;
|
|
508
|
-
if (_optionalChain([metadata, 'optionalAccess',
|
|
509
|
-
delete metadata[paramName];
|
|
670
|
+
if (_optionalChain([metadata, 'optionalAccess', _28 => _28[paramName]])) delete metadata[paramName];
|
|
510
671
|
break;
|
|
511
672
|
default:
|
|
512
673
|
}
|
|
@@ -554,12 +715,12 @@ function stripTrailingSlash(url) {
|
|
|
554
715
|
function prepareServer(spec, url, variables = {}) {
|
|
555
716
|
let serverIdx;
|
|
556
717
|
const sanitizedUrl = stripTrailingSlash(url);
|
|
557
|
-
(spec.api.servers || []).forEach((server,
|
|
718
|
+
(spec.api.servers || []).forEach((server, i2) => {
|
|
558
719
|
if (server.url === sanitizedUrl) {
|
|
559
|
-
serverIdx =
|
|
720
|
+
serverIdx = i2;
|
|
560
721
|
}
|
|
561
722
|
});
|
|
562
|
-
if (serverIdx) {
|
|
723
|
+
if (serverIdx !== void 0) {
|
|
563
724
|
return {
|
|
564
725
|
selected: serverIdx,
|
|
565
726
|
variables
|
|
@@ -584,4 +745,4 @@ function prepareServer(spec, url, variables = {}) {
|
|
|
584
745
|
|
|
585
746
|
|
|
586
747
|
exports.getJSONSchemaDefaults = getJSONSchemaDefaults; exports.parseResponse = parseResponse; exports.prepareAuth = prepareAuth; exports.prepareParams = prepareParams; exports.prepareServer = prepareServer;
|
|
587
|
-
//# sourceMappingURL=chunk-
|
|
748
|
+
//# sourceMappingURL=chunk-MUWYYSMG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kanadg/Code/readmeio/api/packages/core/dist/chunk-MUWYYSMG.cjs","../src/lib/getJSONSchemaDefaults.ts","../src/lib/parseResponse.ts","../src/lib/prepareAuth.ts","../src/lib/prepareParams.ts","../node_modules/get-stream/source/index.js","../node_modules/is-stream/index.js","../../../node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.js","../node_modules/get-stream/source/stream.js","../node_modules/get-stream/source/contents.js","../node_modules/get-stream/source/utils.js","../node_modules/get-stream/source/array-buffer.js","../node_modules/get-stream/source/buffer.js","../src/lib/prepareServer.ts"],"names":["schemes","scheme","stream","i"],"mappings":"AAAA;ACGA,kIAAqB;AAYN,SAAR,qBAAA,CAAuC,WAAA,EAA8B;AAC1E,EAAA,OAAO,WAAA,CACJ,GAAA,CAAI,CAAC,EAAE,IAAA,EAAM,WAAA,EAAa,MAAA,EAAQ,WAAW,CAAA,EAAA,GAAM;AAClD,IAAA,MAAM,SAAA,EAAoC,CAAC,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D,cAAA;AAE2B,cAAA;AAC7B,YAAA;AACF,UAAA;AACD,QAAA;AACH,MAAA;AAEkC,MAAA;AACiB,QAAA;AAC5C,MAAA;AAGP,MAAA;AACF,IAAA;AACF,EAAA;AAEsF,EAAA;AACvC,IAAA;AACzB,MAAA;AACpB,IAAA;AACD,EAAA;AAEM,EAAA;AACT;AJqR6E;AACA;AajsBpC;AACN,EAAA;AACT,IAAA;AACxB,EAAA;AAEO,EAAA;AACT;AAO+G;AACzG,EAAA;AACuC,EAAA;AACK,EAAA;AACb,IAAA;AACnBC,MAAAA;AACd,IAAA;AACD,EAAA;AAK4B,EAAA;AACpB,IAAA;AACK,MAAA;AACV,MAAA;AACF,IAAA;AACwC,EAAA;AAEnC,EAAA;AACiC,IAAA;AAC1B,IAAA;AACH,MAAA;AACY,QAAA;AACC,QAAA;AACpB,MAAA;AACF,IAAA;AAGF,EAAA;AAEO,EAAA;AACT;AborB6E;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/kanadg/Code/readmeio/api/packages/core/dist/chunk-MUWYYSMG.cjs","sourcesContent":[null,"import type { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';\nimport type { SchemaObject } from 'oas/types';\n\nimport traverse from 'json-schema-traverse';\n\n/**\n * Run through a JSON Schema object and compose up an object containing default data for any schema\n * property that is required and also has a defined default.\n *\n * Code partially adapted from the `json-schema-default` package but modified to only return\n * defaults of required properties.\n *\n * @todo This is a good candidate to be moved into a core `oas` library method.\n * @see {@link https://github.com/mdornseif/json-schema-default}\n */\nexport default function getJSONSchemaDefaults(jsonSchemas: SchemaWrapper[]) {\n return jsonSchemas\n .map(({ type: payloadType, schema: jsonSchema }) => {\n const defaults: Record<string, unknown> = {};\n traverse(\n jsonSchema,\n (\n schema: SchemaObject,\n pointer: string,\n rootSchema: SchemaObject,\n parentPointer?: string,\n parentKeyword?: string,\n parentSchema?: SchemaObject,\n indexProperty?: number | string,\n ) => {\n if (!pointer.startsWith('/properties/')) {\n return;\n }\n\n if (Array.isArray(parentSchema?.required) && parentSchema?.required.includes(String(indexProperty))) {\n if (schema.type === 'object' && indexProperty) {\n defaults[indexProperty] = {};\n }\n\n let destination = defaults;\n if (parentPointer) {\n // To map nested objects correct we need to pick apart the parent pointer.\n parentPointer\n .replace(/\\/properties/g, '')\n .split('/')\n .forEach((subSchema: string) => {\n if (subSchema === '') {\n return;\n }\n\n destination = (destination?.[subSchema] as Record<string, unknown>) || {};\n });\n }\n\n if (schema.default !== undefined) {\n if (indexProperty !== undefined) {\n destination[indexProperty] = schema.default;\n }\n }\n }\n },\n );\n\n if (!Object.keys(defaults).length) {\n return {};\n }\n\n return {\n // @todo should we filter out empty and undefined objects from here with `remove-undefined-objects`?\n [payloadType]: defaults,\n };\n })\n .reduce((prev, next) => Object.assign(prev, next));\n}\n","import { matchesMimeType } from 'oas/utils';\n\nexport default async function parseResponse<HTTPStatus extends number = number>(response: Response) {\n const contentType = response.headers.get('Content-Type');\n const isJSON = contentType && (matchesMimeType.json(contentType) || matchesMimeType.wildcard(contentType));\n\n const responseBody = await response.clone().text();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let data: any = responseBody;\n if (isJSON) {\n try {\n data = JSON.parse(responseBody);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n // If our JSON parsing failed then we can just return plaintext instead.\n }\n }\n\n return {\n data,\n status: response.status as HTTPStatus,\n headers: response.headers,\n res: response,\n };\n}\n","/* eslint-disable no-underscore-dangle */\nimport type { AuthForHAR } from '@readme/oas-to-har/lib/types';\nimport type { Operation } from 'oas/operation';\nimport type { KeyedSecuritySchemeObject } from 'oas/types';\n\nexport default function prepareAuth(authKey: (number | string)[], operation: Operation) {\n if (authKey.length === 0) {\n return {};\n }\n\n const preparedAuth: AuthForHAR = {};\n\n const security = operation.getSecurity();\n if (security.length === 0) {\n // If there's no auth configured on this operation, don't prepare anything (even if it was\n // supplied by the user).\n return {};\n }\n\n // Does this operation require multiple forms of auth?\n if (security.every(s => Object.keys(s).length > 1)) {\n throw new Error(\n \"Sorry, this operation currently requires multiple forms of authentication which this library doesn't yet support.\",\n );\n }\n\n // Since we can only handle single auth security configurations, let's pull those out. This code\n // is a bit opaque but `security` here may look like `[{ basic: [] }, { oauth2: [], basic: []}]`\n // and are filtering it down to only single-auth requirements of `[{ basic: [] }]`.\n const usableSecurity = security\n .map(s => {\n return Object.keys(s).length === 1 ? s : false;\n })\n .filter(Boolean);\n\n const usableSecuritySchemes = usableSecurity.map(s => Object.keys(s)).reduce((prev, next) => prev.concat(next), []);\n const preparedSecurity = operation.prepareSecurity();\n\n // If we have two auth tokens present let's look for Basic Auth in their configuration.\n if (authKey.length >= 2) {\n // If this operation doesn't support HTTP Basic auth but we have two tokens, that's a paddlin.\n if (!('Basic' in preparedSecurity)) {\n throw new Error('Multiple auth tokens were supplied for this endpoint but only a single token is needed.');\n }\n\n // If we have two auth keys for Basic Auth but Basic isn't a usable security scheme (maybe it's\n // part of an AND or auth configuration -- which we don't support) then we need to error out.\n const schemes = preparedSecurity.Basic.filter(s => usableSecuritySchemes.includes(s._key));\n if (!schemes.length) {\n throw new Error(\n 'Credentials for Basic Authentication were supplied but this operation requires another form of auth in that case, which this library does not yet support. This operation does, however, allow supplying a single auth token.',\n );\n }\n\n const scheme = schemes.shift() as KeyedSecuritySchemeObject;\n preparedAuth[scheme._key] = {\n user: String(authKey[0]),\n pass: authKey.length === 2 ? String(authKey[1]) : '',\n };\n\n return preparedAuth;\n }\n\n // If we know we don't need to use HTTP Basic auth because we have a username+password then we\n // can pick the first usable security scheme available and try to use that. This might not always\n // be the auth scheme that the user wants, but we don't have any other way for the user to tell\n // us what they want with the current `sdk.auth()` API.\n const usableScheme = usableSecuritySchemes[0];\n const schemes = Object.entries(preparedSecurity)\n .map(([, ps]) => ps.filter(s => usableScheme === s._key))\n .reduce((prev, next) => prev.concat(next), []);\n\n const scheme = schemes.shift() as KeyedSecuritySchemeObject;\n switch (scheme.type) {\n case 'http':\n if (scheme.scheme === 'basic') {\n preparedAuth[scheme._key] = {\n user: String(authKey[0]),\n pass: authKey.length === 2 ? String(authKey[1]) : '',\n };\n } else if (scheme.scheme === 'bearer') {\n preparedAuth[scheme._key] = authKey[0];\n }\n break;\n\n case 'oauth2':\n preparedAuth[scheme._key] = authKey[0];\n break;\n\n case 'apiKey':\n if (scheme.in === 'query' || scheme.in === 'header' || scheme.in === 'cookie') {\n preparedAuth[scheme._key] = authKey[0];\n }\n break;\n\n default:\n throw new Error(\n `Sorry, this API currently uses a security scheme, ${scheme.type}, which this library doesn't yet support.`,\n );\n }\n\n return preparedAuth;\n}\n","import type { ReadStream } from 'node:fs';\nimport type { Operation } from 'oas/operation';\nimport type { ParameterObject, SchemaObject } from 'oas/types';\n\nimport stream from 'node:stream';\n\nimport caseless from 'caseless';\n// `get-stream` is included in our bundle, see `tsup.config.ts`\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { getStreamAsBuffer } from 'get-stream';\nimport lodashMerge from 'lodash.merge';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport getJSONSchemaDefaults from './getJSONSchemaDefaults.js';\n\n// These headers are normally only defined by the OpenAPI definition but we allow the user to\n// manually supply them in their `metadata` parameter if they wish.\nconst specialHeaders = ['accept', 'authorization'];\n\n/**\n * Extract all available parameters from an operations Parameter Object into a digestable array\n * that we can use to apply to the request.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject}\n */\nfunction digestParameters(parameters: ParameterObject[]): Record<string, ParameterObject> {\n return parameters.reduce((prev, param) => {\n if ('$ref' in param || 'allOf' in param || 'anyOf' in param || 'oneOf' in param) {\n throw new Error(\"The OpenAPI document for this operation wasn't dereferenced before processing.\");\n } else if (param.name in prev) {\n throw new Error(\n `The operation you are using has the same parameter, ${param.name}, spread across multiple entry points. We unfortunately can't handle this right now.`,\n );\n }\n\n return Object.assign(prev, { [param.name]: param });\n }, {});\n}\n\n// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_isempty\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isEmpty(obj: any) {\n return [Object, Array].includes((obj || {}).constructor) && !Object.entries(obj || {}).length;\n}\n\nfunction isObject(thing: unknown) {\n if (thing instanceof stream.Readable) {\n return false;\n }\n\n return typeof thing === 'object' && thing !== null && !Array.isArray(thing);\n}\n\nfunction isPrimitive(obj: unknown) {\n return obj === null || typeof obj === 'number' || typeof obj === 'string';\n}\n\nfunction merge(src: unknown, target: unknown) {\n if (Array.isArray(target)) {\n // @todo we need to add support for merging array defaults with array body/metadata arguments\n return target;\n } else if (!isObject(target)) {\n return target;\n }\n\n return lodashMerge(src, target);\n}\n\n/**\n * Ingest a file path or readable stream into a common object that we can later use to process it\n * into a parameters object for making an API request.\n *\n */\nasync function processFile(\n paramName: string | undefined,\n file: ReadStream | string,\n): Promise<{ base64?: string; buffer?: Buffer; filename: string; paramName?: string } | undefined> {\n const fs = await import('node:fs');\n // eslint-disable-next-line unicorn/import-style\n const path = await import('node:path');\n const { default: DatauriParser } = await import('datauri/parser.js');\n const { default: datauri } = await import('datauri/sync.js');\n if (typeof file === 'string') {\n // In order to support relative pathed files, we need to attempt to resolve them.\n const resolvedFile = path.resolve(file);\n\n return new Promise((resolve, reject) => {\n fs.stat(resolvedFile, async err => {\n if (err) {\n if (err.code === 'ENOENT') {\n // It's less than ideal for us to handle files that don't exist like this but because\n // `file` is a string it might actually be the full text contents of the file and not\n // actually a path.\n //\n // We also can't really regex to see if `file` *looks*` like a path because one should be\n // able to pass in a relative `owlbert.png` (instead of `./owlbert.png`) and though that\n // doesn't *look* like a path, it is one that should still work.\n return resolve(undefined);\n }\n\n return reject(err);\n }\n\n const fileMetadata = await datauri(resolvedFile);\n const payloadFilename = encodeURIComponent(path.basename(resolvedFile));\n\n return resolve({\n paramName,\n base64: fileMetadata?.content?.replace(';base64', `;name=${payloadFilename};base64`),\n filename: payloadFilename,\n buffer: fileMetadata.buffer,\n });\n });\n });\n } else if (file instanceof stream.Readable) {\n return getStreamAsBuffer(file).then(buffer => {\n const filePath = file.path as string;\n const parser = new DatauriParser();\n const base64 = parser.format(filePath, buffer).content;\n const payloadFilename = encodeURIComponent(path.basename(filePath));\n\n return {\n paramName,\n base64: base64?.replace(';base64', `;name=${payloadFilename};base64`),\n filename: payloadFilename,\n buffer,\n };\n });\n }\n\n return Promise.reject(\n new TypeError(\n paramName\n ? `The data supplied for the \\`${paramName}\\` request body parameter is not a file handler that we support.`\n : 'The data supplied for the request body payload is not a file handler that we support.',\n ),\n );\n}\n\n/**\n * With potentially supplied body and/or metadata we need to run through them against a given API\n * operation to see what's what and prepare any available parameters to be used in an API request\n * with `@readme/oas-to-har`.\n *\n */\nexport default async function prepareParams(operation: Operation, body?: unknown, metadata?: Record<string, unknown>) {\n let metadataIntersected = false;\n const digestedParameters = digestParameters(operation.getParameters());\n const jsonSchema = operation.getParametersAsJSONSchema();\n\n /**\n * It might be common for somebody to run `sdk.findPetsByStatus({ status: 'available' }, {})`, in\n * which case we want to filter out the second (metadata) parameter and treat the first parameter\n * as the metadata instead. If we don't do this, their supplied `status` metadata will be treated\n * as a body parameter, and because there's no `status` body parameter, and no supplied metadata\n * (because it's an empty object), the request won't send a payload.\n *\n * @see {@link https://github.com/readmeio/api/issues/449}\n */\n // eslint-disable-next-line no-param-reassign\n metadata = removeUndefinedObjects(metadata);\n\n if (!jsonSchema && (body !== undefined || metadata !== undefined)) {\n let throwNoParamsError = true;\n\n // If this operation doesn't have any parameters for us to transform to JSON Schema but they've\n // sent us either an `Accept` or `Authorization` header (or both) we should let them do that.\n // We should, however, only do this check for the `body` parameter as if they've sent this\n // request both `body` and `metadata` we can reject it outright as the operation won't have any\n // body data.\n if (body !== undefined) {\n if (typeof body === 'object' && body !== null && !Array.isArray(body)) {\n if (Object.keys(body).length <= 2) {\n const bodyParams = caseless(body);\n\n if (specialHeaders.some(header => bodyParams.has(header))) {\n throwNoParamsError = false;\n }\n }\n }\n }\n\n if (throwNoParamsError) {\n throw new Error(\n \"You supplied metadata and/or body data for this operation but it doesn't have any documented parameters or request payloads. If you think this is an error please contact support for the API you're using.\",\n );\n }\n }\n\n const jsonSchemaDefaults = jsonSchema ? getJSONSchemaDefaults(jsonSchema) : {};\n\n const params: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n body?: any;\n cookie?: Record<string, boolean | number | string>;\n files?: Record<string, Buffer>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n formData?: any;\n header?: Record<string, boolean | number | string>;\n path?: Record<string, boolean | number | string>;\n query?: Record<string, boolean | number | string>;\n server?: {\n selected: number;\n variables: Record<string, number | string>;\n };\n } = jsonSchemaDefaults;\n\n // If a body argument was supplied we need to do a bit of work to see if it's actually a body\n // argument or metadata because the library lets you supply either a body, metadata, or body with\n // metadata.\n if (typeof body !== 'undefined') {\n if (Array.isArray(body) || isPrimitive(body)) {\n // If the body param is an array or a primitive then we know it's absolutely a body because\n // metadata can only ever be undefined or an object.\n params.body = merge(params.body, body);\n } else if (typeof metadata === 'undefined') {\n // No metadata was explicitly provided so we need to analyze the body to determine if it's a\n // body or should be actually be treated as metadata.\n const headerParams = caseless({});\n Object.entries(digestedParameters).forEach(([paramName, param]) => {\n // Headers are sent case-insensitive so we need to make sure that we're properly\n // matching them when detecting what our incoming payload looks like.\n if (param.in === 'header') {\n headerParams.set(paramName, '');\n }\n });\n\n // `Accept` and `Authorization` headers can't be defined as normal parameters but we should\n // always allow the user to supply them if they wish.\n specialHeaders.forEach(header => {\n if (!headerParams.has(header)) {\n headerParams.set(header, '');\n }\n });\n\n const intersection = Object.keys(body as NonNullable<unknown>).filter(value => {\n if (Object.keys(digestedParameters).includes(value)) {\n return true;\n } else if (headerParams.has(value)) {\n return true;\n }\n\n return false;\n }).length;\n\n // If more than 25% of the body intersects with the parameters that we've got on hand, then\n // we should treat it as a metadata object and organize into parameters.\n if (intersection && intersection / Object.keys(body as NonNullable<unknown>).length > 0.25) {\n /* eslint-disable no-param-reassign */\n metadataIntersected = true;\n metadata = merge(params.body, body) as Record<string, unknown>;\n body = undefined;\n /* eslint-enable no-param-reassign */\n } else {\n // For all other cases, we should just treat the supplied body as a body.\n params.body = merge(params.body, body);\n }\n } else {\n // Body and metadata were both supplied.\n params.body = merge(params.body, body);\n }\n }\n\n if (!operation.hasRequestBody()) {\n // If this operation doesn't have any documented request body then we shouldn't be sending\n // anything.\n delete params.body;\n } else {\n if (!('body' in params)) params.body = {};\n\n // We need to retrieve the request body for this operation to search for any `binary` format\n // data that the user wants to send so we know what we need to prepare for the final API\n // request.\n const payloadJsonSchema = jsonSchema.find(js => js.type === 'body');\n if (payloadJsonSchema) {\n if (!params.files) params.files = {};\n\n const conversions = [];\n\n // @todo add support for `type: array`, `oneOf` and `anyOf`\n if (payloadJsonSchema.schema?.properties) {\n Object.entries(payloadJsonSchema.schema?.properties)\n .filter(([, schema]: [string, SchemaObject]) => schema?.format === 'binary')\n .filter(([prop]) => Object.keys(params.body).includes(prop))\n .forEach(([prop]) => {\n conversions.push(processFile(prop, params.body[prop]));\n });\n } else if (payloadJsonSchema.schema?.type === 'string') {\n if (payloadJsonSchema.schema?.format === 'binary') {\n conversions.push(processFile(undefined, params.body));\n }\n }\n\n await Promise.all(conversions)\n .then(fileMetadata => fileMetadata.filter(Boolean))\n .then(fm => {\n fm.forEach(fileMetadata => {\n if (!fileMetadata) {\n // If we don't have any metadata here it's because the file we have is likely\n // the full string content of the file so since we don't have any filenames to\n // work with we shouldn't do any additional handling to the `body` or `files`\n // parameters.\n return;\n }\n\n if (fileMetadata.paramName) {\n params.body[fileMetadata.paramName] = fileMetadata.base64;\n } else {\n params.body = fileMetadata.base64;\n }\n\n if (fileMetadata.buffer && params?.files) {\n params.files[fileMetadata.filename] = fileMetadata.buffer;\n }\n });\n });\n }\n }\n\n // Form data should be placed within `formData` instead of `body` for it to properly get picked\n // up by `fetch-har`.\n if (operation.isFormUrlEncoded()) {\n params.formData = merge(params.formData, params.body);\n delete params.body;\n }\n\n // Only spend time trying to organize metadata into parameters if we were able to digest\n // parameters out of the operation schema. If we couldn't digest anything, but metadata was\n // supplied then we wouldn't know how to send it in the request!\n if (typeof metadata !== 'undefined') {\n if (!('cookie' in params)) params.cookie = {};\n if (!('header' in params)) params.header = {};\n if (!('path' in params)) params.path = {};\n if (!('query' in params)) params.query = {};\n\n Object.entries(digestedParameters).forEach(([paramName, param]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let value: any;\n let metadataHeaderParam;\n if (typeof metadata === 'object' && !isEmpty(metadata)) {\n if (paramName in metadata) {\n value = metadata[paramName];\n metadataHeaderParam = paramName;\n } else if (param.in === 'header') {\n // Headers are sent case-insensitive so we need to make sure that we're properly\n // matching them when detecting what our incoming payload looks like.\n metadataHeaderParam = Object.keys(metadata).find(k => k.toLowerCase() === paramName.toLowerCase()) || '';\n value = metadata[metadataHeaderParam];\n }\n }\n\n if (value === undefined) {\n return;\n }\n\n /* eslint-disable no-param-reassign */\n switch (param.in) {\n case 'path':\n (params.path as NonNullable<typeof params.path>)[paramName] = value;\n if (metadata?.[paramName]) delete metadata[paramName];\n break;\n case 'query':\n (params.query as NonNullable<typeof params.query>)[paramName] = value;\n if (metadata?.[paramName]) delete metadata[paramName];\n break;\n case 'header':\n (params.header as NonNullable<typeof params.header>)[paramName.toLowerCase()] = value;\n if (metadataHeaderParam && metadata?.[metadataHeaderParam]) delete metadata[metadataHeaderParam];\n break;\n case 'cookie':\n (params.cookie as NonNullable<typeof params.cookie>)[paramName] = value;\n if (metadata?.[paramName]) delete metadata[paramName];\n break;\n default: // no-op\n }\n /* eslint-enable no-param-reassign */\n\n // Because a user might have sent just a metadata object, we want to make sure that we filter\n // out anything that they sent that is a parameter from also being sent as part of a form\n // data payload for `x-www-form-urlencoded` requests.\n if (metadataIntersected && operation.isFormUrlEncoded()) {\n if (paramName in params.formData) {\n delete params.formData[paramName];\n }\n }\n });\n\n // If there's any leftover metadata that hasn't been moved into form data for this request we\n // need to move it or else it'll get tossed.\n if (!isEmpty(metadata)) {\n if (typeof metadata === 'object') {\n // If the user supplied an `accept` or `authorization` header themselves we should allow it\n // through. Normally these headers are automatically handled by `@readme/oas-to-har` but in\n // the event that maybe the user wants to return XML for an API that normally returns JSON\n // or specify a custom auth header (maybe we can't handle their auth case right) this is the\n // only way with this library that they can do that.\n specialHeaders.forEach(headerName => {\n const headerParam = Object.keys(metadata || {}).find(m => m.toLowerCase() === headerName);\n if (headerParam) {\n // this if-statement below is a typeguard\n if (typeof metadata === 'object') {\n // this if-statement below is a typeguard\n if (typeof params.header === 'object') {\n params.header[headerName] = metadata[headerParam] as string;\n }\n // eslint-disable-next-line no-param-reassign\n delete metadata[headerParam];\n }\n }\n });\n }\n\n if (operation.isFormUrlEncoded()) {\n params.formData = merge(params.formData, metadata);\n } else {\n // Any other remaining unused metadata will be unused because we don't know where to place\n // it in the request.\n }\n }\n }\n\n (['body', 'cookie', 'files', 'formData', 'header', 'path', 'query'] as const).forEach((type: keyof typeof params) => {\n if (type in params && isEmpty(params[type])) {\n delete params[type];\n }\n });\n\n return params;\n}\n","import {on} from 'node:events';\nimport {finished} from 'node:stream/promises';\nimport {nodeImports} from './stream.js';\n\nObject.assign(nodeImports, {on, finished});\n\nexport {\n\tdefault,\n\tgetStreamAsArray,\n\tgetStreamAsArrayBuffer,\n\tgetStreamAsBuffer,\n\tMaxBufferError,\n} from './exports.js';\n","export function isStream(stream, {checkOpen = true} = {}) {\n\treturn stream !== null\n\t\t&& typeof stream === 'object'\n\t\t&& (stream.writable || stream.readable || !checkOpen || (stream.writable === undefined && stream.readable === undefined))\n\t\t&& typeof stream.pipe === 'function';\n}\n\nexport function isWritableStream(stream, {checkOpen = true} = {}) {\n\treturn isStream(stream, {checkOpen})\n\t\t&& (stream.writable || !checkOpen)\n\t\t&& typeof stream.write === 'function'\n\t\t&& typeof stream.end === 'function'\n\t\t&& typeof stream.writable === 'boolean'\n\t\t&& typeof stream.writableObjectMode === 'boolean'\n\t\t&& typeof stream.destroy === 'function'\n\t\t&& typeof stream.destroyed === 'boolean';\n}\n\nexport function isReadableStream(stream, {checkOpen = true} = {}) {\n\treturn isStream(stream, {checkOpen})\n\t\t&& (stream.readable || !checkOpen)\n\t\t&& typeof stream.read === 'function'\n\t\t&& typeof stream.readable === 'boolean'\n\t\t&& typeof stream.readableObjectMode === 'boolean'\n\t\t&& typeof stream.destroy === 'function'\n\t\t&& typeof stream.destroyed === 'boolean';\n}\n\nexport function isDuplexStream(stream, options) {\n\treturn isWritableStream(stream, options)\n\t\t&& isReadableStream(stream, options);\n}\n\nexport function isTransformStream(stream, options) {\n\treturn isDuplexStream(stream, options)\n\t\t&& typeof stream._transform === 'function';\n}\n","const a = Object.getPrototypeOf(\n Object.getPrototypeOf(\n /* istanbul ignore next */\n async function* () {\n }\n ).prototype\n);\nclass c {\n #t;\n #n;\n #r = !1;\n #e = void 0;\n constructor(e, t) {\n this.#t = e, this.#n = t;\n }\n next() {\n const e = () => this.#s();\n return this.#e = this.#e ? this.#e.then(e, e) : e(), this.#e;\n }\n return(e) {\n const t = () => this.#i(e);\n return this.#e ? this.#e.then(t, t) : t();\n }\n async #s() {\n if (this.#r)\n return {\n done: !0,\n value: void 0\n };\n let e;\n try {\n e = await this.#t.read();\n } catch (t) {\n throw this.#e = void 0, this.#r = !0, this.#t.releaseLock(), t;\n }\n return e.done && (this.#e = void 0, this.#r = !0, this.#t.releaseLock()), e;\n }\n async #i(e) {\n if (this.#r)\n return {\n done: !0,\n value: e\n };\n if (this.#r = !0, !this.#n) {\n const t = this.#t.cancel(e);\n return this.#t.releaseLock(), await t, {\n done: !0,\n value: e\n };\n }\n return this.#t.releaseLock(), {\n done: !0,\n value: e\n };\n }\n}\nconst n = Symbol();\nfunction i() {\n return this[n].next();\n}\nObject.defineProperty(i, \"name\", { value: \"next\" });\nfunction o(r) {\n return this[n].return(r);\n}\nObject.defineProperty(o, \"name\", { value: \"return\" });\nconst u = Object.create(a, {\n next: {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: i\n },\n return: {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: o\n }\n});\nfunction h({ preventCancel: r = !1 } = {}) {\n const e = this.getReader(), t = new c(\n e,\n r\n ), s = Object.create(u);\n return s[n] = t, s;\n}\nexport {\n h as asyncIterator\n};\n","import {isReadableStream} from 'is-stream';\nimport {asyncIterator} from '@sec-ant/readable-stream/ponyfill';\n\nexport const getAsyncIterable = stream => {\n\tif (isReadableStream(stream, {checkOpen: false}) && nodeImports.on !== undefined) {\n\t\treturn getStreamIterable(stream);\n\t}\n\n\tif (typeof stream?.[Symbol.asyncIterator] === 'function') {\n\t\treturn stream;\n\t}\n\n\t// `ReadableStream[Symbol.asyncIterator]` support is missing in multiple browsers, so we ponyfill it\n\tif (toString.call(stream) === '[object ReadableStream]') {\n\t\treturn asyncIterator.call(stream);\n\t}\n\n\tthrow new TypeError('The first argument must be a Readable, a ReadableStream, or an async iterable.');\n};\n\nconst {toString} = Object.prototype;\n\n// The default iterable for Node.js streams does not allow for multiple readers at once, so we re-implement it\nconst getStreamIterable = async function * (stream) {\n\tconst controller = new AbortController();\n\tconst state = {};\n\thandleStreamEnd(stream, controller, state);\n\n\ttry {\n\t\tfor await (const [chunk] of nodeImports.on(stream, 'data', {signal: controller.signal})) {\n\t\t\tyield chunk;\n\t\t}\n\t} catch (error) {\n\t\t// Stream failure, for example due to `stream.destroy(error)`\n\t\tif (state.error !== undefined) {\n\t\t\tthrow state.error;\n\t\t// `error` event directly emitted on stream\n\t\t} else if (!controller.signal.aborted) {\n\t\t\tthrow error;\n\t\t// Otherwise, stream completed successfully\n\t\t}\n\t\t// The `finally` block also runs when the caller throws, for example due to the `maxBuffer` option\n\t} finally {\n\t\tstream.destroy();\n\t}\n};\n\nconst handleStreamEnd = async (stream, controller, state) => {\n\ttry {\n\t\tawait nodeImports.finished(stream, {\n\t\t\tcleanup: true,\n\t\t\treadable: true,\n\t\t\twritable: false,\n\t\t\terror: false,\n\t\t});\n\t} catch (error) {\n\t\tstate.error = error;\n\t} finally {\n\t\tcontroller.abort();\n\t}\n};\n\n// Loaded by the Node entrypoint, but not by the browser one.\n// This prevents using dynamic imports.\nexport const nodeImports = {};\n","import {getAsyncIterable} from './stream.js';\n\nexport const getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => {\n\tconst asyncIterable = getAsyncIterable(stream);\n\n\tconst state = init();\n\tstate.length = 0;\n\n\ttry {\n\t\tfor await (const chunk of asyncIterable) {\n\t\t\tconst chunkType = getChunkType(chunk);\n\t\t\tconst convertedChunk = convertChunk[chunkType](chunk, state);\n\t\t\tappendChunk({\n\t\t\t\tconvertedChunk,\n\t\t\t\tstate,\n\t\t\t\tgetSize,\n\t\t\t\ttruncateChunk,\n\t\t\t\taddChunk,\n\t\t\t\tmaxBuffer,\n\t\t\t});\n\t\t}\n\n\t\tappendFinalChunk({\n\t\t\tstate,\n\t\t\tconvertChunk,\n\t\t\tgetSize,\n\t\t\ttruncateChunk,\n\t\t\taddChunk,\n\t\t\tgetFinalChunk,\n\t\t\tmaxBuffer,\n\t\t});\n\t\treturn finalize(state);\n\t} catch (error) {\n\t\tconst normalizedError = typeof error === 'object' && error !== null ? error : new Error(error);\n\t\tnormalizedError.bufferedData = finalize(state);\n\t\tthrow normalizedError;\n\t}\n};\n\nconst appendFinalChunk = ({state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer}) => {\n\tconst convertedChunk = getFinalChunk(state);\n\tif (convertedChunk !== undefined) {\n\t\tappendChunk({\n\t\t\tconvertedChunk,\n\t\t\tstate,\n\t\t\tgetSize,\n\t\t\ttruncateChunk,\n\t\t\taddChunk,\n\t\t\tmaxBuffer,\n\t\t});\n\t}\n};\n\nconst appendChunk = ({convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer}) => {\n\tconst chunkSize = getSize(convertedChunk);\n\tconst newLength = state.length + chunkSize;\n\n\tif (newLength <= maxBuffer) {\n\t\taddNewChunk(convertedChunk, state, addChunk, newLength);\n\t\treturn;\n\t}\n\n\tconst truncatedChunk = truncateChunk(convertedChunk, maxBuffer - state.length);\n\n\tif (truncatedChunk !== undefined) {\n\t\taddNewChunk(truncatedChunk, state, addChunk, maxBuffer);\n\t}\n\n\tthrow new MaxBufferError();\n};\n\nconst addNewChunk = (convertedChunk, state, addChunk, newLength) => {\n\tstate.contents = addChunk(convertedChunk, state, newLength);\n\tstate.length = newLength;\n};\n\nconst getChunkType = chunk => {\n\tconst typeOfChunk = typeof chunk;\n\n\tif (typeOfChunk === 'string') {\n\t\treturn 'string';\n\t}\n\n\tif (typeOfChunk !== 'object' || chunk === null) {\n\t\treturn 'others';\n\t}\n\n\tif (globalThis.Buffer?.isBuffer(chunk)) {\n\t\treturn 'buffer';\n\t}\n\n\tconst prototypeName = objectToString.call(chunk);\n\n\tif (prototypeName === '[object ArrayBuffer]') {\n\t\treturn 'arrayBuffer';\n\t}\n\n\tif (prototypeName === '[object DataView]') {\n\t\treturn 'dataView';\n\t}\n\n\tif (\n\t\tNumber.isInteger(chunk.byteLength)\n\t\t&& Number.isInteger(chunk.byteOffset)\n\t\t&& objectToString.call(chunk.buffer) === '[object ArrayBuffer]'\n\t) {\n\t\treturn 'typedArray';\n\t}\n\n\treturn 'others';\n};\n\nconst {toString: objectToString} = Object.prototype;\n\nexport class MaxBufferError extends Error {\n\tname = 'MaxBufferError';\n\n\tconstructor() {\n\t\tsuper('maxBuffer exceeded');\n\t}\n}\n","export const identity = value => value;\n\nexport const noop = () => undefined;\n\nexport const getContentsProperty = ({contents}) => contents;\n\nexport const throwObjectStream = chunk => {\n\tthrow new Error(`Streams in object mode are not supported: ${String(chunk)}`);\n};\n\nexport const getLengthProperty = convertedChunk => convertedChunk.length;\n","import {getStreamContents} from './contents.js';\nimport {noop, throwObjectStream, getLengthProperty} from './utils.js';\n\nexport async function getStreamAsArrayBuffer(stream, options) {\n\treturn getStreamContents(stream, arrayBufferMethods, options);\n}\n\nconst initArrayBuffer = () => ({contents: new ArrayBuffer(0)});\n\nconst useTextEncoder = chunk => textEncoder.encode(chunk);\nconst textEncoder = new TextEncoder();\n\nconst useUint8Array = chunk => new Uint8Array(chunk);\n\nconst useUint8ArrayWithOffset = chunk => new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);\n\nconst truncateArrayBufferChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);\n\n// `contents` is an increasingly growing `Uint8Array`.\nconst addArrayBufferChunk = (convertedChunk, {contents, length: previousLength}, length) => {\n\tconst newContents = hasArrayBufferResize() ? resizeArrayBuffer(contents, length) : resizeArrayBufferSlow(contents, length);\n\tnew Uint8Array(newContents).set(convertedChunk, previousLength);\n\treturn newContents;\n};\n\n// Without `ArrayBuffer.resize()`, `contents` size is always a power of 2.\n// This means its last bytes are zeroes (not stream data), which need to be\n// trimmed at the end with `ArrayBuffer.slice()`.\nconst resizeArrayBufferSlow = (contents, length) => {\n\tif (length <= contents.byteLength) {\n\t\treturn contents;\n\t}\n\n\tconst arrayBuffer = new ArrayBuffer(getNewContentsLength(length));\n\tnew Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);\n\treturn arrayBuffer;\n};\n\n// With `ArrayBuffer.resize()`, `contents` size matches exactly the size of\n// the stream data. It does not include extraneous zeroes to trim at the end.\n// The underlying `ArrayBuffer` does allocate a number of bytes that is a power\n// of 2, but those bytes are only visible after calling `ArrayBuffer.resize()`.\nconst resizeArrayBuffer = (contents, length) => {\n\tif (length <= contents.maxByteLength) {\n\t\tcontents.resize(length);\n\t\treturn contents;\n\t}\n\n\tconst arrayBuffer = new ArrayBuffer(length, {maxByteLength: getNewContentsLength(length)});\n\tnew Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);\n\treturn arrayBuffer;\n};\n\n// Retrieve the closest `length` that is both >= and a power of 2\nconst getNewContentsLength = length => SCALE_FACTOR ** Math.ceil(Math.log(length) / Math.log(SCALE_FACTOR));\n\nconst SCALE_FACTOR = 2;\n\nconst finalizeArrayBuffer = ({contents, length}) => hasArrayBufferResize() ? contents : contents.slice(0, length);\n\n// `ArrayBuffer.slice()` is slow. When `ArrayBuffer.resize()` is available\n// (Node >=20.0.0, Safari >=16.4 and Chrome), we can use it instead.\n// eslint-disable-next-line no-warning-comments\n// TODO: remove after dropping support for Node 20.\n// eslint-disable-next-line no-warning-comments\n// TODO: use `ArrayBuffer.transferToFixedLength()` instead once it is available\nconst hasArrayBufferResize = () => 'resize' in ArrayBuffer.prototype;\n\nconst arrayBufferMethods = {\n\tinit: initArrayBuffer,\n\tconvertChunk: {\n\t\tstring: useTextEncoder,\n\t\tbuffer: useUint8Array,\n\t\tarrayBuffer: useUint8Array,\n\t\tdataView: useUint8ArrayWithOffset,\n\t\ttypedArray: useUint8ArrayWithOffset,\n\t\tothers: throwObjectStream,\n\t},\n\tgetSize: getLengthProperty,\n\ttruncateChunk: truncateArrayBufferChunk,\n\taddChunk: addArrayBufferChunk,\n\tgetFinalChunk: noop,\n\tfinalize: finalizeArrayBuffer,\n};\n","import {getStreamAsArrayBuffer} from './array-buffer.js';\n\nexport async function getStreamAsBuffer(stream, options) {\n\tif (!('Buffer' in globalThis)) {\n\t\tthrow new Error('getStreamAsBuffer() is only supported in Node.js');\n\t}\n\n\ttry {\n\t\treturn arrayBufferToNodeBuffer(await getStreamAsArrayBuffer(stream, options));\n\t} catch (error) {\n\t\tif (error.bufferedData !== undefined) {\n\t\t\terror.bufferedData = arrayBufferToNodeBuffer(error.bufferedData);\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nconst arrayBufferToNodeBuffer = arrayBuffer => globalThis.Buffer.from(arrayBuffer);\n","import type Oas from 'oas';\n\nfunction stripTrailingSlash(url: string) {\n if (url[url.length - 1] === '/') {\n return url.slice(0, -1);\n }\n\n return url;\n}\n\n/**\n * With an SDK server config and an instance of OAS we should extract and prepare the server and\n * any server variables to be supplied to `@readme/oas-to-har`.\n *\n */\nexport default function prepareServer(spec: Oas, url: string, variables: Record<string, number | string> = {}) {\n let serverIdx: number | undefined;\n const sanitizedUrl = stripTrailingSlash(url);\n (spec.api.servers || []).forEach((server, i) => {\n if (server.url === sanitizedUrl) {\n serverIdx = i;\n }\n });\n\n // If we were able to find the passed in server in the OAS servers, we should use that! If we\n // couldn't and server variables were passed in we should try our best to handle that, otherwise\n // we should ignore the passed in server and use whever the default from the OAS is.\n if (serverIdx !== undefined) {\n return {\n selected: serverIdx,\n variables,\n };\n } else if (Object.keys(variables).length) {\n // @todo we should run `oas.replaceUrl(url)` and pass that unto `@readme/oas-to-har`\n } else {\n const server = spec.splitVariables(url);\n if (server) {\n return {\n selected: server.selected,\n variables: server.variables,\n };\n }\n\n // @todo we should pass `url` directly into `@readme/oas-to-har` as the base URL\n }\n\n return false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/fetchError.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["/Users/kanadg/Code/readmeio/api/packages/core/dist/chunk-NVFSP2R3.cjs","../src/errors/fetchError.ts"],"names":[],"mappings":"AAAA;ACAA,IAAqB,WAAA,EAArB,MAAqB,YAAA,QAAoD,MAAM;AAAA;AAAA,EAE7E;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EAEA,WAAA,CAAY,MAAA,EAAgB,IAAA,EAAY,OAAA,EAAkB,GAAA,EAAe;AACvE,IAAA,KAAA,CAAM,GAAA,CAAI,UAAU,CAAA;AAEpB,IAAA,IAAA,CAAK,KAAA,EAAO,YAAA;AACZ,IAAA,IAAA,CAAK,OAAA,EAAS,MAAA;AACd,IAAA,IAAA,CAAK,KAAA,EAAO,IAAA;AACZ,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AACf,IAAA,IAAA,CAAK,IAAA,EAAM,GAAA;AAMX,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,WAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF,CAAA;ADRA;AACA;AACE;AACF,gCAAC","file":"/Users/kanadg/Code/readmeio/api/packages/core/dist/chunk-NVFSP2R3.cjs","sourcesContent":[null,"export default class FetchError<Status = number, Data = unknown> extends Error {\n /** HTTP Status */\n status: Status;\n\n /** The content of the response. */\n data: Data;\n\n /** The Headers of the response. */\n headers: Headers;\n\n /** The raw `Response` object. */\n res: Response;\n\n constructor(status: Status, data: Data, headers: Headers, res: Response) {\n super(res.statusText);\n\n this.name = 'FetchError';\n this.status = status;\n this.data = data;\n this.headers = headers;\n this.res = res;\n\n // We could fix this by updating our target to ES2015 but because we support exporting to CJS\n // we can't.\n //\n // https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/\n Object.setPrototypeOf(this, FetchError.prototype);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"sources":["/Users/kanadg/Code/readmeio/api/packages/core/dist/errors/fetchError.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,yDAAA;AACA;AACE;AACF,+CAAA","file":"/Users/kanadg/Code/readmeio/api/packages/core/dist/errors/fetchError.cjs"}
|