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.
- package/README.md +9 -1
- package/build/{src → cjs}/client.d.ts +6 -4
- package/build/{src → cjs}/client.js +4 -4
- package/build/{src → cjs}/customer.d.ts +5 -5
- package/build/{src → cjs}/customer.js +24 -20
- package/build/{src → cjs}/hooks.d.ts +2 -2
- package/build/cjs/index.d.ts +9 -0
- package/build/{src → cjs}/index.js +22 -20
- package/build/{src → cjs}/parser.d.ts +2 -2
- package/build/{src → cjs}/parser.js +5 -5
- package/build/{src → cjs}/parserRest.js +7 -7
- package/build/{src → cjs}/protos/autogen/enums.d.ts +1679 -1180
- package/build/{src → cjs}/protos/autogen/enums.js +1696 -1177
- package/build/cjs/protos/autogen/fields.d.ts +1191 -0
- package/build/cjs/protos/autogen/fields.js +205 -0
- package/build/cjs/protos/autogen/resourceNames.d.ts +1668 -0
- package/build/cjs/protos/autogen/resourceNames.js +1669 -0
- package/build/{src → cjs}/protos/autogen/serviceFactory.d.ts +206 -215
- package/build/{src → cjs}/protos/autogen/serviceFactory.js +483 -554
- package/build/cjs/protos/index.d.ts +14 -0
- package/build/{src → cjs}/protos/index.js +12 -12
- package/build/{src → cjs}/query.d.ts +2 -2
- package/build/{src → cjs}/query.js +5 -5
- package/build/{src → cjs}/service.d.ts +5 -5
- package/build/{src → cjs}/service.js +64 -22
- package/build/{src → cjs}/types.d.ts +1 -1
- package/build/{src → cjs}/utils.d.ts +1 -1
- package/build/{src → cjs}/utils.js +2 -2
- package/build/cjs/version.d.ts +1 -0
- package/build/{src → cjs}/version.js +1 -1
- package/build/esm/client.d.ts +19 -0
- package/build/esm/client.js +40 -0
- package/build/esm/customer.d.ts +71 -0
- package/build/esm/customer.js +502 -0
- package/build/esm/hooks.d.ts +160 -0
- package/build/esm/hooks.js +1 -0
- package/build/esm/index.d.ts +9 -0
- package/build/esm/index.js +10 -0
- package/build/esm/package.json +1 -0
- package/build/esm/parser.d.ts +21 -0
- package/build/esm/parser.js +113 -0
- package/build/esm/parserRest.d.ts +1 -0
- package/build/esm/parserRest.js +112 -0
- package/build/esm/protos/autogen/enums.d.ts +6002 -0
- package/build/esm/protos/autogen/enums.js +6401 -0
- package/build/esm/protos/autogen/fields.d.ts +1191 -0
- package/build/esm/protos/autogen/fields.js +202 -0
- package/build/esm/protos/autogen/resourceNames.d.ts +1668 -0
- package/build/esm/protos/autogen/resourceNames.js +1475 -0
- package/build/esm/protos/autogen/serviceFactory.d.ts +1825 -0
- package/build/esm/protos/autogen/serviceFactory.js +18795 -0
- package/build/esm/protos/index.d.ts +14 -0
- package/build/esm/protos/index.js +19 -0
- package/build/esm/query.d.ts +62 -0
- package/build/esm/query.js +304 -0
- package/build/esm/service.d.ts +47 -0
- package/build/esm/service.js +222 -0
- package/build/esm/types.d.ts +75 -0
- package/build/esm/types.js +14 -0
- package/build/esm/utils.d.ts +49 -0
- package/build/esm/utils.js +108 -0
- package/build/esm/version.d.ts +1 -0
- package/build/esm/version.js +1 -0
- package/package.json +50 -11
- package/build/src/index.d.ts +0 -8
- package/build/src/protos/autogen/fields.d.ts +0 -1122
- package/build/src/protos/autogen/fields.js +0 -644
- package/build/src/protos/autogen/resourceNames.d.ts +0 -1609
- package/build/src/protos/autogen/resourceNames.js +0 -1982
- package/build/src/protos/index.d.ts +0 -14
- package/build/src/testUtils.d.ts +0 -107
- package/build/src/testUtils.js +0 -333
- package/build/src/version.d.ts +0 -1
- /package/build/{src → cjs}/hooks.js +0 -0
- /package/build/{src → cjs}/parserRest.d.ts +0 -0
- /package/build/{src → cjs}/types.js +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import allProtos, { protos } from "google-ads-node";
|
|
2
|
-
export declare const VERSION: "v24";
|
|
3
|
-
export import common = protos.google.ads.googleads.v24.common;
|
|
4
|
-
export import errors = protos.google.ads.googleads.v24.errors;
|
|
5
|
-
export import resources = protos.google.ads.googleads.v24.resources;
|
|
6
|
-
export import services = protos.google.ads.googleads.v24.services;
|
|
7
|
-
export import internalEnums = protos.google.ads.googleads.v24.enums;
|
|
8
|
-
export { enums } from "./autogen/enums";
|
|
9
|
-
export { fields, fieldDataTypes } from "./autogen/fields";
|
|
10
|
-
export { GoogleAdsServiceClient } from "google-ads-node";
|
|
11
|
-
export type AllServices = Omit<typeof allProtos, typeof VERSION>;
|
|
12
|
-
export type ServiceName = keyof Omit<typeof allProtos, typeof VERSION>;
|
|
13
|
-
export import protobuf = protos.google.protobuf;
|
|
14
|
-
export import longrunning = protos.google.longrunning;
|
package/build/src/testUtils.d.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Readable } from "stream";
|
|
2
|
-
import { Customer } from "./customer";
|
|
3
|
-
import { Hooks } from "./hooks";
|
|
4
|
-
import { errors, GoogleAdsServiceClient, services } from "./protos";
|
|
5
|
-
import { PageToken, ReportOptions, MutateOperation } from "./types";
|
|
6
|
-
export declare const MOCK_CLIENT_ID = "MOCK CLIENT ID";
|
|
7
|
-
export declare const MOCK_CLIENT_SECRET = "MOCK CLIENT SECRET";
|
|
8
|
-
export declare const MOCK_DEVELOPER_TOKEN = "MOCK DEVELOPER TOKEN";
|
|
9
|
-
export declare const MOCK_REFRESH_TOKEN = "MOCK REFRESH TOKEN";
|
|
10
|
-
export declare const MOCK_CID = "MOCK CID";
|
|
11
|
-
export declare const MOCK_LOGIN_CID = "MOCK LOGIN CID";
|
|
12
|
-
export declare const mockGaqlQuery = "SELECT campaign.resource_name FROM campaign LIMIT 1";
|
|
13
|
-
export declare const mockReportOptions: ReportOptions;
|
|
14
|
-
export declare const mockMutations: MutateOperation<any>[];
|
|
15
|
-
export declare const mockSearchRawResult: {
|
|
16
|
-
totalResultsCount: number;
|
|
17
|
-
results: {
|
|
18
|
-
campaign: {
|
|
19
|
-
resourceName: string;
|
|
20
|
-
};
|
|
21
|
-
}[];
|
|
22
|
-
}[];
|
|
23
|
-
export declare const mockSearchRawResultWithSummaryRow: ({
|
|
24
|
-
totalResultsCount: number;
|
|
25
|
-
results: {
|
|
26
|
-
campaign: {
|
|
27
|
-
resourceName: string;
|
|
28
|
-
};
|
|
29
|
-
}[];
|
|
30
|
-
summaryRow?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
summaryRow: {
|
|
33
|
-
metrics: {
|
|
34
|
-
clicks: number;
|
|
35
|
-
impressions: number;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
totalResultsCount?: undefined;
|
|
39
|
-
results?: undefined;
|
|
40
|
-
})[];
|
|
41
|
-
export declare const mockQueryReturnValue: services.IGoogleAdsRow[];
|
|
42
|
-
export declare const mockQueryReturnValueWithSummaryRow: services.IGoogleAdsRow[];
|
|
43
|
-
export declare const mockQueryReturnValueUnparsed: {
|
|
44
|
-
campaign: {
|
|
45
|
-
resourceName: string;
|
|
46
|
-
};
|
|
47
|
-
}[];
|
|
48
|
-
export declare const mockSummaryRow: services.IGoogleAdsRow;
|
|
49
|
-
export declare const mockTotalResultsCount = 23;
|
|
50
|
-
export declare const mockMutationReturnValue: services.MutateGoogleAdsResponse;
|
|
51
|
-
export declare const mockError: {
|
|
52
|
-
errors: {
|
|
53
|
-
errorCode: {
|
|
54
|
-
queryError: errors.QueryErrorEnum.QueryError;
|
|
55
|
-
};
|
|
56
|
-
message: string;
|
|
57
|
-
}[];
|
|
58
|
-
};
|
|
59
|
-
export declare const mockErrorMessage = "mock error message";
|
|
60
|
-
export declare const mockParseValue: services.IGoogleAdsRow;
|
|
61
|
-
export declare const mockParsedValues: services.IGoogleAdsRow[];
|
|
62
|
-
export declare const mockStream: (data?: any) => Readable;
|
|
63
|
-
export declare function mockGetAccessToken(customer: Customer): jest.SpyInstance;
|
|
64
|
-
export declare const mockStreamWithSummaryRow: () => Readable;
|
|
65
|
-
export declare const mockStreamWithBadData: () => Readable;
|
|
66
|
-
export declare function mockPaginatedSearch(customer: Customer, includeTotalResultsCount?: boolean): jest.SpyInstance;
|
|
67
|
-
export declare function mockSearchOnce({ customer, response, nextPageToken, includeTotalResultsCount, }: {
|
|
68
|
-
customer: Customer;
|
|
69
|
-
response: any[];
|
|
70
|
-
nextPageToken: PageToken;
|
|
71
|
-
includeTotalResultsCount?: boolean;
|
|
72
|
-
}): jest.SpyInstance;
|
|
73
|
-
export declare function mockBuildSearchStreamRequestAndService(customer: Customer): {
|
|
74
|
-
spyBuild: jest.SpyInstance;
|
|
75
|
-
mockStreamData: (data: services.IGoogleAdsRow[]) => void;
|
|
76
|
-
mockStreamSummaryRow: () => void;
|
|
77
|
-
mockStreamError: (error: Error) => void;
|
|
78
|
-
mockStreamEnd: () => void;
|
|
79
|
-
};
|
|
80
|
-
export declare function mockBuildSearchRequestAndService({ customer, shouldThrow, includeSummaryRow, includeTotalResultsCount, }: {
|
|
81
|
-
customer: Customer;
|
|
82
|
-
shouldThrow?: boolean;
|
|
83
|
-
includeSummaryRow?: boolean;
|
|
84
|
-
includeTotalResultsCount?: boolean;
|
|
85
|
-
}): {
|
|
86
|
-
mockService: GoogleAdsServiceClient;
|
|
87
|
-
spyBuild: jest.SpyInstance;
|
|
88
|
-
};
|
|
89
|
-
export declare function mockBuildMutateRequestAndService({ customer, shouldThrow, request, response, }: {
|
|
90
|
-
customer: Customer;
|
|
91
|
-
shouldThrow?: boolean;
|
|
92
|
-
request?: services.MutateGoogleAdsRequest;
|
|
93
|
-
response?: services.MutateGoogleAdsResponse;
|
|
94
|
-
}): {
|
|
95
|
-
mockService: GoogleAdsServiceClient;
|
|
96
|
-
spyBuild: jest.SpyInstance;
|
|
97
|
-
};
|
|
98
|
-
export declare function mockGetGoogleAdsError(customer: Customer): jest.SpyInstance;
|
|
99
|
-
export declare function mockQuery(customer: Customer): jest.SpyInstance;
|
|
100
|
-
export declare function mockParse(mockParsedValues: services.IGoogleAdsRow[]): jest.SpyInstance;
|
|
101
|
-
export declare function mockParseRest(mockParsedValues: services.IGoogleAdsRow[]): jest.SpyInstance;
|
|
102
|
-
export declare function noopParser(rows: services.IGoogleAdsRow[]): services.IGoogleAdsRow[];
|
|
103
|
-
export declare function mockMethod(): {
|
|
104
|
-
method(): void;
|
|
105
|
-
};
|
|
106
|
-
export declare function failTestIfExecuted(): void;
|
|
107
|
-
export declare function newCustomer(hooks?: Hooks, disableParsing?: boolean): Customer;
|
package/build/src/testUtils.js
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = 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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.mockStreamWithBadData = exports.mockStreamWithSummaryRow = exports.mockStream = exports.mockParsedValues = exports.mockParseValue = exports.mockErrorMessage = exports.mockError = exports.mockMutationReturnValue = exports.mockTotalResultsCount = exports.mockSummaryRow = exports.mockQueryReturnValueUnparsed = exports.mockQueryReturnValueWithSummaryRow = exports.mockQueryReturnValue = exports.mockSearchRawResultWithSummaryRow = exports.mockSearchRawResult = 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;
|
|
40
|
-
exports.mockGetAccessToken = mockGetAccessToken;
|
|
41
|
-
exports.mockPaginatedSearch = mockPaginatedSearch;
|
|
42
|
-
exports.mockSearchOnce = mockSearchOnce;
|
|
43
|
-
exports.mockBuildSearchStreamRequestAndService = mockBuildSearchStreamRequestAndService;
|
|
44
|
-
exports.mockBuildSearchRequestAndService = mockBuildSearchRequestAndService;
|
|
45
|
-
exports.mockBuildMutateRequestAndService = mockBuildMutateRequestAndService;
|
|
46
|
-
exports.mockGetGoogleAdsError = mockGetGoogleAdsError;
|
|
47
|
-
exports.mockQuery = mockQuery;
|
|
48
|
-
exports.mockParse = mockParse;
|
|
49
|
-
exports.mockParseRest = mockParseRest;
|
|
50
|
-
exports.noopParser = noopParser;
|
|
51
|
-
exports.mockMethod = mockMethod;
|
|
52
|
-
exports.failTestIfExecuted = failTestIfExecuted;
|
|
53
|
-
exports.newCustomer = newCustomer;
|
|
54
|
-
const stream_1 = require("stream");
|
|
55
|
-
const customer_1 = require("./customer");
|
|
56
|
-
const parser = __importStar(require("./parser"));
|
|
57
|
-
const parserRest = __importStar(require("./parserRest"));
|
|
58
|
-
const protos_1 = require("./protos");
|
|
59
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
60
|
-
exports.MOCK_CLIENT_ID = "MOCK CLIENT ID";
|
|
61
|
-
exports.MOCK_CLIENT_SECRET = "MOCK CLIENT SECRET";
|
|
62
|
-
exports.MOCK_DEVELOPER_TOKEN = "MOCK DEVELOPER TOKEN";
|
|
63
|
-
exports.MOCK_REFRESH_TOKEN = "MOCK REFRESH TOKEN";
|
|
64
|
-
exports.MOCK_CID = "MOCK CID";
|
|
65
|
-
exports.MOCK_LOGIN_CID = "MOCK LOGIN CID";
|
|
66
|
-
exports.mockGaqlQuery = `SELECT campaign.resource_name FROM campaign LIMIT 1`;
|
|
67
|
-
exports.mockReportOptions = {
|
|
68
|
-
entity: "campaign",
|
|
69
|
-
attributes: ["campaign.resource_name"],
|
|
70
|
-
limit: 1,
|
|
71
|
-
};
|
|
72
|
-
exports.mockMutations = [
|
|
73
|
-
{ resource: "abc", entity: "campaign", operation: "create" },
|
|
74
|
-
];
|
|
75
|
-
exports.mockSearchRawResult = [
|
|
76
|
-
{
|
|
77
|
-
totalResultsCount: 23,
|
|
78
|
-
results: [
|
|
79
|
-
{ campaign: { resourceName: "customers/1/campaigns/11" } },
|
|
80
|
-
{ campaign: { resourceName: "customers/2/campaigns/22" } },
|
|
81
|
-
{ campaign: { resourceName: "customers/3/campaigns/33" } },
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
];
|
|
85
|
-
exports.mockSearchRawResultWithSummaryRow = [
|
|
86
|
-
{
|
|
87
|
-
totalResultsCount: 23,
|
|
88
|
-
results: [
|
|
89
|
-
{ campaign: { resourceName: "customers/1/campaigns/11" } },
|
|
90
|
-
{ campaign: { resourceName: "customers/2/campaigns/22" } },
|
|
91
|
-
{ campaign: { resourceName: "customers/3/campaigns/33" } },
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
summaryRow: { metrics: { clicks: 90, impressions: 153 } },
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
exports.mockQueryReturnValue = [
|
|
99
|
-
{ campaign: { resource_name: "customers/1/campaigns/11" } },
|
|
100
|
-
{ campaign: { resource_name: "customers/2/campaigns/22" } },
|
|
101
|
-
{ campaign: { resource_name: "customers/3/campaigns/33" } },
|
|
102
|
-
];
|
|
103
|
-
exports.mockQueryReturnValueWithSummaryRow = [
|
|
104
|
-
{ campaign: { resource_name: "customers/1/campaigns/11" } },
|
|
105
|
-
{ campaign: { resource_name: "customers/2/campaigns/22" } },
|
|
106
|
-
{ campaign: { resource_name: "customers/3/campaigns/33" } },
|
|
107
|
-
{ metrics: { clicks: 90, impressions: 153 } },
|
|
108
|
-
];
|
|
109
|
-
exports.mockQueryReturnValueUnparsed = [
|
|
110
|
-
{ campaign: { resourceName: "customers/1/campaigns/11" } },
|
|
111
|
-
{ campaign: { resourceName: "customers/2/campaigns/22" } },
|
|
112
|
-
{ campaign: { resourceName: "customers/3/campaigns/33" } },
|
|
113
|
-
];
|
|
114
|
-
exports.mockSummaryRow = {
|
|
115
|
-
metrics: { clicks: 90, impressions: 153 },
|
|
116
|
-
};
|
|
117
|
-
exports.mockTotalResultsCount = 23;
|
|
118
|
-
exports.mockMutationReturnValue = {
|
|
119
|
-
mutate_operation_responses: [],
|
|
120
|
-
toJSON: () => {
|
|
121
|
-
return {};
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
exports.mockError = {
|
|
125
|
-
errors: [
|
|
126
|
-
{
|
|
127
|
-
errorCode: {
|
|
128
|
-
queryError: protos_1.errors.QueryErrorEnum.QueryError.BAD_RESOURCE_TYPE_IN_FROM_CLAUSE,
|
|
129
|
-
},
|
|
130
|
-
message: "Error in campaigns: is not a valid resource name.",
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
};
|
|
134
|
-
exports.mockErrorMessage = "mock error message";
|
|
135
|
-
exports.mockParseValue = "mock parse value";
|
|
136
|
-
exports.mockParsedValues = [
|
|
137
|
-
exports.mockParseValue,
|
|
138
|
-
exports.mockParseValue,
|
|
139
|
-
exports.mockParseValue,
|
|
140
|
-
];
|
|
141
|
-
// Returns a stream that emits the provided values
|
|
142
|
-
const mockStream = function (data = exports.mockSearchRawResult) {
|
|
143
|
-
const chunks = lodash_1.default.chunk(JSON.stringify(data), 10).map((c) => c.join("")); // random splits
|
|
144
|
-
const stream = new stream_1.Readable({ objectMode: true });
|
|
145
|
-
chunks.forEach((value) => stream.push(new Buffer(value)));
|
|
146
|
-
stream.push(null);
|
|
147
|
-
return stream;
|
|
148
|
-
};
|
|
149
|
-
exports.mockStream = mockStream;
|
|
150
|
-
function mockGetAccessToken(customer) {
|
|
151
|
-
return (jest
|
|
152
|
-
.spyOn(customer, "getAccessToken")
|
|
153
|
-
// ts-expect-error
|
|
154
|
-
.mockImplementation(async () => {
|
|
155
|
-
return "mockedAccessTokenHere";
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
const mockStreamWithSummaryRow = function () {
|
|
159
|
-
return (0, exports.mockStream)(exports.mockSearchRawResultWithSummaryRow);
|
|
160
|
-
};
|
|
161
|
-
exports.mockStreamWithSummaryRow = mockStreamWithSummaryRow;
|
|
162
|
-
const mockStreamWithBadData = function () {
|
|
163
|
-
return (0, exports.mockStream)({ results: 66 });
|
|
164
|
-
};
|
|
165
|
-
exports.mockStreamWithBadData = mockStreamWithBadData;
|
|
166
|
-
function mockPaginatedSearch(customer, includeTotalResultsCount = false) {
|
|
167
|
-
return (jest
|
|
168
|
-
// @ts-expect-error private method
|
|
169
|
-
.spyOn(customer, "paginatedSearch")
|
|
170
|
-
// @ts-expect-error
|
|
171
|
-
.mockImplementation((gaqlQuery, requestOptions) => {
|
|
172
|
-
const totalResultsCount = includeTotalResultsCount
|
|
173
|
-
? exports.mockTotalResultsCount
|
|
174
|
-
: undefined;
|
|
175
|
-
return {
|
|
176
|
-
response: exports.mockQueryReturnValue,
|
|
177
|
-
totalResultsCount,
|
|
178
|
-
};
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
|
-
function mockSearchOnce({ customer, response, nextPageToken, includeTotalResultsCount, }) {
|
|
182
|
-
return (jest
|
|
183
|
-
// @ts-expect-error private method
|
|
184
|
-
.spyOn(customer, "search")
|
|
185
|
-
// @ts-expect-error
|
|
186
|
-
.mockImplementationOnce(() => {
|
|
187
|
-
return {
|
|
188
|
-
response,
|
|
189
|
-
nextPageToken,
|
|
190
|
-
totalResultsCount: includeTotalResultsCount
|
|
191
|
-
? exports.mockTotalResultsCount
|
|
192
|
-
: undefined,
|
|
193
|
-
};
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
function mockBuildSearchStreamRequestAndService(customer) {
|
|
197
|
-
const mockStream = new stream_1.Readable({ objectMode: true });
|
|
198
|
-
const mockStreamData = (results) => {
|
|
199
|
-
const chunk = { results };
|
|
200
|
-
mockStream.push(chunk);
|
|
201
|
-
};
|
|
202
|
-
const mockStreamSummaryRow = () => {
|
|
203
|
-
const chunk = {
|
|
204
|
-
summary_row: exports.mockSummaryRow,
|
|
205
|
-
};
|
|
206
|
-
mockStream.push(chunk);
|
|
207
|
-
};
|
|
208
|
-
const mockStreamError = (error) => {
|
|
209
|
-
mockStream.destroy(error);
|
|
210
|
-
};
|
|
211
|
-
const mockStreamEnd = () => {
|
|
212
|
-
mockStream.push(null);
|
|
213
|
-
};
|
|
214
|
-
const spyBuild = jest
|
|
215
|
-
// @ts-expect-error protected method
|
|
216
|
-
.spyOn(customer, "buildSearchStreamRequestAndService")
|
|
217
|
-
// @ts-expect-error
|
|
218
|
-
.mockImplementation(() => {
|
|
219
|
-
return {
|
|
220
|
-
service: {
|
|
221
|
-
searchStream: () => mockStream,
|
|
222
|
-
},
|
|
223
|
-
request: {},
|
|
224
|
-
};
|
|
225
|
-
});
|
|
226
|
-
return {
|
|
227
|
-
spyBuild,
|
|
228
|
-
mockStreamData,
|
|
229
|
-
mockStreamSummaryRow,
|
|
230
|
-
mockStreamError,
|
|
231
|
-
mockStreamEnd,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function mockBuildSearchRequestAndService({ customer, shouldThrow = false, includeSummaryRow = false, includeTotalResultsCount = false, }) {
|
|
235
|
-
const mockService = {
|
|
236
|
-
search: () => {
|
|
237
|
-
if (shouldThrow) {
|
|
238
|
-
throw new Error(exports.mockErrorMessage);
|
|
239
|
-
}
|
|
240
|
-
const searchGoogleAdsResponse = {
|
|
241
|
-
summary_row: includeSummaryRow ? exports.mockSummaryRow : undefined,
|
|
242
|
-
total_results_count: includeTotalResultsCount
|
|
243
|
-
? exports.mockTotalResultsCount
|
|
244
|
-
: undefined,
|
|
245
|
-
};
|
|
246
|
-
return [exports.mockQueryReturnValue, null, searchGoogleAdsResponse];
|
|
247
|
-
},
|
|
248
|
-
};
|
|
249
|
-
const spyBuild = jest
|
|
250
|
-
// @ts-expect-error protected method
|
|
251
|
-
.spyOn(customer, "buildSearchRequestAndService")
|
|
252
|
-
// @ts-expect-error
|
|
253
|
-
.mockImplementation(() => {
|
|
254
|
-
return {
|
|
255
|
-
service: mockService,
|
|
256
|
-
request: {},
|
|
257
|
-
};
|
|
258
|
-
});
|
|
259
|
-
return { mockService, spyBuild };
|
|
260
|
-
}
|
|
261
|
-
function mockBuildMutateRequestAndService({ customer, shouldThrow = false, request, response, }) {
|
|
262
|
-
const mockService = {
|
|
263
|
-
mutate() {
|
|
264
|
-
if (shouldThrow) {
|
|
265
|
-
throw new Error(exports.mockErrorMessage);
|
|
266
|
-
}
|
|
267
|
-
return [response ?? exports.mockMutationReturnValue];
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
const spyBuild = jest
|
|
271
|
-
// @ts-expect-error protected method
|
|
272
|
-
.spyOn(customer, "buildMutationRequestAndService")
|
|
273
|
-
// @ts-expect-error
|
|
274
|
-
.mockImplementation(() => {
|
|
275
|
-
return {
|
|
276
|
-
service: mockService,
|
|
277
|
-
request: request ?? {},
|
|
278
|
-
};
|
|
279
|
-
});
|
|
280
|
-
return { mockService, spyBuild };
|
|
281
|
-
}
|
|
282
|
-
function mockGetGoogleAdsError(customer) {
|
|
283
|
-
return (jest
|
|
284
|
-
// @ts-expect-error protected method
|
|
285
|
-
.spyOn(customer, "getGoogleAdsError")
|
|
286
|
-
// @ts-expect-error
|
|
287
|
-
.mockImplementation(() => exports.mockError));
|
|
288
|
-
}
|
|
289
|
-
function mockQuery(customer) {
|
|
290
|
-
return (jest
|
|
291
|
-
// @ts-expect-error private method
|
|
292
|
-
.spyOn(customer, "querier")
|
|
293
|
-
// @ts-expect-error
|
|
294
|
-
.mockImplementation(() => {
|
|
295
|
-
return {
|
|
296
|
-
response: exports.mockQueryReturnValue,
|
|
297
|
-
totalResultsCount: exports.mockTotalResultsCount,
|
|
298
|
-
};
|
|
299
|
-
}));
|
|
300
|
-
}
|
|
301
|
-
function mockParse(mockParsedValues) {
|
|
302
|
-
return jest.spyOn(parser, "parse").mockImplementation(() => mockParsedValues);
|
|
303
|
-
}
|
|
304
|
-
function mockParseRest(mockParsedValues) {
|
|
305
|
-
return jest
|
|
306
|
-
.spyOn(parserRest, "decamelizeKeys")
|
|
307
|
-
.mockImplementation(() => mockParsedValues);
|
|
308
|
-
}
|
|
309
|
-
function noopParser(rows) {
|
|
310
|
-
return rows;
|
|
311
|
-
}
|
|
312
|
-
function mockMethod() {
|
|
313
|
-
return {
|
|
314
|
-
method() {
|
|
315
|
-
return;
|
|
316
|
-
},
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
function failTestIfExecuted() {
|
|
320
|
-
expect(true).toBeFalsy();
|
|
321
|
-
}
|
|
322
|
-
function newCustomer(hooks, disableParsing = false) {
|
|
323
|
-
return new customer_1.Customer({
|
|
324
|
-
client_id: exports.MOCK_CLIENT_ID,
|
|
325
|
-
client_secret: exports.MOCK_CLIENT_SECRET,
|
|
326
|
-
developer_token: exports.MOCK_DEVELOPER_TOKEN,
|
|
327
|
-
disable_parsing: disableParsing,
|
|
328
|
-
}, {
|
|
329
|
-
refresh_token: exports.MOCK_REFRESH_TOKEN,
|
|
330
|
-
customer_id: exports.MOCK_CID,
|
|
331
|
-
login_customer_id: exports.MOCK_LOGIN_CID,
|
|
332
|
-
}, hooks);
|
|
333
|
-
}
|
package/build/src/version.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const googleAdsVersion = "v24";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|