google-ads-api 24.1.0 → 25.1.0-beta.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.
Files changed (76) hide show
  1. package/README.md +9 -1
  2. package/build/{src → cjs}/client.d.ts +6 -4
  3. package/build/{src → cjs}/client.js +4 -4
  4. package/build/{src → cjs}/customer.d.ts +5 -5
  5. package/build/{src → cjs}/customer.js +24 -20
  6. package/build/{src → cjs}/hooks.d.ts +2 -2
  7. package/build/cjs/index.d.ts +9 -0
  8. package/build/{src → cjs}/index.js +22 -20
  9. package/build/{src → cjs}/parser.d.ts +2 -2
  10. package/build/{src → cjs}/parser.js +5 -5
  11. package/build/{src → cjs}/parserRest.js +7 -7
  12. package/build/{src → cjs}/protos/autogen/enums.d.ts +1679 -1180
  13. package/build/{src → cjs}/protos/autogen/enums.js +1696 -1177
  14. package/build/cjs/protos/autogen/fields.d.ts +1191 -0
  15. package/build/cjs/protos/autogen/fields.js +205 -0
  16. package/build/cjs/protos/autogen/resourceNames.d.ts +1668 -0
  17. package/build/cjs/protos/autogen/resourceNames.js +1669 -0
  18. package/build/{src → cjs}/protos/autogen/serviceFactory.d.ts +206 -215
  19. package/build/{src → cjs}/protos/autogen/serviceFactory.js +483 -554
  20. package/build/cjs/protos/index.d.ts +14 -0
  21. package/build/{src → cjs}/protos/index.js +12 -12
  22. package/build/{src → cjs}/query.d.ts +2 -2
  23. package/build/{src → cjs}/query.js +5 -5
  24. package/build/{src → cjs}/service.d.ts +5 -5
  25. package/build/{src → cjs}/service.js +64 -22
  26. package/build/{src → cjs}/types.d.ts +1 -1
  27. package/build/{src → cjs}/utils.d.ts +1 -1
  28. package/build/{src → cjs}/utils.js +2 -2
  29. package/build/cjs/version.d.ts +1 -0
  30. package/build/{src → cjs}/version.js +1 -1
  31. package/build/esm/client.d.ts +19 -0
  32. package/build/esm/client.js +40 -0
  33. package/build/esm/customer.d.ts +71 -0
  34. package/build/esm/customer.js +502 -0
  35. package/build/esm/hooks.d.ts +160 -0
  36. package/build/esm/hooks.js +1 -0
  37. package/build/esm/index.d.ts +9 -0
  38. package/build/esm/index.js +10 -0
  39. package/build/esm/package.json +1 -0
  40. package/build/esm/parser.d.ts +21 -0
  41. package/build/esm/parser.js +113 -0
  42. package/build/esm/parserRest.d.ts +1 -0
  43. package/build/esm/parserRest.js +112 -0
  44. package/build/esm/protos/autogen/enums.d.ts +6002 -0
  45. package/build/esm/protos/autogen/enums.js +6401 -0
  46. package/build/esm/protos/autogen/fields.d.ts +1191 -0
  47. package/build/esm/protos/autogen/fields.js +202 -0
  48. package/build/esm/protos/autogen/resourceNames.d.ts +1668 -0
  49. package/build/esm/protos/autogen/resourceNames.js +1475 -0
  50. package/build/esm/protos/autogen/serviceFactory.d.ts +1825 -0
  51. package/build/esm/protos/autogen/serviceFactory.js +18795 -0
  52. package/build/esm/protos/index.d.ts +14 -0
  53. package/build/esm/protos/index.js +19 -0
  54. package/build/esm/query.d.ts +62 -0
  55. package/build/esm/query.js +304 -0
  56. package/build/esm/service.d.ts +47 -0
  57. package/build/esm/service.js +222 -0
  58. package/build/esm/types.d.ts +75 -0
  59. package/build/esm/types.js +14 -0
  60. package/build/esm/utils.d.ts +49 -0
  61. package/build/esm/utils.js +108 -0
  62. package/build/esm/version.d.ts +1 -0
  63. package/build/esm/version.js +1 -0
  64. package/package.json +50 -11
  65. package/build/src/index.d.ts +0 -8
  66. package/build/src/protos/autogen/fields.d.ts +0 -1122
  67. package/build/src/protos/autogen/fields.js +0 -644
  68. package/build/src/protos/autogen/resourceNames.d.ts +0 -1609
  69. package/build/src/protos/autogen/resourceNames.js +0 -1982
  70. package/build/src/protos/index.d.ts +0 -14
  71. package/build/src/testUtils.d.ts +0 -107
  72. package/build/src/testUtils.js +0 -333
  73. package/build/src/version.d.ts +0 -1
  74. /package/build/{src → cjs}/hooks.js +0 -0
  75. /package/build/{src → cjs}/parserRest.d.ts +0 -0
  76. /package/build/{src → cjs}/types.js +0 -0
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-v23-009688.svg?style=flat-square">
10
+ <img src="https://img.shields.io/badge/google%20ads-v25.1-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">
@@ -36,6 +36,8 @@
36
36
  npm install google-ads-api
