google-ads-api 11.0.0 → 12.0.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/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-v11.0.0-009688.svg?style=flat-square">
10
+ <img src="https://img.shields.io/badge/google%20ads-v12.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">
@@ -19,7 +19,7 @@
19
19
 
20
20
  <p align="center">
21
21
  <a href="https://opteo.com">
22
- <img src="https://app.opteo.com/img/opteo-icon-120.png">
22
+ <img src="https://app.opteo.com/favicon.png" width="90" height="90">
23
23
  </a>
24
24
  </p>
25
25
 
@@ -99,7 +99,7 @@ const customer = client.Customer({
99
99
 
100
100
  ## List accessible customers
101
101
 
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/v11/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/v12/CustomerService#listaccessiblecustomers). It returns the resource names of available customer accounts.
103
103
 
104
104
  ```ts
105
105
  const client = new GoogleAdsApi({
@@ -563,11 +563,13 @@ const onQueryStart: OnQueryStart = async ({ cancel, editOptions }) => {
563
563
  }
564
564
  };
565
565
 
566
- const customer = client.Customer({
567
- clientOptions,
568
- customerOptions,
569
- hooks: { onQueryStart },
570
- });
566
+ const customer = client.Customer(
567
+ {
568
+ clientOptions,
569
+ customerOptions,
570
+ },
571
+ { onQueryStart }
572
+ );
571
573
  ```
572
574
 
573
575
  ### On error hooks:
@@ -586,11 +588,13 @@ const onQueryError: OnQueryError = async ({ error }) => {
586
588
  console.log(error.message); // An Error or a GoogleAdsFailure
587
589
  };
588
590
 
589
- const customer = client.Customer({
590
- clientOptions,
591
- customerOptions,
592
- hooks: { onQueryError },
593
- });
591
+ const customer = client.Customer(
592
+ {
593
+ clientOptions,
594
+ customerOptions,
595
+ },
596
+ { onQueryError }
597
+ );
594
598
  ```
595
599
 
596
600
  ### Post-request hooks:
@@ -609,20 +613,22 @@ const onQueryEnd: OnQueryEnd = async ({ response, resolve }) => {
609
613
  resolve([first]); // The supplied argument will become the alternative return value
610
614
  };
611
615
 
612
- const customer = client.Customer({
613
- clientOptions,
614
- customerOptions,
615
- hooks: { onQueryEnd },
616
- });
616
+ const customer = client.Customer(
617
+ {
618
+ clientOptions,
619
+ customerOptions,
620
+ },
621
+ { onQueryEnd }
622
+ );
617
623
  ```
618
624
 
619
625
  ---
620
626
 
621
627
  ## Error handling
622
628
 
623
- 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/v11/GoogleAdsFailure).
629
+ 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/v12/GoogleAdsFailure).
624
630
 
