@owox/connectors 0.13.0-next-20251118090139 → 0.13.0-next-20251118110411
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/dist/index.cjs +23 -10
- package/dist/index.js +23 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -973,11 +973,9 @@ async function _resolveShortLinks(shortLinks) {
|
|
|
973
973
|
const response = await HttpUtils.fetch(linkObj.originalUrl, {
|
|
974
974
|
method: "GET"
|
|
975
975
|
});
|
|
976
|
-
const headers = response.getHeaders();
|
|
977
|
-
const resolvedUrl = headers.Location || headers.location || linkObj.originalUrl;
|
|
978
976
|
return {
|
|
979
977
|
originalUrl: linkObj.originalUrl,
|
|
980
|
-
resolvedUrl
|
|
978
|
+
resolvedUrl: response.getUrl()
|
|
981
979
|
};
|
|
982
980
|
} catch (error) {
|
|
983
981
|
console.log(`Failed to resolve short link ${linkObj.originalUrl}: ${error.message}`);
|
|
@@ -1143,17 +1141,21 @@ var HttpUtils = class HttpUtils2 {
|
|
|
1143
1141
|
if (options.body) {
|
|
1144
1142
|
fetchOptions.body = options.body;
|
|
1145
1143
|
}
|
|
1144
|
+
if (options.redirect !== void 0) {
|
|
1145
|
+
fetchOptions.redirect = options.redirect;
|
|
1146
|
+
}
|
|
1146
1147
|
const response = await fetch(url, fetchOptions);
|
|
1147
|
-
return this._wrapNodeResponse(response);
|
|
1148
|
+
return this._wrapNodeResponse(response, url);
|
|
1148
1149
|
}
|
|
1149
1150
|
/**
|
|
1150
1151
|
* Wraps the response from the Node environment.
|
|
1151
1152
|
* Not use directly, only for internal purposes.
|
|
1152
1153
|
*
|
|
1153
1154
|
* @param {Response} response - Native fetch Response object
|
|
1155
|
+
* @param {string} originalUrl - Original URL that was requested
|
|
1154
1156
|
* @returns {FetchResponse}
|
|
1155
1157
|
*/
|
|
1156
|
-
static _wrapNodeResponse(response) {
|
|
1158
|
+
static _wrapNodeResponse(response, originalUrl) {
|
|
1157
1159
|
let textCache = null;
|
|
1158
1160
|
let blobCache = null;
|
|
1159
1161
|
const getText = async () => {
|
|
@@ -1184,7 +1186,8 @@ var HttpUtils = class HttpUtils2 {
|
|
|
1184
1186
|
getContent: () => getText(),
|
|
1185
1187
|
getContentText: () => getText(),
|
|
1186
1188
|
getBlob: () => getBlob(),
|
|
1187
|
-
getResponseCode: () => response.status
|
|
1189
|
+
getResponseCode: () => response.status,
|
|
1190
|
+
getUrl: () => response.url || originalUrl
|
|
1188
1191
|
};
|
|
1189
1192
|
}
|
|
1190
1193
|
};
|
|
@@ -14377,7 +14380,7 @@ const GoogleAds = (function() {
|
|
|
14377
14380
|
isRequired: true,
|
|
14378
14381
|
requiredType: "string",
|
|
14379
14382
|
label: "Customer ID",
|
|
14380
|
-
description: "Google Ads Customer ID (format:
|
|
14383
|
+
description: "Google Ads Customer ID (format: 1234567890)"
|
|
14381
14384
|
},
|
|
14382
14385
|
AuthType: {
|
|
14383
14386
|
requiredType: "object",
|
|
@@ -14621,7 +14624,7 @@ const GoogleAds = (function() {
|
|
|
14621
14624
|
* @returns {Array<Object>} - API response data
|
|
14622
14625
|
*/
|
|
14623
14626
|
async makeRequest({ customerId, query, nodeName, fields }) {
|
|
14624
|
-
var _a, _b, _c, _d;
|
|
14627
|
+
var _a, _b, _c, _d, _e;
|
|
14625
14628
|
const accessToken = await this.getAccessToken();
|
|
14626
14629
|
const url = `https://googleads.googleapis.com/v21/customers/${customerId}/googleAds:search`;
|
|
14627
14630
|
console.log(`Google Ads API Request URL: ${url}`);
|
|
@@ -14636,12 +14639,13 @@ const GoogleAds = (function() {
|
|
|
14636
14639
|
requestBody.pageToken = nextPageToken;
|
|
14637
14640
|
}
|
|
14638
14641
|
const loginCustomerId = (_b = (_a = this.config.AuthType.items) == null ? void 0 : _a.LoginCustomerId) == null ? void 0 : _b.value;
|
|
14642
|
+
const shouldIncludeLoginCustomerIdHeader = loginCustomerId && loginCustomerId !== customerId;
|
|
14639
14643
|
const headers = {
|
|
14640
14644
|
"Authorization": `Bearer ${accessToken}`,
|
|
14641
14645
|
"developer-token": (_d = (_c = this.config.AuthType.items) == null ? void 0 : _c.DeveloperToken) == null ? void 0 : _d.value,
|
|
14642
14646
|
"Content-Type": "application/json"
|
|
14643
14647
|
};
|
|
14644
|
-
if (
|
|
14648
|
+
if (shouldIncludeLoginCustomerIdHeader) {
|
|
14645
14649
|
headers["login-customer-id"] = loginCustomerId;
|
|
14646
14650
|
}
|
|
14647
14651
|
const options = {
|
|
@@ -14651,10 +14655,19 @@ const GoogleAds = (function() {
|
|
|
14651
14655
|
body: JSON.stringify(requestBody),
|
|
14652
14656
|
muteHttpExceptions: true
|
|
14653
14657
|
};
|
|
14654
|
-
|
|
14658
|
+
let response;
|
|
14659
|
+
try {
|
|
14660
|
+
response = await this.urlFetchWithRetry(url, options);
|
|
14661
|
+
} catch (error) {
|
|
14662
|
+
if ((_e = error.payload) == null ? void 0 : _e.error) {
|
|
14663
|
+
this.config.logMessage(`Google Ads API error payload: ${JSON.stringify(error.payload.error, null, 2)}`);
|
|
14664
|
+
}
|
|
14665
|
+
throw error;
|
|
14666
|
+
}
|
|
14655
14667
|
const text = await response.getContentText();
|
|
14656
14668
|
const jsonData = JSON.parse(text);
|
|
14657
14669
|
if (jsonData.error) {
|
|
14670
|
+
this.config.logMessage(`Google Ads API error payload: ${JSON.stringify(jsonData.error, null, 2)}`);
|
|
14658
14671
|
throw new Error(`Google Ads API error: ${jsonData.error.message}`);
|
|
14659
14672
|
}
|
|
14660
14673
|
if (jsonData.results) {
|
package/dist/index.js
CHANGED
|
@@ -978,11 +978,9 @@ var require_index = __commonJS({
|
|
|
978
978
|
const response = await HttpUtils.fetch(linkObj.originalUrl, {
|
|
979
979
|
method: "GET"
|
|
980
980
|
});
|
|
981
|
-
const headers = response.getHeaders();
|
|
982
|
-
const resolvedUrl = headers.Location || headers.location || linkObj.originalUrl;
|
|
983
981
|
return {
|
|
984
982
|
originalUrl: linkObj.originalUrl,
|
|
985
|
-
resolvedUrl
|
|
983
|
+
resolvedUrl: response.getUrl()
|
|
986
984
|
};
|
|
987
985
|
} catch (error) {
|
|
988
986
|
console.log(`Failed to resolve short link ${linkObj.originalUrl}: ${error.message}`);
|
|
@@ -1148,17 +1146,21 @@ var require_index = __commonJS({
|
|
|
1148
1146
|
if (options.body) {
|
|
1149
1147
|
fetchOptions.body = options.body;
|
|
1150
1148
|
}
|
|
1149
|
+
if (options.redirect !== void 0) {
|
|
1150
|
+
fetchOptions.redirect = options.redirect;
|
|
1151
|
+
}
|
|
1151
1152
|
const response = await fetch(url, fetchOptions);
|
|
1152
|
-
return this._wrapNodeResponse(response);
|
|
1153
|
+
return this._wrapNodeResponse(response, url);
|
|
1153
1154
|
}
|
|
1154
1155
|
/**
|
|
1155
1156
|
* Wraps the response from the Node environment.
|
|
1156
1157
|
* Not use directly, only for internal purposes.
|
|
1157
1158
|
*
|
|
1158
1159
|
* @param {Response} response - Native fetch Response object
|
|
1160
|
+
* @param {string} originalUrl - Original URL that was requested
|
|
1159
1161
|
* @returns {FetchResponse}
|
|
1160
1162
|
*/
|
|
1161
|
-
static _wrapNodeResponse(response) {
|
|
1163
|
+
static _wrapNodeResponse(response, originalUrl) {
|
|
1162
1164
|
let textCache = null;
|
|
1163
1165
|
let blobCache = null;
|
|
1164
1166
|
const getText = async () => {
|
|
@@ -1189,7 +1191,8 @@ var require_index = __commonJS({
|
|
|
1189
1191
|
getContent: () => getText(),
|
|
1190
1192
|
getContentText: () => getText(),
|
|
1191
1193
|
getBlob: () => getBlob(),
|
|
1192
|
-
getResponseCode: () => response.status
|
|
1194
|
+
getResponseCode: () => response.status,
|
|
1195
|
+
getUrl: () => response.url || originalUrl
|
|
1193
1196
|
};
|
|
1194
1197
|
}
|
|
1195
1198
|
};
|
|
@@ -14382,7 +14385,7 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
|
|
|
14382
14385
|
isRequired: true,
|
|
14383
14386
|
requiredType: "string",
|
|
14384
14387
|
label: "Customer ID",
|
|
14385
|
-
description: "Google Ads Customer ID (format:
|
|
14388
|
+
description: "Google Ads Customer ID (format: 1234567890)"
|
|
14386
14389
|
},
|
|
14387
14390
|
AuthType: {
|
|
14388
14391
|
requiredType: "object",
|
|
@@ -14626,7 +14629,7 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
|
|
|
14626
14629
|
* @returns {Array<Object>} - API response data
|
|
14627
14630
|
*/
|
|
14628
14631
|
async makeRequest({ customerId, query, nodeName, fields }) {
|
|
14629
|
-
var _a, _b, _c, _d;
|
|
14632
|
+
var _a, _b, _c, _d, _e;
|
|
14630
14633
|
const accessToken = await this.getAccessToken();
|
|
14631
14634
|
const url = `https://googleads.googleapis.com/v21/customers/${customerId}/googleAds:search`;
|
|
14632
14635
|
console.log(`Google Ads API Request URL: ${url}`);
|
|
@@ -14641,12 +14644,13 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
|
|
|
14641
14644
|
requestBody.pageToken = nextPageToken;
|
|
14642
14645
|
}
|
|
14643
14646
|
const loginCustomerId = (_b = (_a = this.config.AuthType.items) == null ? void 0 : _a.LoginCustomerId) == null ? void 0 : _b.value;
|
|
14647
|
+
const shouldIncludeLoginCustomerIdHeader = loginCustomerId && loginCustomerId !== customerId;
|
|
14644
14648
|
const headers = {
|
|
14645
14649
|
"Authorization": `Bearer ${accessToken}`,
|
|
14646
14650
|
"developer-token": (_d = (_c = this.config.AuthType.items) == null ? void 0 : _c.DeveloperToken) == null ? void 0 : _d.value,
|
|
14647
14651
|
"Content-Type": "application/json"
|
|
14648
14652
|
};
|
|
14649
|
-
if (
|
|
14653
|
+
if (shouldIncludeLoginCustomerIdHeader) {
|
|
14650
14654
|
headers["login-customer-id"] = loginCustomerId;
|
|
14651
14655
|
}
|
|
14652
14656
|
const options = {
|
|
@@ -14656,10 +14660,19 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
|
|
|
14656
14660
|
body: JSON.stringify(requestBody),
|
|
14657
14661
|
muteHttpExceptions: true
|
|
14658
14662
|
};
|
|
14659
|
-
|
|
14663
|
+
let response;
|
|
14664
|
+
try {
|
|
14665
|
+
response = await this.urlFetchWithRetry(url, options);
|
|
14666
|
+
} catch (error) {
|
|
14667
|
+
if ((_e = error.payload) == null ? void 0 : _e.error) {
|
|
14668
|
+
this.config.logMessage(`Google Ads API error payload: ${JSON.stringify(error.payload.error, null, 2)}`);
|
|
14669
|
+
}
|
|
14670
|
+
throw error;
|
|
14671
|
+
}
|
|
14660
14672
|
const text = await response.getContentText();
|
|
14661
14673
|
const jsonData = JSON.parse(text);
|
|
14662
14674
|
if (jsonData.error) {
|
|
14675
|
+
this.config.logMessage(`Google Ads API error payload: ${JSON.stringify(jsonData.error, null, 2)}`);
|
|
14663
14676
|
throw new Error(`Google Ads API error: ${jsonData.error.message}`);
|
|
14664
14677
|
}
|
|
14665
14678
|
if (jsonData.results) {
|