@triveria/wallet 0.0.278 → 0.0.279

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/common.d.ts +6 -0
  2. package/common.js +17 -3
  3. package/package.json +1 -1
package/common.d.ts CHANGED
@@ -23,6 +23,12 @@ export declare const setBasicAuthToObject: (object: any, configuration?: Configu
23
23
  export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
24
24
  export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
25
25
  export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
26
+ /**
27
+ * JSON serialization helper function which replaces instances of unserializable types with serializable ones.
28
+ * This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
29
+ * Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
30
+ */
31
+ export declare const replaceWithSerializableTypeIfNeeded: (key: any, value: any) => any;
26
32
  export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
27
33
  export declare const toPathString: (url: URL) => string;
28
34
  export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
package/common.js CHANGED
@@ -22,7 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  });
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
25
+ exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.replaceWithSerializableTypeIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
26
26
  const base_1 = require("./base");
27
27
  exports.DUMMY_BASE_URL = 'https://example.com';
28
28
  /**
@@ -78,7 +78,7 @@ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
78
78
  if (parameter == null)
79
79
  return;
80
80
  if (typeof parameter === "object") {
81
- if (Array.isArray(parameter)) {
81
+ if (Array.isArray(parameter) || parameter instanceof Set) {
82
82
  parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
83
83
  }
84
84
  else {
@@ -100,13 +100,27 @@ const setSearchParams = function (url, ...objects) {
100
100
  url.search = searchParams.toString();
101
101
  };
102
102
  exports.setSearchParams = setSearchParams;
103
+ /**
104
+ * JSON serialization helper function which replaces instances of unserializable types with serializable ones.
105
+ * This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
106
+ * Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
107
+ */
108
+ const replaceWithSerializableTypeIfNeeded = function (key, value) {
109
+ if (value instanceof Set) {
110
+ return Array.from(value);
111
+ }
112
+ else {
113
+ return value;
114
+ }
115
+ };
116
+ exports.replaceWithSerializableTypeIfNeeded = replaceWithSerializableTypeIfNeeded;
103
117
  const serializeDataIfNeeded = function (value, requestOptions, configuration) {
104
118
  const nonString = typeof value !== 'string';
105
119
  const needsSerialization = nonString && configuration && configuration.isJsonMime
106
120
  ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
107
121
  : nonString;
108
122
  return needsSerialization
109
- ? JSON.stringify(value !== undefined ? value : {})
123
+ ? JSON.stringify(value !== undefined ? value : {}, exports.replaceWithSerializableTypeIfNeeded)
110
124
  : (value || "");
111
125
  };
112
126
  exports.serializeDataIfNeeded = serializeDataIfNeeded;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@triveria/wallet",
3
3
  "private": false,
4
- "version": "0.0.278",
4
+ "version": "0.0.279",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {