Socket
Socket
Sign inDemoInstall

@qdrant/openapi-typescript-fetch

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qdrant/openapi-typescript-fetch - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

25

dist/cjs/fetcher.js

@@ -5,3 +5,18 @@ "use strict";

const types_js_1 = require("./types.js");
const json_with_bigint_js_1 = require("./json-with-bigint.js");
let bigintReviver;
let bigintReplacer;
if ('rawJSON' in JSON) {
bigintReviver = function (_key, val, context) {
if (Number.isInteger(val) && !Number.isSafeInteger(val)) {
return BigInt(context.source);
}
return val;
};
bigintReplacer = function (_key, val) {
if (typeof val === 'bigint') {
return JSON.rawJSON(String(val));
}
return val;
};
}
const sendBody = (method) => method === 'post' ||

@@ -66,3 +81,5 @@ method === 'put' ||

}
const body = payload instanceof FormData ? payload : (0, json_with_bigint_js_1.JSONStringify)(payload);
const body = payload instanceof FormData
? payload
: JSON.stringify(payload, bigintReplacer);
return method === 'delete' && body === '{}' ? undefined : body;

@@ -105,6 +122,6 @@ }

if (contentType && contentType.includes('application/json')) {
return (0, json_with_bigint_js_1.JSONParse)(responseText);
return JSON.parse(responseText, bigintReviver);
}
try {
return (0, json_with_bigint_js_1.JSONParse)(responseText);
return JSON.parse(responseText, bigintReviver);
}

@@ -111,0 +128,0 @@ catch (e) {

@@ -11,3 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { ApiError, } from './types.js';
import { JSONParse, JSONStringify } from './json-with-bigint.js';
let bigintReviver;
let bigintReplacer;
if ('rawJSON' in JSON) {
bigintReviver = function (_key, val, context) {
if (Number.isInteger(val) && !Number.isSafeInteger(val)) {
return BigInt(context.source);
}
return val;
};
bigintReplacer = function (_key, val) {
if (typeof val === 'bigint') {
return JSON.rawJSON(String(val));
}
return val;
};
}
const sendBody = (method) => method === 'post' ||

@@ -72,3 +87,5 @@ method === 'put' ||

}
const body = payload instanceof FormData ? payload : JSONStringify(payload);
const body = payload instanceof FormData
? payload
: JSON.stringify(payload, bigintReplacer);
return method === 'delete' && body === '{}' ? undefined : body;

@@ -109,6 +126,6 @@ }

if (contentType && contentType.includes('application/json')) {
return JSONParse(responseText);
return JSON.parse(responseText, bigintReviver);
}
try {
return JSONParse(responseText);
return JSON.parse(responseText, bigintReviver);
}

@@ -115,0 +132,0 @@ catch (e) {

import { ApiError, } from './types.js';
import { JSONParse, JSONStringify } from './json-with-bigint.js';
let bigintReviver;
let bigintReplacer;
if ('rawJSON' in JSON) {
bigintReviver = function (_key, val, context) {
if (Number.isInteger(val) && !Number.isSafeInteger(val)) {
return BigInt(context.source);
}
return val;
};
bigintReplacer = function (_key, val) {
if (typeof val === 'bigint') {
return JSON.rawJSON(String(val));
}
return val;
};
}
const sendBody = (method) => method === 'post' ||

@@ -62,3 +77,5 @@ method === 'put' ||

}
const body = payload instanceof FormData ? payload : JSONStringify(payload);
const body = payload instanceof FormData
? payload
: JSON.stringify(payload, bigintReplacer);
return method === 'delete' && body === '{}' ? undefined : body;

@@ -101,6 +118,6 @@ }

if (contentType && contentType.includes('application/json')) {
return JSONParse(responseText);
return JSON.parse(responseText, bigintReviver);
}
try {
return JSONParse(responseText);
return JSON.parse(responseText, bigintReviver);
}

@@ -107,0 +124,0 @@ catch (e) {

import { CreateFetch, FetchConfig, Middleware, OpenapiPaths } from './types.js';
declare global {
interface JSON {
rawJSON?(jsonStr: string): {
rawJSON: string;
};
}
}
export declare const Fetcher: {

@@ -3,0 +10,0 @@ for: <Paths extends OpenapiPaths<Paths>>() => {

18

package.json
{
"name": "@qdrant/openapi-typescript-fetch",
"description": "A typed fetch client for openapi-typescript",
"version": "1.2.3",
"version": "1.2.4",
"engines": {
"node": ">=12.0.0",
"node": ">=21.0.0",
"pnpm": ">=8"

@@ -79,3 +79,3 @@ },

"@changesets/cli": "2.26.1",
"@types/jest": "^28.0.0",
"@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^4.30.0",

@@ -87,10 +87,10 @@ "@typescript-eslint/parser": "^4.31.0",

"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.0.0",
"jest-environment-jsdom": "^28.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"msw": "^0.49.3",
"prettier": "^2.4.0",
"rimraf": "^3.0.0",
"ts-jest": "^28.0.0",
"ts-node": "^10.0.0",
"typescript": "~4.7.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": ">=4.7",
"whatwg-fetch": "^3.6.2"

@@ -107,3 +107,3 @@ },

"lint": "eslint .",
"test": "pnpm build && jest",
"test": "jest",
"test:coverage": "pnpm build && jest --no-cache --coverage && codecov",

@@ -110,0 +110,0 @@ "test:coverage:local": "pnpm build && jest --no-cache --collectCoverage",

@@ -197,2 +197,23 @@ [![version(scoped)](https://img.shields.io/npm/v/@qdrant/openapi-typescript-fetch.svg)](https://www.npmjs.com/package/@qdrant/openapi-typescript-fetch)

### Long numeric values (de)serialization: BigInt
Stringifying and parsing big numeric values could be problematic. JSON.parse will coerce large numeric values and JSON.stringify will throw an error: `Uncaught TypeError: Do not know how to serialize a BigInt` in such cases.
To circumvent this issue, this library will serialize big numeric values to `BigInt` using `JSON.rawJSON`, and equally parse big numeric values from responses via `JSON.parse` [source text access](https://github.com/tc39/proposal-json-parse-with-source) transforming them to `BigInt` for you.
> If you rely on the precision of big number in responses, or are sending big numeric values, make sure your JavaScript environment supports it. Read below...
#### JavaScript engine/environment support
##### TL;DR
- Node 21
- Chrome 112
Support is conditional; the TC39 proposal has reached staged 3 and has even shipped with Chrome by default already, with the rest of modern browsers [soon to follow](https://github.com/tc39/proposal-json-parse-with-source/issues/15#issue-664090651) with their corresponding releases.
Regarding Node.js support; at **least Node 20 is required** to be run with the next harmony flag `node --harmony-json-parse-with-source` (or Node 21 without flag πŸŽ‰), until it is switched by default in future versions.
---
Happy fetching! πŸ‘
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc