@basis-theory/basis-theory-js 1.77.1 → 1.77.2
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/common/utils.d.ts +4 -4
- package/common/utils.js +73 -17
- package/package.json +1 -1
package/common/utils.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { AxiosRequestConfig, AxiosResponse, AxiosRequestTransformer, AxiosResponseTransformer } from 'axios';
|
|
2
2
|
import type { RequestTransformers } from '../service';
|
|
3
3
|
import type { Reactor, Proxy, Token, CreateReactor, UpdateReactor, CreateToken, UpdateToken, CreateProxy, UpdateProxy } from '../types/models';
|
|
4
|
-
import type { ApplicationInfo, ProxyRequestOptions, RequestOptions } from '../types/sdk';
|
|
4
|
+
import type { ApplicationInfo, PaginatedList, ProxyRequestOptions, RequestOptions } from '../types/sdk';
|
|
5
5
|
declare const assertInit: <T>(prop: T) => NonNullable<T>;
|
|
6
6
|
declare const transformRequestSnakeCase: <T, S>(data: T) => S | undefined;
|
|
7
7
|
declare const proxyRaw: <T>(data: T) => T | undefined;
|
|
8
8
|
declare const transformReactorRequestSnakeCase: (reactor: Reactor | CreateReactor | UpdateReactor) => Reactor | CreateReactor | UpdateReactor | undefined;
|
|
9
9
|
declare const transformProxyRequestSnakeCase: (proxy: Proxy | CreateProxy | UpdateProxy) => Proxy | CreateProxy | UpdateProxy | undefined;
|
|
10
10
|
declare const transformTokenRequestSnakeCase: (token: Token | CreateToken | UpdateToken) => Token | CreateToken | UpdateToken | undefined;
|
|
11
|
-
declare const transformTokenResponseCamelCase: (
|
|
12
|
-
declare const transformReactorResponseCamelCase: (
|
|
13
|
-
declare const transformProxyResponseCamelCase: (
|
|
11
|
+
declare const transformTokenResponseCamelCase: (tokenResponse: Token | PaginatedList<Token> | undefined) => Token | PaginatedList<Token> | undefined;
|
|
12
|
+
declare const transformReactorResponseCamelCase: (reactorResponse: Reactor | PaginatedList<Reactor> | undefined) => Reactor | PaginatedList<Reactor> | undefined;
|
|
13
|
+
declare const transformProxyResponseCamelCase: (proxyResponse: Proxy | PaginatedList<Proxy> | undefined) => Proxy | PaginatedList<Proxy> | undefined;
|
|
14
14
|
declare const transformResponseCamelCase: <T, C>(data: T) => C | undefined;
|
|
15
15
|
declare const dataExtractor: <T>(res: AxiosResponse<T, any>) => T;
|
|
16
16
|
declare const dataAndHeadersExtractor: <T>(res: AxiosResponse<T, any>) => Pick<AxiosResponse<T, any>, "data" | "headers">;
|
package/common/utils.js
CHANGED
|
@@ -99,51 +99,107 @@ const transformTokenRequestSnakeCase = token => {
|
|
|
99
99
|
|
|
100
100
|
exports.transformTokenRequestSnakeCase = transformTokenRequestSnakeCase;
|
|
101
101
|
|
|
102
|
-
const
|
|
103
|
-
|
|
102
|
+
const isList = arg => arg && (arg === null || arg === void 0 ? void 0 : arg.pagination) !== undefined && (arg === null || arg === void 0 ? void 0 : arg.data) !== undefined;
|
|
103
|
+
|
|
104
|
+
const transformTokenResponseCamelCase = tokenResponse => {
|
|
105
|
+
if (typeof tokenResponse === 'undefined') {
|
|
104
106
|
return undefined;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
if (isList(tokenResponse)) {
|
|
110
|
+
const transformedData = tokenResponse.data.map(t => ({ ...(0, _camelcaseKeys.default)(t, {
|
|
111
|
+
deep: true
|
|
112
|
+
}),
|
|
113
|
+
...(t.data !== undefined ? {
|
|
114
|
+
data: t.data
|
|
115
|
+
} : {}),
|
|
116
|
+
...(t.metadata !== undefined ? {
|
|
117
|
+
metadata: t.metadata
|
|
118
|
+
} : {})
|
|
119
|
+
}));
|
|
120
|
+
const transformedToken = {
|
|
121
|
+
data: transformedData,
|
|
122
|
+
pagination: (0, _camelcaseKeys.default)(tokenResponse.pagination, {
|
|
123
|
+
deep: true
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
return transformedToken;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { ...(0, _camelcaseKeys.default)(tokenResponse, {
|
|
108
130
|
deep: true
|
|
109
131
|
}),
|
|
110
|
-
...(
|
|
111
|
-
data:
|
|
132
|
+
...(tokenResponse.data !== undefined ? {
|
|
133
|
+
data: tokenResponse.data
|
|
112
134
|
} : {}),
|
|
113
|
-
...(
|
|
114
|
-
metadata:
|
|
135
|
+
...(tokenResponse.metadata !== undefined ? {
|
|
136
|
+
metadata: tokenResponse.metadata
|
|
115
137
|
} : {})
|
|
116
138
|
};
|
|
117
139
|
};
|
|
118
140
|
|
|
119
141
|
exports.transformTokenResponseCamelCase = transformTokenResponseCamelCase;
|
|
120
142
|
|
|
121
|
-
const transformReactorResponseCamelCase =
|
|
122
|
-
if (typeof
|
|
143
|
+
const transformReactorResponseCamelCase = reactorResponse => {
|
|
144
|
+
if (typeof reactorResponse === 'undefined') {
|
|
123
145
|
return undefined;
|
|
124
146
|
}
|
|
125
147
|
|
|
126
|
-
|
|
148
|
+
if (isList(reactorResponse)) {
|
|
149
|
+
const transformedData = reactorResponse.data.map(r => ({ ...(0, _camelcaseKeys.default)(r, {
|
|
150
|
+
deep: true
|
|
151
|
+
}),
|
|
152
|
+
...(r.configuration !== undefined ? {
|
|
153
|
+
configuration: r.configuration
|
|
154
|
+
} : {})
|
|
155
|
+
}));
|
|
156
|
+
const transformedReactor = {
|
|
157
|
+
data: transformedData,
|
|
158
|
+
pagination: (0, _camelcaseKeys.default)(reactorResponse.pagination, {
|
|
159
|
+
deep: true
|
|
160
|
+
})
|
|
161
|
+
};
|
|
162
|
+
return transformedReactor;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return { ...(0, _camelcaseKeys.default)(reactorResponse, {
|
|
127
166
|
deep: true
|
|
128
167
|
}),
|
|
129
|
-
...(
|
|
130
|
-
configuration:
|
|
168
|
+
...(reactorResponse.configuration !== undefined ? {
|
|
169
|
+
configuration: reactorResponse.configuration
|
|
131
170
|
} : {})
|
|
132
171
|
};
|
|
133
172
|
};
|
|
134
173
|
|
|
135
174
|
exports.transformReactorResponseCamelCase = transformReactorResponseCamelCase;
|
|
136
175
|
|
|
137
|
-
const transformProxyResponseCamelCase =
|
|
138
|
-
if (typeof
|
|
176
|
+
const transformProxyResponseCamelCase = proxyResponse => {
|
|
177
|
+
if (typeof proxyResponse === 'undefined') {
|
|
139
178
|
return undefined;
|
|
140
179
|
}
|
|
141
180
|
|
|
142
|
-
|
|
181
|
+
if (isList(proxyResponse)) {
|
|
182
|
+
const transformedData = proxyResponse.data.map(p => ({ ...(0, _camelcaseKeys.default)(p, {
|
|
183
|
+
deep: true
|
|
184
|
+
}),
|
|
185
|
+
...(p.configuration !== undefined ? {
|
|
186
|
+
configuration: p.configuration
|
|
187
|
+
} : {})
|
|
188
|
+
}));
|
|
189
|
+
const transformedReactor = {
|
|
190
|
+
data: transformedData,
|
|
191
|
+
pagination: (0, _camelcaseKeys.default)(proxyResponse.pagination, {
|
|
192
|
+
deep: true
|
|
193
|
+
})
|
|
194
|
+
};
|
|
195
|
+
return transformedReactor;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return { ...(0, _camelcaseKeys.default)(proxyResponse, {
|
|
143
199
|
deep: true
|
|
144
200
|
}),
|
|
145
|
-
...(
|
|
146
|
-
configuration:
|
|
201
|
+
...(proxyResponse.configuration !== undefined ? {
|
|
202
|
+
configuration: proxyResponse.configuration
|
|
147
203
|
} : {})
|
|
148
204
|
};
|
|
149
205
|
};
|