37
37
  ```
38
38
 
39
+ Requires Node.js 22 or newer. Both `import { GoogleAdsApi } from "google-ads-api"` (ES modules) and `require("google-ads-api")` (CommonJS) are supported. `google-ads-api/enums` and `google-ads-api/fields` expose the generated enums and field types without loading the gRPC service clients.
40
+
39
41
  # Usage
40
42
 
41
43
  - Setup
@@ -70,6 +72,12 @@ const client = new GoogleAdsApi({
70
72
  });
71
73
  ```
72
74
 
75
+ Optional client settings:
76
+
77
+ - `grpc_channel_options`: [gRPC channel options](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js#supported-channel-options) applied to every service client this instance creates, for example `{ "grpc.keepalive_time_ms": 30000, "grpc.keepalive_timeout_ms": 10000 }`. Service clients are cached per client id and refresh token, so use one `GoogleAdsApi` instance per set of options.
78
+ - `max_reporting_rows`: throw once a report or query returns more rows than this.
79
+ - `disable_parsing`: return raw API responses instead of parsed rows.
80
+
73
81
  ---
74
82
 
75
83
  ## Create a customer instance
@@ -1,13 +1,15 @@
1
- import { Customer } from "./customer";
2
- import { CustomerOptions } from "./types";
3
- import { Hooks } from "./hooks";
4
- import { services } from "./protos";
1
+ import type { grpc } from "google-gax";
2
+ import { Customer } from "./customer.js";
3
+ import { CustomerOptions } from "./types.js";
4
+ import { Hooks } from "./hooks.js";
5
+ import { services } from "./protos/index.js";
5
6
  export interface ClientOptions {
6
7
  client_id: string;
7
8
  client_secret: string;
8
9
  developer_token: string;
9
10
  disable_parsing?: boolean;
10
11
  max_reporting_rows?: number;
12
+ grpc_channel_options?: grpc.ChannelOptions;
11
13
  }
12
14
  export declare class Client {
13
15
  private readonly options;
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
- const customer_1 = require("./customer");
5
- const service_1 = require("./service");
4
+ const customer_js_1 = require("./customer.js");
5
+ const service_js_1 = require("./service.js");
6
6
  class Client {
7
7
  options;
8
8
  constructor(options) {
9
9
  this.options = options;
10
10
  }
11
11
  Customer(customerOptions, hooks) {
12
- const cus = new customer_1.Customer(this.options, customerOptions, hooks);
12
+ const cus = new customer_js_1.Customer(this.options, customerOptions, hooks);
13
13
  return cus;
14
14
  }
15
15
  async listAccessibleCustomers(refreshToken) {
16
- const service = new service_1.Service(this.options, {
16
+ const service = new service_js_1.Service(this.options, {
17
17
  customer_id: "",
18
18
  refresh_token: refreshToken,
19
19
  });
@@ -1,9 +1,9 @@
1
1
  import { CancellableStream } from "google-gax";
2
- import { ClientOptions } from "./client";
3
- import { Hooks } from "./hooks";
4
- import { services } from "./protos";
5
- import ServiceFactory from "./protos/autogen/serviceFactory";
6
- import { CustomerOptions, MutateOperation, MutateOptions, ReportOptions, RequestOptions } from "./types";
2
+ import { ClientOptions } from "./client.js";
3
+ import { Hooks } from "./hooks.js";
4
+ import { services } from "./protos/index.js";
5
+ import ServiceFactory from "./protos/autogen/serviceFactory.js";
6
+ import { CustomerOptions, MutateOperation, MutateOptions, ReportOptions, RequestOptions } from "./types.js";
7
7
  export declare class Customer extends ServiceFactory {
8
8
  constructor(clientOptions: ClientOptions, customerOptions: CustomerOptions, hooks?: Hooks);
9
9
  /**
@@ -5,16 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Customer = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const stream_chain_1 = require("stream-chain");
9
- const stream_json_1 = require("stream-json");
10
- const StreamArray_1 = require("stream-json/streamers/StreamArray");
11
- const parserRest_1 = require("./parserRest");
12
- const protos_1 = require("./protos");
13
- const serviceFactory_1 = __importDefault(require("./protos/autogen/serviceFactory"));
14
- const query_1 = require("./query");
15
- const version_1 = require("./version");
8
+ const stream_chain_1 = __importDefault(require("stream-chain"));
9
+ const stream_json_1 = __importDefault(require("stream-json"));
10
+ const StreamArray_js_1 = __importDefault(require("stream-json/streamers/StreamArray.js"));
11
+ const parserRest_js_1 = require("./parserRest.js");
12
+ const index_js_1 = require("./protos/index.js");
13
+ const serviceFactory_js_1 = __importDefault(require("./protos/autogen/serviceFactory.js"));
14
+ const query_js_1 = require("./query.js");
15
+ const version_js_1 = require("./version.js");
16
16
  const ROWS_PER_STREAMED_CHUNK = 10_000; // From experience, this is what can be expected from the API.
17
- class Customer extends serviceFactory_1.default {
17
+ class Customer extends serviceFactory_js_1.default {
18
18
  constructor(clientOptions, customerOptions, hooks) {
19
19
  super(clientOptions, customerOptions, hooks ?? {});
20
20
  }
@@ -46,7 +46,7 @@ class Customer extends serviceFactory_1.default {
46
46
  @hooks onQueryStart, onQueryError, onQueryEnd
47
47
  */
48
48
  async report(options) {
49
- const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)(options);
49
+ const { gaqlQuery, requestOptions } = (0, query_js_1.buildQuery)(options);
50
50
  const { response } = await this.querier(gaqlQuery, requestOptions, options);
51
51
  return response;
52
52
  }
@@ -56,7 +56,7 @@ class Customer extends serviceFactory_1.default {
56
56
  */
57
57
  async reportCount(options) {
58
58
  // must get at least one row
59
- const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)({ ...options, limit: 1 });
59
+ const { gaqlQuery, requestOptions } = (0, query_js_1.buildQuery)({ ...options, limit: 1 });
60
60
  // We do not allow this field in reportOptions, however it is still a valid request option
61
61
  requestOptions.search_settings = {
62
62
  return_total_results_count: true,
@@ -75,7 +75,7 @@ class Customer extends serviceFactory_1.default {
75
75
  for await (const row of stream) { ... }
76
76
  */
77
77
  async *reportStream(reportOptions) {
78
- const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)(reportOptions);
78
+ const { gaqlQuery, requestOptions } = (0, query_js_1.buildQuery)(reportOptions);
79
79
  const stream = this.streamer(gaqlQuery, requestOptions, reportOptions);
80
80
  for await (const row of stream) {
81
81
  yield row;
@@ -91,7 +91,7 @@ class Customer extends serviceFactory_1.default {
91
91
  stream.on('end', () => { ... })
92
92
  */
93
93
  async reportStreamRaw(reportOptions) {
94
- const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)(reportOptions);
94
+ const { gaqlQuery, requestOptions } = (0, query_js_1.buildQuery)(reportOptions);
95
95
  const baseHookArguments = {
96
96
  credentials: this.credentials,
97
97
  query: gaqlQuery,
@@ -141,7 +141,7 @@ class Customer extends serviceFactory_1.default {
141
141
  }
142
142
  catch (e) {
143
143
  if (e.response?.data.error.details[0]) {
144
- throw new protos_1.errors.GoogleAdsFailure(this.decamelizeKeysIfNeeded(e.response.data.error.details[0]));
144
+ throw new index_js_1.errors.GoogleAdsFailure(this.decamelizeKeysIfNeeded(e.response.data.error.details[0]));
145
145
  }
146
146
  throw e;
147
147
  }
@@ -329,13 +329,13 @@ class Customer extends serviceFactory_1.default {
329
329
  const response = await (0, axios_1.default)(args);
330
330
  const stream = response.data;
331
331
  // The options below help to make the stream less CPU intensive.
332
- const parser = new stream_json_1.Parser({
332
+ const parser = new stream_json_1.default.Parser({
333
333
  streamValues: false,
334
334
  streamKeys: false,
335
335
  packValues: true,
336
336
  packKeys: true,
337
337
  });
338
- const pipeline = (0, stream_chain_1.chain)([stream, parser, (0, StreamArray_1.streamArray)()]);
338
+ const pipeline = stream_chain_1.default.chain([stream, parser, StreamArray_js_1.default.streamArray()]);
339
339
  let count = 0;
340
340
  try {
341
341
  for await (const data of pipeline) {
@@ -382,13 +382,17 @@ class Customer extends serviceFactory_1.default {
382
382
  }
383
383
  // The error is a stream, so some effort is required to parse it.
384
384
  const stream = e.response.data;
385
- const pipeline = (0, stream_chain_1.chain)([stream, (0, stream_json_1.parser)(), (0, StreamArray_1.streamArray)()]);
385
+ const pipeline = stream_chain_1.default.chain([
386
+ stream,
387
+ stream_json_1.default.parser(),
388
+ StreamArray_js_1.default.streamArray(),
389
+ ]);
386
390
  const defaultErrorMessage = "Unknown GoogleAdsFailure";
387
391
  let googleAdsFailure = new Error(defaultErrorMessage);
388
392
  // Only throw the first error.
389
393
  pipeline.once("data", (data) => {
390
394
  if (data?.value?.error?.details?.[0]) {
391
- googleAdsFailure = new protos_1.errors.GoogleAdsFailure(this.decamelizeKeysIfNeeded(data.value.error.details[0]));
395
+ googleAdsFailure = new index_js_1.errors.GoogleAdsFailure(this.decamelizeKeysIfNeeded(data.value.error.details[0]));
392
396
  }
393
397
  else {
394
398
  googleAdsFailure = new Error(data?.value?.error?.message ?? defaultErrorMessage, { cause: data?.value?.error ?? data?.value });
@@ -481,7 +485,7 @@ class Customer extends serviceFactory_1.default {
481
485
  prepareGoogleAdsServicePostRequestArgs(functionName, accessToken, extra) {
482
486
  return {
483
487
  method: "POST",
484
- url: `https://googleads.googleapis.com/${version_1.googleAdsVersion}/customers/${this.customerOptions.customer_id}/googleAds:${functionName}`,
488
+ url: `https://googleads.googleapis.com/${version_js_1.googleAdsVersion}/customers/${this.customerOptions.customer_id}/googleAds:${functionName}`,
485
489
  headers: {
486
490
  Authorization: `Bearer ${accessToken}`,
487
491
  ...this.callHeaders,
@@ -493,7 +497,7 @@ class Customer extends serviceFactory_1.default {
493
497
  if (this.clientOptions.disable_parsing) {
494
498
  return input;
495
499
  }
496
- return (0, parserRest_1.decamelizeKeys)(input);
500
+ return (0, parserRest_js_1.decamelizeKeys)(input);
497
501
  }
498
502
  gaqlQueryStringIncludesLimit(gaqlQuery) {
499
503
  return gaqlQuery.toLowerCase().includes("limit ");
@@ -1,5 +1,5 @@
1
- import { errors, services } from "./protos";
2
- import { CustomerCredentials, MutateOperation, ReportOptions, RequestOptions, MutateOptions } from "./types";
1
+ import { errors, services } from "./protos/index.js";
2
+ import { CustomerCredentials, MutateOperation, ReportOptions, RequestOptions, MutateOptions } from "./types.js";
3
3
  export type BaseRequestHookArgs = {
4
4
  credentials: CustomerCredentials;
5
5
  query: string;
@@ -0,0 +1,9 @@
1
+ export { Client as GoogleAdsApi, ClientOptions } from "./client.js";
2
+ export { common, enums, fields, errors, resources, services, longrunning, protobuf, } from "./protos/index.js";
3
+ export { fromMicros, toMicros } from "./utils.js";
4
+ export { googleAdsVersion } from "./version.js";
5
+ export { parse } from "./parser.js";
6
+ export * as ResourceNames from "./protos/autogen/resourceNames.js";
7
+ export { CustomerOptions, ReportOptions, MutateOperation, Constraint, Constraints, } from "./types.js";
8
+ export { Hooks, OnQueryStart, OnQueryError, OnQueryEnd, OnStreamStart, OnStreamError, OnMutationStart, OnMutationError, OnMutationEnd, OnServiceStart, OnServiceError, OnServiceEnd, } from "./hooks.js";
9
+ export { Customer } from "./customer.js";
@@ -33,26 +33,28 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Customer = exports.ResourceNames = exports.parse = exports.toMicros = exports.fromMicros = exports.protobuf = exports.longrunning = exports.services = exports.resources = exports.errors = exports.fields = exports.enums = exports.common = exports.GoogleAdsApi = void 0;
36
+ exports.Customer = exports.ResourceNames = exports.parse = exports.googleAdsVersion = exports.toMicros = exports.fromMicros = exports.protobuf = exports.longrunning = exports.services = exports.resources = exports.errors = exports.fields = exports.enums = exports.common = exports.GoogleAdsApi = void 0;
37
37
  // Core library client
38
- var client_1 = require("./client");
39
- Object.defineProperty(exports, "GoogleAdsApi", { enumerable: true, get: function () { return client_1.Client; } });
38
+ var client_js_1 = require("./client.js");
39
+ Object.defineProperty(exports, "GoogleAdsApi", { enumerable: true, get: function () { return client_js_1.Client; } });
40
40
  // Compiled proto types
41
- var index_1 = require("./protos/index");
42
- Object.defineProperty(exports, "common", { enumerable: true, get: function () { return index_1.common; } });
43
- Object.defineProperty(exports, "enums", { enumerable: true, get: function () { return index_1.enums; } });
44
- Object.defineProperty(exports, "fields", { enumerable: true, get: function () { return index_1.fields; } });
45
- Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return index_1.errors; } });
46
- Object.defineProperty(exports, "resources", { enumerable: true, get: function () { return index_1.resources; } });
47
- Object.defineProperty(exports, "services", { enumerable: true, get: function () { return index_1.services; } });
48
- Object.defineProperty(exports, "longrunning", { enumerable: true, get: function () { return index_1.longrunning; } });
49
- Object.defineProperty(exports, "protobuf", { enumerable: true, get: function () { return index_1.protobuf; } });
41
+ var index_js_1 = require("./protos/index.js");
42
+ Object.defineProperty(exports, "common", { enumerable: true, get: function () { return index_js_1.common; } });
43
+ Object.defineProperty(exports, "enums", { enumerable: true, get: function () { return index_js_1.enums; } });
44
+ Object.defineProperty(exports, "fields", { enumerable: true, get: function () { return index_js_1.fields; } });
45
+ Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return index_js_1.errors; } });
46
+ Object.defineProperty(exports, "resources", { enumerable: true, get: function () { return index_js_1.resources; } });
47
+ Object.defineProperty(exports, "services", { enumerable: true, get: function () { return index_js_1.services; } });
48
+ Object.defineProperty(exports, "longrunning", { enumerable: true, get: function () { return index_js_1.longrunning; } });
49
+ Object.defineProperty(exports, "protobuf", { enumerable: true, get: function () { return index_js_1.protobuf; } });
50
50
  // Util functions
51
- var utils_1 = require("./utils");
52
- Object.defineProperty(exports, "fromMicros", { enumerable: true, get: function () { return utils_1.fromMicros; } });
53
- Object.defineProperty(exports, "toMicros", { enumerable: true, get: function () { return utils_1.toMicros; } });
54
- var parser_1 = require("./parser");
55
- Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_1.parse; } });
56
- exports.ResourceNames = __importStar(require("./protos/autogen/resourceNames"));
57
- var customer_1 = require("./customer");
58
- Object.defineProperty(exports, "Customer", { enumerable: true, get: function () { return customer_1.Customer; } });
51
+ var utils_js_1 = require("./utils.js");
52
+ Object.defineProperty(exports, "fromMicros", { enumerable: true, get: function () { return utils_js_1.fromMicros; } });
53
+ Object.defineProperty(exports, "toMicros", { enumerable: true, get: function () { return utils_js_1.toMicros; } });
54
+ var version_js_1 = require("./version.js");
55
+ Object.defineProperty(exports, "googleAdsVersion", { enumerable: true, get: function () { return version_js_1.googleAdsVersion; } });
56
+ var parser_js_1 = require("./parser.js");
57
+ Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_js_1.parse; } });
58
+ exports.ResourceNames = __importStar(require("./protos/autogen/resourceNames.js"));
59
+ var customer_js_1 = require("./customer.js");
60
+ Object.defineProperty(exports, "Customer", { enumerable: true, get: function () { return customer_js_1.Customer; } });
@@ -1,5 +1,5 @@
1
- import { ReportOptions } from "./types";
2
- import { services } from "./protos";
1
+ import { ReportOptions } from "./types.js";
2
+ import { services } from "./protos/index.js";
3
3
  export declare const ParsingError: {
4
4
  NO_REPORT_OPTIONS_OR_GAQL_QUERY: string;
5
5
  NO_FIELDS_IN_GAQL_QUERY: string;
@@ -9,8 +9,8 @@ exports.getGAQLFields = getGAQLFields;
9
9
  exports.getReportOptionFields = getReportOptionFields;
10
10
  exports.parseRows = parseRows;
11
11
  const long_1 = __importDefault(require("long"));
12
- const protos_1 = require("./protos");
13
- const utils_1 = require("./utils");
12
+ const index_js_1 = require("./protos/index.js");
13
+ const utils_js_1 = require("./utils.js");
14
14
  exports.ParsingError = {
15
15
  NO_REPORT_OPTIONS_OR_GAQL_QUERY: "Must provided reportOptions or gaqlString to parse results.",
16
16
  NO_FIELDS_IN_GAQL_QUERY: "GAQL Query must contain at least one attribute, metric or segment.",
@@ -35,14 +35,14 @@ function parse({ results, reportOptions, gaqlString, }) {
35
35
  : getGAQLFields(gaqlString);
36
36
  // Add in all relevant resource_name fields, which are always returned by API
37
37
  const entities = queryFields.map((field) => field.split(".")[0]);
38
- const resourceNameFields = protos_1.fields.resourceNames.filter((resourceNameField) => entities.includes(resourceNameField.split(".")[0]));
38
+ const resourceNameFields = index_js_1.fields.resourceNames.filter((resourceNameField) => entities.includes(resourceNameField.split(".")[0]));
39
39
  const allFields = [...queryFields, ...resourceNameFields];
40
40
  return parseRows(results, allFields);
41
41
  }
42
42
  // This function assumes that a gaql query is of the format "select * * * from * ...".
43
43
  // Queries that are not in this format should have thrown an error when called.
44
44
  function getGAQLFields(gaqlString) {
45
- const normalisedQuery = (0, utils_1.normaliseQuery)(gaqlString);
45
+ const normalisedQuery = (0, utils_js_1.normaliseQuery)(gaqlString);
46
46
  const fields = normalisedQuery
47
47
  .toLowerCase()
48
48
  .replace(/(^\s*select)|( from .*)|(\s+)/g, "")
@@ -73,7 +73,7 @@ function parseRows(rows, fields) {
73
73
  const newRows = [];
74
74
  for (let r = 0; r < rows.length; r++) {
75
75
  const newRow = {};
76
- const originalRow = protos_1.services.GoogleAdsRow.fromObject(rows[r]);
76
+ const originalRow = index_js_1.services.GoogleAdsRow.fromObject(rows[r]);
77
77
  for (const split in fieldsPreSplit) {
78
78
  // @ts-expect-error These are the best we can do for these types
79
79
  const [parent, ...children] = fieldsPreSplit[split];
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decamelizeKeys = void 0;
4
4
  const circ_json_1 = require("circ-json");
5
- const utils_1 = require("./utils");
6
- const fields_1 = require("./protos/autogen/fields");
7
- const enums_1 = require("./protos/autogen/enums");
8
- const fieldDataTypes = (0, circ_json_1.parse)(fields_1.fieldDataTypes);
5
+ const utils_js_1 = require("./utils.js");
6
+ const fields_js_1 = require("./protos/autogen/fields.js");
7
+ const enums_js_1 = require("./protos/autogen/enums.js");
8
+ const fieldDataTypes = (0, circ_json_1.parse)(fields_js_1.fieldDataTypes);
9
9
  const decamelizeCache = new Map();
10
10
  const fieldTypeCache = new Map();
11
11
  const isObject = (value) => typeof value === "object" && value !== null;
@@ -51,7 +51,7 @@ const cachedDecamelize = (key) => {
51
51
  if (cachedResult) {
52
52
  return cachedResult;
53
53
  }
54
- const newKey = (0, utils_1.toSnakeCase)(key);
54
+ const newKey = (0, utils_js_1.toSnakeCase)(key);
55
55
  decamelizeCache.set(key, newKey);
56
56
  return newKey;
57
57
  };
@@ -73,7 +73,7 @@ const cachedValueParser = (key, parentPath, value) => {
73
73
  return p
74
74
  .trim()
75
75
  .split(".")
76
- .map((segment) => (0, utils_1.toSnakeCase)(segment))
76
+ .map((segment) => (0, utils_js_1.toSnakeCase)(segment))
77
77
  .join(".");
78
78
  }),
79
79
  };
@@ -89,7 +89,7 @@ const cachedValueParser = (key, parentPath, value) => {
89
89
  else if (megaDataType === "ENUM") {
90
90
  // Some enums aren't embedded in megaDataType, so we need this fallback.
91
91
  // @ts-expect-error typescript doesn't like accessing items in a namespace with a string
92
- newValue = enums_1.enums[fields_1.fields.enumFields[fullPath]][value]; // e.g. enums['CampaignStatus'][ENABLED] = "2"
92
+ newValue = enums_js_1.enums[fields_js_1.fields.enumFields[fullPath]][value]; // e.g. enums['CampaignStatus'][ENABLED] = "2"
93
93
  }
94
94
  return newValue;
95
95
  };