google-ads-api 10.0.0 → 10.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/build/src/parser.js +15 -6
- package/package.json +3 -3
package/build/src/parser.js
CHANGED
|
@@ -37,12 +37,17 @@ function parse(_a) {
|
|
|
37
37
|
var queryFields = reportOptions
|
|
38
38
|
? getReportOptionFields(reportOptions)
|
|
39
39
|
: getGAQLFields(gaqlString);
|
|
40
|
-
|
|
40
|
+
// Add in all relevant resource_name fields, which are always returned by API
|
|
41
|
+
var entities = queryFields.map(function (field) { return field.split(".")[0]; });
|
|
42
|
+
var resourceNameFields = protos_1.fields.resourceNames.filter(function (resourceNameField) {
|
|
43
|
+
return entities.includes(resourceNameField.split(".")[0]);
|
|
44
|
+
});
|
|
45
|
+
var allFields = __spreadArrays(queryFields, resourceNameFields);
|
|
41
46
|
return parseRows(results, allFields);
|
|
42
47
|
}
|
|
43
48
|
exports.parse = parse;
|
|
44
49
|
// This function assumes that a gaql query is of the format "select * * * from * ...".
|
|
45
|
-
// Queries that are
|
|
50
|
+
// Queries that are not in this format should have thrown an error when called.
|
|
46
51
|
function getGAQLFields(gaqlString) {
|
|
47
52
|
var normalisedQuery = utils_1.normaliseQuery(gaqlString);
|
|
48
53
|
var fields = normalisedQuery
|
|
@@ -65,15 +70,19 @@ function getReportOptionFields(reportOptions) {
|
|
|
65
70
|
}
|
|
66
71
|
exports.getReportOptionFields = getReportOptionFields;
|
|
67
72
|
function parseRows(rows, fields) {
|
|
73
|
+
var fieldsPreSplit = {};
|
|
74
|
+
// pre-split all the field strings for performance reasons (increases speed by ~5x for large number of rows)
|
|
75
|
+
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
76
|
+
var field = fields_1[_i];
|
|
77
|
+
fieldsPreSplit[field] = field.split(".");
|
|
78
|
+
}
|
|
68
79
|
var newRows = [];
|
|
69
80
|
for (var r = 0; r < rows.length; r++) {
|
|
70
81
|
var newRow = {};
|
|
71
82
|
var originalRow = protos_1.services.GoogleAdsRow.fromObject(rows[r]);
|
|
72
|
-
for (var
|
|
73
|
-
var field = fields[f];
|
|
74
|
-
var split = field.split(".");
|
|
83
|
+
for (var split in fieldsPreSplit) {
|
|
75
84
|
// @ts-expect-error These are the best we can do for these types
|
|
76
|
-
var parent_1 =
|
|
85
|
+
var _a = fieldsPreSplit[split], parent_1 = _a[0], children = _a.slice(1);
|
|
77
86
|
// Ignore null fields (unspecified resource names)
|
|
78
87
|
if (!originalRow[parent_1]) {
|
|
79
88
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "google-ads-api",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"description": "Google Ads API Client Library for Node.js",
|
|
5
5
|
"repository": "https://github.com/Opteo/google-ads-api",
|
|
6
6
|
"main": "build/src/index.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"author": "Opteo",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"google-ads-node": "^8.0.
|
|
20
|
+
"google-ads-node": "^8.0.1",
|
|
21
21
|
"google-auth-library": "^7.1.0",
|
|
22
|
-
"google-gax": "^2.
|
|
22
|
+
"google-gax": "^2.30.1",
|
|
23
23
|
"long": "^4.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|