google-ads-api 10.0.2 → 11.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.
@@ -20,17 +20,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.newCustomer = exports.failTestIfExecuted = exports.mockMethod = exports.noopParser = exports.mockParse = exports.mockQuery = exports.mockGetGoogleAdsError = exports.mockBuildMutateRequestAndService = exports.mockBuildSearchRequestAndService = exports.mockBuildSearchStreamRequestAndService = exports.mockSearchOnce = exports.mockPaginatedSearch = exports.mockParsedValues = exports.mockParseValue = exports.mockErrorMessage = exports.mockError = exports.mockMutationReturnValue = exports.mockTotalResultsCount = exports.mockSummaryRow = exports.mockQueryReturnValue = exports.mockMutations = exports.mockReportOptions = exports.mockGaqlQuery = exports.MOCK_LOGIN_CID = exports.MOCK_CID = exports.MOCK_REFRESH_TOKEN = exports.MOCK_DEVELOPER_TOKEN = exports.MOCK_CLIENT_SECRET = exports.MOCK_CLIENT_ID = void 0;
23
- var stream_1 = require("stream");
24
- var customer_1 = require("./customer");
25
- var parser = __importStar(require("./parser"));
26
- var protos_1 = require("./protos");
23
+ const stream_1 = require("stream");
24
+ const customer_1 = require("./customer");
25
+ const parser = __importStar(require("./parser"));
26
+ const protos_1 = require("./protos");
27
27
  exports.MOCK_CLIENT_ID = "MOCK CLIENT ID";
28
28
  exports.MOCK_CLIENT_SECRET = "MOCK CLIENT SECRET";
29
29
  exports.MOCK_DEVELOPER_TOKEN = "MOCK DEVELOPER TOKEN";
30
30
  exports.MOCK_REFRESH_TOKEN = "MOCK REFRESH TOKEN";
31
31
  exports.MOCK_CID = "MOCK CID";
32
32
  exports.MOCK_LOGIN_CID = "MOCK LOGIN CID";