625
- 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/v11/AccessInvitationErrorEnum.AccessInvitationError), as well as more information about [handling errors here](https://developers.google.com/google-ads/api/docs/best-practices/error-types).
631
+ 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/v12/AccessInvitationErrorEnum.AccessInvitationError), as well as more information about [handling errors here](https://developers.google.com/google-ads/api/docs/best-practices/error-types).
626
632
 
627
633
  ```ts
628
634
  import { errors } from "google-ads-api";
@@ -40,7 +40,7 @@ class Customer extends serviceFactory_1.default {
40
40
  @hooks onQueryStart, onQueryError, onQueryEnd
41
41
  */
42
42
  async report(options) {
43
- const { gaqlQuery, requestOptions } = query_1.buildQuery(options);
43
+ const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)(options);
44
44
  const { response } = await this.querier(gaqlQuery, requestOptions, options);
45
45
  return response;
46
46
  }
@@ -50,7 +50,7 @@ class Customer extends serviceFactory_1.default {
50
50
  */
51
51
  async reportCount(options) {
52
52
  options.limit = 1; // must get at least one row
53
- const { gaqlQuery, requestOptions } = query_1.buildQuery(options);
53
+ const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)(options);
54
54
  // @ts-expect-error we do not allow this field in reportOptions, however it is still a valid request option
55
55
  requestOptions.return_total_results_count = true;
56
56
  const useHooks = false; // to avoid cacheing conflicts
@@ -66,7 +66,7 @@ class Customer extends serviceFactory_1.default {
66
66
  for await (const row of stream) { ... }
67
67
  */
68
68
  async *reportStream(reportOptions) {
69
- const { gaqlQuery, requestOptions } = query_1.buildQuery(reportOptions);
69
+ const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)(reportOptions);
70
70
  const stream = this.streamer(gaqlQuery, requestOptions, reportOptions);
71
71
  for await (const row of stream) {
72
72
  yield row;
@@ -82,7 +82,7 @@ class Customer extends serviceFactory_1.default {
82
82
  stream.on('end', () => { ... })
83
83
  */
84
84
  async reportStreamRaw(reportOptions) {
85
- const { gaqlQuery, requestOptions } = query_1.buildQuery(reportOptions);
85
+ const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)(reportOptions);
86
86
  const baseHookArguments = {
87
87
  credentials: this.credentials,
88
88
  query: gaqlQuery,
@@ -115,7 +115,7 @@ class Customer extends serviceFactory_1.default {
115
115
  const { service, request } = this.buildSearchRequestAndService(gaqlQuery, requestOptions);
116
116
  const searchResponse = await service.search(request, {
117
117
  otherArgs: { headers: this.callHeaders },
118
- autoPaginate: false,
118
+ autoPaginate: false, // autoPaginate doesn't work
119
119
  });
120
120
  const response = searchResponse[0];
121
121
  const summaryRow = searchResponse[2].summary_row;
@@ -175,8 +175,8 @@ class Customer extends serviceFactory_1.default {
175
175
  return this.clientOptions.disable_parsing
176
176
  ? rows
177
177
  : reportOptions
178
- ? parser_1.parse({ results: rows, reportOptions })
179
- : parser_1.parse({ results: rows, gaqlString: gaqlQuery });
178
+ ? (0, parser_1.parse)({ results: rows, reportOptions })
179
+ : (0, parser_1.parse)({ results: rows, gaqlString: gaqlQuery });
180
180
  };
181
181
  const { response, totalResultsCount } = await this.paginatedSearch(gaqlQuery, requestOptions, parsingWapper);
182
182
  if (this.hooks.onQueryEnd && useHooks) {
@@ -236,17 +236,17 @@ class Customer extends serviceFactory_1.default {
236
236
  });
237
237
  let streamFinished = false;
238
238
  const accumulator = [];
239
- let nextChunk = utils_1.createNextChunkArrivedPromise();
239
+ let nextChunk = (0, utils_1.createNextChunkArrivedPromise)();
240
240
  stream.on("data", (chunk) => {
241
241
  const results = chunk.summary_row ? [chunk.summary_row] : chunk.results;
242
242
  const parsedResponse = this.clientOptions.disable_parsing
243
243
  ? results
244
244
  : reportOptions
245
- ? parser_1.parse({ results, reportOptions })
246
- : parser_1.parse({ results, gaqlString: gaqlQuery });
245
+ ? (0, parser_1.parse)({ results, reportOptions })
246
+ : (0, parser_1.parse)({ results, gaqlString: gaqlQuery });
247
247
  accumulator.push(...parsedResponse);
248
248
  nextChunk.resolve();
249
- nextChunk = utils_1.createNextChunkArrivedPromise();
249
+ nextChunk = (0, utils_1.createNextChunkArrivedPromise)();
250
250
  });
251
251
  stream.on("error", (searchError) => {
252
252
  nextChunk.reject(searchError);
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -39,7 +39,7 @@ exports.parse = parse;
39
39
  // This function assumes that a gaql query is of the format "select * * * from * ...".
40
40
  // Queries that are not in this format should have thrown an error when called.
41
41
  function getGAQLFields(gaqlString) {
42
- const normalisedQuery = utils_1.normaliseQuery(gaqlString);
42
+ const normalisedQuery = (0, utils_1.normaliseQuery)(gaqlString);
43
43
  const fields = normalisedQuery
44
44
  .toLowerCase()
45
45
  .replace(/(^\s*select)|( from .*)|(\s+)/g, "")