google-ads-api 23.0.1 → 24.1.0
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/client.js +5 -1
- package/build/src/customer.js +20 -13
- package/build/src/parser.js +22 -5
- package/build/src/protos/autogen/enums.d.ts +579 -372
- package/build/src/protos/autogen/enums.js +584 -361
- package/build/src/protos/autogen/fields.d.ts +223 -192
- package/build/src/protos/autogen/fields.js +25 -3
- package/build/src/protos/autogen/resourceNames.d.ts +33 -0
- package/build/src/protos/autogen/resourceNames.js +41 -0
- package/build/src/protos/autogen/serviceFactory.d.ts +219 -189
- package/build/src/protos/autogen/serviceFactory.js +520 -189
- package/build/src/protos/index.d.ts +6 -6
- package/build/src/protos/index.js +5 -5
- package/build/src/service.d.ts +11 -2
- package/build/src/service.js +20 -10
- package/build/src/utils.d.ts +1 -1
- package/build/src/utils.js +18 -3
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/package.json +4 -4
package/build/src/client.js
CHANGED
|
@@ -18,7 +18,7 @@ class Client {
|
|
|
18
18
|
refresh_token: refreshToken,
|
|
19
19
|
});
|
|
20
20
|
// @ts-expect-error Protected usage is fine here
|
|
21
|
-
const customerService =
|
|
21
|
+
const customerService = service.loadService("CustomerServiceClient", { skipCache: true });
|
|
22
22
|
try {
|
|
23
23
|
// @ts-expect-error Type definition is incorrect, response is an array
|
|
24
24
|
const [response] = await customerService.listAccessibleCustomers({}, {
|
|
@@ -35,6 +35,10 @@ class Client {
|
|
|
35
35
|
// @ts-expect-error Protected usage is fine here
|
|
36
36
|
throw service.getGoogleAdsError(err);
|
|
37
37
|
}
|
|
38
|
+
finally {
|
|
39
|
+
// @ts-expect-error close() exists on the gax client but not on the proto type
|
|
40
|
+
await customerService.close().catch(() => null);
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
exports.Client = Client;
|
package/build/src/customer.js
CHANGED
|
@@ -337,21 +337,28 @@ class Customer extends serviceFactory_1.default {
|
|
|
337
337
|
});
|
|
338
338
|
const pipeline = (0, stream_chain_1.chain)([stream, parser, (0, StreamArray_1.streamArray)()]);
|
|
339
339
|
let count = 0;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
340
|
+
try {
|
|
341
|
+
for await (const data of pipeline) {
|
|
342
|
+
const results = data.value.results ??
|
|
343
|
+
(data.value.summaryRow ? [data.value.summaryRow] : undefined) ??
|
|
344
|
+
[];
|
|
345
|
+
count += results.length;
|
|
346
|
+
if (this.clientOptions.max_reporting_rows &&
|
|
347
|
+
count > this.clientOptions.max_reporting_rows &&
|
|
348
|
+
!this.gaqlQueryStringIncludesLimit(gaqlQuery)) {
|
|
349
|
+
throw this.generateTooManyRowsError();
|
|
350
|
+
}
|
|
351
|
+
for (const row of results) {
|
|
352
|
+
const parsed = this.decamelizeKeysIfNeeded(row);
|
|
353
|
+
yield parsed;
|
|
354
|
+
}
|
|
353
355
|
}
|
|
354
356
|
}
|
|
357
|
+
finally {
|
|
358
|
+
pipeline.destroy();
|
|
359
|
+
parser.destroy();
|
|
360
|
+
stream.destroy();
|
|
361
|
+
}
|
|
355
362
|
return;
|
|
356
363
|
}
|
|
357
364
|
catch (e) {
|
package/build/src/parser.js
CHANGED
|
@@ -87,6 +87,27 @@ function parseRows(rows, fields) {
|
|
|
87
87
|
}
|
|
88
88
|
return newRows;
|
|
89
89
|
}
|
|
90
|
+
function convertLongsToNumbers(value) {
|
|
91
|
+
const isPrimitive = value === null || typeof value !== "object";
|
|
92
|
+
if (isPrimitive) {
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
if (long_1.default.isLong(value)) {
|
|
96
|
+
return value.toNumber();
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(value)) {
|
|
99
|
+
return value.map(convertLongsToNumbers);
|
|
100
|
+
}
|
|
101
|
+
const isBytesField = ArrayBuffer.isView(value);
|
|
102
|
+
if (isBytesField) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
const converted = {};
|
|
106
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
107
|
+
converted[key] = convertLongsToNumbers(nestedValue);
|
|
108
|
+
}
|
|
109
|
+
return converted;
|
|
110
|
+
}
|
|
90
111
|
function parseNestedValues(row, data, field, paths) {
|
|
91
112
|
if (!data)
|
|
92
113
|
return null;
|
|
@@ -94,11 +115,7 @@ function parseNestedValues(row, data, field, paths) {
|
|
|
94
115
|
if (!row)
|
|
95
116
|
row = {};
|
|
96
117
|
if (childFields.length === 0) {
|
|
97
|
-
|
|
98
|
-
const parsedVal = long_1.default.isLong(rawVal)
|
|
99
|
-
? new long_1.default(rawVal.low, rawVal.high, rawVal.unsigned).toNumber()
|
|
100
|
-
: rawVal;
|
|
101
|
-
row[parentField] = parsedVal;
|
|
118
|
+
row[parentField] = convertLongsToNumbers(data[parentField]);
|
|
102
119
|
return row;
|
|
103
120
|
}
|
|
104
121
|
row[parentField] = parseNestedValues(row[parentField], data[parentField], parentField, childFields);
|