33
- exports.mockGaqlQuery = "SELECT campaign.resource_name FROM campaign LIMIT 1";
33
+ exports.mockGaqlQuery = `SELECT campaign.resource_name FROM campaign LIMIT 1`;
34
34
  exports.mockReportOptions = {
35
35
  entity: "campaign",
36
36
  attributes: ["campaign.resource_name"],
@@ -50,7 +50,7 @@ exports.mockSummaryRow = {
50
50
  exports.mockTotalResultsCount = 23;
51
51
  exports.mockMutationReturnValue = {
52
52
  mutate_operation_responses: [],
53
- toJSON: function () {
53
+ toJSON: () => {
54
54
  return {};
55
55
  },
56
56
  };
@@ -71,33 +71,31 @@ exports.mockParsedValues = [
71
71
  exports.mockParseValue,
72
72
  exports.mockParseValue,
73
73
  ];
74
- function mockPaginatedSearch(customer, includeTotalResultsCount) {
75
- if (includeTotalResultsCount === void 0) { includeTotalResultsCount = false; }
74
+ function mockPaginatedSearch(customer, includeTotalResultsCount = false) {
76
75
  return (jest
77
76
  // @ts-expect-error private method
78
77
  .spyOn(customer, "paginatedSearch")
79
78
  // @ts-expect-error
80
- .mockImplementation(function (gaqlQuery, requestOptions, _parser) {
81
- var totalResultsCount = includeTotalResultsCount
79
+ .mockImplementation((gaqlQuery, requestOptions, _parser) => {
80
+ const totalResultsCount = includeTotalResultsCount
82
81
  ? exports.mockTotalResultsCount
83
82
  : undefined;
84
83
  return {
85
84
  response: _parser(exports.mockQueryReturnValue),
86
- totalResultsCount: totalResultsCount,
85
+ totalResultsCount,
87
86
  };
88
87
  }));
89
88
  }
90
89
  exports.mockPaginatedSearch = mockPaginatedSearch;
91
- function mockSearchOnce(_a) {
92
- var customer = _a.customer, response = _a.response, nextPageToken = _a.nextPageToken, includeTotalResultsCount = _a.includeTotalResultsCount;
90
+ function mockSearchOnce({ customer, response, nextPageToken, includeTotalResultsCount, }) {
93
91
  return (jest
94
92
  // @ts-expect-error private method
95
93
  .spyOn(customer, "search")
96
94
  // @ts-expect-error
97
- .mockImplementationOnce(function () {
95
+ .mockImplementationOnce(() => {
98
96
  return {
99
- response: response,
100
- nextPageToken: nextPageToken,
97
+ response,
98
+ nextPageToken,
101
99
  totalResultsCount: includeTotalResultsCount
102
100
  ? exports.mockTotalResultsCount
103
101
  : undefined,
@@ -106,52 +104,51 @@ function mockSearchOnce(_a) {
106
104
  }
107
105
  exports.mockSearchOnce = mockSearchOnce;
108
106
  function mockBuildSearchStreamRequestAndService(customer) {
109
- var mockStream = new stream_1.Readable({ objectMode: true });
110
- var mockStreamData = function (results) {
111
- var chunk = { results: results };
107
+ const mockStream = new stream_1.Readable({ objectMode: true });
108
+ const mockStreamData = (results) => {
109
+ const chunk = { results };
112
110
  mockStream.push(chunk);
113
111
  };
114
- var mockStreamSummaryRow = function () {
115
- var chunk = {
112
+ const mockStreamSummaryRow = () => {
113
+ const chunk = {
116
114
  summary_row: exports.mockSummaryRow,
117
115
  };
118
116
  mockStream.push(chunk);
119
117
  };
120
- var mockStreamError = function (error) {
118
+ const mockStreamError = (error) => {
121
119
  mockStream.destroy(error);
122
120
  };
123
- var mockStreamEnd = function () {
121
+ const mockStreamEnd = () => {
124
122
  mockStream.push(null);
125
123
  };
126
- var spyBuild = jest
124
+ const spyBuild = jest
127
125
  // @ts-expect-error protected method
128
126
  .spyOn(customer, "buildSearchStreamRequestAndService")
129
127
  // @ts-expect-error
130
- .mockImplementation(function () {
128
+ .mockImplementation(() => {
131
129
  return {
132
130
  service: {
133
- searchStream: function () { return mockStream; },
131
+ searchStream: () => mockStream,
134
132
  },
135
133
  request: {},
136
134
  };
137
135
  });
138
136
  return {
139
- spyBuild: spyBuild,
140
- mockStreamData: mockStreamData,
141
- mockStreamSummaryRow: mockStreamSummaryRow,
142
- mockStreamError: mockStreamError,
143
- mockStreamEnd: mockStreamEnd,
137
+ spyBuild,
138
+ mockStreamData,
139
+ mockStreamSummaryRow,
140
+ mockStreamError,
141
+ mockStreamEnd,
144
142
  };
145
143
  }
146
144
  exports.mockBuildSearchStreamRequestAndService = mockBuildSearchStreamRequestAndService;
147
- function mockBuildSearchRequestAndService(_a) {
148
- var customer = _a.customer, _b = _a.shouldThrow, shouldThrow = _b === void 0 ? false : _b, _c = _a.includeSummaryRow, includeSummaryRow = _c === void 0 ? false : _c, _d = _a.includeTotalResultsCount, includeTotalResultsCount = _d === void 0 ? false : _d;
149
- var mockService = {
150
- search: function () {
145
+ function mockBuildSearchRequestAndService({ customer, shouldThrow = false, includeSummaryRow = false, includeTotalResultsCount = false, }) {
146
+ const mockService = {
147
+ search: () => {
151
148
  if (shouldThrow) {
152
149
  throw new Error(exports.mockErrorMessage);
153
150
  }
154
- var searchGoogleAdsResponse = {
151
+ const searchGoogleAdsResponse = {
155
152
  summary_row: includeSummaryRow ? exports.mockSummaryRow : undefined,
156
153
  total_results_count: includeTotalResultsCount
157
154
  ? exports.mockTotalResultsCount
@@ -160,40 +157,39 @@ function mockBuildSearchRequestAndService(_a) {
160
157
  return [exports.mockQueryReturnValue, null, searchGoogleAdsResponse];
161
158
  },
162
159
  };
163
- var spyBuild = jest
160
+ const spyBuild = jest
164
161
  // @ts-expect-error protected method
165
162
  .spyOn(customer, "buildSearchRequestAndService")
166
163
  // @ts-expect-error
167
- .mockImplementation(function () {
164
+ .mockImplementation(() => {
168
165
  return {
169
166
  service: mockService,
170
167
  request: {},
171
168
  };
172
169
  });
173
- return { mockService: mockService, spyBuild: spyBuild };
170
+ return { mockService, spyBuild };
174
171
  }
175
172
  exports.mockBuildSearchRequestAndService = mockBuildSearchRequestAndService;
176
- function mockBuildMutateRequestAndService(_a) {
177
- var customer = _a.customer, _b = _a.shouldThrow, shouldThrow = _b === void 0 ? false : _b, request = _a.request, response = _a.response;
178
- var mockService = {
179
- mutate: function () {
173
+ function mockBuildMutateRequestAndService({ customer, shouldThrow = false, request, response, }) {
174
+ const mockService = {
175
+ mutate() {
180
176
  if (shouldThrow) {
181
177
  throw new Error(exports.mockErrorMessage);
182
178
  }
183
179
  return [response !== null && response !== void 0 ? response : exports.mockMutationReturnValue];
184
180
  },
185
181
  };
186
- var spyBuild = jest
182
+ const spyBuild = jest
187
183
  // @ts-expect-error protected method
188
184
  .spyOn(customer, "buildMutationRequestAndService")
189
185
  // @ts-expect-error
190
- .mockImplementation(function () {
186
+ .mockImplementation(() => {
191
187
  return {
192
188
  service: mockService,
193
189
  request: request !== null && request !== void 0 ? request : {},
194
190
  };
195
191
  });
196
- return { mockService: mockService, spyBuild: spyBuild };
192
+ return { mockService, spyBuild };
197
193
  }
198
194
  exports.mockBuildMutateRequestAndService = mockBuildMutateRequestAndService;
199
195
  function mockGetGoogleAdsError(customer) {
@@ -201,7 +197,7 @@ function mockGetGoogleAdsError(customer) {
201
197
  // @ts-expect-error protected method
202
198
  .spyOn(customer, "getGoogleAdsError")
203
199
  // @ts-expect-error
204
- .mockImplementation(function () { return exports.mockError; }));
200
+ .mockImplementation(() => exports.mockError));
205
201
  }
206
202
  exports.mockGetGoogleAdsError = mockGetGoogleAdsError;
207
203
  function mockQuery(customer) {
@@ -209,7 +205,7 @@ function mockQuery(customer) {
209
205
  // @ts-expect-error private method
210
206
  .spyOn(customer, "querier")
211
207
  // @ts-expect-error
212
- .mockImplementation(function () {
208
+ .mockImplementation(() => {
213
209
  return {
214
210
  response: exports.mockQueryReturnValue,
215
211
  totalResultsCount: exports.mockTotalResultsCount,
@@ -218,7 +214,7 @@ function mockQuery(customer) {
218
214
  }
219
215
  exports.mockQuery = mockQuery;
220
216
  function mockParse(mockParsedValues) {
221
- return jest.spyOn(parser, "parse").mockImplementation(function () { return mockParsedValues; });
217
+ return jest.spyOn(parser, "parse").mockImplementation(() => mockParsedValues);
222
218
  }
223
219
  exports.mockParse = mockParse;
224
220
  function noopParser(rows) {
@@ -227,7 +223,7 @@ function noopParser(rows) {
227
223
  exports.noopParser = noopParser;
228
224
  function mockMethod() {
229
225
  return {
230
- method: function () {
226
+ method() {
231
227
  return;
232
228
  },
233
229
  };
@@ -237,8 +233,7 @@ function failTestIfExecuted() {
237
233
  expect(true).toBeFalsy();
238
234
  }
239
235
  exports.failTestIfExecuted = failTestIfExecuted;
240
- function newCustomer(hooks, disableParsing) {
241
- if (disableParsing === void 0) { disableParsing = false; }
236
+ function newCustomer(hooks, disableParsing = false) {
242
237
  return new customer_1.Customer({
243
238
  client_id: exports.MOCK_CLIENT_ID,
244
239
  client_secret: exports.MOCK_CLIENT_SECRET,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNextChunkArrivedPromise = exports.getFieldMask = exports.recursiveFieldMaskSearch = exports.toSnakeCase = exports.toCamelCase = exports.capitaliseFirstLetter = exports.normaliseQuery = exports.toMicros = exports.fromMicros = void 0;
4
- var protos_1 = require("./protos");
4
+ const protos_1 = require("./protos");
5
5
  /**
6
6
  * @param micros Money value in micros format
7
7
  * @description Converts a micro amount to a normalised value
@@ -33,7 +33,7 @@ exports.toMicros = toMicros;
33
33
  * const normalisedQuery = normaliseQuery(gaqlQuery) // "SELECT campaign.name FROM campaign LIMIT 10"
34
34
  */
35
35
  function normaliseQuery(query) {
36
- return "" + query.replace(/\s{2,}/g, " ");
36
+ return `${query.replace(/\s{2,}/g, " ")}`;
37
37
  }
38
38
  exports.normaliseQuery = normaliseQuery;
39
39
  /**
@@ -55,8 +55,8 @@ exports.capitaliseFirstLetter = capitaliseFirstLetter;
55
55
  function toCamelCase(str) {
56
56
  return str
57
57
  .replace(/\s+/g, "_") // convert spaces to underscores
58
- .replace(/(_)([A-Za-z])/g, function (pattern) { return pattern[1].toUpperCase(); }) // replace "_x" patterns with "X"
59
- .replace(/^([A-Z])/g, function (pattern) { return pattern.toLowerCase(); }); // capitalises the first letter of the string
58
+ .replace(/(_)([A-Za-z])/g, (pattern) => pattern[1].toUpperCase()) // replace "_x" patterns with "X"
59
+ .replace(/^([A-Z])/g, (pattern) => pattern.toLowerCase()); // capitalises the first letter of the string
60
60
  }
61
61
  exports.toCamelCase = toCamelCase;
62
62
  /**
@@ -68,24 +68,22 @@ exports.toCamelCase = toCamelCase;
68
68
  function toSnakeCase(str) {
69
69
  return str
70
70
  .replace(/\s+/g, "_") // convert spaces to underscores
71
- .replace(/(?<!(^|_))([A-Z])/g, function (pattern) { return "_" + pattern; }) // places an underscore before any capital chars, unless there is already an underscore or it is the first char of the string
71
+ .replace(/(?<!(^|_))([A-Z])/g, (pattern) => "_" + pattern) // places an underscore before any capital chars, unless there is already an underscore or it is the first char of the string
72
72
  .toLowerCase();
73
73
  }
74
74
  exports.toSnakeCase = toSnakeCase;
75
75
  function recursiveFieldMaskSearch(data) {
76
- var paths = [];
77
- for (var _i = 0, _a = Object.keys(data); _i < _a.length; _i++) {
78
- var key = _a[_i];
76
+ const paths = [];
77
+ for (const key of Object.keys(data)) {
79
78
  if (key === "resourceName") {
80
79
  continue;
81
80
  }
82
- var fieldKey = toSnakeCase(key);
83
- var value = data[key];
81
+ const fieldKey = toSnakeCase(key);
82
+ const value = data[key];
84
83
  if (typeof value === "object" && !Array.isArray(value)) {
85
- var children = recursiveFieldMaskSearch(value);
86
- for (var _b = 0, children_1 = children; _b < children_1.length; _b++) {
87
- var child = children_1[_b];
88
- paths.push(fieldKey + "." + child);
84
+ const children = recursiveFieldMaskSearch(value);
85
+ for (const child of children) {
86
+ paths.push(`${fieldKey}.${child}`);
89
87
  }
90
88
  continue;
91
89
  }
@@ -96,24 +94,24 @@ function recursiveFieldMaskSearch(data) {
96
94
  exports.recursiveFieldMaskSearch = recursiveFieldMaskSearch;
97
95
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
96
  function getFieldMask(data) {
99
- var paths = recursiveFieldMaskSearch(data);
97
+ const paths = recursiveFieldMaskSearch(data);
100
98
  return new protos_1.protobuf.FieldMask({
101
- paths: paths,
99
+ paths,
102
100
  });
103
101
  }
104
102
  exports.getFieldMask = getFieldMask;
105
103
  function createNextChunkArrivedPromise() {
106
- var resolvePromise = function () {
104
+ let resolvePromise = () => {
107
105
  return;
108
106
  };
109
- var rejectPromise = function (error) {
107
+ let rejectPromise = (error) => {
110
108
  throw error;
111
109
  };
112
- var newPromise = new Promise(function (resolve, reject) {
110
+ const newPromise = new Promise((resolve, reject) => {
113
111
  // @ts-ignore
114
112
  resolvePromise = resolve;
115
113
  rejectPromise = reject;
116
114
  });
117
- return { newPromise: newPromise, resolve: resolvePromise, reject: rejectPromise };
115
+ return { newPromise, resolve: resolvePromise, reject: rejectPromise };
118
116
  }
119
117
  exports.createNextChunkArrivedPromise = createNextChunkArrivedPromise;
@@ -1 +1 @@
1
- export declare const googleAdsVersion = "v10";
1
+ export declare const googleAdsVersion = "v11";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.googleAdsVersion = void 0;
4
- exports.googleAdsVersion = "v10";
4
+ exports.googleAdsVersion = "v11";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "google-ads-api",
3
- "version": "10.0.2",
3
+ "version": "11.0.0",
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.1",
20
+ "google-ads-node": "^9.0.0",
21
21
  "google-auth-library": "^7.1.0",
22
- "google-gax": "^2.30.1",
22
+ "google-gax": "^3.1.1",
23
23
  "long": "^4.0.0"
24
24
  },
25
25
  "devDependencies": {