google-ads-api 9.0.0 → 10.0.2

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/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  </p>
8
8
  <p align="center">
9
9
  <a href="https://developers.google.com/google-ads/api/docs/release-notes">
10
- <img src="https://img.shields.io/badge/google%20ads-v9.1.0-009688.svg?style=flat-square">
10
+ <img src="https://img.shields.io/badge/google%20ads-v10.0.0-009688.svg?style=flat-square">
11
11
  </a>
12
12
  <a href="https://www.npmjs.com/package/google-ads-api">
13
13
  <img src="https://img.shields.io/npm/v/google-ads-api.svg?style=flat-square">
@@ -15,14 +15,11 @@
15
15
  <a>
16
16
  <img src="https://img.shields.io/npm/dm/google-ads-api.svg?style=flat-square">
17
17
  </a>
18
- <a>
19
- <img src="https://img.shields.io/david/opteo/google-ads-api.svg?style=flat-square">
20
- </a>
21
18
  </p>
22
19
 
23
20
  <p align="center">
24
21
  <a href="https://opteo.com">
25
- <img src="https://app.opteo.com/icons/logo.svg">
22
+ <img src="https://app.opteo.com/img/opteo-icon-120.png">
26
23
  </a>
27
24
  </p>
28
25
 
@@ -102,7 +99,7 @@ const customer = client.Customer({
102
99
 
103
100
  ## List accessible customers
104
101
 
105
- This is a special client method for listing the accessible customers for a given refresh token, and is equivalent to [CustomerService.listAccessibleCustomers](https://developers.google.com/google-ads/api/reference/rpc/v9/CustomerService#listaccessiblecustomers). It returns the resource names of available customer accounts.
102
+ This is a special client method for listing the accessible customers for a given refresh token, and is equivalent to [CustomerService.listAccessibleCustomers](https://developers.google.com/google-ads/api/reference/rpc/v10/CustomerService#listaccessiblecustomers). It returns the resource names of available customer accounts.
106
103
 
107
104
  ```ts
108
105
  const client = new GoogleAdsApi({
@@ -566,9 +563,9 @@ const customer = client.Customer({
566
563
 
567
564
  ## Error handling
568
565
 
569
- All errors, apart from GRPC specific cases (such as a connection problem or timeout, [see more here](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md)), are instances of a [GoogleAdsFailure](https://developers.google.com/google-ads/api/reference/rpc/v9/GoogleAdsFailure).
566
+ All errors, apart from GRPC specific cases (such as a connection problem or timeout, [see more here](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md)), are instances of a [GoogleAdsFailure](https://developers.google.com/google-ads/api/reference/rpc/v10/GoogleAdsFailure).
570
567
 
571
- You can find a list of all error types for a specific version in [the official documentation](https://developers.google.com/google-ads/api/reference/rpc/v9/AccessInvitationErrorEnum.AccessInvitationError), as well as more information about [handling errors here](https://developers.google.com/google-ads/api/docs/best-practices/error-types).
568
+ You can find a list of all error types for a specific version in [the official documentation](https://developers.google.com/google-ads/api/reference/rpc/v10/AccessInvitationErrorEnum.AccessInvitationError), as well as more information about [handling errors here](https://developers.google.com/google-ads/api/docs/best-practices/error-types).
572
569
 
573
570
  ```ts
574
571
  import { errors } from "google-ads-api";
@@ -37,12 +37,17 @@ function parse(_a) {
37
37
  var queryFields = reportOptions
38
38
  ? getReportOptionFields(reportOptions)
39
39
  : getGAQLFields(gaqlString);
40
- var allFields = __spreadArrays(queryFields, protos_1.fields.resourceNames);
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 no in this format should have thrown an error when called.
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 f = 0; f < fields.length; f++) {
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 = split[0], children = split.slice(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;