@aloma.io/integration-sdk 3.6.2 → 3.6.3

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.
@@ -32,9 +32,12 @@ const unwrap = async (ret, options) => {
32
32
  if (options?.text)
33
33
  return unwrap0(ret, await ret.text(), options);
34
34
  if (options?.base64) {
35
- const base64 = Buffer.from(await ret.arrayBuffer()).toString('base64');
35
+ const base64 = Buffer.from(await ret.arrayBuffer()).toString("base64");
36
36
  return unwrap0(ret, base64, options);
37
37
  }
38
+ if (options?.skipResponseBody) {
39
+ return { status: ret.status, headers: ret.headers };
40
+ }
38
41
  const text = await ret.text();
39
42
  try {
40
43
  return unwrap0(ret, JSON.parse(text), options);
@@ -72,13 +75,17 @@ class Fetcher {
72
75
  var local = this, baseUrl = local.baseUrl;
73
76
  if (retries == null)
74
77
  retries = local.retry;
75
- let theURL = !baseUrl ? url : `${baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"}${url}`.replace(/\/\/+/gi, "/");
78
+ let theURL = !baseUrl
79
+ ? url
80
+ : `${baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"}${url}`.replace(/\/\/+/gi, "/");
76
81
  try {
77
82
  options.url = url;
78
83
  await local.customize(options, args);
79
84
  url = options.url;
80
85
  delete options.url;
81
- theURL = !baseUrl ? url : `${baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"}${url}`.replace(/\/\/+/gi, "/");
86
+ theURL = !baseUrl
87
+ ? url
88
+ : `${baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"}${url}`.replace(/\/\/+/gi, "/");
82
89
  if (!options?.headers || !options?.headers?.Accept) {
83
90
  options.headers = {
84
91
  ...options.headers,
@@ -97,6 +104,7 @@ class Fetcher {
97
104
  options?.headers?.["Content-type"] === "application/json") {
98
105
  options.body = JSON.stringify(options.body);
99
106
  }
107
+ const timeout = Math.min(options?.timeout || 30 * 60 * 1000, 30 * 60 * 1000);
100
108
  const ret = await fetch(theURL, {
101
109
  ...options,
102
110
  signal: AbortSignal.timeout(30 * 60 * 1000),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -38,12 +38,15 @@ const unwrap0 = (ret, body, options) => {
38
38
 
39
39
  const unwrap = async (ret, options) => {
40
40
  if (options?.text) return unwrap0(ret, await ret.text(), options);
41
- if (options?.base64)
42
- {
43
- const base64 = Buffer.from(await ret.arrayBuffer()).toString('base64');
41
+ if (options?.base64) {
42
+ const base64 = Buffer.from(await ret.arrayBuffer()).toString("base64");
44
43
 
45
44
  return unwrap0(ret, base64, options);
46
45
  }
46
+
47
+ if (options?.skipResponseBody) {
48
+ return { status: ret.status, headers: ret.headers};
49
+ }
47
50
 
48
51
  const text = await ret.text();
49
52
 
@@ -89,9 +92,12 @@ class Fetcher {
89
92
 
90
93
  if (retries == null) retries = local.retry;
91
94
 
92
- let theURL = !baseUrl?url:`${
93
- baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"
94
- }${url}`.replace(/\/\/+/gi, "/");
95
+ let theURL = !baseUrl
96
+ ? url
97
+ : `${baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"}${url}`.replace(
98
+ /\/\/+/gi,
99
+ "/",
100
+ );
95
101
 
96
102
  try {
97
103
  options.url = url;
@@ -100,9 +106,12 @@ class Fetcher {
100
106
  url = options.url;
101
107
  delete options.url;
102
108
 
103
- theURL = !baseUrl?url:`${
104
- baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"
105
- }${url}`.replace(/\/\/+/gi, "/");
109
+ theURL = !baseUrl
110
+ ? url
111
+ : `${baseUrl?.endsWith("/") ? baseUrl : baseUrl + "/"}${url}`.replace(
112
+ /\/\/+/gi,
113
+ "/",
114
+ );
106
115
 
107
116
  if (!options?.headers || !options?.headers?.Accept) {
108
117
  options.headers = {
@@ -127,6 +136,7 @@ class Fetcher {
127
136
  options.body = JSON.stringify(options.body);
128
137
  }
129
138
 
139
+ const timeout = Math.min(options?.timeout || 30 * 60 * 1000, 30 * 60 * 1000);
130
140
  const ret = await fetch(theURL, {
131
141
  ...options,
132
142
  signal: AbortSignal.timeout(30 * 60 * 1000),
@@ -19,7 +19,7 @@
19
19
  "typescript": "^5"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/node": "^18",
22
+ "@types/node": "^20",
23
23
  "mocha": "^10",
24
24
  "prettier": "^3"
25
25
  }