@1money/protocol-ts-sdk 2.0.0 → 2.0.1
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/.claude/settings.local.json +17 -1
- package/es/api/index.js +32 -0
- package/es/client/core.d.ts +2 -4
- package/es/client/index.js +32 -0
- package/es/index.js +32 -0
- package/eslint.config.mjs +101 -0
- package/lib/api/index.js +42 -0
- package/lib/client/core.d.ts +2 -4
- package/lib/client/index.js +42 -0
- package/lib/index.js +42 -0
- package/package.json +25 -14
- package/umd/1money-protocol-ts-sdk.min.js +4 -3
|
@@ -20,7 +20,23 @@
|
|
|
20
20
|
"Bash(xargs grep:*)",
|
|
21
21
|
"Bash(npm run lint:es_fix:*)",
|
|
22
22
|
"Bash(node test-encoding.mjs:*)",
|
|
23
|
-
"Bash(npm test:*)"
|
|
23
|
+
"Bash(npm test:*)",
|
|
24
|
+
"Bash(gh repo view --json name,owner,url,defaultBranchRef)",
|
|
25
|
+
"Bash(gh api:*)",
|
|
26
|
+
"Bash(npm ls:*)",
|
|
27
|
+
"Bash(npm audit:*)",
|
|
28
|
+
"Bash(pnpm why flatted)",
|
|
29
|
+
"Bash(pnpm why:*)",
|
|
30
|
+
"Bash(npm view @commitlint/cli version)",
|
|
31
|
+
"Bash(npm view:*)",
|
|
32
|
+
"Bash(npm view nyc version)",
|
|
33
|
+
"Bash(python3:*)",
|
|
34
|
+
"Bash(pnpm install:*)",
|
|
35
|
+
"Bash(npx mocha:*)",
|
|
36
|
+
"Bash(git add package.json pnpm-lock.yaml)",
|
|
37
|
+
"Bash(git commit -m \"$\\(cat <<''EOF''\nchore: upgrade mocha to v11 for security fixes\n\nCo-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>\nEOF\n\\)\")",
|
|
38
|
+
"Bash(npx commitlint:*)",
|
|
39
|
+
"Bash(npm run lint:es:*)"
|
|
24
40
|
],
|
|
25
41
|
"deny": []
|
|
26
42
|
}
|
package/es/api/index.js
CHANGED
|
@@ -108,6 +108,23 @@ class Request {
|
|
|
108
108
|
data
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
+
mergeSignals(...signals) {
|
|
112
|
+
const controller = new AbortController();
|
|
113
|
+
const onAbort = () => controller.abort();
|
|
114
|
+
const cleanups = [];
|
|
115
|
+
for (const signal of signals) {
|
|
116
|
+
if (signal.aborted) {
|
|
117
|
+
controller.abort();
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
signal.addEventListener('abort', onAbort);
|
|
121
|
+
cleanups.push(() => signal.removeEventListener('abort', onAbort));
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
signal: controller.signal,
|
|
125
|
+
cleanup: () => cleanups.forEach(fn => fn()),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
111
128
|
setting(config) {
|
|
112
129
|
if (!config)
|
|
113
130
|
return console.warn('[1Money SDK]: setting method required correct parameters!');
|
|
@@ -208,18 +225,33 @@ class Request {
|
|
|
208
225
|
let timer = null;
|
|
209
226
|
let isTimeout = false;
|
|
210
227
|
const _timeout = timeout ?? initTimeout;
|
|
228
|
+
const controller = new AbortController();
|
|
229
|
+
let signalCleanup = null;
|
|
230
|
+
if (options.signal) {
|
|
231
|
+
const merged = this.mergeSignals(options.signal, controller.signal);
|
|
232
|
+
options.signal = merged.signal;
|
|
233
|
+
signalCleanup = merged.cleanup;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
options.signal = controller.signal;
|
|
237
|
+
}
|
|
211
238
|
// Cleanup function for timeout
|
|
212
239
|
const cleanup = () => {
|
|
213
240
|
if (timer !== null) {
|
|
214
241
|
clearTimeout(timer);
|
|
215
242
|
timer = null;
|
|
216
243
|
}
|
|
244
|
+
if (signalCleanup) {
|
|
245
|
+
signalCleanup();
|
|
246
|
+
signalCleanup = null;
|
|
247
|
+
}
|
|
217
248
|
};
|
|
218
249
|
if (_timeout) {
|
|
219
250
|
timer = setTimeout(async () => {
|
|
220
251
|
try {
|
|
221
252
|
isTimeout = true;
|
|
222
253
|
cleanup();
|
|
254
|
+
controller.abort();
|
|
223
255
|
let err = this.parseError('timeout');
|
|
224
256
|
// @ts-ignore
|
|
225
257
|
const res = await Promise.resolve(callbacks.timeout(err, options.headers ?? {}));
|
package/es/client/core.d.ts
CHANGED
|
@@ -87,22 +87,20 @@ export type ErrorRes = {
|
|
|
87
87
|
};
|
|
88
88
|
export type RestScopeName = ChainName['all'];
|
|
89
89
|
export type RestScope = Readonly<[RestScopeName, RestScopeName?, RestScopeName?, RestScopeName?, RestScopeName?]>;
|
|
90
|
-
type Tuple2Record<T extends readonly any[]> = {
|
|
91
|
-
[Value in T[number]]: Value;
|
|
92
|
-
};
|
|
93
90
|
export interface PromiseWrapper<T, U, TSuc = ChainReturn<T, U>['success'], TFail = ChainReturn<T, U>['failure'], TErr = ChainReturn<T, U>['error'], TLogin = ChainReturn<T, U>['login'], TTime = ChainReturn<T, U>['timeout'], HadCall extends string = ''> {
|
|
94
91
|
success<TRes = TSuc, Delete extends string = HadCall | 'success'>(onSuccess?: (res: ChainReturn<T, U>['success'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TRes, TFail, TErr, TLogin, TTime, Delete>, ChainName['withoutS'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TRes | TFail | TErr | TLogin | TTime>;
|
|
95
92
|
failure<TRes = TFail, Delete extends string = HadCall | 'failure'>(onFailure?: (res: ChainReturn<T, U>['failure'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TRes, TErr, TLogin, TTime, Delete>, ChainName['withoutF'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TRes | TErr | TLogin | TTime>;
|
|
96
93
|
error<TRes = TErr, Delete extends string = HadCall | 'error'>(onError?: (err: ChainReturn<T, U>['error'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TRes, TLogin, TTime, Delete>, ChainName['withoutE'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TRes | TLogin | TTime>;
|
|
97
94
|
login<TRes = TLogin, Delete extends string = HadCall | 'login'>(onLogin?: (res: ChainReturn<T, U>['login'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TRes, TTime, Delete>, ChainName['withoutL'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TRes | TTime>;
|
|
98
95
|
timeout<TRes = TTime, Delete extends string = HadCall | 'timeout'>(onTimeout?: (err: ChainReturn<T, U>['timeout'], headers: AxiosReqHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TRes, Delete>, ChainName['withoutT'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TLogin | TRes>;
|
|
99
|
-
rest<TRes = TSuc | TFail | TErr | TLogin | TTime,
|
|
96
|
+
rest<TRes = TSuc | TFail | TErr | TLogin | TTime, S1 extends Exclude<RestScopeName, HadCall> = Exclude<RestScopeName, HadCall>, S2 extends Exclude<RestScopeName, HadCall | S1> | undefined = undefined, S3 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string>> | undefined = undefined, S4 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string> | Extract<S3, string>> | undefined = undefined, S5 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string> | Extract<S3, string> | Extract<S4, string>> | undefined = undefined, TRestScopeName extends RestScopeName = Extract<S1 | S2 | S3 | S4 | S5, RestScopeName>, THadCallWithNotInScope extends string = HadCall | Exclude<RestScopeName, TRestScopeName>, Delete extends string = HadCall | TRestScopeName | 'rest'>(onRest?: (val: ChainName['all'] extends THadCallWithNotInScope ? unknown : ChainName['withoutS'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success'] : ChainName['withoutF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure'] : ChainName['withoutE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error'] : ChainName['withoutL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login'] : ChainName['withoutT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['timeout'] : ChainName['withoutSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure'] : ChainName['withoutSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error'] : ChainName['withoutSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login'] : ChainName['withoutST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'timeout'] : ChainName['withoutFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error'] : ChainName['withoutFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login'] : ChainName['withoutFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'timeout'] : ChainName['withoutEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login'] : ChainName['withoutET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'timeout'] : ChainName['withoutLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login' | 'timeout'] : ChainName['withSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login' | 'timeout'] : ChainName['withSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login' | 'timeout'] : ChainName['withSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'timeout'] : ChainName['withST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login'] : ChainName['withFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login' | 'timeout'] : ChainName['withFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'timeout'] : ChainName['withFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login'] : ChainName['withEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'timeout'] : ChainName['withET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login'] : ChainName['withLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error'] : ChainName['success'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login' | 'timeout'] : ChainName['failure'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login' | 'timeout'] : ChainName['error'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login' | 'timeout'] : ChainName['login'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'timeout'] : ChainName['timeout'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'login'] : ChainReturn<T, U>['all'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes, scope?: Readonly<[S1, S2?, S3?, S4?, S5?]>): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TTime, Delete>, Delete> & Promise<ChainName['all'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TTime : ChainName['withoutS'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin | TTime : ChainName['withoutF'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin | TTime : ChainName['withoutE'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin | TTime : ChainName['withoutL'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes | TTime : ChainName['withoutT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TRes : ChainName['withoutSF'] extends THadCallWithNotInScope ? TRes | TErr | TLogin | TTime : ChainName['withoutSE'] extends THadCallWithNotInScope ? TRes | TFail | TLogin | TTime : ChainName['withoutSL'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TTime : ChainName['withoutST'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin : ChainName['withoutFE'] extends THadCallWithNotInScope ? TSuc | TRes | TLogin | TTime : ChainName['withoutFL'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TTime : ChainName['withoutFT'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin : ChainName['withoutEL'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TTime : ChainName['withoutET'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin : ChainName['withoutLT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes : ChainName['withSF'] extends THadCallWithNotInScope ? TSuc | TFail | TRes : ChainName['withSE'] extends THadCallWithNotInScope ? TSuc | TErr | TRes : ChainName['withSL'] extends THadCallWithNotInScope ? TSuc | TLogin | TRes : ChainName['withST'] extends THadCallWithNotInScope ? TSuc | TTime | TRes : ChainName['withFE'] extends THadCallWithNotInScope ? TFail | TErr | TRes : ChainName['withFL'] extends THadCallWithNotInScope ? TFail | TLogin | TRes : ChainName['withFT'] extends THadCallWithNotInScope ? TFail | TTime | TRes : ChainName['withEL'] extends THadCallWithNotInScope ? TErr | TLogin | TRes : ChainName['withET'] extends THadCallWithNotInScope ? TErr | TTime | TRes : ChainName['withLT'] extends THadCallWithNotInScope ? TLogin | TTime | TRes : ChainName['success'] extends THadCallWithNotInScope ? TSuc | TRes : ChainName['failure'] extends THadCallWithNotInScope ? TFail | TRes : ChainName['error'] extends THadCallWithNotInScope ? TErr | TRes : ChainName['login'] extends THadCallWithNotInScope ? TLogin | TRes : ChainName['timeout'] extends THadCallWithNotInScope ? TTime | TRes : TRes>;
|
|
100
97
|
}
|
|
101
98
|
export declare class Request {
|
|
102
99
|
private _config;
|
|
103
100
|
axios: AxiosStatic;
|
|
104
101
|
constructor(config?: InitConfig);
|
|
105
102
|
private parseError;
|
|
103
|
+
private mergeSignals;
|
|
106
104
|
setting(config: InitConfig): void;
|
|
107
105
|
request<T, U = unknown>(options: Options<T, U>): PromiseWrapper<T, U> & Promise<CustomResponseData<T, U, WithFailureData<T>>>;
|
|
108
106
|
}
|
package/es/client/index.js
CHANGED
|
@@ -108,6 +108,23 @@ class Request {
|
|
|
108
108
|
data
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
+
mergeSignals(...signals) {
|
|
112
|
+
const controller = new AbortController();
|
|
113
|
+
const onAbort = () => controller.abort();
|
|
114
|
+
const cleanups = [];
|
|
115
|
+
for (const signal of signals) {
|
|
116
|
+
if (signal.aborted) {
|
|
117
|
+
controller.abort();
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
signal.addEventListener('abort', onAbort);
|
|
121
|
+
cleanups.push(() => signal.removeEventListener('abort', onAbort));
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
signal: controller.signal,
|
|
125
|
+
cleanup: () => cleanups.forEach(fn => fn()),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
111
128
|
setting(config) {
|
|
112
129
|
if (!config)
|
|
113
130
|
return console.warn('[1Money SDK]: setting method required correct parameters!');
|
|
@@ -208,18 +225,33 @@ class Request {
|
|
|
208
225
|
let timer = null;
|
|
209
226
|
let isTimeout = false;
|
|
210
227
|
const _timeout = timeout ?? initTimeout;
|
|
228
|
+
const controller = new AbortController();
|
|
229
|
+
let signalCleanup = null;
|
|
230
|
+
if (options.signal) {
|
|
231
|
+
const merged = this.mergeSignals(options.signal, controller.signal);
|
|
232
|
+
options.signal = merged.signal;
|
|
233
|
+
signalCleanup = merged.cleanup;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
options.signal = controller.signal;
|
|
237
|
+
}
|
|
211
238
|
// Cleanup function for timeout
|
|
212
239
|
const cleanup = () => {
|
|
213
240
|
if (timer !== null) {
|
|
214
241
|
clearTimeout(timer);
|
|
215
242
|
timer = null;
|
|
216
243
|
}
|
|
244
|
+
if (signalCleanup) {
|
|
245
|
+
signalCleanup();
|
|
246
|
+
signalCleanup = null;
|
|
247
|
+
}
|
|
217
248
|
};
|
|
218
249
|
if (_timeout) {
|
|
219
250
|
timer = setTimeout(async () => {
|
|
220
251
|
try {
|
|
221
252
|
isTimeout = true;
|
|
222
253
|
cleanup();
|
|
254
|
+
controller.abort();
|
|
223
255
|
let err = this.parseError('timeout');
|
|
224
256
|
// @ts-ignore
|
|
225
257
|
const res = await Promise.resolve(callbacks.timeout(err, options.headers ?? {}));
|
package/es/index.js
CHANGED
|
@@ -1032,6 +1032,23 @@ class Request {
|
|
|
1032
1032
|
data
|
|
1033
1033
|
};
|
|
1034
1034
|
}
|
|
1035
|
+
mergeSignals(...signals) {
|
|
1036
|
+
const controller = new AbortController();
|
|
1037
|
+
const onAbort = () => controller.abort();
|
|
1038
|
+
const cleanups = [];
|
|
1039
|
+
for (const signal of signals) {
|
|
1040
|
+
if (signal.aborted) {
|
|
1041
|
+
controller.abort();
|
|
1042
|
+
break;
|
|
1043
|
+
}
|
|
1044
|
+
signal.addEventListener('abort', onAbort);
|
|
1045
|
+
cleanups.push(() => signal.removeEventListener('abort', onAbort));
|
|
1046
|
+
}
|
|
1047
|
+
return {
|
|
1048
|
+
signal: controller.signal,
|
|
1049
|
+
cleanup: () => cleanups.forEach(fn => fn()),
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1035
1052
|
setting(config) {
|
|
1036
1053
|
if (!config)
|
|
1037
1054
|
return console.warn('[1Money SDK]: setting method required correct parameters!');
|
|
@@ -1132,18 +1149,33 @@ class Request {
|
|
|
1132
1149
|
let timer = null;
|
|
1133
1150
|
let isTimeout = false;
|
|
1134
1151
|
const _timeout = timeout ?? initTimeout;
|
|
1152
|
+
const controller = new AbortController();
|
|
1153
|
+
let signalCleanup = null;
|
|
1154
|
+
if (options.signal) {
|
|
1155
|
+
const merged = this.mergeSignals(options.signal, controller.signal);
|
|
1156
|
+
options.signal = merged.signal;
|
|
1157
|
+
signalCleanup = merged.cleanup;
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1160
|
+
options.signal = controller.signal;
|
|
1161
|
+
}
|
|
1135
1162
|
// Cleanup function for timeout
|
|
1136
1163
|
const cleanup = () => {
|
|
1137
1164
|
if (timer !== null) {
|
|
1138
1165
|
clearTimeout(timer);
|
|
1139
1166
|
timer = null;
|
|
1140
1167
|
}
|
|
1168
|
+
if (signalCleanup) {
|
|
1169
|
+
signalCleanup();
|
|
1170
|
+
signalCleanup = null;
|
|
1171
|
+
}
|
|
1141
1172
|
};
|
|
1142
1173
|
if (_timeout) {
|
|
1143
1174
|
timer = setTimeout(async () => {
|
|
1144
1175
|
try {
|
|
1145
1176
|
isTimeout = true;
|
|
1146
1177
|
cleanup();
|
|
1178
|
+
controller.abort();
|
|
1147
1179
|
let err = this.parseError('timeout');
|
|
1148
1180
|
// @ts-ignore
|
|
1149
1181
|
const res = await Promise.resolve(callbacks.timeout(err, options.headers ?? {}));
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
|
|
5
|
+
export default tseslint.config(
|
|
6
|
+
// Global ignores (replaces .eslintignore)
|
|
7
|
+
{
|
|
8
|
+
ignores: [
|
|
9
|
+
'build/',
|
|
10
|
+
'configs/',
|
|
11
|
+
'es/',
|
|
12
|
+
'lib/',
|
|
13
|
+
'dist/',
|
|
14
|
+
'server/',
|
|
15
|
+
'demo/',
|
|
16
|
+
'node_modules/',
|
|
17
|
+
'src/**/__test__/',
|
|
18
|
+
'src/.umi',
|
|
19
|
+
'*.config.js',
|
|
20
|
+
'*.config.mjs',
|
|
21
|
+
'*.conf.js',
|
|
22
|
+
'mocha.tsx.js',
|
|
23
|
+
'commitlint.config.js',
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
// Base configs
|
|
28
|
+
js.configs.recommended,
|
|
29
|
+
...tseslint.configs.recommended,
|
|
30
|
+
|
|
31
|
+
// Main source config
|
|
32
|
+
{
|
|
33
|
+
files: ['src/**/*.{ts,tsx}'],
|
|
34
|
+
languageOptions: {
|
|
35
|
+
ecmaVersion: 2020,
|
|
36
|
+
sourceType: 'module',
|
|
37
|
+
globals: {
|
|
38
|
+
Atomics: 'readonly',
|
|
39
|
+
SharedArrayBuffer: 'readonly',
|
|
40
|
+
},
|
|
41
|
+
parserOptions: {
|
|
42
|
+
project: './tsconfig.json',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
rules: {
|
|
46
|
+
// TypeScript
|
|
47
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
48
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
49
|
+
'@typescript-eslint/restrict-plus-operands': 'warn',
|
|
50
|
+
'@typescript-eslint/array-type': 'off',
|
|
51
|
+
'@typescript-eslint/no-use-before-define': 'off',
|
|
52
|
+
'@typescript-eslint/consistent-type-assertions': 'warn',
|
|
53
|
+
'@typescript-eslint/no-inferrable-types': 'warn',
|
|
54
|
+
'@typescript-eslint/explicit-member-accessibility': 'warn',
|
|
55
|
+
|
|
56
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
57
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
58
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
59
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
60
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
|
|
61
|
+
|
|
62
|
+
// Core ESLint
|
|
63
|
+
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
|
|
64
|
+
'prefer-spread': 'warn',
|
|
65
|
+
'no-unused-vars': 'off',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Integration tests override
|
|
70
|
+
{
|
|
71
|
+
files: ['src/__integration__/**/*.ts'],
|
|
72
|
+
rules: {
|
|
73
|
+
'no-console': 'off',
|
|
74
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Prettier (must be last — disables conflicting rules + adds prettier plugin)
|
|
79
|
+
eslintPluginPrettierRecommended,
|
|
80
|
+
|
|
81
|
+
// Custom prettier options
|
|
82
|
+
{
|
|
83
|
+
files: ['src/**/*.{ts,tsx}'],
|
|
84
|
+
rules: {
|
|
85
|
+
'prettier/prettier': [
|
|
86
|
+
'warn',
|
|
87
|
+
{
|
|
88
|
+
printWidth: 50,
|
|
89
|
+
tabWidth: 2,
|
|
90
|
+
singleQuote: true,
|
|
91
|
+
jsxSingleQuote: true,
|
|
92
|
+
semi: true,
|
|
93
|
+
trailingComma: 'none',
|
|
94
|
+
endOfLine: 'auto',
|
|
95
|
+
arrowParens: 'avoid',
|
|
96
|
+
rangeEnd: 0,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
);
|
package/lib/api/index.js
CHANGED
|
@@ -184,6 +184,33 @@ var Request = /** @class */ (function () {
|
|
|
184
184
|
data: data
|
|
185
185
|
};
|
|
186
186
|
};
|
|
187
|
+
Request.prototype.mergeSignals = function () {
|
|
188
|
+
var signals = [];
|
|
189
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
190
|
+
signals[_i] = arguments[_i];
|
|
191
|
+
}
|
|
192
|
+
var controller = new AbortController();
|
|
193
|
+
var onAbort = function () { return controller.abort(); };
|
|
194
|
+
var cleanups = [];
|
|
195
|
+
var _loop_2 = function (signal) {
|
|
196
|
+
if (signal.aborted) {
|
|
197
|
+
controller.abort();
|
|
198
|
+
return "break";
|
|
199
|
+
}
|
|
200
|
+
signal.addEventListener('abort', onAbort);
|
|
201
|
+
cleanups.push(function () { return signal.removeEventListener('abort', onAbort); });
|
|
202
|
+
};
|
|
203
|
+
for (var _a = 0, signals_1 = signals; _a < signals_1.length; _a++) {
|
|
204
|
+
var signal = signals_1[_a];
|
|
205
|
+
var state_1 = _loop_2(signal);
|
|
206
|
+
if (state_1 === "break")
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
signal: controller.signal,
|
|
211
|
+
cleanup: function () { return cleanups.forEach(function (fn) { return fn(); }); },
|
|
212
|
+
};
|
|
213
|
+
};
|
|
187
214
|
Request.prototype.setting = function (config) {
|
|
188
215
|
if (!config)
|
|
189
216
|
return console.warn('[1Money SDK]: setting method required correct parameters!');
|
|
@@ -272,12 +299,26 @@ var Request = /** @class */ (function () {
|
|
|
272
299
|
var timer = null;
|
|
273
300
|
var isTimeout = false;
|
|
274
301
|
var _timeout = timeout !== null && timeout !== void 0 ? timeout : initTimeout;
|
|
302
|
+
var controller = new AbortController();
|
|
303
|
+
var signalCleanup = null;
|
|
304
|
+
if (options.signal) {
|
|
305
|
+
var merged = _this.mergeSignals(options.signal, controller.signal);
|
|
306
|
+
options.signal = merged.signal;
|
|
307
|
+
signalCleanup = merged.cleanup;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
options.signal = controller.signal;
|
|
311
|
+
}
|
|
275
312
|
// Cleanup function for timeout
|
|
276
313
|
var cleanup = function () {
|
|
277
314
|
if (timer !== null) {
|
|
278
315
|
clearTimeout(timer);
|
|
279
316
|
timer = null;
|
|
280
317
|
}
|
|
318
|
+
if (signalCleanup) {
|
|
319
|
+
signalCleanup();
|
|
320
|
+
signalCleanup = null;
|
|
321
|
+
}
|
|
281
322
|
};
|
|
282
323
|
if (_timeout) {
|
|
283
324
|
timer = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -289,6 +330,7 @@ var Request = /** @class */ (function () {
|
|
|
289
330
|
_c.trys.push([0, 2, , 3]);
|
|
290
331
|
isTimeout = true;
|
|
291
332
|
cleanup();
|
|
333
|
+
controller.abort();
|
|
292
334
|
err = this.parseError('timeout');
|
|
293
335
|
return [4 /*yield*/, Promise.resolve(callbacks.timeout(err, (_a = options.headers) !== null && _a !== void 0 ? _a : {}))];
|
|
294
336
|
case 1:
|
package/lib/client/core.d.ts
CHANGED
|
@@ -87,22 +87,20 @@ export type ErrorRes = {
|
|
|
87
87
|
};
|
|
88
88
|
export type RestScopeName = ChainName['all'];
|
|
89
89
|
export type RestScope = Readonly<[RestScopeName, RestScopeName?, RestScopeName?, RestScopeName?, RestScopeName?]>;
|
|
90
|
-
type Tuple2Record<T extends readonly any[]> = {
|
|
91
|
-
[Value in T[number]]: Value;
|
|
92
|
-
};
|
|
93
90
|
export interface PromiseWrapper<T, U, TSuc = ChainReturn<T, U>['success'], TFail = ChainReturn<T, U>['failure'], TErr = ChainReturn<T, U>['error'], TLogin = ChainReturn<T, U>['login'], TTime = ChainReturn<T, U>['timeout'], HadCall extends string = ''> {
|
|
94
91
|
success<TRes = TSuc, Delete extends string = HadCall | 'success'>(onSuccess?: (res: ChainReturn<T, U>['success'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TRes, TFail, TErr, TLogin, TTime, Delete>, ChainName['withoutS'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TRes | TFail | TErr | TLogin | TTime>;
|
|
95
92
|
failure<TRes = TFail, Delete extends string = HadCall | 'failure'>(onFailure?: (res: ChainReturn<T, U>['failure'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TRes, TErr, TLogin, TTime, Delete>, ChainName['withoutF'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TRes | TErr | TLogin | TTime>;
|
|
96
93
|
error<TRes = TErr, Delete extends string = HadCall | 'error'>(onError?: (err: ChainReturn<T, U>['error'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TRes, TLogin, TTime, Delete>, ChainName['withoutE'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TRes | TLogin | TTime>;
|
|
97
94
|
login<TRes = TLogin, Delete extends string = HadCall | 'login'>(onLogin?: (res: ChainReturn<T, U>['login'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TRes, TTime, Delete>, ChainName['withoutL'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TRes | TTime>;
|
|
98
95
|
timeout<TRes = TTime, Delete extends string = HadCall | 'timeout'>(onTimeout?: (err: ChainReturn<T, U>['timeout'], headers: AxiosReqHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TRes, Delete>, ChainName['withoutT'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TLogin | TRes>;
|
|
99
|
-
rest<TRes = TSuc | TFail | TErr | TLogin | TTime,
|
|
96
|
+
rest<TRes = TSuc | TFail | TErr | TLogin | TTime, S1 extends Exclude<RestScopeName, HadCall> = Exclude<RestScopeName, HadCall>, S2 extends Exclude<RestScopeName, HadCall | S1> | undefined = undefined, S3 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string>> | undefined = undefined, S4 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string> | Extract<S3, string>> | undefined = undefined, S5 extends Exclude<RestScopeName, HadCall | S1 | Extract<S2, string> | Extract<S3, string> | Extract<S4, string>> | undefined = undefined, TRestScopeName extends RestScopeName = Extract<S1 | S2 | S3 | S4 | S5, RestScopeName>, THadCallWithNotInScope extends string = HadCall | Exclude<RestScopeName, TRestScopeName>, Delete extends string = HadCall | TRestScopeName | 'rest'>(onRest?: (val: ChainName['all'] extends THadCallWithNotInScope ? unknown : ChainName['withoutS'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success'] : ChainName['withoutF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure'] : ChainName['withoutE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error'] : ChainName['withoutL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login'] : ChainName['withoutT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['timeout'] : ChainName['withoutSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure'] : ChainName['withoutSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error'] : ChainName['withoutSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login'] : ChainName['withoutST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'timeout'] : ChainName['withoutFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error'] : ChainName['withoutFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login'] : ChainName['withoutFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'timeout'] : ChainName['withoutEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login'] : ChainName['withoutET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'timeout'] : ChainName['withoutLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login' | 'timeout'] : ChainName['withSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login' | 'timeout'] : ChainName['withSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login' | 'timeout'] : ChainName['withSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'timeout'] : ChainName['withST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login'] : ChainName['withFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login' | 'timeout'] : ChainName['withFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'timeout'] : ChainName['withFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login'] : ChainName['withEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'timeout'] : ChainName['withET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login'] : ChainName['withLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error'] : ChainName['success'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login' | 'timeout'] : ChainName['failure'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login' | 'timeout'] : ChainName['error'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login' | 'timeout'] : ChainName['login'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'timeout'] : ChainName['timeout'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'login'] : ChainReturn<T, U>['all'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes, scope?: Readonly<[S1, S2?, S3?, S4?, S5?]>): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TTime, Delete>, Delete> & Promise<ChainName['all'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TTime : ChainName['withoutS'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin | TTime : ChainName['withoutF'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin | TTime : ChainName['withoutE'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin | TTime : ChainName['withoutL'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes | TTime : ChainName['withoutT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TRes : ChainName['withoutSF'] extends THadCallWithNotInScope ? TRes | TErr | TLogin | TTime : ChainName['withoutSE'] extends THadCallWithNotInScope ? TRes | TFail | TLogin | TTime : ChainName['withoutSL'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TTime : ChainName['withoutST'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin : ChainName['withoutFE'] extends THadCallWithNotInScope ? TSuc | TRes | TLogin | TTime : ChainName['withoutFL'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TTime : ChainName['withoutFT'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin : ChainName['withoutEL'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TTime : ChainName['withoutET'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin : ChainName['withoutLT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes : ChainName['withSF'] extends THadCallWithNotInScope ? TSuc | TFail | TRes : ChainName['withSE'] extends THadCallWithNotInScope ? TSuc | TErr | TRes : ChainName['withSL'] extends THadCallWithNotInScope ? TSuc | TLogin | TRes : ChainName['withST'] extends THadCallWithNotInScope ? TSuc | TTime | TRes : ChainName['withFE'] extends THadCallWithNotInScope ? TFail | TErr | TRes : ChainName['withFL'] extends THadCallWithNotInScope ? TFail | TLogin | TRes : ChainName['withFT'] extends THadCallWithNotInScope ? TFail | TTime | TRes : ChainName['withEL'] extends THadCallWithNotInScope ? TErr | TLogin | TRes : ChainName['withET'] extends THadCallWithNotInScope ? TErr | TTime | TRes : ChainName['withLT'] extends THadCallWithNotInScope ? TLogin | TTime | TRes : ChainName['success'] extends THadCallWithNotInScope ? TSuc | TRes : ChainName['failure'] extends THadCallWithNotInScope ? TFail | TRes : ChainName['error'] extends THadCallWithNotInScope ? TErr | TRes : ChainName['login'] extends THadCallWithNotInScope ? TLogin | TRes : ChainName['timeout'] extends THadCallWithNotInScope ? TTime | TRes : TRes>;
|
|
100
97
|
}
|
|
101
98
|
export declare class Request {
|
|
102
99
|
private _config;
|
|
103
100
|
axios: AxiosStatic;
|
|
104
101
|
constructor(config?: InitConfig);
|
|
105
102
|
private parseError;
|
|
103
|
+
private mergeSignals;
|
|
106
104
|
setting(config: InitConfig): void;
|
|
107
105
|
request<T, U = unknown>(options: Options<T, U>): PromiseWrapper<T, U> & Promise<CustomResponseData<T, U, WithFailureData<T>>>;
|
|
108
106
|
}
|
package/lib/client/index.js
CHANGED
|
@@ -184,6 +184,33 @@ var Request = /** @class */ (function () {
|
|
|
184
184
|
data: data
|
|
185
185
|
};
|
|
186
186
|
};
|
|
187
|
+
Request.prototype.mergeSignals = function () {
|
|
188
|
+
var signals = [];
|
|
189
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
190
|
+
signals[_i] = arguments[_i];
|
|
191
|
+
}
|
|
192
|
+
var controller = new AbortController();
|
|
193
|
+
var onAbort = function () { return controller.abort(); };
|
|
194
|
+
var cleanups = [];
|
|
195
|
+
var _loop_2 = function (signal) {
|
|
196
|
+
if (signal.aborted) {
|
|
197
|
+
controller.abort();
|
|
198
|
+
return "break";
|
|
199
|
+
}
|
|
200
|
+
signal.addEventListener('abort', onAbort);
|
|
201
|
+
cleanups.push(function () { return signal.removeEventListener('abort', onAbort); });
|
|
202
|
+
};
|
|
203
|
+
for (var _a = 0, signals_1 = signals; _a < signals_1.length; _a++) {
|
|
204
|
+
var signal = signals_1[_a];
|
|
205
|
+
var state_1 = _loop_2(signal);
|
|
206
|
+
if (state_1 === "break")
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
signal: controller.signal,
|
|
211
|
+
cleanup: function () { return cleanups.forEach(function (fn) { return fn(); }); },
|
|
212
|
+
};
|
|
213
|
+
};
|
|
187
214
|
Request.prototype.setting = function (config) {
|
|
188
215
|
if (!config)
|
|
189
216
|
return console.warn('[1Money SDK]: setting method required correct parameters!');
|
|
@@ -272,12 +299,26 @@ var Request = /** @class */ (function () {
|
|
|
272
299
|
var timer = null;
|
|
273
300
|
var isTimeout = false;
|
|
274
301
|
var _timeout = timeout !== null && timeout !== void 0 ? timeout : initTimeout;
|
|
302
|
+
var controller = new AbortController();
|
|
303
|
+
var signalCleanup = null;
|
|
304
|
+
if (options.signal) {
|
|
305
|
+
var merged = _this.mergeSignals(options.signal, controller.signal);
|
|
306
|
+
options.signal = merged.signal;
|
|
307
|
+
signalCleanup = merged.cleanup;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
options.signal = controller.signal;
|
|
311
|
+
}
|
|
275
312
|
// Cleanup function for timeout
|
|
276
313
|
var cleanup = function () {
|
|
277
314
|
if (timer !== null) {
|
|
278
315
|
clearTimeout(timer);
|
|
279
316
|
timer = null;
|
|
280
317
|
}
|
|
318
|
+
if (signalCleanup) {
|
|
319
|
+
signalCleanup();
|
|
320
|
+
signalCleanup = null;
|
|
321
|
+
}
|
|
281
322
|
};
|
|
282
323
|
if (_timeout) {
|
|
283
324
|
timer = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -289,6 +330,7 @@ var Request = /** @class */ (function () {
|
|
|
289
330
|
_c.trys.push([0, 2, , 3]);
|
|
290
331
|
isTimeout = true;
|
|
291
332
|
cleanup();
|
|
333
|
+
controller.abort();
|
|
292
334
|
err = this.parseError('timeout');
|
|
293
335
|
return [4 /*yield*/, Promise.resolve(callbacks.timeout(err, (_a = options.headers) !== null && _a !== void 0 ? _a : {}))];
|
|
294
336
|
case 1:
|
package/lib/index.js
CHANGED
|
@@ -1146,6 +1146,33 @@ var Request = /** @class */ (function () {
|
|
|
1146
1146
|
data: data
|
|
1147
1147
|
};
|
|
1148
1148
|
};
|
|
1149
|
+
Request.prototype.mergeSignals = function () {
|
|
1150
|
+
var signals = [];
|
|
1151
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1152
|
+
signals[_i] = arguments[_i];
|
|
1153
|
+
}
|
|
1154
|
+
var controller = new AbortController();
|
|
1155
|
+
var onAbort = function () { return controller.abort(); };
|
|
1156
|
+
var cleanups = [];
|
|
1157
|
+
var _loop_2 = function (signal) {
|
|
1158
|
+
if (signal.aborted) {
|
|
1159
|
+
controller.abort();
|
|
1160
|
+
return "break";
|
|
1161
|
+
}
|
|
1162
|
+
signal.addEventListener('abort', onAbort);
|
|
1163
|
+
cleanups.push(function () { return signal.removeEventListener('abort', onAbort); });
|
|
1164
|
+
};
|
|
1165
|
+
for (var _a = 0, signals_1 = signals; _a < signals_1.length; _a++) {
|
|
1166
|
+
var signal = signals_1[_a];
|
|
1167
|
+
var state_1 = _loop_2(signal);
|
|
1168
|
+
if (state_1 === "break")
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
return {
|
|
1172
|
+
signal: controller.signal,
|
|
1173
|
+
cleanup: function () { return cleanups.forEach(function (fn) { return fn(); }); },
|
|
1174
|
+
};
|
|
1175
|
+
};
|
|
1149
1176
|
Request.prototype.setting = function (config) {
|
|
1150
1177
|
if (!config)
|
|
1151
1178
|
return console.warn('[1Money SDK]: setting method required correct parameters!');
|
|
@@ -1234,12 +1261,26 @@ var Request = /** @class */ (function () {
|
|
|
1234
1261
|
var timer = null;
|
|
1235
1262
|
var isTimeout = false;
|
|
1236
1263
|
var _timeout = timeout !== null && timeout !== void 0 ? timeout : initTimeout;
|
|
1264
|
+
var controller = new AbortController();
|
|
1265
|
+
var signalCleanup = null;
|
|
1266
|
+
if (options.signal) {
|
|
1267
|
+
var merged = _this.mergeSignals(options.signal, controller.signal);
|
|
1268
|
+
options.signal = merged.signal;
|
|
1269
|
+
signalCleanup = merged.cleanup;
|
|
1270
|
+
}
|
|
1271
|
+
else {
|
|
1272
|
+
options.signal = controller.signal;
|
|
1273
|
+
}
|
|
1237
1274
|
// Cleanup function for timeout
|
|
1238
1275
|
var cleanup = function () {
|
|
1239
1276
|
if (timer !== null) {
|
|
1240
1277
|
clearTimeout(timer);
|
|
1241
1278
|
timer = null;
|
|
1242
1279
|
}
|
|
1280
|
+
if (signalCleanup) {
|
|
1281
|
+
signalCleanup();
|
|
1282
|
+
signalCleanup = null;
|
|
1283
|
+
}
|
|
1243
1284
|
};
|
|
1244
1285
|
if (_timeout) {
|
|
1245
1286
|
timer = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -1251,6 +1292,7 @@ var Request = /** @class */ (function () {
|
|
|
1251
1292
|
_c.trys.push([0, 2, , 3]);
|
|
1252
1293
|
isTimeout = true;
|
|
1253
1294
|
cleanup();
|
|
1295
|
+
controller.abort();
|
|
1254
1296
|
err = this.parseError('timeout');
|
|
1255
1297
|
return [4 /*yield*/, Promise.resolve(callbacks.timeout(err, (_a = options.headers) !== null && _a !== void 0 ? _a : {}))];
|
|
1256
1298
|
case 1:
|